blob: 2396252b224866955fa0a99b647e96485424951b [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattnerce5f24e2007-07-05 17:26:49 +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 Lattnerce5f24e2007-07-05 17:26:49 +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 Lattnerce5f24e2007-07-05 17:26:49 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattnerce5f24e2007-07-05 17:26:49 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattnerce5f24e2007-07-05 17:26:49 +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 LABEL 268
26#define TYPE 269
27#define LOCALVAR 270
28#define GLOBALVAR 271
29#define LABELSTR 272
30#define STRINGCONSTANT 273
31#define ATSTRINGCONSTANT 274
32#define PCTSTRINGCONSTANT 275
33#define ZEROINITIALIZER 276
34#define TRUETOK 277
35#define FALSETOK 278
36#define BEGINTOK 279
37#define ENDTOK 280
38#define DECLARE 281
39#define DEFINE 282
40#define GLOBAL 283
41#define CONSTANT 284
42#define SECTION 285
43#define ALIAS 286
44#define VOLATILE 287
45#define THREAD_LOCAL 288
46#define TO 289
47#define DOTDOTDOT 290
48#define NULL_TOK 291
49#define UNDEF 292
50#define INTERNAL 293
51#define LINKONCE 294
52#define WEAK 295
53#define APPENDING 296
54#define DLLIMPORT 297
55#define DLLEXPORT 298
56#define EXTERN_WEAK 299
57#define OPAQUE 300
58#define EXTERNAL 301
59#define TARGET 302
60#define TRIPLE 303
61#define ALIGN 304
62#define DEPLIBS 305
63#define CALL 306
64#define TAIL 307
65#define ASM_TOK 308
66#define MODULE 309
67#define SIDEEFFECT 310
68#define CC_TOK 311
69#define CCC_TOK 312
70#define FASTCC_TOK 313
71#define COLDCC_TOK 314
72#define X86_STDCALLCC_TOK 315
73#define X86_FASTCALLCC_TOK 316
74#define DATALAYOUT 317
75#define RET 318
76#define BR 319
77#define SWITCH 320
78#define INVOKE 321
79#define UNWIND 322
80#define UNREACHABLE 323
81#define ADD 324
82#define SUB 325
83#define MUL 326
84#define UDIV 327
85#define SDIV 328
86#define FDIV 329
87#define UREM 330
88#define SREM 331
89#define FREM 332
90#define AND 333
91#define OR 334
92#define XOR 335
93#define SHL 336
94#define LSHR 337
95#define ASHR 338
96#define ICMP 339
97#define FCMP 340
98#define EQ 341
99#define NE 342
100#define SLT 343
101#define SGT 344
102#define SLE 345
103#define SGE 346
104#define ULT 347
105#define UGT 348
106#define ULE 349
107#define UGE 350
108#define OEQ 351
109#define ONE 352
110#define OLT 353
111#define OGT 354
112#define OLE 355
113#define OGE 356
114#define ORD 357
115#define UNO 358
116#define UEQ 359
117#define UNE 360
118#define MALLOC 361
119#define ALLOCA 362
120#define FREE 363
121#define LOAD 364
122#define STORE 365
123#define GETELEMENTPTR 366
124#define TRUNC 367
125#define ZEXT 368
126#define SEXT 369
127#define FPTRUNC 370
128#define FPEXT 371
129#define BITCAST 372
130#define UITOFP 373
131#define SITOFP 374
132#define FPTOUI 375
133#define FPTOSI 376
134#define INTTOPTR 377
135#define PTRTOINT 378
136#define PHI_TOK 379
137#define SELECT 380
138#define VAARG 381
139#define EXTRACTELEMENT 382
140#define INSERTELEMENT 383
141#define SHUFFLEVECTOR 384
142#define NORETURN 385
143#define INREG 386
144#define SRET 387
145#define NOUNWIND 388
146#define NOALIAS 389
147#define DEFAULT 390
148#define HIDDEN 391
149#define PROTECTED 392
Reid Spencer68a24bd2005-08-27 18:50:39 +0000150
Chris Lattnerce5f24e2007-07-05 17:26:49 +0000151#line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000152
153#include "ParserInternals.h"
154#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000155#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000156#include "llvm/Instructions.h"
157#include "llvm/Module.h"
Reid Spenceref9b9a72007-02-05 20:47:22 +0000158#include "llvm/ValueSymbolTable.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000159#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000160#include "llvm/Support/CommandLine.h"
Chris Lattnerf7469af2007-01-31 04:44:08 +0000161#include "llvm/ADT/SmallVector.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000162#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000163#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000164#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000165#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000166#include <list>
Chris Lattner8adde282007-02-11 21:40:10 +0000167#include <map>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000168#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000169#ifndef NDEBUG
170#define YYDEBUG 1
171#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000172
Reid Spencere4f47592006-08-18 17:32:55 +0000173// The following is a gross hack. In order to rid the libAsmParser library of
174// exceptions, we have to have a way of getting the yyparse function to go into
175// an error situation. So, whenever we want an error to occur, the GenerateError
176// function (see bottom of file) sets TriggerError. Then, at the end of each
177// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
178// (a goto) to put YACC in error state. Furthermore, several calls to
179// GenerateError are made from inside productions and they must simulate the
180// previous exception behavior by exiting the production immediately. We have
181// replaced these with the GEN_ERROR macro which calls GeneratError and then
182// immediately invokes YYERROR. This would be so much cleaner if it was a
183// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000184static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000185#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000186#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
187
Reid Spencer68a24bd2005-08-27 18:50:39 +0000188int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
189int yylex(); // declaration" of xxx warnings.
190int yyparse();
191
192namespace llvm {
193 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000194#if YYDEBUG
195static cl::opt<bool>
196Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
197 cl::Hidden, cl::init(false));
198#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000199}
200using namespace llvm;
201
202static Module *ParserResult;
203
204// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
205// relating to upreferences in the input stream.
206//
207//#define DEBUG_UPREFS 1
208#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000209#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000210#else
211#define UR_OUT(X)
212#endif
213
214#define YYERROR_VERBOSE 1
215
Chris Lattnerb475c422005-11-12 18:22:38 +0000216static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000217
218
219// This contains info used when building the body of a function. It is
220// destroyed when the function is completed.
221//
222typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000223
Reid Spencer68a24bd2005-08-27 18:50:39 +0000224static void
Reid Spencer93c40032007-03-19 18:40:50 +0000225ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000226
227static struct PerModuleInfo {
228 Module *CurrentModule;
Reid Spencer93c40032007-03-19 18:40:50 +0000229 ValueList Values; // Module level numbered definitions
230 ValueList LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000231 std::vector<PATypeHolder> Types;
232 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000233
234 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000235 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000236 /// that we can resolve them later and print error messages as appropriate.
237 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
238
239 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
240 // references to global values. Global values may be referenced before they
241 // are defined, and if so, the temporary object that they represent is held
242 // here. This is used for forward references of GlobalValues.
243 //
244 typedef std::map<std::pair<const PointerType *,
245 ValID>, GlobalValue*> GlobalRefsType;
246 GlobalRefsType GlobalRefs;
247
248 void ModuleDone() {
249 // If we could not resolve some functions at function compilation time
250 // (calls to functions before they are defined), resolve them now... Types
251 // are resolved when the constant pool has been completely parsed.
252 //
253 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000254 if (TriggerError)
255 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000256
257 // Check to make sure that all global value forward references have been
258 // resolved!
259 //
260 if (!GlobalRefs.empty()) {
261 std::string UndefinedReferences = "Unresolved global references exist:\n";
262
263 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
264 I != E; ++I) {
265 UndefinedReferences += " " + I->first.first->getDescription() + " " +
266 I->first.second.getName() + "\n";
267 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000268 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000269 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000270 }
271
272 Values.clear(); // Clear out function local definitions
273 Types.clear();
274 CurrentModule = 0;
275 }
276
Reid Spencer68a24bd2005-08-27 18:50:39 +0000277 // GetForwardRefForGlobal - Check to see if there is a forward reference
278 // for this global. If so, remove it from the GlobalRefs map and return it.
279 // If not, just return null.
280 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
281 // Check to see if there is a forward reference to this global variable...
282 // if there is, eliminate it and patch the reference to use the new def'n.
283 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
284 GlobalValue *Ret = 0;
285 if (I != GlobalRefs.end()) {
286 Ret = I->second;
287 GlobalRefs.erase(I);
288 }
289 return Ret;
290 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000291
292 bool TypeIsUnresolved(PATypeHolder* PATy) {
293 // If it isn't abstract, its resolved
294 const Type* Ty = PATy->get();
295 if (!Ty->isAbstract())
296 return false;
297 // Traverse the type looking for abstract types. If it isn't abstract then
298 // we don't need to traverse that leg of the type.
299 std::vector<const Type*> WorkList, SeenList;
300 WorkList.push_back(Ty);
301 while (!WorkList.empty()) {
302 const Type* Ty = WorkList.back();
303 SeenList.push_back(Ty);
304 WorkList.pop_back();
305 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
306 // Check to see if this is an unresolved type
307 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
308 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
309 for ( ; I != E; ++I) {
310 if (I->second.get() == OpTy)
311 return true;
312 }
313 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
314 const Type* TheTy = SeqTy->getElementType();
315 if (TheTy->isAbstract() && TheTy != Ty) {
316 std::vector<const Type*>::iterator I = SeenList.begin(),
317 E = SeenList.end();
318 for ( ; I != E; ++I)
319 if (*I == TheTy)
320 break;
321 if (I == E)
322 WorkList.push_back(TheTy);
323 }
324 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
325 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
326 const Type* TheTy = StrTy->getElementType(i);
327 if (TheTy->isAbstract() && TheTy != Ty) {
328 std::vector<const Type*>::iterator I = SeenList.begin(),
329 E = SeenList.end();
330 for ( ; I != E; ++I)
331 if (*I == TheTy)
332 break;
333 if (I == E)
334 WorkList.push_back(TheTy);
335 }
336 }
337 }
338 }
339 return false;
340 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000341} CurModule;
342
343static struct PerFunctionInfo {
344 Function *CurrentFunction; // Pointer to current function being created
345
Reid Spencer93c40032007-03-19 18:40:50 +0000346 ValueList Values; // Keep track of #'d definitions
347 unsigned NextValNum;
348 ValueList LateResolveValues;
Reid Spenceref9b9a72007-02-05 20:47:22 +0000349 bool isDeclare; // Is this function a forward declararation?
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000350 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000351 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000352
353 /// BBForwardRefs - When we see forward references to basic blocks, keep
354 /// track of them here.
Reid Spencer93c40032007-03-19 18:40:50 +0000355 std::map<ValID, BasicBlock*> BBForwardRefs;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000356
357 inline PerFunctionInfo() {
358 CurrentFunction = 0;
359 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000360 Linkage = GlobalValue::ExternalLinkage;
361 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000362 }
363
364 inline void FunctionStart(Function *M) {
365 CurrentFunction = M;
Reid Spencer93c40032007-03-19 18:40:50 +0000366 NextValNum = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000367 }
368
369 void FunctionDone() {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000370 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000371 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000372 GenerateError("Undefined reference to label " +
Reid Spencer93c40032007-03-19 18:40:50 +0000373 BBForwardRefs.begin()->second->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000374 return;
375 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000376
377 // Resolve all forward references now.
378 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
379
380 Values.clear(); // Clear out function local definitions
Reid Spencer93c40032007-03-19 18:40:50 +0000381 BBForwardRefs.clear();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000382 CurrentFunction = 0;
383 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000384 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000385 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000386 }
387} CurFun; // Info for the current function...
388
389static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
390
391
392//===----------------------------------------------------------------------===//
393// Code to handle definitions of all the types
394//===----------------------------------------------------------------------===//
395
Reid Spencer93c40032007-03-19 18:40:50 +0000396static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
397 // Things that have names or are void typed don't get slot numbers
398 if (V->hasName() || (V->getType() == Type::VoidTy))
399 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000400
Reid Spencer93c40032007-03-19 18:40:50 +0000401 // In the case of function values, we have to allow for the forward reference
402 // of basic blocks, which are included in the numbering. Consequently, we keep
403 // track of the next insertion location with NextValNum. When a BB gets
404 // inserted, it could change the size of the CurFun.Values vector.
405 if (&ValueTab == &CurFun.Values) {
406 if (ValueTab.size() <= CurFun.NextValNum)
407 ValueTab.resize(CurFun.NextValNum+1);
408 ValueTab[CurFun.NextValNum++] = V;
409 return;
410 }
411 // For all other lists, its okay to just tack it on the back of the vector.
412 ValueTab.push_back(V);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000413}
414
415static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
416 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000417 case ValID::LocalID: // Is it a numbered definition?
Reid Spencer68a24bd2005-08-27 18:50:39 +0000418 // Module constants occupy the lowest numbered slots...
Reid Spencer41dff5e2007-01-26 08:05:27 +0000419 if (D.Num < CurModule.Types.size())
420 return CurModule.Types[D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000421 break;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000422 case ValID::LocalName: // Is it a named definition?
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000423 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.getName())) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000424 D.destroy(); // Free old strdup'd memory...
425 return N;
426 }
427 break;
428 default:
Reid Spencerb5334b02007-02-05 10:18:06 +0000429 GenerateError("Internal parser error: Invalid symbol type reference");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000430 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000431 }
432
433 // If we reached here, we referenced either a symbol that we don't know about
434 // or an id number that hasn't been read yet. We may be referencing something
435 // forward, so just create an entry to be resolved later and get to it...
436 //
437 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
438
439
440 if (inFunctionScope()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000441 if (D.Type == ValID::LocalName) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000442 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000443 return 0;
444 } else {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000445 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000446 return 0;
447 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000448 }
449
Reid Spencer861d9d62006-11-28 07:29:44 +0000450 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000451 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000452 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000453
Reid Spencer861d9d62006-11-28 07:29:44 +0000454 Type *Typ = OpaqueType::get();
455 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
456 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000457 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000458
Reid Spencer93c40032007-03-19 18:40:50 +0000459// getExistingVal - Look up the value specified by the provided type and
Reid Spencer68a24bd2005-08-27 18:50:39 +0000460// the provided ValID. If the value exists and has already been defined, return
461// it. Otherwise return null.
462//
Reid Spencer93c40032007-03-19 18:40:50 +0000463static Value *getExistingVal(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000464 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000465 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000466 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000467 return 0;
468 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000469
470 switch (D.Type) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000471 case ValID::LocalID: { // Is it a numbered definition?
Reid Spencer41dff5e2007-01-26 08:05:27 +0000472 // Check that the number is within bounds.
Reid Spencer93c40032007-03-19 18:40:50 +0000473 if (D.Num >= CurFun.Values.size())
474 return 0;
475 Value *Result = CurFun.Values[D.Num];
476 if (Ty != Result->getType()) {
477 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
478 Result->getType()->getDescription() + "' does not match "
479 "expected type, '" + Ty->getDescription() + "'");
480 return 0;
481 }
482 return Result;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000483 }
484 case ValID::GlobalID: { // Is it a numbered definition?
Reid Spencer93c40032007-03-19 18:40:50 +0000485 if (D.Num >= CurModule.Values.size())
Reid Spenceref9b9a72007-02-05 20:47:22 +0000486 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000487 Value *Result = CurModule.Values[D.Num];
488 if (Ty != Result->getType()) {
489 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
490 Result->getType()->getDescription() + "' does not match "
491 "expected type, '" + Ty->getDescription() + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000492 return 0;
Reid Spencer93c40032007-03-19 18:40:50 +0000493 }
494 return Result;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000495 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000496
497 case ValID::LocalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000498 if (!inFunctionScope())
499 return 0;
500 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000501 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000502 if (N == 0)
503 return 0;
504 if (N->getType() != Ty)
505 return 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +0000506
507 D.destroy(); // Free old strdup'd memory...
508 return N;
509 }
510 case ValID::GlobalName: { // Is it a named definition?
Reid Spenceref9b9a72007-02-05 20:47:22 +0000511 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000512 Value *N = SymTab.lookup(D.getName());
Reid Spenceref9b9a72007-02-05 20:47:22 +0000513 if (N == 0)
514 return 0;
515 if (N->getType() != Ty)
516 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000517
518 D.destroy(); // Free old strdup'd memory...
519 return N;
520 }
521
522 // Check to make sure that "Ty" is an integral type, and that our
523 // value will fit into the specified type...
524 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000525 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000526 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000527 itostr(D.ConstPool64) + "' is invalid for type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000528 Ty->getDescription() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000529 return 0;
530 }
Reid Spencer49d273e2007-03-19 20:40:51 +0000531 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000532
533 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000534 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
535 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000536 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerb5334b02007-02-05 10:18:06 +0000537 "' is invalid or out of range");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000538 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000539 } else { // This is really a signed reference. Transmogrify.
Reid Spencer49d273e2007-03-19 20:40:51 +0000540 return ConstantInt::get(Ty, D.ConstPool64, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000541 }
542 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000543 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000544 }
545
546 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000547 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000548 GenerateError("FP constant invalid for type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000549 return 0;
550 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000551 return ConstantFP::get(Ty, D.ConstPoolFP);
552
553 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000554 if (!isa<PointerType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000555 GenerateError("Cannot create a a non pointer null");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000556 return 0;
557 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558 return ConstantPointerNull::get(cast<PointerType>(Ty));
559
560 case ValID::ConstUndefVal: // Is it an undef value?
561 return UndefValue::get(Ty);
562
Chris Lattner7aa61892005-12-21 17:53:23 +0000563 case ValID::ConstZeroVal: // Is it a zero value?
564 return Constant::getNullValue(Ty);
565
Reid Spencer68a24bd2005-08-27 18:50:39 +0000566 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000567 if (D.ConstantValue->getType() != Ty) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000568 GenerateError("Constant expression type different from required type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000569 return 0;
570 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000571 return D.ConstantValue;
572
Chris Lattner0e9c3762006-01-25 22:27:16 +0000573 case ValID::InlineAsmVal: { // Inline asm expression
574 const PointerType *PTy = dyn_cast<PointerType>(Ty);
575 const FunctionType *FTy =
576 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000577 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000578 GenerateError("Invalid type for asm constraint string");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000579 return 0;
580 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000581 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
582 D.IAD->HasSideEffects);
583 D.destroy(); // Free InlineAsmDescriptor.
584 return IA;
585 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000586 default:
Reid Spencera9720f52007-02-05 17:04:00 +0000587 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000588 return 0;
589 } // End of switch
590
Reid Spencera9720f52007-02-05 17:04:00 +0000591 assert(0 && "Unhandled case!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000592 return 0;
593}
594
Reid Spencer93c40032007-03-19 18:40:50 +0000595// getVal - This function is identical to getExistingVal, except that if a
Reid Spencer68a24bd2005-08-27 18:50:39 +0000596// value is not already defined, it "improvises" by creating a placeholder var
597// that looks and acts just like the requested variable. When the value is
598// defined later, all uses of the placeholder variable are replaced with the
599// real thing.
600//
601static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000602 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000603 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000604 return 0;
605 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606
607 // See if the value has already been defined.
Reid Spencer93c40032007-03-19 18:40:50 +0000608 Value *V = getExistingVal(Ty, ID);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000609 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000610 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611
Reid Spencer5b7e7532006-09-28 19:28:24 +0000612 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000613 GenerateError("Invalid use of a composite type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000614 return 0;
615 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000616
617 // If we reached here, we referenced either a symbol that we don't know about
618 // or an id number that hasn't been read yet. We may be referencing something
619 // forward, so just create an entry to be resolved later and get to it...
620 //
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000621 switch (ID.Type) {
622 case ValID::GlobalName:
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000623 case ValID::GlobalID: {
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000624 const PointerType *PTy = dyn_cast<PointerType>(Ty);
625 if (!PTy) {
626 GenerateError("Invalid type for reference to global" );
627 return 0;
628 }
629 const Type* ElTy = PTy->getElementType();
630 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
631 V = new Function(FTy, GlobalValue::ExternalLinkage);
632 else
633 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
634 break;
Reid Spencer9c9b63a2007-04-28 16:07:31 +0000635 }
Anton Korobeynikov38e09802007-04-28 13:48:45 +0000636 default:
637 V = new Argument(Ty);
638 }
639
Reid Spencer68a24bd2005-08-27 18:50:39 +0000640 // Remember where this forward reference came from. FIXME, shouldn't we try
641 // to recycle these things??
642 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
643 llvmAsmlineno)));
644
645 if (inFunctionScope())
646 InsertValue(V, CurFun.LateResolveValues);
647 else
648 InsertValue(V, CurModule.LateResolveValues);
649 return V;
650}
651
Reid Spencer93c40032007-03-19 18:40:50 +0000652/// defineBBVal - This is a definition of a new basic block with the specified
653/// identifier which must be the same as CurFun.NextValNum, if its numeric.
654static BasicBlock *defineBBVal(const ValID &ID) {
Reid Spencera9720f52007-02-05 17:04:00 +0000655 assert(inFunctionScope() && "Can't get basic block at global scope!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000656
Reid Spencer68a24bd2005-08-27 18:50:39 +0000657 BasicBlock *BB = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000658
Reid Spencer93c40032007-03-19 18:40:50 +0000659 // First, see if this was forward referenced
Reid Spencer68a24bd2005-08-27 18:50:39 +0000660
Reid Spencer93c40032007-03-19 18:40:50 +0000661 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
662 if (BBI != CurFun.BBForwardRefs.end()) {
663 BB = BBI->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000664 // The forward declaration could have been inserted anywhere in the
665 // function: insert it into the correct place now.
666 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
667 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
Reid Spencer93c40032007-03-19 18:40:50 +0000668
Reid Spencer66728ef2007-03-20 01:13:36 +0000669 // We're about to erase the entry, save the key so we can clean it up.
670 ValID Tmp = BBI->first;
671
Reid Spencer93c40032007-03-19 18:40:50 +0000672 // Erase the forward ref from the map as its no longer "forward"
673 CurFun.BBForwardRefs.erase(ID);
674
Reid Spencer66728ef2007-03-20 01:13:36 +0000675 // The key has been removed from the map but so we don't want to leave
676 // strdup'd memory around so destroy it too.
677 Tmp.destroy();
678
Reid Spencer93c40032007-03-19 18:40:50 +0000679 // If its a numbered definition, bump the number and set the BB value.
680 if (ID.Type == ValID::LocalID) {
681 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
682 InsertValue(BB);
683 }
684
685 ID.destroy();
686 return BB;
687 }
688
689 // We haven't seen this BB before and its first mention is a definition.
690 // Just create it and return it.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000691 std::string Name (ID.Type == ValID::LocalName ? ID.getName() : "");
Reid Spencer93c40032007-03-19 18:40:50 +0000692 BB = new BasicBlock(Name, CurFun.CurrentFunction);
693 if (ID.Type == ValID::LocalID) {
694 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
695 InsertValue(BB);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000696 }
Reid Spencer93c40032007-03-19 18:40:50 +0000697
698 ID.destroy(); // Free strdup'd memory
699 return BB;
700}
701
702/// getBBVal - get an existing BB value or create a forward reference for it.
703///
704static BasicBlock *getBBVal(const ValID &ID) {
705 assert(inFunctionScope() && "Can't get basic block at global scope!");
706
707 BasicBlock *BB = 0;
708
709 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
710 if (BBI != CurFun.BBForwardRefs.end()) {
711 BB = BBI->second;
712 } if (ID.Type == ValID::LocalName) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000713 std::string Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000714 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
715 if (N)
716 if (N->getType()->getTypeID() == Type::LabelTyID)
717 BB = cast<BasicBlock>(N);
718 else
719 GenerateError("Reference to label '" + Name + "' is actually of type '"+
720 N->getType()->getDescription() + "'");
721 } else if (ID.Type == ValID::LocalID) {
722 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
723 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
724 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
725 else
726 GenerateError("Reference to label '%" + utostr(ID.Num) +
727 "' is actually of type '"+
728 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
729 }
730 } else {
731 GenerateError("Illegal label reference " + ID.getName());
732 return 0;
733 }
734
735 // If its already been defined, return it now.
736 if (BB) {
737 ID.destroy(); // Free strdup'd memory.
738 return BB;
739 }
740
741 // Otherwise, this block has not been seen before, create it.
742 std::string Name;
743 if (ID.Type == ValID::LocalName)
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000744 Name = ID.getName();
Reid Spencer93c40032007-03-19 18:40:50 +0000745 BB = new BasicBlock(Name, CurFun.CurrentFunction);
746
747 // Insert it in the forward refs map.
748 CurFun.BBForwardRefs[ID] = BB;
749
Reid Spencer68a24bd2005-08-27 18:50:39 +0000750 return BB;
751}
752
753
754//===----------------------------------------------------------------------===//
755// Code to handle forward references in instructions
756//===----------------------------------------------------------------------===//
757//
758// This code handles the late binding needed with statements that reference
759// values not defined yet... for example, a forward branch, or the PHI node for
760// a loop body.
761//
762// This keeps a table (CurFun.LateResolveValues) of all such forward references
763// and back patchs after we are done.
764//
765
766// ResolveDefinitions - If we could not resolve some defs at parsing
767// time (forward branches, phi functions for loops, etc...) resolve the
768// defs now...
769//
770static void
Reid Spencer93c40032007-03-19 18:40:50 +0000771ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000772 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
Reid Spencer93c40032007-03-19 18:40:50 +0000773 while (!LateResolvers.empty()) {
774 Value *V = LateResolvers.back();
775 LateResolvers.pop_back();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776
Reid Spencer93c40032007-03-19 18:40:50 +0000777 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
778 CurModule.PlaceHolderInfo.find(V);
779 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000780
Reid Spencer93c40032007-03-19 18:40:50 +0000781 ValID &DID = PHI->second.first;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000782
Reid Spencer93c40032007-03-19 18:40:50 +0000783 Value *TheRealValue = getExistingVal(V->getType(), DID);
784 if (TriggerError)
785 return;
786 if (TheRealValue) {
787 V->replaceAllUsesWith(TheRealValue);
788 delete V;
789 CurModule.PlaceHolderInfo.erase(PHI);
790 } else if (FutureLateResolvers) {
791 // Functions have their unresolved items forwarded to the module late
792 // resolver table
793 InsertValue(V, *FutureLateResolvers);
794 } else {
795 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
796 GenerateError("Reference to an invalid definition: '" +DID.getName()+
797 "' of type '" + V->getType()->getDescription() + "'",
798 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000799 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000800 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000801 GenerateError("Reference to an invalid definition: #" +
802 itostr(DID.Num) + " of type '" +
803 V->getType()->getDescription() + "'",
804 PHI->second.second);
805 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000806 }
807 }
808 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000809 LateResolvers.clear();
810}
811
812// ResolveTypeTo - A brand new type was just declared. This means that (if
813// name is not null) things referencing Name can be resolved. Otherwise, things
814// refering to the number can be resolved. Do this now.
815//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000816static void ResolveTypeTo(std::string *Name, const Type *ToTy) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000817 ValID D;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000818 if (Name)
819 D = ValID::createLocalName(*Name);
820 else
821 D = ValID::createLocalID(CurModule.Types.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000822
Reid Spencer861d9d62006-11-28 07:29:44 +0000823 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000824 CurModule.LateResolveTypes.find(D);
825 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000826 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000827 CurModule.LateResolveTypes.erase(I);
828 }
829}
830
831// setValueName - Set the specified value to the name given. The name may be
832// null potentially, in which case this is a noop. The string passed in is
833// assumed to be a malloc'd string buffer, and is free'd by this function.
834//
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000835static void setValueName(Value *V, std::string *NameStr) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000836 if (!NameStr) return;
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000837 std::string Name(*NameStr); // Copy string
838 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000839
Reid Spencer41dff5e2007-01-26 08:05:27 +0000840 if (V->getType() == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000841 GenerateError("Can't assign name '" + Name+"' to value with void type");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000842 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000843 }
Reid Spencer41dff5e2007-01-26 08:05:27 +0000844
Reid Spencera9720f52007-02-05 17:04:00 +0000845 assert(inFunctionScope() && "Must be in function scope!");
Reid Spenceref9b9a72007-02-05 20:47:22 +0000846 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
847 if (ST.lookup(Name)) {
Reid Spencer41dff5e2007-01-26 08:05:27 +0000848 GenerateError("Redefinition of value '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000849 V->getType()->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +0000850 return;
851 }
852
853 // Set the name.
854 V->setName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000855}
856
857/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
858/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000859static GlobalVariable *
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000860ParseGlobalVariable(std::string *NameStr,
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000861 GlobalValue::LinkageTypes Linkage,
862 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000863 bool isConstantGlobal, const Type *Ty,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000864 Constant *Initializer, bool IsThreadLocal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000865 if (isa<FunctionType>(Ty)) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000866 GenerateError("Cannot declare global vars of function type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000867 return 0;
868 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000869
870 const PointerType *PTy = PointerType::get(Ty);
871
872 std::string Name;
873 if (NameStr) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000874 Name = *NameStr; // Copy string
875 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000876 }
877
878 // See if this global value was forward referenced. If so, recycle the
879 // object.
880 ValID ID;
881 if (!Name.empty()) {
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000882 ID = ValID::createGlobalName(Name);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000883 } else {
Reid Spencer93c40032007-03-19 18:40:50 +0000884 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000885 }
886
887 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
888 // Move the global to the end of the list, from whereever it was
889 // previously inserted.
890 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
891 CurModule.CurrentModule->getGlobalList().remove(GV);
892 CurModule.CurrentModule->getGlobalList().push_back(GV);
893 GV->setInitializer(Initializer);
894 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000895 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000896 GV->setConstant(isConstantGlobal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000897 GV->setThreadLocal(IsThreadLocal);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000898 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000899 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000900 }
901
Reid Spenceref9b9a72007-02-05 20:47:22 +0000902 // If this global has a name
Reid Spencer68a24bd2005-08-27 18:50:39 +0000903 if (!Name.empty()) {
Reid Spenceref9b9a72007-02-05 20:47:22 +0000904 // if the global we're parsing has an initializer (is a definition) and
905 // has external linkage.
906 if (Initializer && Linkage != GlobalValue::InternalLinkage)
907 // If there is already a global with external linkage with this name
908 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
909 // If we allow this GVar to get created, it will be renamed in the
910 // symbol table because it conflicts with an existing GVar. We can't
911 // allow redefinition of GVars whose linking indicates that their name
912 // must stay the same. Issue the error.
913 GenerateError("Redefinition of global variable named '" + Name +
914 "' of type '" + Ty->getDescription() + "'");
915 return 0;
916 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000917 }
918
919 // Otherwise there is no existing GV to use, create one now.
920 GlobalVariable *GV =
921 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +0000922 CurModule.CurrentModule, IsThreadLocal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000923 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000924 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000925 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000926}
927
928// setTypeName - Set the specified type to the name given. The name may be
929// null potentially, in which case this is a noop. The string passed in is
930// assumed to be a malloc'd string buffer, and is freed by this function.
931//
932// This function returns true if the type has already been defined, but is
933// allowed to be redefined in the specified context. If the name is a new name
934// for the type plane, it is inserted and false is returned.
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000935static bool setTypeName(const Type *T, std::string *NameStr) {
Reid Spencera9720f52007-02-05 17:04:00 +0000936 assert(!inFunctionScope() && "Can't give types function-local names!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000937 if (NameStr == 0) return false;
938
Reid Spencer0a8a16b2007-05-22 18:52:55 +0000939 std::string Name(*NameStr); // Copy string
940 delete NameStr; // Free old string
Reid Spencer68a24bd2005-08-27 18:50:39 +0000941
942 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000943 if (T == Type::VoidTy) {
Reid Spencerb5334b02007-02-05 10:18:06 +0000944 GenerateError("Can't assign name '" + Name + "' to the void type");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000945 return false;
946 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000947
948 // Set the type name, checking for conflicts as we do so.
949 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
950
951 if (AlreadyExists) { // Inserting a name that is already defined???
952 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
Reid Spencera9720f52007-02-05 17:04:00 +0000953 assert(Existing && "Conflict but no matching type?!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000954
955 // There is only one case where this is allowed: when we are refining an
956 // opaque type. In this case, Existing will be an opaque type.
957 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
958 // We ARE replacing an opaque type!
959 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
960 return true;
961 }
962
963 // Otherwise, this is an attempt to redefine a type. That's okay if
964 // the redefinition is identical to the original. This will be so if
965 // Existing and T point to the same Type object. In this one case we
966 // allow the equivalent redefinition.
967 if (Existing == T) return true; // Yes, it's equal.
968
969 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +0000970 GenerateError("Redefinition of type named '" + Name + "' of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +0000971 T->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000972 }
973
974 return false;
975}
976
977//===----------------------------------------------------------------------===//
978// Code for handling upreferences in type names...
979//
980
981// TypeContains - Returns true if Ty directly contains E in it.
982//
983static bool TypeContains(const Type *Ty, const Type *E) {
984 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
985 E) != Ty->subtype_end();
986}
987
988namespace {
989 struct UpRefRecord {
990 // NestingLevel - The number of nesting levels that need to be popped before
991 // this type is resolved.
992 unsigned NestingLevel;
993
994 // LastContainedTy - This is the type at the current binding level for the
995 // type. Every time we reduce the nesting level, this gets updated.
996 const Type *LastContainedTy;
997
998 // UpRefTy - This is the actual opaque type that the upreference is
999 // represented with.
1000 OpaqueType *UpRefTy;
1001
1002 UpRefRecord(unsigned NL, OpaqueType *URTy)
1003 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1004 };
1005}
1006
1007// UpRefs - A list of the outstanding upreferences that need to be resolved.
1008static std::vector<UpRefRecord> UpRefs;
1009
1010/// HandleUpRefs - Every time we finish a new layer of types, this function is
1011/// called. It loops through the UpRefs vector, which is a list of the
1012/// currently active types. For each type, if the up reference is contained in
1013/// the newly completed type, we decrement the level count. When the level
1014/// count reaches zero, the upreferenced type is the type that is passed in:
1015/// thus we can complete the cycle.
1016///
1017static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001018 // If Ty isn't abstract, or if there are no up-references in it, then there is
1019 // nothing to resolve here.
1020 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1021
Reid Spencer68a24bd2005-08-27 18:50:39 +00001022 PATypeHolder Ty(ty);
1023 UR_OUT("Type '" << Ty->getDescription() <<
1024 "' newly formed. Resolving upreferences.\n" <<
1025 UpRefs.size() << " upreferences active!\n");
1026
1027 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1028 // to zero), we resolve them all together before we resolve them to Ty. At
1029 // the end of the loop, if there is anything to resolve to Ty, it will be in
1030 // this variable.
1031 OpaqueType *TypeToResolve = 0;
1032
1033 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1034 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1035 << UpRefs[i].second->getDescription() << ") = "
1036 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1037 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1038 // Decrement level of upreference
1039 unsigned Level = --UpRefs[i].NestingLevel;
1040 UpRefs[i].LastContainedTy = Ty;
1041 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1042 if (Level == 0) { // Upreference should be resolved!
1043 if (!TypeToResolve) {
1044 TypeToResolve = UpRefs[i].UpRefTy;
1045 } else {
1046 UR_OUT(" * Resolving upreference for "
1047 << UpRefs[i].second->getDescription() << "\n";
1048 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1049 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1050 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1051 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1052 }
1053 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1054 --i; // Do not skip the next element...
1055 }
1056 }
1057 }
1058
1059 if (TypeToResolve) {
1060 UR_OUT(" * Resolving upreference for "
1061 << UpRefs[i].second->getDescription() << "\n";
1062 std::string OldName = TypeToResolve->getDescription());
1063 TypeToResolve->refineAbstractTypeTo(Ty);
1064 }
1065
1066 return Ty;
1067}
1068
Reid Spencer68a24bd2005-08-27 18:50:39 +00001069//===----------------------------------------------------------------------===//
1070// RunVMAsmParser - Define an interface to this parser
1071//===----------------------------------------------------------------------===//
1072//
Reid Spencer14310612006-12-31 05:40:51 +00001073static Module* RunParser(Module * M);
1074
Reid Spencer68a24bd2005-08-27 18:50:39 +00001075Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1076 set_scan_file(F);
1077
1078 CurFilename = Filename;
1079 return RunParser(new Module(CurFilename));
1080}
1081
1082Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1083 set_scan_string(AsmString);
1084
1085 CurFilename = "from_memory";
1086 if (M == NULL) {
1087 return RunParser(new Module (CurFilename));
1088 } else {
1089 return RunParser(M);
1090 }
1091}
1092
1093
Chris Lattnerce5f24e2007-07-05 17:26:49 +00001094#line 957 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1095typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001096 llvm::Module *ModuleVal;
1097 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001098 llvm::BasicBlock *BasicBlockVal;
1099 llvm::TerminatorInst *TermInstVal;
1100 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001101 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001102
Reid Spencera132e042006-12-03 05:46:11 +00001103 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001104 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001105 llvm::PATypeHolder *TypeVal;
1106 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001107 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001108 llvm::ArgListType *ArgList;
1109 llvm::TypeWithAttrs TypeWithAttrs;
1110 llvm::TypeWithAttrsList *TypeWithAttrsList;
1111 llvm::ValueRefList *ValueRefList;
1112
Reid Spencer68a24bd2005-08-27 18:50:39 +00001113 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001114 std::list<std::pair<llvm::Value*,
1115 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001116 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001117 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001118
1119 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001120 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer7b5d4662007-04-09 06:16:21 +00001121 uint16_t ParamAttrs;
Reid Spencer38c91a92007-02-28 02:24:54 +00001122 llvm::APInt *APIntVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001123 int64_t SInt64Val;
1124 uint64_t UInt64Val;
1125 int SIntVal;
1126 unsigned UIntVal;
1127 double FPVal;
1128 bool BoolVal;
1129
Reid Spencer0a8a16b2007-05-22 18:52:55 +00001130 std::string *StrVal; // This memory must be deleted
1131 llvm::ValID ValIDVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001132
Reid Spencera132e042006-12-03 05:46:11 +00001133 llvm::Instruction::BinaryOps BinaryOpVal;
1134 llvm::Instruction::TermOps TermOpVal;
1135 llvm::Instruction::MemoryOps MemOpVal;
1136 llvm::Instruction::CastOps CastOpVal;
1137 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencera132e042006-12-03 05:46:11 +00001138 llvm::ICmpInst::Predicate IPredicate;
1139 llvm::FCmpInst::Predicate FPredicate;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00001140} YYSTYPE;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00001141#include <stdio.h>
1142
1143#ifndef __cplusplus
1144#ifndef __STDC__
1145#define const
1146#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001147#endif
1148
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001149
Reid Spencer68a24bd2005-08-27 18:50:39 +00001150
Chris Lattnerce5f24e2007-07-05 17:26:49 +00001151#define YYFINAL 583
1152#define YYFLAG -32768
1153#define YYNTBASE 153
Reid Spencer68a24bd2005-08-27 18:50:39 +00001154
Chris Lattnerce5f24e2007-07-05 17:26:49 +00001155#define YYTRANSLATE(x) ((unsigned)(x) <= 392 ? yytranslate[x] : 234)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001156
Chris Lattnerce5f24e2007-07-05 17:26:49 +00001157static const short yytranslate[] = { 0,
1158 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1159 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1160 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1161 2, 2, 2, 2, 2, 2, 2, 2, 2, 143,
1162 144, 141, 2, 140, 2, 2, 2, 2, 2, 2,
1163 2, 2, 2, 2, 2, 2, 2, 2, 2, 148,
1164 139, 149, 2, 2, 2, 2, 2, 2, 2, 2,
1165 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1166 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1167 145, 142, 147, 2, 2, 2, 2, 2, 152, 2,
1168 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1169 2, 2, 2, 2, 2, 2, 2, 2, 2, 146,
1170 2, 2, 150, 2, 151, 2, 2, 2, 2, 2,
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, 2,
1175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1176 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1177 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1183 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1184 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1185 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1186 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1187 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1188 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1189 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1190 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1191 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1192 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1193 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1194 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1195 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1196 127, 128, 129, 130, 131, 132, 133, 134, 135, 136,
1197 137, 138
1198};
Anton Korobeynikov38e09802007-04-28 13:48:45 +00001199
Chris Lattnerce5f24e2007-07-05 17:26:49 +00001200#if YYDEBUG != 0
1201static const short yyprhs[] = { 0,
1202 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1203 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1204 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1205 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1206 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1207 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
1208 120, 121, 124, 125, 127, 129, 131, 132, 135, 137,
1209 139, 141, 143, 145, 147, 149, 151, 152, 154, 156,
1210 158, 159, 161, 163, 164, 166, 168, 170, 172, 173,
1211 175, 177, 178, 180, 182, 184, 186, 188, 191, 193,
1212 195, 197, 199, 201, 202, 205, 207, 209, 211, 212,
1213 215, 216, 219, 220, 224, 227, 228, 230, 231, 235,
1214 237, 240, 242, 244, 246, 248, 250, 252, 255, 257,
1215 260, 266, 272, 278, 284, 288, 291, 297, 302, 305,
1216 307, 309, 311, 315, 317, 321, 323, 324, 326, 330,
1217 335, 339, 343, 348, 353, 357, 364, 370, 373, 376,
1218 379, 382, 385, 388, 391, 394, 397, 400, 403, 406,
1219 413, 419, 428, 435, 442, 450, 458, 465, 474, 483,
1220 487, 489, 491, 493, 495, 496, 499, 506, 508, 509,
1221 511, 514, 515, 519, 520, 524, 528, 532, 536, 537,
1222 545, 546, 555, 556, 565, 571, 574, 578, 580, 584,
1223 588, 592, 596, 598, 599, 605, 609, 611, 615, 617,
1224 618, 628, 630, 632, 637, 639, 641, 644, 648, 649,
1225 651, 653, 655, 657, 659, 661, 663, 665, 667, 671,
1226 673, 679, 681, 683, 685, 687, 689, 691, 694, 697,
1227 700, 704, 707, 708, 710, 713, 716, 720, 730, 740,
1228 749, 764, 766, 768, 775, 781, 784, 791, 799, 803,
1229 809, 810, 811, 815, 818, 820, 826, 832, 839, 846,
1230 851, 858, 863, 868, 875, 882, 885, 894, 896, 898,
1231 899, 903, 910, 914, 921, 924, 930, 938
1232};
Chris Lattner39b2e8b2007-05-04 04:01:37 +00001233
Chris Lattnerce5f24e2007-07-05 17:26:49 +00001234static const short yyrhs[] = { 70,
1235 0, 71, 0, 72, 0, 73, 0, 74, 0, 75,
1236 0, 76, 0, 77, 0, 78, 0, 82, 0, 83,
1237 0, 84, 0, 79, 0, 80, 0, 81, 0, 113,
1238 0, 114, 0, 115, 0, 116, 0, 117, 0, 118,
1239 0, 119, 0, 120, 0, 121, 0, 122, 0, 123,
1240 0, 124, 0, 87, 0, 88, 0, 89, 0, 90,
1241 0, 91, 0, 92, 0, 93, 0, 94, 0, 95,
1242 0, 96, 0, 97, 0, 98, 0, 99, 0, 100,
1243 0, 101, 0, 102, 0, 103, 0, 104, 0, 105,
1244 0, 106, 0, 93, 0, 94, 0, 95, 0, 96,
1245 0, 23, 0, 24, 0, 11, 0, 12, 0, 13,
1246 0, 16, 0, 19, 0, 21, 0, 160, 0, 0,
1247 160, 139, 0, 0, 17, 0, 20, 0, 165, 0,
1248 0, 163, 139, 0, 39, 0, 41, 0, 40, 0,
1249 42, 0, 44, 0, 43, 0, 45, 0, 47, 0,
1250 0, 136, 0, 137, 0, 138, 0, 0, 43, 0,
1251 45, 0, 0, 39, 0, 40, 0, 41, 0, 44,
1252 0, 0, 41, 0, 39, 0, 0, 58, 0, 59,
1253 0, 60, 0, 61, 0, 62, 0, 57, 4, 0,
1254 114, 0, 115, 0, 132, 0, 133, 0, 135, 0,
1255 0, 174, 173, 0, 131, 0, 134, 0, 173, 0,
1256 0, 176, 175, 0, 0, 50, 4, 0, 0, 140,
1257 50, 4, 0, 31, 19, 0, 0, 179, 0, 0,
1258 140, 182, 181, 0, 179, 0, 50, 4, 0, 11,
1259 0, 12, 0, 13, 0, 14, 0, 46, 0, 183,
1260 0, 184, 141, 0, 218, 0, 142, 4, 0, 184,
1261 143, 188, 144, 176, 0, 10, 143, 188, 144, 176,
1262 0, 145, 4, 146, 184, 147, 0, 148, 4, 146,
1263 184, 149, 0, 150, 189, 151, 0, 150, 151, 0,
1264 148, 150, 189, 151, 149, 0, 148, 150, 151, 149,
1265 0, 184, 174, 0, 184, 0, 10, 0, 185, 0,
1266 187, 140, 185, 0, 187, 0, 187, 140, 36, 0,
1267 36, 0, 0, 184, 0, 189, 140, 184, 0, 184,
1268 145, 192, 147, 0, 184, 145, 147, 0, 184, 152,
1269 19, 0, 184, 148, 192, 149, 0, 184, 150, 192,
1270 151, 0, 184, 150, 151, 0, 184, 148, 150, 192,
1271 151, 149, 0, 184, 148, 150, 151, 149, 0, 184,
1272 37, 0, 184, 38, 0, 184, 218, 0, 184, 191,
1273 0, 184, 22, 0, 158, 3, 0, 158, 5, 0,
1274 158, 4, 0, 158, 6, 0, 11, 23, 0, 11,
1275 24, 0, 159, 9, 0, 155, 143, 190, 35, 184,
1276 144, 0, 112, 143, 190, 229, 144, 0, 126, 143,
1277 190, 140, 190, 140, 190, 144, 0, 153, 143, 190,
1278 140, 190, 144, 0, 154, 143, 190, 140, 190, 144,
1279 0, 85, 156, 143, 190, 140, 190, 144, 0, 86,
1280 157, 143, 190, 140, 190, 144, 0, 128, 143, 190,
1281 140, 190, 144, 0, 129, 143, 190, 140, 190, 140,
1282 190, 144, 0, 130, 143, 190, 140, 190, 140, 190,
1283 144, 0, 192, 140, 190, 0, 190, 0, 29, 0,
1284 30, 0, 34, 0, 0, 186, 218, 0, 118, 143,
1285 195, 35, 184, 144, 0, 197, 0, 0, 198, 0,
1286 197, 198, 0, 0, 28, 199, 214, 0, 0, 27,
1287 200, 215, 0, 55, 54, 204, 0, 162, 15, 184,
1288 0, 162, 15, 10, 0, 0, 164, 168, 194, 193,
1289 190, 201, 181, 0, 0, 164, 166, 168, 194, 193,
1290 190, 202, 181, 0, 0, 164, 167, 168, 194, 193,
1291 184, 203, 181, 0, 164, 168, 32, 171, 195, 0,
1292 48, 205, 0, 51, 139, 206, 0, 19, 0, 49,
1293 139, 19, 0, 63, 139, 19, 0, 145, 207, 147,
1294 0, 207, 140, 19, 0, 19, 0, 0, 208, 140,
1295 184, 174, 161, 0, 184, 174, 161, 0, 208, 0,
1296 208, 140, 36, 0, 36, 0, 0, 172, 186, 163,
1297 143, 209, 144, 176, 180, 177, 0, 25, 0, 150,
1298 0, 170, 168, 210, 211, 0, 26, 0, 151, 0,
1299 221, 213, 0, 169, 168, 210, 0, 0, 56, 0,
1300 3, 0, 4, 0, 9, 0, 23, 0, 24, 0,
1301 37, 0, 38, 0, 22, 0, 148, 192, 149, 0,
1302 191, 0, 54, 216, 19, 140, 19, 0, 7, 0,
1303 8, 0, 160, 0, 163, 0, 218, 0, 217, 0,
1304 184, 219, 0, 221, 222, 0, 212, 222, 0, 223,
1305 162, 224, 0, 223, 226, 0, 0, 18, 0, 64,
1306 220, 0, 64, 10, 0, 65, 14, 219, 0, 65,
1307 11, 219, 140, 14, 219, 140, 14, 219, 0, 66,
1308 158, 219, 140, 14, 219, 145, 225, 147, 0, 66,
1309 158, 219, 140, 14, 219, 145, 147, 0, 67, 172,
1310 186, 219, 143, 228, 144, 176, 35, 14, 219, 68,
1311 14, 219, 0, 68, 0, 69, 0, 225, 158, 217,
1312 140, 14, 219, 0, 158, 217, 140, 14, 219, 0,
1313 162, 231, 0, 184, 145, 219, 140, 219, 147, 0,
1314 227, 140, 145, 219, 140, 219, 147, 0, 184, 219,
1315 174, 0, 228, 140, 184, 219, 174, 0, 0, 0,
1316 229, 140, 220, 0, 53, 52, 0, 52, 0, 153,
1317 184, 219, 140, 219, 0, 154, 184, 219, 140, 219,
1318 0, 85, 156, 184, 219, 140, 219, 0, 86, 157,
1319 184, 219, 140, 219, 0, 155, 220, 35, 184, 0,
1320 126, 220, 140, 220, 140, 220, 0, 127, 220, 140,
1321 184, 0, 128, 220, 140, 220, 0, 129, 220, 140,
1322 220, 140, 220, 0, 130, 220, 140, 220, 140, 220,
1323 0, 125, 227, 0, 230, 172, 186, 219, 143, 228,
1324 144, 176, 0, 233, 0, 33, 0, 0, 107, 184,
1325 178, 0, 107, 184, 140, 11, 219, 178, 0, 108,
1326 184, 178, 0, 108, 184, 140, 11, 219, 178, 0,
1327 109, 220, 0, 232, 110, 184, 219, 178, 0, 232,
1328 111, 220, 140, 184, 219, 178, 0, 112, 184, 219,
1329 229, 0
1330};
Chris Lattner39b2e8b2007-05-04 04:01:37 +00001331
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00001332#endif
1333
Chris Lattnerce5f24e2007-07-05 17:26:49 +00001334#if YYDEBUG != 0
1335static const short yyrline[] = { 0,
1336 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1116, 1117,
1337 1117, 1117, 1117, 1117, 1117, 1118, 1118, 1118, 1118, 1118,
1338 1118, 1118, 1119, 1119, 1119, 1119, 1119, 1122, 1122, 1123,
1339 1123, 1124, 1124, 1125, 1125, 1126, 1126, 1130, 1130, 1131,
1340 1131, 1132, 1132, 1133, 1133, 1134, 1134, 1135, 1135, 1136,
1341 1136, 1137, 1138, 1143, 1144, 1144, 1146, 1146, 1146, 1147,
1342 1147, 1151, 1155, 1160, 1160, 1162, 1163, 1168, 1174, 1175,
1343 1176, 1177, 1178, 1182, 1183, 1184, 1188, 1189, 1190, 1191,
1344 1195, 1196, 1197, 1201, 1202, 1203, 1204, 1205, 1209, 1210,
1345 1211, 1214, 1214, 1215, 1216, 1217, 1218, 1219, 1227, 1228,
1346 1229, 1230, 1231, 1234, 1235, 1240, 1241, 1242, 1245, 1246,
1347 1253, 1253, 1260, 1260, 1269, 1277, 1277, 1283, 1283, 1285,
1348 1290, 1303, 1303, 1303, 1303, 1306, 1310, 1314, 1321, 1326,
1349 1334, 1364, 1395, 1400, 1412, 1422, 1426, 1436, 1443, 1450,
1350 1457, 1462, 1467, 1474, 1475, 1482, 1489, 1497, 1503, 1515,
1351 1543, 1559, 1586, 1614, 1640, 1660, 1686, 1706, 1718, 1725,
1352 1791, 1801, 1811, 1817, 1827, 1833, 1843, 1848, 1853, 1861,
1353 1873, 1895, 1903, 1909, 1920, 1925, 1930, 1936, 1942, 1951,
1354 1955, 1963, 1963, 1966, 1966, 1969, 1980, 2001, 2006, 2014,
1355 2015, 2019, 2019, 2023, 2023, 2026, 2029, 2053, 2064, 2071,
1356 2074, 2080, 2083, 2090, 2094, 2113, 2116, 2122, 2132, 2136,
1357 2141, 2143, 2148, 2153, 2162, 2172, 2183, 2187, 2196, 2205,
1358 2210, 2331, 2331, 2333, 2342, 2342, 2344, 2349, 2361, 2365,
1359 2370, 2374, 2378, 2382, 2386, 2390, 2394, 2398, 2402, 2427,
1360 2431, 2441, 2445, 2449, 2454, 2461, 2461, 2467, 2476, 2480,
1361 2489, 2498, 2507, 2511, 2518, 2522, 2526, 2531, 2541, 2560,
1362 2569, 2649, 2653, 2660, 2671, 2684, 2694, 2705, 2715, 2724,
1363 2733, 2736, 2737, 2744, 2748, 2753, 2774, 2791, 2805, 2819,
1364 2831, 2839, 2846, 2852, 2858, 2864, 2879, 2964, 2969, 2973,
1365 2980, 2987, 2995, 3002, 3010, 3018, 3032, 3049
1366};
1367#endif
1368
1369
1370#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1371
1372static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1373"EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL",
1374"VOID","INTTYPE","FLOAT","DOUBLE","LABEL","TYPE","LOCALVAR","GLOBALVAR","LABELSTR",
1375"STRINGCONSTANT","ATSTRINGCONSTANT","PCTSTRINGCONSTANT","ZEROINITIALIZER","TRUETOK",
1376"FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT","SECTION",
1377"ALIAS","VOLATILE","THREAD_LOCAL","TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL",
1378"LINKONCE","WEAK","APPENDING","DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE",
1379"EXTERNAL","TARGET","TRIPLE","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE",
1380"SIDEEFFECT","CC_TOK","CCC_TOK","FASTCC_TOK","COLDCC_TOK","X86_STDCALLCC_TOK",
1381"X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE",
1382"ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM","FREM","AND","OR","XOR",
1383"SHL","LSHR","ASHR","ICMP","FCMP","EQ","NE","SLT","SGT","SLE","SGE","ULT","UGT",
1384"ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE","MALLOC",
1385"ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC","ZEXT","SEXT","FPTRUNC",
1386"FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI","INTTOPTR","PTRTOINT",
1387"PHI_TOK","SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR",
1388"NORETURN","INREG","SRET","NOUNWIND","NOALIAS","DEFAULT","HIDDEN","PROTECTED",
1389"'='","','","'*'","'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'",
1390"'c'","ArithmeticOps","LogicalOps","CastOps","IPredicates","FPredicates","IntType",
1391"FPType","LocalName","OptLocalName","OptLocalAssign","GlobalName","OptGlobalAssign",
1392"GlobalAssign","GVInternalLinkage","GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage",
1393"FunctionDefineLinkage","AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs",
1394"FuncAttr","OptFuncAttrs","OptAlign","OptCAlign","SectionString","OptSection",
1395"GlobalVarAttributes","GlobalVarAttribute","PrimType","Types","ArgType","ResultTypes",
1396"ArgTypeList","ArgTypeListI","TypeListI","ConstVal","ConstExpr","ConstVector",
1397"GlobalType","ThreadLocal","AliaseeRef","Module","DefinitionList","Definition",
1398"@1","@2","@3","@4","@5","AsmBlock","TargetDefinition","LibrariesDefinition",
1399"LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END",
1400"Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef",
1401"ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1402"JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal",
1403"OptVolatile","MemoryInst", NULL
1404};
1405#endif
1406
1407static const short yyr1[] = { 0,
1408 153, 153, 153, 153, 153, 153, 153, 153, 153, 154,
1409 154, 154, 154, 154, 154, 155, 155, 155, 155, 155,
1410 155, 155, 155, 155, 155, 155, 155, 156, 156, 156,
1411 156, 156, 156, 156, 156, 156, 156, 157, 157, 157,
1412 157, 157, 157, 157, 157, 157, 157, 157, 157, 157,
1413 157, 157, 157, 158, 159, 159, 160, 160, 160, 161,
1414 161, 162, 162, 163, 163, 164, 164, 165, 166, 166,
1415 166, 166, 166, 167, 167, 167, 168, 168, 168, 168,
1416 169, 169, 169, 170, 170, 170, 170, 170, 171, 171,
1417 171, 172, 172, 172, 172, 172, 172, 172, 173, 173,
1418 173, 173, 173, 174, 174, 175, 175, 175, 176, 176,
1419 177, 177, 178, 178, 179, 180, 180, 181, 181, 182,
1420 182, 183, 183, 183, 183, 184, 184, 184, 184, 184,
1421 184, 184, 184, 184, 184, 184, 184, 184, 185, 186,
1422 186, 187, 187, 188, 188, 188, 188, 189, 189, 190,
1423 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
1424 190, 190, 190, 190, 190, 190, 190, 190, 190, 191,
1425 191, 191, 191, 191, 191, 191, 191, 191, 191, 192,
1426 192, 193, 193, 194, 194, 195, 195, 196, 196, 197,
1427 197, 199, 198, 200, 198, 198, 198, 198, 201, 198,
1428 202, 198, 203, 198, 198, 198, 198, 204, 205, 205,
1429 206, 207, 207, 207, 208, 208, 209, 209, 209, 209,
1430 210, 211, 211, 212, 213, 213, 214, 215, 216, 216,
1431 217, 217, 217, 217, 217, 217, 217, 217, 217, 217,
1432 217, 218, 218, 218, 218, 219, 219, 220, 221, 221,
1433 222, 223, 223, 223, 224, 224, 224, 224, 224, 224,
1434 224, 224, 224, 225, 225, 226, 227, 227, 228, 228,
1435 228, 229, 229, 230, 230, 231, 231, 231, 231, 231,
1436 231, 231, 231, 231, 231, 231, 231, 231, 232, 232,
1437 233, 233, 233, 233, 233, 233, 233, 233
1438};
1439
1440static const short yyr2[] = { 0,
1441 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1442 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1443 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1444 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1445 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1446 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1447 0, 2, 0, 1, 1, 1, 0, 2, 1, 1,
1448 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
1449 0, 1, 1, 0, 1, 1, 1, 1, 0, 1,
1450 1, 0, 1, 1, 1, 1, 1, 2, 1, 1,
1451 1, 1, 1, 0, 2, 1, 1, 1, 0, 2,
1452 0, 2, 0, 3, 2, 0, 1, 0, 3, 1,
1453 2, 1, 1, 1, 1, 1, 1, 2, 1, 2,
1454 5, 5, 5, 5, 3, 2, 5, 4, 2, 1,
1455 1, 1, 3, 1, 3, 1, 0, 1, 3, 4,
1456 3, 3, 4, 4, 3, 6, 5, 2, 2, 2,
1457 2, 2, 2, 2, 2, 2, 2, 2, 2, 6,
1458 5, 8, 6, 6, 7, 7, 6, 8, 8, 3,
1459 1, 1, 1, 1, 0, 2, 6, 1, 0, 1,
1460 2, 0, 3, 0, 3, 3, 3, 3, 0, 7,
1461 0, 8, 0, 8, 5, 2, 3, 1, 3, 3,
1462 3, 3, 1, 0, 5, 3, 1, 3, 1, 0,
1463 9, 1, 1, 4, 1, 1, 2, 3, 0, 1,
1464 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
1465 5, 1, 1, 1, 1, 1, 1, 2, 2, 2,
1466 3, 2, 0, 1, 2, 2, 3, 9, 9, 8,
1467 14, 1, 1, 6, 5, 2, 6, 7, 3, 5,
1468 0, 0, 3, 2, 1, 5, 5, 6, 6, 4,
1469 6, 4, 4, 6, 6, 2, 8, 1, 1, 0,
1470 3, 6, 3, 6, 2, 5, 7, 4
1471};
1472
1473static const short yydefact[] = { 67,
1474 57, 64, 58, 65, 59, 194, 192, 0, 0, 0,
1475 0, 0, 0, 77, 66, 67, 190, 81, 84, 0,
1476 0, 206, 0, 0, 62, 0, 68, 69, 71, 70,
1477 72, 74, 73, 75, 76, 78, 79, 80, 77, 77,
1478 185, 191, 82, 83, 77, 195, 85, 86, 87, 88,
1479 77, 253, 193, 253, 0, 0, 214, 207, 208, 196,
1480 242, 243, 198, 122, 123, 124, 125, 126, 0, 0,
1481 0, 0, 244, 245, 127, 197, 129, 185, 185, 89,
1482 184, 0, 92, 92, 254, 250, 63, 225, 226, 227,
1483 249, 209, 210, 213, 0, 147, 130, 0, 0, 0,
1484 0, 136, 148, 0, 128, 147, 0, 0, 91, 90,
1485 0, 182, 183, 0, 0, 93, 94, 95, 96, 97,
1486 0, 228, 0, 290, 252, 0, 211, 146, 104, 142,
1487 144, 0, 0, 0, 0, 0, 0, 135, 0, 0,
1488 0, 141, 0, 140, 0, 205, 122, 123, 124, 0,
1489 0, 0, 199, 98, 0, 222, 223, 224, 289, 275,
1490 0, 0, 0, 0, 92, 262, 263, 1, 2, 3,
1491 4, 5, 6, 7, 8, 9, 13, 14, 15, 10,
1492 11, 12, 0, 0, 0, 0, 0, 0, 16, 17,
1493 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1494 0, 0, 0, 0, 0, 0, 0, 0, 0, 251,
1495 92, 266, 0, 288, 212, 139, 0, 109, 0, 0,
1496 138, 0, 149, 109, 201, 203, 0, 186, 167, 168,
1497 163, 165, 164, 166, 169, 162, 158, 159, 0, 0,
1498 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1499 0, 0, 161, 160, 118, 0, 274, 256, 0, 255,
1500 0, 0, 54, 0, 0, 28, 29, 30, 31, 32,
1501 33, 34, 35, 36, 37, 0, 52, 53, 48, 49,
1502 50, 51, 38, 39, 40, 41, 42, 43, 44, 45,
1503 46, 47, 0, 113, 113, 295, 0, 0, 286, 0,
1504 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1505 99, 100, 101, 102, 103, 105, 145, 143, 132, 133,
1506 134, 137, 131, 118, 118, 0, 0, 0, 0, 0,
1507 0, 0, 0, 151, 181, 0, 0, 0, 155, 0,
1508 152, 0, 0, 0, 0, 200, 220, 231, 232, 233,
1509 238, 234, 235, 236, 237, 229, 0, 240, 247, 246,
1510 248, 0, 257, 0, 0, 0, 0, 0, 291, 0,
1511 293, 272, 0, 0, 0, 0, 0, 0, 0, 0,
1512 0, 0, 0, 0, 0, 106, 107, 108, 110, 202,
1513 204, 0, 0, 0, 272, 0, 0, 0, 0, 0,
1514 150, 136, 148, 0, 153, 154, 0, 0, 0, 0,
1515 0, 120, 118, 219, 104, 217, 0, 230, 0, 0,
1516 0, 0, 0, 0, 0, 0, 0, 0, 298, 0,
1517 0, 0, 282, 283, 0, 0, 0, 0, 280, 0,
1518 113, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1519 180, 157, 0, 0, 0, 0, 115, 121, 119, 61,
1520 0, 109, 0, 239, 0, 0, 271, 0, 0, 113,
1521 114, 113, 0, 0, 0, 0, 0, 0, 276, 277,
1522 271, 0, 296, 0, 187, 0, 0, 171, 0, 0,
1523 0, 0, 156, 0, 0, 0, 60, 216, 218, 104,
1524 116, 0, 0, 0, 0, 0, 278, 279, 292, 294,
1525 273, 0, 0, 281, 284, 285, 0, 113, 0, 0,
1526 0, 177, 0, 0, 173, 174, 170, 61, 117, 111,
1527 241, 0, 0, 104, 0, 109, 267, 0, 109, 297,
1528 175, 176, 0, 0, 0, 215, 0, 221, 0, 260,
1529 0, 0, 269, 0, 0, 268, 287, 172, 178, 179,
1530 112, 258, 0, 259, 0, 104, 0, 0, 0, 270,
1531 0, 0, 0, 0, 265, 0, 0, 264, 0, 261,
1532 0, 0, 0
1533};
1534
1535static const short yydefgoto[] = { 250,
1536 251, 252, 276, 293, 150, 151, 73, 498, 12, 74,
1537 14, 15, 39, 40, 41, 45, 51, 111, 121, 316,
1538 216, 389, 319, 548, 369, 412, 530, 346, 413, 75,
1539 152, 130, 145, 131, 132, 104, 335, 358, 336, 114,
1540 82, 146, 581, 16, 17, 19, 18, 255, 324, 325,
1541 60, 22, 58, 95, 416, 417, 122, 158, 52, 90,
1542 53, 46, 419, 359, 77, 361, 260, 54, 86, 87,
1543 210, 552, 125, 299, 506, 429, 211, 212, 213, 214
1544};
1545
1546static const short yypact[] = { 1026,
1547-32768,-32768,-32768,-32768,-32768,-32768,-32768, -3, -63, 44,
1548 -10, 142, 62, 336,-32768, 1490,-32768, 107, 131, 74,
1549 127,-32768, -27, 149,-32768, 1195,-32768,-32768,-32768,-32768,
1550-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 93, 93,
1551 214,-32768,-32768,-32768, 93,-32768,-32768,-32768,-32768,-32768,
1552 93, 155,-32768, 13, 239, 253, 258,-32768,-32768,-32768,
1553-32768,-32768, 139,-32768,-32768,-32768,-32768,-32768, 282, 284,
1554 5, 128,-32768,-32768,-32768, 124,-32768, 256, 256, 230,
1555-32768, 34, 163, 163,-32768,-32768, 184,-32768,-32768,-32768,
1556-32768,-32768,-32768,-32768, -30, 956,-32768, 147, 151, 910,
1557 139,-32768, 124, -74,-32768, 956, 34, 34,-32768,-32768,
1558 987,-32768,-32768, 1210, 302,-32768,-32768,-32768,-32768,-32768,
1559 1247,-32768, 15, 1353,-32768, 290,-32768,-32768, 124,-32768,
1560 170, 173, 1262, 1262, 162, -68, 1262,-32768, 174, 1210,
1561 1262, 139, 177, 124, 83,-32768, 38, 312, 314, 251,
1562 315, 764,-32768,-32768, 126,-32768,-32768,-32768,-32768,-32768,
1563 273, 1308, 227, 317, 163,-32768,-32768,-32768,-32768,-32768,
1564-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1565-32768,-32768, 566, 613, 1262, 1262, 1262, 1262,-32768,-32768,
1566-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1567 1262, 1262, 1262, 1262, 1262, 1262, 1262, 1262, 1262,-32768,
1568 163,-32768, -4,-32768,-32768, -77, 1002,-32768, -59, 63,
1569-32768, 182, 124,-32768,-32768, 124, 987,-32768,-32768,-32768,
1570-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 566, 613,
1571 189, 190, 191, 193, 194, 1100, 1354, 925, 319, 196,
1572 197, 198,-32768,-32768, 203, 199,-32768, 139, 611,-32768,
1573 741, 741,-32768, 741, 1247,-32768,-32768,-32768,-32768,-32768,
1574-32768,-32768,-32768,-32768,-32768, 1262,-32768,-32768,-32768,-32768,
1575-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1576-32768,-32768, 1262, 109, 119,-32768, 611, 94, 204, 206,
1577 207, 208, 209, 215, 611, 611, 321, 1247, 1262, 1262,
1578-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -82,-32768,
1579-32768,-32768, -82, 203, 203, 323, 218, 220, 1210, 1210,
1580 1210, 1210, 1210,-32768,-32768, -21, 941, -92,-32768, -62,
1581-32768, 1210, 1210, 1210, -5,-32768, 1146,-32768,-32768,-32768,
1582-32768,-32768,-32768,-32768,-32768, 313, 1210,-32768,-32768,-32768,
1583-32768, 228,-32768, 233, 741, 611, 611, 4,-32768, 17,
1584-32768,-32768, 741, 225, 1262, 1262, 1262, 1262, 1262, 242,
1585 244, 1262, 741, 611, 245,-32768,-32768,-32768,-32768,-32768,
1586-32768, 1262, 1210, 1210,-32768, 246, 247, 248, 249, 1210,
1587-32768, 241, 764, -46,-32768,-32768, 252, 254, 358, 377,
1588 393,-32768, 203,-32768, 124, 259, 257,-32768, 379, -70,
1589 386, 388, 262, 266, 267, 741, 404, 741, 269, 271,
1590 741, 272, 124,-32768, 274, 276, 741, 741, 124, 270,
1591 283, 1262, 45, 287, 288, 70, 1210, 1210, 1210, 1210,
1592-32768,-32768, 275, 1210, 1210, 1262,-32768,-32768,-32768, 76,
1593 1164,-32768, 289,-32768, 741, 741, 1262, 741, 741, 283,
1594-32768, 283, 1262, 741, 294, 1262, 1262, 1262,-32768,-32768,
1595 1262, 372,-32768, 611,-32768, 1210, 1210,-32768, 295, 286,
1596 298, 299,-32768, 297, 300, 164,-32768,-32768,-32768, 124,
1597 84, 424, 305, 301, 611, 92,-32768,-32768,-32768,-32768,
1598-32768, 303, 741,-32768,-32768,-32768, 103, 283, 310, 311,
1599 1210,-32768, 1210, 1210,-32768,-32768,-32768, 76,-32768, 397,
1600-32768, 435, 6,-32768, 1262,-32768,-32768, 320,-32768,-32768,
1601-32768,-32768, 318, 322, 324,-32768, 455,-32768, 741,-32768,
1602 476, 7, -77, 611, -1,-32768, -82,-32768,-32768,-32768,
1603-32768,-32768, 329,-32768, 476,-32768, 447, 456, 335, -77,
1604 741, 741, 462, 409,-32768, 741, 464,-32768, 741,-32768,
1605 483, 484,-32768
1606};
1607
1608static const short yypgoto[] = { 362,
1609 363, 364, 250, 261, -161,-32768, 0, -38, 406, 14,
1610-32768,-32768,-32768,-32768, 29,-32768,-32768,-32768, -146, -294,
1611 -407,-32768, -220,-32768, -285, 1,-32768, -289,-32768,-32768,
1612 -25, 279, -114,-32768, 385, 403, -29, -150, -236, 167,
1613 202, 277,-32768,-32768, 481,-32768,-32768,-32768,-32768,-32768,
1614-32768,-32768,-32768,-32768,-32768,-32768, 421,-32768,-32768,-32768,
1615-32768,-32768,-32768, -492, -139, 98, -182,-32768, 452,-32768,
1616-32768,-32768,-32768,-32768, 26, 113,-32768,-32768,-32768,-32768
1617};
1618
1619
1620#define YYLAST 1545
1621
1622
1623static const short yytable[] = { 11,
1624 76, 253, 264, 323, 296, 228, 155, 460, 99, 371,
1625 338, 340, 254, 13, 426, 11, 263, 263, 265, 300,
1626 301, 302, 303, 304, 388, 410, 307, 428, 388, 13,
1627 85, 311, 312, 567, 390, 391, 311, 312, 88, 156,
1628 -54, -54, -54, -54, 411, 20, 103, 400, 386, 313,
1629 314, 387, 315, 427, 313, 314, 405, 315, 563, 21,
1630 229, 230, 112, 113, 308, 137, 427, 78, 79, 400,
1631 129, 137, 569, 83, 103, 23, 138, 400, 464, 84,
1632 129, 105, 222, 106, 153, 144, 11, 320, 406, 61,
1633 62, 1, 528, 400, 3, 144, 5, 24, 1, 2,
1634 404, 3, 4, 5, 453, 309, 310, 219, 220, 126,
1635 225, 223, 311, 312, 410, 226, 127, 57, 400, 360,
1636 420, 360, 360, 459, 360, 401, 553, 385, 25, 386,
1637 313, 314, 387, 315, 61, 62, 259, 101, 64, 65,
1638 66, 67, 2, 1, 2, 4, 3, 4, 5, 43,
1639 365, 44, 550, 564, 100, 483, 26, 360, 570, 294,
1640 295, 259, 297, 89, 157, 360, 360, 59, 256, 47,
1641 48, 49, 85, 68, 50, 298, 259, 259, 259, 259,
1642 259, 305, 306, 259, 509, 105, 510, 106, 485, 311,
1643 312, 129, 432, 383, 434, 435, 436, 311, 312, 1,
1644 27, 144, 3, 105, 5, 106, 388, 313, 314, 473,
1645 315, 321, 55, 488, 386, 313, 314, 387, 315, 115,
1646 116, 117, 118, 119, 120, 360, 360, 360, 36, 37,
1647 38, 535, 540, 360, 105, 536, 106, 261, 373, 144,
1648 262, 501, 535, 360, 360, 80, 539, 81, 368, 105,
1649 366, 106, 253, 231, 232, 233, 234, 92, 370, 105,
1650 388, 106, 388, 254, 105, 56, 106, 367, 109, 69,
1651 110, 93, 70, 140, 141, 71, 94, 72, 102, 107,
1652 108, 96, 144, 384, 259, 97, 360, 98, 360, 81,
1653 511, 360, 133, 514, 515, 516, 134, 360, 360, 395,
1654 396, 397, 398, 399, 105, 154, 106, 527, 215, 217,
1655 221, 403, 407, 408, 409, 555, 218, 224, 557, 227,
1656 -55, 415, -56, 235, 257, 360, 360, 263, 360, 360,
1657 322, 329, 330, 331, 360, 332, 333, 341, 342, 343,
1658 344, 347, 345, 374, 360, 375, 376, 377, 378, 259,
1659 433, 259, 259, 259, 379, 382, 439, 392, 362, 363,
1660 393, 364, 394, 444, 445, 360, 443, 421, 418, 431,
1661 451, 551, 422, 360, 28, 29, 30, 31, 32, 33,
1662 34, 437, 35, 438, 442, 447, 448, 449, 450, 452,
1663 565, 454, 456, 455, 372, 457, 458, 463, 461, 465,
1664 462, 466, 380, 381, 467, 468, 469, 471, 473, 360,
1665 474, 476, 481, 477, 360, 478, 484, 489, 490, 491,
1666 492, 427, 482, 493, 494, 495, 486, 487, 502, 522,
1667 496, 360, 360, 513, 521, 500, 360, 523, 524, 360,
1668 525, 505, 531, 526, 532, 533, 547, 259, 549, 537,
1669 259, 259, 259, 541, 542, 505, 519, 520, 561, 497,
1670 571, 558, 423, 424, 425, 559, 556, 560, 568, 572,
1671 430, 36, 37, 38, 573, 576, 577, 579, 348, 349,
1672 440, 441, 582, 583, 350, 207, 208, 209, 327, 546,
1673 139, 543, 124, 544, 545, 318, 42, 351, 352, 353,
1674 328, 529, 136, 326, 123, 91, 517, 446, 0, 554,
1675 0, 0, 354, 355, 0, 0, 0, 0, 0, 0,
1676 0, 0, 0, 470, 0, 472, 0, 497, 475, 356,
1677 0, 0, 0, 0, 479, 480, 0, 0, 0, 0,
1678 0, 0, 0, 0, 0, 168, 169, 170, 171, 172,
1679 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1680 239, 240, 503, 504, 0, 507, 508, 0, 0, 0,
1681 0, 512, 0, 0, 0, 0, 0, 0, 0, 0,
1682 0, 518, 0, 0, 0, 0, 0, 241, 189, 190,
1683 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
1684 0, 242, 534, 243, 244, 245, 0, 0, 0, 0,
1685 538, 0, 0, 348, 349, 0, 0, 61, 62, 350,
1686 0, 0, 0, 357, 0, 0, 1, 2, 0, 3,
1687 4, 5, 351, 352, 353, 277, 278, 0, 0, 0,
1688 0, 0, 0, 0, 0, 0, 562, 354, 355, 0,
1689 0, 566, 266, 267, 268, 269, 270, 271, 272, 273,
1690 274, 275, 0, 0, 356, 0, 0, 0, 574, 575,
1691 0, 0, 0, 578, 0, 0, 580, 0, 0, 0,
1692 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
1693 178, 179, 180, 181, 182, 239, 240, 0, 0, 0,
1694 0, 0, 0, 0, 0, 279, 280, 281, 282, 283,
1695 284, 285, 286, 287, 288, 289, 290, 291, 292, 0,
1696 0, 0, 241, 189, 190, 191, 192, 193, 194, 195,
1697 196, 197, 198, 199, 200, 0, 242, 0, 243, 244,
1698 245, 0, 0, 348, 349, 0, 0, 61, 62, 350,
1699 0, 105, 0, 106, 0, 0, 1, 2, 357, 3,
1700 4, 5, 351, 352, 353, 0, 0, 0, 0, 0,
1701 61, 62, 0, 0, 0, 0, 0, 354, 355, 1,
1702 2, 0, 3, 4, 5, 236, 0, 0, 0, 0,
1703 0, 0, 0, 0, 356, 0, 0, 0, 0, 0,
1704 237, 238, 0, 0, 0, 0, 0, 0, 0, 0,
1705 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
1706 178, 179, 180, 181, 182, 239, 240, 0, 0, 0,
1707 0, 0, 0, 168, 169, 170, 171, 172, 173, 174,
1708 175, 176, 177, 178, 179, 180, 181, 182, 239, 240,
1709 0, 0, 241, 189, 190, 191, 192, 193, 194, 195,
1710 196, 197, 198, 199, 200, 0, 242, 0, 243, 244,
1711 245, 0, 0, 0, 0, 241, 189, 190, 191, 192,
1712 193, 194, 195, 196, 197, 198, 199, 200, 357, 242,
1713 0, 243, 244, 245, 0, 0, 0, 0, 0, 0,
1714 0, 0, 0, 0, 105, 0, 106, 0, 246, 0,
1715 0, 247, 0, 248, 0, 249, 61, 62, 0, 101,
1716 64, 65, 66, 67, 0, 1, 2, 0, 3, 4,
1717 5, 61, 62, 0, 101, 147, 148, 149, 67, 0,
1718 1, 2, 0, 3, 4, 5, 0, 61, 62, 0,
1719 101, 147, 148, 149, 67, 68, 1, 2, 0, 3,
1720 4, 5, 61, 62, 0, 101, 64, 65, 66, 67,
1721 68, 1, 2, 0, 3, 4, 5, 0, 0, 0,
1722 0, 0, 0, 0, 0, 0, 68, 0, 0, 0,
1723 0, 128, 0, 61, 62, 0, 142, 64, 65, 66,
1724 67, 68, 1, 2, 0, 3, 4, 5, 61, 62,
1725 0, 101, 64, 65, 66, 67, 0, 1, 2, 0,
1726 3, 4, 5, 0, 0, -189, 0, 0, 0, 0,
1727 0, 0, 68, 0, 0, 0, 0, 317, 0, 0,
1728 -63, 1, 2, 0, 3, 4, 5, 68, 0, 0,
1729 0, 69, 6, 7, 70, 0, 0, 71, 0, 72,
1730 135, 0, 0, 0, 0, 0, 69, 0, 0, 70,
1731 0, 0, 71, 8, 72, 339, 9, 0, 0, 0,
1732 10, 0, 69, 0, 0, 70, 0, 0, 71, 0,
1733 72, 402, 0, 0, 0, 0, 0, 69, 0, 0,
1734 70, 0, 0, 71, 143, 72, 61, 62, 0, 101,
1735 147, 148, 149, 67, 0, 1, 2, 0, 3, 4,
1736 5, 0, 0, 0, 0, 0, 0, 0, 69, 0,
1737 0, 70, 0, 0, 71, 0, 72, 0, 0, 0,
1738 0, 0, 0, 69, 0, 68, 70, 0, 0, 71,
1739 0, 72, 61, 62, 0, 101, 64, 65, 66, 67,
1740 0, 1, 2, 0, 3, 4, 5, 0, 0, 0,
1741 61, 62, 0, 101, 64, 65, 66, 67, 0, 1,
1742 2, 414, 3, 4, 5, 0, 0, 0, 0, 0,
1743 0, 68, 0, 0, 0, 0, 0, 0, 0, 499,
1744 0, 61, 62, 0, 63, 64, 65, 66, 67, 68,
1745 1, 2, 0, 3, 4, 5, 61, 62, 0, 101,
1746 147, 148, 149, 67, 0, 1, 2, 0, 3, 4,
1747 5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1748 68, 69, 0, 0, 70, 0, 334, 71, 0, 72,
1749 0, 0, 0, 61, 62, 68, 142, 64, 65, 66,
1750 67, 0, 1, 2, 0, 3, 4, 5, 61, 62,
1751 0, 101, 64, 65, 66, 67, 0, 1, 2, 0,
1752 3, 4, 5, 0, 0, 0, 0, 69, 0, 0,
1753 70, 0, 68, 71, 0, 72, 0, 0, 0, 0,
1754 0, 0, 0, 0, 0, 69, 0, 68, 70, 0,
1755 0, 71, 0, 72, 61, 62, 0, 258, 64, 65,
1756 66, 67, 0, 1, 2, 0, 3, 4, 5, 0,
1757 0, 0, 0, 0, 0, 0, 69, 0, 0, 70,
1758 0, 0, 71, 0, 72, 0, 0, 0, 0, 0,
1759 0, 69, 0, 68, 70, 0, 0, 71, 0, 72,
1760 61, 62, 0, 101, 147, 148, 149, 67, 0, 1,
1761 2, 0, 3, 4, 5, 0, 0, 0, 0, 0,
1762 0, 0, 0, 0, 0, 159, 0, 0, 69, 0,
1763 0, 70, 0, 0, 71, 0, 72, 0, 0, 68,
1764 0, 0, 0, 69, 160, 161, 70, 0, 0, 71,
1765 0, 72, 0, 0, 0, 0, 162, 163, 164, 165,
1766 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
1767 176, 177, 178, 179, 180, 181, 182, 183, 184, 0,
1768 0, 0, 0, 0, 0, 0, 0, 0, 0, 69,
1769 0, 0, 70, 0, 0, 71, 0, 72, 0, 185,
1770 186, 187, 0, 0, 188, 189, 190, 191, 192, 193,
1771 194, 195, 196, 197, 198, 199, 200, 201, 202, 203,
1772 204, 205, 206, 0, 0, 0, 0, 0, 0, -188,
1773 0, 0, 0, 0, 0, 69, 0, 0, 70, 0,
1774 0, 71, 0, 337, -63, 1, 2, 0, 3, 4,
1775 5, 0, 0, 0, 0, 0, 6, 7, 0, 0,
1776 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1777 0, 0, 0, 0, 0, 0, 0, 8, 0, 0,
1778 9, 0, 0, 0, 10
1779};
1780
1781static const short yycheck[] = { 0,
1782 26, 152, 164, 224, 187, 145, 121, 415, 4, 295,
1783 247, 248, 152, 0, 11, 16, 11, 11, 165, 202,
1784 203, 204, 205, 206, 319, 31, 209, 11, 323, 16,
1785 18, 114, 115, 35, 324, 325, 114, 115, 26, 25,
1786 3, 4, 5, 6, 50, 49, 72, 140, 131, 132,
1787 133, 134, 135, 50, 132, 133, 149, 135, 551, 63,
1788 23, 24, 29, 30, 211, 140, 50, 39, 40, 140,
1789 96, 140, 565, 45, 100, 139, 151, 140, 149, 51,
1790 106, 141, 151, 143, 114, 111, 87, 147, 151, 7,
1791 8, 16, 500, 140, 19, 121, 21, 54, 16, 17,
1792 337, 19, 20, 21, 151, 110, 111, 133, 134, 140,
1793 140, 137, 114, 115, 31, 141, 147, 145, 140, 259,
1794 357, 261, 262, 413, 264, 147, 534, 310, 139, 131,
1795 132, 133, 134, 135, 7, 8, 162, 10, 11, 12,
1796 13, 14, 17, 16, 17, 20, 19, 20, 21, 43,
1797 265, 45, 147, 147, 150, 441, 15, 297, 566, 185,
1798 186, 187, 188, 151, 150, 305, 306, 19, 155, 39,
1799 40, 41, 18, 46, 44, 201, 202, 203, 204, 205,
1800 206, 207, 208, 209, 470, 141, 472, 143, 144, 114,
1801 115, 217, 375, 308, 377, 378, 379, 114, 115, 16,
1802 139, 227, 19, 141, 21, 143, 501, 132, 133, 140,
1803 135, 149, 139, 144, 131, 132, 133, 134, 135, 57,
1804 58, 59, 60, 61, 62, 365, 366, 367, 136, 137,
1805 138, 140, 518, 373, 141, 144, 143, 11, 145, 265,
1806 14, 462, 140, 383, 384, 32, 144, 34, 140, 141,
1807 276, 143, 403, 3, 4, 5, 6, 19, 140, 141,
1808 555, 143, 557, 403, 141, 139, 143, 293, 39, 142,
1809 41, 19, 145, 107, 108, 148, 19, 150, 151, 78,
1810 79, 143, 308, 309, 310, 4, 426, 4, 428, 34,
1811 473, 431, 146, 476, 477, 478, 146, 437, 438, 329,
1812 330, 331, 332, 333, 141, 4, 143, 144, 19, 140,
1813 149, 337, 342, 343, 344, 536, 144, 144, 539, 143,
1814 9, 347, 9, 9, 52, 465, 466, 11, 468, 469,
1815 149, 143, 143, 143, 474, 143, 143, 19, 143, 143,
1816 143, 143, 140, 140, 484, 140, 140, 140, 140, 375,
1817 376, 377, 378, 379, 140, 35, 382, 35, 261, 262,
1818 143, 264, 143, 393, 394, 505, 392, 140, 56, 145,
1819 400, 533, 140, 513, 39, 40, 41, 42, 43, 44,
1820 45, 140, 47, 140, 140, 140, 140, 140, 140, 149,
1821 552, 140, 35, 140, 297, 19, 4, 19, 140, 14,
1822 144, 14, 305, 306, 143, 140, 140, 4, 140, 549,
1823 140, 140, 143, 140, 554, 140, 442, 447, 448, 449,
1824 450, 50, 140, 149, 454, 455, 140, 140, 140, 144,
1825 456, 571, 572, 140, 140, 461, 576, 140, 140, 579,
1826 144, 467, 19, 144, 140, 145, 50, 473, 14, 147,
1827 476, 477, 478, 144, 144, 481, 486, 487, 4, 460,
1828 14, 144, 365, 366, 367, 144, 147, 144, 140, 14,
1829 373, 136, 137, 138, 140, 14, 68, 14, 3, 4,
1830 383, 384, 0, 0, 9, 124, 124, 124, 239, 528,
1831 106, 521, 87, 523, 524, 217, 16, 22, 23, 24,
1832 240, 501, 100, 227, 84, 54, 481, 395, -1, 535,
1833 -1, -1, 37, 38, -1, -1, -1, -1, -1, -1,
1834 -1, -1, -1, 426, -1, 428, -1, 528, 431, 54,
1835 -1, -1, -1, -1, 437, 438, -1, -1, -1, -1,
1836 -1, -1, -1, -1, -1, 70, 71, 72, 73, 74,
1837 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1838 85, 86, 465, 466, -1, 468, 469, -1, -1, -1,
1839 -1, 474, -1, -1, -1, -1, -1, -1, -1, -1,
1840 -1, 484, -1, -1, -1, -1, -1, 112, 113, 114,
1841 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1842 -1, 126, 505, 128, 129, 130, -1, -1, -1, -1,
1843 513, -1, -1, 3, 4, -1, -1, 7, 8, 9,
1844 -1, -1, -1, 148, -1, -1, 16, 17, -1, 19,
1845 20, 21, 22, 23, 24, 23, 24, -1, -1, -1,
1846 -1, -1, -1, -1, -1, -1, 549, 37, 38, -1,
1847 -1, 554, 87, 88, 89, 90, 91, 92, 93, 94,
1848 95, 96, -1, -1, 54, -1, -1, -1, 571, 572,
1849 -1, -1, -1, 576, -1, -1, 579, -1, -1, -1,
1850 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1851 80, 81, 82, 83, 84, 85, 86, -1, -1, -1,
1852 -1, -1, -1, -1, -1, 93, 94, 95, 96, 97,
1853 98, 99, 100, 101, 102, 103, 104, 105, 106, -1,
1854 -1, -1, 112, 113, 114, 115, 116, 117, 118, 119,
1855 120, 121, 122, 123, 124, -1, 126, -1, 128, 129,
1856 130, -1, -1, 3, 4, -1, -1, 7, 8, 9,
1857 -1, 141, -1, 143, -1, -1, 16, 17, 148, 19,
1858 20, 21, 22, 23, 24, -1, -1, -1, -1, -1,
1859 7, 8, -1, -1, -1, -1, -1, 37, 38, 16,
1860 17, -1, 19, 20, 21, 22, -1, -1, -1, -1,
1861 -1, -1, -1, -1, 54, -1, -1, -1, -1, -1,
1862 37, 38, -1, -1, -1, -1, -1, -1, -1, -1,
1863 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1864 80, 81, 82, 83, 84, 85, 86, -1, -1, -1,
1865 -1, -1, -1, 70, 71, 72, 73, 74, 75, 76,
1866 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1867 -1, -1, 112, 113, 114, 115, 116, 117, 118, 119,
1868 120, 121, 122, 123, 124, -1, 126, -1, 128, 129,
1869 130, -1, -1, -1, -1, 112, 113, 114, 115, 116,
1870 117, 118, 119, 120, 121, 122, 123, 124, 148, 126,
1871 -1, 128, 129, 130, -1, -1, -1, -1, -1, -1,
1872 -1, -1, -1, -1, 141, -1, 143, -1, 145, -1,
1873 -1, 148, -1, 150, -1, 152, 7, 8, -1, 10,
1874 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
1875 21, 7, 8, -1, 10, 11, 12, 13, 14, -1,
1876 16, 17, -1, 19, 20, 21, -1, 7, 8, -1,
1877 10, 11, 12, 13, 14, 46, 16, 17, -1, 19,
1878 20, 21, 7, 8, -1, 10, 11, 12, 13, 14,
1879 46, 16, 17, -1, 19, 20, 21, -1, -1, -1,
1880 -1, -1, -1, -1, -1, -1, 46, -1, -1, -1,
1881 -1, 36, -1, 7, 8, -1, 10, 11, 12, 13,
1882 14, 46, 16, 17, -1, 19, 20, 21, 7, 8,
1883 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
1884 19, 20, 21, -1, -1, 0, -1, -1, -1, -1,
1885 -1, -1, 46, -1, -1, -1, -1, 36, -1, -1,
1886 15, 16, 17, -1, 19, 20, 21, 46, -1, -1,
1887 -1, 142, 27, 28, 145, -1, -1, 148, -1, 150,
1888 151, -1, -1, -1, -1, -1, 142, -1, -1, 145,
1889 -1, -1, 148, 48, 150, 151, 51, -1, -1, -1,
1890 55, -1, 142, -1, -1, 145, -1, -1, 148, -1,
1891 150, 151, -1, -1, -1, -1, -1, 142, -1, -1,
1892 145, -1, -1, 148, 118, 150, 7, 8, -1, 10,
1893 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
1894 21, -1, -1, -1, -1, -1, -1, -1, 142, -1,
1895 -1, 145, -1, -1, 148, -1, 150, -1, -1, -1,
1896 -1, -1, -1, 142, -1, 46, 145, -1, -1, 148,
1897 -1, 150, 7, 8, -1, 10, 11, 12, 13, 14,
1898 -1, 16, 17, -1, 19, 20, 21, -1, -1, -1,
1899 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
1900 17, 36, 19, 20, 21, -1, -1, -1, -1, -1,
1901 -1, 46, -1, -1, -1, -1, -1, -1, -1, 36,
1902 -1, 7, 8, -1, 10, 11, 12, 13, 14, 46,
1903 16, 17, -1, 19, 20, 21, 7, 8, -1, 10,
1904 11, 12, 13, 14, -1, 16, 17, -1, 19, 20,
1905 21, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1906 46, 142, -1, -1, 145, -1, 147, 148, -1, 150,
1907 -1, -1, -1, 7, 8, 46, 10, 11, 12, 13,
1908 14, -1, 16, 17, -1, 19, 20, 21, 7, 8,
1909 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
1910 19, 20, 21, -1, -1, -1, -1, 142, -1, -1,
1911 145, -1, 46, 148, -1, 150, -1, -1, -1, -1,
1912 -1, -1, -1, -1, -1, 142, -1, 46, 145, -1,
1913 -1, 148, -1, 150, 7, 8, -1, 10, 11, 12,
1914 13, 14, -1, 16, 17, -1, 19, 20, 21, -1,
1915 -1, -1, -1, -1, -1, -1, 142, -1, -1, 145,
1916 -1, -1, 148, -1, 150, -1, -1, -1, -1, -1,
1917 -1, 142, -1, 46, 145, -1, -1, 148, -1, 150,
1918 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
1919 17, -1, 19, 20, 21, -1, -1, -1, -1, -1,
1920 -1, -1, -1, -1, -1, 33, -1, -1, 142, -1,
1921 -1, 145, -1, -1, 148, -1, 150, -1, -1, 46,
1922 -1, -1, -1, 142, 52, 53, 145, -1, -1, 148,
1923 -1, 150, -1, -1, -1, -1, 64, 65, 66, 67,
1924 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1925 78, 79, 80, 81, 82, 83, 84, 85, 86, -1,
1926 -1, -1, -1, -1, -1, -1, -1, -1, -1, 142,
1927 -1, -1, 145, -1, -1, 148, -1, 150, -1, 107,
1928 108, 109, -1, -1, 112, 113, 114, 115, 116, 117,
1929 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
1930 128, 129, 130, -1, -1, -1, -1, -1, -1, 0,
1931 -1, -1, -1, -1, -1, 142, -1, -1, 145, -1,
1932 -1, 148, -1, 150, 15, 16, 17, -1, 19, 20,
1933 21, -1, -1, -1, -1, -1, 27, 28, -1, -1,
1934 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1935 -1, -1, -1, -1, -1, -1, -1, 48, -1, -1,
1936 51, -1, -1, -1, 55
1937};
1938/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1939#line 3 "/usr/share/bison.simple"
1940/* This file comes from bison-1.28. */
1941
1942/* Skeleton output parser for bison,
1943 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1944
1945 This program is free software; you can redistribute it and/or modify
1946 it under the terms of the GNU General Public License as published by
1947 the Free Software Foundation; either version 2, or (at your option)
1948 any later version.
1949
1950 This program is distributed in the hope that it will be useful,
1951 but WITHOUT ANY WARRANTY; without even the implied warranty of
1952 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1953 GNU General Public License for more details.
1954
1955 You should have received a copy of the GNU General Public License
1956 along with this program; if not, write to the Free Software
1957 Foundation, Inc., 59 Temple Place - Suite 330,
1958 Boston, MA 02111-1307, USA. */
1959
1960/* As a special exception, when this file is copied by Bison into a
1961 Bison output file, you may use that output file without restriction.
1962 This special exception was added by the Free Software Foundation
1963 in version 1.24 of Bison. */
1964
1965/* This is the parser code that is written into each bison parser
1966 when the %semantic_parser declaration is not specified in the grammar.
1967 It was written by Richard Stallman by simplifying the hairy parser
1968 used when %semantic_parser is specified. */
1969
1970#ifndef YYSTACK_USE_ALLOCA
1971#ifdef alloca
1972#define YYSTACK_USE_ALLOCA
1973#else /* alloca not defined */
1974#ifdef __GNUC__
1975#define YYSTACK_USE_ALLOCA
1976#define alloca __builtin_alloca
1977#else /* not GNU C. */
1978#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1979#define YYSTACK_USE_ALLOCA
1980#include <alloca.h>
1981#else /* not sparc */
1982/* We think this test detects Watcom and Microsoft C. */
1983/* This used to test MSDOS, but that is a bad idea
1984 since that symbol is in the user namespace. */
1985#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1986#if 0 /* No need for malloc.h, which pollutes the namespace;
1987 instead, just don't use alloca. */
1988#include <malloc.h>
1989#endif
1990#else /* not MSDOS, or __TURBOC__ */
1991#if defined(_AIX)
1992/* I don't know what this was needed for, but it pollutes the namespace.
1993 So I turned it off. rms, 2 May 1997. */
1994/* #include <malloc.h> */
1995 #pragma alloca
1996#define YYSTACK_USE_ALLOCA
1997#else /* not MSDOS, or __TURBOC__, or _AIX */
1998#if 0
1999#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2000 and on HPUX 10. Eventually we can turn this on. */
2001#define YYSTACK_USE_ALLOCA
2002#define alloca __builtin_alloca
2003#endif /* __hpux */
2004#endif
2005#endif /* not _AIX */
2006#endif /* not MSDOS, or __TURBOC__ */
2007#endif /* not sparc */
2008#endif /* not GNU C */
2009#endif /* alloca not defined */
2010#endif /* YYSTACK_USE_ALLOCA not defined */
2011
2012#ifdef YYSTACK_USE_ALLOCA
2013#define YYSTACK_ALLOC alloca
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002014#else
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002015#define YYSTACK_ALLOC malloc
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002016#endif
2017
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002018/* Note: there must be only one dollar sign in this file.
2019 It is replaced by the list of actions, each action
2020 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002021
2022#define yyerrok (yyerrstatus = 0)
2023#define yyclearin (yychar = YYEMPTY)
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002024#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00002025#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00002026#define YYACCEPT goto yyacceptlab
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002027#define YYABORT goto yyabortlab
2028#define YYERROR goto yyerrlab1
2029/* Like YYERROR except do call yyerror.
2030 This remains here temporarily to ease the
2031 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002032 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002033#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00002034#define YYRECOVERING() (!!yyerrstatus)
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002035#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002036do \
2037 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002038 { yychar = (token), yylval = (value); \
2039 yychar1 = YYTRANSLATE (yychar); \
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002040 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002041 goto yybackup; \
2042 } \
2043 else \
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002044 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002045while (0)
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002046
Reid Spencer68a24bd2005-08-27 18:50:39 +00002047#define YYTERROR 1
2048#define YYERRCODE 256
2049
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002050#ifndef YYPURE
2051#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00002052#endif
2053
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002054#ifdef YYPURE
2055#ifdef YYLSP_NEEDED
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002056#ifdef YYLEX_PARAM
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002057#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002058#else
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002059#define YYLEX yylex(&yylval, &yylloc)
2060#endif
2061#else /* not YYLSP_NEEDED */
2062#ifdef YYLEX_PARAM
2063#define YYLEX yylex(&yylval, YYLEX_PARAM)
2064#else
2065#define YYLEX yylex(&yylval)
2066#endif
2067#endif /* not YYLSP_NEEDED */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002068#endif
Reid Spencered951ea2007-05-19 07:22:10 +00002069
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002070/* If nonreentrant, generate the variables here */
Reid Spencered951ea2007-05-19 07:22:10 +00002071
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002072#ifndef YYPURE
Reid Spencered951ea2007-05-19 07:22:10 +00002073
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002074int yychar; /* the lookahead symbol */
2075YYSTYPE yylval; /* the semantic value of the */
2076 /* lookahead symbol */
Reid Spencered951ea2007-05-19 07:22:10 +00002077
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002078#ifdef YYLSP_NEEDED
2079YYLTYPE yylloc; /* location data for the lookahead */
2080 /* symbol */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002081#endif
Reid Spencered951ea2007-05-19 07:22:10 +00002082
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002083int yynerrs; /* number of parse errors so far */
2084#endif /* not YYPURE */
Reid Spencered951ea2007-05-19 07:22:10 +00002085
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002086#if YYDEBUG != 0
2087int yydebug; /* nonzero means print parse trace */
2088/* Since this is uninitialized, it does not stop multiple parsers
2089 from coexisting. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002090#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002091
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002092/* YYINITDEPTH indicates the initial size of the parser's stacks */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002093
Reid Spencer68a24bd2005-08-27 18:50:39 +00002094#ifndef YYINITDEPTH
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002095#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002096#endif
2097
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002098/* YYMAXDEPTH is the maximum size the stacks can grow to
2099 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002100
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002101#if YYMAXDEPTH == 0
2102#undef YYMAXDEPTH
2103#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002104
2105#ifndef YYMAXDEPTH
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002106#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002107#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002108
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002109/* Define __yy_memcpy. Note that the size argument
2110 should be passed with type unsigned int, because that is what the non-GCC
2111 definitions require. With GCC, __builtin_memcpy takes an arg
2112 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002113
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002114#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2115#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2116#else /* not GNU C or C++ */
2117#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00002118
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002119/* This is the most reliable way to avoid incompatibilities
2120 in available built-in functions on various systems. */
Reid Spencered951ea2007-05-19 07:22:10 +00002121static void
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002122__yy_memcpy (to, from, count)
2123 char *to;
2124 char *from;
2125 unsigned int count;
2126{
2127 register char *f = from;
2128 register char *t = to;
2129 register int i = count;
2130
2131 while (i-- > 0)
2132 *t++ = *f++;
2133}
2134
2135#else /* __cplusplus */
2136
2137/* This is the most reliable way to avoid incompatibilities
2138 in available built-in functions on various systems. */
Reid Spencered951ea2007-05-19 07:22:10 +00002139static void
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002140__yy_memcpy (char *to, char *from, unsigned int count)
2141{
2142 register char *t = to;
2143 register char *f = from;
2144 register int i = count;
2145
2146 while (i-- > 0)
2147 *t++ = *f++;
2148}
2149
Reid Spencered951ea2007-05-19 07:22:10 +00002150#endif
Reid Spencered951ea2007-05-19 07:22:10 +00002151#endif
Reid Spencered951ea2007-05-19 07:22:10 +00002152
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002153#line 217 "/usr/share/bison.simple"
Reid Spencered951ea2007-05-19 07:22:10 +00002154
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002155/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2156 into yyparse. The argument should have type void *.
2157 It should actually point to an object.
2158 Grammar actions can access the variable by casting it
2159 to the proper pointer type. */
Reid Spencered951ea2007-05-19 07:22:10 +00002160
2161#ifdef YYPARSE_PARAM
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002162#ifdef __cplusplus
2163#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2164#define YYPARSE_PARAM_DECL
2165#else /* not __cplusplus */
2166#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2167#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2168#endif /* not __cplusplus */
2169#else /* not YYPARSE_PARAM */
2170#define YYPARSE_PARAM_ARG
2171#define YYPARSE_PARAM_DECL
2172#endif /* not YYPARSE_PARAM */
2173
2174/* Prevent warning if -Wstrict-prototypes. */
2175#ifdef __GNUC__
2176#ifdef YYPARSE_PARAM
2177int yyparse (void *);
2178#else
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002179int yyparse (void);
Reid Spencered951ea2007-05-19 07:22:10 +00002180#endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002181#endif
Reid Spencered951ea2007-05-19 07:22:10 +00002182
Reid Spencered951ea2007-05-19 07:22:10 +00002183int
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002184yyparse(YYPARSE_PARAM_ARG)
2185 YYPARSE_PARAM_DECL
Reid Spencered951ea2007-05-19 07:22:10 +00002186{
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002187 register int yystate;
2188 register int yyn;
2189 register short *yyssp;
2190 register YYSTYPE *yyvsp;
2191 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2192 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencered951ea2007-05-19 07:22:10 +00002193
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002194 short yyssa[YYINITDEPTH]; /* the state stack */
2195 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencered951ea2007-05-19 07:22:10 +00002196
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002197 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2198 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencered951ea2007-05-19 07:22:10 +00002199
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002200#ifdef YYLSP_NEEDED
2201 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2202 YYLTYPE *yyls = yylsa;
2203 YYLTYPE *yylsp;
Reid Spencered951ea2007-05-19 07:22:10 +00002204
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002205#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2206#else
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002207#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002208#endif
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00002209
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002210 int yystacksize = YYINITDEPTH;
2211 int yyfree_stacks = 0;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002212
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002213#ifdef YYPURE
2214 int yychar;
2215 YYSTYPE yylval;
2216 int yynerrs;
2217#ifdef YYLSP_NEEDED
2218 YYLTYPE yylloc;
2219#endif
2220#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002221
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002222 YYSTYPE yyval; /* the variable used to return */
2223 /* semantic values from the action */
2224 /* routines */
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002225
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002226 int yylen;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002227
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002228#if YYDEBUG != 0
2229 if (yydebug)
2230 fprintf(stderr, "Starting parse\n");
2231#endif
Anton Korobeynikov38e09802007-04-28 13:48:45 +00002232
Reid Spencer68a24bd2005-08-27 18:50:39 +00002233 yystate = 0;
2234 yyerrstatus = 0;
2235 yynerrs = 0;
2236 yychar = YYEMPTY; /* Cause a token to be read. */
2237
2238 /* Initialize stack pointers.
2239 Waste one element of value and location stack
2240 so that they stay on the same level as the state stack.
2241 The wasted elements are never initialized. */
2242
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002243 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002244 yyvsp = yyvs;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002245#ifdef YYLSP_NEEDED
2246 yylsp = yyls;
2247#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002248
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002249/* Push a new state, which is found in yystate . */
2250/* In all cases, when you get here, the value and location stacks
2251 have just been pushed. so pushing a state here evens the stacks. */
2252yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002253
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002254 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002255
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002256 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002257 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002258 /* Give user a chance to reallocate the stack */
2259 /* Use copies of these so that the &'s don't force the real ones into memory. */
2260 YYSTYPE *yyvs1 = yyvs;
2261 short *yyss1 = yyss;
2262#ifdef YYLSP_NEEDED
2263 YYLTYPE *yyls1 = yyls;
2264#endif
2265
Reid Spencer68a24bd2005-08-27 18:50:39 +00002266 /* Get the current used size of the three stacks, in elements. */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002267 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002268
2269#ifdef yyoverflow
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002270 /* Each stack pointer address is followed by the size of
2271 the data in use in that stack, in bytes. */
2272#ifdef YYLSP_NEEDED
2273 /* This used to be a conditional around just the two extra args,
2274 but that might be undefined if yyoverflow is a macro. */
2275 yyoverflow("parser stack overflow",
2276 &yyss1, size * sizeof (*yyssp),
2277 &yyvs1, size * sizeof (*yyvsp),
2278 &yyls1, size * sizeof (*yylsp),
2279 &yystacksize);
2280#else
2281 yyoverflow("parser stack overflow",
2282 &yyss1, size * sizeof (*yyssp),
2283 &yyvs1, size * sizeof (*yyvsp),
2284 &yystacksize);
2285#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002286
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002287 yyss = yyss1; yyvs = yyvs1;
2288#ifdef YYLSP_NEEDED
2289 yyls = yyls1;
2290#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002291#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002292 /* Extend the stack our own way. */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002293 if (yystacksize >= YYMAXDEPTH)
2294 {
2295 yyerror("parser stack overflow");
2296 if (yyfree_stacks)
2297 {
2298 free (yyss);
2299 free (yyvs);
2300#ifdef YYLSP_NEEDED
2301 free (yyls);
2302#endif
2303 }
2304 return 2;
2305 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002306 yystacksize *= 2;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002307 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002308 yystacksize = YYMAXDEPTH;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002309#ifndef YYSTACK_USE_ALLOCA
2310 yyfree_stacks = 1;
2311#endif
2312 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2313 __yy_memcpy ((char *)yyss, (char *)yyss1,
2314 size * (unsigned int) sizeof (*yyssp));
2315 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2316 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2317 size * (unsigned int) sizeof (*yyvsp));
2318#ifdef YYLSP_NEEDED
2319 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2320 __yy_memcpy ((char *)yyls, (char *)yyls1,
2321 size * (unsigned int) sizeof (*yylsp));
2322#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002323#endif /* no yyoverflow */
2324
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002325 yyssp = yyss + size - 1;
2326 yyvsp = yyvs + size - 1;
2327#ifdef YYLSP_NEEDED
2328 yylsp = yyls + size - 1;
2329#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002330
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002331#if YYDEBUG != 0
2332 if (yydebug)
2333 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2334#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002335
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002336 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002337 YYABORT;
2338 }
2339
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002340#if YYDEBUG != 0
2341 if (yydebug)
2342 fprintf(stderr, "Entering state %d\n", yystate);
2343#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002344
2345 goto yybackup;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002346 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002347
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002348/* Do appropriate processing given the current state. */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002349/* Read a lookahead token if we need one and don't already have one. */
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002350/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002351
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002352 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer7780acb2007-04-16 06:56:07 +00002353
Reid Spencer68a24bd2005-08-27 18:50:39 +00002354 yyn = yypact[yystate];
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002355 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002356 goto yydefault;
2357
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002358 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002359
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002360 /* yychar is either YYEMPTY or YYEOF
2361 or a valid token in external form. */
2362
Reid Spencer68a24bd2005-08-27 18:50:39 +00002363 if (yychar == YYEMPTY)
2364 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002365#if YYDEBUG != 0
2366 if (yydebug)
2367 fprintf(stderr, "Reading a token: ");
2368#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002369 yychar = YYLEX;
2370 }
2371
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002372 /* Convert token to internal form (in yychar1) for indexing tables with */
2373
2374 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002375 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002376 yychar1 = 0;
2377 yychar = YYEOF; /* Don't call YYLEX any more */
2378
2379#if YYDEBUG != 0
2380 if (yydebug)
2381 fprintf(stderr, "Now at end of input.\n");
2382#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002383 }
2384 else
2385 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002386 yychar1 = YYTRANSLATE(yychar);
2387
2388#if YYDEBUG != 0
2389 if (yydebug)
2390 {
2391 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2392 /* Give the individual parser a way to print the precise meaning
2393 of a token, for further debugging info. */
2394#ifdef YYPRINT
2395 YYPRINT (stderr, yychar, yylval);
2396#endif
2397 fprintf (stderr, ")\n");
2398 }
2399#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002400 }
2401
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002402 yyn += yychar1;
2403 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002404 goto yydefault;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002405
Reid Spencer68a24bd2005-08-27 18:50:39 +00002406 yyn = yytable[yyn];
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002407
2408 /* yyn is what to do for this token type in this state.
2409 Negative => reduce, -yyn is rule number.
2410 Positive => shift, yyn is new state.
2411 New state is final state => don't bother to shift,
2412 just return success.
2413 0, or most negative number => error. */
2414
2415 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002416 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002417 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002418 goto yyerrlab;
2419 yyn = -yyn;
2420 goto yyreduce;
2421 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002422 else if (yyn == 0)
2423 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002424
2425 if (yyn == YYFINAL)
2426 YYACCEPT;
2427
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002428 /* Shift the lookahead token. */
2429
2430#if YYDEBUG != 0
2431 if (yydebug)
2432 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2433#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002434
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002435 /* Discard the token being shifted unless it is eof. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002436 if (yychar != YYEOF)
2437 yychar = YYEMPTY;
2438
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002439 *++yyvsp = yylval;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002440#ifdef YYLSP_NEEDED
2441 *++yylsp = yylloc;
2442#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002443
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002444 /* count tokens shifted since error; after three, turn off error status. */
2445 if (yyerrstatus) yyerrstatus--;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00002446
2447 yystate = yyn;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002448 goto yynewstate;
2449
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002450/* Do the default action for the current state. */
Reid Spencered951ea2007-05-19 07:22:10 +00002451yydefault:
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002452
Reid Spencer68a24bd2005-08-27 18:50:39 +00002453 yyn = yydefact[yystate];
2454 if (yyn == 0)
2455 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002456
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002457/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002458yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002459 yylen = yyr2[yyn];
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002460 if (yylen > 0)
2461 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002462
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002463#if YYDEBUG != 0
2464 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002465 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002466 int i;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002467
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002468 fprintf (stderr, "Reducing via rule %d (line %d), ",
2469 yyn, yyrline[yyn]);
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002470
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002471 /* Print the symbols being reduced, and their result. */
2472 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2473 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2474 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2475 }
2476#endif
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002477
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002478
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002479 switch (yyn) {
Reid Spencerb0fcf8f2007-01-17 02:48:45 +00002480
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002481case 28:
2482#line 1122 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2483{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2484 break;}
2485case 29:
2486#line 1122 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2487{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2488 break;}
2489case 30:
2490#line 1123 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2491{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2492 break;}
2493case 31:
2494#line 1123 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2495{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2496 break;}
2497case 32:
2498#line 1124 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2499{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2500 break;}
2501case 33:
2502#line 1124 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2503{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2504 break;}
2505case 34:
2506#line 1125 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2507{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2508 break;}
2509case 35:
2510#line 1125 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2511{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2512 break;}
2513case 36:
2514#line 1126 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2515{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2516 break;}
2517case 37:
2518#line 1126 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2519{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2520 break;}
2521case 38:
2522#line 1130 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2523{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2524 break;}
2525case 39:
2526#line 1130 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2527{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2528 break;}
2529case 40:
2530#line 1131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2531{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2532 break;}
2533case 41:
2534#line 1131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2535{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2536 break;}
2537case 42:
2538#line 1132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2539{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2540 break;}
2541case 43:
2542#line 1132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2543{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2544 break;}
2545case 44:
2546#line 1133 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2547{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2548 break;}
2549case 45:
2550#line 1133 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2551{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2552 break;}
2553case 46:
2554#line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2555{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2556 break;}
2557case 47:
2558#line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2559{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2560 break;}
2561case 48:
2562#line 1135 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2563{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2564 break;}
2565case 49:
2566#line 1135 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2567{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2568 break;}
2569case 50:
2570#line 1136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2571{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2572 break;}
2573case 51:
2574#line 1136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2575{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2576 break;}
2577case 52:
2578#line 1137 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2579{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2580 break;}
2581case 53:
2582#line 1138 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2583{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2584 break;}
2585case 61:
2586#line 1147 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2587{ yyval.StrVal = 0; ;
2588 break;}
2589case 62:
2590#line 1151 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2591{
2592 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002593 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002594 ;
2595 break;}
2596case 63:
2597#line 1155 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2598{
2599 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002600 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002601 ;
2602 break;}
2603case 67:
2604#line 1163 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2605{
2606 yyval.StrVal = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002607 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002608 ;
2609 break;}
2610case 68:
2611#line 1168 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2612{
2613 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002614 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002615 ;
2616 break;}
2617case 69:
2618#line 1174 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2619{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2620 break;}
2621case 70:
2622#line 1175 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2623{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2624 break;}
2625case 71:
2626#line 1176 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2627{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2628 break;}
2629case 72:
2630#line 1177 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2631{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2632 break;}
2633case 73:
2634#line 1178 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2635{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2636 break;}
2637case 74:
2638#line 1182 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2639{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2640 break;}
2641case 75:
2642#line 1183 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2643{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2644 break;}
2645case 76:
2646#line 1184 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2647{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2648 break;}
2649case 77:
2650#line 1188 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2651{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2652 break;}
2653case 78:
2654#line 1189 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2655{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2656 break;}
2657case 79:
2658#line 1190 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2659{ yyval.Visibility = GlobalValue::HiddenVisibility; ;
2660 break;}
2661case 80:
2662#line 1191 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2663{ yyval.Visibility = GlobalValue::ProtectedVisibility; ;
2664 break;}
2665case 81:
2666#line 1195 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2667{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2668 break;}
2669case 82:
2670#line 1196 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2671{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2672 break;}
2673case 83:
2674#line 1197 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2675{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2676 break;}
2677case 84:
2678#line 1201 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2679{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2680 break;}
2681case 85:
2682#line 1202 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2683{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2684 break;}
2685case 86:
2686#line 1203 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2687{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2688 break;}
2689case 87:
2690#line 1204 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2691{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2692 break;}
2693case 88:
2694#line 1205 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2695{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2696 break;}
2697case 89:
2698#line 1209 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2699{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2700 break;}
2701case 90:
2702#line 1210 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2703{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2704 break;}
2705case 91:
2706#line 1211 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2707{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2708 break;}
2709case 92:
2710#line 1214 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2711{ yyval.UIntVal = CallingConv::C; ;
2712 break;}
2713case 93:
2714#line 1215 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2715{ yyval.UIntVal = CallingConv::C; ;
2716 break;}
2717case 94:
2718#line 1216 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2719{ yyval.UIntVal = CallingConv::Fast; ;
2720 break;}
2721case 95:
2722#line 1217 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2723{ yyval.UIntVal = CallingConv::Cold; ;
2724 break;}
2725case 96:
2726#line 1218 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2727{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2728 break;}
2729case 97:
2730#line 1219 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2731{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2732 break;}
2733case 98:
2734#line 1220 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2735{
2736 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002737 GEN_ERROR("Calling conv too large");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002738 yyval.UIntVal = yyvsp[0].UInt64Val;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002739 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002740 ;
2741 break;}
2742case 99:
2743#line 1227 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2744{ yyval.ParamAttrs = ParamAttr::ZExt; ;
2745 break;}
2746case 100:
2747#line 1228 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2748{ yyval.ParamAttrs = ParamAttr::SExt; ;
2749 break;}
2750case 101:
2751#line 1229 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2752{ yyval.ParamAttrs = ParamAttr::InReg; ;
2753 break;}
2754case 102:
2755#line 1230 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2756{ yyval.ParamAttrs = ParamAttr::StructRet; ;
2757 break;}
2758case 103:
2759#line 1231 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2760{ yyval.ParamAttrs = ParamAttr::NoAlias; ;
2761 break;}
2762case 104:
2763#line 1234 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2764{ yyval.ParamAttrs = ParamAttr::None; ;
2765 break;}
2766case 105:
2767#line 1235 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2768{
2769 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2770 ;
2771 break;}
2772case 106:
2773#line 1240 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2774{ yyval.ParamAttrs = ParamAttr::NoReturn; ;
2775 break;}
2776case 107:
2777#line 1241 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2778{ yyval.ParamAttrs = ParamAttr::NoUnwind; ;
2779 break;}
2780case 109:
2781#line 1245 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2782{ yyval.ParamAttrs = ParamAttr::None; ;
2783 break;}
2784case 110:
2785#line 1246 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2786{
2787 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2788 ;
2789 break;}
2790case 111:
2791#line 1253 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2792{ yyval.UIntVal = 0; ;
2793 break;}
2794case 112:
2795#line 1254 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2796{
2797 yyval.UIntVal = yyvsp[0].UInt64Val;
2798 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002799 GEN_ERROR("Alignment must be a power of two");
2800 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002801;
2802 break;}
2803case 113:
2804#line 1260 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2805{ yyval.UIntVal = 0; ;
2806 break;}
2807case 114:
2808#line 1261 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2809{
2810 yyval.UIntVal = yyvsp[0].UInt64Val;
2811 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002812 GEN_ERROR("Alignment must be a power of two");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002813 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002814;
2815 break;}
2816case 115:
2817#line 1269 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2818{
2819 for (unsigned i = 0, e = yyvsp[0].StrVal->length(); i != e; ++i)
2820 if ((*yyvsp[0].StrVal)[i] == '"' || (*yyvsp[0].StrVal)[i] == '\\')
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002821 GEN_ERROR("Invalid character in section name");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002822 yyval.StrVal = yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002823 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002824;
2825 break;}
2826case 116:
2827#line 1277 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2828{ yyval.StrVal = 0; ;
2829 break;}
2830case 117:
2831#line 1278 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2832{ yyval.StrVal = yyvsp[0].StrVal; ;
2833 break;}
2834case 118:
2835#line 1283 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2836{;
2837 break;}
2838case 119:
2839#line 1284 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2840{;
2841 break;}
2842case 120:
2843#line 1285 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2844{
2845 CurGV->setSection(*yyvsp[0].StrVal);
2846 delete yyvsp[0].StrVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002847 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002848 ;
2849 break;}
2850case 121:
2851#line 1290 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2852{
2853 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002854 GEN_ERROR("Alignment must be a power of two");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002855 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer41dff5e2007-01-26 08:05:27 +00002856 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002857 ;
2858 break;}
2859case 126:
2860#line 1306 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2861{
2862 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00002863 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002864 ;
2865 break;}
2866case 127:
2867#line 1310 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2868{
2869 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002870 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002871 ;
2872 break;}
2873case 128:
2874#line 1314 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2875{ // Pointer type?
2876 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002877 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002878 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2879 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00002880 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002881 ;
2882 break;}
2883case 129:
2884#line 1321 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2885{ // Named types are also simple types...
2886 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00002887 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002888 yyval.TypeVal = new PATypeHolder(tmp);
2889 ;
2890 break;}
2891case 130:
2892#line 1326 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2893{ // Type UpReference
2894 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002895 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002896 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2897 yyval.TypeVal = new PATypeHolder(OT);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002898 UR_OUT("New Upreference!\n");
2899 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002900 ;
2901 break;}
2902case 131:
2903#line 1334 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2904{
Reid Spencer41dff5e2007-01-26 08:05:27 +00002905 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00002906 ParamAttrsVector Attrs;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002907 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
2908 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00002909 Attrs.push_back(X);
2910 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00002911 unsigned index = 1;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002912 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00002913 for (; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00002914 const Type *Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00002915 Params.push_back(Ty);
2916 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00002917 if (I->Attrs != ParamAttr::None) {
2918 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
2919 Attrs.push_back(X);
2920 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00002921 }
2922 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2923 if (isVarArg) Params.pop_back();
2924
Reid Spencer7b5d4662007-04-09 06:16:21 +00002925 ParamAttrsList *ActualAttrs = 0;
2926 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00002927 ActualAttrs = ParamAttrsList::get(Attrs);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002928 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs);
2929 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2930 delete yyvsp[-4].TypeVal; // Delete the return type handle
2931 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00002932 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002933 ;
2934 break;}
2935case 132:
2936#line 1364 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2937{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002938 std::vector<const Type*> Params;
Christopher Lamb5c104242007-04-22 20:09:11 +00002939 ParamAttrsVector Attrs;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002940 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
2941 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00002942 Attrs.push_back(X);
2943 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002944 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00002945 unsigned index = 1;
2946 for ( ; I != E; ++I, ++index) {
Reid Spencer66728ef2007-03-20 01:13:36 +00002947 const Type* Ty = I->Ty->get();
Reid Spencer66728ef2007-03-20 01:13:36 +00002948 Params.push_back(Ty);
2949 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00002950 if (I->Attrs != ParamAttr::None) {
2951 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
2952 Attrs.push_back(X);
2953 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00002954 }
2955 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2956 if (isVarArg) Params.pop_back();
2957
Reid Spencer7b5d4662007-04-09 06:16:21 +00002958 ParamAttrsList *ActualAttrs = 0;
2959 if (!Attrs.empty())
Christopher Lamb5c104242007-04-22 20:09:11 +00002960 ActualAttrs = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00002961
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002962 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs);
2963 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2964 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer41dff5e2007-01-26 08:05:27 +00002965 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002966 ;
2967 break;}
2968case 133:
2969#line 1395 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2970{ // Sized array type?
2971 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2972 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002973 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002974 ;
2975 break;}
2976case 134:
2977#line 1400 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2978{ // Vector type?
2979 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2980 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002981 GEN_ERROR("Unsigned result not equal to signed result");
2982 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
2983 GEN_ERROR("Element type of a VectorType must be primitive");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002984 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002985 GEN_ERROR("Vector length should be a power of 2");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002986 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2987 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002988 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002989 ;
2990 break;}
2991case 135:
2992#line 1412 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2993{ // Structure type?
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002994 std::vector<const Type*> Elements;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002995 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2996 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00002997 Elements.push_back(*I);
2998
Chris Lattnerce5f24e2007-07-05 17:26:49 +00002999 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3000 delete yyvsp[-1].TypeList;
Reid Spencer14310612006-12-31 05:40:51 +00003001 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003002 ;
3003 break;}
3004case 136:
3005#line 1422 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3006{ // Empty structure type?
3007 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer14310612006-12-31 05:40:51 +00003008 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003009 ;
3010 break;}
3011case 137:
3012#line 1426 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3013{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003014 std::vector<const Type*> Elements;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003015 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
3016 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003017 Elements.push_back(*I);
3018
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003019 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
3020 delete yyvsp[-2].TypeList;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003021 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003022 ;
3023 break;}
3024case 138:
3025#line 1436 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3026{ // Empty structure type?
3027 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003028 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003029 ;
3030 break;}
3031case 139:
3032#line 1443 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3033{
3034 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3035 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
3036 ;
3037 break;}
3038case 140:
3039#line 1450 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3040{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003041 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003042 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3043 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003044 GEN_ERROR("LLVM functions cannot return aggregate types");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003045 yyval.TypeVal = yyvsp[0].TypeVal;
3046 ;
3047 break;}
3048case 141:
3049#line 1457 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3050{
3051 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
3052 ;
3053 break;}
3054case 142:
3055#line 1462 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3056{
3057 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3058 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer3da59db2006-11-27 01:05:10 +00003059 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003060 ;
3061 break;}
3062case 143:
3063#line 1467 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3064{
3065 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003066 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003067 ;
3068 break;}
3069case 145:
3070#line 1475 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3071{
3072 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer18da0722007-04-11 02:44:20 +00003073 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003074 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003075 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003076 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003077 ;
3078 break;}
3079case 146:
3080#line 1482 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3081{
3082 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003083 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3084 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003085 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003086 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003087 ;
3088 break;}
3089case 147:
3090#line 1489 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3091{
3092 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003093 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003094 ;
3095 break;}
3096case 148:
3097#line 1497 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3098{
3099 yyval.TypeList = new std::list<PATypeHolder>();
3100 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3101 delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00003102 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003103 ;
3104 break;}
3105case 149:
3106#line 1503 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3107{
3108 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3109 delete yyvsp[0].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003110 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003111 ;
3112 break;}
3113case 150:
3114#line 1515 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3115{ // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003116 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003117 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3118 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003119 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003120 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003121 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003122 const Type *ETy = ATy->getElementType();
3123 int NumElements = ATy->getNumElements();
3124
3125 // Verify that we have the correct size...
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003126 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003127 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003128 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003129 itostr(NumElements) + "");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003130
3131 // Verify all elements are correct type!
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003132 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3133 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003134 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3135 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003136 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003137 }
3138
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003139 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3140 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003141 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003142 ;
3143 break;}
3144case 151:
3145#line 1543 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3146{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003147 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003148 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3149 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003150 if (ATy == 0)
3151 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003152 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003153
Andrew Lenharth6353e052006-12-08 18:07:09 +00003154 int NumElements = ATy->getNumElements();
3155 if (NumElements != -1 && NumElements != 0)
3156 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerb5334b02007-02-05 10:18:06 +00003157 " arguments, but has size of " + itostr(NumElements) +"");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003158 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3159 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003160 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003161 ;
3162 break;}
3163case 152:
3164#line 1559 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3165{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003166 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003167 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3168 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003169 if (ATy == 0)
3170 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003171 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003172
3173 int NumElements = ATy->getNumElements();
3174 const Type *ETy = ATy->getElementType();
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003175 if (NumElements != -1 && NumElements != int(yyvsp[0].StrVal->length()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003176 GEN_ERROR("Can't build string constant of size " +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003177 itostr((int)(yyvsp[0].StrVal->length())) +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003178 " when array has size " + itostr(NumElements) + "");
3179 std::vector<Constant*> Vals;
3180 if (ETy == Type::Int8Ty) {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003181 for (unsigned i = 0; i < yyvsp[0].StrVal->length(); ++i)
3182 Vals.push_back(ConstantInt::get(ETy, (*yyvsp[0].StrVal)[i]));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003183 } else {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003184 delete yyvsp[0].StrVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003185 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3186 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003187 delete yyvsp[0].StrVal;
3188 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3189 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003190 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003191 ;
3192 break;}
3193case 153:
3194#line 1586 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3195{ // Nonempty unsized arr
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003196 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003197 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3198 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003199 if (PTy == 0)
3200 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003201 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003202 const Type *ETy = PTy->getElementType();
3203 int NumElements = PTy->getNumElements();
Reid Spencer41dff5e2007-01-26 08:05:27 +00003204
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003205 // Verify that we have the correct size...
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003206 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003207 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003208 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerb5334b02007-02-05 10:18:06 +00003209 itostr(NumElements) + "");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003210
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003211 // Verify all elements are correct type!
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003212 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3213 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003214 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3215 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003216 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003217 }
Reid Spencer41dff5e2007-01-26 08:05:27 +00003218
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003219 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3220 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003221 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003222 ;
3223 break;}
3224case 154:
3225#line 1614 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3226{
3227 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003228 if (STy == 0)
3229 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003230 (*yyvsp[-3].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003231
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003232 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003233 GEN_ERROR("Illegal number of initializers for structure type");
3234
3235 // Check to ensure that constants are compatible with the type initializer!
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003236 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3237 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003238 GEN_ERROR("Expected type '" +
3239 STy->getElementType(i)->getDescription() +
3240 "' for element #" + utostr(i) +
3241 " of structure initializer");
3242
3243 // Check to ensure that Type is not packed
3244 if (STy->isPacked())
3245 GEN_ERROR("Unpacked Initializer to vector type '" +
3246 STy->getDescription() + "'");
3247
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003248 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3249 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003250 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003251 ;
3252 break;}
3253case 155:
3254#line 1640 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3255{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003256 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003257 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3258 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003259 if (STy == 0)
3260 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003261 (*yyvsp[-2].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003262
3263 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003264 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003265
3266 // Check to ensure that Type is not packed
3267 if (STy->isPacked())
Chris Lattner6cdc6822007-04-26 05:31:05 +00003268 GEN_ERROR("Unpacked Initializer to vector type '" +
3269 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003270
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003271 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3272 delete yyvsp[-2].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003273 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003274 ;
3275 break;}
3276case 156:
3277#line 1660 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3278{
3279 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003280 if (STy == 0)
3281 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003282 (*yyvsp[-5].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003283
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003284 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencerb5334b02007-02-05 10:18:06 +00003285 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003286
3287 // Check to ensure that constants are compatible with the type initializer!
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003288 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3289 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer41dff5e2007-01-26 08:05:27 +00003290 GEN_ERROR("Expected type '" +
3291 STy->getElementType(i)->getDescription() +
3292 "' for element #" + utostr(i) +
Reid Spencerb5334b02007-02-05 10:18:06 +00003293 " of structure initializer");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003294
3295 // Check to ensure that Type is packed
3296 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003297 GEN_ERROR("Vector initializer to non-vector type '" +
3298 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003299
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003300 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3301 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003302 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003303 ;
3304 break;}
3305case 157:
3306#line 1686 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3307{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003308 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003309 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3310 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Reid Spencer41dff5e2007-01-26 08:05:27 +00003311 if (STy == 0)
3312 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003313 (*yyvsp[-4].TypeVal)->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003314
3315 if (STy->getNumContainedTypes() != 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003316 GEN_ERROR("Illegal number of initializers for structure type");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003317
3318 // Check to ensure that Type is packed
3319 if (!STy->isPacked())
Chris Lattner32980692007-02-19 07:44:24 +00003320 GEN_ERROR("Vector initializer to non-vector type '" +
3321 STy->getDescription() + "'");
Reid Spencer41dff5e2007-01-26 08:05:27 +00003322
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003323 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3324 delete yyvsp[-4].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003325 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003326 ;
3327 break;}
3328case 158:
3329#line 1706 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3330{
Reid Spencer41dff5e2007-01-26 08:05:27 +00003331 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003332 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3333 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003334 if (PTy == 0)
3335 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003336 (*yyvsp[-1].TypeVal)->getDescription() + "'");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003337
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003338 yyval.ConstVal = ConstantPointerNull::get(PTy);
3339 delete yyvsp[-1].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003340 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003341 ;
3342 break;}
3343case 159:
3344#line 1718 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3345{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003346 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003347 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3348 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3349 delete yyvsp[-1].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003350 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003351 ;
3352 break;}
3353case 160:
3354#line 1725 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3355{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003356 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003357 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3358 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003359 if (Ty == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00003360 GEN_ERROR("Global const reference must be a pointer type");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003361
3362 // ConstExprs can exist in the body of a function, thus creating
3363 // GlobalValues whenever they refer to a variable. Because we are in
Reid Spencer93c40032007-03-19 18:40:50 +00003364 // the context of a function, getExistingVal will search the functions
Reid Spencer68a24bd2005-08-27 18:50:39 +00003365 // symbol table instead of the module symbol table for the global symbol,
3366 // which throws things all off. To get around this, we just tell
Reid Spencer93c40032007-03-19 18:40:50 +00003367 // getExistingVal that we are at global scope here.
Reid Spencer68a24bd2005-08-27 18:50:39 +00003368 //
3369 Function *SavedCurFn = CurFun.CurrentFunction;
3370 CurFun.CurrentFunction = 0;
3371
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003372 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003373 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003374
3375 CurFun.CurrentFunction = SavedCurFn;
3376
3377 // If this is an initializer for a constant pointer, which is referencing a
3378 // (currently) undefined variable, create a stub now that shall be replaced
3379 // in the future with the right type of variable.
3380 //
3381 if (V == 0) {
Reid Spencera9720f52007-02-05 17:04:00 +00003382 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003383 const PointerType *PT = cast<PointerType>(Ty);
3384
3385 // First check to see if the forward references value is already created!
3386 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003387 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003388
3389 if (I != CurModule.GlobalRefs.end()) {
3390 V = I->second; // Placeholder already exists, use it...
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003391 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003392 } else {
3393 std::string Name;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003394 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
3395 Name = yyvsp[0].ValIDVal.getName();
3396 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
Reid Spencer41dff5e2007-01-26 08:05:27 +00003397 GEN_ERROR("Invalid reference to global");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003398
3399 // Create the forward referenced global.
3400 GlobalValue *GV;
3401 if (const FunctionType *FTy =
3402 dyn_cast<FunctionType>(PT->getElementType())) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00003403 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003404 CurModule.CurrentModule);
3405 } else {
3406 GV = new GlobalVariable(PT->getElementType(), false,
Chris Lattner6cdc6822007-04-26 05:31:05 +00003407 GlobalValue::ExternalWeakLinkage, 0,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003408 Name, CurModule.CurrentModule);
3409 }
3410
3411 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003412 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003413 V = GV;
3414 }
3415 }
3416
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003417 yyval.ConstVal = cast<GlobalValue>(V);
3418 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003419 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003420 ;
3421 break;}
3422case 161:
3423#line 1791 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3424{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003425 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003426 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3427 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003428 GEN_ERROR("Mismatched types for constant expression: " +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003429 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3430 yyval.ConstVal = yyvsp[0].ConstVal;
3431 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003432 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003433 ;
3434 break;}
3435case 162:
3436#line 1801 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3437{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003438 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003439 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3440 const Type *Ty = yyvsp[-1].TypeVal->get();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003441 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3442 GEN_ERROR("Cannot create a null initialized value of this type");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003443 yyval.ConstVal = Constant::getNullValue(Ty);
3444 delete yyvsp[-1].TypeVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003445 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003446 ;
3447 break;}
3448case 163:
3449#line 1811 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3450{ // integral constants
3451 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003452 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003453 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
Reid Spencer38c91a92007-02-28 02:24:54 +00003454 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003455 ;
3456 break;}
3457case 164:
3458#line 1817 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3459{ // arbitrary precision integer constants
3460 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3461 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003462 GEN_ERROR("Constant value does not fit in type");
3463 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003464 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
3465 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3466 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003467 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003468 ;
3469 break;}
3470case 165:
3471#line 1827 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3472{ // integral constants
3473 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003474 GEN_ERROR("Constant value doesn't fit in type");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003475 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003476 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003477 ;
3478 break;}
3479case 166:
3480#line 1833 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3481{ // arbitrary precision integer constants
3482 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3483 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003484 GEN_ERROR("Constant value does not fit in type");
3485 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003486 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
3487 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3488 delete yyvsp[0].APIntVal;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003489 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003490 ;
3491 break;}
3492case 167:
3493#line 1843 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3494{ // Boolean constants
3495 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3496 yyval.ConstVal = ConstantInt::getTrue();
Reid Spencer38c91a92007-02-28 02:24:54 +00003497 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003498 ;
3499 break;}
3500case 168:
3501#line 1848 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3502{ // Boolean constants
3503 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3504 yyval.ConstVal = ConstantInt::getFalse();
Reid Spencer6f407902007-01-13 05:00:46 +00003505 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003506 ;
3507 break;}
3508case 169:
3509#line 1853 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3510{ // Float & Double constants
3511 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003512 GEN_ERROR("Floating point constant invalid for type");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003513 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003514 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003515 ;
3516 break;}
3517case 170:
3518#line 1861 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3519{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003520 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003521 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3522 Constant *Val = yyvsp[-3].ConstVal;
3523 const Type *DestTy = yyvsp[-1].TypeVal->get();
3524 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003525 GEN_ERROR("invalid cast opcode for cast from '" +
3526 Val->getType()->getDescription() + "' to '" +
3527 DestTy->getDescription() + "'");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003528 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3529 delete yyvsp[-1].TypeVal;
3530 ;
3531 break;}
3532case 171:
3533#line 1873 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3534{
3535 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencerb5334b02007-02-05 10:18:06 +00003536 GEN_ERROR("GetElementPtr requires a pointer operand");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003537
3538 const Type *IdxTy =
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003539 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), &(*yyvsp[-1].ValueList)[0], yyvsp[-1].ValueList->size(),
Chris Lattner7d9801d2007-02-13 00:58:01 +00003540 true);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003541 if (!IdxTy)
Reid Spencerb5334b02007-02-05 10:18:06 +00003542 GEN_ERROR("Index list invalid for constant getelementptr");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003543
Chris Lattnerf7469af2007-01-31 04:44:08 +00003544 SmallVector<Constant*, 8> IdxVec;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003545 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3546 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003547 IdxVec.push_back(C);
3548 else
Reid Spencerb5334b02007-02-05 10:18:06 +00003549 GEN_ERROR("Indices to constant getelementptr must be constants");
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003550
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003551 delete yyvsp[-1].ValueList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003552
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003553 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003554 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003555 ;
3556 break;}
3557case 172:
3558#line 1895 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3559{
3560 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003561 GEN_ERROR("Select condition must be of boolean type");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003562 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003563 GEN_ERROR("Select operand types must match");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003564 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003565 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003566 ;
3567 break;}
3568case 173:
3569#line 1903 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3570{
3571 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003572 GEN_ERROR("Binary operator types must match");
3573 CHECK_FOR_ERROR;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003574 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3575 ;
3576 break;}
3577case 174:
3578#line 1909 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3579{
3580 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003581 GEN_ERROR("Logical operator types must match");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003582 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3583 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
3584 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003585 GEN_ERROR("Logical operator requires integral operands");
3586 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003587 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003588 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003589 ;
3590 break;}
3591case 175:
3592#line 1920 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3593{
3594 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003595 GEN_ERROR("icmp operand types must match");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003596 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3597 ;
3598 break;}
3599case 176:
3600#line 1925 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3601{
3602 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003603 GEN_ERROR("fcmp operand types must match");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003604 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3605 ;
3606 break;}
3607case 177:
3608#line 1930 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3609{
3610 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003611 GEN_ERROR("Invalid extractelement operands");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003612 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003613 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003614 ;
3615 break;}
3616case 178:
3617#line 1936 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3618{
3619 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003620 GEN_ERROR("Invalid insertelement operands");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003621 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003622 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003623 ;
3624 break;}
3625case 179:
3626#line 1942 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3627{
3628 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003629 GEN_ERROR("Invalid shufflevector operands");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003630 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer41dff5e2007-01-26 08:05:27 +00003631 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003632 ;
3633 break;}
3634case 180:
3635#line 1951 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3636{
3637 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003638 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003639 ;
3640 break;}
3641case 181:
3642#line 1955 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3643{
3644 yyval.ConstVector = new std::vector<Constant*>();
3645 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003646 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003647 ;
3648 break;}
3649case 182:
3650#line 1963 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3651{ yyval.BoolVal = false; ;
3652 break;}
3653case 183:
3654#line 1963 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3655{ yyval.BoolVal = true; ;
3656 break;}
3657case 184:
3658#line 1966 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3659{ yyval.BoolVal = true; ;
3660 break;}
3661case 185:
3662#line 1966 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3663{ yyval.BoolVal = false; ;
3664 break;}
3665case 186:
3666#line 1969 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3667{
3668 const Type* VTy = yyvsp[-1].TypeVal->get();
3669 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003670 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
3671 if (!Aliasee)
3672 GEN_ERROR("Aliases can be created only to global values");
3673
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003674 yyval.ConstVal = Aliasee;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003675 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003676 delete yyvsp[-1].TypeVal;
3677 ;
3678 break;}
3679case 187:
3680#line 1980 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3681{
3682 Constant *Val = yyvsp[-3].ConstVal;
3683 const Type *DestTy = yyvsp[-1].TypeVal->get();
3684 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003685 GEN_ERROR("invalid cast opcode for cast from '" +
3686 Val->getType()->getDescription() + "' to '" +
3687 DestTy->getDescription() + "'");
3688
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003689 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003690 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003691 delete yyvsp[-1].TypeVal;
3692 ;
3693 break;}
3694case 188:
3695#line 2001 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3696{
3697 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003698 CurModule.ModuleDone();
3699 CHECK_FOR_ERROR;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003700 ;
3701 break;}
3702case 189:
3703#line 2006 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3704{
3705 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003706 CurModule.ModuleDone();
3707 CHECK_FOR_ERROR;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003708 ;
3709 break;}
3710case 192:
3711#line 2019 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3712{ CurFun.isDeclare = false; ;
3713 break;}
3714case 193:
3715#line 2019 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3716{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003717 CurFun.FunctionDone();
3718 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003719 ;
3720 break;}
3721case 194:
3722#line 2023 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3723{ CurFun.isDeclare = true; ;
3724 break;}
3725case 195:
3726#line 2023 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3727{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003728 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003729 ;
3730 break;}
3731case 196:
3732#line 2026 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3733{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003734 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003735 ;
3736 break;}
3737case 197:
3738#line 2029 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3739{
Reid Spencer14310612006-12-31 05:40:51 +00003740 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003741 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003742 // Eagerly resolve types. This is not an optimization, this is a
3743 // requirement that is due to the fact that we could have this:
3744 //
3745 // %list = type { %list * }
3746 // %list = type { %list * } ; repeated type decl
3747 //
3748 // If types are not resolved eagerly, then the two types will not be
3749 // determined to be the same type!
3750 //
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003751 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003752
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003753 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003754 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003755 // If this is a named type that is not a redefinition, add it to the slot
3756 // table.
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003757 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003758 }
Reid Spencera132e042006-12-03 05:46:11 +00003759
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003760 delete yyvsp[0].TypeVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003761 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003762 ;
3763 break;}
3764case 198:
3765#line 2053 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3766{
3767 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Anton Korobeynikov38e09802007-04-28 13:48:45 +00003768
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003769 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003770 CHECK_FOR_ERROR
3771 // If this is a named type that is not a redefinition, add it to the slot
3772 // table.
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003773 CurModule.Types.push_back(yyvsp[0].PrimType);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003774 }
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003775 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003776 ;
3777 break;}
3778case 199:
3779#line 2064 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3780{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003781 /* "Externally Visible" Linkage */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003782 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003783 GEN_ERROR("Global value initializer is not a constant");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003784 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage,
3785 yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003786 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003787 ;
3788 break;}
3789case 200:
3790#line 2071 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3791{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003792 CurGV = 0;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003793 ;
3794 break;}
3795case 201:
3796#line 2075 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3797{
3798 if (yyvsp[0].ConstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003799 GEN_ERROR("Global value initializer is not a constant");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003800 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 +00003801 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003802 ;
3803 break;}
3804case 202:
3805#line 2080 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3806{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003807 CurGV = 0;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003808 ;
3809 break;}
3810case 203:
3811#line 2084 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3812{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003813 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003814 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3815 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 +00003816 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003817 delete yyvsp[0].TypeVal;
3818 ;
3819 break;}
3820case 204:
3821#line 2090 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3822{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003823 CurGV = 0;
Reid Spencer41dff5e2007-01-26 08:05:27 +00003824 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003825 ;
3826 break;}
3827case 205:
3828#line 2094 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3829{
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003830 std::string Name;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003831 if (yyvsp[-4].StrVal) {
3832 Name = *yyvsp[-4].StrVal;
3833 delete yyvsp[-4].StrVal;
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003834 }
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003835 if (Name.empty())
3836 GEN_ERROR("Alias name cannot be empty");
3837
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003838 Constant* Aliasee = yyvsp[0].ConstVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003839 if (Aliasee == 0)
Reid Spencer0a8a16b2007-05-22 18:52:55 +00003840 GEN_ERROR(std::string("Invalid aliasee for alias: ") + Name);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003841
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003842 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003843 CurModule.CurrentModule);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003844 GA->setVisibility(yyvsp[-3].Visibility);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003845 InsertValue(GA, CurModule.Values);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003846 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003847 ;
3848 break;}
3849case 206:
3850#line 2113 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3851{
Anton Korobeynikov77d0f972007-04-25 14:29:12 +00003852 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003853 ;
3854 break;}
3855case 207:
3856#line 2116 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3857{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003858 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003859 ;
3860 break;}
3861case 208:
3862#line 2122 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3863{
Chris Lattner66316012006-01-24 04:14:29 +00003864 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner66316012006-01-24 04:14:29 +00003865 if (AsmSoFar.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003866 CurModule.CurrentModule->setModuleInlineAsm(*yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003867 else
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003868 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+*yyvsp[0].StrVal);
3869 delete yyvsp[0].StrVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003870 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003871;
3872 break;}
3873case 209:
3874#line 2132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3875{
3876 CurModule.CurrentModule->setTargetTriple(*yyvsp[0].StrVal);
3877 delete yyvsp[0].StrVal;
3878 ;
3879 break;}
3880case 210:
3881#line 2136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3882{
3883 CurModule.CurrentModule->setDataLayout(*yyvsp[0].StrVal);
3884 delete yyvsp[0].StrVal;
3885 ;
3886 break;}
3887case 212:
3888#line 2143 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3889{
3890 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
3891 delete yyvsp[0].StrVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003892 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003893 ;
3894 break;}
3895case 213:
3896#line 2148 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3897{
3898 CurModule.CurrentModule->addLibrary(*yyvsp[0].StrVal);
3899 delete yyvsp[0].StrVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003900 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003901 ;
3902 break;}
3903case 214:
3904#line 2153 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3905{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003906 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003907 ;
3908 break;}
3909case 215:
3910#line 2162 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3911{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003912 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003913 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3914 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003915 GEN_ERROR("void typed arguments are invalid");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003916 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3917 yyval.ArgList = yyvsp[-4].ArgList;
3918 yyvsp[-4].ArgList->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00003919 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003920 ;
3921 break;}
3922case 216:
3923#line 2172 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3924{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003925 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003926 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3927 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003928 GEN_ERROR("void typed arguments are invalid");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003929 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3930 yyval.ArgList = new ArgListType;
3931 yyval.ArgList->push_back(E);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003932 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003933 ;
3934 break;}
3935case 217:
3936#line 2183 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3937{
3938 yyval.ArgList = yyvsp[0].ArgList;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00003939 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003940 ;
3941 break;}
3942case 218:
3943#line 2187 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3944{
3945 yyval.ArgList = yyvsp[-2].ArgList;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003946 struct ArgListEntry E;
3947 E.Ty = new PATypeHolder(Type::VoidTy);
3948 E.Name = 0;
Reid Spencer18da0722007-04-11 02:44:20 +00003949 E.Attrs = ParamAttr::None;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003950 yyval.ArgList->push_back(E);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00003951 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003952 ;
3953 break;}
3954case 219:
3955#line 2196 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3956{
3957 yyval.ArgList = new ArgListType;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003958 struct ArgListEntry E;
3959 E.Ty = new PATypeHolder(Type::VoidTy);
3960 E.Name = 0;
3961 E.Attrs = ParamAttr::None;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003962 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00003963 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003964 ;
3965 break;}
3966case 220:
3967#line 2205 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3968{
3969 yyval.ArgList = 0;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00003970 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003971 ;
3972 break;}
3973case 221:
3974#line 2211 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3975{
3976 std::string FunctionName(*yyvsp[-6].StrVal);
3977 delete yyvsp[-6].StrVal; // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003978
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00003979 // Check the function result for abstractness if this is a define. We should
3980 // have no abstract types at this point
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003981 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
3982 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00003983
Reid Spencer68a24bd2005-08-27 18:50:39 +00003984 std::vector<const Type*> ParamTypeList;
Christopher Lamb5c104242007-04-22 20:09:11 +00003985 ParamAttrsVector Attrs;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003986 if (yyvsp[-2].ParamAttrs != ParamAttr::None) {
3987 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00003988 Attrs.push_back(PAWI);
3989 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003990 if (yyvsp[-4].ArgList) { // If there are arguments...
Reid Spencer7b5d4662007-04-09 06:16:21 +00003991 unsigned index = 1;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00003992 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00003993 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00003994 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
3995 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00003996 ParamTypeList.push_back(Ty);
3997 if (Ty != Type::VoidTy)
Christopher Lamb5c104242007-04-22 20:09:11 +00003998 if (I->Attrs != ParamAttr::None) {
3999 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4000 Attrs.push_back(PAWI);
4001 }
Reid Spencer14310612006-12-31 05:40:51 +00004002 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004003 }
4004
4005 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4006 if (isVarArg) ParamTypeList.pop_back();
4007
Christopher Lamb5c104242007-04-22 20:09:11 +00004008 ParamAttrsList *PAL = 0;
4009 if (!Attrs.empty())
4010 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004011
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004012 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004013 const PointerType *PFT = PointerType::get(FT);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004014 delete yyvsp[-7].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004015
4016 ValID ID;
4017 if (!FunctionName.empty()) {
Reid Spencer41dff5e2007-01-26 08:05:27 +00004018 ID = ValID::createGlobalName((char*)FunctionName.c_str());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004019 } else {
Reid Spencer93c40032007-03-19 18:40:50 +00004020 ID = ValID::createGlobalID(CurModule.Values.size());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004021 }
4022
4023 Function *Fn = 0;
4024 // See if this function was forward referenced. If so, recycle the object.
4025 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4026 // Move the function to the end of the list, from whereever it was
4027 // previously inserted.
4028 Fn = cast<Function>(FWRef);
4029 CurModule.CurrentModule->getFunctionList().remove(Fn);
4030 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4031 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
Reid Spenceref9b9a72007-02-05 20:47:22 +00004032 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004033 if (Fn->getFunctionType() != FT) {
Reid Spenceref9b9a72007-02-05 20:47:22 +00004034 // The existing function doesn't have the same type. This is an overload
4035 // error.
4036 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4037 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
Chris Lattner6cdc6822007-04-26 05:31:05 +00004038 // Neither the existing or the current function is a declaration and they
4039 // have the same name and same type. Clearly this is a redefinition.
4040 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004041 } if (Fn->isDeclaration()) {
4042 // Make sure to strip off any argument names so we can't get conflicts.
Reid Spencer68a24bd2005-08-27 18:50:39 +00004043 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4044 AI != AE; ++AI)
4045 AI->setName("");
Reid Spenceref9b9a72007-02-05 20:47:22 +00004046 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004047 } else { // Not already defined?
Chris Lattner6cdc6822007-04-26 05:31:05 +00004048 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004049 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004050
Reid Spencer68a24bd2005-08-27 18:50:39 +00004051 InsertValue(Fn, CurModule.Values);
4052 }
4053
4054 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004055
4056 if (CurFun.isDeclare) {
4057 // If we have declaration, always overwrite linkage. This will allow us to
4058 // correctly handle cases, when pointer to function is passed as argument to
4059 // another function.
4060 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004061 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004062 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004063 Fn->setCallingConv(yyvsp[-8].UIntVal);
4064 Fn->setAlignment(yyvsp[0].UIntVal);
4065 if (yyvsp[-1].StrVal) {
4066 Fn->setSection(*yyvsp[-1].StrVal);
4067 delete yyvsp[-1].StrVal;
Chris Lattnere869eef2005-11-12 00:11:49 +00004068 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004069
4070 // Add all of the arguments we parsed to the function...
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004071 if (yyvsp[-4].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004072 if (isVarArg) { // Nuke the last entry
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004073 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 &&
Reid Spencera9720f52007-02-05 17:04:00 +00004074 "Not a varargs marker!");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004075 delete yyvsp[-4].ArgList->back().Ty;
4076 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004077 }
4078 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spenceref9b9a72007-02-05 20:47:22 +00004079 Function::arg_iterator ArgEnd = Fn->arg_end();
Reid Spencer14310612006-12-31 05:40:51 +00004080 unsigned Idx = 1;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004081 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin();
4082 I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00004083 delete I->Ty; // Delete the typeholder...
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004084 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004085 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004086 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00004087 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004088 }
Reid Spencera132e042006-12-03 05:46:11 +00004089
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004090 delete yyvsp[-4].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004091 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004092 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004093;
4094 break;}
4095case 224:
4096#line 2333 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4097{
4098 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004099
4100 // Make sure that we keep track of the linkage type even if there was a
4101 // previous "declare".
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004102 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4103 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
4104;
4105 break;}
4106case 227:
4107#line 2344 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4108{
4109 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004110 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004111;
4112 break;}
4113case 228:
4114#line 2349 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4115{
4116 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4117 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4118 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004119 CurFun.FunctionDone();
Reid Spencer41dff5e2007-01-26 08:05:27 +00004120 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004121 ;
4122 break;}
4123case 229:
4124#line 2361 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4125{
4126 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004127 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004128 ;
4129 break;}
4130case 230:
4131#line 2365 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4132{
4133 yyval.BoolVal = true;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004134 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004135 ;
4136 break;}
4137case 231:
4138#line 2370 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4139{ // A reference to a direct constant
4140 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004141 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004142 ;
4143 break;}
4144case 232:
4145#line 2374 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4146{
4147 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004148 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004149 ;
4150 break;}
4151case 233:
4152#line 2378 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4153{ // Perhaps it's an FP constant?
4154 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004155 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004156 ;
4157 break;}
4158case 234:
4159#line 2382 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4160{
4161 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Reid Spencere4d87aa2006-12-23 06:05:41 +00004162 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004163 ;
4164 break;}
4165case 235:
4166#line 2386 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4167{
4168 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004169 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004170 ;
4171 break;}
4172case 236:
4173#line 2390 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4174{
4175 yyval.ValIDVal = ValID::createNull();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00004176 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004177 ;
4178 break;}
4179case 237:
4180#line 2394 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4181{
4182 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004183 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004184 ;
4185 break;}
4186case 238:
4187#line 2398 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4188{ // A vector zero constant.
4189 yyval.ValIDVal = ValID::createZeroInit();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004190 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004191 ;
4192 break;}
4193case 239:
4194#line 2402 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4195{ // Nonempty unsized packed vector
4196 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4197 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004198
Reid Spencer9d6565a2007-02-15 02:26:10 +00004199 VectorType* pt = VectorType::get(ETy, NumElements);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004200 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00004201 HandleUpRefs(
Reid Spencer9d6565a2007-02-15 02:26:10 +00004202 VectorType::get(
Reid Spencera132e042006-12-03 05:46:11 +00004203 ETy,
4204 NumElements)
4205 )
4206 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00004207
4208 // Verify all elements are correct type!
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004209 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4210 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004211 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004212 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004213 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004214 }
4215
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004216 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4217 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer832254e2007-02-02 02:16:23 +00004218 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004219 ;
4220 break;}
4221case 240:
4222#line 2427 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4223{
4224 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004225 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004226 ;
4227 break;}
4228case 241:
4229#line 2431 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4230{
4231 yyval.ValIDVal = ValID::createInlineAsm(*yyvsp[-2].StrVal, *yyvsp[0].StrVal, yyvsp[-3].BoolVal);
4232 delete yyvsp[-2].StrVal;
4233 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004234 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004235 ;
4236 break;}
4237case 242:
4238#line 2441 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4239{ // Is it an integer reference...?
4240 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004241 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004242 ;
4243 break;}
4244case 243:
4245#line 2445 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4246{
4247 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
Reid Spencer832254e2007-02-02 02:16:23 +00004248 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004249 ;
4250 break;}
4251case 244:
4252#line 2449 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4253{ // Is it a named reference...?
4254 yyval.ValIDVal = ValID::createLocalName(*yyvsp[0].StrVal);
4255 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004256 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004257 ;
4258 break;}
4259case 245:
4260#line 2454 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4261{ // Is it a named reference...?
4262 yyval.ValIDVal = ValID::createGlobalName(*yyvsp[0].StrVal);
4263 delete yyvsp[0].StrVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004264 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004265 ;
4266 break;}
4267case 248:
4268#line 2467 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4269{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004270 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004271 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4272 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4273 delete yyvsp[-1].TypeVal;
Reid Spencer832254e2007-02-02 02:16:23 +00004274 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004275 ;
4276 break;}
4277case 249:
4278#line 2476 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4279{
4280 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004281 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004282 ;
4283 break;}
4284case 250:
4285#line 2480 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4286{ // Do not allow functions with 0 basic blocks
4287 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004288 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004289 ;
4290 break;}
4291case 251:
4292#line 2489 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4293{
4294 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004295 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004296 InsertValue(yyvsp[0].TermInstVal);
4297 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4298 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004299 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004300 ;
4301 break;}
4302case 252:
4303#line 2498 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4304{
4305 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004306 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4307 if (CI2->getParent() == 0)
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004308 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4309 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4310 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov38e09802007-04-28 13:48:45 +00004311 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004312 ;
4313 break;}
4314case 253:
4315#line 2507 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4316{ // Empty space between instruction lists
4317 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
Reid Spencered951ea2007-05-19 07:22:10 +00004318 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004319 ;
4320 break;}
4321case 254:
4322#line 2511 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4323{ // Labelled (named) basic block
4324 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(*yyvsp[0].StrVal));
4325 delete yyvsp[0].StrVal;
Reid Spencered951ea2007-05-19 07:22:10 +00004326 CHECK_FOR_ERROR
Reid Spencer0a8a16b2007-05-22 18:52:55 +00004327
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004328 ;
4329 break;}
4330case 255:
4331#line 2518 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4332{ // Return with a result...
4333 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4334 CHECK_FOR_ERROR
4335 ;
4336 break;}
4337case 256:
4338#line 2522 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4339{ // Return with no result...
4340 yyval.TermInstVal = new ReturnInst();
4341 CHECK_FOR_ERROR
4342 ;
4343 break;}
4344case 257:
4345#line 2526 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4346{ // Unconditional Branch...
4347 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4348 CHECK_FOR_ERROR
4349 yyval.TermInstVal = new BranchInst(tmpBB);
4350 ;
4351 break;}
4352case 258:
4353#line 2531 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4354{
4355 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4356 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4357 CHECK_FOR_ERROR
4358 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4359 CHECK_FOR_ERROR
4360 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4361 CHECK_FOR_ERROR
4362 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4363 ;
4364 break;}
4365case 259:
4366#line 2541 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4367{
4368 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4369 CHECK_FOR_ERROR
4370 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4371 CHECK_FOR_ERROR
4372 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4373 yyval.TermInstVal = S;
Reid Spencered951ea2007-05-19 07:22:10 +00004374
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004375 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4376 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004377 for (; I != E; ++I) {
4378 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4379 S->addCase(CI, I->second);
4380 else
Reid Spencerb5334b02007-02-05 10:18:06 +00004381 GEN_ERROR("Switch case is constant, but not a simple integer");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004382 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004383 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00004384 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004385 ;
4386 break;}
4387case 260:
4388#line 2560 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4389{
4390 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004391 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004392 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004393 CHECK_FOR_ERROR
4394 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004395 yyval.TermInstVal = S;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004396 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004397 ;
4398 break;}
4399case 261:
4400#line 2570 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4401{
Reid Spencer3822ff52006-11-08 06:47:33 +00004402
Reid Spencer14310612006-12-31 05:40:51 +00004403 // Handle the short syntax
4404 const PointerType *PFTy = 0;
4405 const FunctionType *Ty = 0;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004406 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004407 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4408 // Pull out the types of all of the arguments...
4409 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00004410 ParamAttrsVector Attrs;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004411 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
4412 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004413 Attrs.push_back(PAWI);
4414 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004415 ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00004416 unsigned index = 1;
4417 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004418 const Type *Ty = I->Val->getType();
4419 if (Ty == Type::VoidTy)
4420 GEN_ERROR("Short call syntax cannot be used with varargs");
4421 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00004422 if (I->Attrs != ParamAttr::None) {
4423 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4424 Attrs.push_back(PAWI);
4425 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004426 }
4427
Christopher Lamb5c104242007-04-22 20:09:11 +00004428 ParamAttrsList *PAL = 0;
4429 if (!Attrs.empty())
4430 PAL = ParamAttrsList::get(Attrs);
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004431 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004432 PFTy = PointerType::get(Ty);
4433 }
4434
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004435 delete yyvsp[-11].TypeVal;
Reid Spencer66728ef2007-03-20 01:13:36 +00004436
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004437 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004438 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004439 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004440 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004441 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004442 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004443
Reid Spencer14310612006-12-31 05:40:51 +00004444 // Check the arguments
4445 ValueList Args;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004446 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00004447 // Make sure no arguments is a good thing!
4448 if (Ty->getNumParams() != 0)
4449 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004450 "expects arguments");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004451 } else { // Has arguments?
4452 // Loop through FunctionType's arguments and ensure they are specified
4453 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004454 FunctionType::param_iterator I = Ty->param_begin();
4455 FunctionType::param_iterator E = Ty->param_end();
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004456 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004457
Reid Spencer14310612006-12-31 05:40:51 +00004458 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4459 if (ArgI->Val->getType() != *I)
4460 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004461 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004462 Args.push_back(ArgI->Val);
4463 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004464
Reid Spencer14310612006-12-31 05:40:51 +00004465 if (Ty->isVarArg()) {
4466 if (I == E)
4467 for (; ArgI != ArgE; ++ArgI)
4468 Args.push_back(ArgI->Val); // push the remaining varargs
4469 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004470 GEN_ERROR("Invalid number of parameters detected");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004471 }
Reid Spencer14310612006-12-31 05:40:51 +00004472
4473 // Create the InvokeInst
Chris Lattner9d2fda62007-02-13 05:53:56 +00004474 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004475 II->setCallingConv(yyvsp[-12].UIntVal);
4476 yyval.TermInstVal = II;
4477 delete yyvsp[-8].ValueRefList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004478 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004479 ;
4480 break;}
4481case 262:
4482#line 2649 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4483{
4484 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004485 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004486 ;
4487 break;}
4488case 263:
4489#line 2653 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4490{
4491 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004492 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004493 ;
4494 break;}
4495case 264:
4496#line 2660 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4497{
4498 yyval.JumpTable = yyvsp[-5].JumpTable;
4499 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004500 CHECK_FOR_ERROR
4501 if (V == 0)
4502 GEN_ERROR("May only switch on a constant pool value");
4503
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004504 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004505 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004506 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4507 ;
4508 break;}
4509case 265:
4510#line 2671 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4511{
4512 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4513 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004514 CHECK_FOR_ERROR
4515
4516 if (V == 0)
Reid Spencerb5334b02007-02-05 10:18:06 +00004517 GEN_ERROR("May only switch on a constant pool value");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004518
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004519 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004520 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004521 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4522 ;
4523 break;}
4524case 266:
4525#line 2684 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4526{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004527 // Is this definition named?? if so, assign the name...
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004528 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004529 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004530 InsertValue(yyvsp[0].InstVal);
4531 yyval.InstVal = yyvsp[0].InstVal;
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004532 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004533 ;
4534 break;}
4535case 267:
4536#line 2694 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4537{ // Used for PHI nodes
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004538 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004539 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4540 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4541 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004542 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004543 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004544 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004545 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4546 delete yyvsp[-5].TypeVal;
4547 ;
4548 break;}
4549case 268:
4550#line 2705 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4551{
4552 yyval.PHIList = yyvsp[-6].PHIList;
4553 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004554 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004555 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004556 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004557 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4558 ;
4559 break;}
4560case 269:
4561#line 2715 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4562{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004563 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004564 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004565 // Used for call and invoke instructions
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004566 yyval.ValueRefList = new ValueRefList();
4567 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4568 yyval.ValueRefList->push_back(E);
4569 delete yyvsp[-2].TypeVal;
4570 ;
4571 break;}
4572case 270:
4573#line 2724 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4574{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004575 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004576 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4577 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4578 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4579 yyval.ValueRefList->push_back(E);
4580 delete yyvsp[-2].TypeVal;
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004581 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004582 ;
4583 break;}
4584case 271:
4585#line 2733 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4586{ yyval.ValueRefList = new ValueRefList(); ;
4587 break;}
4588case 272:
4589#line 2736 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4590{ yyval.ValueList = new std::vector<Value*>(); ;
4591 break;}
4592case 273:
4593#line 2737 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4594{
4595 yyval.ValueList = yyvsp[-2].ValueList;
4596 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004597 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004598 ;
4599 break;}
4600case 274:
4601#line 2744 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4602{
4603 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004604 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004605 ;
4606 break;}
4607case 275:
4608#line 2748 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4609{
4610 yyval.BoolVal = false;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004611 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004612 ;
4613 break;}
4614case 276:
4615#line 2753 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4616{
Reid Spencer14310612006-12-31 05:40:51 +00004617 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004618 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4619 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4620 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004621 GEN_ERROR(
4622 "Arithmetic operator requires integer, FP, or packed operands");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004623 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) &&
4624 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4625 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4626 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004627 GEN_ERROR("Remainder not supported on vector types");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004628 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004629 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004630 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004631 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004632 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4633 if (yyval.InstVal == 0)
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004634 GEN_ERROR("binary operator returned null");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004635 delete yyvsp[-3].TypeVal;
4636 ;
4637 break;}
4638case 277:
4639#line 2774 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4640{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004641 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004642 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4643 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4644 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
4645 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004646 GEN_ERROR("Logical operator requires integral operands");
4647 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004648 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004649 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004650 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004651 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004652 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4653 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004654 GEN_ERROR("binary operator returned null");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004655 delete yyvsp[-3].TypeVal;
4656 ;
4657 break;}
4658case 278:
4659#line 2791 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4660{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004661 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004662 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4663 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004664 GEN_ERROR("Vector types not supported by icmp instruction");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004665 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004666 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004667 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004668 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004669 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4670 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004671 GEN_ERROR("icmp operator returned null");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004672 delete yyvsp[-3].TypeVal;
4673 ;
4674 break;}
4675case 279:
4676#line 2805 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4677{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004678 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004679 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4680 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004681 GEN_ERROR("Vector types not supported by fcmp instruction");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004682 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004683 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004684 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004685 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004686 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4687 if (yyval.InstVal == 0)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004688 GEN_ERROR("fcmp operator returned null");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004689 delete yyvsp[-3].TypeVal;
4690 ;
4691 break;}
4692case 280:
4693#line 2819 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4694{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004695 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004696 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4697 Value* Val = yyvsp[-2].ValueVal;
4698 const Type* DestTy = yyvsp[0].TypeVal->get();
4699 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004700 GEN_ERROR("invalid cast opcode for cast from '" +
4701 Val->getType()->getDescription() + "' to '" +
4702 DestTy->getDescription() + "'");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004703 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
4704 delete yyvsp[0].TypeVal;
4705 ;
4706 break;}
4707case 281:
4708#line 2831 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4709{
4710 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004711 GEN_ERROR("select condition must be boolean");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004712 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004713 GEN_ERROR("select value types should match");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004714 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004715 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004716 ;
4717 break;}
4718case 282:
4719#line 2839 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4720{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004721 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004722 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4723 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4724 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004725 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004726 ;
4727 break;}
4728case 283:
4729#line 2846 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4730{
4731 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004732 GEN_ERROR("Invalid extractelement operands");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004733 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004734 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004735 ;
4736 break;}
4737case 284:
4738#line 2852 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4739{
4740 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004741 GEN_ERROR("Invalid insertelement operands");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004742 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004743 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004744 ;
4745 break;}
4746case 285:
4747#line 2858 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4748{
4749 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004750 GEN_ERROR("Invalid shufflevector operands");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004751 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004752 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004753 ;
4754 break;}
4755case 286:
4756#line 2864 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4757{
4758 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004759 if (!Ty->isFirstClassType())
4760 GEN_ERROR("PHI node operands must be of first class type");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004761 yyval.InstVal = new PHINode(Ty);
4762 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4763 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4764 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004765 GEN_ERROR("All elements of a PHI node must be of the same type");
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004766 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4767 yyvsp[0].PHIList->pop_front();
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004768 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004769 delete yyvsp[0].PHIList; // Free the list...
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004770 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004771 ;
4772 break;}
4773case 287:
4774#line 2880 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4775{
Reid Spencer14310612006-12-31 05:40:51 +00004776
4777 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00004778 const PointerType *PFTy = 0;
4779 const FunctionType *Ty = 0;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004780 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00004781 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4782 // Pull out the types of all of the arguments...
4783 std::vector<const Type*> ParamTypes;
Christopher Lamb5c104242007-04-22 20:09:11 +00004784 ParamAttrsVector Attrs;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004785 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
4786 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs;
Christopher Lamb5c104242007-04-22 20:09:11 +00004787 Attrs.push_back(PAWI);
4788 }
Reid Spencer7b5d4662007-04-09 06:16:21 +00004789 unsigned index = 1;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004790 ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end();
Reid Spencer7b5d4662007-04-09 06:16:21 +00004791 for (; I != E; ++I, ++index) {
Reid Spencer14310612006-12-31 05:40:51 +00004792 const Type *Ty = I->Val->getType();
4793 if (Ty == Type::VoidTy)
4794 GEN_ERROR("Short call syntax cannot be used with varargs");
4795 ParamTypes.push_back(Ty);
Christopher Lamb5c104242007-04-22 20:09:11 +00004796 if (I->Attrs != ParamAttr::None) {
4797 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4798 Attrs.push_back(PAWI);
4799 }
Andrew Lenharth6353e052006-12-08 18:07:09 +00004800 }
4801
Christopher Lamb5c104242007-04-22 20:09:11 +00004802 ParamAttrsList *PAL = 0;
4803 if (!Attrs.empty())
4804 PAL = ParamAttrsList::get(Attrs);
Reid Spencer7b5d4662007-04-09 06:16:21 +00004805
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004806 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004807 PFTy = PointerType::get(Ty);
4808 }
Chris Lattner6cdc6822007-04-26 05:31:05 +00004809
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004810 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004811 CHECK_FOR_ERROR
Chris Lattner6cdc6822007-04-26 05:31:05 +00004812
Reid Spencer7780acb2007-04-16 06:56:07 +00004813 // Check for call to invalid intrinsic to avoid crashing later.
4814 if (Function *theF = dyn_cast<Function>(V)) {
Reid Spencered48de22007-04-16 22:02:23 +00004815 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
Reid Spencer36fdde12007-04-16 20:35:38 +00004816 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
4817 !theF->getIntrinsicID(true))
Reid Spencer7780acb2007-04-16 06:56:07 +00004818 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
4819 theF->getName() + "'");
4820 }
4821
Reid Spencer14310612006-12-31 05:40:51 +00004822 // Check the arguments
4823 ValueList Args;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004824 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00004825 // Make sure no arguments is a good thing!
4826 if (Ty->getNumParams() != 0)
4827 GEN_ERROR("No arguments passed to a function that "
Reid Spencerb5334b02007-02-05 10:18:06 +00004828 "expects arguments");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004829 } else { // Has arguments?
4830 // Loop through FunctionType's arguments and ensure they are specified
4831 // correctly!
4832 //
4833 FunctionType::param_iterator I = Ty->param_begin();
4834 FunctionType::param_iterator E = Ty->param_end();
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004835 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004836
Reid Spencer14310612006-12-31 05:40:51 +00004837 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4838 if (ArgI->Val->getType() != *I)
4839 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencerb5334b02007-02-05 10:18:06 +00004840 (*I)->getDescription() + "'");
Reid Spencer14310612006-12-31 05:40:51 +00004841 Args.push_back(ArgI->Val);
4842 }
4843 if (Ty->isVarArg()) {
4844 if (I == E)
4845 for (; ArgI != ArgE; ++ArgI)
4846 Args.push_back(ArgI->Val); // push the remaining varargs
4847 } else if (I != E || ArgI != ArgE)
Reid Spencerb5334b02007-02-05 10:18:06 +00004848 GEN_ERROR("Invalid number of parameters detected");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004849 }
Reid Spencer14310612006-12-31 05:40:51 +00004850 // Create the call node
Chris Lattner9d2fda62007-02-13 05:53:56 +00004851 CallInst *CI = new CallInst(V, &Args[0], Args.size());
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004852 CI->setTailCall(yyvsp[-7].BoolVal);
4853 CI->setCallingConv(yyvsp[-6].UIntVal);
4854 yyval.InstVal = CI;
4855 delete yyvsp[-2].ValueRefList;
4856 delete yyvsp[-5].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004857 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004858 ;
4859 break;}
4860case 288:
4861#line 2964 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4862{
4863 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004864 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004865 ;
4866 break;}
4867case 289:
4868#line 2969 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4869{
4870 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004871 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004872 ;
4873 break;}
4874case 290:
4875#line 2973 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4876{
4877 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004878 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004879 ;
4880 break;}
4881case 291:
4882#line 2980 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4883{
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004884 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004885 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4886 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4887 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004888 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004889 ;
4890 break;}
4891case 292:
4892#line 2987 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4893{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004894 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004895 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4896 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004897 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004898 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4899 delete yyvsp[-4].TypeVal;
4900 ;
4901 break;}
4902case 293:
4903#line 2995 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4904{
Reid Spencer14310612006-12-31 05:40:51 +00004905 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004906 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4907 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4908 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004909 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004910 ;
4911 break;}
4912case 294:
4913#line 3002 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4914{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004915 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004916 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4917 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Anton Korobeynikov9adeaa22007-01-28 13:37:39 +00004918 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004919 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4920 delete yyvsp[-4].TypeVal;
4921 ;
4922 break;}
4923case 295:
4924#line 3010 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4925{
4926 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004927 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004928 yyvsp[0].ValueVal->getType()->getDescription() + "");
4929 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004930 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004931 ;
4932 break;}
4933case 296:
4934#line 3018 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4935{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004936 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004937 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4938 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004939 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004940 (*yyvsp[-2].TypeVal)->getDescription());
4941 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004942 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004943 (*yyvsp[-2].TypeVal)->getDescription());
4944 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004945 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004946 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
4947 delete yyvsp[-2].TypeVal;
4948 ;
4949 break;}
4950case 297:
4951#line 3032 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4952{
Lauro Ramos Venancioc7635522007-04-12 18:32:50 +00004953 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004954 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4955 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004956 if (!PT)
4957 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004958 (*yyvsp[-2].TypeVal)->getDescription());
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004959 const Type *ElTy = PT->getElementType();
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004960 if (ElTy != yyvsp[-4].ValueVal->getType())
4961 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004962 "' into space of type '" + ElTy->getDescription() + "'");
4963
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004964 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004965 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004966 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
4967 delete yyvsp[-2].TypeVal;
4968 ;
4969 break;}
4970case 298:
4971#line 3049 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4972{
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00004973 if (!UpRefs.empty())
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004974 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4975 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencerb5334b02007-02-05 10:18:06 +00004976 GEN_ERROR("getelementptr insn requires pointer operand");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004977
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004978 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size(), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00004979 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004980 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
4981 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004982 CHECK_FOR_ERROR
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004983 yyval.InstVal = new GetElementPtrInst(tmpVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size());
4984 delete yyvsp[-2].TypeVal;
4985 delete yyvsp[0].ValueList;
4986 ;
4987 break;}
4988}
4989 /* the action file gets copied in in place of this dollarsign */
4990#line 543 "/usr/share/bison.simple"
Chris Lattner39b2e8b2007-05-04 04:01:37 +00004991
4992 yyvsp -= yylen;
4993 yyssp -= yylen;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004994#ifdef YYLSP_NEEDED
4995 yylsp -= yylen;
4996#endif
Reid Spencer7780acb2007-04-16 06:56:07 +00004997
Chris Lattnerce5f24e2007-07-05 17:26:49 +00004998#if YYDEBUG != 0
4999 if (yydebug)
5000 {
5001 short *ssp1 = yyss - 1;
5002 fprintf (stderr, "state stack now");
5003 while (ssp1 != yyssp)
5004 fprintf (stderr, " %d", *++ssp1);
5005 fprintf (stderr, "\n");
5006 }
5007#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005008
5009 *++yyvsp = yyval;
5010
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005011#ifdef YYLSP_NEEDED
5012 yylsp++;
5013 if (yylen == 0)
5014 {
5015 yylsp->first_line = yylloc.first_line;
5016 yylsp->first_column = yylloc.first_column;
5017 yylsp->last_line = (yylsp-1)->last_line;
5018 yylsp->last_column = (yylsp-1)->last_column;
5019 yylsp->text = 0;
5020 }
5021 else
5022 {
5023 yylsp->last_line = (yylsp+yylen-1)->last_line;
5024 yylsp->last_column = (yylsp+yylen-1)->last_column;
5025 }
5026#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00005027
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005028 /* Now "shift" the result of the reduction.
5029 Determine what state that goes to,
5030 based on the state we popped back to
5031 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005032
5033 yyn = yyr1[yyn];
5034
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005035 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5036 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005037 yystate = yytable[yystate];
5038 else
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005039 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005040
5041 goto yynewstate;
5042
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005043yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005044
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005045 if (! yyerrstatus)
5046 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005047 {
5048 ++yynerrs;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005049
5050#ifdef YYERROR_VERBOSE
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005051 yyn = yypact[yystate];
5052
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005053 if (yyn > YYFLAG && yyn < YYLAST)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005054 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005055 int size = 0;
5056 char *msg;
5057 int x, count;
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005058
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005059 count = 0;
5060 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5061 for (x = (yyn < 0 ? -yyn : 0);
5062 x < (sizeof(yytname) / sizeof(char *)); x++)
5063 if (yycheck[x + yyn] == x)
5064 size += strlen(yytname[x]) + 15, count++;
5065 msg = (char *) malloc(size + 15);
5066 if (msg != 0)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005067 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005068 strcpy(msg, "parse error");
5069
5070 if (count < 5)
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005071 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005072 count = 0;
5073 for (x = (yyn < 0 ? -yyn : 0);
5074 x < (sizeof(yytname) / sizeof(char *)); x++)
5075 if (yycheck[x + yyn] == x)
5076 {
5077 strcat(msg, count == 0 ? ", expecting `" : " or `");
5078 strcat(msg, yytname[x]);
5079 strcat(msg, "'");
5080 count++;
5081 }
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005082 }
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005083 yyerror(msg);
5084 free(msg);
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005085 }
5086 else
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005087 yyerror ("parse error; also virtual memory exceeded");
Chris Lattner39b2e8b2007-05-04 04:01:37 +00005088 }
5089 else
5090#endif /* YYERROR_VERBOSE */
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005091 yyerror("parse error");
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005092 }
5093
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005094 goto yyerrlab1;
5095yyerrlab1: /* here on error raised explicitly by an action */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005096
5097 if (yyerrstatus == 3)
5098 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005099 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005100
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005101 /* return failure if at end of input */
5102 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005103 YYABORT;
5104
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005105#if YYDEBUG != 0
5106 if (yydebug)
5107 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5108#endif
Reid Spencere4d87aa2006-12-23 06:05:41 +00005109
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005110 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005111 }
5112
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005113 /* Else will try to reuse lookahead token
5114 after shifting the error token. */
5115
5116 yyerrstatus = 3; /* Each real token shifted decrements this */
5117
5118 goto yyerrhandle;
5119
5120yyerrdefault: /* current state does not do anything special for the error token. */
5121
5122#if 0
5123 /* This is wrong; only states that explicitly want error tokens
5124 should shift them. */
5125 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5126 if (yyn) goto yydefault;
5127#endif
5128
5129yyerrpop: /* pop the current state because it cannot handle the error token */
5130
5131 if (yyssp == yyss) YYABORT;
5132 yyvsp--;
5133 yystate = *--yyssp;
5134#ifdef YYLSP_NEEDED
5135 yylsp--;
5136#endif
5137
5138#if YYDEBUG != 0
5139 if (yydebug)
5140 {
5141 short *ssp1 = yyss - 1;
5142 fprintf (stderr, "Error: state stack now");
5143 while (ssp1 != yyssp)
5144 fprintf (stderr, " %d", *++ssp1);
5145 fprintf (stderr, "\n");
5146 }
5147#endif
5148
5149yyerrhandle:
5150
5151 yyn = yypact[yystate];
5152 if (yyn == YYFLAG)
5153 goto yyerrdefault;
5154
5155 yyn += YYTERROR;
5156 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5157 goto yyerrdefault;
5158
5159 yyn = yytable[yyn];
5160 if (yyn < 0)
5161 {
5162 if (yyn == YYFLAG)
5163 goto yyerrpop;
5164 yyn = -yyn;
5165 goto yyreduce;
5166 }
5167 else if (yyn == 0)
5168 goto yyerrpop;
5169
Reid Spencer68a24bd2005-08-27 18:50:39 +00005170 if (yyn == YYFINAL)
5171 YYACCEPT;
5172
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005173#if YYDEBUG != 0
5174 if (yydebug)
5175 fprintf(stderr, "Shifting error token, ");
5176#endif
5177
Reid Spencer68a24bd2005-08-27 18:50:39 +00005178 *++yyvsp = yylval;
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005179#ifdef YYLSP_NEEDED
5180 *++yylsp = yylloc;
5181#endif
Anton Korobeynikovf52e6082007-04-29 18:38:24 +00005182
Reid Spencer68a24bd2005-08-27 18:50:39 +00005183 yystate = yyn;
5184 goto yynewstate;
5185
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005186 yyacceptlab:
5187 /* YYACCEPT comes here. */
5188 if (yyfree_stacks)
Reid Spencered951ea2007-05-19 07:22:10 +00005189 {
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005190 free (yyss);
5191 free (yyvs);
5192#ifdef YYLSP_NEEDED
5193 free (yyls);
Reid Spencered951ea2007-05-19 07:22:10 +00005194#endif
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005195 }
5196 return 0;
5197
5198 yyabortlab:
5199 /* YYABORT comes here. */
5200 if (yyfree_stacks)
5201 {
5202 free (yyss);
5203 free (yyvs);
5204#ifdef YYLSP_NEEDED
5205 free (yyls);
5206#endif
5207 }
5208 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005209}
Chris Lattnerce5f24e2007-07-05 17:26:49 +00005210#line 3066 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005211
5212
Reid Spencer14310612006-12-31 05:40:51 +00005213// common code from the two 'RunVMAsmParser' functions
5214static Module* RunParser(Module * M) {
5215
5216 llvmAsmlineno = 1; // Reset the current line number...
5217 CurModule.CurrentModule = M;
5218#if YYDEBUG
5219 yydebug = Debug;
5220#endif
5221
5222 // Check to make sure the parser succeeded
5223 if (yyparse()) {
5224 if (ParserResult)
5225 delete ParserResult;
5226 return 0;
5227 }
5228
Reid Spencer0d60b5a2007-03-30 01:37:39 +00005229 // Emit an error if there are any unresolved types left.
5230 if (!CurModule.LateResolveTypes.empty()) {
5231 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5232 if (DID.Type == ValID::LocalName) {
5233 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5234 } else {
5235 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5236 }
5237 if (ParserResult)
5238 delete ParserResult;
5239 return 0;
5240 }
5241
5242 // Emit an error if there are any unresolved values left.
5243 if (!CurModule.LateResolveValues.empty()) {
5244 Value *V = CurModule.LateResolveValues.back();
5245 std::map<Value*, std::pair<ValID, int> >::iterator I =
5246 CurModule.PlaceHolderInfo.find(V);
5247
5248 if (I != CurModule.PlaceHolderInfo.end()) {
5249 ValID &DID = I->second.first;
5250 if (DID.Type == ValID::LocalName) {
5251 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5252 } else {
5253 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5254 }
5255 if (ParserResult)
5256 delete ParserResult;
5257 return 0;
5258 }
5259 }
5260
Reid Spencer14310612006-12-31 05:40:51 +00005261 // Check to make sure that parsing produced a result
5262 if (!ParserResult)
5263 return 0;
5264
5265 // Reset ParserResult variable while saving its value for the result.
5266 Module *Result = ParserResult;
5267 ParserResult = 0;
5268
5269 return Result;
5270}
5271
Reid Spencer61c83e02006-08-18 08:43:06 +00005272void llvm::GenerateError(const std::string &message, int LineNo) {
5273 if (LineNo == -1) LineNo = llvmAsmlineno;
5274 // TODO: column number in exception
5275 if (TheParseError)
5276 TheParseError->setError(CurFilename, message, LineNo);
5277 TriggerError = 1;
5278}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005279
5280int yyerror(const char *ErrorMsg) {
5281 std::string where
5282 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5283 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
Reid Spenceref9b9a72007-02-05 20:47:22 +00005284 std::string errMsg = where + "error: " + std::string(ErrorMsg);
5285 if (yychar != YYEMPTY && yychar != 0)
5286 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
5287 "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005288 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005289 return 0;
5290}