blob: d205eaf312be3173c35657f0d1461d419e7d1afc [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002/* A Bison parser, made from /Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005#define YYBISON 1 /* Identify Bison output. */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00006
Reid Spencer68a24bd2005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Dale Johannesen320fc8a2007-08-03 01:03:46 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Dale Johannesen320fc8a2007-08-03 01:03:46 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Dale Johannesen320fc8a2007-08-03 01:03:46 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define ESAPINTVAL 259
17#define EUAPINTVAL 260
18#define LOCALVAL_ID 261
19#define GLOBALVAL_ID 262
20#define FPVAL 263
21#define VOID 264
22#define INTTYPE 265
23#define FLOAT 266
24#define DOUBLE 267
25#define X86_FP80 268
26#define FP128 269
27#define PPC_FP128 270
28#define LABEL 271
29#define TYPE 272
30#define LOCALVAR 273
31#define GLOBALVAR 274
32#define LABELSTR 275
33#define STRINGCONSTANT 276
34#define ATSTRINGCONSTANT 277
35#define PCTSTRINGCONSTANT 278
36#define ZEROINITIALIZER 279
37#define TRUETOK 280
38#define FALSETOK 281
39#define BEGINTOK 282
40#define ENDTOK 283
41#define DECLARE 284
42#define DEFINE 285
43#define GLOBAL 286
44#define CONSTANT 287
45#define SECTION 288
46#define ALIAS 289
47#define VOLATILE 290
48#define THREAD_LOCAL 291
49#define TO 292
50#define DOTDOTDOT 293
51#define NULL_TOK 294
52#define UNDEF 295
53#define INTERNAL 296
54#define LINKONCE 297
55#define WEAK 298
56#define APPENDING 299
57#define DLLIMPORT 300
58#define DLLEXPORT 301
59#define EXTERN_WEAK 302
60#define OPAQUE 303
61#define EXTERNAL 304
62#define TARGET 305
63#define TRIPLE 306
64#define ALIGN 307
65#define DEPLIBS 308
66#define CALL 309
67#define TAIL 310
68#define ASM_TOK 311
69#define MODULE 312
70#define SIDEEFFECT 313
71#define CC_TOK 314
72#define CCC_TOK 315
73#define FASTCC_TOK 316
74#define COLDCC_TOK 317
75#define X86_STDCALLCC_TOK 318
76#define X86_FASTCALLCC_TOK 319
77#define DATALAYOUT 320
78#define RET 321
79#define BR 322
80#define SWITCH 323
81#define INVOKE 324
82#define UNWIND 325
83#define UNREACHABLE 326
84#define ADD 327
85#define SUB 328
86#define MUL 329
87#define UDIV 330
88#define SDIV 331
89#define FDIV 332
90#define UREM 333
91#define SREM 334
92#define FREM 335
93#define AND 336
94#define OR 337
95#define XOR 338
96#define SHL 339
97#define LSHR 340
98#define ASHR 341
99#define ICMP 342
100#define FCMP 343
101#define EQ 344
102#define NE 345
103#define SLT 346
104#define SGT 347
105#define SLE 348
106#define SGE 349
107#define ULT 350
108#define UGT 351
109#define ULE 352
110#define UGE 353
111#define OEQ 354
112#define ONE 355
113#define OLT 356
114#define OGT 357
115#define OLE 358
116#define OGE 359
117#define ORD 360
118#define UNO 361
119#define UEQ 362
120#define UNE 363
121#define MALLOC 364
122#define ALLOCA 365
123#define FREE 366
124#define LOAD 367
125#define STORE 368
126#define GETELEMENTPTR 369
127#define TRUNC 370
128#define ZEXT 371
129#define SEXT 372
130#define FPTRUNC 373
131#define FPEXT 374
132#define BITCAST 375
133#define UITOFP 376
134#define SITOFP 377
135#define FPTOUI 378
136#define FPTOSI 379
137#define INTTOPTR 380
138#define PTRTOINT 381
139#define PHI_TOK 382
140#define SELECT 383
141#define VAARG 384
142#define EXTRACTELEMENT 385
143#define INSERTELEMENT 386
144#define SHUFFLEVECTOR 387
145#define SIGNEXT 388
146#define ZEROEXT 389
147#define NORETURN 390
148#define INREG 391
149#define SRET 392
150#define NOUNWIND 393
151#define NOALIAS 394
152#define BYVAL 395
153#define NEST 396
154#define DEFAULT 397
155#define HIDDEN 398
156#define PROTECTED 399
Reid Spencer68a24bd2005-08-27 18:50:39 +0000157
Dale Johannesen320fc8a2007-08-03 01:03:46 +0000158#line 14 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000159
160#include "ParserInternals.h"
161#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000162#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000163#include "llvm/Instructions.h"
164#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000165#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000166#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000167#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000168#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000169#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000170#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000171#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000172#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000173#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000174#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000175#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000176#ifndef NDEBUG
177#define YYDEBUG 1
178#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000179
Reid Spencere4f47592006-08-18 17:32:55 +0000180// The following is a gross hack. In order to rid the libAsmParser library of
181// exceptions, we have to have a way of getting the yyparse function to go into
182// an error situation. So, whenever we want an error to occur, the GenerateError
183// function (see bottom of file) sets TriggerError. Then, at the end of each
184// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
185// (a goto) to put YACC in error state. Furthermore, several calls to
186// GenerateError are made from inside productions and they must simulate the
187// previous exception behavior by exiting the production immediately. We have
188// replaced these with the GEN_ERROR macro which calls GeneratError and then
189// immediately invokes YYERROR. This would be so much cleaner if it was a
190// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000191static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000192#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000193#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
194
Reid Spencer68a24bd2005-08-27 18:50:39 +0000195int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
196int yylex(); // declaration" of xxx warnings.
197int yyparse();
198
199namespace llvm {
200 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000201#if YYDEBUG
202static cl::opt<bool>
203Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
204 cl::Hidden, cl::init(false));
205#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000206}
207using namespace llvm;
208
209static Module *ParserResult;
210
211// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
212// relating to upreferences in the input stream.
213//
214//#define DEBUG_UPREFS 1
215#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000216#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000217#else
218#define UR_OUT(X)
219#endif
220
221#define YYERROR_VERBOSE 1
222
Chris Lattnerb475c422005-11-12 18:22:38 +0000223static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000224
225
226// This contains info used when building the body of a function. It is
227// destroyed when the function is completed.
228//
229typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000230
Reid Spencer68a24bd2005-08-27 18:50:39 +0000231static void
Reid Spencer93c40032007-03-19 18:40:50 +0000232ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000233
234static struct PerModuleInfo {
235 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000236 ValueList Values; // Module level numbered definitions
237 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000238 std::vector<PATypeHolder> Types;
239 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000240
241 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000242 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000243 /// that we can resolve them later and print error messages as appropriate.
244 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
245
246 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
247 // references to global values. Global values may be referenced before they
248 // are defined, and if so, the temporary object that they represent is held
249 // here. This is used for forward references of GlobalValues.
250 //
251 typedef std::map<std::pair<const PointerType *,
252 ValID>, GlobalValue*> GlobalRefsType;
253 GlobalRefsType GlobalRefs;
254
255 void ModuleDone() {
256 // If we could not resolve some functions at function compilation time
257 // (calls to functions before they are defined), resolve them now... Types
258 // are resolved when the constant pool has been completely parsed.
259 //
260 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000261 if (TriggerError)
262 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000263
264 // Check to make sure that all global value forward references have been
265 // resolved!
266 //
267 if (!GlobalRefs.empty()) {
268 std::string UndefinedReferences = "Unresolved global references exist:\n";
269
270 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
271 I != E; ++I) {
272 UndefinedReferences += " " + I->first.first->getDescription() + " " +
273 I->first.second.getName() + "\n";
274 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000275 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000276 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000277 }
278
279 Values.clear(); // Clear out function local definitions
280 Types.clear();
281 CurrentModule = 0;
282 }
283
Reid Spencer68a24bd2005-08-27 18:50:39 +0000284 // GetForwardRefForGlobal - Check to see if there is a forward reference
285 // for this global. If so, remove it from the GlobalRefs map and return it.
286 // If not, just return null.
287 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
288 // Check to see if there is a forward reference to this global variable...
289 // if there is, eliminate it and patch the reference to use the new def'n.
290 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
291 GlobalValue *Ret = 0;
292 if (I != GlobalRefs.end()) {
293 Ret = I->second;
294 GlobalRefs.erase(I);
295 }
296 return Ret;
297 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000298
299 bool TypeIsUnresolved(PATypeHolder* PATy) {
300 // If it isn't abstract, its resolved
301 const Type* Ty = PATy->get();
302 if (!Ty->isAbstract())
303 return false;
304 // Traverse the type looking for abstract types. If it isn't abstract then
305 // we don't need to traverse that leg of the type.
306 std::vector<const Type*> WorkList, SeenList;
307 WorkList.push_back(Ty);
308 while (!WorkList.empty()) {
309 const Type* Ty = WorkList.back();
310 SeenList.push_back(Ty);
311 WorkList.pop_back();
312 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
313 // Check to see if this is an unresolved type
314 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
315 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
316 for ( ; I != E; ++I) {
317 if (I->second.get() == OpTy)
318 return true;
319 }
320 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
321 const Type* TheTy = SeqTy->getElementType();
322 if (TheTy->isAbstract() && TheTy != Ty) {
323 std::vector<const Type*>::iterator I = SeenList.begin(),
324 E = SeenList.end();
325 for ( ; I != E; ++I)
326 if (*I == TheTy)
327 break;
328 if (I == E)
329 WorkList.push_back(TheTy);
330 }
331 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
332 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
333 const Type* TheTy = StrTy->getElementType(i);
334 if (TheTy->isAbstract() && TheTy != Ty) {
335 std::vector<const Type*>::iterator I = SeenList.begin(),
336 E = SeenList.end();
337 for ( ; I != E; ++I)
338 if (*I == TheTy)
339 break;
340 if (I == E)
341 WorkList.push_back(TheTy);
342 }
343 }
344 }
345 }
346 return false;
347 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000348} CurModule;
349
350static struct PerFunctionInfo {
351 Function *CurrentFunction; // Pointer to current function being created
352
Reid Spencer93c40032007-03-19 18:40:50 +0000353 ValueList Values; // Keep track of #'d definitions
354 unsigned NextValNum;
355 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000356 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000357 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000358 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000359
360 /// BBForwardRefs - When we see forward references to basic blocks, keep
361 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000362 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000363
364 inline PerFunctionInfo() {
365 CurrentFunction = 0;
366 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000367 Linkage = GlobalValue::ExternalLinkage;
368 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000369 }
370
371 inline void FunctionStart(Function *M) {
372 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000373 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000374 }
375
376 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000377 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000378 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000379 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000380 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000381 return;
382 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000383
384 // Resolve all forward references now.
385 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
386
387 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000388 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000389 CurrentFunction = 0;
390 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000391 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000392 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000393 }
394} CurFun; // Info for the current function...
395
396static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
397
398
399//===----------------------------------------------------------------------===//
400// Code to handle definitions of all the types
401//===----------------------------------------------------------------------===//
402
Reid Spencer93c40032007-03-19 18:40:50 +0000403static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
404 // Things that have names or are void typed don't get slot numbers
405 if (V->hasName() || (V->getType() == Type::VoidTy))
406 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000407
Reid Spencer93c40032007-03-19 18:40:50 +0000408 // In the case of function values, we have to allow for the forward reference
409 // of basic blocks, which are included in the numbering. Consequently, we keep
410 // track of the next insertion location with NextValNum. When a BB gets
411 // inserted, it could change the size of the CurFun.Values vector.
412 if (&ValueTab == &CurFun.Values) {
413 if (ValueTab.size() <= CurFun.NextValNum)
414 ValueTab.resize(CurFun.NextValNum+1);
415 ValueTab[CurFun.NextValNum++] = V;
416 return;
417 }
418 // For all other lists, its okay to just tack it on the back of the vector.
419 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000420}
421
422static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
423 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000424 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000425 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000426 if (D.Num < CurModule.Types.size())
427 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000428 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000429 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000430 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000431 D.destroy(); // Free old strdup'd memory...
432 return N;
433 }
434 break;
435 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000436 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000437 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000438 }
439
440 // If we reached here, we referenced either a symbol that we don't know about
441 // or an id number that hasn't been read yet. We may be referencing something
442 // forward, so just create an entry to be resolved later and get to it...
443 //
444 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
445
446
447 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000448 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000449 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000450 return 0;
451 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000452 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000453 return 0;
454 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000455 }
456
Reid Spencer861d9d62006-11-28 07:29:44 +0000457 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000458 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000459 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000460
Reid Spencer861d9d62006-11-28 07:29:44 +0000461 Type *Typ = OpaqueType::get();
462 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
463 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000464 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000465
Reid Spencer93c40032007-03-19 18:40:50 +0000466// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000467// the provided ValID. If the value exists and has already been defined, return
468// it. Otherwise return null.
469//
Reid Spencer93c40032007-03-19 18:40:50 +0000470static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000471 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000472 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000473 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000474 return 0;
475 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000476
477 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000478 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000479 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000480 if (D.Num >= CurFun.Values.size())
481 return 0;
482 Value *Result = CurFun.Values[D.Num];
483 if (Ty != Result->getType()) {
484 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
485 Result->getType()->getDescription() + "' does not match "
486 "expected type, '" + Ty->getDescription() + "'");
487 return 0;
488 }
489 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000490 }
491 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000492 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000493 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000494 Value *Result = CurModule.Values[D.Num];
495 if (Ty != Result->getType()) {
496 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
497 Result->getType()->getDescription() + "' does not match "
498 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000499 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000500 }
501 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000502 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000503
504 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000505 if (!inFunctionScope())
506 return 0;
507 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000508 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000509 if (N == 0)
510 return 0;
511 if (N->getType() != Ty)
512 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000513
514 D.destroy(); // Free old strdup'd memory...
515 return N;
516 }
517 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000518 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000519 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000520 if (N == 0)
521 return 0;
522 if (N->getType() != Ty)
523 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000524
525 D.destroy(); // Free old strdup'd memory...
526 return N;
527 }
528
529 // Check to make sure that "Ty" is an integral type, and that our
530 // value will fit into the specified type...
531 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000532 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000533 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000534 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000535 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000536 return 0;
537 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000538 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000539
540 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000541 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
542 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000543 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000544 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000545 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000546 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000547 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000548 }
549 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000550 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000551 }
552
553 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000554 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000555 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000556 return 0;
557 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558 return ConstantFP::get(Ty, D.ConstPoolFP);
559
560 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000561 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000562 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000563 return 0;
564 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000565 return ConstantPointerNull::get(cast<PointerType>(Ty));
566
567 case ValID::ConstUndefVal: // Is it an undef value?
568 return UndefValue::get(Ty);
569
Chris Lattner7aa61892005-12-21 17:53:23 +0000570 case ValID::ConstZeroVal: // Is it a zero value?
571 return Constant::getNullValue(Ty);
572
Reid Spencer68a24bd2005-08-27 18:50:39 +0000573 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000574 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000575 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000576 return 0;
577 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000578 return D.ConstantValue;
579
Chris Lattner0e9c3762006-01-25 22:27:16 +0000580 case ValID::InlineAsmVal: { // Inline asm expression
581 const PointerType *PTy = dyn_cast<PointerType>(Ty);
582 const FunctionType *FTy =
583 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000584 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000585 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000586 return 0;
587 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000588 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
589 D.IAD->HasSideEffects);
590 D.destroy(); // Free InlineAsmDescriptor.
591 return IA;
592 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000593 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000594 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000595 return 0;
596 } // End of switch
597
Reid Spencera9720f52007-02-05 17:04:00 +0000598 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000599 return 0;
600}
601
Reid Spencer93c40032007-03-19 18:40:50 +0000602// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000603// value is not already defined, it "improvises" by creating a placeholder var
604// that looks and acts just like the requested variable. When the value is
605// defined later, all uses of the placeholder variable are replaced with the
606// real thing.
607//
608static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000609 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000610 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000611 return 0;
612 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000613
614 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000615 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000616 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000617 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000618
Reid Spencer5b7e7532006-09-28 19:28:24 +0000619 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000620 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000621 return 0;
622 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000623
624 // If we reached here, we referenced either a symbol that we don't know about
625 // or an id number that hasn't been read yet. We may be referencing something
626 // forward, so just create an entry to be resolved later and get to it...
627 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000628 switch (ID.Type) {
629 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000630 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000631 const PointerType *PTy = dyn_cast<PointerType>(Ty);
632 if (!PTy) {
633 GenerateError("Invalid type for reference to global" );
634 return 0;
635 }
636 const Type* ElTy = PTy->getElementType();
637 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
638 V = new Function(FTy, GlobalValue::ExternalLinkage);
639 else
640 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
641 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000642 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000643 default:
644 V = new Argument(Ty);
645 }
646
Reid Spencer68a24bd2005-08-27 18:50:39 +0000647 // Remember where this forward reference came from. FIXME, shouldn't we try
648 // to recycle these things??
649 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
650 llvmAsmlineno)));
651
652 if (inFunctionScope())
653 InsertValue(V, CurFun.LateResolveValues);
654 else
655 InsertValue(V, CurModule.LateResolveValues);
656 return V;
657}
658
Reid Spencer93c40032007-03-19 18:40:50 +0000659/// defineBBVal - This is a definition of a new basic block with the specified
660/// identifier which must be the same as CurFun.NextValNum, if its numeric.
661static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000662 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000663
Reid Spencer68a24bd2005-08-27 18:50:39 +0000664 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000665
Reid Spencer93c40032007-03-19 18:40:50 +0000666 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000667
Reid Spencer93c40032007-03-19 18:40:50 +0000668 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
669 if (BBI != CurFun.BBForwardRefs.end()) {
670 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000671 // The forward declaration could have been inserted anywhere in the
672 // function: insert it into the correct place now.
673 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
674 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000675
Reid Spencer66728ef2007-03-20 01:13:36 +0000676 // We're about to erase the entry, save the key so we can clean it up.
677 ValID Tmp = BBI->first;
678
Reid Spencer93c40032007-03-19 18:40:50 +0000679 // Erase the forward ref from the map as its no longer "forward"
680 CurFun.BBForwardRefs.erase(ID);
681
Reid Spencer66728ef2007-03-20 01:13:36 +0000682 // The key has been removed from the map but so we don't want to leave
683 // strdup'd memory around so destroy it too.
684 Tmp.destroy();
685
Reid Spencer93c40032007-03-19 18:40:50 +0000686 // If its a numbered definition, bump the number and set the BB value.
687 if (ID.Type == ValID::LocalID) {
688 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
689 InsertValue(BB);
690 }
691
692 ID.destroy();
693 return BB;
694 }
695
696 // We haven't seen this BB before and its first mention is a definition.
697 // Just create it and return it.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000698 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Reid Spencer93c40032007-03-19 18:40:50 +0000699 BB = new BasicBlock(Name, CurFun.CurrentFunction);
700 if (ID.Type == ValID::LocalID) {
701 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
702 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000703 }
Reid Spencer93c40032007-03-19 18:40:50 +0000704
705 ID.destroy(); // Free strdup'd memory
706 return BB;
707}
708
709/// getBBVal - get an existing BB value or create a forward reference for it.
710///
711static BasicBlock *getBBVal(const ValID &ID) {
712 assert(inFunctionScope() && "Can't get basic block at global scope!");
713
714 BasicBlock *BB = 0;
715
716 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
717 if (BBI != CurFun.BBForwardRefs.end()) {
718 BB = BBI->second;
719 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000720 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000721 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
722 if (N)
723 if (N->getType()->getTypeID() == Type::LabelTyID)
724 BB = cast<BasicBlock>(N);
725 else
726 GenerateError("Reference to label '" + Name + "' is actually of type '"+
727 N->getType()->getDescription() + "'");
728 } else if (ID.Type == ValID::LocalID) {
729 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
730 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
731 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
732 else
733 GenerateError("Reference to label '%" + utostr(ID.Num) +
734 "' is actually of type '"+
735 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
736 }
737 } else {
738 GenerateError("Illegal label reference " + ID.getName());
739 return 0;
740 }
741
742 // If its already been defined, return it now.
743 if (BB) {
744 ID.destroy(); // Free strdup'd memory.
745 return BB;
746 }
747
748 // Otherwise, this block has not been seen before, create it.
749 std::string Name;
750 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000751 Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000752 BB = new BasicBlock(Name, CurFun.CurrentFunction);
753
754 // Insert it in the forward refs map.
755 CurFun.BBForwardRefs[ID] = BB;
756
Reid Spencer68a24bd2005-08-27 18:50:39 +0000757 return BB;
758}
759
760
761//===----------------------------------------------------------------------===//
762// Code to handle forward references in instructions
763//===----------------------------------------------------------------------===//
764//
765// This code handles the late binding needed with statements that reference
766// values not defined yet... for example, a forward branch, or the PHI node for
767// a loop body.
768//
769// This keeps a table (CurFun.LateResolveValues) of all such forward references
770// and back patchs after we are done.
771//
772
773// ResolveDefinitions - If we could not resolve some defs at parsing
774// time (forward branches, phi functions for loops, etc...) resolve the
775// defs now...
776//
777static void
Reid Spencer93c40032007-03-19 18:40:50 +0000778ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000779 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000780 while (!LateResolvers.empty()) {
781 Value *V = LateResolvers.back();
782 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000783
Reid Spencer93c40032007-03-19 18:40:50 +0000784 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
785 CurModule.PlaceHolderInfo.find(V);
786 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000787
Reid Spencer93c40032007-03-19 18:40:50 +0000788 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000789
Reid Spencer93c40032007-03-19 18:40:50 +0000790 Value *TheRealValue = getExistingVal(V->getType(), DID);
791 if (TriggerError)
792 return;
793 if (TheRealValue) {
794 V->replaceAllUsesWith(TheRealValue);
795 delete V;
796 CurModule.PlaceHolderInfo.erase(PHI);
797 } else if (FutureLateResolvers) {
798 // Functions have their unresolved items forwarded to the module late
799 // resolver table
800 InsertValue(V, *FutureLateResolvers);
801 } else {
802 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
803 GenerateError("Reference to an invalid definition: '" +DID.getName()+
804 "' of type '" + V->getType()->getDescription() + "'",
805 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000806 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000807 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000808 GenerateError("Reference to an invalid definition: #" +
809 itostr(DID.Num) + " of type '" +
810 V->getType()->getDescription() + "'",
811 PHI->second.second);
812 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000813 }
814 }
815 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000816 LateResolvers.clear();
817}
818
819// ResolveTypeTo - A brand new type was just declared. This means that (if
820// name is not null) things referencing Name can be resolved. Otherwise, things
821// refering to the number can be resolved. Do this now.
822//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000823static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000824 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000825 if (Name)
826 D = ValID::createLocalName(*Name);
827 else
828 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829
Reid Spencer861d9d62006-11-28 07:29:44 +0000830 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000831 CurModule.LateResolveTypes.find(D);
832 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000833 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000834 CurModule.LateResolveTypes.erase(I);
835 }
836}
837
838// setValueName - Set the specified value to the name given. The name may be
839// null potentially, in which case this is a noop. The string passed in is
840// assumed to be a malloc'd string buffer, and is free'd by this function.
841//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000842static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000843 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000844 std::string Name(*NameStr); // Copy string
845 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000846
Reid Spencer41dff5e2007-01-26 08:05:27 +0000847 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000848 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000849 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000850 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000851
Reid Spencera9720f52007-02-05 17:04:00 +0000852 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000853 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
854 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000855 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000856 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000857 return;
858 }
859
860 // Set the name.
861 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000862}
863
864/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
865/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000866static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000867ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000868 GlobalValue::LinkageTypes Linkage,
869 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000870 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000871 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000872 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000873 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000874 return 0;
875 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000876
877 const PointerType *PTy = PointerType::get(Ty);
878
879 std::string Name;
880 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000881 Name = *NameStr; // Copy string
882 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000883 }
884
885 // See if this global value was forward referenced. If so, recycle the
886 // object.
887 ValID ID;
888 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000889 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000890 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000891 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000892 }
893
894 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
895 // Move the global to the end of the list, from whereever it was
896 // previously inserted.
897 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
898 CurModule.CurrentModule->getGlobalList().remove(GV);
899 CurModule.CurrentModule->getGlobalList().push_back(GV);
900 GV->setInitializer(Initializer);
901 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000902 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000903 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000904 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000905 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000906 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000907 }
908
Reid Spenceref9b9a72007-02-05 20:47:22 +0000909 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +0000910 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +0000911 // if the global we're parsing has an initializer (is a definition) and
912 // has external linkage.
913 if (Initializer && Linkage != GlobalValue::InternalLinkage)
914 // If there is already a global with external linkage with this name
915 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
916 // If we allow this GVar to get created, it will be renamed in the
917 // symbol table because it conflicts with an existing GVar. We can't
918 // allow redefinition of GVars whose linking indicates that their name
919 // must stay the same. Issue the error.
920 GenerateError("Redefinition of global variable named '" + Name +
921 "' of type '" + Ty->getDescription() + "'");
922 return 0;
923 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000924 }
925
926 // Otherwise there is no existing GV to use, create one now.
927 GlobalVariable *GV =
928 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000929 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000930 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000931 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000932 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000933}
934
935// setTypeName - Set the specified type to the name given. The name may be
936// null potentially, in which case this is a noop. The string passed in is
937// assumed to be a malloc'd string buffer, and is freed by this function.
938//
939// This function returns true if the type has already been defined, but is
940// allowed to be redefined in the specified context. If the name is a new name
941// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000942static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +0000943 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000944 if (NameStr == 0) return false;
945
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000946 std::string Name(*NameStr); // Copy string
947 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000948
949 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000950 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000951 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000952 return false;
953 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000954
955 // Set the type name, checking for conflicts as we do so.
956 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
957
958 if (AlreadyExists) { // Inserting a name that is already defined???
959 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +0000960 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000961
962 // There is only one case where this is allowed: when we are refining an
963 // opaque type. In this case, Existing will be an opaque type.
964 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
965 // We ARE replacing an opaque type!
966 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
967 return true;
968 }
969
970 // Otherwise, this is an attempt to redefine a type. That's okay if
971 // the redefinition is identical to the original. This will be so if
972 // Existing and T point to the same Type object. In this one case we
973 // allow the equivalent redefinition.
974 if (Existing == T) return true; // Yes, it's equal.
975
976 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +0000977 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000978 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000979 }
980
981 return false;
982}
983
984//===----------------------------------------------------------------------===//
985// Code for handling upreferences in type names...
986//
987
988// TypeContains - Returns true if Ty directly contains E in it.
989//
990static bool TypeContains(const Type *Ty, const Type *E) {
991 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
992 E) != Ty->subtype_end();
993}
994
995namespace {
996 struct UpRefRecord {
997 // NestingLevel - The number of nesting levels that need to be popped before
998 // this type is resolved.
999 unsigned NestingLevel;
1000
1001 // LastContainedTy - This is the type at the current binding level for the
1002 // type. Every time we reduce the nesting level, this gets updated.
1003 const Type *LastContainedTy;
1004
1005 // UpRefTy - This is the actual opaque type that the upreference is
1006 // represented with.
1007 OpaqueType *UpRefTy;
1008
1009 UpRefRecord(unsigned NL, OpaqueType *URTy)
1010 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1011 };
1012}
1013
1014// UpRefs - A list of the outstanding upreferences that need to be resolved.
1015static std::vector<UpRefRecord> UpRefs;
1016
1017/// HandleUpRefs - Every time we finish a new layer of types, this function is
1018/// called. It loops through the UpRefs vector, which is a list of the
1019/// currently active types. For each type, if the up reference is contained in
1020/// the newly completed type, we decrement the level count. When the level
1021/// count reaches zero, the upreferenced type is the type that is passed in:
1022/// thus we can complete the cycle.
1023///
1024static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001025 // If Ty isn't abstract, or if there are no up-references in it, then there is
1026 // nothing to resolve here.
1027 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1028
Reid Spencer68a24bd2005-08-27 18:50:39 +00001029 PATypeHolder Ty(ty);
1030 UR_OUT("Type '" << Ty->getDescription() <<
1031 "' newly formed. Resolving upreferences.\n" <<
1032 UpRefs.size() << " upreferences active!\n");
1033
1034 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1035 // to zero), we resolve them all together before we resolve them to Ty. At
1036 // the end of the loop, if there is anything to resolve to Ty, it will be in
1037 // this variable.
1038 OpaqueType *TypeToResolve = 0;
1039
1040 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1041 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1042 << UpRefs[i].second->getDescription() << ") = "
1043 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1044 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1045 // Decrement level of upreference
1046 unsigned Level = --UpRefs[i].NestingLevel;
1047 UpRefs[i].LastContainedTy = Ty;
1048 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1049 if (Level == 0) { // Upreference should be resolved!
1050 if (!TypeToResolve) {
1051 TypeToResolve = UpRefs[i].UpRefTy;
1052 } else {
1053 UR_OUT(" * Resolving upreference for "
1054 << UpRefs[i].second->getDescription() << "\n";
1055 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1056 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1057 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1058 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1059 }
1060 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1061 --i; // Do not skip the next element...
1062 }
1063 }
1064 }
1065
1066 if (TypeToResolve) {
1067 UR_OUT(" * Resolving upreference for "
1068 << UpRefs[i].second->getDescription() << "\n";
1069 std::string OldName = TypeToResolve->getDescription());
1070 TypeToResolve->refineAbstractTypeTo(Ty);
1071 }
1072
1073 return Ty;
1074}
1075
Reid Spencer68a24bd2005-08-27 18:50:39 +00001076//===----------------------------------------------------------------------===//
1077// RunVMAsmParser - Define an interface to this parser
1078//===----------------------------------------------------------------------===//
1079//
Reid Spencer14310612006-12-31 05:40:51 +00001080static Module* RunParser(Module * M);
1081
Reid Spencer68a24bd2005-08-27 18:50:39 +00001082Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1083 set_scan_file(F);
1084
1085 CurFilename = Filename;
1086 return RunParser(new Module(CurFilename));
1087}
1088
1089Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1090 set_scan_string(AsmString);
1091
1092 CurFilename = "from_memory";
1093 if (M == NULL) {
1094 return RunParser(new Module (CurFilename));
1095 } else {
1096 return RunParser(M);
1097 }
1098}
1099
1100
Dale Johannesen320fc8a2007-08-03 01:03:46 +00001101#line 957 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
1102typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001103 llvm::Module *ModuleVal;
1104 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001105 llvm::BasicBlock *BasicBlockVal;
1106 llvm::TerminatorInst *TermInstVal;
1107 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001108 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001109
Reid Spencera132e042006-12-03 05:46:11 +00001110 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001111 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001112 llvm::PATypeHolder *TypeVal;
1113 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001114 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001115 llvm::ArgListType *ArgList;
1116 llvm::TypeWithAttrs TypeWithAttrs;
1117 llvm::TypeWithAttrsList *TypeWithAttrsList;
1118 llvm::ValueRefList *ValueRefList;
1119
Reid Spencer68a24bd2005-08-27 18:50:39 +00001120 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001121 std::list<std::pair<llvm::Value*,
1122 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001123 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001124 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001125
1126 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001127 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001128 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001129 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001130 int64_t SInt64Val;
1131 uint64_t UInt64Val;
1132 int SIntVal;
1133 unsigned UIntVal;
1134 double FPVal;
1135 bool BoolVal;
1136
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001137 std::string *StrVal; // This memory must be deleted
1138 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001139
Reid Spencera132e042006-12-03 05:46:11 +00001140 llvm::Instruction::BinaryOps BinaryOpVal;
1141 llvm::Instruction::TermOps TermOpVal;
1142 llvm::Instruction::MemoryOps MemOpVal;
1143 llvm::Instruction::CastOps CastOpVal;
1144 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001145 llvm::ICmpInst::Predicate IPredicate;
1146 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00001147} YYSTYPE;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00001148#include <stdio.h>
1149
1150#ifndef __cplusplus
1151#ifndef __STDC__
1152#define const
1153#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001154#endif
1155
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001156
Reid Spencer68a24bd2005-08-27 18:50:39 +00001157
Dale Johannesen320fc8a2007-08-03 01:03:46 +00001158#define YYFINAL 594
1159#define YYFLAG -32768
1160#define YYNTBASE 160
Reid Spencer68a24bd2005-08-27 18:50:39 +00001161
Dale Johannesen320fc8a2007-08-03 01:03:46 +00001162#define YYTRANSLATE(x) ((unsigned)(x) <= 399 ? yytranslate[x] : 241)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001163
Dale Johannesen320fc8a2007-08-03 01:03:46 +00001164static const short yytranslate[] = { 0,
1165 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1166 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1167 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1168 2, 2, 2, 2, 2, 2, 2, 2, 2, 150,
1169 151, 148, 2, 147, 2, 2, 2, 2, 2, 2,
1170 2, 2, 2, 2, 2, 2, 2, 2, 2, 155,
1171 146, 156, 2, 2, 2, 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 152, 149, 154, 2, 2, 2, 2, 2, 159, 2,
1175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1176 2, 2, 2, 2, 2, 2, 2, 2, 2, 153,
1177 2, 2, 157, 2, 158, 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, 2, 2, 2, 2, 2,
1185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1190 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1191 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1192 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1193 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1194 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1195 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1196 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1197 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1198 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1199 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1200 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1201 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1202 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1203 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
1204 137, 138, 139, 140, 141, 142, 143, 144, 145
1205};
Reid Spencerb8f85052007-07-31 03:50:36 +00001206
Dale Johannesen320fc8a2007-08-03 01:03:46 +00001207#if YYDEBUG != 0
1208static const short yyprhs[] = { 0,
1209 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1210 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1211 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1212 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1213 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1214 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
1215 120, 122, 124, 126, 127, 130, 131, 133, 135, 137,
1216 138, 141, 143, 145, 147, 149, 151, 153, 155, 157,
1217 158, 160, 162, 164, 165, 167, 169, 170, 172, 174,
1218 176, 178, 179, 181, 183, 184, 186, 188, 190, 192,
1219 194, 197, 199, 201, 203, 205, 207, 209, 211, 213,
1220 215, 216, 219, 221, 223, 225, 227, 228, 231, 232,
1221 235, 236, 240, 243, 244, 246, 247, 251, 253, 256,
1222 258, 260, 262, 264, 266, 268, 270, 272, 274, 277,
1223 279, 282, 288, 294, 300, 306, 310, 313, 319, 324,
1224 327, 329, 331, 333, 337, 339, 343, 345, 346, 348,
1225 352, 357, 361, 365, 370, 375, 379, 386, 392, 395,
1226 398, 401, 404, 407, 410, 413, 416, 419, 422, 425,
1227 428, 435, 441, 450, 457, 464, 472, 480, 487, 496,
1228 505, 509, 511, 513, 515, 517, 518, 521, 528, 530,
1229 531, 533, 536, 537, 541, 542, 546, 550, 554, 558,
1230 559, 567, 568, 577, 578, 587, 593, 596, 600, 602,
1231 606, 610, 614, 618, 620, 621, 627, 631, 633, 637,
1232 639, 640, 650, 652, 654, 659, 661, 663, 666, 670,
1233 671, 673, 675, 677, 679, 681, 683, 685, 687, 689,
1234 693, 695, 701, 703, 705, 707, 709, 711, 713, 716,
1235 719, 722, 726, 729, 730, 732, 735, 738, 742, 752,
1236 762, 771, 786, 788, 790, 797, 803, 806, 813, 821,
1237 825, 831, 832, 833, 837, 840, 842, 848, 854, 861,
1238 868, 873, 880, 885, 890, 897, 904, 907, 916, 918,
1239 920, 921, 925, 932, 936, 943, 946, 952, 960
1240};
Reid Spencerb8f85052007-07-31 03:50:36 +00001241
Dale Johannesen320fc8a2007-08-03 01:03:46 +00001242static const short yyrhs[] = { 73,
1243 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1244 0, 79, 0, 80, 0, 81, 0, 85, 0, 86,
1245 0, 87, 0, 82, 0, 83, 0, 84, 0, 116,
1246 0, 117, 0, 118, 0, 119, 0, 120, 0, 121,
1247 0, 122, 0, 123, 0, 124, 0, 125, 0, 126,
1248 0, 127, 0, 90, 0, 91, 0, 92, 0, 93,
1249 0, 94, 0, 95, 0, 96, 0, 97, 0, 98,
1250 0, 99, 0, 100, 0, 101, 0, 102, 0, 103,
1251 0, 104, 0, 105, 0, 106, 0, 107, 0, 108,
1252 0, 109, 0, 96, 0, 97, 0, 98, 0, 99,
1253 0, 26, 0, 27, 0, 11, 0, 12, 0, 13,
1254 0, 16, 0, 15, 0, 14, 0, 19, 0, 22,
1255 0, 24, 0, 167, 0, 0, 167, 146, 0, 0,
1256 20, 0, 23, 0, 172, 0, 0, 170, 146, 0,
1257 42, 0, 44, 0, 43, 0, 45, 0, 47, 0,
1258 46, 0, 48, 0, 50, 0, 0, 143, 0, 144,
1259 0, 145, 0, 0, 46, 0, 48, 0, 0, 42,
1260 0, 43, 0, 44, 0, 47, 0, 0, 44, 0,
1261 42, 0, 0, 61, 0, 62, 0, 63, 0, 64,
1262 0, 65, 0, 60, 4, 0, 135, 0, 117, 0,
1263 134, 0, 118, 0, 137, 0, 138, 0, 140, 0,
1264 141, 0, 142, 0, 0, 181, 180, 0, 136, 0,
1265 139, 0, 135, 0, 134, 0, 0, 183, 182, 0,
1266 0, 53, 4, 0, 0, 147, 53, 4, 0, 34,
1267 22, 0, 0, 186, 0, 0, 147, 189, 188, 0,
1268 186, 0, 53, 4, 0, 11, 0, 12, 0, 13,
1269 0, 16, 0, 15, 0, 14, 0, 17, 0, 49,
1270 0, 190, 0, 191, 148, 0, 225, 0, 149, 4,
1271 0, 191, 150, 195, 151, 183, 0, 10, 150, 195,
1272 151, 183, 0, 152, 4, 153, 191, 154, 0, 155,
1273 4, 153, 191, 156, 0, 157, 196, 158, 0, 157,
1274 158, 0, 155, 157, 196, 158, 156, 0, 155, 157,
1275 158, 156, 0, 191, 181, 0, 191, 0, 10, 0,
1276 192, 0, 194, 147, 192, 0, 194, 0, 194, 147,
1277 39, 0, 39, 0, 0, 191, 0, 196, 147, 191,
1278 0, 191, 152, 199, 154, 0, 191, 152, 154, 0,
1279 191, 159, 22, 0, 191, 155, 199, 156, 0, 191,
1280 157, 199, 158, 0, 191, 157, 158, 0, 191, 155,
1281 157, 199, 158, 156, 0, 191, 155, 157, 158, 156,
1282 0, 191, 40, 0, 191, 41, 0, 191, 225, 0,
1283 191, 198, 0, 191, 25, 0, 165, 3, 0, 165,
1284 5, 0, 165, 4, 0, 165, 6, 0, 11, 26,
1285 0, 11, 27, 0, 166, 9, 0, 162, 150, 197,
1286 38, 191, 151, 0, 115, 150, 197, 236, 151, 0,
1287 129, 150, 197, 147, 197, 147, 197, 151, 0, 160,
1288 150, 197, 147, 197, 151, 0, 161, 150, 197, 147,
1289 197, 151, 0, 88, 163, 150, 197, 147, 197, 151,
1290 0, 89, 164, 150, 197, 147, 197, 151, 0, 131,
1291 150, 197, 147, 197, 151, 0, 132, 150, 197, 147,
1292 197, 147, 197, 151, 0, 133, 150, 197, 147, 197,
1293 147, 197, 151, 0, 199, 147, 197, 0, 197, 0,
1294 32, 0, 33, 0, 37, 0, 0, 193, 225, 0,
1295 121, 150, 202, 38, 191, 151, 0, 204, 0, 0,
1296 205, 0, 204, 205, 0, 0, 31, 206, 221, 0,
1297 0, 30, 207, 222, 0, 58, 57, 211, 0, 169,
1298 18, 191, 0, 169, 18, 10, 0, 0, 171, 175,
1299 201, 200, 197, 208, 188, 0, 0, 171, 173, 175,
1300 201, 200, 197, 209, 188, 0, 0, 171, 174, 175,
1301 201, 200, 191, 210, 188, 0, 171, 175, 35, 178,
1302 202, 0, 51, 212, 0, 54, 146, 213, 0, 22,
1303 0, 52, 146, 22, 0, 66, 146, 22, 0, 152,
1304 214, 154, 0, 214, 147, 22, 0, 22, 0, 0,
1305 215, 147, 191, 181, 168, 0, 191, 181, 168, 0,
1306 215, 0, 215, 147, 39, 0, 39, 0, 0, 179,
1307 193, 170, 150, 216, 151, 183, 187, 184, 0, 28,
1308 0, 157, 0, 177, 175, 217, 218, 0, 29, 0,
1309 158, 0, 228, 220, 0, 176, 175, 217, 0, 0,
1310 59, 0, 3, 0, 4, 0, 9, 0, 26, 0,
1311 27, 0, 40, 0, 41, 0, 25, 0, 155, 199,
1312 156, 0, 198, 0, 57, 223, 22, 147, 22, 0,
1313 7, 0, 8, 0, 167, 0, 170, 0, 225, 0,
1314 224, 0, 191, 226, 0, 228, 229, 0, 219, 229,
1315 0, 230, 169, 231, 0, 230, 233, 0, 0, 21,
1316 0, 67, 227, 0, 67, 10, 0, 68, 17, 226,
1317 0, 68, 11, 226, 147, 17, 226, 147, 17, 226,
1318 0, 69, 165, 226, 147, 17, 226, 152, 232, 154,
1319 0, 69, 165, 226, 147, 17, 226, 152, 154, 0,
1320 70, 179, 193, 226, 150, 235, 151, 183, 38, 17,
1321 226, 71, 17, 226, 0, 71, 0, 72, 0, 232,
1322 165, 224, 147, 17, 226, 0, 165, 224, 147, 17,
1323 226, 0, 169, 238, 0, 191, 152, 226, 147, 226,
1324 154, 0, 234, 147, 152, 226, 147, 226, 154, 0,
1325 191, 226, 181, 0, 235, 147, 191, 226, 181, 0,
1326 0, 0, 236, 147, 227, 0, 56, 55, 0, 55,
1327 0, 160, 191, 226, 147, 226, 0, 161, 191, 226,
1328 147, 226, 0, 88, 163, 191, 226, 147, 226, 0,
1329 89, 164, 191, 226, 147, 226, 0, 162, 227, 38,
1330 191, 0, 129, 227, 147, 227, 147, 227, 0, 130,
1331 227, 147, 191, 0, 131, 227, 147, 227, 0, 132,
1332 227, 147, 227, 147, 227, 0, 133, 227, 147, 227,
1333 147, 227, 0, 128, 234, 0, 237, 179, 193, 226,
1334 150, 235, 151, 183, 0, 240, 0, 36, 0, 0,
1335 110, 191, 185, 0, 110, 191, 147, 11, 226, 185,
1336 0, 111, 191, 185, 0, 111, 191, 147, 11, 226,
1337 185, 0, 112, 227, 0, 239, 113, 191, 226, 185,
1338 0, 239, 114, 227, 147, 191, 226, 185, 0, 115,
1339 191, 226, 236, 0
1340};
Chris Lattner39b2e8b2007-05-04 04:01:37 +00001341
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001342#endif
1343
Dale Johannesen320fc8a2007-08-03 01:03:46 +00001344#if YYDEBUG != 0
1345static const short yyrline[] = { 0,
1346 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1117,
1347 1117, 1117, 1117, 1117, 1117, 1118, 1118, 1118, 1118, 1118,
1348 1118, 1118, 1119, 1119, 1119, 1119, 1119, 1122, 1122, 1123,
1349 1123, 1124, 1124, 1125, 1125, 1126, 1126, 1130, 1130, 1131,
1350 1131, 1132, 1132, 1133, 1133, 1134, 1134, 1135, 1135, 1136,
1351 1136, 1137, 1138, 1143, 1144, 1144, 1144, 1144, 1144, 1146,
1352 1146, 1146, 1147, 1147, 1151, 1155, 1160, 1160, 1162, 1163,
1353 1168, 1174, 1175, 1176, 1177, 1178, 1182, 1183, 1184, 1188,
1354 1189, 1190, 1191, 1195, 1196, 1197, 1201, 1202, 1203, 1204,
1355 1205, 1209, 1210, 1211, 1214, 1214, 1215, 1216, 1217, 1218,
1356 1219, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235,
1357 1238, 1239, 1244, 1245, 1246, 1247, 1250, 1251, 1258, 1258,
1358 1265, 1265, 1274, 1282, 1282, 1288, 1288, 1290, 1295, 1308,
1359 1308, 1308, 1308, 1308, 1308, 1308, 1311, 1315, 1319, 1326,
1360 1331, 1339, 1369, 1400, 1405, 1417, 1427, 1431, 1441, 1448,
1361 1455, 1462, 1467, 1472, 1479, 1480, 1487, 1494, 1502, 1508,
1362 1520, 1548, 1564, 1591, 1619, 1645, 1665, 1691, 1711, 1723,
1363 1730, 1796, 1806, 1816, 1822, 1832, 1838, 1848, 1853, 1858,
1364 1866, 1878, 1900, 1908, 1914, 1925, 1930, 1935, 1941, 1947,
1365 1956, 1960, 1968, 1968, 1971, 1971, 1974, 1985, 2006, 2011,
1366 2019, 2020, 2024, 2024, 2028, 2028, 2031, 2034, 2058, 2069,
1367 2076, 2079, 2085, 2088, 2095, 2099, 2118, 2121, 2127, 2137,
1368 2141, 2146, 2148, 2153, 2158, 2167, 2177, 2188, 2192, 2201,
1369 2210, 2215, 2336, 2336, 2338, 2347, 2347, 2349, 2354, 2366,
1370 2370, 2375, 2379, 2383, 2387, 2391, 2395, 2399, 2403, 2407,
1371 2432, 2436, 2446, 2450, 2454, 2459, 2466, 2466, 2472, 2481,
1372 2485, 2494, 2503, 2512, 2516, 2523, 2527, 2531, 2536, 2546,
1373 2565, 2574, 2654, 2658, 2665, 2676, 2689, 2699, 2710, 2720,
1374 2729, 2738, 2741, 2742, 2749, 2753, 2758, 2779, 2796, 2810,
1375 2824, 2836, 2844, 2851, 2857, 2863, 2869, 2884, 2969, 2974,
1376 2978, 2985, 2992, 3000, 3007, 3015, 3023, 3037, 3054
1377};
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","DEPLIBS","CALL",
1391"TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK",
1392"X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE",
1393"UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM",
1394"FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP","FCMP","EQ","NE","SLT","SGT",
1395"SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD",
1396"UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC",
1397"ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI",
1398"INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT",
1399"SHUFFLEVECTOR","SIGNEXT","ZEROEXT","NORETURN","INREG","SRET","NOUNWIND","NOALIAS",
1400"BYVAL","NEST","DEFAULT","HIDDEN","PROTECTED","'='","','","'*'","'\\\\'","'('",
1401"')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps","LogicalOps",
1402"CastOps","IPredicates","FPredicates","IntType","FPType","LocalName","OptLocalName",
1403"OptLocalAssign","GlobalName","OptGlobalAssign","GlobalAssign","GVInternalLinkage",
1404"GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage",
1405"AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs",
1406"OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
1407"PrimType","Types","ArgType","ResultTypes","ArgTypeList","ArgTypeListI","TypeListI",
1408"ConstVal","ConstExpr","ConstVector","GlobalType","ThreadLocal","AliaseeRef",
1409"Module","DefinitionList","Definition","@1","@2","@3","@4","@5","AsmBlock","TargetDefinition",
1410"LibrariesDefinition","LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1411"FunctionHeader","END","Function","FunctionProto","OptSideEffect","ConstValueRef",
1412"SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1413"BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall",
1414"InstVal","OptVolatile","MemoryInst", NULL
1415};
1416#endif
1417
1418static const short yyr1[] = { 0,
1419 160, 160, 160, 160, 160, 160, 160, 160, 160, 161,
1420 161, 161, 161, 161, 161, 162, 162, 162, 162, 162,
1421 162, 162, 162, 162, 162, 162, 162, 163, 163, 163,
1422 163, 163, 163, 163, 163, 163, 163, 164, 164, 164,
1423 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
1424 164, 164, 164, 165, 166, 166, 166, 166, 166, 167,
1425 167, 167, 168, 168, 169, 169, 170, 170, 171, 171,
1426 172, 173, 173, 173, 173, 173, 174, 174, 174, 175,
1427 175, 175, 175, 176, 176, 176, 177, 177, 177, 177,
1428 177, 178, 178, 178, 179, 179, 179, 179, 179, 179,
1429 179, 180, 180, 180, 180, 180, 180, 180, 180, 180,
1430 181, 181, 182, 182, 182, 182, 183, 183, 184, 184,
1431 185, 185, 186, 187, 187, 188, 188, 189, 189, 190,
1432 190, 190, 190, 190, 190, 190, 191, 191, 191, 191,
1433 191, 191, 191, 191, 191, 191, 191, 191, 191, 192,
1434 193, 193, 194, 194, 195, 195, 195, 195, 196, 196,
1435 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1436 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1437 198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
1438 199, 199, 200, 200, 201, 201, 202, 202, 203, 203,
1439 204, 204, 206, 205, 207, 205, 205, 205, 205, 208,
1440 205, 209, 205, 210, 205, 205, 205, 205, 211, 212,
1441 212, 213, 214, 214, 214, 215, 215, 216, 216, 216,
1442 216, 217, 218, 218, 219, 220, 220, 221, 222, 223,
1443 223, 224, 224, 224, 224, 224, 224, 224, 224, 224,
1444 224, 224, 225, 225, 225, 225, 226, 226, 227, 228,
1445 228, 229, 230, 230, 230, 231, 231, 231, 231, 231,
1446 231, 231, 231, 231, 232, 232, 233, 234, 234, 235,
1447 235, 235, 236, 236, 237, 237, 238, 238, 238, 238,
1448 238, 238, 238, 238, 238, 238, 238, 238, 238, 239,
1449 239, 240, 240, 240, 240, 240, 240, 240, 240
1450};
1451
1452static const short yyr2[] = { 0,
1453 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1454 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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, 0, 2, 0, 1, 1, 1, 0,
1460 2, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1461 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1462 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
1463 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1464 0, 2, 1, 1, 1, 1, 0, 2, 0, 2,
1465 0, 3, 2, 0, 1, 0, 3, 1, 2, 1,
1466 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
1467 2, 5, 5, 5, 5, 3, 2, 5, 4, 2,
1468 1, 1, 1, 3, 1, 3, 1, 0, 1, 3,
1469 4, 3, 3, 4, 4, 3, 6, 5, 2, 2,
1470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1471 6, 5, 8, 6, 6, 7, 7, 6, 8, 8,
1472 3, 1, 1, 1, 1, 0, 2, 6, 1, 0,
1473 1, 2, 0, 3, 0, 3, 3, 3, 3, 0,
1474 7, 0, 8, 0, 8, 5, 2, 3, 1, 3,
1475 3, 3, 3, 1, 0, 5, 3, 1, 3, 1,
1476 0, 9, 1, 1, 4, 1, 1, 2, 3, 0,
1477 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1478 1, 5, 1, 1, 1, 1, 1, 1, 2, 2,
1479 2, 3, 2, 0, 1, 2, 2, 3, 9, 9,
1480 8, 14, 1, 1, 6, 5, 2, 6, 7, 3,
1481 5, 0, 0, 3, 2, 1, 5, 5, 6, 6,
1482 4, 6, 4, 4, 6, 6, 2, 8, 1, 1,
1483 0, 3, 6, 3, 6, 2, 5, 7, 4
1484};
1485
1486static const short yydefact[] = { 70,
1487 60, 67, 61, 68, 62, 205, 203, 0, 0, 0,
1488 0, 0, 0, 80, 69, 70, 201, 84, 87, 0,
1489 0, 217, 0, 0, 65, 0, 71, 72, 74, 73,
1490 75, 77, 76, 78, 79, 81, 82, 83, 80, 80,
1491 196, 202, 85, 86, 80, 206, 88, 89, 90, 91,
1492 80, 264, 204, 264, 0, 0, 225, 218, 219, 207,
1493 253, 254, 209, 130, 131, 132, 135, 134, 133, 136,
1494 137, 0, 0, 0, 0, 255, 256, 138, 208, 140,
1495 196, 196, 92, 195, 0, 95, 95, 265, 261, 66,
1496 236, 237, 238, 260, 220, 221, 224, 0, 158, 141,
1497 0, 0, 0, 0, 147, 159, 0, 139, 158, 0,
1498 0, 94, 93, 0, 193, 194, 0, 0, 96, 97,
1499 98, 99, 100, 0, 239, 0, 301, 263, 0, 222,
1500 157, 111, 153, 155, 0, 0, 0, 0, 0, 0,
1501 146, 0, 0, 0, 152, 0, 151, 0, 216, 130,
1502 131, 132, 135, 134, 133, 0, 0, 0, 210, 101,
1503 0, 233, 234, 235, 300, 286, 0, 0, 0, 0,
1504 95, 273, 274, 1, 2, 3, 4, 5, 6, 7,
1505 8, 9, 13, 14, 15, 10, 11, 12, 0, 0,
1506 0, 0, 0, 0, 16, 17, 18, 19, 20, 21,
1507 22, 23, 24, 25, 26, 27, 0, 0, 0, 0,
1508 0, 0, 0, 0, 0, 262, 95, 277, 0, 299,
1509 223, 150, 0, 117, 0, 0, 149, 0, 160, 117,
1510 212, 214, 0, 197, 178, 179, 174, 176, 175, 177,
1511 180, 173, 169, 170, 0, 0, 0, 0, 0, 0,
1512 0, 0, 0, 0, 0, 0, 0, 0, 172, 171,
1513 126, 0, 285, 267, 0, 266, 0, 0, 54, 0,
1514 0, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1515 37, 0, 52, 53, 48, 49, 50, 51, 38, 39,
1516 40, 41, 42, 43, 44, 45, 46, 47, 0, 121,
1517 121, 306, 0, 0, 297, 0, 0, 0, 0, 0,
1518 0, 0, 0, 0, 0, 0, 103, 105, 104, 102,
1519 106, 107, 108, 109, 110, 112, 156, 154, 143, 144,
1520 145, 148, 142, 126, 126, 0, 0, 0, 0, 0,
1521 0, 0, 0, 162, 192, 0, 0, 0, 166, 0,
1522 163, 0, 0, 0, 0, 211, 231, 242, 243, 244,
1523 249, 245, 246, 247, 248, 240, 0, 251, 258, 257,
1524 259, 0, 268, 0, 0, 0, 0, 0, 302, 0,
1525 304, 283, 0, 0, 0, 0, 0, 0, 0, 0,
1526 0, 0, 0, 0, 0, 116, 115, 113, 114, 118,
1527 213, 215, 0, 0, 0, 283, 0, 0, 0, 0,
1528 0, 161, 147, 159, 0, 164, 165, 0, 0, 0,
1529 0, 0, 128, 126, 230, 111, 228, 0, 241, 0,
1530 0, 0, 0, 0, 0, 0, 0, 0, 0, 309,
1531 0, 0, 0, 293, 294, 0, 0, 0, 0, 291,
1532 0, 121, 0, 0, 0, 0, 0, 0, 0, 0,
1533 0, 191, 168, 0, 0, 0, 0, 123, 129, 127,
1534 64, 0, 117, 0, 250, 0, 0, 282, 0, 0,
1535 121, 122, 121, 0, 0, 0, 0, 0, 0, 287,
1536 288, 282, 0, 307, 0, 198, 0, 0, 182, 0,
1537 0, 0, 0, 167, 0, 0, 0, 63, 227, 229,
1538 111, 124, 0, 0, 0, 0, 0, 289, 290, 303,
1539 305, 284, 0, 0, 292, 295, 296, 0, 121, 0,
1540 0, 0, 188, 0, 0, 184, 185, 181, 64, 125,
1541 119, 252, 0, 0, 111, 0, 117, 278, 0, 117,
1542 308, 186, 187, 0, 0, 0, 226, 0, 232, 0,
1543 271, 0, 0, 280, 0, 0, 279, 298, 183, 189,
1544 190, 120, 269, 0, 270, 0, 111, 0, 0, 0,
1545 281, 0, 0, 0, 0, 276, 0, 0, 275, 0,
1546 272, 0, 0, 0
1547};
1548
1549static const short yydefgoto[] = { 256,
1550 257, 258, 282, 299, 156, 157, 76, 509, 12, 77,
1551 14, 15, 39, 40, 41, 45, 51, 114, 124, 326,
1552 222, 400, 329, 559, 379, 423, 541, 356, 424, 78,
1553 158, 133, 148, 134, 135, 107, 345, 368, 346, 117,
1554 85, 149, 592, 16, 17, 19, 18, 261, 334, 335,
1555 60, 22, 58, 98, 427, 428, 125, 164, 52, 93,
1556 53, 46, 430, 369, 80, 371, 266, 54, 89, 90,
1557 216, 563, 128, 305, 517, 440, 217, 218, 219, 220
1558};
1559
1560static const short yypact[] = { 42,
1561-32768,-32768,-32768,-32768,-32768,-32768,-32768, -21, -131, 60,
1562 -93, 105, -22, 182,-32768, 525,-32768, 46, 168, -12,
1563 19,-32768, 1, 152,-32768, 1277,-32768,-32768,-32768,-32768,
1564-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 90, 90,
1565 100,-32768,-32768,-32768, 90,-32768,-32768,-32768,-32768,-32768,
1566 90, 186,-32768, 12, 187, 201, 209,-32768,-32768,-32768,
1567-32768,-32768, 93,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1568-32768, 252, 254, 2, 907,-32768,-32768,-32768, 13,-32768,
1569 225, 225, 150,-32768, 76, 116, 116,-32768,-32768, 108,
1570-32768,-32768,-32768,-32768,-32768,-32768,-32768, -79, 1027,-32768,
1571 111, 114, 947, 93,-32768, 13, -104,-32768, 1027, 76,
1572 76,-32768,-32768, 1067,-32768,-32768, 1299, 266,-32768,-32768,
1573-32768,-32768,-32768, 1330,-32768, -16, 1572,-32768, 256,-32768,
1574-32768, 13,-32768, 139, 144, 1370, 1370, 132, -95, 1370,
1575-32768, 145, 1299, 1370, 93, 147, 13, 311,-32768, 43,
1576 290, 293, 298, 299, 302, 247, 303, 724,-32768,-32768,
1577 35,-32768,-32768,-32768,-32768,-32768, 258, 1450, 70, 305,
1578 116,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1579-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 317, 405,
1580 1370, 1370, 1370, 1370,-32768,-32768,-32768,-32768,-32768,-32768,
1581-32768,-32768,-32768,-32768,-32768,-32768, 1370, 1370, 1370, 1370,
1582 1370, 1370, 1370, 1370, 1370,-32768, 116,-32768, 34,-32768,
1583-32768, 131, 1107,-32768, 6, -46,-32768, 164, 13,-32768,
1584-32768, 13, 1067,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1585-32768,-32768,-32768,-32768, 317, 405, 173, 178, 179, 189,
1586 192, 1179, 1481, 987, 314, 193, 197, 198,-32768,-32768,
1587 202, 203,-32768, 93, 565,-32768, 699, 699,-32768, 699,
1588 1330,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1589-32768, 1370,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1590-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1370, 113,
1591 137,-32768, 565, -10, 205, 207, 208, 210, 218, 219,
1592 565, 565, 330, 1330, 1370, 1370,-32768,-32768,-32768,-32768,
1593-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 106,-32768,
1594-32768,-32768, 106, 202, 202, 331, 220, 221, 1299, 1299,
1595 1299, 1299, 1299,-32768,-32768, -41, 1005, -61,-32768, -91,
1596-32768, 1299, 1299, 1299, -13,-32768, 1219,-32768,-32768,-32768,
1597-32768,-32768,-32768,-32768,-32768, 313, 1299,-32768,-32768,-32768,
1598-32768, 226,-32768, 227, 699, 565, 565, 23,-32768, 24,
1599-32768,-32768, 699, 223, 1370, 1370, 1370, 1370, 1370, 232,
1600 233, 1370, 699, 565, 234,-32768,-32768,-32768,-32768,-32768,
1601-32768,-32768, 1370, 1299, 1299,-32768, 235, 236, 237, 239,
1602 1299,-32768, 231, 724, -76,-32768,-32768, 241, 242, 352,
1603 369, 388,-32768, 202,-32768, 13, 246, 243,-32768, 374,
1604 -59, 380, 385, 253, 257, 270, 699, 414, 699, 272,
1605 273, 699, 278, 13,-32768, 280, 282, 699, 699, 13,
1606 283, 287, 1370, -112, 288, 289, -33, 1299, 1299, 1299,
1607 1299,-32768,-32768, 294, 1299, 1299, 1370,-32768,-32768,-32768,
1608 79, 1259,-32768, 292,-32768, 699, 699, 1370, 699, 699,
1609 287,-32768, 287, 1370, 699, 307, 1370, 1370, 1370,-32768,
1610-32768, 1370, 392,-32768, 565,-32768, 1299, 1299,-32768, 308,
1611 295, 309, 310,-32768, 301, 315, 7,-32768,-32768,-32768,
1612 13, 10, 427, 318, 306, 565, 52,-32768,-32768,-32768,
1613-32768,-32768, 316, 699,-32768,-32768,-32768, 71, 287, 322,
1614 325, 1299,-32768, 1299, 1299,-32768,-32768,-32768, 79,-32768,
1615 407,-32768, 444, -4,-32768, 1370,-32768,-32768, 323,-32768,
1616-32768,-32768,-32768, 327, 328, 329,-32768, 464,-32768, 699,
1617-32768, 859, -3, 131, 565, -14,-32768, 106,-32768,-32768,
1618-32768,-32768,-32768, 334,-32768, 859,-32768, 452, 465, 336,
1619 131, 699, 699, 468, 416,-32768, 699, 471,-32768, 699,
1620-32768, 490, 491,-32768
1621};
1622
1623static const short yypgoto[] = { 365,
1624 366, 367, 255, 251, -168,-32768, 0, -40, 408, 14,
1625-32768,-32768,-32768,-32768, 40,-32768,-32768,-32768, -158,-32768,
1626 -406,-32768, -226,-32768, -290, 3,-32768, -317,-32768,-32768,
1627 -25, 296, -119,-32768, 409, 413, -60, -155, -231, 166,
1628 119, 284,-32768,-32768, 504,-32768,-32768,-32768,-32768,-32768,
1629-32768,-32768,-32768,-32768,-32768,-32768, 435,-32768,-32768,-32768,
1630-32768,-32768,-32768, -525, -139, 47, -183,-32768, 474,-32768,
1631-32768,-32768,-32768,-32768, 37, 124,-32768,-32768,-32768,-32768
1632};
1633
1634
1635#define YYLAST 1705
1636
1637
1638static const short yytable[] = { 11,
1639 79, 270, 259, 333, 161, 102, 269, 269, 234, 302,
1640 381, 162, 271, 13, 23, 11, 401, 402, 260, 471,
1641 421, 348, 350, 578, 306, 307, 308, 309, 310, 13,
1642 20, 313, 88, 437, 439, 108, 574, 109, 496, 422,
1643 91, -200, 140, 421, 21, -54, -54, -54, -54, 106,
1644 580, 140, 25, 141, 2, 411, 159, 4, 314, -66,
1645 1, 2, 228, 3, 4, 5, 417, 129, 235, 236,
1646 411, 6, 7, 132, 130, 438, 438, 106, 81, 82,
1647 267, 464, 231, 132, 86, 411, 268, 411, 147, 11,
1648 87, 43, 8, 44, 416, 9, 475, 1, 147, 10,
1649 3, 108, 5, 109, 539, 411, 470, 115, 116, 331,
1650 225, 226, 412, 484, 229, 415, 24, 499, 232, 396,
1651 397, 398, 26, 27, 399, 370, 1, 370, 370, 3,
1652 370, 5, 395, 55, 83, 431, 84, 108, 564, 109,
1653 163, 383, 265, 396, 397, 398, 315, 316, 399, 561,
1654 575, 375, 57, 108, 108, 109, 109, 538, 103, 330,
1655 108, 494, 109, 370, 56, 300, 301, 265, 303, 92,
1656 581, 370, 370, 59, 262, 118, 119, 120, 121, 122,
1657 123, 304, 265, 265, 265, 265, 265, 311, 312, 265,
1658 520, 112, 521, 113, 393, 317, 318, 132, 546, 110,
1659 111, 443, 547, 445, 446, 447, 88, 147, 95, 47,
1660 48, 49, 319, 320, 50, 321, 322, 546, 323, 324,
1661 325, 550, 96, 28, 29, 30, 31, 32, 33, 34,
1662 97, 35, 36, 37, 38, 370, 370, 370, 551, 396,
1663 397, 398, 99, 370, 399, 147, 512, 317, 318, 237,
1664 238, 239, 240, 370, 370, 100, 376, 101, 259, 378,
1665 108, 84, 109, 136, 319, 320, 137, 321, 322, 160,
1666 323, 324, 325, 377, 260, 143, 144, 221, 406, 407,
1667 408, 409, 410, 380, 108, 223, 109, 227, 147, 394,
1668 265, 418, 419, 420, 224, 230, 233, 370, -55, 370,
1669 522, -56, 370, 525, 526, 527, -59, -58, 370, 370,
1670 -57, 241, 263, 372, 373, 269, 374, 61, 62, 332,
1671 566, 414, 339, 568, 36, 37, 38, 340, 341, 1,
1672 2, 426, 3, 4, 5, 351, 370, 370, 342, 370,
1673 370, 343, 352, 455, 456, 370, 353, 354, 355, 382,
1674 462, 384, 357, 385, 386, 370, 387, 390, 391, 265,
1675 444, 265, 265, 265, 388, 389, 450, 392, 403, 404,
1676 405, 429, 432, 433, 442, 562, 370, 454, 448, 449,
1677 453, 458, 459, 460, 370, 461, 463, 465, 466, 467,
1678 468, 469, 472, 473, 576, 474, 476, 500, 501, 502,
1679 503, 477, 478, 479, 505, 506, 272, 273, 274, 275,
1680 276, 277, 278, 279, 280, 281, 480, 482, 484, 485,
1681 370, 434, 435, 436, 487, 370, 488, 495, 489, 441,
1682 283, 284, 492, 493, 497, 498, 530, 531, 513, 451,
1683 452, 507, 370, 370, 438, 533, 511, 370, 542, 504,
1684 370, 536, 516, 524, 532, 534, 535, 544, 265, 558,
1685 560, 265, 265, 265, 543, 537, 516, 572, 582, 548,
1686 508, 554, 552, 555, 556, 553, 567, 569, 570, 571,
1687 579, 583, 584, 481, 587, 483, 588, 590, 486, 593,
1688 594, 213, 214, 215, 490, 491, 338, 127, 557, 337,
1689 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1690 295, 296, 297, 298, 540, 139, 336, 142, 328, 42,
1691 565, 126, 514, 515, -199, 518, 519, 94, 528, 457,
1692 0, 523, 0, 0, 0, 0, 0, 0, 508, 0,
1693 0, 529, -66, 1, 2, 0, 3, 4, 5, 0,
1694 0, 0, 0, 0, 6, 7, 0, 0, 0, 0,
1695 0, 0, 545, 0, 0, 0, 0, 358, 359, 0,
1696 549, 61, 62, 360, 0, 8, 0, 0, 9, 0,
1697 0, 0, 10, 1, 2, 0, 3, 4, 5, 361,
1698 362, 363, 0, 0, 0, 0, 0, 0, 0, 0,
1699 0, 0, 0, 0, 364, 365, 573, 0, 0, 0,
1700 0, 577, 0, 0, 0, 0, 0, 0, 0, 0,
1701 0, 366, 0, 0, 0, 0, 0, 0, 585, 586,
1702 0, 0, 0, 589, 0, 0, 591, 174, 175, 176,
1703 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
1704 187, 188, 245, 246, 0, 0, 0, 0, 0, 0,
1705 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1706 0, 0, 0, 0, 0, 0, 0, 0, 0, 247,
1707 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
1708 205, 206, 0, 248, 0, 249, 250, 251, 0, 0,
1709 0, 358, 359, 0, 0, 61, 62, 360, 0, 0,
1710 0, 0, 108, 0, 109, 0, 0, 1, 2, 367,
1711 3, 4, 5, 361, 362, 363, 0, 0, 0, 0,
1712 61, 62, 0, 0, 0, 0, 0, 0, 364, 365,
1713 0, 0, 1, 2, 0, 3, 4, 5, 242, 0,
1714 0, 0, 0, 0, 0, 366, 0, 0, 0, 0,
1715 0, 0, 0, 243, 244, 0, 0, 0, 0, 0,
1716 0, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1717 183, 184, 185, 186, 187, 188, 245, 246, 0, 0,
1718 0, 0, 0, 0, 0, 0, 174, 175, 176, 177,
1719 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
1720 188, 245, 246, 247, 195, 196, 197, 198, 199, 200,
1721 201, 202, 203, 204, 205, 206, 0, 248, 0, 249,
1722 250, 251, 0, 0, 0, 0, 0, 0, 247, 195,
1723 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
1724 206, 0, 248, 367, 249, 250, 251, 0, 0, 0,
1725 0, 358, 359, 0, 0, 0, 0, 360, 0, 0,
1726 0, 108, 0, 109, 0, 252, 0, 0, 253, 0,
1727 254, 0, 255, 361, 362, 363, 0, 0, 0, 0,
1728 0, 0, 0, 0, 0, 0, 0, 0, 364, 365,
1729 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1730 0, 0, 0, 61, 62, 366, 104, 64, 65, 66,
1731 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1732 5, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1733 183, 184, 185, 186, 187, 188, 245, 246, 0, 0,
1734 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1735 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1736 5, 0, 0, 247, 195, 196, 197, 198, 199, 200,
1737 201, 202, 203, 204, 205, 206, 0, 248, 0, 249,
1738 250, 251, 0, 61, 62, 71, 104, 150, 151, 152,
1739 153, 154, 155, 70, 0, 1, 2, 0, 3, 4,
1740 5, 61, 62, 367, 104, 150, 151, 152, 153, 154,
1741 155, 70, 0, 1, 2, 0, 3, 4, 5, 0,
1742 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1743 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1744 5, 0, 0, 71, 0, 72, 0, 0, 73, 0,
1745 0, 74, 0, 75, 105, 131, 0, 0, 0, 0,
1746 0, 0, 0, 61, 62, 71, 145, 64, 65, 66,
1747 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1748 5, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1749 0, 74, 0, 75, 138, 0, 0, 0, 0, 0,
1750 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1751 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1752 5, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1753 0, 74, 0, 75, 349, 327, 0, 0, 0, 0,
1754 0, 0, 0, 72, 0, 71, 73, 0, 0, 74,
1755 0, 75, 413, 0, 0, 0, 0, 0, 0, 0,
1756 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1757 0, 74, 0, 75, 0, 61, 62, 146, 104, 150,
1758 151, 152, 153, 154, 155, 70, 0, 1, 2, 0,
1759 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1760 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1761 0, 74, 0, 75, 0, 61, 62, 71, 104, 64,
1762 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1763 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1764 0, 0, 0, 0, 0, 72, 0, 425, 73, 0,
1765 0, 74, 0, 75, 0, 61, 62, 71, 104, 64,
1766 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1767 3, 4, 5, 61, 62, 0, 63, 64, 65, 66,
1768 67, 68, 69, 70, 0, 1, 2, 510, 3, 4,
1769 5, 0, 0, 0, 0, 61, 62, 71, 104, 150,
1770 151, 152, 153, 154, 155, 70, 0, 1, 2, 0,
1771 3, 4, 5, 0, 0, 71, 0, 72, 0, 0,
1772 73, 0, 344, 74, 0, 75, 61, 62, 0, 145,
1773 64, 65, 66, 67, 68, 69, 70, 71, 1, 2,
1774 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1775 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1776 73, 0, 0, 74, 0, 75, 61, 62, 71, 104,
1777 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1778 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1779 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1780 73, 0, 0, 74, 0, 75, 0, 0, 71, 0,
1781 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1782 0, 74, 0, 75, 0, 0, 0, 0, 0, 0,
1783 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1784 73, 0, 0, 74, 0, 75, 61, 62, 0, 264,
1785 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1786 0, 3, 4, 5, 0, 0, 0, 0, 72, 0,
1787 0, 73, 0, 0, 74, 0, 75, 61, 62, 0,
1788 104, 150, 151, 152, 153, 154, 155, 70, 71, 1,
1789 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
1790 0, 0, 0, 0, 0, 0, 0, 0, 72, 0,
1791 0, 73, 0, 0, 74, 0, 75, 0, 0, 71,
1792 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1793 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1794 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1795 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1796 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1797 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1798 0, 0, 0, 0, 0, 0, 0, 0, 72, 0,
1799 0, 73, 0, 0, 74, 0, 75, 165, 0, 0,
1800 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1801 0, 0, 0, 0, 0, 0, 166, 167, 0, 72,
1802 0, 0, 73, 0, 0, 74, 0, 347, 168, 169,
1803 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
1804 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
1805 190, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1806 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1807 0, 191, 192, 193, 0, 0, 194, 195, 196, 197,
1808 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
1809 208, 209, 210, 211, 212
1810};
1811
1812static const short yycheck[] = { 0,
1813 26, 170, 158, 230, 124, 4, 11, 11, 148, 193,
1814 301, 28, 171, 0, 146, 16, 334, 335, 158, 426,
1815 34, 253, 254, 38, 208, 209, 210, 211, 212, 16,
1816 52, 215, 21, 11, 11, 148, 562, 150, 151, 53,
1817 29, 0, 147, 34, 66, 3, 4, 5, 6, 75,
1818 576, 147, 146, 158, 20, 147, 117, 23, 217, 18,
1819 19, 20, 158, 22, 23, 24, 158, 147, 26, 27,
1820 147, 30, 31, 99, 154, 53, 53, 103, 39, 40,
1821 11, 158, 143, 109, 45, 147, 17, 147, 114, 90,
1822 51, 46, 51, 48, 156, 54, 156, 19, 124, 58,
1823 22, 148, 24, 150, 511, 147, 424, 32, 33, 156,
1824 136, 137, 154, 147, 140, 347, 57, 151, 144, 134,
1825 135, 136, 18, 146, 139, 265, 19, 267, 268, 22,
1826 270, 24, 316, 146, 35, 367, 37, 148, 545, 150,
1827 157, 152, 168, 134, 135, 136, 113, 114, 139, 154,
1828 154, 271, 152, 148, 148, 150, 150, 151, 157, 154,
1829 148, 452, 150, 303, 146, 191, 192, 193, 194, 158,
1830 577, 311, 312, 22, 161, 60, 61, 62, 63, 64,
1831 65, 207, 208, 209, 210, 211, 212, 213, 214, 215,
1832 481, 42, 483, 44, 314, 117, 118, 223, 147, 81,
1833 82, 385, 151, 387, 388, 389, 21, 233, 22, 42,
1834 43, 44, 134, 135, 47, 137, 138, 147, 140, 141,
1835 142, 151, 22, 42, 43, 44, 45, 46, 47, 48,
1836 22, 50, 143, 144, 145, 375, 376, 377, 529, 134,
1837 135, 136, 150, 383, 139, 271, 473, 117, 118, 3,
1838 4, 5, 6, 393, 394, 4, 282, 4, 414, 147,
1839 148, 37, 150, 153, 134, 135, 153, 137, 138, 4,
1840 140, 141, 142, 299, 414, 110, 111, 22, 339, 340,
1841 341, 342, 343, 147, 148, 147, 150, 156, 314, 315,
1842 316, 352, 353, 354, 151, 151, 150, 437, 9, 439,
1843 484, 9, 442, 487, 488, 489, 9, 9, 448, 449,
1844 9, 9, 55, 267, 268, 11, 270, 7, 8, 156,
1845 547, 347, 150, 550, 143, 144, 145, 150, 150, 19,
1846 20, 357, 22, 23, 24, 22, 476, 477, 150, 479,
1847 480, 150, 150, 404, 405, 485, 150, 150, 147, 303,
1848 411, 147, 150, 147, 147, 495, 147, 311, 312, 385,
1849 386, 387, 388, 389, 147, 147, 392, 38, 38, 150,
1850 150, 59, 147, 147, 152, 544, 516, 403, 147, 147,
1851 147, 147, 147, 147, 524, 147, 156, 147, 147, 38,
1852 22, 4, 147, 151, 563, 22, 17, 458, 459, 460,
1853 461, 17, 150, 147, 465, 466, 90, 91, 92, 93,
1854 94, 95, 96, 97, 98, 99, 147, 4, 147, 147,
1855 560, 375, 376, 377, 147, 565, 147, 453, 147, 383,
1856 26, 27, 150, 147, 147, 147, 497, 498, 147, 393,
1857 394, 467, 582, 583, 53, 151, 472, 587, 22, 156,
1858 590, 151, 478, 147, 147, 147, 147, 152, 484, 53,
1859 17, 487, 488, 489, 147, 151, 492, 4, 17, 154,
1860 471, 532, 151, 534, 535, 151, 154, 151, 151, 151,
1861 147, 17, 147, 437, 17, 439, 71, 17, 442, 0,
1862 0, 127, 127, 127, 448, 449, 246, 90, 539, 245,
1863 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
1864 106, 107, 108, 109, 512, 103, 233, 109, 223, 16,
1865 546, 87, 476, 477, 0, 479, 480, 54, 492, 406,
1866 -1, 485, -1, -1, -1, -1, -1, -1, 539, -1,
1867 -1, 495, 18, 19, 20, -1, 22, 23, 24, -1,
1868 -1, -1, -1, -1, 30, 31, -1, -1, -1, -1,
1869 -1, -1, 516, -1, -1, -1, -1, 3, 4, -1,
1870 524, 7, 8, 9, -1, 51, -1, -1, 54, -1,
1871 -1, -1, 58, 19, 20, -1, 22, 23, 24, 25,
1872 26, 27, -1, -1, -1, -1, -1, -1, -1, -1,
1873 -1, -1, -1, -1, 40, 41, 560, -1, -1, -1,
1874 -1, 565, -1, -1, -1, -1, -1, -1, -1, -1,
1875 -1, 57, -1, -1, -1, -1, -1, -1, 582, 583,
1876 -1, -1, -1, 587, -1, -1, 590, 73, 74, 75,
1877 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1878 86, 87, 88, 89, -1, -1, -1, -1, -1, -1,
1879 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1880 -1, -1, -1, -1, -1, -1, -1, -1, -1, 115,
1881 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1882 126, 127, -1, 129, -1, 131, 132, 133, -1, -1,
1883 -1, 3, 4, -1, -1, 7, 8, 9, -1, -1,
1884 -1, -1, 148, -1, 150, -1, -1, 19, 20, 155,
1885 22, 23, 24, 25, 26, 27, -1, -1, -1, -1,
1886 7, 8, -1, -1, -1, -1, -1, -1, 40, 41,
1887 -1, -1, 19, 20, -1, 22, 23, 24, 25, -1,
1888 -1, -1, -1, -1, -1, 57, -1, -1, -1, -1,
1889 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
1890 -1, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1891 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1892 -1, -1, -1, -1, -1, -1, 73, 74, 75, 76,
1893 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1894 87, 88, 89, 115, 116, 117, 118, 119, 120, 121,
1895 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
1896 132, 133, -1, -1, -1, -1, -1, -1, 115, 116,
1897 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1898 127, -1, 129, 155, 131, 132, 133, -1, -1, -1,
1899 -1, 3, 4, -1, -1, -1, -1, 9, -1, -1,
1900 -1, 148, -1, 150, -1, 152, -1, -1, 155, -1,
1901 157, -1, 159, 25, 26, 27, -1, -1, -1, -1,
1902 -1, -1, -1, -1, -1, -1, -1, -1, 40, 41,
1903 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1904 -1, -1, -1, 7, 8, 57, 10, 11, 12, 13,
1905 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1906 24, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1907 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1908 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1909 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1910 24, -1, -1, 115, 116, 117, 118, 119, 120, 121,
1911 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
1912 132, 133, -1, 7, 8, 49, 10, 11, 12, 13,
1913 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1914 24, 7, 8, 155, 10, 11, 12, 13, 14, 15,
1915 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
1916 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1917 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1918 24, -1, -1, 49, -1, 149, -1, -1, 152, -1,
1919 -1, 155, -1, 157, 158, 39, -1, -1, -1, -1,
1920 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1921 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1922 24, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1923 -1, 155, -1, 157, 158, -1, -1, -1, -1, -1,
1924 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1925 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1926 24, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1927 -1, 155, -1, 157, 158, 39, -1, -1, -1, -1,
1928 -1, -1, -1, 149, -1, 49, 152, -1, -1, 155,
1929 -1, 157, 158, -1, -1, -1, -1, -1, -1, -1,
1930 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1931 -1, 155, -1, 157, -1, 7, 8, 121, 10, 11,
1932 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1933 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
1934 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1935 -1, 155, -1, 157, -1, 7, 8, 49, 10, 11,
1936 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1937 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
1938 -1, -1, -1, -1, -1, 149, -1, 39, 152, -1,
1939 -1, 155, -1, 157, -1, 7, 8, 49, 10, 11,
1940 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1941 22, 23, 24, 7, 8, -1, 10, 11, 12, 13,
1942 14, 15, 16, 17, -1, 19, 20, 39, 22, 23,
1943 24, -1, -1, -1, -1, 7, 8, 49, 10, 11,
1944 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1945 22, 23, 24, -1, -1, 49, -1, 149, -1, -1,
1946 152, -1, 154, 155, -1, 157, 7, 8, -1, 10,
1947 11, 12, 13, 14, 15, 16, 17, 49, 19, 20,
1948 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
1949 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1950 152, -1, -1, 155, -1, 157, 7, 8, 49, 10,
1951 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
1952 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
1953 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1954 152, -1, -1, 155, -1, 157, -1, -1, 49, -1,
1955 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1956 -1, 155, -1, 157, -1, -1, -1, -1, -1, -1,
1957 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1958 152, -1, -1, 155, -1, 157, 7, 8, -1, 10,
1959 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
1960 -1, 22, 23, 24, -1, -1, -1, -1, 149, -1,
1961 -1, 152, -1, -1, 155, -1, 157, 7, 8, -1,
1962 10, 11, 12, 13, 14, 15, 16, 17, 49, 19,
1963 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
1964 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
1965 -1, 152, -1, -1, 155, -1, 157, -1, -1, 49,
1966 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1967 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1968 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1969 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1970 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1971 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1972 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
1973 -1, 152, -1, -1, 155, -1, 157, 36, -1, -1,
1974 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1975 -1, -1, -1, -1, -1, -1, 55, 56, -1, 149,
1976 -1, -1, 152, -1, -1, 155, -1, 157, 67, 68,
1977 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1978 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1979 89, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1980 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1981 -1, 110, 111, 112, -1, -1, 115, 116, 117, 118,
1982 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
1983 129, 130, 131, 132, 133
1984};
1985/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1986#line 3 "/usr/share/bison.simple"
1987/* This file comes from bison-1.28. */
1988
1989/* Skeleton output parser for bison,
1990 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1991
1992 This program is free software; you can redistribute it and/or modify
1993 it under the terms of the GNU General Public License as published by
1994 the Free Software Foundation; either version 2, or (at your option)
1995 any later version.
1996
1997 This program is distributed in the hope that it will be useful,
1998 but WITHOUT ANY WARRANTY; without even the implied warranty of
1999 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2000 GNU General Public License for more details.
2001
2002 You should have received a copy of the GNU General Public License
2003 along with this program; if not, write to the Free Software
2004 Foundation, Inc., 59 Temple Place - Suite 330,
2005 Boston, MA 02111-1307, USA. */
2006
2007/* As a special exception, when this file is copied by Bison into a
2008 Bison output file, you may use that output file without restriction.
2009 This special exception was added by the Free Software Foundation
2010 in version 1.24 of Bison. */
2011
2012/* This is the parser code that is written into each bison parser
2013 when the %semantic_parser declaration is not specified in the grammar.
2014 It was written by Richard Stallman by simplifying the hairy parser
2015 used when %semantic_parser is specified. */
2016
2017#ifndef YYSTACK_USE_ALLOCA
2018#ifdef alloca
2019#define YYSTACK_USE_ALLOCA
2020#else /* alloca not defined */
2021#ifdef __GNUC__
2022#define YYSTACK_USE_ALLOCA
2023#define alloca __builtin_alloca
2024#else /* not GNU C. */
2025#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2026#define YYSTACK_USE_ALLOCA
2027#include <alloca.h>
2028#else /* not sparc */
2029/* We think this test detects Watcom and Microsoft C. */
2030/* This used to test MSDOS, but that is a bad idea
2031 since that symbol is in the user namespace. */
2032#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2033#if 0 /* No need for malloc.h, which pollutes the namespace;
2034 instead, just don't use alloca. */
2035#include <malloc.h>
2036#endif
2037#else /* not MSDOS, or __TURBOC__ */
2038#if defined(_AIX)
2039/* I don't know what this was needed for, but it pollutes the namespace.
2040 So I turned it off. rms, 2 May 1997. */
2041/* #include <malloc.h> */
2042 #pragma alloca
2043#define YYSTACK_USE_ALLOCA
2044#else /* not MSDOS, or __TURBOC__, or _AIX */
2045#if 0
2046#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2047 and on HPUX 10. Eventually we can turn this on. */
2048#define YYSTACK_USE_ALLOCA
2049#define alloca __builtin_alloca
2050#endif /* __hpux */
2051#endif
2052#endif /* not _AIX */
2053#endif /* not MSDOS, or __TURBOC__ */
2054#endif /* not sparc */
2055#endif /* not GNU C */
2056#endif /* alloca not defined */
2057#endif /* YYSTACK_USE_ALLOCA not defined */
2058
2059#ifdef YYSTACK_USE_ALLOCA
2060#define YYSTACK_ALLOC alloca
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002061#else
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002062#define YYSTACK_ALLOC malloc
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002063#endif
2064
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002065/* Note: there must be only one dollar sign in this file.
2066 It is replaced by the list of actions, each action
2067 as one case of the switch. */
David Greene718fda32007-08-01 03:59:32 +00002068
Reid Spencer68a24bd2005-08-27 18:50:39 +00002069#define yyerrok (yyerrstatus = 0)
2070#define yyclearin (yychar = YYEMPTY)
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002071#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00002072#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00002073#define YYACCEPT goto yyacceptlab
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002074#define YYABORT goto yyabortlab
2075#define YYERROR goto yyerrlab1
2076/* Like YYERROR except do call yyerror.
2077 This remains here temporarily to ease the
2078 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002079 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002080#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00002081#define YYRECOVERING() (!!yyerrstatus)
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002082#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002083do \
2084 if (yychar == YYEMPTY && yylen == 1) \
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002085 { yychar = (token), yylval = (value); \
2086 yychar1 = YYTRANSLATE (yychar); \
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002087 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002088 goto yybackup; \
2089 } \
2090 else \
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002091 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002092while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002093
Reid Spencer68a24bd2005-08-27 18:50:39 +00002094#define YYTERROR 1
2095#define YYERRCODE 256
2096
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002097#ifndef YYPURE
2098#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00002099#endif
2100
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002101#ifdef YYPURE
2102#ifdef YYLSP_NEEDED
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002103#ifdef YYLEX_PARAM
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002104#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002105#else
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002106#define YYLEX yylex(&yylval, &yylloc)
2107#endif
2108#else /* not YYLSP_NEEDED */
2109#ifdef YYLEX_PARAM
2110#define YYLEX yylex(&yylval, YYLEX_PARAM)
2111#else
2112#define YYLEX yylex(&yylval)
2113#endif
2114#endif /* not YYLSP_NEEDED */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002115#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002116
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002117/* If nonreentrant, generate the variables here */
Reid Spencerb8f85052007-07-31 03:50:36 +00002118
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002119#ifndef YYPURE
Reid Spencerb8f85052007-07-31 03:50:36 +00002120
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002121int yychar; /* the lookahead symbol */
2122YYSTYPE yylval; /* the semantic value of the */
2123 /* lookahead symbol */
Reid Spencerb8f85052007-07-31 03:50:36 +00002124
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002125#ifdef YYLSP_NEEDED
2126YYLTYPE yylloc; /* location data for the lookahead */
2127 /* symbol */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002128#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002129
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002130int yynerrs; /* number of parse errors so far */
2131#endif /* not YYPURE */
Reid Spencerb8f85052007-07-31 03:50:36 +00002132
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002133#if YYDEBUG != 0
2134int yydebug; /* nonzero means print parse trace */
2135/* Since this is uninitialized, it does not stop multiple parsers
2136 from coexisting. */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002137#endif
Reid Spencered951ea2007-05-19 07:22:10 +00002138
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002139/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencered951ea2007-05-19 07:22:10 +00002140
Reid Spencer68a24bd2005-08-27 18:50:39 +00002141#ifndef YYINITDEPTH
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002142#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002143#endif
2144
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002145/* YYMAXDEPTH is the maximum size the stacks can grow to
2146 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002147
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002148#if YYMAXDEPTH == 0
2149#undef YYMAXDEPTH
David Greene718fda32007-08-01 03:59:32 +00002150#endif
2151
Reid Spencer68a24bd2005-08-27 18:50:39 +00002152#ifndef YYMAXDEPTH
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002153#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002154#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002155
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002156/* Define __yy_memcpy. Note that the size argument
2157 should be passed with type unsigned int, because that is what the non-GCC
2158 definitions require. With GCC, __builtin_memcpy takes an arg
2159 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002160
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002161#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2162#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2163#else /* not GNU C or C++ */
2164#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00002165
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002166/* This is the most reliable way to avoid incompatibilities
2167 in available built-in functions on various systems. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002168static void
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002169__yy_memcpy (to, from, count)
2170 char *to;
2171 char *from;
2172 unsigned int count;
2173{
2174 register char *f = from;
2175 register char *t = to;
2176 register int i = count;
2177
2178 while (i-- > 0)
2179 *t++ = *f++;
2180}
2181
2182#else /* __cplusplus */
2183
2184/* This is the most reliable way to avoid incompatibilities
2185 in available built-in functions on various systems. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002186static void
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002187__yy_memcpy (char *to, char *from, unsigned int count)
2188{
2189 register char *t = to;
2190 register char *f = from;
2191 register int i = count;
2192
2193 while (i-- > 0)
2194 *t++ = *f++;
2195}
2196
Reid Spencerb8f85052007-07-31 03:50:36 +00002197#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002198#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002199
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002200#line 217 "/usr/share/bison.simple"
Reid Spencerb8f85052007-07-31 03:50:36 +00002201
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002202/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2203 into yyparse. The argument should have type void *.
2204 It should actually point to an object.
2205 Grammar actions can access the variable by casting it
2206 to the proper pointer type. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002207
2208#ifdef YYPARSE_PARAM
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002209#ifdef __cplusplus
2210#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2211#define YYPARSE_PARAM_DECL
2212#else /* not __cplusplus */
2213#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2214#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2215#endif /* not __cplusplus */
2216#else /* not YYPARSE_PARAM */
2217#define YYPARSE_PARAM_ARG
2218#define YYPARSE_PARAM_DECL
2219#endif /* not YYPARSE_PARAM */
2220
2221/* Prevent warning if -Wstrict-prototypes. */
2222#ifdef __GNUC__
2223#ifdef YYPARSE_PARAM
2224int yyparse (void *);
2225#else
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002226int yyparse (void);
Reid Spencerb8f85052007-07-31 03:50:36 +00002227#endif
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002228#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002229
Reid Spencerb8f85052007-07-31 03:50:36 +00002230int
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002231yyparse(YYPARSE_PARAM_ARG)
2232 YYPARSE_PARAM_DECL
Reid Spencerb8f85052007-07-31 03:50:36 +00002233{
David Greene718fda32007-08-01 03:59:32 +00002234 register int yystate;
2235 register int yyn;
David Greene718fda32007-08-01 03:59:32 +00002236 register short *yyssp;
David Greene718fda32007-08-01 03:59:32 +00002237 register YYSTYPE *yyvsp;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002238 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2239 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencerb8f85052007-07-31 03:50:36 +00002240
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002241 short yyssa[YYINITDEPTH]; /* the state stack */
2242 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencerb8f85052007-07-31 03:50:36 +00002243
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002244 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2245 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencerb8f85052007-07-31 03:50:36 +00002246
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002247#ifdef YYLSP_NEEDED
2248 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2249 YYLTYPE *yyls = yylsa;
2250 YYLTYPE *yylsp;
2251
2252#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2253#else
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002254#define YYPOPSTACK (yyvsp--, yyssp--)
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002255#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002256
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002257 int yystacksize = YYINITDEPTH;
2258 int yyfree_stacks = 0;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002259
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002260#ifdef YYPURE
2261 int yychar;
2262 YYSTYPE yylval;
2263 int yynerrs;
2264#ifdef YYLSP_NEEDED
2265 YYLTYPE yylloc;
2266#endif
2267#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002268
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002269 YYSTYPE yyval; /* the variable used to return */
2270 /* semantic values from the action */
2271 /* routines */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002272
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002273 int yylen;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002274
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002275#if YYDEBUG != 0
2276 if (yydebug)
2277 fprintf(stderr, "Starting parse\n");
2278#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002279
Reid Spencer68a24bd2005-08-27 18:50:39 +00002280 yystate = 0;
2281 yyerrstatus = 0;
2282 yynerrs = 0;
2283 yychar = YYEMPTY; /* Cause a token to be read. */
2284
2285 /* Initialize stack pointers.
2286 Waste one element of value and location stack
2287 so that they stay on the same level as the state stack.
2288 The wasted elements are never initialized. */
2289
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002290 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002291 yyvsp = yyvs;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002292#ifdef YYLSP_NEEDED
2293 yylsp = yyls;
2294#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002295
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002296/* Push a new state, which is found in yystate . */
2297/* In all cases, when you get here, the value and location stacks
2298 have just been pushed. so pushing a state here evens the stacks. */
2299yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002300
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002301 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002302
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002303 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002304 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002305 /* Give user a chance to reallocate the stack */
2306 /* Use copies of these so that the &'s don't force the real ones into memory. */
2307 YYSTYPE *yyvs1 = yyvs;
2308 short *yyss1 = yyss;
2309#ifdef YYLSP_NEEDED
2310 YYLTYPE *yyls1 = yyls;
2311#endif
2312
Reid Spencer68a24bd2005-08-27 18:50:39 +00002313 /* Get the current used size of the three stacks, in elements. */
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002314 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002315
2316#ifdef yyoverflow
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002317 /* Each stack pointer address is followed by the size of
2318 the data in use in that stack, in bytes. */
2319#ifdef YYLSP_NEEDED
2320 /* This used to be a conditional around just the two extra args,
2321 but that might be undefined if yyoverflow is a macro. */
2322 yyoverflow("parser stack overflow",
2323 &yyss1, size * sizeof (*yyssp),
2324 &yyvs1, size * sizeof (*yyvsp),
2325 &yyls1, size * sizeof (*yylsp),
2326 &yystacksize);
2327#else
2328 yyoverflow("parser stack overflow",
2329 &yyss1, size * sizeof (*yyssp),
2330 &yyvs1, size * sizeof (*yyvsp),
2331 &yystacksize);
2332#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002333
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002334 yyss = yyss1; yyvs = yyvs1;
2335#ifdef YYLSP_NEEDED
2336 yyls = yyls1;
2337#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002338#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002339 /* Extend the stack our own way. */
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002340 if (yystacksize >= YYMAXDEPTH)
2341 {
2342 yyerror("parser stack overflow");
2343 if (yyfree_stacks)
2344 {
2345 free (yyss);
2346 free (yyvs);
2347#ifdef YYLSP_NEEDED
2348 free (yyls);
2349#endif
2350 }
2351 return 2;
2352 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002353 yystacksize *= 2;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002354 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002355 yystacksize = YYMAXDEPTH;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002356#ifndef YYSTACK_USE_ALLOCA
2357 yyfree_stacks = 1;
2358#endif
2359 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2360 __yy_memcpy ((char *)yyss, (char *)yyss1,
2361 size * (unsigned int) sizeof (*yyssp));
2362 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2363 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2364 size * (unsigned int) sizeof (*yyvsp));
2365#ifdef YYLSP_NEEDED
2366 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2367 __yy_memcpy ((char *)yyls, (char *)yyls1,
2368 size * (unsigned int) sizeof (*yylsp));
2369#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002370#endif /* no yyoverflow */
2371
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002372 yyssp = yyss + size - 1;
2373 yyvsp = yyvs + size - 1;
2374#ifdef YYLSP_NEEDED
2375 yylsp = yyls + size - 1;
2376#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002377
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002378#if YYDEBUG != 0
2379 if (yydebug)
2380 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2381#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002382
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002383 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002384 YYABORT;
2385 }
2386
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002387#if YYDEBUG != 0
2388 if (yydebug)
2389 fprintf(stderr, "Entering state %d\n", yystate);
2390#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002391
2392 goto yybackup;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002393 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002394
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002395/* Do appropriate processing given the current state. */
David Greene718fda32007-08-01 03:59:32 +00002396/* Read a lookahead token if we need one and don't already have one. */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002397/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002398
David Greene718fda32007-08-01 03:59:32 +00002399 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002400
Reid Spencer68a24bd2005-08-27 18:50:39 +00002401 yyn = yypact[yystate];
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002402 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002403 goto yydefault;
2404
David Greene718fda32007-08-01 03:59:32 +00002405 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002406
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002407 /* yychar is either YYEMPTY or YYEOF
2408 or a valid token in external form. */
2409
Reid Spencer68a24bd2005-08-27 18:50:39 +00002410 if (yychar == YYEMPTY)
2411 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002412#if YYDEBUG != 0
2413 if (yydebug)
2414 fprintf(stderr, "Reading a token: ");
2415#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002416 yychar = YYLEX;
2417 }
2418
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002419 /* Convert token to internal form (in yychar1) for indexing tables with */
2420
2421 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002422 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002423 yychar1 = 0;
2424 yychar = YYEOF; /* Don't call YYLEX any more */
2425
2426#if YYDEBUG != 0
2427 if (yydebug)
2428 fprintf(stderr, "Now at end of input.\n");
2429#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002430 }
2431 else
2432 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002433 yychar1 = YYTRANSLATE(yychar);
2434
2435#if YYDEBUG != 0
2436 if (yydebug)
2437 {
2438 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2439 /* Give the individual parser a way to print the precise meaning
2440 of a token, for further debugging info. */
2441#ifdef YYPRINT
2442 YYPRINT (stderr, yychar, yylval);
2443#endif
2444 fprintf (stderr, ")\n");
2445 }
2446#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002447 }
2448
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002449 yyn += yychar1;
2450 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002451 goto yydefault;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002452
Reid Spencer68a24bd2005-08-27 18:50:39 +00002453 yyn = yytable[yyn];
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002454
2455 /* yyn is what to do for this token type in this state.
2456 Negative => reduce, -yyn is rule number.
2457 Positive => shift, yyn is new state.
2458 New state is final state => don't bother to shift,
2459 just return success.
2460 0, or most negative number => error. */
2461
2462 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002463 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002464 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002465 goto yyerrlab;
2466 yyn = -yyn;
2467 goto yyreduce;
2468 }
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002469 else if (yyn == 0)
2470 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002471
2472 if (yyn == YYFINAL)
2473 YYACCEPT;
2474
David Greene718fda32007-08-01 03:59:32 +00002475 /* Shift the lookahead token. */
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002476
2477#if YYDEBUG != 0
2478 if (yydebug)
2479 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2480#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002481
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002482 /* Discard the token being shifted unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002483 if (yychar != YYEOF)
2484 yychar = YYEMPTY;
2485
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002486 *++yyvsp = yylval;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002487#ifdef YYLSP_NEEDED
2488 *++yylsp = yylloc;
2489#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002490
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002491 /* count tokens shifted since error; after three, turn off error status. */
2492 if (yyerrstatus) yyerrstatus--;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002493
2494 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002495 goto yynewstate;
2496
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002497/* Do the default action for the current state. */
Reid Spencerb8f85052007-07-31 03:50:36 +00002498yydefault:
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002499
Reid Spencer68a24bd2005-08-27 18:50:39 +00002500 yyn = yydefact[yystate];
2501 if (yyn == 0)
2502 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002503
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002504/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002505yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002506 yylen = yyr2[yyn];
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002507 if (yylen > 0)
2508 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002509
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002510#if YYDEBUG != 0
2511 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002512 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002513 int i;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002514
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002515 fprintf (stderr, "Reducing via rule %d (line %d), ",
2516 yyn, yyrline[yyn]);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002517
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002518 /* Print the symbols being reduced, and their result. */
2519 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2520 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2521 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2522 }
2523#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002524
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002525
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002526 switch (yyn) {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002527
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002528case 28:
2529#line 1122 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2530{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2531 break;}
2532case 29:
2533#line 1122 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2534{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2535 break;}
2536case 30:
2537#line 1123 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2538{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2539 break;}
2540case 31:
2541#line 1123 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2542{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2543 break;}
2544case 32:
2545#line 1124 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2546{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2547 break;}
2548case 33:
2549#line 1124 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2550{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2551 break;}
2552case 34:
2553#line 1125 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2554{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2555 break;}
2556case 35:
2557#line 1125 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2558{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2559 break;}
2560case 36:
2561#line 1126 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2562{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2563 break;}
2564case 37:
2565#line 1126 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2566{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2567 break;}
2568case 38:
2569#line 1130 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2570{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2571 break;}
2572case 39:
2573#line 1130 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2574{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2575 break;}
2576case 40:
2577#line 1131 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2578{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2579 break;}
2580case 41:
2581#line 1131 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2582{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2583 break;}
2584case 42:
2585#line 1132 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2586{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2587 break;}
2588case 43:
2589#line 1132 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2590{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2591 break;}
2592case 44:
2593#line 1133 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2594{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2595 break;}
2596case 45:
2597#line 1133 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2598{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2599 break;}
2600case 46:
2601#line 1134 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2602{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2603 break;}
2604case 47:
2605#line 1134 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2606{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2607 break;}
2608case 48:
2609#line 1135 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2610{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2611 break;}
2612case 49:
2613#line 1135 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2614{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2615 break;}
2616case 50:
2617#line 1136 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2618{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2619 break;}
2620case 51:
2621#line 1136 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2622{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2623 break;}
2624case 52:
2625#line 1137 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2626{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2627 break;}
2628case 53:
2629#line 1138 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2630{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2631 break;}
2632case 64:
2633#line 1147 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2634{ yyval.StrVal = 0; ;
2635 break;}
2636case 65:
2637#line 1151 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2638{
David Greene718fda32007-08-01 03:59:32 +00002639 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002640 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002641 ;
2642 break;}
2643case 66:
2644#line 1155 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2645{
David Greene718fda32007-08-01 03:59:32 +00002646 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002647 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002648 ;
2649 break;}
2650case 70:
2651#line 1163 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2652{
David Greene718fda32007-08-01 03:59:32 +00002653 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002654 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002655 ;
2656 break;}
2657case 71:
2658#line 1168 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2659{
David Greene718fda32007-08-01 03:59:32 +00002660 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002661 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002662 ;
2663 break;}
2664case 72:
2665#line 1174 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2666{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2667 break;}
2668case 73:
2669#line 1175 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2670{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2671 break;}
2672case 74:
2673#line 1176 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2674{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2675 break;}
2676case 75:
2677#line 1177 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2678{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2679 break;}
2680case 76:
2681#line 1178 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2682{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2683 break;}
2684case 77:
2685#line 1182 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2686{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2687 break;}
2688case 78:
2689#line 1183 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2690{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2691 break;}
2692case 79:
2693#line 1184 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2694{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2695 break;}
2696case 80:
2697#line 1188 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2698{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2699 break;}
2700case 81:
2701#line 1189 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2702{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2703 break;}
2704case 82:
2705#line 1190 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2706{ yyval.Visibility = GlobalValue::HiddenVisibility; ;
2707 break;}
2708case 83:
2709#line 1191 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2710{ yyval.Visibility = GlobalValue::ProtectedVisibility; ;
2711 break;}
2712case 84:
2713#line 1195 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2714{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2715 break;}
2716case 85:
2717#line 1196 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2718{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2719 break;}
2720case 86:
2721#line 1197 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2722{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2723 break;}
2724case 87:
2725#line 1201 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2726{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2727 break;}
2728case 88:
2729#line 1202 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2730{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2731 break;}
2732case 89:
2733#line 1203 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2734{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2735 break;}
2736case 90:
2737#line 1204 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2738{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2739 break;}
2740case 91:
2741#line 1205 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2742{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2743 break;}
2744case 92:
2745#line 1209 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2746{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2747 break;}
2748case 93:
2749#line 1210 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2750{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2751 break;}
2752case 94:
2753#line 1211 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2754{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2755 break;}
2756case 95:
2757#line 1214 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2758{ yyval.UIntVal = CallingConv::C; ;
2759 break;}
2760case 96:
2761#line 1215 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2762{ yyval.UIntVal = CallingConv::C; ;
2763 break;}
2764case 97:
2765#line 1216 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2766{ yyval.UIntVal = CallingConv::Fast; ;
2767 break;}
2768case 98:
2769#line 1217 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2770{ yyval.UIntVal = CallingConv::Cold; ;
2771 break;}
2772case 99:
2773#line 1218 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2774{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2775 break;}
2776case 100:
2777#line 1219 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2778{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2779 break;}
2780case 101:
2781#line 1220 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2782{
David Greene718fda32007-08-01 03:59:32 +00002783 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002784 GEN_ERROR("Calling conv too large");
David Greene718fda32007-08-01 03:59:32 +00002785 yyval.UIntVal = yyvsp[0].UInt64Val;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002786 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002787 ;
2788 break;}
2789case 102:
2790#line 1227 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2791{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2792 break;}
2793case 103:
2794#line 1228 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2795{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2796 break;}
2797case 104:
2798#line 1229 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2799{ yyval.ParamAttrs = ParamAttr::SExt; ;
2800 break;}
2801case 105:
2802#line 1230 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2803{ yyval.ParamAttrs = ParamAttr::SExt; ;
2804 break;}
2805case 106:
2806#line 1231 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2807{ yyval.ParamAttrs = ParamAttr::InReg; ;
2808 break;}
2809case 107:
2810#line 1232 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2811{ yyval.ParamAttrs = ParamAttr::StructRet; ;
2812 break;}
2813case 108:
2814#line 1233 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2815{ yyval.ParamAttrs = ParamAttr::NoAlias; ;
2816 break;}
2817case 109:
2818#line 1234 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2819{ yyval.ParamAttrs = ParamAttr::ByVal; ;
2820 break;}
2821case 110:
2822#line 1235 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2823{ yyval.ParamAttrs = ParamAttr::Nest; ;
2824 break;}
2825case 111:
2826#line 1238 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2827{ yyval.ParamAttrs = ParamAttr::None; ;
2828 break;}
2829case 112:
2830#line 1239 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2831{
David Greene718fda32007-08-01 03:59:32 +00002832 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002833 ;
2834 break;}
2835case 113:
2836#line 1244 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2837{ yyval.ParamAttrs = ParamAttr::NoReturn; ;
2838 break;}
2839case 114:
2840#line 1245 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2841{ yyval.ParamAttrs = ParamAttr::NoUnwind; ;
2842 break;}
2843case 115:
2844#line 1246 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2845{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2846 break;}
2847case 116:
2848#line 1247 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2849{ yyval.ParamAttrs = ParamAttr::SExt; ;
2850 break;}
2851case 117:
2852#line 1250 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2853{ yyval.ParamAttrs = ParamAttr::None; ;
2854 break;}
2855case 118:
2856#line 1251 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2857{
David Greene718fda32007-08-01 03:59:32 +00002858 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002859 ;
2860 break;}
2861case 119:
2862#line 1258 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2863{ yyval.UIntVal = 0; ;
2864 break;}
2865case 120:
2866#line 1259 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2867{
David Greene718fda32007-08-01 03:59:32 +00002868 yyval.UIntVal = yyvsp[0].UInt64Val;
2869 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002870 GEN_ERROR("Alignment must be a power of two");
2871 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002872;
2873 break;}
2874case 121:
2875#line 1265 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2876{ yyval.UIntVal = 0; ;
2877 break;}
2878case 122:
2879#line 1266 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2880{
David Greene718fda32007-08-01 03:59:32 +00002881 yyval.UIntVal = yyvsp[0].UInt64Val;
2882 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002883 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002884 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002885;
2886 break;}
2887case 123:
2888#line 1274 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2889{
David Greene718fda32007-08-01 03:59:32 +00002890 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
2891 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002892 GEN_ERROR("Invalid character in section name");
David Greene718fda32007-08-01 03:59:32 +00002893 yyval.StrVal = yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002894 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002895;
2896 break;}
2897case 124:
2898#line 1282 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2899{ yyval.StrVal = 0; ;
2900 break;}
2901case 125:
2902#line 1283 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2903{ yyval.StrVal = yyvsp[0].StrVal; ;
2904 break;}
2905case 126:
2906#line 1288 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2907{;
2908 break;}
2909case 127:
2910#line 1289 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2911{;
2912 break;}
2913case 128:
2914#line 1290 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2915{
David Greene718fda32007-08-01 03:59:32 +00002916 CurGV->setSection(*yyvsp[0].StrVal);
2917 delete yyvsp[0].StrVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002918 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002919 ;
2920 break;}
2921case 129:
2922#line 1295 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2923{
David Greene718fda32007-08-01 03:59:32 +00002924 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002925 GEN_ERROR("Alignment must be a power of two");
David Greene718fda32007-08-01 03:59:32 +00002926 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00002927 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002928 ;
2929 break;}
2930case 137:
2931#line 1311 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2932{
David Greene718fda32007-08-01 03:59:32 +00002933 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00002934 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002935 ;
2936 break;}
2937case 138:
2938#line 1315 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2939{
David Greene718fda32007-08-01 03:59:32 +00002940 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002941 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002942 ;
2943 break;}
2944case 139:
2945#line 1319 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2946{ // Pointer type?
David Greene718fda32007-08-01 03:59:32 +00002947 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002948 GEN_ERROR("Cannot form a pointer to a basic block");
David Greene718fda32007-08-01 03:59:32 +00002949 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2950 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002951 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002952 ;
2953 break;}
2954case 140:
2955#line 1326 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2956{ // Named types are also simple types...
David Greene718fda32007-08-01 03:59:32 +00002957 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00002958 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00002959 yyval.TypeVal = new PATypeHolder(tmp);
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002960 ;
2961 break;}
2962case 141:
2963#line 1331 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2964{ // Type UpReference
David Greene718fda32007-08-01 03:59:32 +00002965 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002966 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
David Greene718fda32007-08-01 03:59:32 +00002967 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2968 yyval.TypeVal = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002969 UR_OUT("New Upreference!\n");
2970 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002971 ;
2972 break;}
2973case 142:
2974#line 1339 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
2975{
Reid Spencer41dff5e2007-01-26 08:05:27 +00002976 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00002977 ParamAttrsVector Attrs;
David Greene718fda32007-08-01 03:59:32 +00002978 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
2979 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00002980 Attrs.push_back(X);
2981 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00002982 unsigned index = 1;
David Greene718fda32007-08-01 03:59:32 +00002983 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00002984 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00002985 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00002986 Params.push_back(Ty);
2987 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00002988 if (I->Attrs != ParamAttr::None) {
2989 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
2990 Attrs.push_back(X);
2991 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00002992 }
2993 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2994 if (isVarArg) Params.pop_back();
2995
Reid Spencer7b5d4662007-04-09 06:16:21 +00002996 ParamAttrsList *ActualAttrs = 0;
2997 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00002998 ActualAttrs = ParamAttrsList::get(Attrs);
David Greene718fda32007-08-01 03:59:32 +00002999 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs);
3000 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3001 delete yyvsp[-4].TypeVal; // Delete the return type handle
3002 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003003 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003004 ;
3005 break;}
3006case 143:
3007#line 1369 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3008{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003009 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003010 ParamAttrsVector Attrs;
David Greene718fda32007-08-01 03:59:32 +00003011 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
3012 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00003013 Attrs.push_back(X);
3014 }
David Greene718fda32007-08-01 03:59:32 +00003015 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003016 unsigned index = 1;
3017 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003018 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003019 Params.push_back(Ty);
3020 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003021 if (I->Attrs != ParamAttr::None) {
3022 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3023 Attrs.push_back(X);
3024 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003025 }
3026 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3027 if (isVarArg) Params.pop_back();
3028
Reid Spencer7b5d4662007-04-09 06:16:21 +00003029 ParamAttrsList *ActualAttrs = 0;
3030 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003031 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003032
David Greene718fda32007-08-01 03:59:32 +00003033 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs);
3034 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3035 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003036 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003037 ;
3038 break;}
3039case 144:
3040#line 1400 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3041{ // Sized array type?
David Greene718fda32007-08-01 03:59:32 +00003042 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3043 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003044 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003045 ;
3046 break;}
3047case 145:
3048#line 1405 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3049{ // Vector type?
David Greene718fda32007-08-01 03:59:32 +00003050 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3051 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003052 GEN_ERROR("Unsigned result not equal to signed result");
3053 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3054 GEN_ERROR("Element type of a VectorType must be primitive");
David Greene718fda32007-08-01 03:59:32 +00003055 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003056 GEN_ERROR("Vector length should be a power of 2");
David Greene718fda32007-08-01 03:59:32 +00003057 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3058 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003059 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003060 ;
3061 break;}
3062case 146:
3063#line 1417 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3064{ // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003065 std::vector<const Type*> Elements;
David Greene718fda32007-08-01 03:59:32 +00003066 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3067 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003068 Elements.push_back(*I);
3069
David Greene718fda32007-08-01 03:59:32 +00003070 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3071 delete yyvsp[-1].TypeList;
Reid Spencer14310612006-12-31 05:40:51 +00003072 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003073 ;
3074 break;}
3075case 147:
3076#line 1427 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3077{ // Empty structure type?
David Greene718fda32007-08-01 03:59:32 +00003078 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003079 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003080 ;
3081 break;}
3082case 148:
3083#line 1431 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3084{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003085 std::vector<const Type*> Elements;
David Greene718fda32007-08-01 03:59:32 +00003086 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3087 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003088 Elements.push_back(*I);
3089
David Greene718fda32007-08-01 03:59:32 +00003090 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3091 delete yyvsp[-2].TypeList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003092 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003093 ;
3094 break;}
3095case 149:
3096#line 1441 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3097{ // Empty structure type?
David Greene718fda32007-08-01 03:59:32 +00003098 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003099 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003100 ;
3101 break;}
3102case 150:
3103#line 1448 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3104{
David Greene718fda32007-08-01 03:59:32 +00003105 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3106 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003107 ;
3108 break;}
3109case 151:
3110#line 1455 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3111{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003112 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003113 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3114 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003115 GEN_ERROR("LLVM functions cannot return aggregate types");
David Greene718fda32007-08-01 03:59:32 +00003116 yyval.TypeVal = yyvsp[0].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003117 ;
3118 break;}
3119case 152:
3120#line 1462 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3121{
David Greene718fda32007-08-01 03:59:32 +00003122 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003123 ;
3124 break;}
3125case 153:
3126#line 1467 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3127{
David Greene718fda32007-08-01 03:59:32 +00003128 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3129 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer3da59db2006-11-27 01:05:10 +00003130 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003131 ;
3132 break;}
3133case 154:
3134#line 1472 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3135{
David Greene718fda32007-08-01 03:59:32 +00003136 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003137 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003138 ;
3139 break;}
3140case 156:
3141#line 1480 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3142{
David Greene718fda32007-08-01 03:59:32 +00003143 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003144 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003145 TWA.Ty = new PATypeHolder(Type::VoidTy);
David Greene718fda32007-08-01 03:59:32 +00003146 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003147 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003148 ;
3149 break;}
3150case 157:
3151#line 1487 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3152{
David Greene718fda32007-08-01 03:59:32 +00003153 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003154 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3155 TWA.Ty = new PATypeHolder(Type::VoidTy);
David Greene718fda32007-08-01 03:59:32 +00003156 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003157 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003158 ;
3159 break;}
3160case 158:
3161#line 1494 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3162{
David Greene718fda32007-08-01 03:59:32 +00003163 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003164 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003165 ;
3166 break;}
3167case 159:
3168#line 1502 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3169{
David Greene718fda32007-08-01 03:59:32 +00003170 yyval.TypeList = new std::list<PATypeHolder>();
3171 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3172 delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00003173 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003174 ;
3175 break;}
3176case 160:
3177#line 1508 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3178{
David Greene718fda32007-08-01 03:59:32 +00003179 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3180 delete yyvsp[0].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003181 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003182 ;
3183 break;}
3184case 161:
3185#line 1520 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3186{ // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003187 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003188 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3189 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003190 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003191 GEN_ERROR("Cannot make array constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003192 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003193 const Type *ETy = ATy->getElementType();
3194 int NumElements = ATy->getNumElements();
3195
3196 // Verify that we have the correct size...
David Greene718fda32007-08-01 03:59:32 +00003197 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003198 GEN_ERROR("Type mismatch: constant sized array initialized with " +
David Greene718fda32007-08-01 03:59:32 +00003199 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003200 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003201
3202 // Verify all elements are correct type!
David Greene718fda32007-08-01 03:59:32 +00003203 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3204 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003205 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3206 ETy->getDescription() +"' as required!\nIt is of type '"+
David Greene718fda32007-08-01 03:59:32 +00003207 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003208 }
3209
David Greene718fda32007-08-01 03:59:32 +00003210 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3211 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003212 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003213 ;
3214 break;}
3215case 162:
3216#line 1548 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3217{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003218 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003219 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3220 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003221 if (ATy == 0)
3222 GEN_ERROR("Cannot make array constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003223 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003224
Andrew Lenharth6353e052006-12-08 18:07:09 +00003225 int NumElements = ATy->getNumElements();
3226 if (NumElements != -1 && NumElements != 0)
3227 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003228 " arguments, but has size of " + itostr(NumElements) +"");
David Greene718fda32007-08-01 03:59:32 +00003229 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3230 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003231 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003232 ;
3233 break;}
3234case 163:
3235#line 1564 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3236{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003237 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003238 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3239 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003240 if (ATy == 0)
3241 GEN_ERROR("Cannot make array constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003242 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003243
3244 int NumElements = ATy->getNumElements();
3245 const Type *ETy = ATy->getElementType();
David Greene718fda32007-08-01 03:59:32 +00003246 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003247 GEN_ERROR("Can't build string constant of size " +
David Greene718fda32007-08-01 03:59:32 +00003248 itostr((int)(yyvsp[0].StrVal->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003249 " when array has size " + itostr(NumElements) + "");
3250 std::vector<Constant*> Vals;
3251 if (ETy == Type::Int8Ty) {
David Greene718fda32007-08-01 03:59:32 +00003252 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3253 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003254 } else {
David Greene718fda32007-08-01 03:59:32 +00003255 delete yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003256 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3257 }
David Greene718fda32007-08-01 03:59:32 +00003258 delete yyvsp[0].StrVal;
3259 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3260 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003261 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003262 ;
3263 break;}
3264case 164:
3265#line 1591 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3266{ // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003267 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003268 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3269 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003270 if (PTy == 0)
3271 GEN_ERROR("Cannot make packed constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003272 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003273 const Type *ETy = PTy->getElementType();
3274 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003275
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003276 // Verify that we have the correct size...
David Greene718fda32007-08-01 03:59:32 +00003277 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003278 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
David Greene718fda32007-08-01 03:59:32 +00003279 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003280 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003281
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003282 // Verify all elements are correct type!
David Greene718fda32007-08-01 03:59:32 +00003283 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3284 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003285 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3286 ETy->getDescription() +"' as required!\nIt is of type '"+
David Greene718fda32007-08-01 03:59:32 +00003287 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003288 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003289
David Greene718fda32007-08-01 03:59:32 +00003290 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3291 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003292 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003293 ;
3294 break;}
3295case 165:
3296#line 1619 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3297{
David Greene718fda32007-08-01 03:59:32 +00003298 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003299 if (STy == 0)
3300 GEN_ERROR("Cannot make struct constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003301 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003302
David Greene718fda32007-08-01 03:59:32 +00003303 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003304 GEN_ERROR("Illegal number of initializers for structure type");
3305
3306 // Check to ensure that constants are compatible with the type initializer!
David Greene718fda32007-08-01 03:59:32 +00003307 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3308 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003309 GEN_ERROR("Expected type '" +
3310 STy->getElementType(i)->getDescription() +
3311 "' for element #" + utostr(i) +
3312 " of structure initializer");
3313
3314 // Check to ensure that Type is not packed
3315 if (STy->isPacked())
3316 GEN_ERROR("Unpacked Initializer to vector type '" +
3317 STy->getDescription() + "'");
3318
David Greene718fda32007-08-01 03:59:32 +00003319 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3320 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003321 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003322 ;
3323 break;}
3324case 166:
3325#line 1645 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3326{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003327 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003328 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3329 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003330 if (STy == 0)
3331 GEN_ERROR("Cannot make struct constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003332 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003333
3334 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003335 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003336
3337 // Check to ensure that Type is not packed
3338 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00003339 GEN_ERROR("Unpacked Initializer to vector type '" +
3340 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003341
David Greene718fda32007-08-01 03:59:32 +00003342 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3343 delete yyvsp[-2].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003344 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003345 ;
3346 break;}
3347case 167:
3348#line 1665 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3349{
David Greene718fda32007-08-01 03:59:32 +00003350 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003351 if (STy == 0)
3352 GEN_ERROR("Cannot make struct constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003353 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003354
David Greene718fda32007-08-01 03:59:32 +00003355 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003356 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003357
3358 // Check to ensure that constants are compatible with the type initializer!
David Greene718fda32007-08-01 03:59:32 +00003359 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3360 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003361 GEN_ERROR("Expected type '" +
3362 STy->getElementType(i)->getDescription() +
3363 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003364 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003365
3366 // Check to ensure that Type is packed
3367 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003368 GEN_ERROR("Vector initializer to non-vector type '" +
3369 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003370
David Greene718fda32007-08-01 03:59:32 +00003371 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3372 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003373 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003374 ;
3375 break;}
3376case 168:
3377#line 1691 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3378{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003379 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003380 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3381 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003382 if (STy == 0)
3383 GEN_ERROR("Cannot make struct constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003384 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003385
3386 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003387 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003388
3389 // Check to ensure that Type is packed
3390 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003391 GEN_ERROR("Vector initializer to non-vector type '" +
3392 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003393
David Greene718fda32007-08-01 03:59:32 +00003394 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3395 delete yyvsp[-4].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003396 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003397 ;
3398 break;}
3399case 169:
3400#line 1711 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3401{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003402 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003403 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3404 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003405 if (PTy == 0)
3406 GEN_ERROR("Cannot make null pointer constant with type: '" +
David Greene718fda32007-08-01 03:59:32 +00003407 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003408
David Greene718fda32007-08-01 03:59:32 +00003409 yyval.ConstVal = ConstantPointerNull::get(PTy);
3410 delete yyvsp[-1].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003411 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003412 ;
3413 break;}
3414case 170:
3415#line 1723 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3416{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003417 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003418 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3419 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3420 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003421 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003422 ;
3423 break;}
3424case 171:
3425#line 1730 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3426{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003427 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003428 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3429 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003430 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003431 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003432
3433 // ConstExprs can exist in the body of a function, thus creating
3434 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00003435 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00003436 // symbol table instead of the module symbol table for the global symbol,
3437 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00003438 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00003439 //
3440 Function *SavedCurFn = CurFun.CurrentFunction;
3441 CurFun.CurrentFunction = 0;
3442
David Greene718fda32007-08-01 03:59:32 +00003443 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003444 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003445
3446 CurFun.CurrentFunction = SavedCurFn;
3447
3448 // If this is an initializer for a constant pointer, which is referencing a
3449 // (currently) undefined variable, create a stub now that shall be replaced
3450 // in the future with the right type of variable.
3451 //
3452 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00003453 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003454 const PointerType *PT = cast<PointerType>(Ty);
3455
3456 // First check to see if the forward references value is already created!
3457 PerModuleInfo::GlobalRefsType::iterator I =
David Greene718fda32007-08-01 03:59:32 +00003458 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003459
3460 if (I != CurModule.GlobalRefs.end()) {
3461 V = I->second; // Placeholder already exists, use it...
David Greene718fda32007-08-01 03:59:32 +00003462 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003463 } else {
3464 std::string Name;
David Greene718fda32007-08-01 03:59:32 +00003465 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
3466 Name = yyvsp[0].ValIDVal.getName();
3467 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003468 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003469
3470 // Create the forward referenced global.
3471 GlobalValue *GV;
3472 if (const FunctionType *FTy =
3473 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00003474 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003475 CurModule.CurrentModule);
3476 } else {
3477 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00003478 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003479 Name, CurModule.CurrentModule);
3480 }
3481
3482 // Keep track of the fact that we have a forward ref to recycle it
David Greene718fda32007-08-01 03:59:32 +00003483 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003484 V = GV;
3485 }
3486 }
3487
David Greene718fda32007-08-01 03:59:32 +00003488 yyval.ConstVal = cast<GlobalValue>(V);
3489 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003490 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003491 ;
3492 break;}
3493case 172:
3494#line 1796 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3495{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003496 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003497 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3498 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003499 GEN_ERROR("Mismatched types for constant expression: " +
David Greene718fda32007-08-01 03:59:32 +00003500 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3501 yyval.ConstVal = yyvsp[0].ConstVal;
3502 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003503 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003504 ;
3505 break;}
3506case 173:
3507#line 1806 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3508{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003509 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003510 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3511 const Type *Ty = yyvsp[-1].TypeVal->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003512 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3513 GEN_ERROR("Cannot create a null initialized value of this type");
David Greene718fda32007-08-01 03:59:32 +00003514 yyval.ConstVal = Constant::getNullValue(Ty);
3515 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003516 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003517 ;
3518 break;}
3519case 174:
3520#line 1816 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3521{ // integral constants
David Greene718fda32007-08-01 03:59:32 +00003522 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003523 GEN_ERROR("Constant value doesn't fit in type");
David Greene718fda32007-08-01 03:59:32 +00003524 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Reid Spencer38c91a92007-02-28 02:24:54 +00003525 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003526 ;
3527 break;}
3528case 175:
3529#line 1822 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3530{ // arbitrary precision integer constants
David Greene718fda32007-08-01 03:59:32 +00003531 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3532 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003533 GEN_ERROR("Constant value does not fit in type");
3534 }
David Greene718fda32007-08-01 03:59:32 +00003535 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
3536 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3537 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003538 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003539 ;
3540 break;}
3541case 176:
3542#line 1832 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3543{ // integral constants
David Greene718fda32007-08-01 03:59:32 +00003544 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003545 GEN_ERROR("Constant value doesn't fit in type");
David Greene718fda32007-08-01 03:59:32 +00003546 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003547 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003548 ;
3549 break;}
3550case 177:
3551#line 1838 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3552{ // arbitrary precision integer constants
David Greene718fda32007-08-01 03:59:32 +00003553 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3554 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003555 GEN_ERROR("Constant value does not fit in type");
3556 }
David Greene718fda32007-08-01 03:59:32 +00003557 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
3558 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3559 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003560 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003561 ;
3562 break;}
3563case 178:
3564#line 1848 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3565{ // Boolean constants
David Greene718fda32007-08-01 03:59:32 +00003566 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3567 yyval.ConstVal = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00003568 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003569 ;
3570 break;}
3571case 179:
3572#line 1853 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3573{ // Boolean constants
David Greene718fda32007-08-01 03:59:32 +00003574 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3575 yyval.ConstVal = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00003576 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003577 ;
3578 break;}
3579case 180:
3580#line 1858 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3581{ // Float & Double constants
David Greene718fda32007-08-01 03:59:32 +00003582 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003583 GEN_ERROR("Floating point constant invalid for type");
David Greene718fda32007-08-01 03:59:32 +00003584 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003585 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003586 ;
3587 break;}
3588case 181:
3589#line 1866 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3590{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003591 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003592 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3593 Constant *Val = yyvsp[-3].ConstVal;
3594 const Type *DestTy = yyvsp[-1].TypeVal->get();
3595 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003596 GEN_ERROR("invalid cast opcode for cast from '" +
3597 Val->getType()->getDescription() + "' to '" +
3598 DestTy->getDescription() + "'");
David Greene718fda32007-08-01 03:59:32 +00003599 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3600 delete yyvsp[-1].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003601 ;
3602 break;}
3603case 182:
3604#line 1878 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3605{
David Greene718fda32007-08-01 03:59:32 +00003606 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00003607 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003608
3609 const Type *IdxTy =
David Greene718fda32007-08-01 03:59:32 +00003610 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), &(*yyvsp[-1].ValueList)[0], yyvsp[-1].ValueList->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00003611 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003612 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00003613 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003614
Chris Lattnerf7469af2007-01-31 04:44:08 +00003615 SmallVector<Constant*, 8> IdxVec;
David Greene718fda32007-08-01 03:59:32 +00003616 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3617 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003618 IdxVec.push_back(C);
3619 else
Reid Spencerb5334b02007-02-05 10:18:06 +00003620 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003621
David Greene718fda32007-08-01 03:59:32 +00003622 delete yyvsp[-1].ValueList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003623
David Greene718fda32007-08-01 03:59:32 +00003624 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003625 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003626 ;
3627 break;}
3628case 183:
3629#line 1900 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3630{
David Greene718fda32007-08-01 03:59:32 +00003631 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003632 GEN_ERROR("Select condition must be of boolean type");
David Greene718fda32007-08-01 03:59:32 +00003633 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003634 GEN_ERROR("Select operand types must match");
David Greene718fda32007-08-01 03:59:32 +00003635 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003636 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003637 ;
3638 break;}
3639case 184:
3640#line 1908 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3641{
David Greene718fda32007-08-01 03:59:32 +00003642 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003643 GEN_ERROR("Binary operator types must match");
3644 CHECK_FOR_ERROR;
David Greene718fda32007-08-01 03:59:32 +00003645 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003646 ;
3647 break;}
3648case 185:
3649#line 1914 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3650{
David Greene718fda32007-08-01 03:59:32 +00003651 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003652 GEN_ERROR("Logical operator types must match");
David Greene718fda32007-08-01 03:59:32 +00003653 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3654 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
3655 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003656 GEN_ERROR("Logical operator requires integral operands");
3657 }
David Greene718fda32007-08-01 03:59:32 +00003658 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003659 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003660 ;
3661 break;}
3662case 186:
3663#line 1925 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3664{
David Greene718fda32007-08-01 03:59:32 +00003665 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003666 GEN_ERROR("icmp operand types must match");
David Greene718fda32007-08-01 03:59:32 +00003667 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003668 ;
3669 break;}
3670case 187:
3671#line 1930 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3672{
David Greene718fda32007-08-01 03:59:32 +00003673 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003674 GEN_ERROR("fcmp operand types must match");
David Greene718fda32007-08-01 03:59:32 +00003675 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003676 ;
3677 break;}
3678case 188:
3679#line 1935 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3680{
David Greene718fda32007-08-01 03:59:32 +00003681 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003682 GEN_ERROR("Invalid extractelement operands");
David Greene718fda32007-08-01 03:59:32 +00003683 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003684 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003685 ;
3686 break;}
3687case 189:
3688#line 1941 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3689{
David Greene718fda32007-08-01 03:59:32 +00003690 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003691 GEN_ERROR("Invalid insertelement operands");
David Greene718fda32007-08-01 03:59:32 +00003692 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003693 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003694 ;
3695 break;}
3696case 190:
3697#line 1947 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3698{
David Greene718fda32007-08-01 03:59:32 +00003699 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003700 GEN_ERROR("Invalid shufflevector operands");
David Greene718fda32007-08-01 03:59:32 +00003701 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003702 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003703 ;
3704 break;}
3705case 191:
3706#line 1956 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3707{
David Greene718fda32007-08-01 03:59:32 +00003708 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003709 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003710 ;
3711 break;}
3712case 192:
3713#line 1960 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3714{
David Greene718fda32007-08-01 03:59:32 +00003715 yyval.ConstVector = new std::vector<Constant*>();
3716 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003717 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003718 ;
3719 break;}
3720case 193:
3721#line 1968 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3722{ yyval.BoolVal = false; ;
3723 break;}
3724case 194:
3725#line 1968 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3726{ yyval.BoolVal = true; ;
3727 break;}
3728case 195:
3729#line 1971 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3730{ yyval.BoolVal = true; ;
3731 break;}
3732case 196:
3733#line 1971 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3734{ yyval.BoolVal = false; ;
3735 break;}
3736case 197:
3737#line 1974 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3738{
David Greene718fda32007-08-01 03:59:32 +00003739 const Type* VTy = yyvsp[-1].TypeVal->get();
3740 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003741 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
3742 if (!Aliasee)
3743 GEN_ERROR("Aliases can be created only to global values");
3744
David Greene718fda32007-08-01 03:59:32 +00003745 yyval.ConstVal = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003746 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00003747 delete yyvsp[-1].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003748 ;
3749 break;}
3750case 198:
3751#line 1985 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3752{
David Greene718fda32007-08-01 03:59:32 +00003753 Constant *Val = yyvsp[-3].ConstVal;
3754 const Type *DestTy = yyvsp[-1].TypeVal->get();
3755 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003756 GEN_ERROR("invalid cast opcode for cast from '" +
3757 Val->getType()->getDescription() + "' to '" +
3758 DestTy->getDescription() + "'");
3759
David Greene718fda32007-08-01 03:59:32 +00003760 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003761 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00003762 delete yyvsp[-1].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003763 ;
3764 break;}
3765case 199:
3766#line 2006 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3767{
David Greene718fda32007-08-01 03:59:32 +00003768 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer1013b4d2007-07-31 14:41:17 +00003769 CurModule.ModuleDone();
3770 CHECK_FOR_ERROR;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003771 ;
3772 break;}
3773case 200:
3774#line 2011 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3775{
David Greene718fda32007-08-01 03:59:32 +00003776 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003777 CurModule.ModuleDone();
3778 CHECK_FOR_ERROR;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003779 ;
3780 break;}
3781case 203:
3782#line 2024 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3783{ CurFun.isDeclare = false; ;
3784 break;}
3785case 204:
3786#line 2024 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3787{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003788 CurFun.FunctionDone();
3789 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003790 ;
3791 break;}
3792case 205:
3793#line 2028 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3794{ CurFun.isDeclare = true; ;
3795 break;}
3796case 206:
3797#line 2028 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3798{
Reid Spencer1013b4d2007-07-31 14:41:17 +00003799 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003800 ;
3801 break;}
3802case 207:
3803#line 2031 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3804{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003805 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003806 ;
3807 break;}
3808case 208:
3809#line 2034 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3810{
Reid Spencer14310612006-12-31 05:40:51 +00003811 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003812 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003813 // Eagerly resolve types. This is not an optimization, this is a
3814 // requirement that is due to the fact that we could have this:
3815 //
3816 // %list = type { %list * }
3817 // %list = type { %list * } ; repeated type decl
3818 //
3819 // If types are not resolved eagerly, then the two types will not be
3820 // determined to be the same type!
3821 //
David Greene718fda32007-08-01 03:59:32 +00003822 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003823
David Greene718fda32007-08-01 03:59:32 +00003824 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003825 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003826 // If this is a named type that is not a redefinition, add it to the slot
3827 // table.
David Greene718fda32007-08-01 03:59:32 +00003828 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003829 }
Reid Spencera132e042006-12-03 05:46:11 +00003830
David Greene718fda32007-08-01 03:59:32 +00003831 delete yyvsp[0].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003832 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003833 ;
3834 break;}
3835case 209:
3836#line 2058 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3837{
David Greene718fda32007-08-01 03:59:32 +00003838 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spencerb8f85052007-07-31 03:50:36 +00003839
David Greene718fda32007-08-01 03:59:32 +00003840 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003841 CHECK_FOR_ERROR
3842 // If this is a named type that is not a redefinition, add it to the slot
3843 // table.
David Greene718fda32007-08-01 03:59:32 +00003844 CurModule.Types.push_back(yyvsp[0].PrimType);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003845 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003846 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003847 ;
3848 break;}
3849case 210:
3850#line 2069 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3851{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003852 /* "Externally Visible" Linkage */
David Greene718fda32007-08-01 03:59:32 +00003853 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003854 GEN_ERROR("Global value initializer is not a constant");
David Greene718fda32007-08-01 03:59:32 +00003855 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage,
3856 yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003857 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003858 ;
3859 break;}
3860case 211:
3861#line 2076 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3862{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003863 CurGV = 0;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003864 ;
3865 break;}
3866case 212:
3867#line 2080 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3868{
David Greene718fda32007-08-01 03:59:32 +00003869 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003870 GEN_ERROR("Global value initializer is not a constant");
David Greene718fda32007-08-01 03:59:32 +00003871 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003872 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003873 ;
3874 break;}
3875case 213:
3876#line 2085 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3877{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003878 CurGV = 0;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003879 ;
3880 break;}
3881case 214:
3882#line 2089 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3883{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003884 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003885 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3886 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0, yyvsp[-2].BoolVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003887 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00003888 delete yyvsp[0].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003889 ;
3890 break;}
3891case 215:
3892#line 2095 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3893{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003894 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003895 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003896 ;
3897 break;}
3898case 216:
3899#line 2099 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3900{
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003901 std::string Name;
David Greene718fda32007-08-01 03:59:32 +00003902 if (yyvsp[-4].StrVal) {
3903 Name = *yyvsp[-4].StrVal;
3904 delete yyvsp[-4].StrVal;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003905 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003906 if (Name.empty())
3907 GEN_ERROR("Alias name cannot be empty");
3908
David Greene718fda32007-08-01 03:59:32 +00003909 Constant* Aliasee = yyvsp[0].ConstVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003910 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003911 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003912
David Greene718fda32007-08-01 03:59:32 +00003913 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003914 CurModule.CurrentModule);
David Greene718fda32007-08-01 03:59:32 +00003915 GA->setVisibility(yyvsp[-3].Visibility);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003916 InsertValue(GA, CurModule.Values);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003917 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003918 ;
3919 break;}
3920case 217:
3921#line 2118 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3922{
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003923 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003924 ;
3925 break;}
3926case 218:
3927#line 2121 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3928{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003929 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003930 ;
3931 break;}
3932case 219:
3933#line 2127 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3934{
Chris Lattner66316012006-01-24 04:14:29 +00003935 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00003936 if (AsmSoFar.empty())
David Greene718fda32007-08-01 03:59:32 +00003937 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003938 else
David Greene718fda32007-08-01 03:59:32 +00003939 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
3940 delete yyvsp[0].StrVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003941 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003942;
3943 break;}
3944case 220:
3945#line 2137 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3946{
David Greene718fda32007-08-01 03:59:32 +00003947 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
3948 delete yyvsp[0].StrVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003949 ;
3950 break;}
3951case 221:
3952#line 2141 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3953{
David Greene718fda32007-08-01 03:59:32 +00003954 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
3955 delete yyvsp[0].StrVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003956 ;
3957 break;}
3958case 223:
3959#line 2148 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3960{
David Greene718fda32007-08-01 03:59:32 +00003961 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
3962 delete yyvsp[0].StrVal;
Reid Spencer1013b4d2007-07-31 14:41:17 +00003963 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003964 ;
3965 break;}
3966case 224:
3967#line 2153 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3968{
David Greene718fda32007-08-01 03:59:32 +00003969 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
3970 delete yyvsp[0].StrVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003971 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003972 ;
3973 break;}
3974case 225:
3975#line 2158 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3976{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003977 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003978 ;
3979 break;}
3980case 226:
3981#line 2167 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3982{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003983 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003984 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3985 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003986 GEN_ERROR("void typed arguments are invalid");
David Greene718fda32007-08-01 03:59:32 +00003987 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3988 yyval.ArgList = yyvsp[-4].ArgList;
3989 yyvsp[-4].ArgList->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00003990 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00003991 ;
3992 break;}
3993case 227:
3994#line 2177 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
3995{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003996 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00003997 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3998 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003999 GEN_ERROR("void typed arguments are invalid");
David Greene718fda32007-08-01 03:59:32 +00004000 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4001 yyval.ArgList = new ArgListType;
4002 yyval.ArgList->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004003 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004004 ;
4005 break;}
4006case 228:
4007#line 2188 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4008{
David Greene718fda32007-08-01 03:59:32 +00004009 yyval.ArgList = yyvsp[0].ArgList;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004010 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004011 ;
4012 break;}
4013case 229:
4014#line 2192 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4015{
David Greene718fda32007-08-01 03:59:32 +00004016 yyval.ArgList = yyvsp[-2].ArgList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004017 struct ArgListEntry E;
4018 E.Ty = new PATypeHolder(Type::VoidTy);
4019 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004020 E.Attrs = ParamAttr::None;
David Greene718fda32007-08-01 03:59:32 +00004021 yyval.ArgList->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004022 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004023 ;
4024 break;}
4025case 230:
4026#line 2201 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4027{
David Greene718fda32007-08-01 03:59:32 +00004028 yyval.ArgList = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004029 struct ArgListEntry E;
4030 E.Ty = new PATypeHolder(Type::VoidTy);
4031 E.Name = 0;
4032 E.Attrs = ParamAttr::None;
David Greene718fda32007-08-01 03:59:32 +00004033 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004034 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004035 ;
4036 break;}
4037case 231:
4038#line 2210 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4039{
David Greene718fda32007-08-01 03:59:32 +00004040 yyval.ArgList = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004041 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004042 ;
4043 break;}
4044case 232:
4045#line 2216 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4046{
David Greene718fda32007-08-01 03:59:32 +00004047 std::string FunctionName(*yyvsp[-6].StrVal);
4048 delete yyvsp[-6].StrVal; // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004049
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004050 // Check the function result for abstractness if this is a define. We should
4051 // have no abstract types at this point
David Greene718fda32007-08-01 03:59:32 +00004052 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
4053 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004054
Reid Spencer68a24bd2005-08-27 18:50:39 +00004055 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004056 ParamAttrsVector Attrs;
David Greene718fda32007-08-01 03:59:32 +00004057 if (yyvsp[-2].ParamAttrs != ParamAttr::None) {
4058 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004059 Attrs.push_back(PAWI);
4060 }
David Greene718fda32007-08-01 03:59:32 +00004061 if (yyvsp[-4].ArgList) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004062 unsigned index = 1;
David Greene718fda32007-08-01 03:59:32 +00004063 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004064 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004065 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4066 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004067 ParamTypeList.push_back(Ty);
4068 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004069 if (I->Attrs != ParamAttr::None) {
4070 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4071 Attrs.push_back(PAWI);
4072 }
Reid Spencer14310612006-12-31 05:40:51 +00004073 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004074 }
4075
4076 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4077 if (isVarArg) ParamTypeList.pop_back();
4078
Christopher Lamb5c104242007-04-22 20:09:11 +00004079 ParamAttrsList *PAL = 0;
4080 if (!Attrs.empty())
4081 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004082
David Greene718fda32007-08-01 03:59:32 +00004083 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004084 const PointerType *PFT = PointerType::get(FT);
David Greene718fda32007-08-01 03:59:32 +00004085 delete yyvsp[-7].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004086
4087 ValID ID;
4088 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004089 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004090 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004091 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004092 }
4093
4094 Function *Fn = 0;
4095 // See if this function was forward referenced. If so, recycle the object.
4096 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4097 // Move the function to the end of the list, from whereever it was
4098 // previously inserted.
4099 Fn = cast<Function>(FWRef);
4100 CurModule.CurrentModule->getFunctionList().remove(Fn);
4101 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4102 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004103 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004104 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004105 // The existing function doesn't have the same type. This is an overload
4106 // error.
4107 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4108 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004109 // Neither the existing or the current function is a declaration and they
4110 // have the same name and same type. Clearly this is a redefinition.
4111 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004112 } if (Fn->isDeclaration()) {
4113 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004114 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4115 AI != AE; ++AI)
4116 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004117 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004118 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004119 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004120 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004121
Reid Spencer68a24bd2005-08-27 18:50:39 +00004122 InsertValue(Fn, CurModule.Values);
4123 }
4124
4125 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004126
4127 if (CurFun.isDeclare) {
4128 // If we have declaration, always overwrite linkage. This will allow us to
4129 // correctly handle cases, when pointer to function is passed as argument to
4130 // another function.
4131 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004132 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004133 }
David Greene718fda32007-08-01 03:59:32 +00004134 Fn->setCallingConv(yyvsp[-8].UIntVal);
4135 Fn->setAlignment(yyvsp[0].UIntVal);
4136 if (yyvsp[-1].StrVal) {
4137 Fn->setSection(*yyvsp[-1].StrVal);
4138 delete yyvsp[-1].StrVal;
Chris Lattnere869eef2005-11-12 00:11:49 +00004139 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004140
4141 // Add all of the arguments we parsed to the function...
David Greene718fda32007-08-01 03:59:32 +00004142 if (yyvsp[-4].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004143 if (isVarArg) { // Nuke the last entry
David Greene718fda32007-08-01 03:59:32 +00004144 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004145 "Not a varargs marker!");
David Greene718fda32007-08-01 03:59:32 +00004146 delete yyvsp[-4].ArgList->back().Ty;
4147 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004148 }
4149 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004150 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004151 unsigned Idx = 1;
David Greene718fda32007-08-01 03:59:32 +00004152 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin();
4153 I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004154 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004155 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004156 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004157 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004158 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004159 }
Reid Spencera132e042006-12-03 05:46:11 +00004160
David Greene718fda32007-08-01 03:59:32 +00004161 delete yyvsp[-4].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004162 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004163 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004164;
4165 break;}
4166case 235:
4167#line 2338 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4168{
David Greene718fda32007-08-01 03:59:32 +00004169 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004170
4171 // Make sure that we keep track of the linkage type even if there was a
4172 // previous "declare".
David Greene718fda32007-08-01 03:59:32 +00004173 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4174 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004175;
4176 break;}
4177case 238:
4178#line 2349 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4179{
David Greene718fda32007-08-01 03:59:32 +00004180 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004181 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004182;
4183 break;}
4184case 239:
4185#line 2354 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4186{
David Greene718fda32007-08-01 03:59:32 +00004187 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4188 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4189 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004190 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004191 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004192 ;
4193 break;}
4194case 240:
4195#line 2366 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4196{
David Greene718fda32007-08-01 03:59:32 +00004197 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004198 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004199 ;
4200 break;}
4201case 241:
4202#line 2370 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4203{
David Greene718fda32007-08-01 03:59:32 +00004204 yyval.BoolVal = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004205 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004206 ;
4207 break;}
4208case 242:
4209#line 2375 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4210{ // A reference to a direct constant
David Greene718fda32007-08-01 03:59:32 +00004211 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004212 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004213 ;
4214 break;}
4215case 243:
4216#line 2379 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4217{
David Greene718fda32007-08-01 03:59:32 +00004218 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004219 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004220 ;
4221 break;}
4222case 244:
4223#line 2383 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4224{ // Perhaps it's an FP constant?
David Greene718fda32007-08-01 03:59:32 +00004225 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004226 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004227 ;
4228 break;}
4229case 245:
4230#line 2387 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4231{
David Greene718fda32007-08-01 03:59:32 +00004232 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004233 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004234 ;
4235 break;}
4236case 246:
4237#line 2391 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4238{
David Greene718fda32007-08-01 03:59:32 +00004239 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004240 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004241 ;
4242 break;}
4243case 247:
4244#line 2395 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4245{
David Greene718fda32007-08-01 03:59:32 +00004246 yyval.ValIDVal = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004247 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004248 ;
4249 break;}
4250case 248:
4251#line 2399 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4252{
David Greene718fda32007-08-01 03:59:32 +00004253 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004254 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004255 ;
4256 break;}
4257case 249:
4258#line 2403 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4259{ // A vector zero constant.
David Greene718fda32007-08-01 03:59:32 +00004260 yyval.ValIDVal = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004261 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004262 ;
4263 break;}
4264case 250:
4265#line 2407 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4266{ // Nonempty unsized packed vector
David Greene718fda32007-08-01 03:59:32 +00004267 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4268 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004269
Reid Spencer9d6565a2007-02-15 02:26:10 +00004270 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004271 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004272 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004273 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004274 ETy,
4275 NumElements)
4276 )
4277 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004278
4279 // Verify all elements are correct type!
David Greene718fda32007-08-01 03:59:32 +00004280 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4281 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004282 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004283 ETy->getDescription() +"' as required!\nIt is of type '" +
David Greene718fda32007-08-01 03:59:32 +00004284 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004285 }
4286
David Greene718fda32007-08-01 03:59:32 +00004287 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4288 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer832254e2007-02-02 02:16:23 +00004289 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004290 ;
4291 break;}
4292case 251:
4293#line 2432 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4294{
David Greene718fda32007-08-01 03:59:32 +00004295 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004296 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004297 ;
4298 break;}
4299case 252:
4300#line 2436 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4301{
David Greene718fda32007-08-01 03:59:32 +00004302 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
4303 delete yyvsp[-2].StrVal;
4304 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004305 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004306 ;
4307 break;}
4308case 253:
4309#line 2446 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4310{ // Is it an integer reference...?
David Greene718fda32007-08-01 03:59:32 +00004311 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004312 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004313 ;
4314 break;}
4315case 254:
4316#line 2450 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4317{
David Greene718fda32007-08-01 03:59:32 +00004318 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004319 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004320 ;
4321 break;}
4322case 255:
4323#line 2454 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4324{ // Is it a named reference...?
David Greene718fda32007-08-01 03:59:32 +00004325 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
4326 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004327 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004328 ;
4329 break;}
4330case 256:
4331#line 2459 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4332{ // Is it a named reference...?
David Greene718fda32007-08-01 03:59:32 +00004333 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
4334 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004335 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004336 ;
4337 break;}
4338case 259:
4339#line 2472 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4340{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004341 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004342 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4343 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4344 delete yyvsp[-1].TypeVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004345 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004346 ;
4347 break;}
4348case 260:
4349#line 2481 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4350{
David Greene718fda32007-08-01 03:59:32 +00004351 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004352 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004353 ;
4354 break;}
4355case 261:
4356#line 2485 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4357{ // Do not allow functions with 0 basic blocks
David Greene718fda32007-08-01 03:59:32 +00004358 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004359 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004360 ;
4361 break;}
4362case 262:
4363#line 2494 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4364{
David Greene718fda32007-08-01 03:59:32 +00004365 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004366 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004367 InsertValue(yyvsp[0].TermInstVal);
4368 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4369 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004370 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004371 ;
4372 break;}
4373case 263:
4374#line 2503 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4375{
David Greene718fda32007-08-01 03:59:32 +00004376 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004377 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4378 if (CI2->getParent() == 0)
David Greene718fda32007-08-01 03:59:32 +00004379 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4380 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4381 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004382 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004383 ;
4384 break;}
4385case 264:
4386#line 2512 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4387{ // Empty space between instruction lists
David Greene718fda32007-08-01 03:59:32 +00004388 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00004389 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004390 ;
4391 break;}
4392case 265:
4393#line 2516 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4394{ // Labelled (named) basic block
David Greene718fda32007-08-01 03:59:32 +00004395 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal));
4396 delete yyvsp[0].StrVal;
Reid Spencered951ea2007-05-19 07:22:10 +00004397 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004398
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004399 ;
4400 break;}
4401case 266:
4402#line 2523 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4403{ // Return with a result...
David Greene718fda32007-08-01 03:59:32 +00004404 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00004405 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004406 ;
4407 break;}
4408case 267:
4409#line 2527 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4410{ // Return with no result...
David Greene718fda32007-08-01 03:59:32 +00004411 yyval.TermInstVal = new ReturnInst();
Reid Spencerb8f85052007-07-31 03:50:36 +00004412 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004413 ;
4414 break;}
4415case 268:
4416#line 2531 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4417{ // Unconditional Branch...
David Greene718fda32007-08-01 03:59:32 +00004418 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00004419 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004420 yyval.TermInstVal = new BranchInst(tmpBB);
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004421 ;
4422 break;}
4423case 269:
4424#line 2536 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4425{
David Greene718fda32007-08-01 03:59:32 +00004426 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4427 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00004428 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004429 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00004430 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004431 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00004432 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004433 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004434 ;
4435 break;}
4436case 270:
4437#line 2546 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4438{
David Greene718fda32007-08-01 03:59:32 +00004439 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00004440 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004441 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
Reid Spencerb8f85052007-07-31 03:50:36 +00004442 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004443 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4444 yyval.TermInstVal = S;
Reid Spencerb8f85052007-07-31 03:50:36 +00004445
David Greene718fda32007-08-01 03:59:32 +00004446 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4447 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004448 for (; I != E; ++I) {
4449 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4450 S->addCase(CI, I->second);
4451 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004452 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004453 }
David Greene718fda32007-08-01 03:59:32 +00004454 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00004455 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004456 ;
4457 break;}
4458case 271:
4459#line 2565 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4460{
David Greene718fda32007-08-01 03:59:32 +00004461 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004462 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004463 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004464 CHECK_FOR_ERROR
4465 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
David Greene718fda32007-08-01 03:59:32 +00004466 yyval.TermInstVal = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004467 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004468 ;
4469 break;}
4470case 272:
4471#line 2575 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4472{
Reid Spencer3822ff52006-11-08 06:47:33 +00004473
Reid Spencer14310612006-12-31 05:40:51 +00004474 // Handle the short syntax
4475 const PointerType *PFTy = 0;
4476 const FunctionType *Ty = 0;
David Greene718fda32007-08-01 03:59:32 +00004477 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004478 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4479 // Pull out the types of all of the arguments...
4480 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00004481 ParamAttrsVector Attrs;
David Greene718fda32007-08-01 03:59:32 +00004482 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
4483 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004484 Attrs.push_back(PAWI);
4485 }
David Greene718fda32007-08-01 03:59:32 +00004486 ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00004487 unsigned index = 1;
4488 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004489 const Type *Ty = I->Val->getType();
4490 if (Ty == Type::VoidTy)
4491 GEN_ERROR("Short call syntax cannot be used with varargs");
4492 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00004493 if (I->Attrs != ParamAttr::None) {
4494 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4495 Attrs.push_back(PAWI);
4496 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004497 }
4498
Christopher Lamb5c104242007-04-22 20:09:11 +00004499 ParamAttrsList *PAL = 0;
4500 if (!Attrs.empty())
4501 PAL = ParamAttrsList::get(Attrs);
David Greene718fda32007-08-01 03:59:32 +00004502 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004503 PFTy = PointerType::get(Ty);
4504 }
4505
David Greene718fda32007-08-01 03:59:32 +00004506 delete yyvsp[-11].TypeVal;
Reid Spencer66728ef2007-03-20 01:13:36 +00004507
David Greene718fda32007-08-01 03:59:32 +00004508 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004509 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004510 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004511 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004512 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004513 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004514
Reid Spencer14310612006-12-31 05:40:51 +00004515 // Check the arguments
4516 ValueList Args;
David Greene718fda32007-08-01 03:59:32 +00004517 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00004518 // Make sure no arguments is a good thing!
4519 if (Ty->getNumParams() != 0)
4520 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004521 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004522 } else { // Has arguments?
4523 // Loop through FunctionType's arguments and ensure they are specified
4524 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004525 FunctionType::param_iterator I = Ty->param_begin();
4526 FunctionType::param_iterator E = Ty->param_end();
David Greene718fda32007-08-01 03:59:32 +00004527 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004528
Reid Spencer14310612006-12-31 05:40:51 +00004529 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4530 if (ArgI->Val->getType() != *I)
4531 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004532 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004533 Args.push_back(ArgI->Val);
4534 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004535
Reid Spencer14310612006-12-31 05:40:51 +00004536 if (Ty->isVarArg()) {
4537 if (I == E)
4538 for (; ArgI != ArgE; ++ArgI)
4539 Args.push_back(ArgI->Val); // push the remaining varargs
4540 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004541 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004542 }
Reid Spencer14310612006-12-31 05:40:51 +00004543
4544 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00004545 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
David Greene718fda32007-08-01 03:59:32 +00004546 II->setCallingConv(yyvsp[-12].UIntVal);
4547 yyval.TermInstVal = II;
4548 delete yyvsp[-8].ValueRefList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004549 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004550 ;
4551 break;}
4552case 273:
4553#line 2654 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4554{
David Greene718fda32007-08-01 03:59:32 +00004555 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004556 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004557 ;
4558 break;}
4559case 274:
4560#line 2658 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4561{
David Greene718fda32007-08-01 03:59:32 +00004562 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004563 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004564 ;
4565 break;}
4566case 275:
4567#line 2665 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4568{
David Greene718fda32007-08-01 03:59:32 +00004569 yyval.JumpTable = yyvsp[-5].JumpTable;
4570 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004571 CHECK_FOR_ERROR
4572 if (V == 0)
4573 GEN_ERROR("May only switch on a constant pool value");
4574
David Greene718fda32007-08-01 03:59:32 +00004575 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004576 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004577 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004578 ;
4579 break;}
4580case 276:
4581#line 2676 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4582{
David Greene718fda32007-08-01 03:59:32 +00004583 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4584 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004585 CHECK_FOR_ERROR
4586
4587 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004588 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004589
David Greene718fda32007-08-01 03:59:32 +00004590 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004591 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004592 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004593 ;
4594 break;}
4595case 277:
4596#line 2689 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4597{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004598 // Is this definition named?? if so, assign the name...
David Greene718fda32007-08-01 03:59:32 +00004599 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004600 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004601 InsertValue(yyvsp[0].InstVal);
4602 yyval.InstVal = yyvsp[0].InstVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004603 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004604 ;
4605 break;}
4606case 278:
4607#line 2699 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4608{ // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004609 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004610 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4611 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4612 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004613 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004614 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004615 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004616 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4617 delete yyvsp[-5].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004618 ;
4619 break;}
4620case 279:
4621#line 2710 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4622{
David Greene718fda32007-08-01 03:59:32 +00004623 yyval.PHIList = yyvsp[-6].PHIList;
4624 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004625 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004626 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004627 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004628 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004629 ;
4630 break;}
4631case 280:
4632#line 2720 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4633{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004634 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004635 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004636 // Used for call and invoke instructions
David Greene718fda32007-08-01 03:59:32 +00004637 yyval.ValueRefList = new ValueRefList();
4638 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4639 yyval.ValueRefList->push_back(E);
4640 delete yyvsp[-2].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004641 ;
4642 break;}
4643case 281:
4644#line 2729 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4645{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004646 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004647 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4648 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4649 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4650 yyval.ValueRefList->push_back(E);
4651 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004652 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004653 ;
4654 break;}
4655case 282:
4656#line 2738 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4657{ yyval.ValueRefList = new ValueRefList(); ;
4658 break;}
4659case 283:
4660#line 2741 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4661{ yyval.ValueList = new std::vector<Value*>(); ;
4662 break;}
4663case 284:
4664#line 2742 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4665{
David Greene718fda32007-08-01 03:59:32 +00004666 yyval.ValueList = yyvsp[-2].ValueList;
4667 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004668 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004669 ;
4670 break;}
4671case 285:
4672#line 2749 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4673{
David Greene718fda32007-08-01 03:59:32 +00004674 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004675 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004676 ;
4677 break;}
4678case 286:
4679#line 2753 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4680{
David Greene718fda32007-08-01 03:59:32 +00004681 yyval.BoolVal = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004682 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004683 ;
4684 break;}
4685case 287:
4686#line 2758 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4687{
Reid Spencer14310612006-12-31 05:40:51 +00004688 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004689 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4690 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4691 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004692 GEN_ERROR(
4693 "Arithmetic operator requires integer, FP, or packed operands");
David Greene718fda32007-08-01 03:59:32 +00004694 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) &&
4695 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4696 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4697 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004698 GEN_ERROR("Remainder not supported on vector types");
David Greene718fda32007-08-01 03:59:32 +00004699 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004700 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004701 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004702 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004703 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4704 if (yyval.InstVal == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004705 GEN_ERROR("binary operator returned null");
David Greene718fda32007-08-01 03:59:32 +00004706 delete yyvsp[-3].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004707 ;
4708 break;}
4709case 288:
4710#line 2779 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4711{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004712 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004713 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4714 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4715 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
4716 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004717 GEN_ERROR("Logical operator requires integral operands");
4718 }
David Greene718fda32007-08-01 03:59:32 +00004719 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004720 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004721 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004722 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004723 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4724 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004725 GEN_ERROR("binary operator returned null");
David Greene718fda32007-08-01 03:59:32 +00004726 delete yyvsp[-3].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004727 ;
4728 break;}
4729case 289:
4730#line 2796 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4731{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004732 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004733 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4734 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004735 GEN_ERROR("Vector types not supported by icmp instruction");
David Greene718fda32007-08-01 03:59:32 +00004736 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004737 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004738 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004739 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004740 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4741 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004742 GEN_ERROR("icmp operator returned null");
David Greene718fda32007-08-01 03:59:32 +00004743 delete yyvsp[-3].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004744 ;
4745 break;}
4746case 290:
4747#line 2810 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4748{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004749 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004750 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4751 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004752 GEN_ERROR("Vector types not supported by fcmp instruction");
David Greene718fda32007-08-01 03:59:32 +00004753 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004754 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004755 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004756 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004757 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4758 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004759 GEN_ERROR("fcmp operator returned null");
David Greene718fda32007-08-01 03:59:32 +00004760 delete yyvsp[-3].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004761 ;
4762 break;}
4763case 291:
4764#line 2824 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4765{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004766 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004767 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4768 Value* Val = yyvsp[-2].ValueVal;
4769 const Type* DestTy = yyvsp[0].TypeVal->get();
4770 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004771 GEN_ERROR("invalid cast opcode for cast from '" +
4772 Val->getType()->getDescription() + "' to '" +
4773 DestTy->getDescription() + "'");
David Greene718fda32007-08-01 03:59:32 +00004774 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
4775 delete yyvsp[0].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004776 ;
4777 break;}
4778case 292:
4779#line 2836 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4780{
David Greene718fda32007-08-01 03:59:32 +00004781 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004782 GEN_ERROR("select condition must be boolean");
David Greene718fda32007-08-01 03:59:32 +00004783 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004784 GEN_ERROR("select value types should match");
David Greene718fda32007-08-01 03:59:32 +00004785 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004786 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004787 ;
4788 break;}
4789case 293:
4790#line 2844 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4791{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004792 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004793 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4794 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4795 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004796 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004797 ;
4798 break;}
4799case 294:
4800#line 2851 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4801{
David Greene718fda32007-08-01 03:59:32 +00004802 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004803 GEN_ERROR("Invalid extractelement operands");
David Greene718fda32007-08-01 03:59:32 +00004804 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004805 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004806 ;
4807 break;}
4808case 295:
4809#line 2857 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4810{
David Greene718fda32007-08-01 03:59:32 +00004811 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004812 GEN_ERROR("Invalid insertelement operands");
David Greene718fda32007-08-01 03:59:32 +00004813 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004814 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004815 ;
4816 break;}
4817case 296:
4818#line 2863 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4819{
David Greene718fda32007-08-01 03:59:32 +00004820 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004821 GEN_ERROR("Invalid shufflevector operands");
David Greene718fda32007-08-01 03:59:32 +00004822 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004823 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004824 ;
4825 break;}
4826case 297:
4827#line 2869 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4828{
David Greene718fda32007-08-01 03:59:32 +00004829 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004830 if (!Ty->isFirstClassType())
4831 GEN_ERROR("PHI node operands must be of first class type");
David Greene718fda32007-08-01 03:59:32 +00004832 yyval.InstVal = new PHINode(Ty);
4833 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4834 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4835 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004836 GEN_ERROR("All elements of a PHI node must be of the same type");
David Greene718fda32007-08-01 03:59:32 +00004837 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4838 yyvsp[0].PHIList->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004839 }
David Greene718fda32007-08-01 03:59:32 +00004840 delete yyvsp[0].PHIList; // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004841 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004842 ;
4843 break;}
4844case 298:
4845#line 2885 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4846{
Reid Spencer14310612006-12-31 05:40:51 +00004847
4848 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00004849 const PointerType *PFTy = 0;
4850 const FunctionType *Ty = 0;
David Greene718fda32007-08-01 03:59:32 +00004851 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00004852 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4853 // Pull out the types of all of the arguments...
4854 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00004855 ParamAttrsVector Attrs;
David Greene718fda32007-08-01 03:59:32 +00004856 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
4857 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004858 Attrs.push_back(PAWI);
4859 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00004860 unsigned index = 1;
David Greene718fda32007-08-01 03:59:32 +00004861 ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00004862 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004863 const Type *Ty = I->Val->getType();
4864 if (Ty == Type::VoidTy)
4865 GEN_ERROR("Short call syntax cannot be used with varargs");
4866 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00004867 if (I->Attrs != ParamAttr::None) {
4868 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4869 Attrs.push_back(PAWI);
4870 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00004871 }
4872
Christopher Lamb5c104242007-04-22 20:09:11 +00004873 ParamAttrsList *PAL = 0;
4874 if (!Attrs.empty())
4875 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004876
David Greene718fda32007-08-01 03:59:32 +00004877 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004878 PFTy = PointerType::get(Ty);
4879 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00004880
David Greene718fda32007-08-01 03:59:32 +00004881 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004882 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00004883
Reid Spencer7780acb2007-04-16 06:56:07 +00004884 // Check for call to invalid intrinsic to avoid crashing later.
4885 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00004886 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00004887 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
4888 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00004889 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
4890 theF->getName() + "'");
4891 }
4892
Reid Spencer14310612006-12-31 05:40:51 +00004893 // Check the arguments
4894 ValueList Args;
David Greene718fda32007-08-01 03:59:32 +00004895 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00004896 // Make sure no arguments is a good thing!
4897 if (Ty->getNumParams() != 0)
4898 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004899 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004900 } else { // Has arguments?
4901 // Loop through FunctionType's arguments and ensure they are specified
4902 // correctly!
4903 //
4904 FunctionType::param_iterator I = Ty->param_begin();
4905 FunctionType::param_iterator E = Ty->param_end();
David Greene718fda32007-08-01 03:59:32 +00004906 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004907
Reid Spencer14310612006-12-31 05:40:51 +00004908 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4909 if (ArgI->Val->getType() != *I)
4910 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004911 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004912 Args.push_back(ArgI->Val);
4913 }
4914 if (Ty->isVarArg()) {
4915 if (I == E)
4916 for (; ArgI != ArgE; ++ArgI)
4917 Args.push_back(ArgI->Val); // push the remaining varargs
4918 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004919 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004920 }
Reid Spencer14310612006-12-31 05:40:51 +00004921 // Create the call node
David Greene718fda32007-08-01 03:59:32 +00004922 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
4923 CI->setTailCall(yyvsp[-7].BoolVal);
4924 CI->setCallingConv(yyvsp[-6].UIntVal);
4925 yyval.InstVal = CI;
4926 delete yyvsp[-2].ValueRefList;
4927 delete yyvsp[-5].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004928 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004929 ;
4930 break;}
4931case 299:
4932#line 2969 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4933{
David Greene718fda32007-08-01 03:59:32 +00004934 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004935 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004936 ;
4937 break;}
4938case 300:
4939#line 2974 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4940{
David Greene718fda32007-08-01 03:59:32 +00004941 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004942 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004943 ;
4944 break;}
4945case 301:
4946#line 2978 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4947{
David Greene718fda32007-08-01 03:59:32 +00004948 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004949 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004950 ;
4951 break;}
4952case 302:
4953#line 2985 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4954{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004955 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004956 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4957 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4958 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004959 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004960 ;
4961 break;}
4962case 303:
4963#line 2992 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4964{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004965 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004966 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4967 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004968 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004969 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4970 delete yyvsp[-4].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004971 ;
4972 break;}
4973case 304:
4974#line 3000 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4975{
Reid Spencer14310612006-12-31 05:40:51 +00004976 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004977 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4978 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4979 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004980 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004981 ;
4982 break;}
4983case 305:
4984#line 3007 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4985{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004986 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00004987 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4988 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004989 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00004990 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4991 delete yyvsp[-4].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00004992 ;
4993 break;}
4994case 306:
4995#line 3015 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
4996{
David Greene718fda32007-08-01 03:59:32 +00004997 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004998 GEN_ERROR("Trying to free nonpointer type " +
David Greene718fda32007-08-01 03:59:32 +00004999 yyvsp[0].ValueVal->getType()->getDescription() + "");
5000 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005001 CHECK_FOR_ERROR
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005002 ;
5003 break;}
5004case 307:
5005#line 3023 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5006{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005007 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005008 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5009 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005010 GEN_ERROR("Can't load from nonpointer type: " +
David Greene718fda32007-08-01 03:59:32 +00005011 (*yyvsp[-2].TypeVal)->getDescription());
5012 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005013 GEN_ERROR("Can't load from pointer of non-first-class type: " +
David Greene718fda32007-08-01 03:59:32 +00005014 (*yyvsp[-2].TypeVal)->getDescription());
5015 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005016 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005017 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
5018 delete yyvsp[-2].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005019 ;
5020 break;}
5021case 308:
5022#line 3037 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5023{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005024 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005025 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5026 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005027 if (!PT)
5028 GEN_ERROR("Can't store to a nonpointer type: " +
David Greene718fda32007-08-01 03:59:32 +00005029 (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005030 const Type *ElTy = PT->getElementType();
David Greene718fda32007-08-01 03:59:32 +00005031 if (ElTy != yyvsp[-4].ValueVal->getType())
5032 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005033 "' into space of type '" + ElTy->getDescription() + "'");
5034
David Greene718fda32007-08-01 03:59:32 +00005035 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005036 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005037 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
5038 delete yyvsp[-2].TypeVal;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005039 ;
5040 break;}
5041case 309:
5042#line 3054 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
5043{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005044 if (!UpRefs.empty())
David Greene718fda32007-08-01 03:59:32 +00005045 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5046 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005047 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005048
David Greene718fda32007-08-01 03:59:32 +00005049 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005050 GEN_ERROR("Invalid getelementptr indices for type '" +
David Greene718fda32007-08-01 03:59:32 +00005051 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
5052 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005053 CHECK_FOR_ERROR
David Greene718fda32007-08-01 03:59:32 +00005054 yyval.InstVal = new GetElementPtrInst(tmpVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size());
5055 delete yyvsp[-2].TypeVal;
5056 delete yyvsp[0].ValueList;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005057 ;
5058 break;}
5059}
5060 /* the action file gets copied in in place of this dollarsign */
5061#line 543 "/usr/share/bison.simple"
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005062
5063 yyvsp -= yylen;
5064 yyssp -= yylen;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005065#ifdef YYLSP_NEEDED
5066 yylsp -= yylen;
5067#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00005068
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005069#if YYDEBUG != 0
5070 if (yydebug)
5071 {
5072 short *ssp1 = yyss - 1;
5073 fprintf (stderr, "state stack now");
5074 while (ssp1 != yyssp)
5075 fprintf (stderr, " %d", *++ssp1);
5076 fprintf (stderr, "\n");
5077 }
5078#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005079
5080 *++yyvsp = yyval;
5081
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005082#ifdef YYLSP_NEEDED
5083 yylsp++;
5084 if (yylen == 0)
5085 {
5086 yylsp->first_line = yylloc.first_line;
5087 yylsp->first_column = yylloc.first_column;
5088 yylsp->last_line = (yylsp-1)->last_line;
5089 yylsp->last_column = (yylsp-1)->last_column;
5090 yylsp->text = 0;
5091 }
5092 else
5093 {
5094 yylsp->last_line = (yylsp+yylen-1)->last_line;
5095 yylsp->last_column = (yylsp+yylen-1)->last_column;
5096 }
5097#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005098
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005099 /* Now "shift" the result of the reduction.
5100 Determine what state that goes to,
5101 based on the state we popped back to
5102 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005103
5104 yyn = yyr1[yyn];
5105
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005106 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5107 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005108 yystate = yytable[yystate];
5109 else
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005110 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005111
5112 goto yynewstate;
5113
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005114yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005115
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005116 if (! yyerrstatus)
5117 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005118 {
5119 ++yynerrs;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005120
5121#ifdef YYERROR_VERBOSE
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005122 yyn = yypact[yystate];
5123
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005124 if (yyn > YYFLAG && yyn < YYLAST)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005125 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005126 int size = 0;
5127 char *msg;
5128 int x, count;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005129
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005130 count = 0;
5131 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5132 for (x = (yyn < 0 ? -yyn : 0);
5133 x < (sizeof(yytname) / sizeof(char *)); x++)
5134 if (yycheck[x + yyn] == x)
5135 size += strlen(yytname[x]) + 15, count++;
5136 msg = (char *) malloc(size + 15);
5137 if (msg != 0)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005138 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005139 strcpy(msg, "parse error");
David Greene718fda32007-08-01 03:59:32 +00005140
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005141 if (count < 5)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005142 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005143 count = 0;
5144 for (x = (yyn < 0 ? -yyn : 0);
5145 x < (sizeof(yytname) / sizeof(char *)); x++)
5146 if (yycheck[x + yyn] == x)
David Greene718fda32007-08-01 03:59:32 +00005147 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005148 strcat(msg, count == 0 ? ", expecting `" : " or `");
5149 strcat(msg, yytname[x]);
5150 strcat(msg, "'");
5151 count++;
David Greene718fda32007-08-01 03:59:32 +00005152 }
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005153 }
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005154 yyerror(msg);
5155 free(msg);
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005156 }
5157 else
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005158 yyerror ("parse error; also virtual memory exceeded");
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005159 }
5160 else
5161#endif /* YYERROR_VERBOSE */
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005162 yyerror("parse error");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005163 }
5164
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005165 goto yyerrlab1;
5166yyerrlab1: /* here on error raised explicitly by an action */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005167
5168 if (yyerrstatus == 3)
5169 {
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005170 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005171
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005172 /* return failure if at end of input */
5173 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005174 YYABORT;
5175
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005176#if YYDEBUG != 0
5177 if (yydebug)
5178 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5179#endif
5180
5181 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005182 }
5183
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005184 /* Else will try to reuse lookahead token
5185 after shifting the error token. */
5186
5187 yyerrstatus = 3; /* Each real token shifted decrements this */
5188
5189 goto yyerrhandle;
5190
5191yyerrdefault: /* current state does not do anything special for the error token. */
5192
5193#if 0
5194 /* This is wrong; only states that explicitly want error tokens
5195 should shift them. */
5196 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5197 if (yyn) goto yydefault;
5198#endif
5199
5200yyerrpop: /* pop the current state because it cannot handle the error token */
5201
5202 if (yyssp == yyss) YYABORT;
5203 yyvsp--;
5204 yystate = *--yyssp;
5205#ifdef YYLSP_NEEDED
5206 yylsp--;
5207#endif
5208
5209#if YYDEBUG != 0
5210 if (yydebug)
5211 {
5212 short *ssp1 = yyss - 1;
5213 fprintf (stderr, "Error: state stack now");
5214 while (ssp1 != yyssp)
5215 fprintf (stderr, " %d", *++ssp1);
5216 fprintf (stderr, "\n");
5217 }
5218#endif
5219
5220yyerrhandle:
5221
5222 yyn = yypact[yystate];
5223 if (yyn == YYFLAG)
5224 goto yyerrdefault;
5225
5226 yyn += YYTERROR;
5227 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5228 goto yyerrdefault;
5229
5230 yyn = yytable[yyn];
5231 if (yyn < 0)
5232 {
5233 if (yyn == YYFLAG)
5234 goto yyerrpop;
5235 yyn = -yyn;
5236 goto yyreduce;
5237 }
5238 else if (yyn == 0)
5239 goto yyerrpop;
5240
Reid Spencer68a24bd2005-08-27 18:50:39 +00005241 if (yyn == YYFINAL)
5242 YYACCEPT;
5243
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005244#if YYDEBUG != 0
5245 if (yydebug)
5246 fprintf(stderr, "Shifting error token, ");
5247#endif
David Greene718fda32007-08-01 03:59:32 +00005248
Reid Spencer68a24bd2005-08-27 18:50:39 +00005249 *++yyvsp = yylval;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005250#ifdef YYLSP_NEEDED
5251 *++yylsp = yylloc;
5252#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00005253
Reid Spencer68a24bd2005-08-27 18:50:39 +00005254 yystate = yyn;
5255 goto yynewstate;
5256
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005257 yyacceptlab:
5258 /* YYACCEPT comes here. */
5259 if (yyfree_stacks)
5260 {
5261 free (yyss);
5262 free (yyvs);
5263#ifdef YYLSP_NEEDED
5264 free (yyls);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005265#endif
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005266 }
5267 return 0;
Reid Spencerb8f85052007-07-31 03:50:36 +00005268
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005269 yyabortlab:
5270 /* YYABORT comes here. */
5271 if (yyfree_stacks)
5272 {
5273 free (yyss);
5274 free (yyvs);
5275#ifdef YYLSP_NEEDED
5276 free (yyls);
Reid Spencerb8f85052007-07-31 03:50:36 +00005277#endif
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005278 }
5279 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005280}
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005281#line 3071 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005282
5283
Reid Spencer14310612006-12-31 05:40:51 +00005284// common code from the two 'RunVMAsmParser' functions
5285static Module* RunParser(Module * M) {
5286
5287 llvmAsmlineno = 1; // Reset the current line number...
5288 CurModule.CurrentModule = M;
5289#if YYDEBUG
5290 yydebug = Debug;
5291#endif
5292
5293 // Check to make sure the parser succeeded
5294 if (yyparse()) {
5295 if (ParserResult)
5296 delete ParserResult;
5297 return 0;
5298 }
5299
Reid Spencer0d60b5a2007-03-30 01:37:39 +00005300 // Emit an error if there are any unresolved types left.
5301 if (!CurModule.LateResolveTypes.empty()) {
5302 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5303 if (DID.Type == ValID::LocalName) {
5304 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5305 } else {
5306 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5307 }
5308 if (ParserResult)
5309 delete ParserResult;
5310 return 0;
5311 }
5312
5313 // Emit an error if there are any unresolved values left.
5314 if (!CurModule.LateResolveValues.empty()) {
5315 Value *V = CurModule.LateResolveValues.back();
5316 std::map<Value*, std::pair<ValID, int> >::iterator I =
5317 CurModule.PlaceHolderInfo.find(V);
5318
5319 if (I != CurModule.PlaceHolderInfo.end()) {
5320 ValID &DID = I->second.first;
5321 if (DID.Type == ValID::LocalName) {
5322 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5323 } else {
5324 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5325 }
5326 if (ParserResult)
5327 delete ParserResult;
5328 return 0;
5329 }
5330 }
5331
Reid Spencer14310612006-12-31 05:40:51 +00005332 // Check to make sure that parsing produced a result
5333 if (!ParserResult)
5334 return 0;
5335
5336 // Reset ParserResult variable while saving its value for the result.
5337 Module *Result = ParserResult;
5338 ParserResult = 0;
5339
5340 return Result;
5341}
5342
Reid Spencer61c83e02006-08-18 08:43:06 +00005343void llvm::GenerateError(const std::string &message, int LineNo) {
5344 if (LineNo == -1) LineNo = llvmAsmlineno;
5345 // TODO: column number in exception
5346 if (TheParseError)
5347 TheParseError->setError(CurFilename, message, LineNo);
5348 TriggerError = 1;
5349}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005350
5351int yyerror(const char *ErrorMsg) {
5352 std::string where
5353 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5354 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00005355 std::string errMsg = where + "error: " + std::string(ErrorMsg);
5356 if (yychar != YYEMPTY && yychar != 0)
5357 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
5358 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005359 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005360 return 0;
5361}