blob: a9e130ca73679081192e43eae64beb0090c5d5d1 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattner0275cff2007-08-06 21:00:46 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004
Chris Lattner0275cff2007-08-06 21:00: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
Chris Lattner0275cff2007-08-06 21:00:46 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattner0275cff2007-08-06 21:00:46 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattner0275cff2007-08-06 21:00: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
Chris Lattner0275cff2007-08-06 21:00:46 +0000158#line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000159
160#include "ParserInternals.h"
161#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000162#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000163#include "llvm/Instructions.h"
164#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000165#include "llvm/ValueSymbolTable.h"
Chandler Carruth02202192007-08-04 01:56:21 +0000166#include "llvm/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000167#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000168#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000169#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000170#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000171#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000172#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000173#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000174#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000175#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000176#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000177#ifndef NDEBUG
178#define YYDEBUG 1
179#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000180
Reid Spencere4f47592006-08-18 17:32:55 +0000181// The following is a gross hack. In order to rid the libAsmParser library of
182// exceptions, we have to have a way of getting the yyparse function to go into
183// an error situation. So, whenever we want an error to occur, the GenerateError
184// function (see bottom of file) sets TriggerError. Then, at the end of each
185// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
186// (a goto) to put YACC in error state. Furthermore, several calls to
187// GenerateError are made from inside productions and they must simulate the
188// previous exception behavior by exiting the production immediately. We have
189// replaced these with the GEN_ERROR macro which calls GeneratError and then
190// immediately invokes YYERROR. This would be so much cleaner if it was a
191// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000192static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000193#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000194#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
195
Reid Spencer68a24bd2005-08-27 18:50:39 +0000196int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
197int yylex(); // declaration" of xxx warnings.
198int yyparse();
199
200namespace llvm {
201 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000202#if YYDEBUG
203static cl::opt<bool>
204Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
205 cl::Hidden, cl::init(false));
206#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000207}
208using namespace llvm;
209
210static Module *ParserResult;
211
212// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
213// relating to upreferences in the input stream.
214//
215//#define DEBUG_UPREFS 1
216#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000217#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000218#else
219#define UR_OUT(X)
220#endif
221
222#define YYERROR_VERBOSE 1
223
Chris Lattnerb475c422005-11-12 18:22:38 +0000224static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000225
226
227// This contains info used when building the body of a function. It is
228// destroyed when the function is completed.
229//
230typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000231
Reid Spencer68a24bd2005-08-27 18:50:39 +0000232static void
Reid Spencer93c40032007-03-19 18:40:50 +0000233ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000234
235static struct PerModuleInfo {
236 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000237 ValueList Values; // Module level numbered definitions
238 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000239 std::vector<PATypeHolder> Types;
240 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000241
242 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000243 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000244 /// that we can resolve them later and print error messages as appropriate.
245 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
246
247 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
248 // references to global values. Global values may be referenced before they
249 // are defined, and if so, the temporary object that they represent is held
250 // here. This is used for forward references of GlobalValues.
251 //
252 typedef std::map<std::pair<const PointerType *,
253 ValID>, GlobalValue*> GlobalRefsType;
254 GlobalRefsType GlobalRefs;
255
256 void ModuleDone() {
257 // If we could not resolve some functions at function compilation time
258 // (calls to functions before they are defined), resolve them now... Types
259 // are resolved when the constant pool has been completely parsed.
260 //
261 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000262 if (TriggerError)
263 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000264
265 // Check to make sure that all global value forward references have been
266 // resolved!
267 //
268 if (!GlobalRefs.empty()) {
269 std::string UndefinedReferences = "Unresolved global references exist:\n";
270
271 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
272 I != E; ++I) {
273 UndefinedReferences += " " + I->first.first->getDescription() + " " +
274 I->first.second.getName() + "\n";
275 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000276 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000277 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000278 }
279
Chandler Carruth02202192007-08-04 01:56:21 +0000280 // Look for intrinsic functions and CallInst that need to be upgraded
281 for (Module::iterator FI = CurrentModule->begin(),
282 FE = CurrentModule->end(); FI != FE; )
283 UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
284
Reid Spencer68a24bd2005-08-27 18:50:39 +0000285 Values.clear(); // Clear out function local definitions
286 Types.clear();
287 CurrentModule = 0;
288 }
289
Reid Spencer68a24bd2005-08-27 18:50:39 +0000290 // GetForwardRefForGlobal - Check to see if there is a forward reference
291 // for this global. If so, remove it from the GlobalRefs map and return it.
292 // If not, just return null.
293 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
294 // Check to see if there is a forward reference to this global variable...
295 // if there is, eliminate it and patch the reference to use the new def'n.
296 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
297 GlobalValue *Ret = 0;
298 if (I != GlobalRefs.end()) {
299 Ret = I->second;
300 GlobalRefs.erase(I);
301 }
302 return Ret;
303 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000304
305 bool TypeIsUnresolved(PATypeHolder* PATy) {
306 // If it isn't abstract, its resolved
307 const Type* Ty = PATy->get();
308 if (!Ty->isAbstract())
309 return false;
310 // Traverse the type looking for abstract types. If it isn't abstract then
311 // we don't need to traverse that leg of the type.
312 std::vector<const Type*> WorkList, SeenList;
313 WorkList.push_back(Ty);
314 while (!WorkList.empty()) {
315 const Type* Ty = WorkList.back();
316 SeenList.push_back(Ty);
317 WorkList.pop_back();
318 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
319 // Check to see if this is an unresolved type
320 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
321 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
322 for ( ; I != E; ++I) {
323 if (I->second.get() == OpTy)
324 return true;
325 }
326 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
327 const Type* TheTy = SeqTy->getElementType();
328 if (TheTy->isAbstract() && TheTy != Ty) {
329 std::vector<const Type*>::iterator I = SeenList.begin(),
330 E = SeenList.end();
331 for ( ; I != E; ++I)
332 if (*I == TheTy)
333 break;
334 if (I == E)
335 WorkList.push_back(TheTy);
336 }
337 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
338 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
339 const Type* TheTy = StrTy->getElementType(i);
340 if (TheTy->isAbstract() && TheTy != Ty) {
341 std::vector<const Type*>::iterator I = SeenList.begin(),
342 E = SeenList.end();
343 for ( ; I != E; ++I)
344 if (*I == TheTy)
345 break;
346 if (I == E)
347 WorkList.push_back(TheTy);
348 }
349 }
350 }
351 }
352 return false;
353 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354} CurModule;
355
356static struct PerFunctionInfo {
357 Function *CurrentFunction; // Pointer to current function being created
358
Reid Spencer93c40032007-03-19 18:40:50 +0000359 ValueList Values; // Keep track of #'d definitions
360 unsigned NextValNum;
361 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000362 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000363 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000364 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000365
366 /// BBForwardRefs - When we see forward references to basic blocks, keep
367 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000368 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000369
370 inline PerFunctionInfo() {
371 CurrentFunction = 0;
372 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000373 Linkage = GlobalValue::ExternalLinkage;
374 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000375 }
376
377 inline void FunctionStart(Function *M) {
378 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000379 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000380 }
381
382 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000383 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000384 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000385 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000386 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000387 return;
388 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000389
390 // Resolve all forward references now.
391 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
392
393 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000394 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000395 CurrentFunction = 0;
396 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000397 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000398 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000399 }
400} CurFun; // Info for the current function...
401
402static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
403
404
405//===----------------------------------------------------------------------===//
406// Code to handle definitions of all the types
407//===----------------------------------------------------------------------===//
408
Reid Spencer93c40032007-03-19 18:40:50 +0000409static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
410 // Things that have names or are void typed don't get slot numbers
411 if (V->hasName() || (V->getType() == Type::VoidTy))
412 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000413
Reid Spencer93c40032007-03-19 18:40:50 +0000414 // In the case of function values, we have to allow for the forward reference
415 // of basic blocks, which are included in the numbering. Consequently, we keep
416 // track of the next insertion location with NextValNum. When a BB gets
417 // inserted, it could change the size of the CurFun.Values vector.
418 if (&ValueTab == &CurFun.Values) {
419 if (ValueTab.size() <= CurFun.NextValNum)
420 ValueTab.resize(CurFun.NextValNum+1);
421 ValueTab[CurFun.NextValNum++] = V;
422 return;
423 }
424 // For all other lists, its okay to just tack it on the back of the vector.
425 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000426}
427
428static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
429 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000430 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000431 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000432 if (D.Num < CurModule.Types.size())
433 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000434 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000435 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000436 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000437 D.destroy(); // Free old strdup'd memory...
438 return N;
439 }
440 break;
441 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000442 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000443 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000444 }
445
446 // If we reached here, we referenced either a symbol that we don't know about
447 // or an id number that hasn't been read yet. We may be referencing something
448 // forward, so just create an entry to be resolved later and get to it...
449 //
450 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
451
452
453 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000454 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000455 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000456 return 0;
457 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000458 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000459 return 0;
460 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000461 }
462
Reid Spencer861d9d62006-11-28 07:29:44 +0000463 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000464 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000465 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000466
Reid Spencer861d9d62006-11-28 07:29:44 +0000467 Type *Typ = OpaqueType::get();
468 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
469 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000470 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000471
Reid Spencer93c40032007-03-19 18:40:50 +0000472// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000473// the provided ValID. If the value exists and has already been defined, return
474// it. Otherwise return null.
475//
Reid Spencer93c40032007-03-19 18:40:50 +0000476static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000477 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000478 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000479 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000480 return 0;
481 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000482
483 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000484 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000485 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000486 if (D.Num >= CurFun.Values.size())
487 return 0;
488 Value *Result = CurFun.Values[D.Num];
489 if (Ty != Result->getType()) {
490 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
491 Result->getType()->getDescription() + "' does not match "
492 "expected type, '" + Ty->getDescription() + "'");
493 return 0;
494 }
495 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000496 }
497 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000498 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000499 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000500 Value *Result = CurModule.Values[D.Num];
501 if (Ty != Result->getType()) {
502 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
503 Result->getType()->getDescription() + "' does not match "
504 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000505 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000506 }
507 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000508 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000509
510 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000511 if (!inFunctionScope())
512 return 0;
513 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000514 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000515 if (N == 0)
516 return 0;
517 if (N->getType() != Ty)
518 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000519
520 D.destroy(); // Free old strdup'd memory...
521 return N;
522 }
523 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000524 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000525 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000526 if (N == 0)
527 return 0;
528 if (N->getType() != Ty)
529 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000530
531 D.destroy(); // Free old strdup'd memory...
532 return N;
533 }
534
535 // Check to make sure that "Ty" is an integral type, and that our
536 // value will fit into the specified type...
537 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000538 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000539 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000540 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000541 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000542 return 0;
543 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000544 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000545
546 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000547 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
548 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000549 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000550 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000551 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000552 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000553 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000554 }
555 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000556 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000557 }
558
559 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000560 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000561 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000562 return 0;
563 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000564 return ConstantFP::get(Ty, D.ConstPoolFP);
565
566 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000567 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000568 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000569 return 0;
570 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000571 return ConstantPointerNull::get(cast<PointerType>(Ty));
572
573 case ValID::ConstUndefVal: // Is it an undef value?
574 return UndefValue::get(Ty);
575
Chris Lattner7aa61892005-12-21 17:53:23 +0000576 case ValID::ConstZeroVal: // Is it a zero value?
577 return Constant::getNullValue(Ty);
578
Reid Spencer68a24bd2005-08-27 18:50:39 +0000579 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000580 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000581 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000582 return 0;
583 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584 return D.ConstantValue;
585
Chris Lattner0e9c3762006-01-25 22:27:16 +0000586 case ValID::InlineAsmVal: { // Inline asm expression
587 const PointerType *PTy = dyn_cast<PointerType>(Ty);
588 const FunctionType *FTy =
589 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000590 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000591 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000592 return 0;
593 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000594 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
595 D.IAD->HasSideEffects);
596 D.destroy(); // Free InlineAsmDescriptor.
597 return IA;
598 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000599 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000600 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000601 return 0;
602 } // End of switch
603
Reid Spencera9720f52007-02-05 17:04:00 +0000604 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000605 return 0;
606}
607
Reid Spencer93c40032007-03-19 18:40:50 +0000608// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000609// value is not already defined, it "improvises" by creating a placeholder var
610// that looks and acts just like the requested variable. When the value is
611// defined later, all uses of the placeholder variable are replaced with the
612// real thing.
613//
614static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000615 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000616 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000617 return 0;
618 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000619
620 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000621 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000622 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000623 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000624
Reid Spencer5b7e7532006-09-28 19:28:24 +0000625 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000626 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000627 return 0;
628 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000629
630 // If we reached here, we referenced either a symbol that we don't know about
631 // or an id number that hasn't been read yet. We may be referencing something
632 // forward, so just create an entry to be resolved later and get to it...
633 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000634 switch (ID.Type) {
635 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000636 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000637 const PointerType *PTy = dyn_cast<PointerType>(Ty);
638 if (!PTy) {
639 GenerateError("Invalid type for reference to global" );
640 return 0;
641 }
642 const Type* ElTy = PTy->getElementType();
643 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
644 V = new Function(FTy, GlobalValue::ExternalLinkage);
645 else
646 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
647 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000648 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000649 default:
650 V = new Argument(Ty);
651 }
652
Reid Spencer68a24bd2005-08-27 18:50:39 +0000653 // Remember where this forward reference came from. FIXME, shouldn't we try
654 // to recycle these things??
655 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
656 llvmAsmlineno)));
657
658 if (inFunctionScope())
659 InsertValue(V, CurFun.LateResolveValues);
660 else
661 InsertValue(V, CurModule.LateResolveValues);
662 return V;
663}
664
Reid Spencer93c40032007-03-19 18:40:50 +0000665/// defineBBVal - This is a definition of a new basic block with the specified
666/// identifier which must be the same as CurFun.NextValNum, if its numeric.
667static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000668 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000669
Reid Spencer68a24bd2005-08-27 18:50:39 +0000670 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000671
Reid Spencer93c40032007-03-19 18:40:50 +0000672 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000673
Reid Spencer93c40032007-03-19 18:40:50 +0000674 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
675 if (BBI != CurFun.BBForwardRefs.end()) {
676 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000677 // The forward declaration could have been inserted anywhere in the
678 // function: insert it into the correct place now.
679 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
680 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000681
Reid Spencer66728ef2007-03-20 01:13:36 +0000682 // We're about to erase the entry, save the key so we can clean it up.
683 ValID Tmp = BBI->first;
684
Reid Spencer93c40032007-03-19 18:40:50 +0000685 // Erase the forward ref from the map as its no longer "forward"
686 CurFun.BBForwardRefs.erase(ID);
687
Reid Spencer66728ef2007-03-20 01:13:36 +0000688 // The key has been removed from the map but so we don't want to leave
689 // strdup'd memory around so destroy it too.
690 Tmp.destroy();
691
Reid Spencer93c40032007-03-19 18:40:50 +0000692 // If its a numbered definition, bump the number and set the BB value.
693 if (ID.Type == ValID::LocalID) {
694 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
695 InsertValue(BB);
696 }
697
698 ID.destroy();
699 return BB;
700 }
701
702 // We haven't seen this BB before and its first mention is a definition.
703 // Just create it and return it.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000704 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Reid Spencer93c40032007-03-19 18:40:50 +0000705 BB = new BasicBlock(Name, CurFun.CurrentFunction);
706 if (ID.Type == ValID::LocalID) {
707 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
708 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000709 }
Reid Spencer93c40032007-03-19 18:40:50 +0000710
711 ID.destroy(); // Free strdup'd memory
712 return BB;
713}
714
715/// getBBVal - get an existing BB value or create a forward reference for it.
716///
717static BasicBlock *getBBVal(const ValID &ID) {
718 assert(inFunctionScope() && "Can't get basic block at global scope!");
719
720 BasicBlock *BB = 0;
721
722 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
723 if (BBI != CurFun.BBForwardRefs.end()) {
724 BB = BBI->second;
725 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000726 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000727 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
728 if (N)
729 if (N->getType()->getTypeID() == Type::LabelTyID)
730 BB = cast<BasicBlock>(N);
731 else
732 GenerateError("Reference to label '" + Name + "' is actually of type '"+
733 N->getType()->getDescription() + "'");
734 } else if (ID.Type == ValID::LocalID) {
735 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
736 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
737 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
738 else
739 GenerateError("Reference to label '%" + utostr(ID.Num) +
740 "' is actually of type '"+
741 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
742 }
743 } else {
744 GenerateError("Illegal label reference " + ID.getName());
745 return 0;
746 }
747
748 // If its already been defined, return it now.
749 if (BB) {
750 ID.destroy(); // Free strdup'd memory.
751 return BB;
752 }
753
754 // Otherwise, this block has not been seen before, create it.
755 std::string Name;
756 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000757 Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000758 BB = new BasicBlock(Name, CurFun.CurrentFunction);
759
760 // Insert it in the forward refs map.
761 CurFun.BBForwardRefs[ID] = BB;
762
Reid Spencer68a24bd2005-08-27 18:50:39 +0000763 return BB;
764}
765
766
767//===----------------------------------------------------------------------===//
768// Code to handle forward references in instructions
769//===----------------------------------------------------------------------===//
770//
771// This code handles the late binding needed with statements that reference
772// values not defined yet... for example, a forward branch, or the PHI node for
773// a loop body.
774//
775// This keeps a table (CurFun.LateResolveValues) of all such forward references
776// and back patchs after we are done.
777//
778
779// ResolveDefinitions - If we could not resolve some defs at parsing
780// time (forward branches, phi functions for loops, etc...) resolve the
781// defs now...
782//
783static void
Reid Spencer93c40032007-03-19 18:40:50 +0000784ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000785 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000786 while (!LateResolvers.empty()) {
787 Value *V = LateResolvers.back();
788 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000789
Reid Spencer93c40032007-03-19 18:40:50 +0000790 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
791 CurModule.PlaceHolderInfo.find(V);
792 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000793
Reid Spencer93c40032007-03-19 18:40:50 +0000794 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000795
Reid Spencer93c40032007-03-19 18:40:50 +0000796 Value *TheRealValue = getExistingVal(V->getType(), DID);
797 if (TriggerError)
798 return;
799 if (TheRealValue) {
800 V->replaceAllUsesWith(TheRealValue);
801 delete V;
802 CurModule.PlaceHolderInfo.erase(PHI);
803 } else if (FutureLateResolvers) {
804 // Functions have their unresolved items forwarded to the module late
805 // resolver table
806 InsertValue(V, *FutureLateResolvers);
807 } else {
808 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
809 GenerateError("Reference to an invalid definition: '" +DID.getName()+
810 "' of type '" + V->getType()->getDescription() + "'",
811 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000812 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000813 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000814 GenerateError("Reference to an invalid definition: #" +
815 itostr(DID.Num) + " of type '" +
816 V->getType()->getDescription() + "'",
817 PHI->second.second);
818 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000819 }
820 }
821 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000822 LateResolvers.clear();
823}
824
825// ResolveTypeTo - A brand new type was just declared. This means that (if
826// name is not null) things referencing Name can be resolved. Otherwise, things
827// refering to the number can be resolved. Do this now.
828//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000829static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000830 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000831 if (Name)
832 D = ValID::createLocalName(*Name);
833 else
834 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000835
Reid Spencer861d9d62006-11-28 07:29:44 +0000836 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000837 CurModule.LateResolveTypes.find(D);
838 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000839 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000840 CurModule.LateResolveTypes.erase(I);
841 }
842}
843
844// setValueName - Set the specified value to the name given. The name may be
845// null potentially, in which case this is a noop. The string passed in is
846// assumed to be a malloc'd string buffer, and is free'd by this function.
847//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000848static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000849 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000850 std::string Name(*NameStr); // Copy string
851 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000852
Reid Spencer41dff5e2007-01-26 08:05:27 +0000853 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000854 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000855 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000856 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000857
Reid Spencera9720f52007-02-05 17:04:00 +0000858 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000859 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
860 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000861 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000862 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000863 return;
864 }
865
866 // Set the name.
867 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000868}
869
870/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
871/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000872static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000873ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000874 GlobalValue::LinkageTypes Linkage,
875 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000876 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000877 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000878 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000879 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000880 return 0;
881 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000882
883 const PointerType *PTy = PointerType::get(Ty);
884
885 std::string Name;
886 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000887 Name = *NameStr; // Copy string
888 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000889 }
890
891 // See if this global value was forward referenced. If so, recycle the
892 // object.
893 ValID ID;
894 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000895 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000896 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000897 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000898 }
899
900 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
901 // Move the global to the end of the list, from whereever it was
902 // previously inserted.
903 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
904 CurModule.CurrentModule->getGlobalList().remove(GV);
905 CurModule.CurrentModule->getGlobalList().push_back(GV);
906 GV->setInitializer(Initializer);
907 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000908 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000909 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000910 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000911 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000912 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000913 }
914
Reid Spenceref9b9a72007-02-05 20:47:22 +0000915 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +0000916 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +0000917 // if the global we're parsing has an initializer (is a definition) and
918 // has external linkage.
919 if (Initializer && Linkage != GlobalValue::InternalLinkage)
920 // If there is already a global with external linkage with this name
921 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
922 // If we allow this GVar to get created, it will be renamed in the
923 // symbol table because it conflicts with an existing GVar. We can't
924 // allow redefinition of GVars whose linking indicates that their name
925 // must stay the same. Issue the error.
926 GenerateError("Redefinition of global variable named '" + Name +
927 "' of type '" + Ty->getDescription() + "'");
928 return 0;
929 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000930 }
931
932 // Otherwise there is no existing GV to use, create one now.
933 GlobalVariable *GV =
934 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000935 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000936 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000937 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000938 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000939}
940
941// setTypeName - Set the specified type to the name given. The name may be
942// null potentially, in which case this is a noop. The string passed in is
943// assumed to be a malloc'd string buffer, and is freed by this function.
944//
945// This function returns true if the type has already been defined, but is
946// allowed to be redefined in the specified context. If the name is a new name
947// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000948static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +0000949 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000950 if (NameStr == 0) return false;
951
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000952 std::string Name(*NameStr); // Copy string
953 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000954
955 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000956 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000957 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000958 return false;
959 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000960
961 // Set the type name, checking for conflicts as we do so.
962 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
963
964 if (AlreadyExists) { // Inserting a name that is already defined???
965 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +0000966 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000967
968 // There is only one case where this is allowed: when we are refining an
969 // opaque type. In this case, Existing will be an opaque type.
970 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
971 // We ARE replacing an opaque type!
972 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
973 return true;
974 }
975
976 // Otherwise, this is an attempt to redefine a type. That's okay if
977 // the redefinition is identical to the original. This will be so if
978 // Existing and T point to the same Type object. In this one case we
979 // allow the equivalent redefinition.
980 if (Existing == T) return true; // Yes, it's equal.
981
982 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +0000983 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000984 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000985 }
986
987 return false;
988}
989
990//===----------------------------------------------------------------------===//
991// Code for handling upreferences in type names...
992//
993
994// TypeContains - Returns true if Ty directly contains E in it.
995//
996static bool TypeContains(const Type *Ty, const Type *E) {
997 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
998 E) != Ty->subtype_end();
999}
1000
1001namespace {
1002 struct UpRefRecord {
1003 // NestingLevel - The number of nesting levels that need to be popped before
1004 // this type is resolved.
1005 unsigned NestingLevel;
1006
1007 // LastContainedTy - This is the type at the current binding level for the
1008 // type. Every time we reduce the nesting level, this gets updated.
1009 const Type *LastContainedTy;
1010
1011 // UpRefTy - This is the actual opaque type that the upreference is
1012 // represented with.
1013 OpaqueType *UpRefTy;
1014
1015 UpRefRecord(unsigned NL, OpaqueType *URTy)
1016 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1017 };
1018}
1019
1020// UpRefs - A list of the outstanding upreferences that need to be resolved.
1021static std::vector<UpRefRecord> UpRefs;
1022
1023/// HandleUpRefs - Every time we finish a new layer of types, this function is
1024/// called. It loops through the UpRefs vector, which is a list of the
1025/// currently active types. For each type, if the up reference is contained in
1026/// the newly completed type, we decrement the level count. When the level
1027/// count reaches zero, the upreferenced type is the type that is passed in:
1028/// thus we can complete the cycle.
1029///
1030static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001031 // If Ty isn't abstract, or if there are no up-references in it, then there is
1032 // nothing to resolve here.
1033 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1034
Reid Spencer68a24bd2005-08-27 18:50:39 +00001035 PATypeHolder Ty(ty);
1036 UR_OUT("Type '" << Ty->getDescription() <<
1037 "' newly formed. Resolving upreferences.\n" <<
1038 UpRefs.size() << " upreferences active!\n");
1039
1040 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1041 // to zero), we resolve them all together before we resolve them to Ty. At
1042 // the end of the loop, if there is anything to resolve to Ty, it will be in
1043 // this variable.
1044 OpaqueType *TypeToResolve = 0;
1045
1046 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1047 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1048 << UpRefs[i].second->getDescription() << ") = "
1049 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1050 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1051 // Decrement level of upreference
1052 unsigned Level = --UpRefs[i].NestingLevel;
1053 UpRefs[i].LastContainedTy = Ty;
1054 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1055 if (Level == 0) { // Upreference should be resolved!
1056 if (!TypeToResolve) {
1057 TypeToResolve = UpRefs[i].UpRefTy;
1058 } else {
1059 UR_OUT(" * Resolving upreference for "
1060 << UpRefs[i].second->getDescription() << "\n";
1061 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1062 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1063 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1064 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1065 }
1066 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1067 --i; // Do not skip the next element...
1068 }
1069 }
1070 }
1071
1072 if (TypeToResolve) {
1073 UR_OUT(" * Resolving upreference for "
1074 << UpRefs[i].second->getDescription() << "\n";
1075 std::string OldName = TypeToResolve->getDescription());
1076 TypeToResolve->refineAbstractTypeTo(Ty);
1077 }
1078
1079 return Ty;
1080}
1081
Reid Spencer68a24bd2005-08-27 18:50:39 +00001082//===----------------------------------------------------------------------===//
1083// RunVMAsmParser - Define an interface to this parser
1084//===----------------------------------------------------------------------===//
1085//
Reid Spencer14310612006-12-31 05:40:51 +00001086static Module* RunParser(Module * M);
1087
Reid Spencer68a24bd2005-08-27 18:50:39 +00001088Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1089 set_scan_file(F);
1090
1091 CurFilename = Filename;
1092 return RunParser(new Module(CurFilename));
1093}
1094
1095Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1096 set_scan_string(AsmString);
1097
1098 CurFilename = "from_memory";
1099 if (M == NULL) {
1100 return RunParser(new Module (CurFilename));
1101 } else {
1102 return RunParser(M);
1103 }
1104}
1105
1106
Chris Lattner0275cff2007-08-06 21:00:46 +00001107#line 963 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1108typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001109 llvm::Module *ModuleVal;
1110 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001111 llvm::BasicBlock *BasicBlockVal;
1112 llvm::TerminatorInst *TermInstVal;
1113 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001114 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001115
Reid Spencera132e042006-12-03 05:46:11 +00001116 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001117 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001118 llvm::PATypeHolder *TypeVal;
1119 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001120 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001121 llvm::ArgListType *ArgList;
1122 llvm::TypeWithAttrs TypeWithAttrs;
1123 llvm::TypeWithAttrsList *TypeWithAttrsList;
1124 llvm::ValueRefList *ValueRefList;
1125
Reid Spencer68a24bd2005-08-27 18:50:39 +00001126 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001127 std::list<std::pair<llvm::Value*,
1128 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001129 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001130 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001131
1132 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001133 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001134 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001135 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001136 int64_t SInt64Val;
1137 uint64_t UInt64Val;
1138 int SIntVal;
1139 unsigned UIntVal;
1140 double FPVal;
1141 bool BoolVal;
1142
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001143 std::string *StrVal; // This memory must be deleted
1144 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001145
Reid Spencera132e042006-12-03 05:46:11 +00001146 llvm::Instruction::BinaryOps BinaryOpVal;
1147 llvm::Instruction::TermOps TermOpVal;
1148 llvm::Instruction::MemoryOps MemOpVal;
1149 llvm::Instruction::CastOps CastOpVal;
1150 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001151 llvm::ICmpInst::Predicate IPredicate;
1152 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner0275cff2007-08-06 21:00:46 +00001153} YYSTYPE;
1154#include <stdio.h>
1155
1156#ifndef __cplusplus
1157#ifndef __STDC__
1158#define const
1159#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001160#endif
1161
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001162
Reid Spencer68a24bd2005-08-27 18:50:39 +00001163
Chris Lattner0275cff2007-08-06 21:00:46 +00001164#define YYFINAL 594
1165#define YYFLAG -32768
1166#define YYNTBASE 160
Reid Spencer68a24bd2005-08-27 18:50:39 +00001167
Chris Lattner0275cff2007-08-06 21:00:46 +00001168#define YYTRANSLATE(x) ((unsigned)(x) <= 399 ? yytranslate[x] : 241)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001169
Chris Lattner0275cff2007-08-06 21:00:46 +00001170static const short yytranslate[] = { 0,
1171 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 150,
1175 151, 148, 2, 147, 2, 2, 2, 2, 2, 2,
1176 2, 2, 2, 2, 2, 2, 2, 2, 2, 155,
1177 146, 156, 2, 2, 2, 2, 2, 2, 2, 2,
1178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1180 152, 149, 154, 2, 2, 2, 2, 2, 159, 2,
1181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1182 2, 2, 2, 2, 2, 2, 2, 2, 2, 153,
1183 2, 2, 157, 2, 158, 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, 2, 2, 2, 2, 2,
1191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1193 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1196 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1197 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1198 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1199 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1200 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1201 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1202 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1203 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1204 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1205 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1206 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1207 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1208 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1209 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
1210 137, 138, 139, 140, 141, 142, 143, 144, 145
1211};
Reid Spencerb8f85052007-07-31 03:50:36 +00001212
Chris Lattner0275cff2007-08-06 21:00:46 +00001213#if YYDEBUG != 0
1214static const short yyprhs[] = { 0,
1215 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1216 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1217 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1218 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1219 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1220 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
1221 120, 122, 124, 126, 127, 130, 131, 133, 135, 137,
1222 138, 141, 143, 145, 147, 149, 151, 153, 155, 157,
1223 158, 160, 162, 164, 165, 167, 169, 170, 172, 174,
1224 176, 178, 179, 181, 183, 184, 186, 188, 190, 192,
1225 194, 197, 199, 201, 203, 205, 207, 209, 211, 213,
1226 215, 216, 219, 221, 223, 225, 227, 228, 231, 232,
1227 235, 236, 240, 243, 244, 246, 247, 251, 253, 256,
1228 258, 260, 262, 264, 266, 268, 270, 272, 274, 277,
1229 279, 282, 288, 294, 300, 306, 310, 313, 319, 324,
1230 327, 329, 331, 333, 337, 339, 343, 345, 346, 348,
1231 352, 357, 361, 365, 370, 375, 379, 386, 392, 395,
1232 398, 401, 404, 407, 410, 413, 416, 419, 422, 425,
1233 428, 435, 441, 450, 457, 464, 472, 480, 487, 496,
1234 505, 509, 511, 513, 515, 517, 518, 521, 528, 530,
1235 531, 533, 536, 537, 541, 542, 546, 550, 554, 558,
1236 559, 567, 568, 577, 578, 587, 593, 596, 600, 602,
1237 606, 610, 614, 618, 620, 621, 627, 631, 633, 637,
1238 639, 640, 650, 652, 654, 659, 661, 663, 666, 670,
1239 671, 673, 675, 677, 679, 681, 683, 685, 687, 689,
1240 693, 695, 701, 703, 705, 707, 709, 711, 713, 716,
1241 719, 722, 726, 729, 730, 732, 735, 738, 742, 752,
1242 762, 771, 786, 788, 790, 797, 803, 806, 813, 821,
1243 825, 831, 832, 833, 837, 840, 842, 848, 854, 861,
1244 868, 873, 880, 885, 890, 897, 904, 907, 916, 918,
1245 920, 921, 925, 932, 936, 943, 946, 952, 960
1246};
1247
1248static const short yyrhs[] = { 73,
1249 0, 74, 0, 75, 0, 76, 0, 77, 0, 78,
1250 0, 79, 0, 80, 0, 81, 0, 85, 0, 86,
1251 0, 87, 0, 82, 0, 83, 0, 84, 0, 116,
1252 0, 117, 0, 118, 0, 119, 0, 120, 0, 121,
1253 0, 122, 0, 123, 0, 124, 0, 125, 0, 126,
1254 0, 127, 0, 90, 0, 91, 0, 92, 0, 93,
1255 0, 94, 0, 95, 0, 96, 0, 97, 0, 98,
1256 0, 99, 0, 100, 0, 101, 0, 102, 0, 103,
1257 0, 104, 0, 105, 0, 106, 0, 107, 0, 108,
1258 0, 109, 0, 96, 0, 97, 0, 98, 0, 99,
1259 0, 26, 0, 27, 0, 11, 0, 12, 0, 13,
1260 0, 16, 0, 15, 0, 14, 0, 19, 0, 22,
1261 0, 24, 0, 167, 0, 0, 167, 146, 0, 0,
1262 20, 0, 23, 0, 172, 0, 0, 170, 146, 0,
1263 42, 0, 44, 0, 43, 0, 45, 0, 47, 0,
1264 46, 0, 48, 0, 50, 0, 0, 143, 0, 144,
1265 0, 145, 0, 0, 46, 0, 48, 0, 0, 42,
1266 0, 43, 0, 44, 0, 47, 0, 0, 44, 0,
1267 42, 0, 0, 61, 0, 62, 0, 63, 0, 64,
1268 0, 65, 0, 60, 4, 0, 135, 0, 117, 0,
1269 134, 0, 118, 0, 137, 0, 138, 0, 140, 0,
1270 141, 0, 142, 0, 0, 181, 180, 0, 136, 0,
1271 139, 0, 135, 0, 134, 0, 0, 183, 182, 0,
1272 0, 53, 4, 0, 0, 147, 53, 4, 0, 34,
1273 22, 0, 0, 186, 0, 0, 147, 189, 188, 0,
1274 186, 0, 53, 4, 0, 11, 0, 12, 0, 13,
1275 0, 16, 0, 15, 0, 14, 0, 17, 0, 49,
1276 0, 190, 0, 191, 148, 0, 225, 0, 149, 4,
1277 0, 191, 150, 195, 151, 183, 0, 10, 150, 195,
1278 151, 183, 0, 152, 4, 153, 191, 154, 0, 155,
1279 4, 153, 191, 156, 0, 157, 196, 158, 0, 157,
1280 158, 0, 155, 157, 196, 158, 156, 0, 155, 157,
1281 158, 156, 0, 191, 181, 0, 191, 0, 10, 0,
1282 192, 0, 194, 147, 192, 0, 194, 0, 194, 147,
1283 39, 0, 39, 0, 0, 191, 0, 196, 147, 191,
1284 0, 191, 152, 199, 154, 0, 191, 152, 154, 0,
1285 191, 159, 22, 0, 191, 155, 199, 156, 0, 191,
1286 157, 199, 158, 0, 191, 157, 158, 0, 191, 155,
1287 157, 199, 158, 156, 0, 191, 155, 157, 158, 156,
1288 0, 191, 40, 0, 191, 41, 0, 191, 225, 0,
1289 191, 198, 0, 191, 25, 0, 165, 3, 0, 165,
1290 5, 0, 165, 4, 0, 165, 6, 0, 11, 26,
1291 0, 11, 27, 0, 166, 9, 0, 162, 150, 197,
1292 38, 191, 151, 0, 115, 150, 197, 236, 151, 0,
1293 129, 150, 197, 147, 197, 147, 197, 151, 0, 160,
1294 150, 197, 147, 197, 151, 0, 161, 150, 197, 147,
1295 197, 151, 0, 88, 163, 150, 197, 147, 197, 151,
1296 0, 89, 164, 150, 197, 147, 197, 151, 0, 131,
1297 150, 197, 147, 197, 151, 0, 132, 150, 197, 147,
1298 197, 147, 197, 151, 0, 133, 150, 197, 147, 197,
1299 147, 197, 151, 0, 199, 147, 197, 0, 197, 0,
1300 32, 0, 33, 0, 37, 0, 0, 193, 225, 0,
1301 121, 150, 202, 38, 191, 151, 0, 204, 0, 0,
1302 205, 0, 204, 205, 0, 0, 31, 206, 221, 0,
1303 0, 30, 207, 222, 0, 58, 57, 211, 0, 169,
1304 18, 191, 0, 169, 18, 10, 0, 0, 171, 175,
1305 201, 200, 197, 208, 188, 0, 0, 171, 173, 175,
1306 201, 200, 197, 209, 188, 0, 0, 171, 174, 175,
1307 201, 200, 191, 210, 188, 0, 171, 175, 35, 178,
1308 202, 0, 51, 212, 0, 54, 146, 213, 0, 22,
1309 0, 52, 146, 22, 0, 66, 146, 22, 0, 152,
1310 214, 154, 0, 214, 147, 22, 0, 22, 0, 0,
1311 215, 147, 191, 181, 168, 0, 191, 181, 168, 0,
1312 215, 0, 215, 147, 39, 0, 39, 0, 0, 179,
1313 193, 170, 150, 216, 151, 183, 187, 184, 0, 28,
1314 0, 157, 0, 177, 175, 217, 218, 0, 29, 0,
1315 158, 0, 228, 220, 0, 176, 175, 217, 0, 0,
1316 59, 0, 3, 0, 4, 0, 9, 0, 26, 0,
1317 27, 0, 40, 0, 41, 0, 25, 0, 155, 199,
1318 156, 0, 198, 0, 57, 223, 22, 147, 22, 0,
1319 7, 0, 8, 0, 167, 0, 170, 0, 225, 0,
1320 224, 0, 191, 226, 0, 228, 229, 0, 219, 229,
1321 0, 230, 169, 231, 0, 230, 233, 0, 0, 21,
1322 0, 67, 227, 0, 67, 10, 0, 68, 17, 226,
1323 0, 68, 11, 226, 147, 17, 226, 147, 17, 226,
1324 0, 69, 165, 226, 147, 17, 226, 152, 232, 154,
1325 0, 69, 165, 226, 147, 17, 226, 152, 154, 0,
1326 70, 179, 193, 226, 150, 235, 151, 183, 38, 17,
1327 226, 71, 17, 226, 0, 71, 0, 72, 0, 232,
1328 165, 224, 147, 17, 226, 0, 165, 224, 147, 17,
1329 226, 0, 169, 238, 0, 191, 152, 226, 147, 226,
1330 154, 0, 234, 147, 152, 226, 147, 226, 154, 0,
1331 191, 226, 181, 0, 235, 147, 191, 226, 181, 0,
1332 0, 0, 236, 147, 227, 0, 56, 55, 0, 55,
1333 0, 160, 191, 226, 147, 226, 0, 161, 191, 226,
1334 147, 226, 0, 88, 163, 191, 226, 147, 226, 0,
1335 89, 164, 191, 226, 147, 226, 0, 162, 227, 38,
1336 191, 0, 129, 227, 147, 227, 147, 227, 0, 130,
1337 227, 147, 191, 0, 131, 227, 147, 227, 0, 132,
1338 227, 147, 227, 147, 227, 0, 133, 227, 147, 227,
1339 147, 227, 0, 128, 234, 0, 237, 179, 193, 226,
1340 150, 235, 151, 183, 0, 240, 0, 36, 0, 0,
1341 110, 191, 185, 0, 110, 191, 147, 11, 226, 185,
1342 0, 111, 191, 185, 0, 111, 191, 147, 11, 226,
1343 185, 0, 112, 227, 0, 239, 113, 191, 226, 185,
1344 0, 239, 114, 227, 147, 191, 226, 185, 0, 115,
1345 191, 226, 236, 0
1346};
1347
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001348#endif
1349
Chris Lattner0275cff2007-08-06 21:00:46 +00001350#if YYDEBUG != 0
1351static const short yyrline[] = { 0,
1352 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1122, 1123,
1353 1123, 1123, 1123, 1123, 1123, 1124, 1124, 1124, 1124, 1124,
1354 1124, 1124, 1125, 1125, 1125, 1125, 1125, 1128, 1128, 1129,
1355 1129, 1130, 1130, 1131, 1131, 1132, 1132, 1136, 1136, 1137,
1356 1137, 1138, 1138, 1139, 1139, 1140, 1140, 1141, 1141, 1142,
1357 1142, 1143, 1144, 1149, 1150, 1150, 1150, 1150, 1150, 1152,
1358 1152, 1152, 1153, 1153, 1157, 1161, 1166, 1166, 1168, 1169,
1359 1174, 1180, 1181, 1182, 1183, 1184, 1188, 1189, 1190, 1194,
1360 1195, 1196, 1197, 1201, 1202, 1203, 1207, 1208, 1209, 1210,
1361 1211, 1215, 1216, 1217, 1220, 1220, 1221, 1222, 1223, 1224,
1362 1225, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241,
1363 1244, 1245, 1250, 1251, 1252, 1253, 1256, 1257, 1264, 1264,
1364 1271, 1271, 1280, 1288, 1288, 1294, 1294, 1296, 1301, 1314,
1365 1314, 1314, 1314, 1314, 1314, 1314, 1317, 1321, 1325, 1332,
1366 1337, 1345, 1375, 1406, 1411, 1423, 1433, 1437, 1447, 1454,
1367 1461, 1468, 1473, 1478, 1485, 1486, 1493, 1500, 1508, 1514,
1368 1526, 1554, 1570, 1597, 1625, 1651, 1671, 1697, 1717, 1729,
1369 1736, 1802, 1812, 1822, 1828, 1838, 1844, 1854, 1859, 1864,
1370 1872, 1884, 1906, 1914, 1920, 1931, 1936, 1941, 1947, 1953,
1371 1962, 1966, 1974, 1974, 1977, 1977, 1980, 1992, 2013, 2018,
1372 2026, 2027, 2031, 2031, 2035, 2035, 2038, 2041, 2065, 2076,
1373 2083, 2086, 2092, 2095, 2102, 2106, 2125, 2128, 2134, 2144,
1374 2148, 2153, 2155, 2160, 2165, 2174, 2184, 2195, 2199, 2208,
1375 2217, 2222, 2343, 2343, 2345, 2354, 2354, 2356, 2361, 2373,
1376 2377, 2382, 2386, 2390, 2394, 2398, 2402, 2406, 2410, 2414,
1377 2439, 2443, 2453, 2457, 2461, 2466, 2473, 2473, 2479, 2488,
1378 2492, 2501, 2510, 2519, 2523, 2530, 2534, 2538, 2543, 2553,
1379 2572, 2581, 2661, 2665, 2672, 2683, 2696, 2706, 2717, 2727,
1380 2736, 2745, 2748, 2749, 2756, 2760, 2765, 2786, 2803, 2817,
1381 2831, 2843, 2851, 2858, 2864, 2870, 2876, 2891, 2976, 2981,
1382 2985, 2992, 2999, 3007, 3014, 3022, 3030, 3044, 3061
1383};
1384#endif
1385
1386
1387#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1388
1389static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1390"EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL",
1391"VOID","INTTYPE","FLOAT","DOUBLE","X86_FP80","FP128","PPC_FP128","LABEL","TYPE",
1392"LOCALVAR","GLOBALVAR","LABELSTR","STRINGCONSTANT","ATSTRINGCONSTANT","PCTSTRINGCONSTANT",
1393"ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE",
1394"GLOBAL","CONSTANT","SECTION","ALIAS","VOLATILE","THREAD_LOCAL","TO","DOTDOTDOT",
1395"NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT",
1396"EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET","TRIPLE","ALIGN","DEPLIBS","CALL",
1397"TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK",
1398"X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE",
1399"UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM",
1400"FREM","AND","OR","XOR","SHL","LSHR","ASHR","ICMP","FCMP","EQ","NE","SLT","SGT",
1401"SLE","SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD",
1402"UNO","UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC",
1403"ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI",
1404"INTTOPTR","PTRTOINT","PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT",
1405"SHUFFLEVECTOR","SIGNEXT","ZEROEXT","NORETURN","INREG","SRET","NOUNWIND","NOALIAS",
1406"BYVAL","NEST","DEFAULT","HIDDEN","PROTECTED","'='","','","'*'","'\\\\'","'('",
1407"')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps","LogicalOps",
1408"CastOps","IPredicates","FPredicates","IntType","FPType","LocalName","OptLocalName",
1409"OptLocalAssign","GlobalName","OptGlobalAssign","GlobalAssign","GVInternalLinkage",
1410"GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage","FunctionDefineLinkage",
1411"AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs","FuncAttr","OptFuncAttrs",
1412"OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
1413"PrimType","Types","ArgType","ResultTypes","ArgTypeList","ArgTypeListI","TypeListI",
1414"ConstVal","ConstExpr","ConstVector","GlobalType","ThreadLocal","AliaseeRef",
1415"Module","DefinitionList","Definition","@1","@2","@3","@4","@5","AsmBlock","TargetDefinition",
1416"LibrariesDefinition","LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1417"FunctionHeader","END","Function","FunctionProto","OptSideEffect","ConstValueRef",
1418"SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1419"BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall",
1420"InstVal","OptVolatile","MemoryInst", NULL
1421};
1422#endif
1423
1424static const short yyr1[] = { 0,
1425 160, 160, 160, 160, 160, 160, 160, 160, 160, 161,
1426 161, 161, 161, 161, 161, 162, 162, 162, 162, 162,
1427 162, 162, 162, 162, 162, 162, 162, 163, 163, 163,
1428 163, 163, 163, 163, 163, 163, 163, 164, 164, 164,
1429 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
1430 164, 164, 164, 165, 166, 166, 166, 166, 166, 167,
1431 167, 167, 168, 168, 169, 169, 170, 170, 171, 171,
1432 172, 173, 173, 173, 173, 173, 174, 174, 174, 175,
1433 175, 175, 175, 176, 176, 176, 177, 177, 177, 177,
1434 177, 178, 178, 178, 179, 179, 179, 179, 179, 179,
1435 179, 180, 180, 180, 180, 180, 180, 180, 180, 180,
1436 181, 181, 182, 182, 182, 182, 183, 183, 184, 184,
1437 185, 185, 186, 187, 187, 188, 188, 189, 189, 190,
1438 190, 190, 190, 190, 190, 190, 191, 191, 191, 191,
1439 191, 191, 191, 191, 191, 191, 191, 191, 191, 192,
1440 193, 193, 194, 194, 195, 195, 195, 195, 196, 196,
1441 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1442 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1443 198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
1444 199, 199, 200, 200, 201, 201, 202, 202, 203, 203,
1445 204, 204, 206, 205, 207, 205, 205, 205, 205, 208,
1446 205, 209, 205, 210, 205, 205, 205, 205, 211, 212,
1447 212, 213, 214, 214, 214, 215, 215, 216, 216, 216,
1448 216, 217, 218, 218, 219, 220, 220, 221, 222, 223,
1449 223, 224, 224, 224, 224, 224, 224, 224, 224, 224,
1450 224, 224, 225, 225, 225, 225, 226, 226, 227, 228,
1451 228, 229, 230, 230, 230, 231, 231, 231, 231, 231,
1452 231, 231, 231, 231, 232, 232, 233, 234, 234, 235,
1453 235, 235, 236, 236, 237, 237, 238, 238, 238, 238,
1454 238, 238, 238, 238, 238, 238, 238, 238, 238, 239,
1455 239, 240, 240, 240, 240, 240, 240, 240, 240
1456};
1457
1458static const short yyr2[] = { 0,
1459 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1460 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1461 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1462 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1463 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1464 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1465 1, 1, 1, 0, 2, 0, 1, 1, 1, 0,
1466 2, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1467 1, 1, 1, 0, 1, 1, 0, 1, 1, 1,
1468 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
1469 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1470 0, 2, 1, 1, 1, 1, 0, 2, 0, 2,
1471 0, 3, 2, 0, 1, 0, 3, 1, 2, 1,
1472 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
1473 2, 5, 5, 5, 5, 3, 2, 5, 4, 2,
1474 1, 1, 1, 3, 1, 3, 1, 0, 1, 3,
1475 4, 3, 3, 4, 4, 3, 6, 5, 2, 2,
1476 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1477 6, 5, 8, 6, 6, 7, 7, 6, 8, 8,
1478 3, 1, 1, 1, 1, 0, 2, 6, 1, 0,
1479 1, 2, 0, 3, 0, 3, 3, 3, 3, 0,
1480 7, 0, 8, 0, 8, 5, 2, 3, 1, 3,
1481 3, 3, 3, 1, 0, 5, 3, 1, 3, 1,
1482 0, 9, 1, 1, 4, 1, 1, 2, 3, 0,
1483 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
1484 1, 5, 1, 1, 1, 1, 1, 1, 2, 2,
1485 2, 3, 2, 0, 1, 2, 2, 3, 9, 9,
1486 8, 14, 1, 1, 6, 5, 2, 6, 7, 3,
1487 5, 0, 0, 3, 2, 1, 5, 5, 6, 6,
1488 4, 6, 4, 4, 6, 6, 2, 8, 1, 1,
1489 0, 3, 6, 3, 6, 2, 5, 7, 4
1490};
1491
1492static const short yydefact[] = { 70,
1493 60, 67, 61, 68, 62, 205, 203, 0, 0, 0,
1494 0, 0, 0, 80, 69, 70, 201, 84, 87, 0,
1495 0, 217, 0, 0, 65, 0, 71, 72, 74, 73,
1496 75, 77, 76, 78, 79, 81, 82, 83, 80, 80,
1497 196, 202, 85, 86, 80, 206, 88, 89, 90, 91,
1498 80, 264, 204, 264, 0, 0, 225, 218, 219, 207,
1499 253, 254, 209, 130, 131, 132, 135, 134, 133, 136,
1500 137, 0, 0, 0, 0, 255, 256, 138, 208, 140,
1501 196, 196, 92, 195, 0, 95, 95, 265, 261, 66,
1502 236, 237, 238, 260, 220, 221, 224, 0, 158, 141,
1503 0, 0, 0, 0, 147, 159, 0, 139, 158, 0,
1504 0, 94, 93, 0, 193, 194, 0, 0, 96, 97,
1505 98, 99, 100, 0, 239, 0, 301, 263, 0, 222,
1506 157, 111, 153, 155, 0, 0, 0, 0, 0, 0,
1507 146, 0, 0, 0, 152, 0, 151, 0, 216, 130,
1508 131, 132, 135, 134, 133, 0, 0, 0, 210, 101,
1509 0, 233, 234, 235, 300, 286, 0, 0, 0, 0,
1510 95, 273, 274, 1, 2, 3, 4, 5, 6, 7,
1511 8, 9, 13, 14, 15, 10, 11, 12, 0, 0,
1512 0, 0, 0, 0, 16, 17, 18, 19, 20, 21,
1513 22, 23, 24, 25, 26, 27, 0, 0, 0, 0,
1514 0, 0, 0, 0, 0, 262, 95, 277, 0, 299,
1515 223, 150, 0, 117, 0, 0, 149, 0, 160, 117,
1516 212, 214, 0, 197, 178, 179, 174, 176, 175, 177,
1517 180, 173, 169, 170, 0, 0, 0, 0, 0, 0,
1518 0, 0, 0, 0, 0, 0, 0, 0, 172, 171,
1519 126, 0, 285, 267, 0, 266, 0, 0, 54, 0,
1520 0, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1521 37, 0, 52, 53, 48, 49, 50, 51, 38, 39,
1522 40, 41, 42, 43, 44, 45, 46, 47, 0, 121,
1523 121, 306, 0, 0, 297, 0, 0, 0, 0, 0,
1524 0, 0, 0, 0, 0, 0, 103, 105, 104, 102,
1525 106, 107, 108, 109, 110, 112, 156, 154, 143, 144,
1526 145, 148, 142, 126, 126, 0, 0, 0, 0, 0,
1527 0, 0, 0, 162, 192, 0, 0, 0, 166, 0,
1528 163, 0, 0, 0, 0, 211, 231, 242, 243, 244,
1529 249, 245, 246, 247, 248, 240, 0, 251, 258, 257,
1530 259, 0, 268, 0, 0, 0, 0, 0, 302, 0,
1531 304, 283, 0, 0, 0, 0, 0, 0, 0, 0,
1532 0, 0, 0, 0, 0, 116, 115, 113, 114, 118,
1533 213, 215, 0, 0, 0, 283, 0, 0, 0, 0,
1534 0, 161, 147, 159, 0, 164, 165, 0, 0, 0,
1535 0, 0, 128, 126, 230, 111, 228, 0, 241, 0,
1536 0, 0, 0, 0, 0, 0, 0, 0, 0, 309,
1537 0, 0, 0, 293, 294, 0, 0, 0, 0, 291,
1538 0, 121, 0, 0, 0, 0, 0, 0, 0, 0,
1539 0, 191, 168, 0, 0, 0, 0, 123, 129, 127,
1540 64, 0, 117, 0, 250, 0, 0, 282, 0, 0,
1541 121, 122, 121, 0, 0, 0, 0, 0, 0, 287,
1542 288, 282, 0, 307, 0, 198, 0, 0, 182, 0,
1543 0, 0, 0, 167, 0, 0, 0, 63, 227, 229,
1544 111, 124, 0, 0, 0, 0, 0, 289, 290, 303,
1545 305, 284, 0, 0, 292, 295, 296, 0, 121, 0,
1546 0, 0, 188, 0, 0, 184, 185, 181, 64, 125,
1547 119, 252, 0, 0, 111, 0, 117, 278, 0, 117,
1548 308, 186, 187, 0, 0, 0, 226, 0, 232, 0,
1549 271, 0, 0, 280, 0, 0, 279, 298, 183, 189,
1550 190, 120, 269, 0, 270, 0, 111, 0, 0, 0,
1551 281, 0, 0, 0, 0, 276, 0, 0, 275, 0,
1552 272, 0, 0, 0
1553};
1554
1555static const short yydefgoto[] = { 256,
1556 257, 258, 282, 299, 156, 157, 76, 509, 12, 77,
1557 14, 15, 39, 40, 41, 45, 51, 114, 124, 326,
1558 222, 400, 329, 559, 379, 423, 541, 356, 424, 78,
1559 158, 133, 148, 134, 135, 107, 345, 368, 346, 117,
1560 85, 149, 592, 16, 17, 19, 18, 261, 334, 335,
1561 60, 22, 58, 98, 427, 428, 125, 164, 52, 93,
1562 53, 46, 430, 369, 80, 371, 266, 54, 89, 90,
1563 216, 563, 128, 305, 517, 440, 217, 218, 219, 220
1564};
1565
1566static const short yypact[] = { 42,
1567-32768,-32768,-32768,-32768,-32768,-32768,-32768, -21, -131, 60,
1568 -93, 105, -22, 182,-32768, 525,-32768, 46, 168, -12,
1569 19,-32768, 1, 152,-32768, 1277,-32768,-32768,-32768,-32768,
1570-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 90, 90,
1571 100,-32768,-32768,-32768, 90,-32768,-32768,-32768,-32768,-32768,
1572 90, 186,-32768, 12, 187, 201, 209,-32768,-32768,-32768,
1573-32768,-32768, 93,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1574-32768, 252, 254, 2, 907,-32768,-32768,-32768, 13,-32768,
1575 225, 225, 150,-32768, 76, 116, 116,-32768,-32768, 108,
1576-32768,-32768,-32768,-32768,-32768,-32768,-32768, -79, 1027,-32768,
1577 111, 114, 947, 93,-32768, 13, -104,-32768, 1027, 76,
1578 76,-32768,-32768, 1067,-32768,-32768, 1299, 266,-32768,-32768,
1579-32768,-32768,-32768, 1330,-32768, -16, 1572,-32768, 256,-32768,
1580-32768, 13,-32768, 139, 144, 1370, 1370, 132, -95, 1370,
1581-32768, 145, 1299, 1370, 93, 147, 13, 311,-32768, 43,
1582 290, 293, 298, 299, 302, 247, 303, 724,-32768,-32768,
1583 35,-32768,-32768,-32768,-32768,-32768, 258, 1450, 70, 305,
1584 116,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1585-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 317, 405,
1586 1370, 1370, 1370, 1370,-32768,-32768,-32768,-32768,-32768,-32768,
1587-32768,-32768,-32768,-32768,-32768,-32768, 1370, 1370, 1370, 1370,
1588 1370, 1370, 1370, 1370, 1370,-32768, 116,-32768, 34,-32768,
1589-32768, 131, 1107,-32768, 6, -46,-32768, 164, 13,-32768,
1590-32768, 13, 1067,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1591-32768,-32768,-32768,-32768, 317, 405, 173, 178, 179, 189,
1592 192, 1179, 1481, 987, 314, 193, 197, 198,-32768,-32768,
1593 202, 203,-32768, 93, 565,-32768, 699, 699,-32768, 699,
1594 1330,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1595-32768, 1370,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1596-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1370, 113,
1597 137,-32768, 565, -10, 205, 207, 208, 210, 218, 219,
1598 565, 565, 330, 1330, 1370, 1370,-32768,-32768,-32768,-32768,
1599-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 106,-32768,
1600-32768,-32768, 106, 202, 202, 331, 220, 221, 1299, 1299,
1601 1299, 1299, 1299,-32768,-32768, -41, 1005, -61,-32768, -91,
1602-32768, 1299, 1299, 1299, -13,-32768, 1219,-32768,-32768,-32768,
1603-32768,-32768,-32768,-32768,-32768, 313, 1299,-32768,-32768,-32768,
1604-32768, 226,-32768, 227, 699, 565, 565, 23,-32768, 24,
1605-32768,-32768, 699, 223, 1370, 1370, 1370, 1370, 1370, 232,
1606 233, 1370, 699, 565, 234,-32768,-32768,-32768,-32768,-32768,
1607-32768,-32768, 1370, 1299, 1299,-32768, 235, 236, 237, 239,
1608 1299,-32768, 231, 724, -76,-32768,-32768, 241, 242, 352,
1609 369, 388,-32768, 202,-32768, 13, 246, 243,-32768, 374,
1610 -59, 380, 385, 253, 257, 270, 699, 414, 699, 272,
1611 273, 699, 278, 13,-32768, 280, 282, 699, 699, 13,
1612 283, 287, 1370, -112, 288, 289, -33, 1299, 1299, 1299,
1613 1299,-32768,-32768, 294, 1299, 1299, 1370,-32768,-32768,-32768,
1614 79, 1259,-32768, 292,-32768, 699, 699, 1370, 699, 699,
1615 287,-32768, 287, 1370, 699, 307, 1370, 1370, 1370,-32768,
1616-32768, 1370, 392,-32768, 565,-32768, 1299, 1299,-32768, 308,
1617 295, 309, 310,-32768, 301, 315, 7,-32768,-32768,-32768,
1618 13, 10, 427, 318, 306, 565, 52,-32768,-32768,-32768,
1619-32768,-32768, 316, 699,-32768,-32768,-32768, 71, 287, 322,
1620 325, 1299,-32768, 1299, 1299,-32768,-32768,-32768, 79,-32768,
1621 407,-32768, 444, -4,-32768, 1370,-32768,-32768, 323,-32768,
1622-32768,-32768,-32768, 327, 328, 329,-32768, 464,-32768, 699,
1623-32768, 859, -3, 131, 565, -14,-32768, 106,-32768,-32768,
1624-32768,-32768,-32768, 334,-32768, 859,-32768, 452, 465, 336,
1625 131, 699, 699, 468, 416,-32768, 699, 471,-32768, 699,
1626-32768, 490, 491,-32768
1627};
1628
1629static const short yypgoto[] = { 365,
1630 366, 367, 255, 251, -168,-32768, 0, -40, 408, 14,
1631-32768,-32768,-32768,-32768, 40,-32768,-32768,-32768, -158,-32768,
1632 -406,-32768, -226,-32768, -290, 3,-32768, -317,-32768,-32768,
1633 -25, 296, -119,-32768, 409, 413, -60, -155, -231, 166,
1634 119, 284,-32768,-32768, 504,-32768,-32768,-32768,-32768,-32768,
1635-32768,-32768,-32768,-32768,-32768,-32768, 435,-32768,-32768,-32768,
1636-32768,-32768,-32768, -525, -139, 47, -183,-32768, 474,-32768,
1637-32768,-32768,-32768,-32768, 37, 124,-32768,-32768,-32768,-32768
1638};
1639
1640
1641#define YYLAST 1705
1642
1643
1644static const short yytable[] = { 11,
1645 79, 270, 259, 333, 161, 102, 269, 269, 234, 302,
1646 381, 162, 271, 13, 23, 11, 401, 402, 260, 471,
1647 421, 348, 350, 578, 306, 307, 308, 309, 310, 13,
1648 20, 313, 88, 437, 439, 108, 574, 109, 496, 422,
1649 91, -200, 140, 421, 21, -54, -54, -54, -54, 106,
1650 580, 140, 25, 141, 2, 411, 159, 4, 314, -66,
1651 1, 2, 228, 3, 4, 5, 417, 129, 235, 236,
1652 411, 6, 7, 132, 130, 438, 438, 106, 81, 82,
1653 267, 464, 231, 132, 86, 411, 268, 411, 147, 11,
1654 87, 43, 8, 44, 416, 9, 475, 1, 147, 10,
1655 3, 108, 5, 109, 539, 411, 470, 115, 116, 331,
1656 225, 226, 412, 484, 229, 415, 24, 499, 232, 396,
1657 397, 398, 26, 27, 399, 370, 1, 370, 370, 3,
1658 370, 5, 395, 55, 83, 431, 84, 108, 564, 109,
1659 163, 383, 265, 396, 397, 398, 315, 316, 399, 561,
1660 575, 375, 57, 108, 108, 109, 109, 538, 103, 330,
1661 108, 494, 109, 370, 56, 300, 301, 265, 303, 92,
1662 581, 370, 370, 59, 262, 118, 119, 120, 121, 122,
1663 123, 304, 265, 265, 265, 265, 265, 311, 312, 265,
1664 520, 112, 521, 113, 393, 317, 318, 132, 546, 110,
1665 111, 443, 547, 445, 446, 447, 88, 147, 95, 47,
1666 48, 49, 319, 320, 50, 321, 322, 546, 323, 324,
1667 325, 550, 96, 28, 29, 30, 31, 32, 33, 34,
1668 97, 35, 36, 37, 38, 370, 370, 370, 551, 396,
1669 397, 398, 99, 370, 399, 147, 512, 317, 318, 237,
1670 238, 239, 240, 370, 370, 100, 376, 101, 259, 378,
1671 108, 84, 109, 136, 319, 320, 137, 321, 322, 160,
1672 323, 324, 325, 377, 260, 143, 144, 221, 406, 407,
1673 408, 409, 410, 380, 108, 223, 109, 227, 147, 394,
1674 265, 418, 419, 420, 224, 230, 233, 370, -55, 370,
1675 522, -56, 370, 525, 526, 527, -59, -58, 370, 370,
1676 -57, 241, 263, 372, 373, 269, 374, 61, 62, 332,
1677 566, 414, 339, 568, 36, 37, 38, 340, 341, 1,
1678 2, 426, 3, 4, 5, 351, 370, 370, 342, 370,
1679 370, 343, 352, 455, 456, 370, 353, 354, 355, 382,
1680 462, 384, 357, 385, 386, 370, 387, 390, 391, 265,
1681 444, 265, 265, 265, 388, 389, 450, 392, 403, 404,
1682 405, 429, 432, 433, 442, 562, 370, 454, 448, 449,
1683 453, 458, 459, 460, 370, 461, 463, 465, 466, 467,
1684 468, 469, 472, 473, 576, 474, 476, 500, 501, 502,
1685 503, 477, 478, 479, 505, 506, 272, 273, 274, 275,
1686 276, 277, 278, 279, 280, 281, 480, 482, 484, 485,
1687 370, 434, 435, 436, 487, 370, 488, 495, 489, 441,
1688 283, 284, 492, 493, 497, 498, 530, 531, 513, 451,
1689 452, 507, 370, 370, 438, 533, 511, 370, 542, 504,
1690 370, 536, 516, 524, 532, 534, 535, 544, 265, 558,
1691 560, 265, 265, 265, 543, 537, 516, 572, 582, 548,
1692 508, 554, 552, 555, 556, 553, 567, 569, 570, 571,
1693 579, 583, 584, 481, 587, 483, 588, 590, 486, 593,
1694 594, 213, 214, 215, 490, 491, 338, 127, 557, 337,
1695 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1696 295, 296, 297, 298, 540, 139, 336, 142, 328, 42,
1697 565, 126, 514, 515, -199, 518, 519, 94, 528, 457,
1698 0, 523, 0, 0, 0, 0, 0, 0, 508, 0,
1699 0, 529, -66, 1, 2, 0, 3, 4, 5, 0,
1700 0, 0, 0, 0, 6, 7, 0, 0, 0, 0,
1701 0, 0, 545, 0, 0, 0, 0, 358, 359, 0,
1702 549, 61, 62, 360, 0, 8, 0, 0, 9, 0,
1703 0, 0, 10, 1, 2, 0, 3, 4, 5, 361,
1704 362, 363, 0, 0, 0, 0, 0, 0, 0, 0,
1705 0, 0, 0, 0, 364, 365, 573, 0, 0, 0,
1706 0, 577, 0, 0, 0, 0, 0, 0, 0, 0,
1707 0, 366, 0, 0, 0, 0, 0, 0, 585, 586,
1708 0, 0, 0, 589, 0, 0, 591, 174, 175, 176,
1709 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
1710 187, 188, 245, 246, 0, 0, 0, 0, 0, 0,
1711 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1712 0, 0, 0, 0, 0, 0, 0, 0, 0, 247,
1713 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
1714 205, 206, 0, 248, 0, 249, 250, 251, 0, 0,
1715 0, 358, 359, 0, 0, 61, 62, 360, 0, 0,
1716 0, 0, 108, 0, 109, 0, 0, 1, 2, 367,
1717 3, 4, 5, 361, 362, 363, 0, 0, 0, 0,
1718 61, 62, 0, 0, 0, 0, 0, 0, 364, 365,
1719 0, 0, 1, 2, 0, 3, 4, 5, 242, 0,
1720 0, 0, 0, 0, 0, 366, 0, 0, 0, 0,
1721 0, 0, 0, 243, 244, 0, 0, 0, 0, 0,
1722 0, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1723 183, 184, 185, 186, 187, 188, 245, 246, 0, 0,
1724 0, 0, 0, 0, 0, 0, 174, 175, 176, 177,
1725 178, 179, 180, 181, 182, 183, 184, 185, 186, 187,
1726 188, 245, 246, 247, 195, 196, 197, 198, 199, 200,
1727 201, 202, 203, 204, 205, 206, 0, 248, 0, 249,
1728 250, 251, 0, 0, 0, 0, 0, 0, 247, 195,
1729 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
1730 206, 0, 248, 367, 249, 250, 251, 0, 0, 0,
1731 0, 358, 359, 0, 0, 0, 0, 360, 0, 0,
1732 0, 108, 0, 109, 0, 252, 0, 0, 253, 0,
1733 254, 0, 255, 361, 362, 363, 0, 0, 0, 0,
1734 0, 0, 0, 0, 0, 0, 0, 0, 364, 365,
1735 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1736 0, 0, 0, 61, 62, 366, 104, 64, 65, 66,
1737 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1738 5, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1739 183, 184, 185, 186, 187, 188, 245, 246, 0, 0,
1740 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1741 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1742 5, 0, 0, 247, 195, 196, 197, 198, 199, 200,
1743 201, 202, 203, 204, 205, 206, 0, 248, 0, 249,
1744 250, 251, 0, 61, 62, 71, 104, 150, 151, 152,
1745 153, 154, 155, 70, 0, 1, 2, 0, 3, 4,
1746 5, 61, 62, 367, 104, 150, 151, 152, 153, 154,
1747 155, 70, 0, 1, 2, 0, 3, 4, 5, 0,
1748 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1749 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1750 5, 0, 0, 71, 0, 72, 0, 0, 73, 0,
1751 0, 74, 0, 75, 105, 131, 0, 0, 0, 0,
1752 0, 0, 0, 61, 62, 71, 145, 64, 65, 66,
1753 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1754 5, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1755 0, 74, 0, 75, 138, 0, 0, 0, 0, 0,
1756 0, 0, 0, 61, 62, 71, 104, 64, 65, 66,
1757 67, 68, 69, 70, 0, 1, 2, 0, 3, 4,
1758 5, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1759 0, 74, 0, 75, 349, 327, 0, 0, 0, 0,
1760 0, 0, 0, 72, 0, 71, 73, 0, 0, 74,
1761 0, 75, 413, 0, 0, 0, 0, 0, 0, 0,
1762 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1763 0, 74, 0, 75, 0, 61, 62, 146, 104, 150,
1764 151, 152, 153, 154, 155, 70, 0, 1, 2, 0,
1765 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1766 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1767 0, 74, 0, 75, 0, 61, 62, 71, 104, 64,
1768 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1769 3, 4, 5, 0, 0, 0, 0, 0, 0, 0,
1770 0, 0, 0, 0, 0, 72, 0, 425, 73, 0,
1771 0, 74, 0, 75, 0, 61, 62, 71, 104, 64,
1772 65, 66, 67, 68, 69, 70, 0, 1, 2, 0,
1773 3, 4, 5, 61, 62, 0, 63, 64, 65, 66,
1774 67, 68, 69, 70, 0, 1, 2, 510, 3, 4,
1775 5, 0, 0, 0, 0, 61, 62, 71, 104, 150,
1776 151, 152, 153, 154, 155, 70, 0, 1, 2, 0,
1777 3, 4, 5, 0, 0, 71, 0, 72, 0, 0,
1778 73, 0, 344, 74, 0, 75, 61, 62, 0, 145,
1779 64, 65, 66, 67, 68, 69, 70, 71, 1, 2,
1780 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1781 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1782 73, 0, 0, 74, 0, 75, 61, 62, 71, 104,
1783 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1784 0, 3, 4, 5, 0, 0, 0, 0, 0, 0,
1785 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1786 73, 0, 0, 74, 0, 75, 0, 0, 71, 0,
1787 0, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1788 0, 74, 0, 75, 0, 0, 0, 0, 0, 0,
1789 0, 0, 0, 0, 0, 0, 0, 72, 0, 0,
1790 73, 0, 0, 74, 0, 75, 61, 62, 0, 264,
1791 64, 65, 66, 67, 68, 69, 70, 0, 1, 2,
1792 0, 3, 4, 5, 0, 0, 0, 0, 72, 0,
1793 0, 73, 0, 0, 74, 0, 75, 61, 62, 0,
1794 104, 150, 151, 152, 153, 154, 155, 70, 71, 1,
1795 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
1796 0, 0, 0, 0, 0, 0, 0, 0, 72, 0,
1797 0, 73, 0, 0, 74, 0, 75, 0, 0, 71,
1798 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1799 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1800 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1801 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1802 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1803 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1804 0, 0, 0, 0, 0, 0, 0, 0, 72, 0,
1805 0, 73, 0, 0, 74, 0, 75, 165, 0, 0,
1806 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1807 0, 0, 0, 0, 0, 0, 166, 167, 0, 72,
1808 0, 0, 73, 0, 0, 74, 0, 347, 168, 169,
1809 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
1810 180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
1811 190, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1812 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1813 0, 191, 192, 193, 0, 0, 194, 195, 196, 197,
1814 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
1815 208, 209, 210, 211, 212
1816};
1817
1818static const short yycheck[] = { 0,
1819 26, 170, 158, 230, 124, 4, 11, 11, 148, 193,
1820 301, 28, 171, 0, 146, 16, 334, 335, 158, 426,
1821 34, 253, 254, 38, 208, 209, 210, 211, 212, 16,
1822 52, 215, 21, 11, 11, 148, 562, 150, 151, 53,
1823 29, 0, 147, 34, 66, 3, 4, 5, 6, 75,
1824 576, 147, 146, 158, 20, 147, 117, 23, 217, 18,
1825 19, 20, 158, 22, 23, 24, 158, 147, 26, 27,
1826 147, 30, 31, 99, 154, 53, 53, 103, 39, 40,
1827 11, 158, 143, 109, 45, 147, 17, 147, 114, 90,
1828 51, 46, 51, 48, 156, 54, 156, 19, 124, 58,
1829 22, 148, 24, 150, 511, 147, 424, 32, 33, 156,
1830 136, 137, 154, 147, 140, 347, 57, 151, 144, 134,
1831 135, 136, 18, 146, 139, 265, 19, 267, 268, 22,
1832 270, 24, 316, 146, 35, 367, 37, 148, 545, 150,
1833 157, 152, 168, 134, 135, 136, 113, 114, 139, 154,
1834 154, 271, 152, 148, 148, 150, 150, 151, 157, 154,
1835 148, 452, 150, 303, 146, 191, 192, 193, 194, 158,
1836 577, 311, 312, 22, 161, 60, 61, 62, 63, 64,
1837 65, 207, 208, 209, 210, 211, 212, 213, 214, 215,
1838 481, 42, 483, 44, 314, 117, 118, 223, 147, 81,
1839 82, 385, 151, 387, 388, 389, 21, 233, 22, 42,
1840 43, 44, 134, 135, 47, 137, 138, 147, 140, 141,
1841 142, 151, 22, 42, 43, 44, 45, 46, 47, 48,
1842 22, 50, 143, 144, 145, 375, 376, 377, 529, 134,
1843 135, 136, 150, 383, 139, 271, 473, 117, 118, 3,
1844 4, 5, 6, 393, 394, 4, 282, 4, 414, 147,
1845 148, 37, 150, 153, 134, 135, 153, 137, 138, 4,
1846 140, 141, 142, 299, 414, 110, 111, 22, 339, 340,
1847 341, 342, 343, 147, 148, 147, 150, 156, 314, 315,
1848 316, 352, 353, 354, 151, 151, 150, 437, 9, 439,
1849 484, 9, 442, 487, 488, 489, 9, 9, 448, 449,
1850 9, 9, 55, 267, 268, 11, 270, 7, 8, 156,
1851 547, 347, 150, 550, 143, 144, 145, 150, 150, 19,
1852 20, 357, 22, 23, 24, 22, 476, 477, 150, 479,
1853 480, 150, 150, 404, 405, 485, 150, 150, 147, 303,
1854 411, 147, 150, 147, 147, 495, 147, 311, 312, 385,
1855 386, 387, 388, 389, 147, 147, 392, 38, 38, 150,
1856 150, 59, 147, 147, 152, 544, 516, 403, 147, 147,
1857 147, 147, 147, 147, 524, 147, 156, 147, 147, 38,
1858 22, 4, 147, 151, 563, 22, 17, 458, 459, 460,
1859 461, 17, 150, 147, 465, 466, 90, 91, 92, 93,
1860 94, 95, 96, 97, 98, 99, 147, 4, 147, 147,
1861 560, 375, 376, 377, 147, 565, 147, 453, 147, 383,
1862 26, 27, 150, 147, 147, 147, 497, 498, 147, 393,
1863 394, 467, 582, 583, 53, 151, 472, 587, 22, 156,
1864 590, 151, 478, 147, 147, 147, 147, 152, 484, 53,
1865 17, 487, 488, 489, 147, 151, 492, 4, 17, 154,
1866 471, 532, 151, 534, 535, 151, 154, 151, 151, 151,
1867 147, 17, 147, 437, 17, 439, 71, 17, 442, 0,
1868 0, 127, 127, 127, 448, 449, 246, 90, 539, 245,
1869 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
1870 106, 107, 108, 109, 512, 103, 233, 109, 223, 16,
1871 546, 87, 476, 477, 0, 479, 480, 54, 492, 406,
1872 -1, 485, -1, -1, -1, -1, -1, -1, 539, -1,
1873 -1, 495, 18, 19, 20, -1, 22, 23, 24, -1,
1874 -1, -1, -1, -1, 30, 31, -1, -1, -1, -1,
1875 -1, -1, 516, -1, -1, -1, -1, 3, 4, -1,
1876 524, 7, 8, 9, -1, 51, -1, -1, 54, -1,
1877 -1, -1, 58, 19, 20, -1, 22, 23, 24, 25,
1878 26, 27, -1, -1, -1, -1, -1, -1, -1, -1,
1879 -1, -1, -1, -1, 40, 41, 560, -1, -1, -1,
1880 -1, 565, -1, -1, -1, -1, -1, -1, -1, -1,
1881 -1, 57, -1, -1, -1, -1, -1, -1, 582, 583,
1882 -1, -1, -1, 587, -1, -1, 590, 73, 74, 75,
1883 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1884 86, 87, 88, 89, -1, -1, -1, -1, -1, -1,
1885 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1886 -1, -1, -1, -1, -1, -1, -1, -1, -1, 115,
1887 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
1888 126, 127, -1, 129, -1, 131, 132, 133, -1, -1,
1889 -1, 3, 4, -1, -1, 7, 8, 9, -1, -1,
1890 -1, -1, 148, -1, 150, -1, -1, 19, 20, 155,
1891 22, 23, 24, 25, 26, 27, -1, -1, -1, -1,
1892 7, 8, -1, -1, -1, -1, -1, -1, 40, 41,
1893 -1, -1, 19, 20, -1, 22, 23, 24, 25, -1,
1894 -1, -1, -1, -1, -1, 57, -1, -1, -1, -1,
1895 -1, -1, -1, 40, 41, -1, -1, -1, -1, -1,
1896 -1, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1897 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1898 -1, -1, -1, -1, -1, -1, 73, 74, 75, 76,
1899 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1900 87, 88, 89, 115, 116, 117, 118, 119, 120, 121,
1901 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
1902 132, 133, -1, -1, -1, -1, -1, -1, 115, 116,
1903 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1904 127, -1, 129, 155, 131, 132, 133, -1, -1, -1,
1905 -1, 3, 4, -1, -1, -1, -1, 9, -1, -1,
1906 -1, 148, -1, 150, -1, 152, -1, -1, 155, -1,
1907 157, -1, 159, 25, 26, 27, -1, -1, -1, -1,
1908 -1, -1, -1, -1, -1, -1, -1, -1, 40, 41,
1909 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1910 -1, -1, -1, 7, 8, 57, 10, 11, 12, 13,
1911 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1912 24, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1913 82, 83, 84, 85, 86, 87, 88, 89, -1, -1,
1914 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1915 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1916 24, -1, -1, 115, 116, 117, 118, 119, 120, 121,
1917 122, 123, 124, 125, 126, 127, -1, 129, -1, 131,
1918 132, 133, -1, 7, 8, 49, 10, 11, 12, 13,
1919 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1920 24, 7, 8, 155, 10, 11, 12, 13, 14, 15,
1921 16, 17, -1, 19, 20, -1, 22, 23, 24, -1,
1922 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1923 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1924 24, -1, -1, 49, -1, 149, -1, -1, 152, -1,
1925 -1, 155, -1, 157, 158, 39, -1, -1, -1, -1,
1926 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1927 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1928 24, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1929 -1, 155, -1, 157, 158, -1, -1, -1, -1, -1,
1930 -1, -1, -1, 7, 8, 49, 10, 11, 12, 13,
1931 14, 15, 16, 17, -1, 19, 20, -1, 22, 23,
1932 24, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1933 -1, 155, -1, 157, 158, 39, -1, -1, -1, -1,
1934 -1, -1, -1, 149, -1, 49, 152, -1, -1, 155,
1935 -1, 157, 158, -1, -1, -1, -1, -1, -1, -1,
1936 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1937 -1, 155, -1, 157, -1, 7, 8, 121, 10, 11,
1938 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1939 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
1940 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1941 -1, 155, -1, 157, -1, 7, 8, 49, 10, 11,
1942 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1943 22, 23, 24, -1, -1, -1, -1, -1, -1, -1,
1944 -1, -1, -1, -1, -1, 149, -1, 39, 152, -1,
1945 -1, 155, -1, 157, -1, 7, 8, 49, 10, 11,
1946 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1947 22, 23, 24, 7, 8, -1, 10, 11, 12, 13,
1948 14, 15, 16, 17, -1, 19, 20, 39, 22, 23,
1949 24, -1, -1, -1, -1, 7, 8, 49, 10, 11,
1950 12, 13, 14, 15, 16, 17, -1, 19, 20, -1,
1951 22, 23, 24, -1, -1, 49, -1, 149, -1, -1,
1952 152, -1, 154, 155, -1, 157, 7, 8, -1, 10,
1953 11, 12, 13, 14, 15, 16, 17, 49, 19, 20,
1954 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
1955 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1956 152, -1, -1, 155, -1, 157, 7, 8, 49, 10,
1957 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
1958 -1, 22, 23, 24, -1, -1, -1, -1, -1, -1,
1959 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1960 152, -1, -1, 155, -1, 157, -1, -1, 49, -1,
1961 -1, -1, -1, -1, -1, 149, -1, -1, 152, -1,
1962 -1, 155, -1, 157, -1, -1, -1, -1, -1, -1,
1963 -1, -1, -1, -1, -1, -1, -1, 149, -1, -1,
1964 152, -1, -1, 155, -1, 157, 7, 8, -1, 10,
1965 11, 12, 13, 14, 15, 16, 17, -1, 19, 20,
1966 -1, 22, 23, 24, -1, -1, -1, -1, 149, -1,
1967 -1, 152, -1, -1, 155, -1, 157, 7, 8, -1,
1968 10, 11, 12, 13, 14, 15, 16, 17, 49, 19,
1969 20, -1, 22, 23, 24, -1, -1, -1, -1, -1,
1970 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
1971 -1, 152, -1, -1, 155, -1, 157, -1, -1, 49,
1972 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1973 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1974 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1975 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1976 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1977 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1978 -1, -1, -1, -1, -1, -1, -1, -1, 149, -1,
1979 -1, 152, -1, -1, 155, -1, 157, 36, -1, -1,
1980 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1981 -1, -1, -1, -1, -1, -1, 55, 56, -1, 149,
1982 -1, -1, 152, -1, -1, 155, -1, 157, 67, 68,
1983 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1984 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1985 89, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1986 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1987 -1, 110, 111, 112, -1, -1, 115, 116, 117, 118,
1988 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
1989 129, 130, 131, 132, 133
1990};
1991/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1992#line 3 "/usr/share/bison.simple"
1993/* This file comes from bison-1.28. */
1994
1995/* Skeleton output parser for bison,
1996 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1997
1998 This program is free software; you can redistribute it and/or modify
1999 it under the terms of the GNU General Public License as published by
2000 the Free Software Foundation; either version 2, or (at your option)
2001 any later version.
2002
2003 This program is distributed in the hope that it will be useful,
2004 but WITHOUT ANY WARRANTY; without even the implied warranty of
2005 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2006 GNU General Public License for more details.
2007
2008 You should have received a copy of the GNU General Public License
2009 along with this program; if not, write to the Free Software
2010 Foundation, Inc., 59 Temple Place - Suite 330,
2011 Boston, MA 02111-1307, USA. */
2012
2013/* As a special exception, when this file is copied by Bison into a
2014 Bison output file, you may use that output file without restriction.
2015 This special exception was added by the Free Software Foundation
2016 in version 1.24 of Bison. */
2017
2018/* This is the parser code that is written into each bison parser
2019 when the %semantic_parser declaration is not specified in the grammar.
2020 It was written by Richard Stallman by simplifying the hairy parser
2021 used when %semantic_parser is specified. */
2022
2023#ifndef YYSTACK_USE_ALLOCA
2024#ifdef alloca
2025#define YYSTACK_USE_ALLOCA
2026#else /* alloca not defined */
2027#ifdef __GNUC__
2028#define YYSTACK_USE_ALLOCA
2029#define alloca __builtin_alloca
2030#else /* not GNU C. */
2031#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2032#define YYSTACK_USE_ALLOCA
2033#include <alloca.h>
2034#else /* not sparc */
2035/* We think this test detects Watcom and Microsoft C. */
2036/* This used to test MSDOS, but that is a bad idea
2037 since that symbol is in the user namespace. */
2038#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2039#if 0 /* No need for malloc.h, which pollutes the namespace;
2040 instead, just don't use alloca. */
2041#include <malloc.h>
2042#endif
2043#else /* not MSDOS, or __TURBOC__ */
2044#if defined(_AIX)
2045/* I don't know what this was needed for, but it pollutes the namespace.
2046 So I turned it off. rms, 2 May 1997. */
2047/* #include <malloc.h> */
2048 #pragma alloca
2049#define YYSTACK_USE_ALLOCA
2050#else /* not MSDOS, or __TURBOC__, or _AIX */
2051#if 0
2052#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2053 and on HPUX 10. Eventually we can turn this on. */
2054#define YYSTACK_USE_ALLOCA
2055#define alloca __builtin_alloca
2056#endif /* __hpux */
2057#endif
2058#endif /* not _AIX */
2059#endif /* not MSDOS, or __TURBOC__ */
2060#endif /* not sparc */
2061#endif /* not GNU C */
2062#endif /* alloca not defined */
2063#endif /* YYSTACK_USE_ALLOCA not defined */
2064
2065#ifdef YYSTACK_USE_ALLOCA
2066#define YYSTACK_ALLOC alloca
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002067#else
Chris Lattner0275cff2007-08-06 21:00:46 +00002068#define YYSTACK_ALLOC malloc
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002069#endif
2070
Chris Lattner0275cff2007-08-06 21:00:46 +00002071/* Note: there must be only one dollar sign in this file.
2072 It is replaced by the list of actions, each action
2073 as one case of the switch. */
David Greene718fda32007-08-01 03:59:32 +00002074
Reid Spencer68a24bd2005-08-27 18:50:39 +00002075#define yyerrok (yyerrstatus = 0)
2076#define yyclearin (yychar = YYEMPTY)
Chris Lattner0275cff2007-08-06 21:00:46 +00002077#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00002078#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00002079#define YYACCEPT goto yyacceptlab
Chris Lattner0275cff2007-08-06 21:00:46 +00002080#define YYABORT goto yyabortlab
2081#define YYERROR goto yyerrlab1
2082/* Like YYERROR except do call yyerror.
2083 This remains here temporarily to ease the
2084 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002085 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002086#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00002087#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner0275cff2007-08-06 21:00:46 +00002088#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002089do \
2090 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner0275cff2007-08-06 21:00:46 +00002091 { yychar = (token), yylval = (value); \
2092 yychar1 = YYTRANSLATE (yychar); \
2093 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002094 goto yybackup; \
2095 } \
2096 else \
Chris Lattner0275cff2007-08-06 21:00:46 +00002097 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2098while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002099
Reid Spencer68a24bd2005-08-27 18:50:39 +00002100#define YYTERROR 1
2101#define YYERRCODE 256
2102
Chris Lattner0275cff2007-08-06 21:00:46 +00002103#ifndef YYPURE
2104#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00002105#endif
2106
Chris Lattner0275cff2007-08-06 21:00:46 +00002107#ifdef YYPURE
2108#ifdef YYLSP_NEEDED
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002109#ifdef YYLEX_PARAM
Chris Lattner0275cff2007-08-06 21:00:46 +00002110#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002111#else
Chris Lattner0275cff2007-08-06 21:00:46 +00002112#define YYLEX yylex(&yylval, &yylloc)
2113#endif
2114#else /* not YYLSP_NEEDED */
2115#ifdef YYLEX_PARAM
2116#define YYLEX yylex(&yylval, YYLEX_PARAM)
2117#else
2118#define YYLEX yylex(&yylval)
2119#endif
2120#endif /* not YYLSP_NEEDED */
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002121#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002122
Chris Lattner0275cff2007-08-06 21:00:46 +00002123/* If nonreentrant, generate the variables here */
Chandler Carruth02202192007-08-04 01:56:21 +00002124
Chris Lattner0275cff2007-08-06 21:00:46 +00002125#ifndef YYPURE
Chandler Carruth02202192007-08-04 01:56:21 +00002126
Chris Lattner0275cff2007-08-06 21:00:46 +00002127int yychar; /* the lookahead symbol */
2128YYSTYPE yylval; /* the semantic value of the */
2129 /* lookahead symbol */
Chandler Carruth02202192007-08-04 01:56:21 +00002130
Chris Lattner0275cff2007-08-06 21:00:46 +00002131#ifdef YYLSP_NEEDED
2132YYLTYPE yylloc; /* location data for the lookahead */
2133 /* symbol */
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002134#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002135
Chris Lattner0275cff2007-08-06 21:00:46 +00002136int yynerrs; /* number of parse errors so far */
2137#endif /* not YYPURE */
Chandler Carruth02202192007-08-04 01:56:21 +00002138
Chris Lattner0275cff2007-08-06 21:00:46 +00002139#if YYDEBUG != 0
2140int yydebug; /* nonzero means print parse trace */
2141/* Since this is uninitialized, it does not stop multiple parsers
2142 from coexisting. */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002143#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00002144
Chris Lattner0275cff2007-08-06 21:00:46 +00002145/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencerb8f85052007-07-31 03:50:36 +00002146
Reid Spencer68a24bd2005-08-27 18:50:39 +00002147#ifndef YYINITDEPTH
Chris Lattner0275cff2007-08-06 21:00:46 +00002148#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002149#endif
2150
Chris Lattner0275cff2007-08-06 21:00:46 +00002151/* YYMAXDEPTH is the maximum size the stacks can grow to
2152 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002153
Chris Lattner0275cff2007-08-06 21:00:46 +00002154#if YYMAXDEPTH == 0
2155#undef YYMAXDEPTH
2156#endif
David Greene718fda32007-08-01 03:59:32 +00002157
Reid Spencer68a24bd2005-08-27 18:50:39 +00002158#ifndef YYMAXDEPTH
Chris Lattner0275cff2007-08-06 21:00:46 +00002159#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002160#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002161
Chris Lattner0275cff2007-08-06 21:00:46 +00002162/* Define __yy_memcpy. Note that the size argument
2163 should be passed with type unsigned int, because that is what the non-GCC
2164 definitions require. With GCC, __builtin_memcpy takes an arg
2165 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002166
Chris Lattner0275cff2007-08-06 21:00:46 +00002167#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2168#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2169#else /* not GNU C or C++ */
2170#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00002171
Chris Lattner0275cff2007-08-06 21:00:46 +00002172/* This is the most reliable way to avoid incompatibilities
2173 in available built-in functions on various systems. */
Chandler Carruth02202192007-08-04 01:56:21 +00002174static void
Chris Lattner0275cff2007-08-06 21:00:46 +00002175__yy_memcpy (to, from, count)
2176 char *to;
2177 char *from;
2178 unsigned int count;
Chandler Carruth02202192007-08-04 01:56:21 +00002179{
Chris Lattner0275cff2007-08-06 21:00:46 +00002180 register char *f = from;
2181 register char *t = to;
2182 register int i = count;
Chandler Carruth02202192007-08-04 01:56:21 +00002183
Chris Lattner0275cff2007-08-06 21:00:46 +00002184 while (i-- > 0)
2185 *t++ = *f++;
Chandler Carruth02202192007-08-04 01:56:21 +00002186}
Chandler Carruth02202192007-08-04 01:56:21 +00002187
Chris Lattner0275cff2007-08-06 21:00:46 +00002188#else /* __cplusplus */
2189
2190/* This is the most reliable way to avoid incompatibilities
2191 in available built-in functions on various systems. */
2192static void
2193__yy_memcpy (char *to, char *from, unsigned int count)
2194{
2195 register char *t = to;
2196 register char *f = from;
2197 register int i = count;
2198
2199 while (i-- > 0)
2200 *t++ = *f++;
2201}
2202
2203#endif
2204#endif
2205
2206#line 217 "/usr/share/bison.simple"
2207
2208/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2209 into yyparse. The argument should have type void *.
2210 It should actually point to an object.
2211 Grammar actions can access the variable by casting it
2212 to the proper pointer type. */
Chandler Carruth02202192007-08-04 01:56:21 +00002213
2214#ifdef YYPARSE_PARAM
Chris Lattner0275cff2007-08-06 21:00:46 +00002215#ifdef __cplusplus
2216#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2217#define YYPARSE_PARAM_DECL
2218#else /* not __cplusplus */
2219#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2220#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2221#endif /* not __cplusplus */
2222#else /* not YYPARSE_PARAM */
2223#define YYPARSE_PARAM_ARG
2224#define YYPARSE_PARAM_DECL
2225#endif /* not YYPARSE_PARAM */
2226
2227/* Prevent warning if -Wstrict-prototypes. */
2228#ifdef __GNUC__
2229#ifdef YYPARSE_PARAM
2230int yyparse (void *);
Chandler Carruth02202192007-08-04 01:56:21 +00002231#else
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002232int yyparse (void);
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002233#endif
2234#endif
Chris Lattner0275cff2007-08-06 21:00:46 +00002235
2236int
2237yyparse(YYPARSE_PARAM_ARG)
2238 YYPARSE_PARAM_DECL
Chandler Carruth02202192007-08-04 01:56:21 +00002239{
Chris Lattner0275cff2007-08-06 21:00:46 +00002240 register int yystate;
2241 register int yyn;
2242 register short *yyssp;
2243 register YYSTYPE *yyvsp;
2244 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2245 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2246
2247 short yyssa[YYINITDEPTH]; /* the state stack */
2248 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2249
2250 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2251 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2252
2253#ifdef YYLSP_NEEDED
2254 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2255 YYLTYPE *yyls = yylsa;
2256 YYLTYPE *yylsp;
2257
2258#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2259#else
2260#define YYPOPSTACK (yyvsp--, yyssp--)
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002261#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002262
Chris Lattner0275cff2007-08-06 21:00:46 +00002263 int yystacksize = YYINITDEPTH;
2264 int yyfree_stacks = 0;
Chandler Carruth02202192007-08-04 01:56:21 +00002265
Chris Lattner0275cff2007-08-06 21:00:46 +00002266#ifdef YYPURE
2267 int yychar;
2268 YYSTYPE yylval;
2269 int yynerrs;
2270#ifdef YYLSP_NEEDED
2271 YYLTYPE yylloc;
2272#endif
2273#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002274
Chris Lattner0275cff2007-08-06 21:00:46 +00002275 YYSTYPE yyval; /* the variable used to return */
2276 /* semantic values from the action */
2277 /* routines */
Chandler Carruth02202192007-08-04 01:56:21 +00002278
Chris Lattner0275cff2007-08-06 21:00:46 +00002279 int yylen;
Chandler Carruth02202192007-08-04 01:56:21 +00002280
Chris Lattner0275cff2007-08-06 21:00:46 +00002281#if YYDEBUG != 0
2282 if (yydebug)
2283 fprintf(stderr, "Starting parse\n");
2284#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002285
Reid Spencer68a24bd2005-08-27 18:50:39 +00002286 yystate = 0;
2287 yyerrstatus = 0;
2288 yynerrs = 0;
2289 yychar = YYEMPTY; /* Cause a token to be read. */
2290
2291 /* Initialize stack pointers.
2292 Waste one element of value and location stack
2293 so that they stay on the same level as the state stack.
2294 The wasted elements are never initialized. */
2295
Chris Lattner0275cff2007-08-06 21:00:46 +00002296 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002297 yyvsp = yyvs;
Chris Lattner0275cff2007-08-06 21:00:46 +00002298#ifdef YYLSP_NEEDED
2299 yylsp = yyls;
2300#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002301
Chris Lattner0275cff2007-08-06 21:00:46 +00002302/* Push a new state, which is found in yystate . */
2303/* In all cases, when you get here, the value and location stacks
2304 have just been pushed. so pushing a state here evens the stacks. */
2305yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002306
Chris Lattner0275cff2007-08-06 21:00:46 +00002307 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002308
Chris Lattner0275cff2007-08-06 21:00:46 +00002309 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002310 {
Chris Lattner0275cff2007-08-06 21:00:46 +00002311 /* Give user a chance to reallocate the stack */
2312 /* Use copies of these so that the &'s don't force the real ones into memory. */
2313 YYSTYPE *yyvs1 = yyvs;
2314 short *yyss1 = yyss;
2315#ifdef YYLSP_NEEDED
2316 YYLTYPE *yyls1 = yyls;
2317#endif
2318
Reid Spencer68a24bd2005-08-27 18:50:39 +00002319 /* Get the current used size of the three stacks, in elements. */
Chris Lattner0275cff2007-08-06 21:00:46 +00002320 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002321
2322#ifdef yyoverflow
Chris Lattner0275cff2007-08-06 21:00:46 +00002323 /* Each stack pointer address is followed by the size of
2324 the data in use in that stack, in bytes. */
2325#ifdef YYLSP_NEEDED
2326 /* This used to be a conditional around just the two extra args,
2327 but that might be undefined if yyoverflow is a macro. */
2328 yyoverflow("parser stack overflow",
2329 &yyss1, size * sizeof (*yyssp),
2330 &yyvs1, size * sizeof (*yyvsp),
2331 &yyls1, size * sizeof (*yylsp),
2332 &yystacksize);
2333#else
2334 yyoverflow("parser stack overflow",
2335 &yyss1, size * sizeof (*yyssp),
2336 &yyvs1, size * sizeof (*yyvsp),
2337 &yystacksize);
2338#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002339
Chris Lattner0275cff2007-08-06 21:00:46 +00002340 yyss = yyss1; yyvs = yyvs1;
2341#ifdef YYLSP_NEEDED
2342 yyls = yyls1;
2343#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002344#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002345 /* Extend the stack our own way. */
Chris Lattner0275cff2007-08-06 21:00:46 +00002346 if (yystacksize >= YYMAXDEPTH)
2347 {
2348 yyerror("parser stack overflow");
2349 if (yyfree_stacks)
2350 {
2351 free (yyss);
2352 free (yyvs);
2353#ifdef YYLSP_NEEDED
2354 free (yyls);
2355#endif
2356 }
2357 return 2;
2358 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002359 yystacksize *= 2;
Chris Lattner0275cff2007-08-06 21:00:46 +00002360 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002361 yystacksize = YYMAXDEPTH;
Chris Lattner0275cff2007-08-06 21:00:46 +00002362#ifndef YYSTACK_USE_ALLOCA
2363 yyfree_stacks = 1;
2364#endif
2365 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2366 __yy_memcpy ((char *)yyss, (char *)yyss1,
2367 size * (unsigned int) sizeof (*yyssp));
2368 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2369 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2370 size * (unsigned int) sizeof (*yyvsp));
2371#ifdef YYLSP_NEEDED
2372 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2373 __yy_memcpy ((char *)yyls, (char *)yyls1,
2374 size * (unsigned int) sizeof (*yylsp));
2375#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002376#endif /* no yyoverflow */
2377
Chris Lattner0275cff2007-08-06 21:00:46 +00002378 yyssp = yyss + size - 1;
2379 yyvsp = yyvs + size - 1;
2380#ifdef YYLSP_NEEDED
2381 yylsp = yyls + size - 1;
2382#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002383
Chris Lattner0275cff2007-08-06 21:00:46 +00002384#if YYDEBUG != 0
2385 if (yydebug)
2386 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2387#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002388
Chris Lattner0275cff2007-08-06 21:00:46 +00002389 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002390 YYABORT;
2391 }
2392
Chris Lattner0275cff2007-08-06 21:00:46 +00002393#if YYDEBUG != 0
2394 if (yydebug)
2395 fprintf(stderr, "Entering state %d\n", yystate);
2396#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002397
2398 goto yybackup;
Chris Lattner0275cff2007-08-06 21:00:46 +00002399 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002400
Chris Lattner0275cff2007-08-06 21:00:46 +00002401/* Do appropriate processing given the current state. */
2402/* Read a lookahead token if we need one and don't already have one. */
2403/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002404
Chris Lattner0275cff2007-08-06 21:00:46 +00002405 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002406
Reid Spencer68a24bd2005-08-27 18:50:39 +00002407 yyn = yypact[yystate];
Chris Lattner0275cff2007-08-06 21:00:46 +00002408 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002409 goto yydefault;
2410
Chris Lattner0275cff2007-08-06 21:00:46 +00002411 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002412
Chris Lattner0275cff2007-08-06 21:00:46 +00002413 /* yychar is either YYEMPTY or YYEOF
2414 or a valid token in external form. */
2415
Reid Spencer68a24bd2005-08-27 18:50:39 +00002416 if (yychar == YYEMPTY)
2417 {
Chris Lattner0275cff2007-08-06 21:00:46 +00002418#if YYDEBUG != 0
2419 if (yydebug)
2420 fprintf(stderr, "Reading a token: ");
2421#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002422 yychar = YYLEX;
2423 }
2424
Chris Lattner0275cff2007-08-06 21:00:46 +00002425 /* Convert token to internal form (in yychar1) for indexing tables with */
2426
2427 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002428 {
Chris Lattner0275cff2007-08-06 21:00:46 +00002429 yychar1 = 0;
2430 yychar = YYEOF; /* Don't call YYLEX any more */
2431
2432#if YYDEBUG != 0
2433 if (yydebug)
2434 fprintf(stderr, "Now at end of input.\n");
2435#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002436 }
2437 else
2438 {
Chris Lattner0275cff2007-08-06 21:00:46 +00002439 yychar1 = YYTRANSLATE(yychar);
2440
2441#if YYDEBUG != 0
2442 if (yydebug)
2443 {
2444 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2445 /* Give the individual parser a way to print the precise meaning
2446 of a token, for further debugging info. */
2447#ifdef YYPRINT
2448 YYPRINT (stderr, yychar, yylval);
2449#endif
2450 fprintf (stderr, ")\n");
2451 }
2452#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002453 }
2454
Chris Lattner0275cff2007-08-06 21:00:46 +00002455 yyn += yychar1;
2456 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002457 goto yydefault;
Chris Lattner0275cff2007-08-06 21:00:46 +00002458
Reid Spencer68a24bd2005-08-27 18:50:39 +00002459 yyn = yytable[yyn];
Chris Lattner0275cff2007-08-06 21:00:46 +00002460
2461 /* yyn is what to do for this token type in this state.
2462 Negative => reduce, -yyn is rule number.
2463 Positive => shift, yyn is new state.
2464 New state is final state => don't bother to shift,
2465 just return success.
2466 0, or most negative number => error. */
2467
2468 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002469 {
Chris Lattner0275cff2007-08-06 21:00:46 +00002470 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002471 goto yyerrlab;
2472 yyn = -yyn;
2473 goto yyreduce;
2474 }
Chris Lattner0275cff2007-08-06 21:00:46 +00002475 else if (yyn == 0)
2476 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002477
2478 if (yyn == YYFINAL)
2479 YYACCEPT;
2480
Chris Lattner0275cff2007-08-06 21:00:46 +00002481 /* Shift the lookahead token. */
Dale Johannesen320fc8a2007-08-03 01:03:46 +00002482
Chris Lattner0275cff2007-08-06 21:00:46 +00002483#if YYDEBUG != 0
2484 if (yydebug)
2485 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2486#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002487
Chris Lattner0275cff2007-08-06 21:00:46 +00002488 /* Discard the token being shifted unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002489 if (yychar != YYEOF)
2490 yychar = YYEMPTY;
2491
Chandler Carruth02202192007-08-04 01:56:21 +00002492 *++yyvsp = yylval;
Chris Lattner0275cff2007-08-06 21:00:46 +00002493#ifdef YYLSP_NEEDED
2494 *++yylsp = yylloc;
2495#endif
Chandler Carruth02202192007-08-04 01:56:21 +00002496
Chris Lattner0275cff2007-08-06 21:00:46 +00002497 /* count tokens shifted since error; after three, turn off error status. */
2498 if (yyerrstatus) yyerrstatus--;
2499
2500 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002501 goto yynewstate;
2502
Chris Lattner0275cff2007-08-06 21:00:46 +00002503/* Do the default action for the current state. */
Chandler Carruth02202192007-08-04 01:56:21 +00002504yydefault:
Chris Lattner0275cff2007-08-06 21:00:46 +00002505
Reid Spencer68a24bd2005-08-27 18:50:39 +00002506 yyn = yydefact[yystate];
2507 if (yyn == 0)
2508 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002509
Chris Lattner0275cff2007-08-06 21:00:46 +00002510/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002511yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002512 yylen = yyr2[yyn];
Chris Lattner0275cff2007-08-06 21:00:46 +00002513 if (yylen > 0)
2514 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002515
Chris Lattner0275cff2007-08-06 21:00:46 +00002516#if YYDEBUG != 0
2517 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002518 {
Chris Lattner0275cff2007-08-06 21:00:46 +00002519 int i;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002520
Chris Lattner0275cff2007-08-06 21:00:46 +00002521 fprintf (stderr, "Reducing via rule %d (line %d), ",
2522 yyn, yyrline[yyn]);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002523
Chris Lattner0275cff2007-08-06 21:00:46 +00002524 /* Print the symbols being reduced, and their result. */
2525 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2526 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2527 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2528 }
2529#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002530
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002531
Chris Lattner0275cff2007-08-06 21:00:46 +00002532 switch (yyn) {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002533
Chris Lattner0275cff2007-08-06 21:00:46 +00002534case 28:
2535#line 1128 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2536{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2537 break;}
2538case 29:
2539#line 1128 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2540{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2541 break;}
2542case 30:
2543#line 1129 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2544{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2545 break;}
2546case 31:
2547#line 1129 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2548{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2549 break;}
2550case 32:
2551#line 1130 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2552{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2553 break;}
2554case 33:
2555#line 1130 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2556{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2557 break;}
2558case 34:
2559#line 1131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2560{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2561 break;}
2562case 35:
2563#line 1131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2564{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2565 break;}
2566case 36:
2567#line 1132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2568{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2569 break;}
2570case 37:
2571#line 1132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2572{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2573 break;}
2574case 38:
2575#line 1136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2576{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2577 break;}
2578case 39:
2579#line 1136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2580{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2581 break;}
2582case 40:
2583#line 1137 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2584{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2585 break;}
2586case 41:
2587#line 1137 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2588{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2589 break;}
2590case 42:
2591#line 1138 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2592{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2593 break;}
2594case 43:
2595#line 1138 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2596{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2597 break;}
2598case 44:
2599#line 1139 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2600{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2601 break;}
2602case 45:
2603#line 1139 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2604{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2605 break;}
2606case 46:
2607#line 1140 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2608{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2609 break;}
2610case 47:
2611#line 1140 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2612{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2613 break;}
2614case 48:
2615#line 1141 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2616{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2617 break;}
2618case 49:
2619#line 1141 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2620{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2621 break;}
2622case 50:
2623#line 1142 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2624{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2625 break;}
2626case 51:
2627#line 1142 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2628{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2629 break;}
2630case 52:
2631#line 1143 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2632{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2633 break;}
2634case 53:
2635#line 1144 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2636{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2637 break;}
2638case 64:
2639#line 1153 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2640{ yyval.StrVal = 0; ;
2641 break;}
2642case 65:
2643#line 1157 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2644{
2645 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002646 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002647 ;
2648 break;}
2649case 66:
2650#line 1161 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2651{
2652 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002653 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002654 ;
2655 break;}
2656case 70:
2657#line 1169 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2658{
2659 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002660 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002661 ;
2662 break;}
2663case 71:
2664#line 1174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2665{
2666 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002667 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002668 ;
2669 break;}
2670case 72:
2671#line 1180 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2672{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2673 break;}
2674case 73:
2675#line 1181 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2676{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2677 break;}
2678case 74:
2679#line 1182 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2680{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2681 break;}
2682case 75:
2683#line 1183 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2684{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2685 break;}
2686case 76:
2687#line 1184 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2688{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2689 break;}
2690case 77:
2691#line 1188 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2692{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2693 break;}
2694case 78:
2695#line 1189 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2696{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2697 break;}
2698case 79:
2699#line 1190 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2700{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2701 break;}
2702case 80:
2703#line 1194 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2704{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2705 break;}
2706case 81:
2707#line 1195 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2708{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2709 break;}
2710case 82:
2711#line 1196 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2712{ yyval.Visibility = GlobalValue::HiddenVisibility; ;
2713 break;}
2714case 83:
2715#line 1197 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2716{ yyval.Visibility = GlobalValue::ProtectedVisibility; ;
2717 break;}
2718case 84:
2719#line 1201 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2720{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2721 break;}
2722case 85:
2723#line 1202 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2724{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2725 break;}
2726case 86:
2727#line 1203 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2728{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2729 break;}
2730case 87:
2731#line 1207 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2732{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2733 break;}
2734case 88:
2735#line 1208 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2736{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2737 break;}
2738case 89:
2739#line 1209 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2740{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2741 break;}
2742case 90:
2743#line 1210 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2744{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2745 break;}
2746case 91:
2747#line 1211 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2748{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2749 break;}
2750case 92:
2751#line 1215 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2752{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2753 break;}
2754case 93:
2755#line 1216 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2756{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2757 break;}
2758case 94:
2759#line 1217 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2760{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2761 break;}
2762case 95:
2763#line 1220 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2764{ yyval.UIntVal = CallingConv::C; ;
2765 break;}
2766case 96:
2767#line 1221 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2768{ yyval.UIntVal = CallingConv::C; ;
2769 break;}
2770case 97:
2771#line 1222 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2772{ yyval.UIntVal = CallingConv::Fast; ;
2773 break;}
2774case 98:
2775#line 1223 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2776{ yyval.UIntVal = CallingConv::Cold; ;
2777 break;}
2778case 99:
2779#line 1224 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2780{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2781 break;}
2782case 100:
2783#line 1225 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2784{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2785 break;}
2786case 101:
2787#line 1226 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2788{
2789 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002790 GEN_ERROR("Calling conv too large");
Chris Lattner0275cff2007-08-06 21:00:46 +00002791 yyval.UIntVal = yyvsp[0].UInt64Val;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002792 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002793 ;
2794 break;}
2795case 102:
2796#line 1233 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2797{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2798 break;}
2799case 103:
2800#line 1234 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2801{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2802 break;}
2803case 104:
2804#line 1235 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2805{ yyval.ParamAttrs = ParamAttr::SExt; ;
2806 break;}
2807case 105:
2808#line 1236 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2809{ yyval.ParamAttrs = ParamAttr::SExt; ;
2810 break;}
2811case 106:
2812#line 1237 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2813{ yyval.ParamAttrs = ParamAttr::InReg; ;
2814 break;}
2815case 107:
2816#line 1238 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2817{ yyval.ParamAttrs = ParamAttr::StructRet; ;
2818 break;}
2819case 108:
2820#line 1239 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2821{ yyval.ParamAttrs = ParamAttr::NoAlias; ;
2822 break;}
2823case 109:
2824#line 1240 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2825{ yyval.ParamAttrs = ParamAttr::ByVal; ;
2826 break;}
2827case 110:
2828#line 1241 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2829{ yyval.ParamAttrs = ParamAttr::Nest; ;
2830 break;}
2831case 111:
2832#line 1244 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2833{ yyval.ParamAttrs = ParamAttr::None; ;
2834 break;}
2835case 112:
2836#line 1245 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2837{
2838 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2839 ;
2840 break;}
2841case 113:
2842#line 1250 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2843{ yyval.ParamAttrs = ParamAttr::NoReturn; ;
2844 break;}
2845case 114:
2846#line 1251 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2847{ yyval.ParamAttrs = ParamAttr::NoUnwind; ;
2848 break;}
2849case 115:
2850#line 1252 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2851{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2852 break;}
2853case 116:
2854#line 1253 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2855{ yyval.ParamAttrs = ParamAttr::SExt; ;
2856 break;}
2857case 117:
2858#line 1256 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2859{ yyval.ParamAttrs = ParamAttr::None; ;
2860 break;}
2861case 118:
2862#line 1257 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2863{
2864 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2865 ;
2866 break;}
2867case 119:
2868#line 1264 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2869{ yyval.UIntVal = 0; ;
2870 break;}
2871case 120:
2872#line 1265 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2873{
2874 yyval.UIntVal = yyvsp[0].UInt64Val;
2875 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002876 GEN_ERROR("Alignment must be a power of two");
2877 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002878;
2879 break;}
2880case 121:
2881#line 1271 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2882{ yyval.UIntVal = 0; ;
2883 break;}
2884case 122:
2885#line 1272 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2886{
2887 yyval.UIntVal = yyvsp[0].UInt64Val;
2888 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002889 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002890 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002891;
2892 break;}
2893case 123:
2894#line 1280 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2895{
2896 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
2897 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002898 GEN_ERROR("Invalid character in section name");
Chris Lattner0275cff2007-08-06 21:00:46 +00002899 yyval.StrVal = yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002900 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002901;
2902 break;}
2903case 124:
2904#line 1288 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2905{ yyval.StrVal = 0; ;
2906 break;}
2907case 125:
2908#line 1289 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2909{ yyval.StrVal = yyvsp[0].StrVal; ;
2910 break;}
2911case 126:
2912#line 1294 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2913{;
2914 break;}
2915case 127:
2916#line 1295 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2917{;
2918 break;}
2919case 128:
2920#line 1296 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2921{
2922 CurGV->setSection(*yyvsp[0].StrVal);
2923 delete yyvsp[0].StrVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002924 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002925 ;
2926 break;}
2927case 129:
2928#line 1301 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2929{
2930 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002931 GEN_ERROR("Alignment must be a power of two");
Chris Lattner0275cff2007-08-06 21:00:46 +00002932 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00002933 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002934 ;
2935 break;}
2936case 137:
2937#line 1317 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2938{
2939 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00002940 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002941 ;
2942 break;}
2943case 138:
2944#line 1321 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2945{
2946 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002947 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002948 ;
2949 break;}
2950case 139:
2951#line 1325 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2952{ // Pointer type?
2953 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002954 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattner0275cff2007-08-06 21:00:46 +00002955 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2956 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002957 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002958 ;
2959 break;}
2960case 140:
2961#line 1332 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2962{ // Named types are also simple types...
2963 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00002964 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002965 yyval.TypeVal = new PATypeHolder(tmp);
2966 ;
2967 break;}
2968case 141:
2969#line 1337 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2970{ // Type UpReference
2971 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002972 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattner0275cff2007-08-06 21:00:46 +00002973 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2974 yyval.TypeVal = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002975 UR_OUT("New Upreference!\n");
2976 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00002977 ;
2978 break;}
2979case 142:
2980#line 1345 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2981{
Reid Spencer41dff5e2007-01-26 08:05:27 +00002982 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00002983 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00002984 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
2985 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00002986 Attrs.push_back(X);
2987 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00002988 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00002989 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00002990 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00002991 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00002992 Params.push_back(Ty);
2993 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00002994 if (I->Attrs != ParamAttr::None) {
2995 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
2996 Attrs.push_back(X);
2997 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00002998 }
2999 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3000 if (isVarArg) Params.pop_back();
3001
Reid Spencer7b5d4662007-04-09 06:16:21 +00003002 ParamAttrsList *ActualAttrs = 0;
3003 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003004 ActualAttrs = ParamAttrsList::get(Attrs);
Chris Lattner0275cff2007-08-06 21:00:46 +00003005 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs);
3006 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3007 delete yyvsp[-4].TypeVal; // Delete the return type handle
3008 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00003009 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003010 ;
3011 break;}
3012case 143:
3013#line 1375 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3014{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003015 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00003016 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00003017 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
3018 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00003019 Attrs.push_back(X);
3020 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003021 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00003022 unsigned index = 1;
3023 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00003024 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00003025 Params.push_back(Ty);
3026 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003027 if (I->Attrs != ParamAttr::None) {
3028 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
3029 Attrs.push_back(X);
3030 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003031 }
3032 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3033 if (isVarArg) Params.pop_back();
3034
Reid Spencer7b5d4662007-04-09 06:16:21 +00003035 ParamAttrsList *ActualAttrs = 0;
3036 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00003037 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00003038
Chris Lattner0275cff2007-08-06 21:00:46 +00003039 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs);
3040 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
3041 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00003042 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003043 ;
3044 break;}
3045case 144:
3046#line 1406 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3047{ // Sized array type?
3048 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3049 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003050 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003051 ;
3052 break;}
3053case 145:
3054#line 1411 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3055{ // Vector type?
3056 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
3057 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003058 GEN_ERROR("Unsigned result not equal to signed result");
3059 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
3060 GEN_ERROR("Element type of a VectorType must be primitive");
Chris Lattner0275cff2007-08-06 21:00:46 +00003061 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003062 GEN_ERROR("Vector length should be a power of 2");
Chris Lattner0275cff2007-08-06 21:00:46 +00003063 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
3064 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003065 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003066 ;
3067 break;}
3068case 146:
3069#line 1423 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3070{ // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003071 std::vector<const Type*> Elements;
Chris Lattner0275cff2007-08-06 21:00:46 +00003072 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
3073 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003074 Elements.push_back(*I);
3075
Chris Lattner0275cff2007-08-06 21:00:46 +00003076 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3077 delete yyvsp[-1].TypeList;
Reid Spencer14310612006-12-31 05:40:51 +00003078 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003079 ;
3080 break;}
3081case 147:
3082#line 1433 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3083{ // Empty structure type?
3084 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003085 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003086 ;
3087 break;}
3088case 148:
3089#line 1437 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3090{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003091 std::vector<const Type*> Elements;
Chris Lattner0275cff2007-08-06 21:00:46 +00003092 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3093 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003094 Elements.push_back(*I);
3095
Chris Lattner0275cff2007-08-06 21:00:46 +00003096 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3097 delete yyvsp[-2].TypeList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003098 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003099 ;
3100 break;}
3101case 149:
3102#line 1447 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3103{ // Empty structure type?
3104 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003105 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003106 ;
3107 break;}
3108case 150:
3109#line 1454 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3110{
3111 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3112 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
3113 ;
3114 break;}
3115case 151:
3116#line 1461 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3117{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003118 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003119 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3120 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003121 GEN_ERROR("LLVM functions cannot return aggregate types");
Chris Lattner0275cff2007-08-06 21:00:46 +00003122 yyval.TypeVal = yyvsp[0].TypeVal;
3123 ;
3124 break;}
3125case 152:
3126#line 1468 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3127{
3128 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
3129 ;
3130 break;}
3131case 153:
3132#line 1473 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3133{
3134 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3135 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer3da59db2006-11-27 01:05:10 +00003136 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003137 ;
3138 break;}
3139case 154:
3140#line 1478 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3141{
3142 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003143 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003144 ;
3145 break;}
3146case 156:
3147#line 1486 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3148{
3149 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003150 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003151 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner0275cff2007-08-06 21:00:46 +00003152 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003153 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003154 ;
3155 break;}
3156case 157:
3157#line 1493 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3158{
3159 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003160 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3161 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattner0275cff2007-08-06 21:00:46 +00003162 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003163 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003164 ;
3165 break;}
3166case 158:
3167#line 1500 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3168{
3169 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003170 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003171 ;
3172 break;}
3173case 159:
3174#line 1508 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3175{
3176 yyval.TypeList = new std::list<PATypeHolder>();
3177 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3178 delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00003179 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003180 ;
3181 break;}
3182case 160:
3183#line 1514 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3184{
3185 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3186 delete yyvsp[0].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003187 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003188 ;
3189 break;}
3190case 161:
3191#line 1526 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3192{ // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003193 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003194 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3195 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003196 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003197 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003198 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003199 const Type *ETy = ATy->getElementType();
3200 int NumElements = ATy->getNumElements();
3201
3202 // Verify that we have the correct size...
Chris Lattner0275cff2007-08-06 21:00:46 +00003203 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003204 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003205 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003206 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003207
3208 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00003209 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3210 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003211 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3212 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner0275cff2007-08-06 21:00:46 +00003213 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003214 }
3215
Chris Lattner0275cff2007-08-06 21:00:46 +00003216 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3217 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003218 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003219 ;
3220 break;}
3221case 162:
3222#line 1554 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3223{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003224 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003225 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3226 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003227 if (ATy == 0)
3228 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003229 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003230
Andrew Lenharth6353e052006-12-08 18:07:09 +00003231 int NumElements = ATy->getNumElements();
3232 if (NumElements != -1 && NumElements != 0)
3233 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003234 " arguments, but has size of " + itostr(NumElements) +"");
Chris Lattner0275cff2007-08-06 21:00:46 +00003235 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3236 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003237 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003238 ;
3239 break;}
3240case 163:
3241#line 1570 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3242{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003243 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003244 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3245 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003246 if (ATy == 0)
3247 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003248 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003249
3250 int NumElements = ATy->getNumElements();
3251 const Type *ETy = ATy->getElementType();
Chris Lattner0275cff2007-08-06 21:00:46 +00003252 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003253 GEN_ERROR("Can't build string constant of size " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003254 itostr((int)(yyvsp[0].StrVal->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003255 " when array has size " + itostr(NumElements) + "");
3256 std::vector<Constant*> Vals;
3257 if (ETy == Type::Int8Ty) {
Chris Lattner0275cff2007-08-06 21:00:46 +00003258 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3259 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003260 } else {
Chris Lattner0275cff2007-08-06 21:00:46 +00003261 delete yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003262 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3263 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003264 delete yyvsp[0].StrVal;
3265 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3266 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003267 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003268 ;
3269 break;}
3270case 164:
3271#line 1597 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3272{ // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003273 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003274 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3275 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003276 if (PTy == 0)
3277 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003278 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003279 const Type *ETy = PTy->getElementType();
3280 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003281
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003282 // Verify that we have the correct size...
Chris Lattner0275cff2007-08-06 21:00:46 +00003283 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003284 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003285 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003286 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003287
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003288 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00003289 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3290 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003291 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3292 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner0275cff2007-08-06 21:00:46 +00003293 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003294 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003295
Chris Lattner0275cff2007-08-06 21:00:46 +00003296 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3297 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003298 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003299 ;
3300 break;}
3301case 165:
3302#line 1625 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3303{
3304 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003305 if (STy == 0)
3306 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003307 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003308
Chris Lattner0275cff2007-08-06 21:00:46 +00003309 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003310 GEN_ERROR("Illegal number of initializers for structure type");
3311
3312 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner0275cff2007-08-06 21:00:46 +00003313 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3314 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003315 GEN_ERROR("Expected type '" +
3316 STy->getElementType(i)->getDescription() +
3317 "' for element #" + utostr(i) +
3318 " of structure initializer");
3319
3320 // Check to ensure that Type is not packed
3321 if (STy->isPacked())
3322 GEN_ERROR("Unpacked Initializer to vector type '" +
3323 STy->getDescription() + "'");
3324
Chris Lattner0275cff2007-08-06 21:00:46 +00003325 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3326 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003327 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003328 ;
3329 break;}
3330case 166:
3331#line 1651 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3332{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003333 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003334 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3335 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003336 if (STy == 0)
3337 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003338 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003339
3340 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003341 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003342
3343 // Check to ensure that Type is not packed
3344 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00003345 GEN_ERROR("Unpacked Initializer to vector type '" +
3346 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003347
Chris Lattner0275cff2007-08-06 21:00:46 +00003348 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3349 delete yyvsp[-2].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003350 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003351 ;
3352 break;}
3353case 167:
3354#line 1671 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3355{
3356 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003357 if (STy == 0)
3358 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003359 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003360
Chris Lattner0275cff2007-08-06 21:00:46 +00003361 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003362 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003363
3364 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner0275cff2007-08-06 21:00:46 +00003365 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3366 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003367 GEN_ERROR("Expected type '" +
3368 STy->getElementType(i)->getDescription() +
3369 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003370 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003371
3372 // Check to ensure that Type is packed
3373 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003374 GEN_ERROR("Vector initializer to non-vector type '" +
3375 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003376
Chris Lattner0275cff2007-08-06 21:00:46 +00003377 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3378 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003379 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003380 ;
3381 break;}
3382case 168:
3383#line 1697 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3384{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003385 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003386 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3387 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003388 if (STy == 0)
3389 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003390 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003391
3392 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003393 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003394
3395 // Check to ensure that Type is packed
3396 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003397 GEN_ERROR("Vector initializer to non-vector type '" +
3398 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003399
Chris Lattner0275cff2007-08-06 21:00:46 +00003400 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3401 delete yyvsp[-4].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003402 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003403 ;
3404 break;}
3405case 169:
3406#line 1717 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3407{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003408 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003409 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3410 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003411 if (PTy == 0)
3412 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00003413 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003414
Chris Lattner0275cff2007-08-06 21:00:46 +00003415 yyval.ConstVal = ConstantPointerNull::get(PTy);
3416 delete yyvsp[-1].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003417 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003418 ;
3419 break;}
3420case 170:
3421#line 1729 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3422{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003423 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003424 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3425 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3426 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003427 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003428 ;
3429 break;}
3430case 171:
3431#line 1736 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3432{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003433 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003434 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3435 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003436 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003437 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003438
3439 // ConstExprs can exist in the body of a function, thus creating
3440 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00003441 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00003442 // symbol table instead of the module symbol table for the global symbol,
3443 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00003444 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00003445 //
3446 Function *SavedCurFn = CurFun.CurrentFunction;
3447 CurFun.CurrentFunction = 0;
3448
Chris Lattner0275cff2007-08-06 21:00:46 +00003449 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003450 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003451
3452 CurFun.CurrentFunction = SavedCurFn;
3453
3454 // If this is an initializer for a constant pointer, which is referencing a
3455 // (currently) undefined variable, create a stub now that shall be replaced
3456 // in the future with the right type of variable.
3457 //
3458 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00003459 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003460 const PointerType *PT = cast<PointerType>(Ty);
3461
3462 // First check to see if the forward references value is already created!
3463 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattner0275cff2007-08-06 21:00:46 +00003464 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003465
3466 if (I != CurModule.GlobalRefs.end()) {
3467 V = I->second; // Placeholder already exists, use it...
Chris Lattner0275cff2007-08-06 21:00:46 +00003468 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003469 } else {
3470 std::string Name;
Chris Lattner0275cff2007-08-06 21:00:46 +00003471 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
3472 Name = yyvsp[0].ValIDVal.getName();
3473 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003474 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003475
3476 // Create the forward referenced global.
3477 GlobalValue *GV;
3478 if (const FunctionType *FTy =
3479 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00003480 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003481 CurModule.CurrentModule);
3482 } else {
3483 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00003484 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003485 Name, CurModule.CurrentModule);
3486 }
3487
3488 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattner0275cff2007-08-06 21:00:46 +00003489 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003490 V = GV;
3491 }
3492 }
3493
Chris Lattner0275cff2007-08-06 21:00:46 +00003494 yyval.ConstVal = cast<GlobalValue>(V);
3495 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003496 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003497 ;
3498 break;}
3499case 172:
3500#line 1802 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3501{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003502 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003503 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3504 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003505 GEN_ERROR("Mismatched types for constant expression: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00003506 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3507 yyval.ConstVal = yyvsp[0].ConstVal;
3508 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003509 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003510 ;
3511 break;}
3512case 173:
3513#line 1812 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3514{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003515 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003516 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3517 const Type *Ty = yyvsp[-1].TypeVal->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003518 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3519 GEN_ERROR("Cannot create a null initialized value of this type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003520 yyval.ConstVal = Constant::getNullValue(Ty);
3521 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003522 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003523 ;
3524 break;}
3525case 174:
3526#line 1822 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3527{ // integral constants
3528 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003529 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003530 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Reid Spencer38c91a92007-02-28 02:24:54 +00003531 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003532 ;
3533 break;}
3534case 175:
3535#line 1828 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3536{ // arbitrary precision integer constants
3537 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3538 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003539 GEN_ERROR("Constant value does not fit in type");
3540 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003541 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
3542 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3543 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003544 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003545 ;
3546 break;}
3547case 176:
3548#line 1838 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3549{ // integral constants
3550 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003551 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003552 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003553 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003554 ;
3555 break;}
3556case 177:
3557#line 1844 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3558{ // arbitrary precision integer constants
3559 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3560 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003561 GEN_ERROR("Constant value does not fit in type");
3562 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003563 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
3564 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3565 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003566 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003567 ;
3568 break;}
3569case 178:
3570#line 1854 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3571{ // Boolean constants
3572 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3573 yyval.ConstVal = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00003574 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003575 ;
3576 break;}
3577case 179:
3578#line 1859 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3579{ // Boolean constants
3580 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3581 yyval.ConstVal = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00003582 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003583 ;
3584 break;}
3585case 180:
3586#line 1864 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3587{ // Float & Double constants
3588 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003589 GEN_ERROR("Floating point constant invalid for type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003590 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003591 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003592 ;
3593 break;}
3594case 181:
3595#line 1872 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3596{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003597 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003598 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3599 Constant *Val = yyvsp[-3].ConstVal;
3600 const Type *DestTy = yyvsp[-1].TypeVal->get();
3601 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003602 GEN_ERROR("invalid cast opcode for cast from '" +
3603 Val->getType()->getDescription() + "' to '" +
3604 DestTy->getDescription() + "'");
Chris Lattner0275cff2007-08-06 21:00:46 +00003605 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3606 delete yyvsp[-1].TypeVal;
3607 ;
3608 break;}
3609case 182:
3610#line 1884 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3611{
3612 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00003613 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003614
3615 const Type *IdxTy =
Chris Lattner0275cff2007-08-06 21:00:46 +00003616 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), &(*yyvsp[-1].ValueList)[0], yyvsp[-1].ValueList->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00003617 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003618 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00003619 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003620
Chris Lattnerf7469af2007-01-31 04:44:08 +00003621 SmallVector<Constant*, 8> IdxVec;
Chris Lattner0275cff2007-08-06 21:00:46 +00003622 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3623 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003624 IdxVec.push_back(C);
3625 else
Reid Spencerb5334b02007-02-05 10:18:06 +00003626 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003627
Chris Lattner0275cff2007-08-06 21:00:46 +00003628 delete yyvsp[-1].ValueList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003629
Chris Lattner0275cff2007-08-06 21:00:46 +00003630 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003631 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003632 ;
3633 break;}
3634case 183:
3635#line 1906 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3636{
3637 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003638 GEN_ERROR("Select condition must be of boolean type");
Chris Lattner0275cff2007-08-06 21:00:46 +00003639 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003640 GEN_ERROR("Select operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003641 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003642 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003643 ;
3644 break;}
3645case 184:
3646#line 1914 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3647{
3648 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003649 GEN_ERROR("Binary operator types must match");
3650 CHECK_FOR_ERROR;
Chris Lattner0275cff2007-08-06 21:00:46 +00003651 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3652 ;
3653 break;}
3654case 185:
3655#line 1920 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3656{
3657 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003658 GEN_ERROR("Logical operator types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003659 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3660 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
3661 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003662 GEN_ERROR("Logical operator requires integral operands");
3663 }
Chris Lattner0275cff2007-08-06 21:00:46 +00003664 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003665 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003666 ;
3667 break;}
3668case 186:
3669#line 1931 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3670{
3671 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003672 GEN_ERROR("icmp operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003673 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3674 ;
3675 break;}
3676case 187:
3677#line 1936 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3678{
3679 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003680 GEN_ERROR("fcmp operand types must match");
Chris Lattner0275cff2007-08-06 21:00:46 +00003681 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3682 ;
3683 break;}
3684case 188:
3685#line 1941 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3686{
3687 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003688 GEN_ERROR("Invalid extractelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00003689 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003690 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003691 ;
3692 break;}
3693case 189:
3694#line 1947 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3695{
3696 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003697 GEN_ERROR("Invalid insertelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00003698 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003699 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003700 ;
3701 break;}
3702case 190:
3703#line 1953 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3704{
3705 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003706 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00003707 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003708 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003709 ;
3710 break;}
3711case 191:
3712#line 1962 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3713{
3714 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003715 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003716 ;
3717 break;}
3718case 192:
3719#line 1966 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3720{
3721 yyval.ConstVector = new std::vector<Constant*>();
3722 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003723 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003724 ;
3725 break;}
3726case 193:
3727#line 1974 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3728{ yyval.BoolVal = false; ;
3729 break;}
3730case 194:
3731#line 1974 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3732{ yyval.BoolVal = true; ;
3733 break;}
3734case 195:
3735#line 1977 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3736{ yyval.BoolVal = true; ;
3737 break;}
3738case 196:
3739#line 1977 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3740{ yyval.BoolVal = false; ;
3741 break;}
3742case 197:
3743#line 1980 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3744{
3745 const Type* VTy = yyvsp[-1].TypeVal->get();
3746 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
3747 CHECK_FOR_ERROR
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003748 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
3749 if (!Aliasee)
3750 GEN_ERROR("Aliases can be created only to global values");
3751
Chris Lattner0275cff2007-08-06 21:00:46 +00003752 yyval.ConstVal = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003753 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003754 delete yyvsp[-1].TypeVal;
3755 ;
3756 break;}
3757case 198:
3758#line 1992 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3759{
3760 Constant *Val = yyvsp[-3].ConstVal;
3761 const Type *DestTy = yyvsp[-1].TypeVal->get();
3762 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003763 GEN_ERROR("invalid cast opcode for cast from '" +
3764 Val->getType()->getDescription() + "' to '" +
3765 DestTy->getDescription() + "'");
3766
Chris Lattner0275cff2007-08-06 21:00:46 +00003767 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003768 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003769 delete yyvsp[-1].TypeVal;
3770 ;
3771 break;}
3772case 199:
3773#line 2013 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3774{
3775 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer1013b4d2007-07-31 14:41:17 +00003776 CurModule.ModuleDone();
3777 CHECK_FOR_ERROR;
Chris Lattner0275cff2007-08-06 21:00:46 +00003778 ;
3779 break;}
3780case 200:
3781#line 2018 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3782{
3783 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003784 CurModule.ModuleDone();
3785 CHECK_FOR_ERROR;
Chris Lattner0275cff2007-08-06 21:00:46 +00003786 ;
3787 break;}
3788case 203:
3789#line 2031 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3790{ CurFun.isDeclare = false; ;
3791 break;}
3792case 204:
3793#line 2031 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3794{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003795 CurFun.FunctionDone();
3796 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003797 ;
3798 break;}
3799case 205:
3800#line 2035 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3801{ CurFun.isDeclare = true; ;
3802 break;}
3803case 206:
3804#line 2035 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3805{
Reid Spencer1013b4d2007-07-31 14:41:17 +00003806 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003807 ;
3808 break;}
3809case 207:
3810#line 2038 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3811{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003812 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003813 ;
3814 break;}
3815case 208:
3816#line 2041 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3817{
Reid Spencer14310612006-12-31 05:40:51 +00003818 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003819 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003820 // Eagerly resolve types. This is not an optimization, this is a
3821 // requirement that is due to the fact that we could have this:
3822 //
3823 // %list = type { %list * }
3824 // %list = type { %list * } ; repeated type decl
3825 //
3826 // If types are not resolved eagerly, then the two types will not be
3827 // determined to be the same type!
3828 //
Chris Lattner0275cff2007-08-06 21:00:46 +00003829 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003830
Chris Lattner0275cff2007-08-06 21:00:46 +00003831 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003832 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003833 // If this is a named type that is not a redefinition, add it to the slot
3834 // table.
Chris Lattner0275cff2007-08-06 21:00:46 +00003835 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003836 }
Reid Spencera132e042006-12-03 05:46:11 +00003837
Chris Lattner0275cff2007-08-06 21:00:46 +00003838 delete yyvsp[0].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003839 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003840 ;
3841 break;}
3842case 209:
3843#line 2065 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3844{
3845 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spencerb8f85052007-07-31 03:50:36 +00003846
Chris Lattner0275cff2007-08-06 21:00:46 +00003847 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003848 CHECK_FOR_ERROR
3849 // If this is a named type that is not a redefinition, add it to the slot
3850 // table.
Chris Lattner0275cff2007-08-06 21:00:46 +00003851 CurModule.Types.push_back(yyvsp[0].PrimType);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003852 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003853 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003854 ;
3855 break;}
3856case 210:
3857#line 2076 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3858{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003859 /* "Externally Visible" Linkage */
Chris Lattner0275cff2007-08-06 21:00:46 +00003860 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003861 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner0275cff2007-08-06 21:00:46 +00003862 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage,
3863 yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003864 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003865 ;
3866 break;}
3867case 211:
3868#line 2083 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3869{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003870 CurGV = 0;
Chris Lattner0275cff2007-08-06 21:00:46 +00003871 ;
3872 break;}
3873case 212:
3874#line 2087 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3875{
3876 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003877 GEN_ERROR("Global value initializer is not a constant");
Chris Lattner0275cff2007-08-06 21:00:46 +00003878 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 +00003879 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003880 ;
3881 break;}
3882case 213:
3883#line 2092 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3884{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003885 CurGV = 0;
Chris Lattner0275cff2007-08-06 21:00:46 +00003886 ;
3887 break;}
3888case 214:
3889#line 2096 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3890{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003891 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003892 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3893 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 +00003894 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003895 delete yyvsp[0].TypeVal;
3896 ;
3897 break;}
3898case 215:
3899#line 2102 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3900{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003901 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003902 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003903 ;
3904 break;}
3905case 216:
3906#line 2106 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3907{
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003908 std::string Name;
Chris Lattner0275cff2007-08-06 21:00:46 +00003909 if (yyvsp[-4].StrVal) {
3910 Name = *yyvsp[-4].StrVal;
3911 delete yyvsp[-4].StrVal;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003912 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003913 if (Name.empty())
3914 GEN_ERROR("Alias name cannot be empty");
3915
Chris Lattner0275cff2007-08-06 21:00:46 +00003916 Constant* Aliasee = yyvsp[0].ConstVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003917 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003918 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003919
Chris Lattner0275cff2007-08-06 21:00:46 +00003920 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003921 CurModule.CurrentModule);
Chris Lattner0275cff2007-08-06 21:00:46 +00003922 GA->setVisibility(yyvsp[-3].Visibility);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003923 InsertValue(GA, CurModule.Values);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003924 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003925 ;
3926 break;}
3927case 217:
3928#line 2125 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3929{
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003930 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003931 ;
3932 break;}
3933case 218:
3934#line 2128 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3935{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003936 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003937 ;
3938 break;}
3939case 219:
3940#line 2134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3941{
Chris Lattner66316012006-01-24 04:14:29 +00003942 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00003943 if (AsmSoFar.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003944 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003945 else
Chris Lattner0275cff2007-08-06 21:00:46 +00003946 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
3947 delete yyvsp[0].StrVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003948 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003949;
3950 break;}
3951case 220:
3952#line 2144 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3953{
3954 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
3955 delete yyvsp[0].StrVal;
3956 ;
3957 break;}
3958case 221:
3959#line 2148 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3960{
3961 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
3962 delete yyvsp[0].StrVal;
3963 ;
3964 break;}
3965case 223:
3966#line 2155 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3967{
3968 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
3969 delete yyvsp[0].StrVal;
Reid Spencer1013b4d2007-07-31 14:41:17 +00003970 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003971 ;
3972 break;}
3973case 224:
3974#line 2160 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3975{
3976 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
3977 delete yyvsp[0].StrVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003978 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003979 ;
3980 break;}
3981case 225:
3982#line 2165 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3983{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003984 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003985 ;
3986 break;}
3987case 226:
3988#line 2174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3989{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003990 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00003991 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3992 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003993 GEN_ERROR("void typed arguments are invalid");
Chris Lattner0275cff2007-08-06 21:00:46 +00003994 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3995 yyval.ArgList = yyvsp[-4].ArgList;
3996 yyvsp[-4].ArgList->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00003997 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00003998 ;
3999 break;}
4000case 227:
4001#line 2184 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4002{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004003 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004004 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4005 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004006 GEN_ERROR("void typed arguments are invalid");
Chris Lattner0275cff2007-08-06 21:00:46 +00004007 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
4008 yyval.ArgList = new ArgListType;
4009 yyval.ArgList->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004010 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004011 ;
4012 break;}
4013case 228:
4014#line 2195 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4015{
4016 yyval.ArgList = yyvsp[0].ArgList;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004017 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004018 ;
4019 break;}
4020case 229:
4021#line 2199 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4022{
4023 yyval.ArgList = yyvsp[-2].ArgList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004024 struct ArgListEntry E;
4025 E.Ty = new PATypeHolder(Type::VoidTy);
4026 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00004027 E.Attrs = ParamAttr::None;
Chris Lattner0275cff2007-08-06 21:00:46 +00004028 yyval.ArgList->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004029 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004030 ;
4031 break;}
4032case 230:
4033#line 2208 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4034{
4035 yyval.ArgList = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004036 struct ArgListEntry E;
4037 E.Ty = new PATypeHolder(Type::VoidTy);
4038 E.Name = 0;
4039 E.Attrs = ParamAttr::None;
Chris Lattner0275cff2007-08-06 21:00:46 +00004040 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00004041 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004042 ;
4043 break;}
4044case 231:
4045#line 2217 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4046{
4047 yyval.ArgList = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004048 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004049 ;
4050 break;}
4051case 232:
4052#line 2223 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4053{
4054 std::string FunctionName(*yyvsp[-6].StrVal);
4055 delete yyvsp[-6].StrVal; // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004056
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004057 // Check the function result for abstractness if this is a define. We should
4058 // have no abstract types at this point
Chris Lattner0275cff2007-08-06 21:00:46 +00004059 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
4060 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004061
Reid Spencer68a24bd2005-08-27 18:50:39 +00004062 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00004063 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00004064 if (yyvsp[-2].ParamAttrs != ParamAttr::None) {
4065 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004066 Attrs.push_back(PAWI);
4067 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004068 if (yyvsp[-4].ArgList) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00004069 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004070 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004071 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00004072 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
4073 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00004074 ParamTypeList.push_back(Ty);
4075 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00004076 if (I->Attrs != ParamAttr::None) {
4077 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4078 Attrs.push_back(PAWI);
4079 }
Reid Spencer14310612006-12-31 05:40:51 +00004080 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004081 }
4082
4083 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4084 if (isVarArg) ParamTypeList.pop_back();
4085
Christopher Lamb5c104242007-04-22 20:09:11 +00004086 ParamAttrsList *PAL = 0;
4087 if (!Attrs.empty())
4088 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004089
Chris Lattner0275cff2007-08-06 21:00:46 +00004090 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004091 const PointerType *PFT = PointerType::get(FT);
Chris Lattner0275cff2007-08-06 21:00:46 +00004092 delete yyvsp[-7].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004093
4094 ValID ID;
4095 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004096 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004097 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004098 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004099 }
4100
4101 Function *Fn = 0;
4102 // See if this function was forward referenced. If so, recycle the object.
4103 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4104 // Move the function to the end of the list, from whereever it was
4105 // previously inserted.
4106 Fn = cast<Function>(FWRef);
4107 CurModule.CurrentModule->getFunctionList().remove(Fn);
4108 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4109 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004110 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004111 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004112 // The existing function doesn't have the same type. This is an overload
4113 // error.
4114 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4115 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004116 // Neither the existing or the current function is a declaration and they
4117 // have the same name and same type. Clearly this is a redefinition.
4118 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004119 } if (Fn->isDeclaration()) {
4120 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004121 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4122 AI != AE; ++AI)
4123 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004124 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004125 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004126 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004127 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004128
Reid Spencer68a24bd2005-08-27 18:50:39 +00004129 InsertValue(Fn, CurModule.Values);
4130 }
4131
4132 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004133
4134 if (CurFun.isDeclare) {
4135 // If we have declaration, always overwrite linkage. This will allow us to
4136 // correctly handle cases, when pointer to function is passed as argument to
4137 // another function.
4138 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004139 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004140 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004141 Fn->setCallingConv(yyvsp[-8].UIntVal);
4142 Fn->setAlignment(yyvsp[0].UIntVal);
4143 if (yyvsp[-1].StrVal) {
4144 Fn->setSection(*yyvsp[-1].StrVal);
4145 delete yyvsp[-1].StrVal;
Chris Lattnere869eef2005-11-12 00:11:49 +00004146 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004147
4148 // Add all of the arguments we parsed to the function...
Chris Lattner0275cff2007-08-06 21:00:46 +00004149 if (yyvsp[-4].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004150 if (isVarArg) { // Nuke the last entry
Chris Lattner0275cff2007-08-06 21:00:46 +00004151 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004152 "Not a varargs marker!");
Chris Lattner0275cff2007-08-06 21:00:46 +00004153 delete yyvsp[-4].ArgList->back().Ty;
4154 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004155 }
4156 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004157 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004158 unsigned Idx = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004159 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin();
4160 I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004161 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004162 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004163 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004164 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004165 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004166 }
Reid Spencera132e042006-12-03 05:46:11 +00004167
Chris Lattner0275cff2007-08-06 21:00:46 +00004168 delete yyvsp[-4].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004169 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004170 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004171;
4172 break;}
4173case 235:
4174#line 2345 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4175{
4176 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004177
4178 // Make sure that we keep track of the linkage type even if there was a
4179 // previous "declare".
Chris Lattner0275cff2007-08-06 21:00:46 +00004180 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4181 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
4182;
4183 break;}
4184case 238:
4185#line 2356 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4186{
4187 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004188 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004189;
4190 break;}
4191case 239:
4192#line 2361 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4193{
4194 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4195 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4196 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004197 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004198 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004199 ;
4200 break;}
4201case 240:
4202#line 2373 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4203{
4204 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004205 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004206 ;
4207 break;}
4208case 241:
4209#line 2377 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4210{
4211 yyval.BoolVal = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004212 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004213 ;
4214 break;}
4215case 242:
4216#line 2382 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4217{ // A reference to a direct constant
4218 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004219 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004220 ;
4221 break;}
4222case 243:
4223#line 2386 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4224{
4225 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004226 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004227 ;
4228 break;}
4229case 244:
4230#line 2390 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4231{ // Perhaps it's an FP constant?
4232 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004233 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004234 ;
4235 break;}
4236case 245:
4237#line 2394 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4238{
4239 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004240 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004241 ;
4242 break;}
4243case 246:
4244#line 2398 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4245{
4246 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004247 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004248 ;
4249 break;}
4250case 247:
4251#line 2402 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4252{
4253 yyval.ValIDVal = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004254 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004255 ;
4256 break;}
4257case 248:
4258#line 2406 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4259{
4260 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004261 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004262 ;
4263 break;}
4264case 249:
4265#line 2410 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4266{ // A vector zero constant.
4267 yyval.ValIDVal = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004268 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004269 ;
4270 break;}
4271case 250:
4272#line 2414 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4273{ // Nonempty unsized packed vector
4274 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4275 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004276
Reid Spencer9d6565a2007-02-15 02:26:10 +00004277 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004278 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004279 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004280 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004281 ETy,
4282 NumElements)
4283 )
4284 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004285
4286 // Verify all elements are correct type!
Chris Lattner0275cff2007-08-06 21:00:46 +00004287 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4288 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004289 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004290 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00004291 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004292 }
4293
Chris Lattner0275cff2007-08-06 21:00:46 +00004294 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4295 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer832254e2007-02-02 02:16:23 +00004296 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004297 ;
4298 break;}
4299case 251:
4300#line 2439 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4301{
4302 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004303 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004304 ;
4305 break;}
4306case 252:
4307#line 2443 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4308{
4309 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
4310 delete yyvsp[-2].StrVal;
4311 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004312 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004313 ;
4314 break;}
4315case 253:
4316#line 2453 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4317{ // Is it an integer reference...?
4318 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004319 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004320 ;
4321 break;}
4322case 254:
4323#line 2457 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4324{
4325 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004326 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004327 ;
4328 break;}
4329case 255:
4330#line 2461 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4331{ // Is it a named reference...?
4332 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
4333 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004334 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004335 ;
4336 break;}
4337case 256:
4338#line 2466 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4339{ // Is it a named reference...?
4340 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
4341 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004342 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004343 ;
4344 break;}
4345case 259:
4346#line 2479 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4347{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004348 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004349 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4350 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4351 delete yyvsp[-1].TypeVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004352 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004353 ;
4354 break;}
4355case 260:
4356#line 2488 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4357{
4358 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004359 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004360 ;
4361 break;}
4362case 261:
4363#line 2492 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4364{ // Do not allow functions with 0 basic blocks
4365 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004366 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004367 ;
4368 break;}
4369case 262:
4370#line 2501 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4371{
4372 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004373 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004374 InsertValue(yyvsp[0].TermInstVal);
4375 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4376 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004377 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004378 ;
4379 break;}
4380case 263:
4381#line 2510 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4382{
4383 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004384 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4385 if (CI2->getParent() == 0)
Chris Lattner0275cff2007-08-06 21:00:46 +00004386 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4387 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4388 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004389 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004390 ;
4391 break;}
4392case 264:
4393#line 2519 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4394{ // Empty space between instruction lists
4395 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00004396 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004397 ;
4398 break;}
4399case 265:
4400#line 2523 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4401{ // Labelled (named) basic block
4402 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal));
4403 delete yyvsp[0].StrVal;
Reid Spencered951ea2007-05-19 07:22:10 +00004404 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004405
Chris Lattner0275cff2007-08-06 21:00:46 +00004406 ;
4407 break;}
4408case 266:
4409#line 2530 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4410{ // Return with a result...
4411 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4412 CHECK_FOR_ERROR
4413 ;
4414 break;}
4415case 267:
4416#line 2534 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4417{ // Return with no result...
4418 yyval.TermInstVal = new ReturnInst();
4419 CHECK_FOR_ERROR
4420 ;
4421 break;}
4422case 268:
4423#line 2538 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4424{ // Unconditional Branch...
4425 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4426 CHECK_FOR_ERROR
4427 yyval.TermInstVal = new BranchInst(tmpBB);
4428 ;
4429 break;}
4430case 269:
4431#line 2543 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4432{
4433 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4434 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4435 CHECK_FOR_ERROR
4436 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4437 CHECK_FOR_ERROR
4438 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4439 CHECK_FOR_ERROR
4440 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4441 ;
4442 break;}
4443case 270:
4444#line 2553 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4445{
4446 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4447 CHECK_FOR_ERROR
4448 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4449 CHECK_FOR_ERROR
4450 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4451 yyval.TermInstVal = S;
Reid Spencerb8f85052007-07-31 03:50:36 +00004452
Chris Lattner0275cff2007-08-06 21:00:46 +00004453 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4454 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004455 for (; I != E; ++I) {
4456 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4457 S->addCase(CI, I->second);
4458 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004459 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004460 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004461 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00004462 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004463 ;
4464 break;}
4465case 271:
4466#line 2572 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4467{
4468 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004469 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004470 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004471 CHECK_FOR_ERROR
4472 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattner0275cff2007-08-06 21:00:46 +00004473 yyval.TermInstVal = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004474 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004475 ;
4476 break;}
4477case 272:
4478#line 2582 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4479{
Reid Spencer3822ff52006-11-08 06:47:33 +00004480
Reid Spencer14310612006-12-31 05:40:51 +00004481 // Handle the short syntax
4482 const PointerType *PFTy = 0;
4483 const FunctionType *Ty = 0;
Chris Lattner0275cff2007-08-06 21:00:46 +00004484 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004485 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4486 // Pull out the types of all of the arguments...
4487 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00004488 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00004489 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
4490 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004491 Attrs.push_back(PAWI);
4492 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004493 ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00004494 unsigned index = 1;
4495 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004496 const Type *Ty = I->Val->getType();
4497 if (Ty == Type::VoidTy)
4498 GEN_ERROR("Short call syntax cannot be used with varargs");
4499 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00004500 if (I->Attrs != ParamAttr::None) {
4501 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4502 Attrs.push_back(PAWI);
4503 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004504 }
4505
Christopher Lamb5c104242007-04-22 20:09:11 +00004506 ParamAttrsList *PAL = 0;
4507 if (!Attrs.empty())
4508 PAL = ParamAttrsList::get(Attrs);
Chris Lattner0275cff2007-08-06 21:00:46 +00004509 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004510 PFTy = PointerType::get(Ty);
4511 }
4512
Chris Lattner0275cff2007-08-06 21:00:46 +00004513 delete yyvsp[-11].TypeVal;
Reid Spencer66728ef2007-03-20 01:13:36 +00004514
Chris Lattner0275cff2007-08-06 21:00:46 +00004515 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004516 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004517 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004518 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004519 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004520 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004521
Reid Spencer14310612006-12-31 05:40:51 +00004522 // Check the arguments
4523 ValueList Args;
Chris Lattner0275cff2007-08-06 21:00:46 +00004524 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00004525 // Make sure no arguments is a good thing!
4526 if (Ty->getNumParams() != 0)
4527 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004528 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004529 } else { // Has arguments?
4530 // Loop through FunctionType's arguments and ensure they are specified
4531 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004532 FunctionType::param_iterator I = Ty->param_begin();
4533 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner0275cff2007-08-06 21:00:46 +00004534 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004535
Reid Spencer14310612006-12-31 05:40:51 +00004536 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4537 if (ArgI->Val->getType() != *I)
4538 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004539 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004540 Args.push_back(ArgI->Val);
4541 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004542
Reid Spencer14310612006-12-31 05:40:51 +00004543 if (Ty->isVarArg()) {
4544 if (I == E)
4545 for (; ArgI != ArgE; ++ArgI)
4546 Args.push_back(ArgI->Val); // push the remaining varargs
4547 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004548 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004549 }
Reid Spencer14310612006-12-31 05:40:51 +00004550
4551 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00004552 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Chris Lattner0275cff2007-08-06 21:00:46 +00004553 II->setCallingConv(yyvsp[-12].UIntVal);
4554 yyval.TermInstVal = II;
4555 delete yyvsp[-8].ValueRefList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004556 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004557 ;
4558 break;}
4559case 273:
4560#line 2661 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4561{
4562 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004563 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004564 ;
4565 break;}
4566case 274:
4567#line 2665 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4568{
4569 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004570 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004571 ;
4572 break;}
4573case 275:
4574#line 2672 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4575{
4576 yyval.JumpTable = yyvsp[-5].JumpTable;
4577 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004578 CHECK_FOR_ERROR
4579 if (V == 0)
4580 GEN_ERROR("May only switch on a constant pool value");
4581
Chris Lattner0275cff2007-08-06 21:00:46 +00004582 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004583 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004584 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4585 ;
4586 break;}
4587case 276:
4588#line 2683 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4589{
4590 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4591 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004592 CHECK_FOR_ERROR
4593
4594 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004595 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004596
Chris Lattner0275cff2007-08-06 21:00:46 +00004597 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004598 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004599 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4600 ;
4601 break;}
4602case 277:
4603#line 2696 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4604{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004605 // Is this definition named?? if so, assign the name...
Chris Lattner0275cff2007-08-06 21:00:46 +00004606 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004607 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004608 InsertValue(yyvsp[0].InstVal);
4609 yyval.InstVal = yyvsp[0].InstVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004610 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004611 ;
4612 break;}
4613case 278:
4614#line 2706 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4615{ // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004616 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004617 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4618 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4619 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004620 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004621 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004622 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004623 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4624 delete yyvsp[-5].TypeVal;
4625 ;
4626 break;}
4627case 279:
4628#line 2717 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4629{
4630 yyval.PHIList = yyvsp[-6].PHIList;
4631 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004632 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004633 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004634 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004635 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4636 ;
4637 break;}
4638case 280:
4639#line 2727 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4640{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004641 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004642 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004643 // Used for call and invoke instructions
Chris Lattner0275cff2007-08-06 21:00:46 +00004644 yyval.ValueRefList = new ValueRefList();
4645 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4646 yyval.ValueRefList->push_back(E);
4647 delete yyvsp[-2].TypeVal;
4648 ;
4649 break;}
4650case 281:
4651#line 2736 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4652{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004653 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004654 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4655 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4656 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4657 yyval.ValueRefList->push_back(E);
4658 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004659 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004660 ;
4661 break;}
4662case 282:
4663#line 2745 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4664{ yyval.ValueRefList = new ValueRefList(); ;
4665 break;}
4666case 283:
4667#line 2748 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4668{ yyval.ValueList = new std::vector<Value*>(); ;
4669 break;}
4670case 284:
4671#line 2749 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4672{
4673 yyval.ValueList = yyvsp[-2].ValueList;
4674 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004675 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004676 ;
4677 break;}
4678case 285:
4679#line 2756 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4680{
4681 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004682 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004683 ;
4684 break;}
4685case 286:
4686#line 2760 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4687{
4688 yyval.BoolVal = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004689 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004690 ;
4691 break;}
4692case 287:
4693#line 2765 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4694{
Reid Spencer14310612006-12-31 05:40:51 +00004695 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004696 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4697 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4698 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004699 GEN_ERROR(
4700 "Arithmetic operator requires integer, FP, or packed operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004701 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) &&
4702 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4703 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4704 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004705 GEN_ERROR("Remainder not supported on vector types");
Chris Lattner0275cff2007-08-06 21:00:46 +00004706 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004707 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004708 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004709 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004710 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4711 if (yyval.InstVal == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004712 GEN_ERROR("binary operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004713 delete yyvsp[-3].TypeVal;
4714 ;
4715 break;}
4716case 288:
4717#line 2786 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4718{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004719 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004720 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4721 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4722 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
4723 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004724 GEN_ERROR("Logical operator requires integral operands");
4725 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004726 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004727 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004728 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004729 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004730 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4731 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004732 GEN_ERROR("binary operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004733 delete yyvsp[-3].TypeVal;
4734 ;
4735 break;}
4736case 289:
4737#line 2803 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4738{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004739 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004740 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4741 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004742 GEN_ERROR("Vector types not supported by icmp instruction");
Chris Lattner0275cff2007-08-06 21:00:46 +00004743 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004744 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004745 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004746 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004747 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4748 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004749 GEN_ERROR("icmp operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004750 delete yyvsp[-3].TypeVal;
4751 ;
4752 break;}
4753case 290:
4754#line 2817 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4755{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004756 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004757 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4758 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004759 GEN_ERROR("Vector types not supported by fcmp instruction");
Chris Lattner0275cff2007-08-06 21:00:46 +00004760 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004761 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004762 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004763 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004764 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4765 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004766 GEN_ERROR("fcmp operator returned null");
Chris Lattner0275cff2007-08-06 21:00:46 +00004767 delete yyvsp[-3].TypeVal;
4768 ;
4769 break;}
4770case 291:
4771#line 2831 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4772{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004773 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004774 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4775 Value* Val = yyvsp[-2].ValueVal;
4776 const Type* DestTy = yyvsp[0].TypeVal->get();
4777 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004778 GEN_ERROR("invalid cast opcode for cast from '" +
4779 Val->getType()->getDescription() + "' to '" +
4780 DestTy->getDescription() + "'");
Chris Lattner0275cff2007-08-06 21:00:46 +00004781 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
4782 delete yyvsp[0].TypeVal;
4783 ;
4784 break;}
4785case 292:
4786#line 2843 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4787{
4788 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004789 GEN_ERROR("select condition must be boolean");
Chris Lattner0275cff2007-08-06 21:00:46 +00004790 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004791 GEN_ERROR("select value types should match");
Chris Lattner0275cff2007-08-06 21:00:46 +00004792 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004793 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004794 ;
4795 break;}
4796case 293:
4797#line 2851 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4798{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004799 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004800 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4801 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4802 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004803 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004804 ;
4805 break;}
4806case 294:
4807#line 2858 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4808{
4809 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004810 GEN_ERROR("Invalid extractelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004811 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004812 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004813 ;
4814 break;}
4815case 295:
4816#line 2864 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4817{
4818 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004819 GEN_ERROR("Invalid insertelement operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004820 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004821 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004822 ;
4823 break;}
4824case 296:
4825#line 2870 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4826{
4827 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004828 GEN_ERROR("Invalid shufflevector operands");
Chris Lattner0275cff2007-08-06 21:00:46 +00004829 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004830 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004831 ;
4832 break;}
4833case 297:
4834#line 2876 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4835{
4836 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004837 if (!Ty->isFirstClassType())
4838 GEN_ERROR("PHI node operands must be of first class type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004839 yyval.InstVal = new PHINode(Ty);
4840 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4841 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4842 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004843 GEN_ERROR("All elements of a PHI node must be of the same type");
Chris Lattner0275cff2007-08-06 21:00:46 +00004844 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4845 yyvsp[0].PHIList->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004846 }
Chris Lattner0275cff2007-08-06 21:00:46 +00004847 delete yyvsp[0].PHIList; // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004848 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004849 ;
4850 break;}
4851case 298:
4852#line 2892 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4853{
Reid Spencer14310612006-12-31 05:40:51 +00004854
4855 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00004856 const PointerType *PFTy = 0;
4857 const FunctionType *Ty = 0;
Chris Lattner0275cff2007-08-06 21:00:46 +00004858 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00004859 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4860 // Pull out the types of all of the arguments...
4861 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00004862 ParamAttrsVector Attrs;
Chris Lattner0275cff2007-08-06 21:00:46 +00004863 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
4864 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004865 Attrs.push_back(PAWI);
4866 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00004867 unsigned index = 1;
Chris Lattner0275cff2007-08-06 21:00:46 +00004868 ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00004869 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004870 const Type *Ty = I->Val->getType();
4871 if (Ty == Type::VoidTy)
4872 GEN_ERROR("Short call syntax cannot be used with varargs");
4873 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00004874 if (I->Attrs != ParamAttr::None) {
4875 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4876 Attrs.push_back(PAWI);
4877 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00004878 }
4879
Christopher Lamb5c104242007-04-22 20:09:11 +00004880 ParamAttrsList *PAL = 0;
4881 if (!Attrs.empty())
4882 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004883
Chris Lattner0275cff2007-08-06 21:00:46 +00004884 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004885 PFTy = PointerType::get(Ty);
4886 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00004887
Chris Lattner0275cff2007-08-06 21:00:46 +00004888 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004889 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00004890
Reid Spencer7780acb2007-04-16 06:56:07 +00004891 // Check for call to invalid intrinsic to avoid crashing later.
4892 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00004893 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00004894 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
4895 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00004896 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
4897 theF->getName() + "'");
4898 }
4899
Reid Spencer14310612006-12-31 05:40:51 +00004900 // Check the arguments
4901 ValueList Args;
Chris Lattner0275cff2007-08-06 21:00:46 +00004902 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00004903 // Make sure no arguments is a good thing!
4904 if (Ty->getNumParams() != 0)
4905 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004906 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004907 } else { // Has arguments?
4908 // Loop through FunctionType's arguments and ensure they are specified
4909 // correctly!
4910 //
4911 FunctionType::param_iterator I = Ty->param_begin();
4912 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner0275cff2007-08-06 21:00:46 +00004913 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004914
Reid Spencer14310612006-12-31 05:40:51 +00004915 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4916 if (ArgI->Val->getType() != *I)
4917 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004918 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004919 Args.push_back(ArgI->Val);
4920 }
4921 if (Ty->isVarArg()) {
4922 if (I == E)
4923 for (; ArgI != ArgE; ++ArgI)
4924 Args.push_back(ArgI->Val); // push the remaining varargs
4925 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004926 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004927 }
Reid Spencer14310612006-12-31 05:40:51 +00004928 // Create the call node
David Greene718fda32007-08-01 03:59:32 +00004929 CallInst *CI = new CallInst(V, Args.begin(), Args.end());
Chris Lattner0275cff2007-08-06 21:00:46 +00004930 CI->setTailCall(yyvsp[-7].BoolVal);
4931 CI->setCallingConv(yyvsp[-6].UIntVal);
4932 yyval.InstVal = CI;
4933 delete yyvsp[-2].ValueRefList;
4934 delete yyvsp[-5].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004935 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004936 ;
4937 break;}
4938case 299:
4939#line 2976 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4940{
4941 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004942 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004943 ;
4944 break;}
4945case 300:
4946#line 2981 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4947{
4948 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004949 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004950 ;
4951 break;}
4952case 301:
4953#line 2985 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4954{
4955 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004956 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004957 ;
4958 break;}
4959case 302:
4960#line 2992 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4961{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004962 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004963 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4964 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4965 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004966 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004967 ;
4968 break;}
4969case 303:
4970#line 2999 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4971{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004972 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004973 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4974 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004975 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004976 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4977 delete yyvsp[-4].TypeVal;
4978 ;
4979 break;}
4980case 304:
4981#line 3007 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4982{
Reid Spencer14310612006-12-31 05:40:51 +00004983 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004984 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4985 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4986 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004987 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004988 ;
4989 break;}
4990case 305:
4991#line 3014 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4992{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004993 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00004994 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4995 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004996 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00004997 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4998 delete yyvsp[-4].TypeVal;
4999 ;
5000 break;}
5001case 306:
5002#line 3022 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
5003{
5004 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005005 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005006 yyvsp[0].ValueVal->getType()->getDescription() + "");
5007 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005008 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005009 ;
5010 break;}
5011case 307:
5012#line 3030 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
5013{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005014 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005015 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5016 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005017 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005018 (*yyvsp[-2].TypeVal)->getDescription());
5019 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005020 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005021 (*yyvsp[-2].TypeVal)->getDescription());
5022 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005023 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005024 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
5025 delete yyvsp[-2].TypeVal;
5026 ;
5027 break;}
5028case 308:
5029#line 3044 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
5030{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00005031 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005032 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5033 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005034 if (!PT)
5035 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattner0275cff2007-08-06 21:00:46 +00005036 (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005037 const Type *ElTy = PT->getElementType();
Chris Lattner0275cff2007-08-06 21:00:46 +00005038 if (ElTy != yyvsp[-4].ValueVal->getType())
5039 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005040 "' into space of type '" + ElTy->getDescription() + "'");
5041
Chris Lattner0275cff2007-08-06 21:00:46 +00005042 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005043 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005044 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
5045 delete yyvsp[-2].TypeVal;
5046 ;
5047 break;}
5048case 309:
5049#line 3061 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
5050{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005051 if (!UpRefs.empty())
Chris Lattner0275cff2007-08-06 21:00:46 +00005052 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
5053 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00005054 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005055
Chris Lattner0275cff2007-08-06 21:00:46 +00005056 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005057 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattner0275cff2007-08-06 21:00:46 +00005058 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
5059 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005060 CHECK_FOR_ERROR
Chris Lattner0275cff2007-08-06 21:00:46 +00005061 yyval.InstVal = new GetElementPtrInst(tmpVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size());
5062 delete yyvsp[-2].TypeVal;
5063 delete yyvsp[0].ValueList;
5064 ;
5065 break;}
5066}
5067 /* the action file gets copied in in place of this dollarsign */
5068#line 543 "/usr/share/bison.simple"
5069
5070 yyvsp -= yylen;
5071 yyssp -= yylen;
5072#ifdef YYLSP_NEEDED
5073 yylsp -= yylen;
5074#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00005075
Chris Lattner0275cff2007-08-06 21:00:46 +00005076#if YYDEBUG != 0
5077 if (yydebug)
5078 {
5079 short *ssp1 = yyss - 1;
5080 fprintf (stderr, "state stack now");
5081 while (ssp1 != yyssp)
5082 fprintf (stderr, " %d", *++ssp1);
5083 fprintf (stderr, "\n");
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005084 }
Chris Lattner0275cff2007-08-06 21:00:46 +00005085#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005086
5087 *++yyvsp = yyval;
5088
Chris Lattner0275cff2007-08-06 21:00:46 +00005089#ifdef YYLSP_NEEDED
5090 yylsp++;
5091 if (yylen == 0)
5092 {
5093 yylsp->first_line = yylloc.first_line;
5094 yylsp->first_column = yylloc.first_column;
5095 yylsp->last_line = (yylsp-1)->last_line;
5096 yylsp->last_column = (yylsp-1)->last_column;
5097 yylsp->text = 0;
5098 }
5099 else
5100 {
5101 yylsp->last_line = (yylsp+yylen-1)->last_line;
5102 yylsp->last_column = (yylsp+yylen-1)->last_column;
5103 }
5104#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005105
Chris Lattner0275cff2007-08-06 21:00:46 +00005106 /* Now "shift" the result of the reduction.
5107 Determine what state that goes to,
5108 based on the state we popped back to
5109 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005110
5111 yyn = yyr1[yyn];
5112
Chris Lattner0275cff2007-08-06 21:00:46 +00005113 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5114 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005115 yystate = yytable[yystate];
5116 else
Chris Lattner0275cff2007-08-06 21:00:46 +00005117 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005118
5119 goto yynewstate;
5120
Chris Lattner0275cff2007-08-06 21:00:46 +00005121yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005122
Chris Lattner0275cff2007-08-06 21:00:46 +00005123 if (! yyerrstatus)
5124 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005125 {
5126 ++yynerrs;
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005127
Chris Lattner0275cff2007-08-06 21:00:46 +00005128#ifdef YYERROR_VERBOSE
5129 yyn = yypact[yystate];
5130
5131 if (yyn > YYFLAG && yyn < YYLAST)
5132 {
5133 int size = 0;
5134 char *msg;
5135 int x, count;
5136
5137 count = 0;
5138 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5139 for (x = (yyn < 0 ? -yyn : 0);
5140 x < (sizeof(yytname) / sizeof(char *)); x++)
5141 if (yycheck[x + yyn] == x)
5142 size += strlen(yytname[x]) + 15, count++;
5143 msg = (char *) malloc(size + 15);
5144 if (msg != 0)
5145 {
5146 strcpy(msg, "parse error");
5147
5148 if (count < 5)
5149 {
5150 count = 0;
5151 for (x = (yyn < 0 ? -yyn : 0);
5152 x < (sizeof(yytname) / sizeof(char *)); x++)
5153 if (yycheck[x + yyn] == x)
5154 {
5155 strcat(msg, count == 0 ? ", expecting `" : " or `");
5156 strcat(msg, yytname[x]);
5157 strcat(msg, "'");
5158 count++;
5159 }
5160 }
5161 yyerror(msg);
5162 free(msg);
5163 }
5164 else
5165 yyerror ("parse error; also virtual memory exceeded");
5166 }
5167 else
5168#endif /* YYERROR_VERBOSE */
5169 yyerror("parse error");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005170 }
5171
Chris Lattner0275cff2007-08-06 21:00:46 +00005172 goto yyerrlab1;
5173yyerrlab1: /* here on error raised explicitly by an action */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005174
5175 if (yyerrstatus == 3)
5176 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005177 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005178
Chris Lattner0275cff2007-08-06 21:00:46 +00005179 /* return failure if at end of input */
5180 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005181 YYABORT;
5182
Chris Lattner0275cff2007-08-06 21:00:46 +00005183#if YYDEBUG != 0
5184 if (yydebug)
5185 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5186#endif
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005187
Chris Lattner0275cff2007-08-06 21:00:46 +00005188 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005189 }
5190
Chris Lattner0275cff2007-08-06 21:00:46 +00005191 /* Else will try to reuse lookahead token
5192 after shifting the error token. */
5193
5194 yyerrstatus = 3; /* Each real token shifted decrements this */
5195
5196 goto yyerrhandle;
5197
5198yyerrdefault: /* current state does not do anything special for the error token. */
5199
5200#if 0
5201 /* This is wrong; only states that explicitly want error tokens
5202 should shift them. */
5203 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5204 if (yyn) goto yydefault;
5205#endif
5206
5207yyerrpop: /* pop the current state because it cannot handle the error token */
5208
5209 if (yyssp == yyss) YYABORT;
5210 yyvsp--;
5211 yystate = *--yyssp;
5212#ifdef YYLSP_NEEDED
5213 yylsp--;
5214#endif
5215
5216#if YYDEBUG != 0
5217 if (yydebug)
5218 {
5219 short *ssp1 = yyss - 1;
5220 fprintf (stderr, "Error: state stack now");
5221 while (ssp1 != yyssp)
5222 fprintf (stderr, " %d", *++ssp1);
5223 fprintf (stderr, "\n");
5224 }
5225#endif
5226
5227yyerrhandle:
5228
5229 yyn = yypact[yystate];
5230 if (yyn == YYFLAG)
5231 goto yyerrdefault;
5232
5233 yyn += YYTERROR;
5234 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5235 goto yyerrdefault;
5236
5237 yyn = yytable[yyn];
5238 if (yyn < 0)
5239 {
5240 if (yyn == YYFLAG)
5241 goto yyerrpop;
5242 yyn = -yyn;
5243 goto yyreduce;
5244 }
5245 else if (yyn == 0)
5246 goto yyerrpop;
5247
Reid Spencer68a24bd2005-08-27 18:50:39 +00005248 if (yyn == YYFINAL)
5249 YYACCEPT;
5250
Chris Lattner0275cff2007-08-06 21:00:46 +00005251#if YYDEBUG != 0
5252 if (yydebug)
5253 fprintf(stderr, "Shifting error token, ");
5254#endif
5255
Reid Spencer68a24bd2005-08-27 18:50:39 +00005256 *++yyvsp = yylval;
Chris Lattner0275cff2007-08-06 21:00:46 +00005257#ifdef YYLSP_NEEDED
5258 *++yylsp = yylloc;
5259#endif
Reid Spencerb8f85052007-07-31 03:50:36 +00005260
Reid Spencer68a24bd2005-08-27 18:50:39 +00005261 yystate = yyn;
5262 goto yynewstate;
5263
Chris Lattner0275cff2007-08-06 21:00:46 +00005264 yyacceptlab:
5265 /* YYACCEPT comes here. */
5266 if (yyfree_stacks)
Chandler Carruth02202192007-08-04 01:56:21 +00005267 {
Chris Lattner0275cff2007-08-06 21:00:46 +00005268 free (yyss);
5269 free (yyvs);
5270#ifdef YYLSP_NEEDED
5271 free (yyls);
5272#endif
Dale Johannesen320fc8a2007-08-03 01:03:46 +00005273 }
Chris Lattner0275cff2007-08-06 21:00:46 +00005274 return 0;
5275
5276 yyabortlab:
5277 /* YYABORT comes here. */
5278 if (yyfree_stacks)
5279 {
5280 free (yyss);
5281 free (yyvs);
5282#ifdef YYLSP_NEEDED
5283 free (yyls);
Chandler Carruth02202192007-08-04 01:56:21 +00005284#endif
Chris Lattner0275cff2007-08-06 21:00:46 +00005285 }
5286 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005287}
Chris Lattner0275cff2007-08-06 21:00:46 +00005288#line 3078 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005289
5290
Reid Spencer14310612006-12-31 05:40:51 +00005291// common code from the two 'RunVMAsmParser' functions
5292static Module* RunParser(Module * M) {
5293
5294 llvmAsmlineno = 1; // Reset the current line number...
5295 CurModule.CurrentModule = M;
5296#if YYDEBUG
5297 yydebug = Debug;
5298#endif
5299
5300 // Check to make sure the parser succeeded
5301 if (yyparse()) {
5302 if (ParserResult)
5303 delete ParserResult;
5304 return 0;
5305 }
5306
Reid Spencer0d60b5a2007-03-30 01:37:39 +00005307 // Emit an error if there are any unresolved types left.
5308 if (!CurModule.LateResolveTypes.empty()) {
5309 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5310 if (DID.Type == ValID::LocalName) {
5311 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5312 } else {
5313 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5314 }
5315 if (ParserResult)
5316 delete ParserResult;
5317 return 0;
5318 }
5319
5320 // Emit an error if there are any unresolved values left.
5321 if (!CurModule.LateResolveValues.empty()) {
5322 Value *V = CurModule.LateResolveValues.back();
5323 std::map<Value*, std::pair<ValID, int> >::iterator I =
5324 CurModule.PlaceHolderInfo.find(V);
5325
5326 if (I != CurModule.PlaceHolderInfo.end()) {
5327 ValID &DID = I->second.first;
5328 if (DID.Type == ValID::LocalName) {
5329 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5330 } else {
5331 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5332 }
5333 if (ParserResult)
5334 delete ParserResult;
5335 return 0;
5336 }
5337 }
5338
Reid Spencer14310612006-12-31 05:40:51 +00005339 // Check to make sure that parsing produced a result
5340 if (!ParserResult)
5341 return 0;
5342
5343 // Reset ParserResult variable while saving its value for the result.
5344 Module *Result = ParserResult;
5345 ParserResult = 0;
5346
5347 return Result;
5348}
5349
Reid Spencer61c83e02006-08-18 08:43:06 +00005350void llvm::GenerateError(const std::string &message, int LineNo) {
5351 if (LineNo == -1) LineNo = llvmAsmlineno;
5352 // TODO: column number in exception
5353 if (TheParseError)
5354 TheParseError->setError(CurFilename, message, LineNo);
5355 TriggerError = 1;
5356}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005357
5358int yyerror(const char *ErrorMsg) {
5359 std::string where
5360 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5361 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00005362 std::string errMsg = where + "error: " + std::string(ErrorMsg);
5363 if (yychar != YYEMPTY && yychar != 0)
5364 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
5365 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005366 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005367 return 0;
5368}