blob: 1d3a05d0d7f20bd71ef539cef70c2763fd4f46f1 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002/* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004
Chris Lattnerb25c4ca2007-01-15 02:12:07 +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 Lattnerb25c4ca2007-01-15 02:12:07 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattnerb25c4ca2007-01-15 02:12:07 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattnerb25c4ca2007-01-15 02:12:07 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define SINTVAL 259
17#define UINTVAL 260
18#define FPVAL 261
19#define VOID 262
20#define INTTYPE 263
21#define FLOAT 264
22#define DOUBLE 265
23#define LABEL 266
24#define TYPE 267
25#define VAR_ID 268
26#define LABELSTR 269
27#define STRINGCONSTANT 270
28#define IMPLEMENTATION 271
29#define ZEROINITIALIZER 272
30#define TRUETOK 273
31#define FALSETOK 274
32#define BEGINTOK 275
33#define ENDTOK 276
34#define DECLARE 277
35#define DEFINE 278
36#define GLOBAL 279
37#define CONSTANT 280
38#define SECTION 281
39#define VOLATILE 282
40#define TO 283
41#define DOTDOTDOT 284
42#define NULL_TOK 285
43#define UNDEF 286
44#define INTERNAL 287
45#define LINKONCE 288
46#define WEAK 289
47#define APPENDING 290
48#define DLLIMPORT 291
49#define DLLEXPORT 292
50#define EXTERN_WEAK 293
51#define OPAQUE 294
52#define EXTERNAL 295
53#define TARGET 296
54#define TRIPLE 297
55#define ENDIAN 298
56#define POINTERSIZE 299
57#define LITTLE 300
58#define BIG 301
59#define ALIGN 302
60#define DEPLIBS 303
61#define CALL 304
62#define TAIL 305
63#define ASM_TOK 306
64#define MODULE 307
65#define SIDEEFFECT 308
66#define CC_TOK 309
67#define CCC_TOK 310
68#define CSRETCC_TOK 311
69#define FASTCC_TOK 312
70#define COLDCC_TOK 313
71#define X86_STDCALLCC_TOK 314
72#define X86_FASTCALLCC_TOK 315
73#define DATALAYOUT 316
74#define RET 317
75#define BR 318
76#define SWITCH 319
77#define INVOKE 320
78#define UNWIND 321
79#define UNREACHABLE 322
80#define ADD 323
81#define SUB 324
82#define MUL 325
83#define UDIV 326
84#define SDIV 327
85#define FDIV 328
86#define UREM 329
87#define SREM 330
88#define FREM 331
89#define AND 332
90#define OR 333
91#define XOR 334
92#define ICMP 335
93#define FCMP 336
94#define EQ 337
95#define NE 338
96#define SLT 339
97#define SGT 340
98#define SLE 341
99#define SGE 342
100#define ULT 343
101#define UGT 344
102#define ULE 345
103#define UGE 346
104#define OEQ 347
105#define ONE 348
106#define OLT 349
107#define OGT 350
108#define OLE 351
109#define OGE 352
110#define ORD 353
111#define UNO 354
112#define UEQ 355
113#define UNE 356
114#define MALLOC 357
115#define ALLOCA 358
116#define FREE 359
117#define LOAD 360
118#define STORE 361
119#define GETELEMENTPTR 362
120#define TRUNC 363
121#define ZEXT 364
122#define SEXT 365
123#define FPTRUNC 366
124#define FPEXT 367
125#define BITCAST 368
126#define UITOFP 369
127#define SITOFP 370
128#define FPTOUI 371
129#define FPTOSI 372
130#define INTTOPTR 373
131#define PTRTOINT 374
132#define PHI_TOK 375
133#define SELECT 376
134#define SHL 377
135#define LSHR 378
136#define ASHR 379
137#define VAARG 380
138#define EXTRACTELEMENT 381
139#define INSERTELEMENT 382
140#define SHUFFLEVECTOR 383
141#define NORETURN 384
142#define DEFAULT 385
143#define HIDDEN 386
Reid Spencer68a24bd2005-08-27 18:50:39 +0000144
Chris Lattnerb25c4ca2007-01-15 02:12:07 +0000145#line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000146
147#include "ParserInternals.h"
148#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000149#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000150#include "llvm/Instructions.h"
151#include "llvm/Module.h"
152#include "llvm/SymbolTable.h"
153#include "llvm/Support/GetElementPtrTypeIterator.h"
Reid Spencer14310612006-12-31 05:40:51 +0000154#include "llvm/Support/CommandLine.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000155#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000156#include "llvm/Support/MathExtras.h"
Reid Spencer481169e2006-12-01 00:33:46 +0000157#include "llvm/Support/Streams.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000158#include <algorithm>
Reid Spencer68a24bd2005-08-27 18:50:39 +0000159#include <list>
160#include <utility>
Reid Spencer14310612006-12-31 05:40:51 +0000161#ifndef NDEBUG
162#define YYDEBUG 1
163#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000164
Reid Spencere4f47592006-08-18 17:32:55 +0000165// The following is a gross hack. In order to rid the libAsmParser library of
166// exceptions, we have to have a way of getting the yyparse function to go into
167// an error situation. So, whenever we want an error to occur, the GenerateError
168// function (see bottom of file) sets TriggerError. Then, at the end of each
169// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
170// (a goto) to put YACC in error state. Furthermore, several calls to
171// GenerateError are made from inside productions and they must simulate the
172// previous exception behavior by exiting the production immediately. We have
173// replaced these with the GEN_ERROR macro which calls GeneratError and then
174// immediately invokes YYERROR. This would be so much cleaner if it was a
175// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000176static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000177#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000178#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
179
Reid Spencer68a24bd2005-08-27 18:50:39 +0000180int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
181int yylex(); // declaration" of xxx warnings.
182int yyparse();
183
184namespace llvm {
185 std::string CurFilename;
Reid Spencer14310612006-12-31 05:40:51 +0000186#if YYDEBUG
187static cl::opt<bool>
188Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
189 cl::Hidden, cl::init(false));
190#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +0000191}
192using namespace llvm;
193
194static Module *ParserResult;
195
196// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
197// relating to upreferences in the input stream.
198//
199//#define DEBUG_UPREFS 1
200#ifdef DEBUG_UPREFS
Bill Wendlinge8156192006-12-07 01:30:32 +0000201#define UR_OUT(X) cerr << X
Reid Spencer68a24bd2005-08-27 18:50:39 +0000202#else
203#define UR_OUT(X)
204#endif
205
206#define YYERROR_VERBOSE 1
207
Chris Lattnerb475c422005-11-12 18:22:38 +0000208static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000209
210
211// This contains info used when building the body of a function. It is
212// destroyed when the function is completed.
213//
214typedef std::vector<Value *> ValueList; // Numbered defs
Reid Spencer14310612006-12-31 05:40:51 +0000215
Reid Spencer68a24bd2005-08-27 18:50:39 +0000216static void
217ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
218 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
219
220static struct PerModuleInfo {
221 Module *CurrentModule;
222 std::map<const Type *, ValueList> Values; // Module level numbered definitions
223 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer861d9d62006-11-28 07:29:44 +0000224 std::vector<PATypeHolder> Types;
225 std::map<ValID, PATypeHolder> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000226
227 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000228 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000229 /// that we can resolve them later and print error messages as appropriate.
230 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
231
232 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
233 // references to global values. Global values may be referenced before they
234 // are defined, and if so, the temporary object that they represent is held
235 // here. This is used for forward references of GlobalValues.
236 //
237 typedef std::map<std::pair<const PointerType *,
238 ValID>, GlobalValue*> GlobalRefsType;
239 GlobalRefsType GlobalRefs;
240
241 void ModuleDone() {
242 // If we could not resolve some functions at function compilation time
243 // (calls to functions before they are defined), resolve them now... Types
244 // are resolved when the constant pool has been completely parsed.
245 //
246 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000247 if (TriggerError)
248 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000249
250 // Check to make sure that all global value forward references have been
251 // resolved!
252 //
253 if (!GlobalRefs.empty()) {
254 std::string UndefinedReferences = "Unresolved global references exist:\n";
255
256 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
257 I != E; ++I) {
258 UndefinedReferences += " " + I->first.first->getDescription() + " " +
259 I->first.second.getName() + "\n";
260 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000261 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000262 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000263 }
264
265 Values.clear(); // Clear out function local definitions
266 Types.clear();
267 CurrentModule = 0;
268 }
269
Reid Spencer68a24bd2005-08-27 18:50:39 +0000270 // GetForwardRefForGlobal - Check to see if there is a forward reference
271 // for this global. If so, remove it from the GlobalRefs map and return it.
272 // If not, just return null.
273 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
274 // Check to see if there is a forward reference to this global variable...
275 // if there is, eliminate it and patch the reference to use the new def'n.
276 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
277 GlobalValue *Ret = 0;
278 if (I != GlobalRefs.end()) {
279 Ret = I->second;
280 GlobalRefs.erase(I);
281 }
282 return Ret;
283 }
Reid Spencer8c8a2dc2007-01-02 21:54:12 +0000284
285 bool TypeIsUnresolved(PATypeHolder* PATy) {
286 // If it isn't abstract, its resolved
287 const Type* Ty = PATy->get();
288 if (!Ty->isAbstract())
289 return false;
290 // Traverse the type looking for abstract types. If it isn't abstract then
291 // we don't need to traverse that leg of the type.
292 std::vector<const Type*> WorkList, SeenList;
293 WorkList.push_back(Ty);
294 while (!WorkList.empty()) {
295 const Type* Ty = WorkList.back();
296 SeenList.push_back(Ty);
297 WorkList.pop_back();
298 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
299 // Check to see if this is an unresolved type
300 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
301 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
302 for ( ; I != E; ++I) {
303 if (I->second.get() == OpTy)
304 return true;
305 }
306 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
307 const Type* TheTy = SeqTy->getElementType();
308 if (TheTy->isAbstract() && TheTy != Ty) {
309 std::vector<const Type*>::iterator I = SeenList.begin(),
310 E = SeenList.end();
311 for ( ; I != E; ++I)
312 if (*I == TheTy)
313 break;
314 if (I == E)
315 WorkList.push_back(TheTy);
316 }
317 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
318 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
319 const Type* TheTy = StrTy->getElementType(i);
320 if (TheTy->isAbstract() && TheTy != Ty) {
321 std::vector<const Type*>::iterator I = SeenList.begin(),
322 E = SeenList.end();
323 for ( ; I != E; ++I)
324 if (*I == TheTy)
325 break;
326 if (I == E)
327 WorkList.push_back(TheTy);
328 }
329 }
330 }
331 }
332 return false;
333 }
334
335
Reid Spencer68a24bd2005-08-27 18:50:39 +0000336} CurModule;
337
338static struct PerFunctionInfo {
339 Function *CurrentFunction; // Pointer to current function being created
340
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000341 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000342 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000343 bool isDeclare; // Is this function a forward declararation?
344 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000345 GlobalValue::VisibilityTypes Visibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000346
347 /// BBForwardRefs - When we see forward references to basic blocks, keep
348 /// track of them here.
349 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
350 std::vector<BasicBlock*> NumberedBlocks;
351 unsigned NextBBNum;
352
353 inline PerFunctionInfo() {
354 CurrentFunction = 0;
355 isDeclare = false;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000356 Linkage = GlobalValue::ExternalLinkage;
357 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000358 }
359
360 inline void FunctionStart(Function *M) {
361 CurrentFunction = M;
362 NextBBNum = 0;
363 }
364
365 void FunctionDone() {
366 NumberedBlocks.clear();
367
368 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000369 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000370 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000371 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000372 return;
373 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000374
375 // Resolve all forward references now.
376 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
377
378 Values.clear(); // Clear out function local definitions
379 CurrentFunction = 0;
380 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000381 Linkage = GlobalValue::ExternalLinkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000382 Visibility = GlobalValue::DefaultVisibility;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000383 }
384} CurFun; // Info for the current function...
385
386static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
387
388
389//===----------------------------------------------------------------------===//
390// Code to handle definitions of all the types
391//===----------------------------------------------------------------------===//
392
393static int InsertValue(Value *V,
394 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
395 if (V->hasName()) return -1; // Is this a numbered definition?
396
397 // Yes, insert the value into the value table...
398 ValueList &List = ValueTab[V->getType()];
399 List.push_back(V);
400 return List.size()-1;
401}
402
403static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
404 switch (D.Type) {
405 case ValID::NumberVal: // Is it a numbered definition?
406 // Module constants occupy the lowest numbered slots...
407 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer861d9d62006-11-28 07:29:44 +0000408 return CurModule.Types[(unsigned)D.Num];
Reid Spencer68a24bd2005-08-27 18:50:39 +0000409 break;
410 case ValID::NameVal: // Is it a named definition?
411 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
412 D.destroy(); // Free old strdup'd memory...
413 return N;
414 }
415 break;
416 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000417 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000418 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000419 }
420
421 // If we reached here, we referenced either a symbol that we don't know about
422 // or an id number that hasn't been read yet. We may be referencing something
423 // forward, so just create an entry to be resolved later and get to it...
424 //
425 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
426
427
428 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000429 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000430 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000431 return 0;
432 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000433 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000434 return 0;
435 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000436 }
437
Reid Spencer861d9d62006-11-28 07:29:44 +0000438 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000439 if (I != CurModule.LateResolveTypes.end())
Reid Spencer861d9d62006-11-28 07:29:44 +0000440 return I->second;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000441
Reid Spencer861d9d62006-11-28 07:29:44 +0000442 Type *Typ = OpaqueType::get();
443 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
444 return Typ;
Reid Spencera132e042006-12-03 05:46:11 +0000445 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000446
447static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
448 SymbolTable &SymTab =
Reid Spencer78d033e2007-01-06 07:24:44 +0000449 inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() :
450 CurModule.CurrentModule->getValueSymbolTable();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000451 return SymTab.lookup(Ty, Name);
452}
453
454// getValNonImprovising - Look up the value specified by the provided type and
455// the provided ValID. If the value exists and has already been defined, return
456// it. Otherwise return null.
457//
458static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000459 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000460 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000461 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000462 return 0;
463 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000464
465 switch (D.Type) {
466 case ValID::NumberVal: { // Is it a numbered definition?
467 unsigned Num = (unsigned)D.Num;
468
469 // Module constants occupy the lowest numbered slots...
470 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
471 if (VI != CurModule.Values.end()) {
472 if (Num < VI->second.size())
473 return VI->second[Num];
474 Num -= VI->second.size();
475 }
476
477 // Make sure that our type is within bounds
478 VI = CurFun.Values.find(Ty);
479 if (VI == CurFun.Values.end()) return 0;
480
481 // Check that the number is within bounds...
482 if (VI->second.size() <= Num) return 0;
483
484 return VI->second[Num];
485 }
486
487 case ValID::NameVal: { // Is it a named definition?
488 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
489 if (N == 0) return 0;
490
491 D.destroy(); // Free old strdup'd memory...
492 return N;
493 }
494
495 // Check to make sure that "Ty" is an integral type, and that our
496 // value will fit into the specified type...
497 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000498 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000499 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000500 itostr(D.ConstPool64) + "' is invalid for type '" +
501 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000502 return 0;
503 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000504 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000505
506 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000507 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
508 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000509 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000510 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000511 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000512 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000513 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000514 }
515 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000516 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000517 }
518
519 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000520 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000521 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000522 return 0;
523 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000524 return ConstantFP::get(Ty, D.ConstPoolFP);
525
526 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000527 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000528 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000529 return 0;
530 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000531 return ConstantPointerNull::get(cast<PointerType>(Ty));
532
533 case ValID::ConstUndefVal: // Is it an undef value?
534 return UndefValue::get(Ty);
535
Chris Lattner7aa61892005-12-21 17:53:23 +0000536 case ValID::ConstZeroVal: // Is it a zero value?
537 return Constant::getNullValue(Ty);
538
Reid Spencer68a24bd2005-08-27 18:50:39 +0000539 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000540 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000541 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000542 return 0;
543 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000544 return D.ConstantValue;
545
Chris Lattner0e9c3762006-01-25 22:27:16 +0000546 case ValID::InlineAsmVal: { // Inline asm expression
547 const PointerType *PTy = dyn_cast<PointerType>(Ty);
548 const FunctionType *FTy =
549 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000550 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000551 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000552 return 0;
553 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000554 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
555 D.IAD->HasSideEffects);
556 D.destroy(); // Free InlineAsmDescriptor.
557 return IA;
558 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000559 default:
560 assert(0 && "Unhandled case!");
561 return 0;
562 } // End of switch
563
564 assert(0 && "Unhandled case!");
565 return 0;
566}
567
568// getVal - This function is identical to getValNonImprovising, except that if a
569// value is not already defined, it "improvises" by creating a placeholder var
570// that looks and acts just like the requested variable. When the value is
571// defined later, all uses of the placeholder variable are replaced with the
572// real thing.
573//
574static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000575 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000576 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000577 return 0;
578 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000579
580 // See if the value has already been defined.
581 Value *V = getValNonImprovising(Ty, ID);
582 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000583 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584
Reid Spencer5b7e7532006-09-28 19:28:24 +0000585 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000586 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000587 return 0;
588 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000589
590 // If we reached here, we referenced either a symbol that we don't know about
591 // or an id number that hasn't been read yet. We may be referencing something
592 // forward, so just create an entry to be resolved later and get to it...
593 //
594 V = new Argument(Ty);
595
596 // Remember where this forward reference came from. FIXME, shouldn't we try
597 // to recycle these things??
598 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
599 llvmAsmlineno)));
600
601 if (inFunctionScope())
602 InsertValue(V, CurFun.LateResolveValues);
603 else
604 InsertValue(V, CurModule.LateResolveValues);
605 return V;
606}
607
608/// getBBVal - This is used for two purposes:
609/// * If isDefinition is true, a new basic block with the specified ID is being
610/// defined.
611/// * If isDefinition is true, this is a reference to a basic block, which may
612/// or may not be a forward reference.
613///
614static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
615 assert(inFunctionScope() && "Can't get basic block at global scope!");
616
617 std::string Name;
618 BasicBlock *BB = 0;
619 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000620 default:
621 GenerateError("Illegal label reference " + ID.getName());
622 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000623 case ValID::NumberVal: // Is it a numbered definition?
624 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
625 CurFun.NumberedBlocks.resize(ID.Num+1);
626 BB = CurFun.NumberedBlocks[ID.Num];
627 break;
628 case ValID::NameVal: // Is it a named definition?
629 Name = ID.Name;
630 if (Value *N = CurFun.CurrentFunction->
Reid Spencer78d033e2007-01-06 07:24:44 +0000631 getValueSymbolTable().lookup(Type::LabelTy, Name))
Reid Spencer68a24bd2005-08-27 18:50:39 +0000632 BB = cast<BasicBlock>(N);
633 break;
634 }
635
636 // See if the block has already been defined.
637 if (BB) {
638 // If this is the definition of the block, make sure the existing value was
639 // just a forward reference. If it was a forward reference, there will be
640 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000641 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000642 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000643 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000644 return 0;
645 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646
647 ID.destroy(); // Free strdup'd memory.
648 return BB;
649 }
650
651 // Otherwise this block has not been seen before.
652 BB = new BasicBlock("", CurFun.CurrentFunction);
653 if (ID.Type == ValID::NameVal) {
654 BB->setName(ID.Name);
655 } else {
656 CurFun.NumberedBlocks[ID.Num] = BB;
657 }
658
659 // If this is not a definition, keep track of it so we can use it as a forward
660 // reference.
661 if (!isDefinition) {
662 // Remember where this forward reference came from.
663 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
664 } else {
665 // The forward declaration could have been inserted anywhere in the
666 // function: insert it into the correct place now.
667 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
668 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
669 }
670 ID.destroy();
671 return BB;
672}
673
674
675//===----------------------------------------------------------------------===//
676// Code to handle forward references in instructions
677//===----------------------------------------------------------------------===//
678//
679// This code handles the late binding needed with statements that reference
680// values not defined yet... for example, a forward branch, or the PHI node for
681// a loop body.
682//
683// This keeps a table (CurFun.LateResolveValues) of all such forward references
684// and back patchs after we are done.
685//
686
687// ResolveDefinitions - If we could not resolve some defs at parsing
688// time (forward branches, phi functions for loops, etc...) resolve the
689// defs now...
690//
691static void
692ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
693 std::map<const Type*,ValueList> *FutureLateResolvers) {
694 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
695 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
696 E = LateResolvers.end(); LRI != E; ++LRI) {
697 ValueList &List = LRI->second;
698 while (!List.empty()) {
699 Value *V = List.back();
700 List.pop_back();
701
702 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
703 CurModule.PlaceHolderInfo.find(V);
704 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
705
706 ValID &DID = PHI->second.first;
707
708 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000709 if (TriggerError)
710 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000711 if (TheRealValue) {
712 V->replaceAllUsesWith(TheRealValue);
713 delete V;
714 CurModule.PlaceHolderInfo.erase(PHI);
715 } else if (FutureLateResolvers) {
716 // Functions have their unresolved items forwarded to the module late
717 // resolver table
718 InsertValue(V, *FutureLateResolvers);
719 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000720 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000721 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000722 "' of type '" + V->getType()->getDescription() + "'",
723 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000724 return;
725 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000726 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000727 itostr(DID.Num) + " of type '" +
728 V->getType()->getDescription() + "'",
729 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000730 return;
731 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000732 }
733 }
734 }
735
736 LateResolvers.clear();
737}
738
739// ResolveTypeTo - A brand new type was just declared. This means that (if
740// name is not null) things referencing Name can be resolved. Otherwise, things
741// refering to the number can be resolved. Do this now.
742//
743static void ResolveTypeTo(char *Name, const Type *ToTy) {
744 ValID D;
745 if (Name) D = ValID::create(Name);
746 else D = ValID::create((int)CurModule.Types.size());
747
Reid Spencer861d9d62006-11-28 07:29:44 +0000748 std::map<ValID, PATypeHolder>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000749 CurModule.LateResolveTypes.find(D);
750 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer861d9d62006-11-28 07:29:44 +0000751 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000752 CurModule.LateResolveTypes.erase(I);
753 }
754}
755
756// setValueName - Set the specified value to the name given. The name may be
757// null potentially, in which case this is a noop. The string passed in is
758// assumed to be a malloc'd string buffer, and is free'd by this function.
759//
760static void setValueName(Value *V, char *NameStr) {
761 if (NameStr) {
762 std::string Name(NameStr); // Copy string
763 free(NameStr); // Free old string
764
Reid Spencer5b7e7532006-09-28 19:28:24 +0000765 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000766 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000767 return;
768 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000769
770 assert(inFunctionScope() && "Must be in function scope!");
Reid Spencer78d033e2007-01-06 07:24:44 +0000771 SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000772 if (ST.lookup(V->getType(), Name)) {
Reid Spencer63c34452007-01-05 21:51:07 +0000773 GenerateError("Redefinition of value '" + Name + "' of type '" +
774 V->getType()->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000775 return;
776 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000777
778 // Set the name.
779 V->setName(Name);
780 }
781}
782
783/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
784/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000785static GlobalVariable *
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000786ParseGlobalVariable(char *NameStr,
787 GlobalValue::LinkageTypes Linkage,
788 GlobalValue::VisibilityTypes Visibility,
Chris Lattnerb475c422005-11-12 18:22:38 +0000789 bool isConstantGlobal, const Type *Ty,
790 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000791 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000792 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000793 return 0;
794 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000795
796 const PointerType *PTy = PointerType::get(Ty);
797
798 std::string Name;
799 if (NameStr) {
800 Name = NameStr; // Copy string
801 free(NameStr); // Free old string
802 }
803
804 // See if this global value was forward referenced. If so, recycle the
805 // object.
806 ValID ID;
807 if (!Name.empty()) {
808 ID = ValID::create((char*)Name.c_str());
809 } else {
810 ID = ValID::create((int)CurModule.Values[PTy].size());
811 }
812
813 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
814 // Move the global to the end of the list, from whereever it was
815 // previously inserted.
816 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
817 CurModule.CurrentModule->getGlobalList().remove(GV);
818 CurModule.CurrentModule->getGlobalList().push_back(GV);
819 GV->setInitializer(Initializer);
820 GV->setLinkage(Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000821 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000822 GV->setConstant(isConstantGlobal);
823 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000824 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000825 }
826
827 // If this global has a name, check to see if there is already a definition
Reid Spencer63c34452007-01-05 21:51:07 +0000828 // of this global in the module. If so, it is an error.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000829 if (!Name.empty()) {
830 // We are a simple redefinition of a value, check to see if it is defined
831 // the same as the old one.
Reid Spencer63c34452007-01-05 21:51:07 +0000832 if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000833 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer63c34452007-01-05 21:51:07 +0000834 "' of type '" + Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000835 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000836 }
837 }
838
839 // Otherwise there is no existing GV to use, create one now.
840 GlobalVariable *GV =
841 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
842 CurModule.CurrentModule);
Anton Korobeynikov178a3522007-01-12 19:22:51 +0000843 GV->setVisibility(Visibility);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000844 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000845 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000846}
847
848// setTypeName - Set the specified type to the name given. The name may be
849// null potentially, in which case this is a noop. The string passed in is
850// assumed to be a malloc'd string buffer, and is freed by this function.
851//
852// This function returns true if the type has already been defined, but is
853// allowed to be redefined in the specified context. If the name is a new name
854// for the type plane, it is inserted and false is returned.
855static bool setTypeName(const Type *T, char *NameStr) {
856 assert(!inFunctionScope() && "Can't give types function-local names!");
857 if (NameStr == 0) return false;
858
859 std::string Name(NameStr); // Copy string
860 free(NameStr); // Free old string
861
862 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000863 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000864 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000865 return false;
866 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000867
868 // Set the type name, checking for conflicts as we do so.
869 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
870
871 if (AlreadyExists) { // Inserting a name that is already defined???
872 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
873 assert(Existing && "Conflict but no matching type?");
874
875 // There is only one case where this is allowed: when we are refining an
876 // opaque type. In this case, Existing will be an opaque type.
877 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
878 // We ARE replacing an opaque type!
879 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
880 return true;
881 }
882
883 // Otherwise, this is an attempt to redefine a type. That's okay if
884 // the redefinition is identical to the original. This will be so if
885 // Existing and T point to the same Type object. In this one case we
886 // allow the equivalent redefinition.
887 if (Existing == T) return true; // Yes, it's equal.
888
889 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer63c34452007-01-05 21:51:07 +0000890 GenerateError("Redefinition of type named '" + Name + "' of type '" +
891 T->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000892 }
893
894 return false;
895}
896
897//===----------------------------------------------------------------------===//
898// Code for handling upreferences in type names...
899//
900
901// TypeContains - Returns true if Ty directly contains E in it.
902//
903static bool TypeContains(const Type *Ty, const Type *E) {
904 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
905 E) != Ty->subtype_end();
906}
907
908namespace {
909 struct UpRefRecord {
910 // NestingLevel - The number of nesting levels that need to be popped before
911 // this type is resolved.
912 unsigned NestingLevel;
913
914 // LastContainedTy - This is the type at the current binding level for the
915 // type. Every time we reduce the nesting level, this gets updated.
916 const Type *LastContainedTy;
917
918 // UpRefTy - This is the actual opaque type that the upreference is
919 // represented with.
920 OpaqueType *UpRefTy;
921
922 UpRefRecord(unsigned NL, OpaqueType *URTy)
923 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
924 };
925}
926
927// UpRefs - A list of the outstanding upreferences that need to be resolved.
928static std::vector<UpRefRecord> UpRefs;
929
930/// HandleUpRefs - Every time we finish a new layer of types, this function is
931/// called. It loops through the UpRefs vector, which is a list of the
932/// currently active types. For each type, if the up reference is contained in
933/// the newly completed type, we decrement the level count. When the level
934/// count reaches zero, the upreferenced type is the type that is passed in:
935/// thus we can complete the cycle.
936///
937static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +0000938 // If Ty isn't abstract, or if there are no up-references in it, then there is
939 // nothing to resolve here.
940 if (!ty->isAbstract() || UpRefs.empty()) return ty;
941
Reid Spencer68a24bd2005-08-27 18:50:39 +0000942 PATypeHolder Ty(ty);
943 UR_OUT("Type '" << Ty->getDescription() <<
944 "' newly formed. Resolving upreferences.\n" <<
945 UpRefs.size() << " upreferences active!\n");
946
947 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
948 // to zero), we resolve them all together before we resolve them to Ty. At
949 // the end of the loop, if there is anything to resolve to Ty, it will be in
950 // this variable.
951 OpaqueType *TypeToResolve = 0;
952
953 for (unsigned i = 0; i != UpRefs.size(); ++i) {
954 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
955 << UpRefs[i].second->getDescription() << ") = "
956 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
957 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
958 // Decrement level of upreference
959 unsigned Level = --UpRefs[i].NestingLevel;
960 UpRefs[i].LastContainedTy = Ty;
961 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
962 if (Level == 0) { // Upreference should be resolved!
963 if (!TypeToResolve) {
964 TypeToResolve = UpRefs[i].UpRefTy;
965 } else {
966 UR_OUT(" * Resolving upreference for "
967 << UpRefs[i].second->getDescription() << "\n";
968 std::string OldName = UpRefs[i].UpRefTy->getDescription());
969 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
970 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
971 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
972 }
973 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
974 --i; // Do not skip the next element...
975 }
976 }
977 }
978
979 if (TypeToResolve) {
980 UR_OUT(" * Resolving upreference for "
981 << UpRefs[i].second->getDescription() << "\n";
982 std::string OldName = TypeToResolve->getDescription());
983 TypeToResolve->refineAbstractTypeTo(Ty);
984 }
985
986 return Ty;
987}
988
Reid Spencer68a24bd2005-08-27 18:50:39 +0000989//===----------------------------------------------------------------------===//
990// RunVMAsmParser - Define an interface to this parser
991//===----------------------------------------------------------------------===//
992//
Reid Spencer14310612006-12-31 05:40:51 +0000993static Module* RunParser(Module * M);
994
Reid Spencer68a24bd2005-08-27 18:50:39 +0000995Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
996 set_scan_file(F);
997
998 CurFilename = Filename;
999 return RunParser(new Module(CurFilename));
1000}
1001
1002Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1003 set_scan_string(AsmString);
1004
1005 CurFilename = "from_memory";
1006 if (M == NULL) {
1007 return RunParser(new Module (CurFilename));
1008 } else {
1009 return RunParser(M);
1010 }
1011}
1012
1013
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001014#line 883 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1015typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001016 llvm::Module *ModuleVal;
1017 llvm::Function *FunctionVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001018 llvm::BasicBlock *BasicBlockVal;
1019 llvm::TerminatorInst *TermInstVal;
1020 llvm::Instruction *InstVal;
Reid Spencera132e042006-12-03 05:46:11 +00001021 llvm::Constant *ConstVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001022
Reid Spencera132e042006-12-03 05:46:11 +00001023 const llvm::Type *PrimType;
Reid Spencer14310612006-12-31 05:40:51 +00001024 std::list<llvm::PATypeHolder> *TypeList;
Reid Spencera132e042006-12-03 05:46:11 +00001025 llvm::PATypeHolder *TypeVal;
1026 llvm::Value *ValueVal;
Reid Spencera132e042006-12-03 05:46:11 +00001027 std::vector<llvm::Value*> *ValueList;
Reid Spencer14310612006-12-31 05:40:51 +00001028 llvm::ArgListType *ArgList;
1029 llvm::TypeWithAttrs TypeWithAttrs;
1030 llvm::TypeWithAttrsList *TypeWithAttrsList;
1031 llvm::ValueRefList *ValueRefList;
1032
Reid Spencer68a24bd2005-08-27 18:50:39 +00001033 // Represent the RHS of PHI node
Reid Spencera132e042006-12-03 05:46:11 +00001034 std::list<std::pair<llvm::Value*,
1035 llvm::BasicBlock*> > *PHIList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001036 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
Reid Spencera132e042006-12-03 05:46:11 +00001037 std::vector<llvm::Constant*> *ConstVector;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001038
1039 llvm::GlobalValue::LinkageTypes Linkage;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001040 llvm::GlobalValue::VisibilityTypes Visibility;
Reid Spencer14310612006-12-31 05:40:51 +00001041 llvm::FunctionType::ParameterAttributes ParamAttrs;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001042 int64_t SInt64Val;
1043 uint64_t UInt64Val;
1044 int SIntVal;
1045 unsigned UIntVal;
1046 double FPVal;
1047 bool BoolVal;
1048
1049 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001050 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001051
Reid Spencera132e042006-12-03 05:46:11 +00001052 llvm::Instruction::BinaryOps BinaryOpVal;
1053 llvm::Instruction::TermOps TermOpVal;
1054 llvm::Instruction::MemoryOps MemOpVal;
1055 llvm::Instruction::CastOps CastOpVal;
1056 llvm::Instruction::OtherOps OtherOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001057 llvm::Module::Endianness Endianness;
Reid Spencera132e042006-12-03 05:46:11 +00001058 llvm::ICmpInst::Predicate IPredicate;
1059 llvm::FCmpInst::Predicate FPredicate;
Reid Spencer6f407902007-01-13 05:00:46 +00001060} YYSTYPE;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001061#include <stdio.h>
1062
1063#ifndef __cplusplus
1064#ifndef __STDC__
1065#define const
1066#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001067#endif
1068
1069
1070
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001071#define YYFINAL 569
1072#define YYFLAG -32768
1073#define YYNTBASE 147
Reid Spencer68a24bd2005-08-27 18:50:39 +00001074
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001075#define YYTRANSLATE(x) ((unsigned)(x) <= 386 ? yytranslate[x] : 225)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001076
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001077static const short yytranslate[] = { 0,
1078 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1079 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1080 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1081 2, 2, 2, 2, 2, 2, 2, 2, 2, 137,
1082 138, 135, 2, 134, 2, 2, 2, 2, 2, 2,
1083 2, 2, 2, 2, 2, 2, 2, 2, 2, 142,
1084 133, 143, 2, 2, 2, 2, 2, 2, 2, 2,
1085 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1086 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1087 139, 136, 141, 2, 2, 2, 2, 2, 146, 2,
1088 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1089 2, 2, 2, 2, 2, 2, 2, 2, 2, 140,
1090 2, 2, 144, 2, 145, 2, 2, 2, 2, 2,
1091 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1092 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1093 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1094 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1095 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1096 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1097 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1098 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1099 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1100 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1102 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1103 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1104 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1105 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1106 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1107 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1108 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1109 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1110 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1111 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1112 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1113 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1114 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1115 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1116 127, 128, 129, 130, 131, 132
1117};
Reid Spencere4d87aa2006-12-23 06:05:41 +00001118
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001119#if YYDEBUG != 0
1120static const short yyprhs[] = { 0,
1121 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1122 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1123 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1124 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1125 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1126 100, 102, 104, 106, 108, 110, 112, 114, 116, 119,
1127 120, 122, 124, 126, 128, 130, 132, 134, 136, 137,
1128 139, 140, 142, 144, 145, 147, 149, 151, 153, 154,
1129 156, 158, 160, 162, 164, 166, 169, 171, 173, 174,
1130 177, 179, 181, 182, 185, 186, 189, 190, 194, 197,
1131 198, 200, 201, 205, 207, 210, 212, 214, 216, 218,
1132 220, 222, 225, 227, 230, 236, 242, 248, 254, 258,
1133 261, 267, 272, 275, 277, 279, 281, 285, 287, 291,
1134 293, 294, 296, 300, 305, 309, 313, 318, 323, 327,
1135 334, 340, 343, 346, 349, 352, 355, 358, 361, 364,
1136 367, 370, 377, 383, 392, 399, 406, 414, 422, 429,
1137 436, 445, 454, 458, 460, 462, 464, 466, 467, 469,
1138 472, 473, 477, 478, 482, 486, 488, 492, 496, 497,
1139 504, 505, 513, 514, 522, 525, 529, 531, 533, 535,
1140 539, 543, 547, 551, 555, 559, 561, 562, 564, 566,
1141 568, 569, 575, 579, 581, 585, 587, 588, 598, 600,
1142 602, 607, 609, 611, 614, 618, 619, 621, 623, 625,
1143 627, 629, 631, 633, 635, 637, 641, 643, 649, 651,
1144 653, 655, 657, 660, 663, 666, 670, 673, 674, 676,
1145 679, 682, 686, 696, 706, 715, 730, 732, 734, 741,
1146 747, 750, 757, 765, 769, 775, 776, 777, 781, 784,
1147 786, 792, 798, 805, 812, 817, 822, 829, 834, 839,
1148 846, 853, 856, 865, 867, 869, 870, 874, 881, 885,
1149 892, 895, 900, 907
1150};
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001151
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001152static const short yyrhs[] = { 5,
1153 0, 6, 0, 69, 0, 70, 0, 71, 0, 72,
1154 0, 73, 0, 74, 0, 75, 0, 76, 0, 77,
1155 0, 78, 0, 79, 0, 80, 0, 109, 0, 110,
1156 0, 111, 0, 112, 0, 113, 0, 114, 0, 115,
1157 0, 116, 0, 117, 0, 118, 0, 119, 0, 120,
1158 0, 123, 0, 124, 0, 125, 0, 83, 0, 84,
1159 0, 85, 0, 86, 0, 87, 0, 88, 0, 89,
1160 0, 90, 0, 91, 0, 92, 0, 93, 0, 94,
1161 0, 95, 0, 96, 0, 97, 0, 98, 0, 99,
1162 0, 100, 0, 101, 0, 102, 0, 89, 0, 90,
1163 0, 91, 0, 92, 0, 19, 0, 20, 0, 9,
1164 0, 10, 0, 11, 0, 197, 133, 0, 0, 33,
1165 0, 35, 0, 34, 0, 36, 0, 38, 0, 37,
1166 0, 39, 0, 41, 0, 0, 132, 0, 0, 37,
1167 0, 39, 0, 0, 33, 0, 34, 0, 35, 0,
1168 38, 0, 0, 56, 0, 57, 0, 58, 0, 59,
1169 0, 60, 0, 61, 0, 55, 4, 0, 110, 0,
1170 111, 0, 0, 164, 163, 0, 130, 0, 163, 0,
1171 0, 166, 165, 0, 0, 48, 4, 0, 0, 134,
1172 48, 4, 0, 27, 16, 0, 0, 169, 0, 0,
1173 134, 172, 171, 0, 169, 0, 48, 4, 0, 9,
1174 0, 10, 0, 11, 0, 12, 0, 40, 0, 173,
1175 0, 174, 135, 0, 209, 0, 136, 4, 0, 174,
1176 137, 178, 138, 166, 0, 8, 137, 178, 138, 166,
1177 0, 139, 4, 140, 174, 141, 0, 142, 4, 140,
1178 174, 143, 0, 144, 179, 145, 0, 144, 145, 0,
1179 142, 144, 179, 145, 143, 0, 142, 144, 145, 143,
1180 0, 174, 164, 0, 174, 0, 8, 0, 175, 0,
1181 177, 134, 175, 0, 177, 0, 177, 134, 30, 0,
1182 30, 0, 0, 174, 0, 179, 134, 174, 0, 174,
1183 139, 182, 141, 0, 174, 139, 141, 0, 174, 146,
1184 16, 0, 174, 142, 182, 143, 0, 174, 144, 182,
1185 145, 0, 174, 144, 145, 0, 174, 142, 144, 182,
1186 145, 143, 0, 174, 142, 144, 145, 143, 0, 174,
1187 31, 0, 174, 32, 0, 174, 209, 0, 174, 181,
1188 0, 174, 18, 0, 154, 3, 0, 154, 4, 0,
1189 9, 19, 0, 9, 20, 0, 155, 7, 0, 150,
1190 137, 180, 29, 174, 138, 0, 108, 137, 180, 220,
1191 138, 0, 122, 137, 180, 134, 180, 134, 180, 138,
1192 0, 148, 137, 180, 134, 180, 138, 0, 149, 137,
1193 180, 134, 180, 138, 0, 81, 152, 137, 180, 134,
1194 180, 138, 0, 82, 153, 137, 180, 134, 180, 138,
1195 0, 151, 137, 180, 134, 180, 138, 0, 127, 137,
1196 180, 134, 180, 138, 0, 128, 137, 180, 134, 180,
1197 134, 180, 138, 0, 129, 137, 180, 134, 180, 134,
1198 180, 138, 0, 182, 134, 180, 0, 180, 0, 25,
1199 0, 26, 0, 185, 0, 0, 186, 0, 185, 186,
1200 0, 0, 24, 187, 205, 0, 0, 23, 188, 206,
1201 0, 53, 52, 192, 0, 17, 0, 156, 13, 174,
1202 0, 156, 13, 8, 0, 0, 156, 159, 183, 180,
1203 189, 171, 0, 0, 156, 157, 159, 183, 180, 190,
1204 171, 0, 0, 156, 158, 159, 183, 174, 191, 171,
1205 0, 42, 194, 0, 49, 133, 195, 0, 16, 0,
1206 47, 0, 46, 0, 44, 133, 193, 0, 45, 133,
1207 4, 0, 43, 133, 16, 0, 62, 133, 16, 0,
1208 139, 196, 141, 0, 196, 134, 16, 0, 16, 0,
1209 0, 14, 0, 16, 0, 197, 0, 0, 199, 134,
1210 174, 164, 198, 0, 174, 164, 198, 0, 199, 0,
1211 199, 134, 30, 0, 30, 0, 0, 162, 176, 197,
1212 137, 200, 138, 166, 170, 167, 0, 21, 0, 144,
1213 0, 161, 159, 201, 202, 0, 22, 0, 145, 0,
1214 212, 204, 0, 160, 159, 201, 0, 0, 54, 0,
1215 3, 0, 4, 0, 7, 0, 19, 0, 20, 0,
1216 31, 0, 32, 0, 18, 0, 142, 182, 143, 0,
1217 181, 0, 52, 207, 16, 134, 16, 0, 147, 0,
1218 197, 0, 209, 0, 208, 0, 174, 210, 0, 212,
1219 213, 0, 203, 213, 0, 214, 156, 215, 0, 214,
1220 217, 0, 0, 15, 0, 63, 211, 0, 63, 8,
1221 0, 64, 12, 210, 0, 64, 9, 210, 134, 12,
1222 210, 134, 12, 210, 0, 65, 154, 210, 134, 12,
1223 210, 139, 216, 141, 0, 65, 154, 210, 134, 12,
1224 210, 139, 141, 0, 66, 162, 176, 210, 137, 219,
1225 138, 166, 29, 12, 210, 67, 12, 210, 0, 67,
1226 0, 68, 0, 216, 154, 208, 134, 12, 210, 0,
1227 154, 208, 134, 12, 210, 0, 156, 222, 0, 174,
1228 139, 210, 134, 210, 141, 0, 218, 134, 139, 210,
1229 134, 210, 141, 0, 174, 210, 164, 0, 219, 134,
1230 174, 210, 164, 0, 0, 0, 220, 134, 211, 0,
1231 51, 50, 0, 50, 0, 148, 174, 210, 134, 210,
1232 0, 149, 174, 210, 134, 210, 0, 81, 152, 174,
1233 210, 134, 210, 0, 82, 153, 174, 210, 134, 210,
1234 0, 151, 211, 134, 211, 0, 150, 211, 29, 174,
1235 0, 122, 211, 134, 211, 134, 211, 0, 126, 211,
1236 134, 174, 0, 127, 211, 134, 211, 0, 128, 211,
1237 134, 211, 134, 211, 0, 129, 211, 134, 211, 134,
1238 211, 0, 121, 218, 0, 221, 162, 176, 210, 137,
1239 219, 138, 166, 0, 224, 0, 28, 0, 0, 103,
1240 174, 168, 0, 103, 174, 134, 9, 210, 168, 0,
1241 104, 174, 168, 0, 104, 174, 134, 9, 210, 168,
1242 0, 105, 211, 0, 223, 106, 174, 210, 0, 223,
1243 107, 211, 134, 174, 210, 0, 108, 174, 210, 220,
1244 0
1245};
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001246
1247#endif
1248
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001249#if YYDEBUG != 0
1250static const short yyrline[] = { 0,
1251 1031, 1032, 1042, 1042, 1042, 1042, 1042, 1042, 1042, 1042,
1252 1042, 1043, 1043, 1043, 1044, 1044, 1044, 1044, 1044, 1044,
1253 1044, 1045, 1045, 1045, 1045, 1045, 1046, 1046, 1046, 1048,
1254 1048, 1049, 1049, 1050, 1050, 1051, 1051, 1052, 1052, 1056,
1255 1056, 1057, 1057, 1058, 1058, 1059, 1059, 1060, 1060, 1061,
1256 1061, 1062, 1062, 1063, 1064, 1069, 1070, 1070, 1073, 1077,
1257 1083, 1084, 1085, 1086, 1087, 1091, 1092, 1093, 1097, 1098,
1258 1102, 1103, 1104, 1108, 1109, 1110, 1111, 1112, 1115, 1115,
1259 1116, 1117, 1118, 1119, 1120, 1121, 1129, 1130, 1133, 1134,
1260 1139, 1140, 1143, 1144, 1151, 1151, 1158, 1158, 1167, 1175,
1261 1175, 1181, 1181, 1183, 1188, 1201, 1201, 1201, 1201, 1204,
1262 1208, 1212, 1219, 1224, 1232, 1250, 1268, 1273, 1285, 1295,
1263 1299, 1309, 1316, 1323, 1330, 1335, 1340, 1347, 1348, 1355,
1264 1362, 1370, 1375, 1386, 1414, 1430, 1459, 1487, 1512, 1531,
1265 1556, 1575, 1587, 1594, 1657, 1667, 1677, 1683, 1689, 1694,
1266 1699, 1707, 1721, 1742, 1750, 1756, 1767, 1772, 1777, 1786,
1267 1792, 1798, 1807, 1811, 1819, 1819, 1830, 1835, 1843, 1844,
1268 1848, 1848, 1852, 1852, 1855, 1858, 1870, 1894, 1905, 1911,
1269 1914, 1919, 1922, 1928, 1932, 1935, 1941, 1954, 1955, 1957,
1270 1961, 1970, 1974, 1979, 1981, 1986, 1991, 2000, 2000, 2001,
1271 2001, 2003, 2013, 2024, 2028, 2037, 2046, 2051, 2157, 2157,
1272 2159, 2168, 2168, 2170, 2175, 2187, 2191, 2196, 2200, 2204,
1273 2208, 2212, 2216, 2220, 2224, 2228, 2253, 2257, 2271, 2275,
1274 2281, 2281, 2287, 2296, 2300, 2309, 2320, 2329, 2341, 2354,
1275 2358, 2362, 2367, 2377, 2396, 2405, 2472, 2476, 2483, 2494,
1276 2507, 2516, 2527, 2537, 2545, 2553, 2556, 2557, 2564, 2568,
1277 2573, 2594, 2611, 2624, 2637, 2646, 2659, 2667, 2674, 2680,
1278 2686, 2692, 2707, 2770, 2775, 2779, 2786, 2793, 2801, 2808,
1279 2816, 2824, 2838, 2855
1280};
1281#endif
1282
1283
1284#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1285
1286static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1287"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","INTTYPE","FLOAT","DOUBLE","LABEL",
1288"TYPE","VAR_ID","LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER",
1289"TRUETOK","FALSETOK","BEGINTOK","ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT",
1290"SECTION","VOLATILE","TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL","LINKONCE",
1291"WEAK","APPENDING","DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","EXTERNAL",
1292"TARGET","TRIPLE","ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL",
1293"TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK",
1294"COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR",
1295"SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV",
1296"UREM","SREM","FREM","AND","OR","XOR","ICMP","FCMP","EQ","NE","SLT","SGT","SLE",
1297"SGE","ULT","UGT","ULE","UGE","OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO",
1298"UEQ","UNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","TRUNC",
1299"ZEXT","SEXT","FPTRUNC","FPEXT","BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI",
1300"INTTOPTR","PTRTOINT","PHI_TOK","SELECT","SHL","LSHR","ASHR","VAARG","EXTRACTELEMENT",
1301"INSERTELEMENT","SHUFFLEVECTOR","NORETURN","DEFAULT","HIDDEN","'='","','","'*'",
1302"'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","INTVAL",
1303"ArithmeticOps","LogicalOps","CastOps","ShiftOps","IPredicates","FPredicates",
1304"IntType","FPType","OptAssign","GVInternalLinkage","GVExternalLinkage","GVVisibilityStyle",
1305"FunctionDeclareLinkage","FunctionDefineLinkage","OptCallingConv","ParamAttr",
1306"OptParamAttrs","FuncAttr","OptFuncAttrs","OptAlign","OptCAlign","SectionString",
1307"OptSection","GlobalVarAttributes","GlobalVarAttribute","PrimType","Types","ArgType",
1308"ResultTypes","ArgTypeList","ArgTypeListI","TypeListI","ConstVal","ConstExpr",
1309"ConstVector","GlobalType","Module","DefinitionList","Definition","@1","@2",
1310"@3","@4","@5","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition",
1311"LibList","Name","OptName","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader",
1312"END","Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef",
1313"ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1314"JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal",
1315"OptVolatile","MemoryInst", NULL
1316};
1317#endif
1318
1319static const short yyr1[] = { 0,
1320 147, 147, 148, 148, 148, 148, 148, 148, 148, 148,
1321 148, 149, 149, 149, 150, 150, 150, 150, 150, 150,
1322 150, 150, 150, 150, 150, 150, 151, 151, 151, 152,
1323 152, 152, 152, 152, 152, 152, 152, 152, 152, 153,
1324 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
1325 153, 153, 153, 153, 153, 154, 155, 155, 156, 156,
1326 157, 157, 157, 157, 157, 158, 158, 158, 159, 159,
1327 160, 160, 160, 161, 161, 161, 161, 161, 162, 162,
1328 162, 162, 162, 162, 162, 162, 163, 163, 164, 164,
1329 165, 165, 166, 166, 167, 167, 168, 168, 169, 170,
1330 170, 171, 171, 172, 172, 173, 173, 173, 173, 174,
1331 174, 174, 174, 174, 174, 174, 174, 174, 174, 174,
1332 174, 174, 175, 176, 176, 177, 177, 178, 178, 178,
1333 178, 179, 179, 180, 180, 180, 180, 180, 180, 180,
1334 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
1335 180, 181, 181, 181, 181, 181, 181, 181, 181, 181,
1336 181, 181, 182, 182, 183, 183, 184, 184, 185, 185,
1337 187, 186, 188, 186, 186, 186, 186, 186, 189, 186,
1338 190, 186, 191, 186, 186, 186, 192, 193, 193, 194,
1339 194, 194, 194, 195, 196, 196, 196, 197, 197, 198,
1340 198, 199, 199, 200, 200, 200, 200, 201, 202, 202,
1341 203, 204, 204, 205, 206, 207, 207, 208, 208, 208,
1342 208, 208, 208, 208, 208, 208, 208, 208, 209, 209,
1343 210, 210, 211, 212, 212, 213, 214, 214, 214, 215,
1344 215, 215, 215, 215, 215, 215, 215, 215, 216, 216,
1345 217, 218, 218, 219, 219, 219, 220, 220, 221, 221,
1346 222, 222, 222, 222, 222, 222, 222, 222, 222, 222,
1347 222, 222, 222, 222, 223, 223, 224, 224, 224, 224,
1348 224, 224, 224, 224
1349};
1350
1351static const short yyr2[] = { 0,
1352 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1353 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1355 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1356 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1357 1, 1, 1, 1, 1, 1, 1, 1, 2, 0,
1358 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1359 0, 1, 1, 0, 1, 1, 1, 1, 0, 1,
1360 1, 1, 1, 1, 1, 2, 1, 1, 0, 2,
1361 1, 1, 0, 2, 0, 2, 0, 3, 2, 0,
1362 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1363 1, 2, 1, 2, 5, 5, 5, 5, 3, 2,
1364 5, 4, 2, 1, 1, 1, 3, 1, 3, 1,
1365 0, 1, 3, 4, 3, 3, 4, 4, 3, 6,
1366 5, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1367 2, 6, 5, 8, 6, 6, 7, 7, 6, 6,
1368 8, 8, 3, 1, 1, 1, 1, 0, 1, 2,
1369 0, 3, 0, 3, 3, 1, 3, 3, 0, 6,
1370 0, 7, 0, 7, 2, 3, 1, 1, 1, 3,
1371 3, 3, 3, 3, 3, 1, 0, 1, 1, 1,
1372 0, 5, 3, 1, 3, 1, 0, 9, 1, 1,
1373 4, 1, 1, 2, 3, 0, 1, 1, 1, 1,
1374 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
1375 1, 1, 2, 2, 2, 3, 2, 0, 1, 2,
1376 2, 3, 9, 9, 8, 14, 1, 1, 6, 5,
1377 2, 6, 7, 3, 5, 0, 0, 3, 2, 1,
1378 5, 5, 6, 6, 4, 4, 6, 4, 4, 6,
1379 6, 2, 8, 1, 1, 0, 3, 6, 3, 6,
1380 2, 4, 6, 4
1381};
1382
1383static const short yydefact[] = { 60,
1384 198, 199, 176, 173, 171, 0, 0, 0, 69, 60,
1385 169, 0, 71, 74, 0, 0, 0, 0, 185, 0,
1386 0, 0, 61, 63, 62, 64, 66, 65, 67, 68,
1387 70, 69, 69, 0, 170, 59, 72, 73, 69, 174,
1388 75, 76, 77, 78, 69, 238, 172, 238, 0, 0,
1389 0, 0, 197, 186, 187, 175, 1, 2, 178, 106,
1390 107, 108, 109, 110, 0, 0, 0, 0, 229, 111,
1391 177, 230, 113, 0, 0, 165, 166, 0, 79, 79,
1392 239, 235, 60, 212, 213, 214, 234, 192, 189, 188,
1393 190, 191, 193, 196, 0, 131, 114, 0, 0, 0,
1394 0, 120, 132, 0, 112, 131, 0, 0, 106, 107,
1395 108, 0, 0, 0, 179, 0, 80, 81, 82, 83,
1396 84, 85, 0, 215, 0, 276, 237, 0, 194, 130,
1397 89, 126, 128, 0, 0, 0, 0, 0, 0, 119,
1398 0, 181, 183, 149, 150, 147, 148, 151, 146, 142,
1399 143, 3, 4, 5, 6, 7, 8, 9, 10, 11,
1400 12, 13, 14, 0, 0, 0, 15, 16, 17, 18,
1401 19, 20, 21, 22, 23, 24, 25, 26, 0, 27,
1402 28, 29, 0, 0, 0, 0, 0, 0, 0, 0,
1403 0, 0, 0, 145, 144, 102, 86, 125, 124, 0,
1404 209, 210, 211, 275, 260, 0, 0, 0, 0, 79,
1405 247, 248, 0, 0, 0, 0, 0, 0, 0, 0,
1406 0, 0, 0, 0, 0, 0, 0, 0, 236, 79,
1407 251, 0, 274, 195, 123, 0, 93, 0, 0, 122,
1408 0, 133, 93, 102, 102, 30, 31, 32, 33, 34,
1409 35, 36, 37, 38, 39, 0, 54, 55, 50, 51,
1410 52, 53, 40, 41, 42, 43, 44, 45, 46, 47,
1411 48, 49, 0, 0, 0, 0, 0, 0, 135, 164,
1412 0, 0, 0, 139, 0, 136, 0, 0, 0, 0,
1413 0, 180, 0, 259, 241, 0, 240, 0, 0, 56,
1414 0, 0, 0, 0, 97, 97, 281, 0, 0, 272,
1415 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1416 0, 0, 87, 88, 90, 129, 127, 116, 117, 118,
1417 121, 115, 182, 184, 0, 0, 257, 0, 0, 0,
1418 0, 0, 134, 120, 132, 0, 137, 138, 0, 0,
1419 0, 0, 0, 0, 104, 102, 207, 218, 219, 220,
1420 225, 221, 222, 223, 224, 216, 0, 227, 232, 231,
1421 233, 0, 242, 0, 0, 0, 0, 0, 277, 0,
1422 279, 257, 0, 0, 0, 0, 0, 0, 0, 0,
1423 0, 0, 0, 0, 0, 0, 91, 92, 94, 0,
1424 0, 0, 0, 0, 0, 0, 163, 141, 0, 0,
1425 0, 0, 0, 99, 105, 103, 206, 89, 204, 0,
1426 217, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1427 0, 284, 0, 0, 0, 268, 269, 0, 0, 0,
1428 0, 266, 265, 0, 282, 0, 0, 0, 0, 153,
1429 0, 0, 0, 0, 140, 0, 0, 0, 0, 201,
1430 0, 93, 0, 226, 0, 0, 256, 0, 0, 97,
1431 98, 97, 0, 0, 0, 0, 0, 261, 262, 256,
1432 0, 0, 0, 258, 0, 160, 0, 0, 155, 156,
1433 152, 159, 200, 203, 205, 89, 100, 0, 0, 0,
1434 0, 0, 263, 264, 0, 278, 280, 0, 0, 267,
1435 270, 271, 0, 283, 157, 158, 0, 0, 0, 201,
1436 101, 95, 228, 0, 0, 89, 0, 93, 252, 0,
1437 93, 154, 161, 162, 202, 0, 208, 0, 245, 0,
1438 0, 254, 0, 0, 253, 273, 96, 243, 0, 244,
1439 0, 89, 0, 0, 0, 255, 0, 0, 0, 0,
1440 250, 0, 0, 249, 0, 246, 0, 0, 0
1441};
1442
1443static const short yydefgoto[] = { 69,
1444 190, 191, 192, 193, 256, 273, 112, 113, 9, 32,
1445 33, 34, 39, 45, 123, 325, 235, 399, 328, 537,
1446 379, 355, 522, 292, 356, 70, 114, 132, 200, 133,
1447 134, 104, 280, 368, 281, 78, 567, 10, 11, 14,
1448 13, 196, 244, 245, 56, 91, 19, 54, 95, 72,
1449 494, 419, 420, 124, 203, 46, 86, 47, 40, 422,
1450 369, 73, 371, 297, 48, 82, 83, 229, 541, 127,
1451 310, 502, 402, 230, 231, 232, 233
1452};
1453
1454static const short yypact[] = { 399,
1455-32768,-32768,-32768,-32768,-32768, 12, -43, -5, 66, 525,
1456-32768, 47, 142, 122, 58, 63, 82, 88,-32768, -33,
1457 119, 789,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1458-32768, -13, -13, 222,-32768,-32768,-32768,-32768, -13,-32768,
1459-32768,-32768,-32768,-32768, -13, 123,-32768, -6, 208, 218,
1460 223, 224, 243,-32768,-32768,-32768,-32768,-32768, 124,-32768,
1461-32768,-32768,-32768,-32768, 267, 276, 8, 23,-32768,-32768,
1462 121,-32768,-32768, 222, 222,-32768,-32768, 1043, 129, 129,
1463-32768,-32768, 239,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1464-32768,-32768,-32768,-32768, -45, 547,-32768, 143, 147, 118,
1465 124,-32768, 121, -94,-32768, 547, 1043, 1127, 42, 284,
1466 285, 263, 286, 600,-32768, 290,-32768,-32768,-32768,-32768,
1467-32768,-32768, 1140,-32768, -8, 1278,-32768, 279,-32768,-32768,
1468 121,-32768, 162, 159, 1127, 1127, 156, -70, 1127,-32768,
1469 167,-32768, 121,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1470-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1471-32768,-32768,-32768, 536, 499, 172,-32768,-32768,-32768,-32768,
1472-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 175,-32768,
1473-32768,-32768, 176, 178, 179, 691, 1183, 137, 302, 182,
1474 183, 186, 190,-32768,-32768, 166,-32768, 124, 121, 239,
1475-32768,-32768,-32768,-32768,-32768, 251, 1195, 56, 319, 129,
1476-32768,-32768, 536, 499, 1127, 1127, 1127, 1127, 1127, 1127,
1477 1127, 1127, 1127, 1127, 1127, 1127, 1127, 1127,-32768, 129,
1478-32768, 163,-32768,-32768, 164, 772,-32768, 41, -27,-32768,
1479 187, 121,-32768, 166, 166,-32768,-32768,-32768,-32768,-32768,
1480-32768,-32768,-32768,-32768,-32768, 192,-32768,-32768,-32768,-32768,
1481-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1482-32768,-32768, 194, 1043, 1043, 1043, 1043, 1043,-32768,-32768,
1483 20, 498, -91,-32768, -67,-32768, 1043, 1043, 1043, 1043,
1484 -12,-32768, 195,-32768, 124, 744,-32768, 871, 871,-32768,
1485 871, 1140, 1127, 1127, -17, 29,-32768, 744, 60, 200,
1486 201, 202, 203, 204, 205, 744, 744, 311, 207, 1140,
1487 1127, 1127,-32768,-32768,-32768,-32768,-32768, -86,-32768,-32768,
1488-32768, -86,-32768,-32768, 1043, 1043,-32768, 210, 215, 216,
1489 217, 1043,-32768, 199, 600, -50,-32768,-32768, 220, 225,
1490 328, 226, 346, 359,-32768, 166, 1026,-32768,-32768,-32768,
1491-32768,-32768,-32768,-32768,-32768, 310, 1043,-32768,-32768,-32768,
1492-32768, 231,-32768, 232, 871, 744, 744, 2,-32768, 5,
1493-32768,-32768, 871, 230, 1127, 1127, 1127, 1127, 1127, 236,
1494 242, 1127, 1127, 871, 744, 246,-32768,-32768,-32768, 247,
1495 248, 6, 1043, 1043, 1043, 1043,-32768,-32768, 234, 1043,
1496 1043, 1127, 1043,-32768,-32768,-32768,-32768, 121, 249, 250,
1497-32768, 368, -46, 373, 374, 254, 253, 260, 871, 393,
1498 871, 269, 271, 871, 272, 121,-32768, 273, 275, 871,
1499 871, 121,-32768, 277,-32768, 1127, 1043, 1043, 1127,-32768,
1500 278, 280, 283, 287,-32768, 288, 293, 114, 295, 3,
1501 1089,-32768, 291,-32768, 871, 871, 1127, 871, 871, 300,
1502-32768, 300, 871, 303, 1127, 1127, 1127,-32768,-32768, 1127,
1503 744, 301, 304,-32768, 1043,-32768, 1043, 1043,-32768,-32768,
1504-32768,-32768,-32768,-32768,-32768, 121, 64, 394, 306, 299,
1505 744, 35,-32768,-32768, 376,-32768,-32768, 305, 871,-32768,
1506-32768,-32768, 112,-32768,-32768,-32768, 307, 312, 313, 3,
1507-32768, 395,-32768, 432, -4,-32768, 1127,-32768,-32768, 308,
1508-32768,-32768,-32768,-32768,-32768, 450,-32768, 871,-32768, 998,
1509 9, 164, 744, 1,-32768, -86,-32768,-32768, 321,-32768,
1510 998,-32768, 444, 445, 324, 164, 871, 871, 447, 397,
1511-32768, 871, 455,-32768, 871,-32768, 468, 469,-32768
1512};
1513
1514static const short yypgoto[] = {-32768,
1515 345, 347, 348, 349, 259, 262, -208,-32768, 398,-32768,
1516-32768, 48,-32768,-32768, -172, -305, -411,-32768, -217,-32768,
1517 -300, -20,-32768, -223,-32768,-32768, -14, 252, -260,-32768,
1518 377, 382, -58, -112, -184, 211,-32768,-32768, 477,-32768,
1519-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 0,
1520 -30,-32768,-32768, 411,-32768,-32768,-32768,-32768,-32768,-32768,
1521 -492, -73, 103, -151,-32768, 446,-32768,-32768,-32768,-32768,
1522-32768, 13, 113,-32768,-32768,-32768,-32768
1523};
1524
1525
1526#define YYLAST 1407
1527
1528
1529static const short yytable[] = { 12,
1530 301, 194, 283, 285, 300, 381, 460, 71, 81, 12,
1531 429, 99, 201, 431, 353, 84, 1, 300, 2, 115,
1532 333, 334, 398, 323, 324, 332, 398, 57, 58, 553,
1533 101, 60, 61, 62, 63, 354, 1, 302, 2, 139,
1534 195, 375, 342, 397, -56, -56, 21, 549, 142, 430,
1535 140, 347, 430, 103, 15, 16, 17, 320, 555, 394,
1536 144, 145, 64, 139, 298, 307, 342, 299, 311, 312,
1537 313, 314, 315, 18, 241, 318, 319, 348, 22, 74,
1538 75, 131, 12, 342, 520, 103, 79, 342, 128, 20,
1539 353, 131, 80, 143, 409, 129, 464, 346, 23, 24,
1540 25, 26, 27, 28, 29, 53, 30, 105, 199, 106,
1541 323, 324, 323, 324, 542, 330, 378, 105, 31, 106,
1542 238, 239, 57, 58, 242, 101, 60, 61, 62, 63,
1543 397, 1, 416, 2, 55, 202, 539, 81, 85, 449,
1544 556, 57, 58, 450, 101, 109, 110, 111, 63, 550,
1545 1, 100, 2, 342, 41, 42, 43, 64, 65, 44,
1546 343, 66, 380, 105, 67, 106, 68, 102, 527, 506,
1547 396, 507, 528, 323, 324, 105, 64, 106, 37, 36,
1548 38, 329, 423, 116, 117, 118, 119, 120, 121, 122,
1549 49, 398, 296, 397, 105, 50, 106, 31, 383, 293,
1550 305, 306, 296, 308, 309, 296, 296, 296, 296, 296,
1551 316, 317, 296, 296, 51, 337, 338, 339, 340, 341,
1552 52, 131, 370, 88, 370, 370, 92, 370, 349, 350,
1553 351, 352, 194, 435, 370, 437, 438, 439, 398, 93,
1554 398, 443, 370, 370, 497, 527, 76, 77, 105, 531,
1555 106, 491, 1, 65, 2, 105, 66, 106, 94, 67,
1556 96, 68, 137, 89, 90, 146, 147, 345, 321, 322,
1557 97, 195, 65, 323, 324, 66, 400, 401, 67, 98,
1558 68, 284, 135, 407, 107, 108, 136, 199, 376, 377,
1559 -57, -58, 148, 197, 234, 236, 237, 484, 240, 291,
1560 294, 370, 370, 370, 243, 199, 395, 296, 274, 370,
1561 544, 275, 276, 546, 277, 278, 540, 286, 287, 288,
1562 370, 370, 289, 510, 511, 512, 290, 300, 335, 331,
1563 336, 357, 551, 384, 385, 386, 387, 388, 389, 392,
1564 393, 408, 418, 403, 451, 452, 453, 454, 404, 405,
1565 406, 456, 457, 410, 459, 370, 412, 370, 411, 413,
1566 370, 414, 415, 421, 424, 425, 370, 370, 434, 440,
1567 296, 436, 296, 296, 296, 441, 455, 442, 296, 446,
1568 447, 448, 461, 463, 465, 466, 468, 462, 482, 483,
1569 467, 370, 370, 469, 370, 370, 471, 458, -168, 370,
1570 372, 373, 449, 374, 473, 475, 476, 370, 477, 523,
1571 382, 485, 1, 480, 2, 3, 487, 486, 390, 391,
1572 488, 4, 5, 430, 498, 489, 517, 370, 518, 519,
1573 490, 481, 492, 505, 296, 370, 509, 525, 515, 524,
1574 6, 516, 536, 538, 532, 529, 496, 7, 545, 533,
1575 534, 8, 501, 547, 554, 557, 558, 559, 562, 493,
1576 296, 296, 296, 563, 370, 501, 565, 568, 569, 370,
1577 225, 303, 226, 227, 228, 304, 521, 426, 427, 428,
1578 126, 138, 141, 370, 370, 433, 35, 327, 370, 535,
1579 125, 370, 513, 87, 432, 0, 444, 445, 0, 0,
1580 0, 0, 57, 58, 0, 101, 109, 110, 111, 63,
1581 0, 1, 543, 2, 0, 0, 0, 257, 258, 493,
1582 0, 0, 0, 0, -167, 0, 0, 0, 0, 0,
1583 0, 470, 0, 472, 0, 0, 474, 64, 1, 0,
1584 2, 3, 478, 479, 0, 0, 0, 4, 5, 0,
1585 0, 57, 58, 0, 101, 60, 61, 62, 63, 0,
1586 1, 0, 2, 0, 0, 0, 6, 499, 500, 0,
1587 503, 504, 0, 7, 0, 508, 130, 8, 0, 0,
1588 0, 0, 0, 514, 0, 0, 64, 259, 260, 261,
1589 262, 263, 264, 265, 266, 267, 268, 269, 270, 271,
1590 272, 0, 0, 526, 57, 58, 0, 0, 0, 0,
1591 0, 530, 0, 1, 0, 2, 0, 149, 246, 247,
1592 248, 249, 250, 251, 252, 253, 254, 255, 0, 0,
1593 150, 151, 0, 65, 0, 0, 66, 0, 0, 67,
1594 548, 68, 344, 0, 0, 552, 0, 0, 0, 0,
1595 0, 0, 0, 0, 0, 0, 0, 0, 0, 560,
1596 561, 0, 0, 0, 564, 0, 0, 566, 152, 153,
1597 154, 155, 156, 157, 158, 159, 160, 161, 162, 163,
1598 164, 165, 65, 0, 0, 66, 0, 0, 67, 0,
1599 68, 0, 0, 0, 0, 57, 58, 0, 101, 109,
1600 110, 111, 63, 0, 1, 0, 2, 166, 167, 168,
1601 169, 170, 171, 172, 173, 174, 175, 176, 177, 178,
1602 0, 179, 180, 181, 182, 0, 183, 184, 185, 0,
1603 64, 0, 0, 0, 105, 0, 106, 0, 186, 0,
1604 0, 187, 0, 188, 0, 189, 358, 359, 57, 58,
1605 360, 0, 0, 0, 0, 0, 0, 1, 0, 2,
1606 0, 361, 362, 363, 0, 0, 0, 0, 0, 0,
1607 0, 0, 0, 0, 364, 365, 57, 58, 0, 101,
1608 60, 61, 62, 63, 0, 1, 0, 2, 0, 0,
1609 0, 0, 0, 57, 58, 366, 59, 60, 61, 62,
1610 63, 326, 1, 0, 2, 0, 0, 0, 0, 0,
1611 0, 64, 152, 153, 154, 155, 156, 157, 158, 159,
1612 160, 161, 162, 163, 164, 165, 65, 0, 64, 66,
1613 0, 279, 67, 0, 68, 0, 0, 0, 0, 0,
1614 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1615 0, 166, 167, 168, 169, 170, 171, 172, 173, 174,
1616 175, 176, 177, 178, 0, 179, 180, 181, 182, 0,
1617 183, 184, 185, 358, 359, 57, 58, 360, 105, 0,
1618 106, 0, 0, 0, 1, 367, 2, 0, 361, 362,
1619 363, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1620 0, 364, 365, 0, 0, 0, 0, 65, 0, 0,
1621 66, 0, 0, 67, 0, 68, 0, 0, 0, 0,
1622 0, 0, 366, 0, 65, 0, 0, 66, 0, 0,
1623 67, 0, 68, 0, 0, 0, 0, 0, 0, 152,
1624 153, 154, 155, 156, 157, 158, 159, 160, 161, 162,
1625 163, 164, 165, 0, 0, 0, 0, 0, 0, 0,
1626 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1627 0, 0, 0, 0, 0, 0, 0, 0, 166, 167,
1628 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
1629 178, 0, 179, 180, 181, 182, 0, 183, 184, 185,
1630 358, 359, 0, 0, 360, 0, 0, 0, 0, 0,
1631 0, 0, 367, 0, 0, 361, 362, 363, 0, 0,
1632 0, 0, 0, 0, 0, 0, 0, 0, 364, 365,
1633 57, 58, 0, 101, 60, 61, 62, 63, 0, 1,
1634 0, 2, 0, 0, 0, 0, 0, 57, 58, 366,
1635 101, 109, 110, 111, 63, 417, 1, 0, 2, 0,
1636 0, 0, 0, 0, 0, 64, 152, 153, 154, 155,
1637 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
1638 0, 0, 64, 0, 0, 0, 0, 0, 0, 0,
1639 0, 0, 0, 57, 58, 0, 101, 60, 61, 62,
1640 63, 0, 1, 0, 2, 166, 167, 168, 169, 170,
1641 171, 172, 173, 174, 175, 176, 177, 178, 495, 179,
1642 180, 181, 182, 0, 183, 184, 185, 0, 64, 0,
1643 0, 57, 58, 0, 101, 60, 61, 62, 63, 367,
1644 1, 0, 2, 0, 57, 58, 0, 198, 60, 61,
1645 62, 63, 0, 1, 0, 2, 0, 0, 0, 0,
1646 0, 65, 0, 0, 66, 0, 64, 67, 0, 68,
1647 0, 0, 0, 0, 0, 0, 0, 0, 65, 64,
1648 0, 66, 0, 0, 67, 0, 68, 57, 58, 0,
1649 101, 109, 110, 111, 63, 0, 1, 0, 2, 57,
1650 58, 0, 295, 60, 61, 62, 63, 0, 1, 0,
1651 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1652 0, 0, 64, 0, 65, 0, 0, 66, 0, 0,
1653 67, 0, 68, 0, 64, 0, 0, 0, 0, 0,
1654 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1655 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1656 0, 0, 65, 0, 0, 66, 0, 0, 67, 0,
1657 68, 0, 0, 0, 0, 65, 0, 0, 66, 0,
1658 0, 67, 0, 68, 0, 0, 0, 0, 0, 0,
1659 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1660 0, 0, 0, 0, 0, 204, 0, 0, 0, 0,
1661 0, 0, 0, 0, 0, 0, 0, 0, 65, 0,
1662 0, 66, 0, 0, 67, 0, 282, 205, 206, 0,
1663 65, 0, 0, 66, 0, 0, 67, 0, 68, 0,
1664 207, 208, 209, 210, 211, 212, 152, 153, 154, 155,
1665 156, 157, 158, 159, 160, 161, 162, 163, 213, 214,
1666 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1667 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1668 215, 216, 217, 0, 0, 218, 167, 168, 169, 170,
1669 171, 172, 173, 174, 175, 176, 177, 178, 219, 220,
1670 180, 181, 182, 221, 222, 223, 224
1671};
1672
1673static const short yycheck[] = { 0,
1674 209, 114, 187, 188, 9, 306, 418, 22, 15, 10,
1675 9, 4, 21, 9, 27, 22, 14, 9, 16, 78,
1676 244, 245, 328, 110, 111, 243, 332, 5, 6, 29,
1677 8, 9, 10, 11, 12, 48, 14, 210, 16, 134,
1678 114, 302, 134, 130, 3, 4, 52, 540, 107, 48,
1679 145, 143, 48, 68, 43, 44, 45, 230, 551, 320,
1680 19, 20, 40, 134, 9, 217, 134, 12, 220, 221,
1681 222, 223, 224, 62, 145, 227, 228, 145, 13, 32,
1682 33, 96, 83, 134, 496, 100, 39, 134, 134, 133,
1683 27, 106, 45, 108, 145, 141, 143, 282, 33, 34,
1684 35, 36, 37, 38, 39, 139, 41, 135, 123, 137,
1685 110, 111, 110, 111, 526, 143, 134, 135, 132, 137,
1686 135, 136, 5, 6, 139, 8, 9, 10, 11, 12,
1687 130, 14, 356, 16, 16, 144, 141, 15, 145, 134,
1688 552, 5, 6, 138, 8, 9, 10, 11, 12, 141,
1689 14, 144, 16, 134, 33, 34, 35, 40, 136, 38,
1690 141, 139, 134, 135, 142, 137, 144, 145, 134, 470,
1691 322, 472, 138, 110, 111, 135, 40, 137, 37, 133,
1692 39, 141, 367, 55, 56, 57, 58, 59, 60, 61,
1693 133, 497, 207, 130, 135, 133, 137, 132, 139, 200,
1694 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
1695 225, 226, 227, 228, 133, 274, 275, 276, 277, 278,
1696 133, 236, 296, 16, 298, 299, 4, 301, 287, 288,
1697 289, 290, 345, 385, 308, 387, 388, 389, 544, 16,
1698 546, 393, 316, 317, 462, 134, 25, 26, 135, 138,
1699 137, 138, 14, 136, 16, 135, 139, 137, 16, 142,
1700 137, 144, 145, 46, 47, 3, 4, 282, 106, 107,
1701 4, 345, 136, 110, 111, 139, 335, 336, 142, 4,
1702 144, 145, 140, 342, 74, 75, 140, 302, 303, 304,
1703 7, 7, 7, 4, 16, 134, 138, 449, 143, 134,
1704 50, 375, 376, 377, 138, 320, 321, 322, 137, 383,
1705 528, 137, 137, 531, 137, 137, 525, 16, 137, 137,
1706 394, 395, 137, 475, 476, 477, 137, 9, 137, 143,
1707 137, 137, 541, 134, 134, 134, 134, 134, 134, 29,
1708 134, 143, 357, 134, 403, 404, 405, 406, 134, 134,
1709 134, 410, 411, 134, 413, 429, 29, 431, 134, 134,
1710 434, 16, 4, 54, 134, 134, 440, 441, 139, 134,
1711 385, 386, 387, 388, 389, 134, 143, 392, 393, 134,
1712 134, 134, 134, 16, 12, 12, 134, 138, 447, 448,
1713 137, 465, 466, 134, 468, 469, 4, 412, 0, 473,
1714 298, 299, 134, 301, 134, 134, 134, 481, 134, 16,
1715 308, 134, 14, 137, 16, 17, 134, 138, 316, 317,
1716 134, 23, 24, 48, 134, 138, 485, 501, 487, 488,
1717 138, 446, 138, 134, 449, 509, 134, 139, 138, 134,
1718 42, 138, 48, 12, 138, 141, 461, 49, 141, 138,
1719 138, 53, 467, 4, 134, 12, 12, 134, 12, 460,
1720 475, 476, 477, 67, 538, 480, 12, 0, 0, 543,
1721 126, 213, 126, 126, 126, 214, 497, 375, 376, 377,
1722 83, 100, 106, 557, 558, 383, 10, 236, 562, 520,
1723 80, 565, 480, 48, 382, -1, 394, 395, -1, -1,
1724 -1, -1, 5, 6, -1, 8, 9, 10, 11, 12,
1725 -1, 14, 527, 16, -1, -1, -1, 19, 20, 520,
1726 -1, -1, -1, -1, 0, -1, -1, -1, -1, -1,
1727 -1, 429, -1, 431, -1, -1, 434, 40, 14, -1,
1728 16, 17, 440, 441, -1, -1, -1, 23, 24, -1,
1729 -1, 5, 6, -1, 8, 9, 10, 11, 12, -1,
1730 14, -1, 16, -1, -1, -1, 42, 465, 466, -1,
1731 468, 469, -1, 49, -1, 473, 30, 53, -1, -1,
1732 -1, -1, -1, 481, -1, -1, 40, 89, 90, 91,
1733 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
1734 102, -1, -1, 501, 5, 6, -1, -1, -1, -1,
1735 -1, 509, -1, 14, -1, 16, -1, 18, 83, 84,
1736 85, 86, 87, 88, 89, 90, 91, 92, -1, -1,
1737 31, 32, -1, 136, -1, -1, 139, -1, -1, 142,
1738 538, 144, 145, -1, -1, 543, -1, -1, -1, -1,
1739 -1, -1, -1, -1, -1, -1, -1, -1, -1, 557,
1740 558, -1, -1, -1, 562, -1, -1, 565, 69, 70,
1741 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1742 81, 82, 136, -1, -1, 139, -1, -1, 142, -1,
1743 144, -1, -1, -1, -1, 5, 6, -1, 8, 9,
1744 10, 11, 12, -1, 14, -1, 16, 108, 109, 110,
1745 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
1746 -1, 122, 123, 124, 125, -1, 127, 128, 129, -1,
1747 40, -1, -1, -1, 135, -1, 137, -1, 139, -1,
1748 -1, 142, -1, 144, -1, 146, 3, 4, 5, 6,
1749 7, -1, -1, -1, -1, -1, -1, 14, -1, 16,
1750 -1, 18, 19, 20, -1, -1, -1, -1, -1, -1,
1751 -1, -1, -1, -1, 31, 32, 5, 6, -1, 8,
1752 9, 10, 11, 12, -1, 14, -1, 16, -1, -1,
1753 -1, -1, -1, 5, 6, 52, 8, 9, 10, 11,
1754 12, 30, 14, -1, 16, -1, -1, -1, -1, -1,
1755 -1, 40, 69, 70, 71, 72, 73, 74, 75, 76,
1756 77, 78, 79, 80, 81, 82, 136, -1, 40, 139,
1757 -1, 141, 142, -1, 144, -1, -1, -1, -1, -1,
1758 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1759 -1, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1760 117, 118, 119, 120, -1, 122, 123, 124, 125, -1,
1761 127, 128, 129, 3, 4, 5, 6, 7, 135, -1,
1762 137, -1, -1, -1, 14, 142, 16, -1, 18, 19,
1763 20, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1764 -1, 31, 32, -1, -1, -1, -1, 136, -1, -1,
1765 139, -1, -1, 142, -1, 144, -1, -1, -1, -1,
1766 -1, -1, 52, -1, 136, -1, -1, 139, -1, -1,
1767 142, -1, 144, -1, -1, -1, -1, -1, -1, 69,
1768 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1769 80, 81, 82, -1, -1, -1, -1, -1, -1, -1,
1770 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1771 -1, -1, -1, -1, -1, -1, -1, -1, 108, 109,
1772 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
1773 120, -1, 122, 123, 124, 125, -1, 127, 128, 129,
1774 3, 4, -1, -1, 7, -1, -1, -1, -1, -1,
1775 -1, -1, 142, -1, -1, 18, 19, 20, -1, -1,
1776 -1, -1, -1, -1, -1, -1, -1, -1, 31, 32,
1777 5, 6, -1, 8, 9, 10, 11, 12, -1, 14,
1778 -1, 16, -1, -1, -1, -1, -1, 5, 6, 52,
1779 8, 9, 10, 11, 12, 30, 14, -1, 16, -1,
1780 -1, -1, -1, -1, -1, 40, 69, 70, 71, 72,
1781 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
1782 -1, -1, 40, -1, -1, -1, -1, -1, -1, -1,
1783 -1, -1, -1, 5, 6, -1, 8, 9, 10, 11,
1784 12, -1, 14, -1, 16, 108, 109, 110, 111, 112,
1785 113, 114, 115, 116, 117, 118, 119, 120, 30, 122,
1786 123, 124, 125, -1, 127, 128, 129, -1, 40, -1,
1787 -1, 5, 6, -1, 8, 9, 10, 11, 12, 142,
1788 14, -1, 16, -1, 5, 6, -1, 8, 9, 10,
1789 11, 12, -1, 14, -1, 16, -1, -1, -1, -1,
1790 -1, 136, -1, -1, 139, -1, 40, 142, -1, 144,
1791 -1, -1, -1, -1, -1, -1, -1, -1, 136, 40,
1792 -1, 139, -1, -1, 142, -1, 144, 5, 6, -1,
1793 8, 9, 10, 11, 12, -1, 14, -1, 16, 5,
1794 6, -1, 8, 9, 10, 11, 12, -1, 14, -1,
1795 16, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1796 -1, -1, 40, -1, 136, -1, -1, 139, -1, -1,
1797 142, -1, 144, -1, 40, -1, -1, -1, -1, -1,
1798 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1799 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1800 -1, -1, 136, -1, -1, 139, -1, -1, 142, -1,
1801 144, -1, -1, -1, -1, 136, -1, -1, 139, -1,
1802 -1, 142, -1, 144, -1, -1, -1, -1, -1, -1,
1803 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1804 -1, -1, -1, -1, -1, 28, -1, -1, -1, -1,
1805 -1, -1, -1, -1, -1, -1, -1, -1, 136, -1,
1806 -1, 139, -1, -1, 142, -1, 144, 50, 51, -1,
1807 136, -1, -1, 139, -1, -1, 142, -1, 144, -1,
1808 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
1809 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
1810 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1811 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1812 103, 104, 105, -1, -1, 108, 109, 110, 111, 112,
1813 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
1814 123, 124, 125, 126, 127, 128, 129
1815};
1816/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1817#line 3 "/usr/share/bison.simple"
1818/* This file comes from bison-1.28. */
1819
1820/* Skeleton output parser for bison,
1821 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1822
1823 This program is free software; you can redistribute it and/or modify
1824 it under the terms of the GNU General Public License as published by
1825 the Free Software Foundation; either version 2, or (at your option)
1826 any later version.
1827
1828 This program is distributed in the hope that it will be useful,
1829 but WITHOUT ANY WARRANTY; without even the implied warranty of
1830 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1831 GNU General Public License for more details.
1832
1833 You should have received a copy of the GNU General Public License
1834 along with this program; if not, write to the Free Software
1835 Foundation, Inc., 59 Temple Place - Suite 330,
1836 Boston, MA 02111-1307, USA. */
1837
1838/* As a special exception, when this file is copied by Bison into a
1839 Bison output file, you may use that output file without restriction.
1840 This special exception was added by the Free Software Foundation
1841 in version 1.24 of Bison. */
1842
1843/* This is the parser code that is written into each bison parser
1844 when the %semantic_parser declaration is not specified in the grammar.
1845 It was written by Richard Stallman by simplifying the hairy parser
1846 used when %semantic_parser is specified. */
1847
1848#ifndef YYSTACK_USE_ALLOCA
1849#ifdef alloca
1850#define YYSTACK_USE_ALLOCA
1851#else /* alloca not defined */
1852#ifdef __GNUC__
1853#define YYSTACK_USE_ALLOCA
1854#define alloca __builtin_alloca
1855#else /* not GNU C. */
1856#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1857#define YYSTACK_USE_ALLOCA
1858#include <alloca.h>
1859#else /* not sparc */
1860/* We think this test detects Watcom and Microsoft C. */
1861/* This used to test MSDOS, but that is a bad idea
1862 since that symbol is in the user namespace. */
1863#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1864#if 0 /* No need for malloc.h, which pollutes the namespace;
1865 instead, just don't use alloca. */
1866#include <malloc.h>
1867#endif
1868#else /* not MSDOS, or __TURBOC__ */
1869#if defined(_AIX)
1870/* I don't know what this was needed for, but it pollutes the namespace.
1871 So I turned it off. rms, 2 May 1997. */
1872/* #include <malloc.h> */
1873 #pragma alloca
1874#define YYSTACK_USE_ALLOCA
1875#else /* not MSDOS, or __TURBOC__, or _AIX */
1876#if 0
1877#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1878 and on HPUX 10. Eventually we can turn this on. */
1879#define YYSTACK_USE_ALLOCA
1880#define alloca __builtin_alloca
1881#endif /* __hpux */
1882#endif
1883#endif /* not _AIX */
1884#endif /* not MSDOS, or __TURBOC__ */
1885#endif /* not sparc */
1886#endif /* not GNU C */
1887#endif /* alloca not defined */
1888#endif /* YYSTACK_USE_ALLOCA not defined */
1889
1890#ifdef YYSTACK_USE_ALLOCA
1891#define YYSTACK_ALLOC alloca
Reid Spencer6f407902007-01-13 05:00:46 +00001892#else
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001893#define YYSTACK_ALLOC malloc
Reid Spencer6f407902007-01-13 05:00:46 +00001894#endif
1895
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001896/* Note: there must be only one dollar sign in this file.
1897 It is replaced by the list of actions, each action
1898 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001899
1900#define yyerrok (yyerrstatus = 0)
1901#define yyclearin (yychar = YYEMPTY)
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001902#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00001903#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00001904#define YYACCEPT goto yyacceptlab
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001905#define YYABORT goto yyabortlab
1906#define YYERROR goto yyerrlab1
1907/* Like YYERROR except do call yyerror.
1908 This remains here temporarily to ease the
1909 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001910 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001911#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00001912#define YYRECOVERING() (!!yyerrstatus)
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001913#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001914do \
1915 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001916 { yychar = (token), yylval = (value); \
1917 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer6f407902007-01-13 05:00:46 +00001918 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001919 goto yybackup; \
1920 } \
1921 else \
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001922 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer6f407902007-01-13 05:00:46 +00001923while (0)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001924
Reid Spencer68a24bd2005-08-27 18:50:39 +00001925#define YYTERROR 1
1926#define YYERRCODE 256
1927
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001928#ifndef YYPURE
1929#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00001930#endif
1931
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001932#ifdef YYPURE
1933#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +00001934#ifdef YYLEX_PARAM
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001935#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001936#else
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001937#define YYLEX yylex(&yylval, &yylloc)
1938#endif
1939#else /* not YYLSP_NEEDED */
1940#ifdef YYLEX_PARAM
1941#define YYLEX yylex(&yylval, YYLEX_PARAM)
1942#else
1943#define YYLEX yylex(&yylval)
1944#endif
1945#endif /* not YYLSP_NEEDED */
Chris Lattner0fab59c2007-01-12 18:33:30 +00001946#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001947
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001948/* If nonreentrant, generate the variables here */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001949
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001950#ifndef YYPURE
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001951
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001952int yychar; /* the lookahead symbol */
1953YYSTYPE yylval; /* the semantic value of the */
1954 /* lookahead symbol */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00001955
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001956#ifdef YYLSP_NEEDED
1957YYLTYPE yylloc; /* location data for the lookahead */
1958 /* symbol */
Chris Lattnerf49c1762006-11-08 05:58:47 +00001959#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00001960
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001961int yynerrs; /* number of parse errors so far */
1962#endif /* not YYPURE */
Reid Spencer3822ff52006-11-08 06:47:33 +00001963
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001964#if YYDEBUG != 0
1965int yydebug; /* nonzero means print parse trace */
1966/* Since this is uninitialized, it does not stop multiple parsers
1967 from coexisting. */
Chris Lattner1ae022f2006-10-22 06:08:13 +00001968#endif
Reid Spencer21be8652006-10-22 07:03:43 +00001969
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001970/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencer21be8652006-10-22 07:03:43 +00001971
Reid Spencer68a24bd2005-08-27 18:50:39 +00001972#ifndef YYINITDEPTH
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001973#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00001974#endif
1975
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001976/* YYMAXDEPTH is the maximum size the stacks can grow to
1977 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001978
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001979#if YYMAXDEPTH == 0
1980#undef YYMAXDEPTH
1981#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001982
1983#ifndef YYMAXDEPTH
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001984#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00001985#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001986
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001987/* Define __yy_memcpy. Note that the size argument
1988 should be passed with type unsigned int, because that is what the non-GCC
1989 definitions require. With GCC, __builtin_memcpy takes an arg
1990 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001991
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001992#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1993#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1994#else /* not GNU C or C++ */
1995#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00001996
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00001997/* This is the most reliable way to avoid incompatibilities
1998 in available built-in functions on various systems. */
Reid Spencer6f407902007-01-13 05:00:46 +00001999static void
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002000__yy_memcpy (to, from, count)
2001 char *to;
2002 char *from;
2003 unsigned int count;
2004{
2005 register char *f = from;
2006 register char *t = to;
2007 register int i = count;
2008
2009 while (i-- > 0)
2010 *t++ = *f++;
2011}
2012
2013#else /* __cplusplus */
2014
2015/* This is the most reliable way to avoid incompatibilities
2016 in available built-in functions on various systems. */
Reid Spencer6f407902007-01-13 05:00:46 +00002017static void
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002018__yy_memcpy (char *to, char *from, unsigned int count)
2019{
2020 register char *t = to;
2021 register char *f = from;
2022 register int i = count;
2023
2024 while (i-- > 0)
2025 *t++ = *f++;
2026}
2027
Reid Spencer6f407902007-01-13 05:00:46 +00002028#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002029#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002030
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002031#line 217 "/usr/share/bison.simple"
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002032
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002033/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2034 into yyparse. The argument should have type void *.
2035 It should actually point to an object.
2036 Grammar actions can access the variable by casting it
2037 to the proper pointer type. */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002038
2039#ifdef YYPARSE_PARAM
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002040#ifdef __cplusplus
2041#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2042#define YYPARSE_PARAM_DECL
2043#else /* not __cplusplus */
2044#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2045#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2046#endif /* not __cplusplus */
2047#else /* not YYPARSE_PARAM */
2048#define YYPARSE_PARAM_ARG
2049#define YYPARSE_PARAM_DECL
2050#endif /* not YYPARSE_PARAM */
2051
2052/* Prevent warning if -Wstrict-prototypes. */
2053#ifdef __GNUC__
2054#ifdef YYPARSE_PARAM
2055int yyparse (void *);
2056#else
Reid Spencere812fb22006-01-19 01:21:04 +00002057int yyparse (void);
Chris Lattner0fab59c2007-01-12 18:33:30 +00002058#endif
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002059#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002060
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002061int
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002062yyparse(YYPARSE_PARAM_ARG)
2063 YYPARSE_PARAM_DECL
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002064{
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002065 register int yystate;
2066 register int yyn;
2067 register short *yyssp;
2068 register YYSTYPE *yyvsp;
2069 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2070 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002071
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002072 short yyssa[YYINITDEPTH]; /* the state stack */
2073 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002074
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002075 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2076 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002077
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002078#ifdef YYLSP_NEEDED
2079 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2080 YYLTYPE *yyls = yylsa;
2081 YYLTYPE *yylsp;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002082
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002083#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2084#else
Reid Spencer6f407902007-01-13 05:00:46 +00002085#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002086#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002087
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002088 int yystacksize = YYINITDEPTH;
2089 int yyfree_stacks = 0;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002090
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002091#ifdef YYPURE
2092 int yychar;
2093 YYSTYPE yylval;
2094 int yynerrs;
2095#ifdef YYLSP_NEEDED
2096 YYLTYPE yylloc;
2097#endif
2098#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002099
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002100 YYSTYPE yyval; /* the variable used to return */
2101 /* semantic values from the action */
2102 /* routines */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002103
Reid Spencer6f407902007-01-13 05:00:46 +00002104 int yylen;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002105
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002106#if YYDEBUG != 0
2107 if (yydebug)
2108 fprintf(stderr, "Starting parse\n");
2109#endif
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002110
Reid Spencer68a24bd2005-08-27 18:50:39 +00002111 yystate = 0;
2112 yyerrstatus = 0;
2113 yynerrs = 0;
2114 yychar = YYEMPTY; /* Cause a token to be read. */
2115
2116 /* Initialize stack pointers.
2117 Waste one element of value and location stack
2118 so that they stay on the same level as the state stack.
2119 The wasted elements are never initialized. */
2120
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002121 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002122 yyvsp = yyvs;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002123#ifdef YYLSP_NEEDED
2124 yylsp = yyls;
2125#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002126
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002127/* Push a new state, which is found in yystate . */
2128/* In all cases, when you get here, the value and location stacks
2129 have just been pushed. so pushing a state here evens the stacks. */
2130yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002131
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002132 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002133
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002134 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002135 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002136 /* Give user a chance to reallocate the stack */
2137 /* Use copies of these so that the &'s don't force the real ones into memory. */
2138 YYSTYPE *yyvs1 = yyvs;
2139 short *yyss1 = yyss;
2140#ifdef YYLSP_NEEDED
2141 YYLTYPE *yyls1 = yyls;
2142#endif
2143
Reid Spencer68a24bd2005-08-27 18:50:39 +00002144 /* Get the current used size of the three stacks, in elements. */
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002145 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002146
2147#ifdef yyoverflow
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002148 /* Each stack pointer address is followed by the size of
2149 the data in use in that stack, in bytes. */
2150#ifdef YYLSP_NEEDED
2151 /* This used to be a conditional around just the two extra args,
2152 but that might be undefined if yyoverflow is a macro. */
2153 yyoverflow("parser stack overflow",
2154 &yyss1, size * sizeof (*yyssp),
2155 &yyvs1, size * sizeof (*yyvsp),
2156 &yyls1, size * sizeof (*yylsp),
2157 &yystacksize);
2158#else
2159 yyoverflow("parser stack overflow",
2160 &yyss1, size * sizeof (*yyssp),
2161 &yyvs1, size * sizeof (*yyvsp),
2162 &yystacksize);
2163#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002164
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002165 yyss = yyss1; yyvs = yyvs1;
2166#ifdef YYLSP_NEEDED
2167 yyls = yyls1;
2168#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002169#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002170 /* Extend the stack our own way. */
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002171 if (yystacksize >= YYMAXDEPTH)
2172 {
2173 yyerror("parser stack overflow");
2174 if (yyfree_stacks)
2175 {
2176 free (yyss);
2177 free (yyvs);
2178#ifdef YYLSP_NEEDED
2179 free (yyls);
2180#endif
2181 }
2182 return 2;
2183 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002184 yystacksize *= 2;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002185 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002186 yystacksize = YYMAXDEPTH;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002187#ifndef YYSTACK_USE_ALLOCA
2188 yyfree_stacks = 1;
2189#endif
2190 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2191 __yy_memcpy ((char *)yyss, (char *)yyss1,
2192 size * (unsigned int) sizeof (*yyssp));
2193 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2194 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2195 size * (unsigned int) sizeof (*yyvsp));
2196#ifdef YYLSP_NEEDED
2197 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2198 __yy_memcpy ((char *)yyls, (char *)yyls1,
2199 size * (unsigned int) sizeof (*yylsp));
2200#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002201#endif /* no yyoverflow */
2202
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002203 yyssp = yyss + size - 1;
2204 yyvsp = yyvs + size - 1;
2205#ifdef YYLSP_NEEDED
2206 yylsp = yyls + size - 1;
2207#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002208
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002209#if YYDEBUG != 0
2210 if (yydebug)
2211 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2212#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002213
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002214 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002215 YYABORT;
2216 }
2217
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002218#if YYDEBUG != 0
2219 if (yydebug)
2220 fprintf(stderr, "Entering state %d\n", yystate);
2221#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002222
2223 goto yybackup;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002224 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002225
Reid Spencer6f407902007-01-13 05:00:46 +00002226/* Do appropriate processing given the current state. */
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002227/* Read a lookahead token if we need one and don't already have one. */
Reid Spencer6f407902007-01-13 05:00:46 +00002228/* yyresume: */
Andrew Lenharth6353e052006-12-08 18:07:09 +00002229
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002230 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer6f407902007-01-13 05:00:46 +00002231
Reid Spencer68a24bd2005-08-27 18:50:39 +00002232 yyn = yypact[yystate];
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002233 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002234 goto yydefault;
2235
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002236 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002237
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002238 /* yychar is either YYEMPTY or YYEOF
2239 or a valid token in external form. */
2240
Reid Spencer68a24bd2005-08-27 18:50:39 +00002241 if (yychar == YYEMPTY)
2242 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002243#if YYDEBUG != 0
2244 if (yydebug)
2245 fprintf(stderr, "Reading a token: ");
2246#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002247 yychar = YYLEX;
2248 }
2249
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002250 /* Convert token to internal form (in yychar1) for indexing tables with */
2251
2252 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002253 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002254 yychar1 = 0;
2255 yychar = YYEOF; /* Don't call YYLEX any more */
2256
2257#if YYDEBUG != 0
2258 if (yydebug)
2259 fprintf(stderr, "Now at end of input.\n");
2260#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002261 }
2262 else
2263 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002264 yychar1 = YYTRANSLATE(yychar);
2265
2266#if YYDEBUG != 0
2267 if (yydebug)
2268 {
2269 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2270 /* Give the individual parser a way to print the precise meaning
2271 of a token, for further debugging info. */
2272#ifdef YYPRINT
2273 YYPRINT (stderr, yychar, yylval);
2274#endif
2275 fprintf (stderr, ")\n");
2276 }
2277#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002278 }
2279
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002280 yyn += yychar1;
2281 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002282 goto yydefault;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002283
Reid Spencer68a24bd2005-08-27 18:50:39 +00002284 yyn = yytable[yyn];
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002285
2286 /* yyn is what to do for this token type in this state.
2287 Negative => reduce, -yyn is rule number.
2288 Positive => shift, yyn is new state.
2289 New state is final state => don't bother to shift,
2290 just return success.
2291 0, or most negative number => error. */
2292
2293 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002294 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002295 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002296 goto yyerrlab;
2297 yyn = -yyn;
2298 goto yyreduce;
2299 }
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002300 else if (yyn == 0)
2301 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002302
2303 if (yyn == YYFINAL)
2304 YYACCEPT;
2305
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002306 /* Shift the lookahead token. */
2307
2308#if YYDEBUG != 0
2309 if (yydebug)
2310 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2311#endif
Reid Spencer6f407902007-01-13 05:00:46 +00002312
2313 /* Discard the token being shifted unless it is eof. */
2314 if (yychar != YYEOF)
2315 yychar = YYEMPTY;
2316
2317 *++yyvsp = yylval;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002318#ifdef YYLSP_NEEDED
2319 *++yylsp = yylloc;
2320#endif
Reid Spencer6f407902007-01-13 05:00:46 +00002321
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002322 /* count tokens shifted since error; after three, turn off error status. */
2323 if (yyerrstatus) yyerrstatus--;
Chris Lattner0fab59c2007-01-12 18:33:30 +00002324
Reid Spencer68a24bd2005-08-27 18:50:39 +00002325 yystate = yyn;
2326 goto yynewstate;
2327
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002328/* Do the default action for the current state. */
Anton Korobeynikov178a3522007-01-12 19:22:51 +00002329yydefault:
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002330
Reid Spencer68a24bd2005-08-27 18:50:39 +00002331 yyn = yydefact[yystate];
2332 if (yyn == 0)
2333 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002334
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002335/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002336yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002337 yylen = yyr2[yyn];
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002338 if (yylen > 0)
2339 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002340
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002341#if YYDEBUG != 0
2342 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002343 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002344 int i;
2345
2346 fprintf (stderr, "Reducing via rule %d (line %d), ",
2347 yyn, yyrline[yyn]);
2348
2349 /* Print the symbols being reduced, and their result. */
2350 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2351 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2352 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2353 }
2354#endif
2355
2356
2357 switch (yyn) {
2358
2359case 2:
2360#line 1032 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2361{
2362 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00002363 GEN_ERROR("Value too large for type!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002364 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002365 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002366;
2367 break;}
2368case 30:
2369#line 1048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2370{ yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2371 break;}
2372case 31:
2373#line 1048 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2374{ yyval.IPredicate = ICmpInst::ICMP_NE; ;
2375 break;}
2376case 32:
2377#line 1049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2378{ yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2379 break;}
2380case 33:
2381#line 1049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2382{ yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2383 break;}
2384case 34:
2385#line 1050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2386{ yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2387 break;}
2388case 35:
2389#line 1050 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2390{ yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2391 break;}
2392case 36:
2393#line 1051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2394{ yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2395 break;}
2396case 37:
2397#line 1051 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2398{ yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2399 break;}
2400case 38:
2401#line 1052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2402{ yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2403 break;}
2404case 39:
2405#line 1052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2406{ yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2407 break;}
2408case 40:
2409#line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2410{ yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2411 break;}
2412case 41:
2413#line 1056 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2414{ yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2415 break;}
2416case 42:
2417#line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2418{ yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2419 break;}
2420case 43:
2421#line 1057 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2422{ yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2423 break;}
2424case 44:
2425#line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2426{ yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2427 break;}
2428case 45:
2429#line 1058 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2430{ yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2431 break;}
2432case 46:
2433#line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2434{ yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2435 break;}
2436case 47:
2437#line 1059 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2438{ yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2439 break;}
2440case 48:
2441#line 1060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2442{ yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2443 break;}
2444case 49:
2445#line 1060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2446{ yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2447 break;}
2448case 50:
2449#line 1061 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2450{ yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2451 break;}
2452case 51:
2453#line 1061 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2454{ yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2455 break;}
2456case 52:
2457#line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2458{ yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2459 break;}
2460case 53:
2461#line 1062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2462{ yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2463 break;}
2464case 54:
2465#line 1063 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2466{ yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2467 break;}
2468case 55:
2469#line 1064 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2470{ yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2471 break;}
2472case 59:
2473#line 1073 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2474{
2475 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002476 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002477 ;
2478 break;}
2479case 60:
2480#line 1077 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2481{
2482 yyval.StrVal = 0;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002483 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002484 ;
2485 break;}
2486case 61:
2487#line 1083 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2488{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2489 break;}
2490case 62:
2491#line 1084 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2492{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2493 break;}
2494case 63:
2495#line 1085 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2496{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2497 break;}
2498case 64:
2499#line 1086 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2500{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2501 break;}
2502case 65:
2503#line 1087 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2504{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2505 break;}
2506case 66:
2507#line 1091 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2508{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2509 break;}
2510case 67:
2511#line 1092 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2512{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2513 break;}
2514case 68:
2515#line 1093 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2516{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2517 break;}
2518case 69:
2519#line 1097 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2520{ yyval.Visibility = GlobalValue::DefaultVisibility; ;
2521 break;}
2522case 70:
2523#line 1098 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2524{ yyval.Visibility = GlobalValue::HiddenVisibility; ;
2525 break;}
2526case 71:
2527#line 1102 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2528{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2529 break;}
2530case 72:
2531#line 1103 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2532{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2533 break;}
2534case 73:
2535#line 1104 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2536{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2537 break;}
2538case 74:
2539#line 1108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2540{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2541 break;}
2542case 75:
2543#line 1109 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2544{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2545 break;}
2546case 76:
2547#line 1110 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2548{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2549 break;}
2550case 77:
2551#line 1111 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2552{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2553 break;}
2554case 78:
2555#line 1112 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2556{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2557 break;}
2558case 79:
2559#line 1115 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2560{ yyval.UIntVal = CallingConv::C; ;
2561 break;}
2562case 80:
2563#line 1116 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2564{ yyval.UIntVal = CallingConv::C; ;
2565 break;}
2566case 81:
2567#line 1117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2568{ yyval.UIntVal = CallingConv::CSRet; ;
2569 break;}
2570case 82:
2571#line 1118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2572{ yyval.UIntVal = CallingConv::Fast; ;
2573 break;}
2574case 83:
2575#line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2576{ yyval.UIntVal = CallingConv::Cold; ;
2577 break;}
2578case 84:
2579#line 1120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2580{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2581 break;}
2582case 85:
2583#line 1121 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2584{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2585 break;}
2586case 86:
2587#line 1122 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2588{
2589 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Reid Spencer61c83e02006-08-18 08:43:06 +00002590 GEN_ERROR("Calling conv too large!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002591 yyval.UIntVal = yyvsp[0].UInt64Val;
Reid Spencer61c83e02006-08-18 08:43:06 +00002592 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002593 ;
2594 break;}
2595case 87:
2596#line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2597{ yyval.ParamAttrs = FunctionType::ZExtAttribute; ;
2598 break;}
2599case 88:
2600#line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2601{ yyval.ParamAttrs = FunctionType::SExtAttribute; ;
2602 break;}
2603case 89:
2604#line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2605{ yyval.ParamAttrs = FunctionType::NoAttributeSet; ;
2606 break;}
2607case 90:
2608#line 1134 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2609{
2610 yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs);
2611 ;
2612 break;}
2613case 91:
2614#line 1139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2615{ yyval.ParamAttrs = FunctionType::NoReturnAttribute; ;
2616 break;}
2617case 93:
2618#line 1143 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2619{ yyval.ParamAttrs = FunctionType::NoAttributeSet; ;
2620 break;}
2621case 94:
2622#line 1144 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2623{
2624 yyval.ParamAttrs = FunctionType::ParameterAttributes(yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs);
2625 ;
2626 break;}
2627case 95:
2628#line 1151 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2629{ yyval.UIntVal = 0; ;
2630 break;}
2631case 96:
2632#line 1152 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2633{
2634 yyval.UIntVal = yyvsp[0].UInt64Val;
2635 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencera54b7cb2007-01-12 07:05:14 +00002636 GEN_ERROR("Alignment must be a power of two!");
2637 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002638;
2639 break;}
2640case 97:
2641#line 1158 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2642{ yyval.UIntVal = 0; ;
2643 break;}
2644case 98:
2645#line 1159 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2646{
2647 yyval.UIntVal = yyvsp[0].UInt64Val;
2648 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencera54b7cb2007-01-12 07:05:14 +00002649 GEN_ERROR("Alignment must be a power of two!");
2650 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002651;
2652 break;}
2653case 99:
2654#line 1167 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2655{
2656 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2657 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
Reid Spencere4d87aa2006-12-23 06:05:41 +00002658 GEN_ERROR("Invalid character in section name!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002659 yyval.StrVal = yyvsp[0].StrVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002660 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002661;
2662 break;}
2663case 100:
2664#line 1175 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2665{ yyval.StrVal = 0; ;
2666 break;}
2667case 101:
2668#line 1176 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2669{ yyval.StrVal = yyvsp[0].StrVal; ;
2670 break;}
2671case 102:
2672#line 1181 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2673{;
2674 break;}
2675case 103:
2676#line 1182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2677{;
2678 break;}
2679case 104:
2680#line 1183 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2681{
2682 CurGV->setSection(yyvsp[0].StrVal);
2683 free(yyvsp[0].StrVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00002684 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002685 ;
2686 break;}
2687case 105:
2688#line 1188 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2689{
2690 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Reid Spencere4d87aa2006-12-23 06:05:41 +00002691 GEN_ERROR("Alignment must be a power of two!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002692 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencere4d87aa2006-12-23 06:05:41 +00002693 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002694 ;
2695 break;}
2696case 110:
2697#line 1204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2698{
2699 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencera132e042006-12-03 05:46:11 +00002700 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002701 ;
2702 break;}
2703case 111:
2704#line 1208 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2705{
2706 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Reid Spencer6f407902007-01-13 05:00:46 +00002707 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002708 ;
2709 break;}
2710case 112:
2711#line 1212 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2712{ // Pointer type?
2713 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Reid Spencer6f407902007-01-13 05:00:46 +00002714 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002715 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2716 delete yyvsp[-1].TypeVal;
Reid Spencera132e042006-12-03 05:46:11 +00002717 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002718 ;
2719 break;}
2720case 113:
2721#line 1219 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2722{ // Named types are also simple types...
2723 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer14310612006-12-31 05:40:51 +00002724 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002725 yyval.TypeVal = new PATypeHolder(tmp);
2726 ;
2727 break;}
2728case 114:
2729#line 1224 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2730{ // Type UpReference
2731 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer3da59db2006-11-27 01:05:10 +00002732 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002733 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2734 yyval.TypeVal = new PATypeHolder(OT);
Reid Spencer3da59db2006-11-27 01:05:10 +00002735 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00002736 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002737 ;
2738 break;}
2739case 115:
2740#line 1232 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2741{
Reid Spencer3da59db2006-11-27 01:05:10 +00002742 std::vector<const Type*> Params;
Reid Spencer14310612006-12-31 05:40:51 +00002743 std::vector<FunctionType::ParameterAttributes> Attrs;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002744 Attrs.push_back(yyvsp[0].ParamAttrs);
2745 for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00002746 Params.push_back(I->Ty->get());
2747 if (I->Ty->get() != Type::VoidTy)
2748 Attrs.push_back(I->Attrs);
2749 }
Reid Spencer3da59db2006-11-27 01:05:10 +00002750 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2751 if (isVarArg) Params.pop_back();
2752
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002753 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, Attrs);
2754 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2755 delete yyvsp[-4].TypeVal; // Delete the return type handle
2756 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencer6f407902007-01-13 05:00:46 +00002757 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002758 ;
2759 break;}
2760case 116:
2761#line 1250 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2762{
Reid Spencer6f407902007-01-13 05:00:46 +00002763 std::vector<const Type*> Params;
2764 std::vector<FunctionType::ParameterAttributes> Attrs;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002765 Attrs.push_back(yyvsp[0].ParamAttrs);
2766 for (TypeWithAttrsList::iterator I=yyvsp[-2].TypeWithAttrsList->begin(), E=yyvsp[-2].TypeWithAttrsList->end(); I != E; ++I) {
Reid Spencer6f407902007-01-13 05:00:46 +00002767 Params.push_back(I->Ty->get());
2768 if (I->Ty->get() != Type::VoidTy)
2769 Attrs.push_back(I->Attrs);
2770 }
2771 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2772 if (isVarArg) Params.pop_back();
2773
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002774 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, Attrs);
2775 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2776 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
Reid Spencere4d87aa2006-12-23 06:05:41 +00002777 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002778 ;
2779 break;}
2780case 117:
2781#line 1268 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2782{ // Sized array type?
2783 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2784 delete yyvsp[-1].TypeVal;
Reid Spencer14310612006-12-31 05:40:51 +00002785 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002786 ;
2787 break;}
2788case 118:
2789#line 1273 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2790{ // Packed array type?
2791 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2792 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002793 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner42a75512007-01-15 02:27:26 +00002794 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
Reid Spencera54b7cb2007-01-12 07:05:14 +00002795 GEN_ERROR("Element type of a PackedType must be primitive");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002796 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Reid Spencere4d87aa2006-12-23 06:05:41 +00002797 GEN_ERROR("Vector length should be a power of 2!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002798 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2799 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002800 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002801 ;
2802 break;}
2803case 119:
2804#line 1285 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2805{ // Structure type?
Reid Spencere4d87aa2006-12-23 06:05:41 +00002806 std::vector<const Type*> Elements;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002807 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2808 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002809 Elements.push_back(*I);
2810
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002811 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2812 delete yyvsp[-1].TypeList;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002813 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002814 ;
2815 break;}
2816case 120:
2817#line 1295 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2818{ // Empty structure type?
2819 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencere4d87aa2006-12-23 06:05:41 +00002820 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002821 ;
2822 break;}
2823case 121:
2824#line 1299 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2825{
Reid Spencere4d87aa2006-12-23 06:05:41 +00002826 std::vector<const Type*> Elements;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002827 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
2828 E = yyvsp[-2].TypeList->end(); I != E; ++I)
Reid Spencere4d87aa2006-12-23 06:05:41 +00002829 Elements.push_back(*I);
2830
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002831 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
2832 delete yyvsp[-2].TypeList;
Reid Spencere4d87aa2006-12-23 06:05:41 +00002833 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002834 ;
2835 break;}
2836case 122:
2837#line 1309 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2838{ // Empty structure type?
2839 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
Reid Spencere4d87aa2006-12-23 06:05:41 +00002840 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002841 ;
2842 break;}
2843case 123:
2844#line 1316 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2845{
2846 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
2847 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
2848 ;
2849 break;}
2850case 124:
2851#line 1323 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2852{
Reid Spencer6f407902007-01-13 05:00:46 +00002853 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002854 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2855 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
Reid Spencer6f407902007-01-13 05:00:46 +00002856 GEN_ERROR("LLVM functions cannot return aggregate types!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002857 yyval.TypeVal = yyvsp[0].TypeVal;
2858 ;
2859 break;}
2860case 125:
2861#line 1330 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2862{
2863 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
2864 ;
2865 break;}
2866case 126:
2867#line 1335 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2868{
2869 yyval.TypeWithAttrsList = new TypeWithAttrsList();
2870 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer14310612006-12-31 05:40:51 +00002871 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002872 ;
2873 break;}
2874case 127:
2875#line 1340 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2876{
2877 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
Reid Spencer14310612006-12-31 05:40:51 +00002878 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002879 ;
2880 break;}
2881case 129:
2882#line 1348 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2883{
2884 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
Reid Spencer14310612006-12-31 05:40:51 +00002885 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
2886 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002887 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencere4d87aa2006-12-23 06:05:41 +00002888 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002889 ;
2890 break;}
2891case 130:
2892#line 1355 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2893{
2894 yyval.TypeWithAttrsList = new TypeWithAttrsList;
Reid Spencer14310612006-12-31 05:40:51 +00002895 TypeWithAttrs TWA; TWA.Attrs = FunctionType::NoAttributeSet;
2896 TWA.Ty = new PATypeHolder(Type::VoidTy);
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002897 yyval.TypeWithAttrsList->push_back(TWA);
Reid Spencer14310612006-12-31 05:40:51 +00002898 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002899 ;
2900 break;}
2901case 131:
2902#line 1362 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2903{
2904 yyval.TypeWithAttrsList = new TypeWithAttrsList();
Reid Spencer14310612006-12-31 05:40:51 +00002905 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002906 ;
2907 break;}
2908case 132:
2909#line 1370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2910{
2911 yyval.TypeList = new std::list<PATypeHolder>();
2912 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer6f407902007-01-13 05:00:46 +00002913 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002914 ;
2915 break;}
2916case 133:
2917#line 1375 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2918{
2919 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00002920 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002921 ;
2922 break;}
2923case 134:
2924#line 1386 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2925{ // Nonempty unsized arr
Reid Spencer6f407902007-01-13 05:00:46 +00002926 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002927 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
2928 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00002929 if (ATy == 0)
2930 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002931 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00002932 const Type *ETy = ATy->getElementType();
2933 int NumElements = ATy->getNumElements();
2934
2935 // Verify that we have the correct size...
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002936 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencer6f407902007-01-13 05:00:46 +00002937 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002938 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencer6f407902007-01-13 05:00:46 +00002939 itostr(NumElements) + "!");
2940
2941 // Verify all elements are correct type!
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002942 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2943 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00002944 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
2945 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002946 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer6f407902007-01-13 05:00:46 +00002947 }
2948
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002949 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2950 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer3da59db2006-11-27 01:05:10 +00002951 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002952 ;
2953 break;}
2954case 135:
2955#line 1414 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2956{
Reid Spencer14310612006-12-31 05:40:51 +00002957 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002958 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
2959 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00002960 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002961 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002962 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002963
Andrew Lenharth6353e052006-12-08 18:07:09 +00002964 int NumElements = ATy->getNumElements();
2965 if (NumElements != -1 && NumElements != 0)
2966 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
2967 " arguments, but has size of " + itostr(NumElements) +"!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002968 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2969 delete yyvsp[-2].TypeVal;
Reid Spencer6f407902007-01-13 05:00:46 +00002970 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002971 ;
2972 break;}
2973case 136:
2974#line 1430 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2975{
Reid Spencer6f407902007-01-13 05:00:46 +00002976 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002977 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
2978 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00002979 if (ATy == 0)
2980 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002981 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00002982
2983 int NumElements = ATy->getNumElements();
2984 const Type *ETy = ATy->getElementType();
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002985 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2986 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
Reid Spencer6f407902007-01-13 05:00:46 +00002987 GEN_ERROR("Can't build string constant of size " +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002988 itostr((int)(EndStr-yyvsp[0].StrVal)) +
Reid Spencer6f407902007-01-13 05:00:46 +00002989 " when array has size " + itostr(NumElements) + "!");
2990 std::vector<Constant*> Vals;
2991 if (ETy == Type::Int8Ty) {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002992 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
Reid Spencer6f407902007-01-13 05:00:46 +00002993 C != (unsigned char*)EndStr; ++C)
2994 Vals.push_back(ConstantInt::get(ETy, *C));
2995 } else {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002996 free(yyvsp[0].StrVal);
Reid Spencer6f407902007-01-13 05:00:46 +00002997 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
2998 }
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00002999 free(yyvsp[0].StrVal);
3000 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3001 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003002 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003003 ;
3004 break;}
3005case 137:
3006#line 1459 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3007{ // Nonempty unsized arr
Reid Spencer14310612006-12-31 05:40:51 +00003008 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003009 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3010 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003011 if (PTy == 0)
3012 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003013 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00003014 const Type *ETy = PTy->getElementType();
3015 int NumElements = PTy->getNumElements();
Reid Spencer61c83e02006-08-18 08:43:06 +00003016
Reid Spencer6f407902007-01-13 05:00:46 +00003017 // Verify that we have the correct size...
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003018 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencer6f407902007-01-13 05:00:46 +00003019 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003020 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencer6f407902007-01-13 05:00:46 +00003021 itostr(NumElements) + "!");
3022
3023 // Verify all elements are correct type!
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003024 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3025 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003026 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3027 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003028 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003029 }
Reid Spencer6f407902007-01-13 05:00:46 +00003030
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003031 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
3032 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer61c83e02006-08-18 08:43:06 +00003033 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003034 ;
3035 break;}
3036case 138:
3037#line 1487 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3038{
3039 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003040 if (STy == 0)
3041 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003042 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003043
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003044 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencer6f407902007-01-13 05:00:46 +00003045 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003046
Reid Spencer6f407902007-01-13 05:00:46 +00003047 // Check to ensure that constants are compatible with the type initializer!
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003048 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3049 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer6f407902007-01-13 05:00:46 +00003050 GEN_ERROR("Expected type '" +
3051 STy->getElementType(i)->getDescription() +
3052 "' for element #" + utostr(i) +
3053 " of structure initializer!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003054
Reid Spencer6f407902007-01-13 05:00:46 +00003055 // Check to ensure that Type is not packed
3056 if (STy->isPacked())
3057 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3058
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003059 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3060 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer61c83e02006-08-18 08:43:06 +00003061 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003062 ;
3063 break;}
3064case 139:
3065#line 1512 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3066{
Reid Spencer6f407902007-01-13 05:00:46 +00003067 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003068 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3069 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003070 if (STy == 0)
3071 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003072 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003073
Reid Spencer6f407902007-01-13 05:00:46 +00003074 if (STy->getNumContainedTypes() != 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00003075 GEN_ERROR("Illegal number of initializers for structure type!");
3076
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003077 // Check to ensure that Type is not packed
3078 if (STy->isPacked())
3079 GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'");
3080
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003081 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3082 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003083 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003084 ;
3085 break;}
3086case 140:
3087#line 1531 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3088{
3089 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
Andrew Lenharth6353e052006-12-08 18:07:09 +00003090 if (STy == 0)
3091 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003092 (*yyvsp[-5].TypeVal)->getDescription() + "'!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00003093
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003094 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003095 GEN_ERROR("Illegal number of initializers for structure type!");
3096
3097 // Check to ensure that constants are compatible with the type initializer!
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003098 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3099 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003100 GEN_ERROR("Expected type '" +
3101 STy->getElementType(i)->getDescription() +
3102 "' for element #" + utostr(i) +
3103 " of structure initializer!");
3104
3105 // Check to ensure that Type is packed
3106 if (!STy->isPacked())
3107 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3108
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003109 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3110 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003111 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003112 ;
3113 break;}
3114case 141:
3115#line 1556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3116{
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003117 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003118 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3119 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003120 if (STy == 0)
3121 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003122 (*yyvsp[-4].TypeVal)->getDescription() + "'!");
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003123
3124 if (STy->getNumContainedTypes() != 0)
3125 GEN_ERROR("Illegal number of initializers for structure type!");
3126
3127 // Check to ensure that Type is packed
3128 if (!STy->isPacked())
3129 GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'");
3130
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003131 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3132 delete yyvsp[-4].TypeVal;
Reid Spencer6f407902007-01-13 05:00:46 +00003133 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003134 ;
3135 break;}
3136case 142:
3137#line 1575 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3138{
Reid Spencer6f407902007-01-13 05:00:46 +00003139 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003140 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3141 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00003142 if (PTy == 0)
3143 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003144 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
Reid Spencer6f407902007-01-13 05:00:46 +00003145
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003146 yyval.ConstVal = ConstantPointerNull::get(PTy);
3147 delete yyvsp[-1].TypeVal;
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003148 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003149 ;
3150 break;}
3151case 143:
3152#line 1587 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3153{
Reid Spencer14310612006-12-31 05:40:51 +00003154 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003155 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3156 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3157 delete yyvsp[-1].TypeVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003158 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003159 ;
3160 break;}
3161case 144:
3162#line 1594 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3163{
Reid Spencer14310612006-12-31 05:40:51 +00003164 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003165 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3166 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003167 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003168 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003169
3170 // ConstExprs can exist in the body of a function, thus creating
3171 // GlobalValues whenever they refer to a variable. Because we are in
3172 // the context of a function, getValNonImprovising will search the functions
3173 // symbol table instead of the module symbol table for the global symbol,
3174 // which throws things all off. To get around this, we just tell
3175 // getValNonImprovising that we are at global scope here.
3176 //
3177 Function *SavedCurFn = CurFun.CurrentFunction;
3178 CurFun.CurrentFunction = 0;
3179
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003180 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003181 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003182
3183 CurFun.CurrentFunction = SavedCurFn;
3184
3185 // If this is an initializer for a constant pointer, which is referencing a
3186 // (currently) undefined variable, create a stub now that shall be replaced
3187 // in the future with the right type of variable.
3188 //
3189 if (V == 0) {
3190 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3191 const PointerType *PT = cast<PointerType>(Ty);
3192
3193 // First check to see if the forward references value is already created!
3194 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003195 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003196
3197 if (I != CurModule.GlobalRefs.end()) {
3198 V = I->second; // Placeholder already exists, use it...
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003199 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003200 } else {
3201 std::string Name;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003202 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003203
3204 // Create the forward referenced global.
3205 GlobalValue *GV;
3206 if (const FunctionType *FTy =
3207 dyn_cast<FunctionType>(PT->getElementType())) {
3208 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3209 CurModule.CurrentModule);
3210 } else {
3211 GV = new GlobalVariable(PT->getElementType(), false,
3212 GlobalValue::ExternalLinkage, 0,
3213 Name, CurModule.CurrentModule);
3214 }
3215
3216 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003217 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003218 V = GV;
3219 }
3220 }
3221
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003222 yyval.ConstVal = cast<GlobalValue>(V);
3223 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer6f407902007-01-13 05:00:46 +00003224 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003225 ;
3226 break;}
3227case 145:
3228#line 1657 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3229{
Reid Spencer6f407902007-01-13 05:00:46 +00003230 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003231 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3232 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003233 GEN_ERROR("Mismatched types for constant expression: " +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003234 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3235 yyval.ConstVal = yyvsp[0].ConstVal;
3236 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003237 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003238 ;
3239 break;}
3240case 146:
3241#line 1667 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3242{
Reid Spencer14310612006-12-31 05:40:51 +00003243 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003244 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3245 const Type *Ty = yyvsp[-1].TypeVal->get();
Reid Spencer6f407902007-01-13 05:00:46 +00003246 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3247 GEN_ERROR("Cannot create a null initialized value of this type!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003248 yyval.ConstVal = Constant::getNullValue(Ty);
3249 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003250 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003251 ;
3252 break;}
3253case 147:
3254#line 1677 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3255{ // integral constants
3256 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Reid Spencer6f407902007-01-13 05:00:46 +00003257 GEN_ERROR("Constant value doesn't fit in type!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003258 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003259 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003260 ;
3261 break;}
3262case 148:
3263#line 1683 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3264{ // integral constants
3265 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Reid Spencer14310612006-12-31 05:40:51 +00003266 GEN_ERROR("Constant value doesn't fit in type!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003267 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Reid Spencer14310612006-12-31 05:40:51 +00003268 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003269 ;
3270 break;}
3271case 149:
3272#line 1689 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3273{ // Boolean constants
3274 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3275 yyval.ConstVal = ConstantInt::getTrue();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003276 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003277 ;
3278 break;}
3279case 150:
3280#line 1694 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3281{ // Boolean constants
3282 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3283 yyval.ConstVal = ConstantInt::getFalse();
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003284 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003285 ;
3286 break;}
3287case 151:
3288#line 1699 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3289{ // Float & Double constants
3290 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Reid Spencere4d87aa2006-12-23 06:05:41 +00003291 GEN_ERROR("Floating point constant invalid for type!!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003292 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003293 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003294 ;
3295 break;}
3296case 152:
3297#line 1707 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3298{
Reid Spencer14310612006-12-31 05:40:51 +00003299 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003300 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3301 Constant *Val = yyvsp[-3].ConstVal;
3302 const Type *Ty = yyvsp[-1].TypeVal->get();
Reid Spencer3da59db2006-11-27 01:05:10 +00003303 if (!Val->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003304 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003305 Val->getType()->getDescription() + "'!");
3306 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003307 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003308 Ty->getDescription() + "'!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003309 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
3310 delete yyvsp[-1].TypeVal;
3311 ;
3312 break;}
3313case 153:
3314#line 1721 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3315{
3316 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003317 GEN_ERROR("GetElementPtr requires a pointer operand!");
3318
3319 const Type *IdxTy =
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003320 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003321 if (!IdxTy)
3322 GEN_ERROR("Index list invalid for constant getelementptr!");
3323
3324 std::vector<Constant*> IdxVec;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003325 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3326 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Andrew Lenharth6353e052006-12-08 18:07:09 +00003327 IdxVec.push_back(C);
3328 else
3329 GEN_ERROR("Indices to constant getelementptr must be constants!");
3330
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003331 delete yyvsp[-1].ValueList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003332
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003333 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Reid Spencer6f407902007-01-13 05:00:46 +00003334 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003335 ;
3336 break;}
3337case 154:
3338#line 1742 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3339{
3340 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00003341 GEN_ERROR("Select condition must be of boolean type!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003342 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003343 GEN_ERROR("Select operand types must match!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003344 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003345 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003346 ;
3347 break;}
3348case 155:
3349#line 1750 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3350{
3351 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003352 GEN_ERROR("Binary operator types must match!");
3353 CHECK_FOR_ERROR;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003354 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3355 ;
3356 break;}
3357case 156:
3358#line 1756 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3359{
3360 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003361 GEN_ERROR("Logical operator types must match!");
Chris Lattner42a75512007-01-15 02:27:26 +00003362 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003363 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
Chris Lattner42a75512007-01-15 02:27:26 +00003364 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003365 GEN_ERROR("Logical operator requires integral operands!");
3366 }
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003367 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003368 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003369 ;
3370 break;}
3371case 157:
3372#line 1767 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3373{
3374 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencere4d87aa2006-12-23 06:05:41 +00003375 GEN_ERROR("icmp operand types must match!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003376 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3377 ;
3378 break;}
3379case 158:
3380#line 1772 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3381{
3382 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00003383 GEN_ERROR("fcmp operand types must match!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003384 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3385 ;
3386 break;}
3387case 159:
3388#line 1777 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3389{
3390 if (yyvsp[-1].ConstVal->getType() != Type::Int8Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00003391 GEN_ERROR("Shift count for shift constant must be i8 type!");
Chris Lattner42a75512007-01-15 02:27:26 +00003392 if (!yyvsp[-3].ConstVal->getType()->isInteger())
Reid Spencer6f407902007-01-13 05:00:46 +00003393 GEN_ERROR("Shift constant expression requires integer operand!");
3394 CHECK_FOR_ERROR;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003395 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer6f407902007-01-13 05:00:46 +00003396 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003397 ;
3398 break;}
3399case 160:
3400#line 1786 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3401{
3402 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer6f407902007-01-13 05:00:46 +00003403 GEN_ERROR("Invalid extractelement operands!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003404 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003405 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003406 ;
3407 break;}
3408case 161:
3409#line 1792 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3410{
3411 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer6f407902007-01-13 05:00:46 +00003412 GEN_ERROR("Invalid insertelement operands!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003413 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003414 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003415 ;
3416 break;}
3417case 162:
3418#line 1798 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3419{
3420 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer6f407902007-01-13 05:00:46 +00003421 GEN_ERROR("Invalid shufflevector operands!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003422 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003423 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003424 ;
3425 break;}
3426case 163:
3427#line 1807 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3428{
3429 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003430 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003431 ;
3432 break;}
3433case 164:
3434#line 1811 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3435{
3436 yyval.ConstVector = new std::vector<Constant*>();
3437 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00003438 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003439 ;
3440 break;}
3441case 165:
3442#line 1819 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3443{ yyval.BoolVal = false; ;
3444 break;}
3445case 166:
3446#line 1819 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3447{ yyval.BoolVal = true; ;
3448 break;}
3449case 167:
3450#line 1830 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3451{
3452 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer6f407902007-01-13 05:00:46 +00003453 CurModule.ModuleDone();
3454 CHECK_FOR_ERROR;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003455 ;
3456 break;}
3457case 168:
3458#line 1835 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3459{
3460 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
Reid Spencer14310612006-12-31 05:40:51 +00003461 CurModule.ModuleDone();
3462 CHECK_FOR_ERROR;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003463 ;
3464 break;}
3465case 171:
3466#line 1848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3467{ CurFun.isDeclare = false ;
3468 break;}
3469case 172:
3470#line 1848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3471{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003472 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003473 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003474 ;
3475 break;}
3476case 173:
3477#line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3478{ CurFun.isDeclare = true; ;
3479 break;}
3480case 174:
3481#line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3482{
Reid Spencer6f407902007-01-13 05:00:46 +00003483 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003484 ;
3485 break;}
3486case 175:
3487#line 1855 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3488{
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003489 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003490 ;
3491 break;}
3492case 176:
3493#line 1858 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3494{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003495 // Emit an error if there are any unresolved types left.
3496 if (!CurModule.LateResolveTypes.empty()) {
3497 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00003498 if (DID.Type == ValID::NameVal) {
3499 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3500 } else {
3501 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3502 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003503 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003504 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003505 ;
3506 break;}
3507case 177:
3508#line 1870 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3509{
Reid Spencer14310612006-12-31 05:40:51 +00003510 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003511 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003512 // Eagerly resolve types. This is not an optimization, this is a
3513 // requirement that is due to the fact that we could have this:
3514 //
3515 // %list = type { %list * }
3516 // %list = type { %list * } ; repeated type decl
3517 //
3518 // If types are not resolved eagerly, then the two types will not be
3519 // determined to be the same type!
3520 //
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003521 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003522
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003523 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003524 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003525 // If this is a named type that is not a redefinition, add it to the slot
3526 // table.
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003527 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003528 }
Reid Spencera132e042006-12-03 05:46:11 +00003529
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003530 delete yyvsp[0].TypeVal;
Reid Spencer6f407902007-01-13 05:00:46 +00003531 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003532 ;
3533 break;}
3534case 178:
3535#line 1894 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3536{
3537 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
Reid Spencer6f407902007-01-13 05:00:46 +00003538
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003539 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer6f407902007-01-13 05:00:46 +00003540 CHECK_FOR_ERROR
3541 // If this is a named type that is not a redefinition, add it to the slot
3542 // table.
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003543 CurModule.Types.push_back(yyvsp[0].PrimType);
Reid Spencer6f407902007-01-13 05:00:46 +00003544 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003545 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003546 ;
3547 break;}
3548case 179:
3549#line 1905 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3550{ /* "Externally Visible" Linkage */
3551 if (yyvsp[0].ConstVal == 0)
Reid Spencer6f407902007-01-13 05:00:46 +00003552 GEN_ERROR("Global value initializer is not a constant!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003553 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage,
3554 yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Reid Spencer14310612006-12-31 05:40:51 +00003555 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003556 ;
3557 break;}
3558case 180:
3559#line 1911 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3560{
Reid Spencer6f407902007-01-13 05:00:46 +00003561 CurGV = 0;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003562 ;
3563 break;}
3564case 181:
3565#line 1914 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3566{
3567 if (yyvsp[0].ConstVal == 0)
Reid Spencer6f407902007-01-13 05:00:46 +00003568 GEN_ERROR("Global value initializer is not a constant!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003569 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Reid Spencer6f407902007-01-13 05:00:46 +00003570 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003571 ;
3572 break;}
3573case 182:
3574#line 1919 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3575{
Reid Spencer6f407902007-01-13 05:00:46 +00003576 CurGV = 0;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003577 ;
3578 break;}
3579case 183:
3580#line 1922 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3581{
Reid Spencer6f407902007-01-13 05:00:46 +00003582 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003583 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3584 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, yyvsp[-3].Linkage, yyvsp[-2].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
Reid Spencer6f407902007-01-13 05:00:46 +00003585 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003586 delete yyvsp[0].TypeVal;
3587 ;
3588 break;}
3589case 184:
3590#line 1928 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3591{
Reid Spencere4d87aa2006-12-23 06:05:41 +00003592 CurGV = 0;
3593 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003594 ;
3595 break;}
3596case 185:
3597#line 1932 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3598{
Reid Spencer6e18b7d2006-12-03 06:59:29 +00003599 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003600 ;
3601 break;}
3602case 186:
3603#line 1935 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3604{
Reid Spencer218ded22007-01-05 17:07:23 +00003605 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003606 ;
3607 break;}
3608case 187:
3609#line 1941 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3610{
Chris Lattner66316012006-01-24 04:14:29 +00003611 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003612 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3613 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3614 free(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003615
3616 if (AsmSoFar.empty())
3617 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3618 else
3619 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00003620 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003621;
3622 break;}
3623case 188:
3624#line 1954 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3625{ yyval.Endianness = Module::BigEndian; ;
3626 break;}
3627case 189:
3628#line 1955 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3629{ yyval.Endianness = Module::LittleEndian; ;
3630 break;}
3631case 190:
3632#line 1957 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3633{
3634 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Reid Spencer6f407902007-01-13 05:00:46 +00003635 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003636 ;
3637 break;}
3638case 191:
3639#line 1961 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3640{
3641 if (yyvsp[0].UInt64Val == 32)
Reid Spencer6f407902007-01-13 05:00:46 +00003642 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003643 else if (yyvsp[0].UInt64Val == 64)
Reid Spencer6f407902007-01-13 05:00:46 +00003644 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3645 else
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003646 GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Reid Spencere4d87aa2006-12-23 06:05:41 +00003647 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003648 ;
3649 break;}
3650case 192:
3651#line 1970 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3652{
3653 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3654 free(yyvsp[0].StrVal);
3655 ;
3656 break;}
3657case 193:
3658#line 1974 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3659{
3660 CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal);
3661 free(yyvsp[0].StrVal);
3662 ;
3663 break;}
3664case 195:
3665#line 1981 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3666{
3667 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3668 free(yyvsp[0].StrVal);
Reid Spencer6f407902007-01-13 05:00:46 +00003669 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003670 ;
3671 break;}
3672case 196:
3673#line 1986 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3674{
3675 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3676 free(yyvsp[0].StrVal);
Reid Spencera54b7cb2007-01-12 07:05:14 +00003677 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003678 ;
3679 break;}
3680case 197:
3681#line 1991 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3682{
Reid Spencera54b7cb2007-01-12 07:05:14 +00003683 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003684 ;
3685 break;}
3686case 201:
3687#line 2001 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3688{ yyval.StrVal = 0; ;
3689 break;}
3690case 202:
3691#line 2003 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3692{
Reid Spencer14310612006-12-31 05:40:51 +00003693 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003694 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3695 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Reid Spencer14310612006-12-31 05:40:51 +00003696 GEN_ERROR("void typed arguments are invalid!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003697 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3698 yyval.ArgList = yyvsp[-4].ArgList;
3699 yyvsp[-4].ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00003700 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003701 ;
3702 break;}
3703case 203:
3704#line 2013 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3705{
Reid Spencer14310612006-12-31 05:40:51 +00003706 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003707 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3708 if (*yyvsp[-2].TypeVal == Type::VoidTy)
Reid Spencer14310612006-12-31 05:40:51 +00003709 GEN_ERROR("void typed arguments are invalid!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003710 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3711 yyval.ArgList = new ArgListType;
3712 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00003713 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003714 ;
3715 break;}
3716case 204:
3717#line 2024 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3718{
3719 yyval.ArgList = yyvsp[0].ArgList;
Reid Spencer6f407902007-01-13 05:00:46 +00003720 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003721 ;
3722 break;}
3723case 205:
3724#line 2028 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3725{
3726 yyval.ArgList = yyvsp[-2].ArgList;
Reid Spencer6f407902007-01-13 05:00:46 +00003727 struct ArgListEntry E;
3728 E.Ty = new PATypeHolder(Type::VoidTy);
3729 E.Name = 0;
3730 E.Attrs = FunctionType::NoAttributeSet;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003731 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00003732 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003733 ;
3734 break;}
3735case 206:
3736#line 2037 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3737{
3738 yyval.ArgList = new ArgListType;
Reid Spencer14310612006-12-31 05:40:51 +00003739 struct ArgListEntry E;
3740 E.Ty = new PATypeHolder(Type::VoidTy);
3741 E.Name = 0;
3742 E.Attrs = FunctionType::NoAttributeSet;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003743 yyval.ArgList->push_back(E);
Reid Spencer61c83e02006-08-18 08:43:06 +00003744 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003745 ;
3746 break;}
3747case 207:
3748#line 2046 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3749{
3750 yyval.ArgList = 0;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003751 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003752 ;
3753 break;}
3754case 208:
3755#line 2052 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3756{
3757 UnEscapeLexed(yyvsp[-6].StrVal);
3758 std::string FunctionName(yyvsp[-6].StrVal);
3759 free(yyvsp[-6].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003760
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00003761 // Check the function result for abstractness if this is a define. We should
3762 // have no abstract types at this point
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003763 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
3764 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00003765
Reid Spencer68a24bd2005-08-27 18:50:39 +00003766 std::vector<const Type*> ParamTypeList;
Reid Spencer14310612006-12-31 05:40:51 +00003767 std::vector<FunctionType::ParameterAttributes> ParamAttrs;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003768 ParamAttrs.push_back(yyvsp[-2].ParamAttrs);
3769 if (yyvsp[-4].ArgList) { // If there are arguments...
3770 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00003771 const Type* Ty = I->Ty->get();
Reid Spencer8c8a2dc2007-01-02 21:54:12 +00003772 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
3773 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
Reid Spencer14310612006-12-31 05:40:51 +00003774 ParamTypeList.push_back(Ty);
3775 if (Ty != Type::VoidTy)
3776 ParamAttrs.push_back(I->Attrs);
3777 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003778 }
3779
3780 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3781 if (isVarArg) ParamTypeList.pop_back();
3782
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003783 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg,
Reid Spencer14310612006-12-31 05:40:51 +00003784 ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003785 const PointerType *PFT = PointerType::get(FT);
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003786 delete yyvsp[-7].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003787
3788 ValID ID;
3789 if (!FunctionName.empty()) {
3790 ID = ValID::create((char*)FunctionName.c_str());
3791 } else {
3792 ID = ValID::create((int)CurModule.Values[PFT].size());
3793 }
3794
3795 Function *Fn = 0;
3796 // See if this function was forward referenced. If so, recycle the object.
3797 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3798 // Move the function to the end of the list, from whereever it was
3799 // previously inserted.
3800 Fn = cast<Function>(FWRef);
3801 CurModule.CurrentModule->getFunctionList().remove(Fn);
3802 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3803 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3804 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3805 // If this is the case, either we need to be a forward decl, or it needs
3806 // to be.
3807 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00003808 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003809
3810 // Make sure to strip off any argument names so we can't get conflicts.
3811 if (Fn->isExternal())
3812 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3813 AI != AE; ++AI)
3814 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003815 } else { // Not already defined?
3816 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3817 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00003818
Reid Spencer68a24bd2005-08-27 18:50:39 +00003819 InsertValue(Fn, CurModule.Values);
3820 }
3821
3822 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00003823
3824 if (CurFun.isDeclare) {
3825 // If we have declaration, always overwrite linkage. This will allow us to
3826 // correctly handle cases, when pointer to function is passed as argument to
3827 // another function.
3828 Fn->setLinkage(CurFun.Linkage);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00003829 Fn->setVisibility(CurFun.Visibility);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00003830 }
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003831 Fn->setCallingConv(yyvsp[-8].UIntVal);
3832 Fn->setAlignment(yyvsp[0].UIntVal);
3833 if (yyvsp[-1].StrVal) {
3834 Fn->setSection(yyvsp[-1].StrVal);
3835 free(yyvsp[-1].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00003836 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003837
3838 // Add all of the arguments we parsed to the function...
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003839 if (yyvsp[-4].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003840 if (isVarArg) { // Nuke the last entry
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003841 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0&&
Reid Spencera132e042006-12-03 05:46:11 +00003842 "Not a varargs marker!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003843 delete yyvsp[-4].ArgList->back().Ty;
3844 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00003845 }
3846 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer14310612006-12-31 05:40:51 +00003847 unsigned Idx = 1;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003848 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++ArgIt) {
Reid Spencer14310612006-12-31 05:40:51 +00003849 delete I->Ty; // Delete the typeholder...
3850 setValueName(ArgIt, I->Name); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00003851 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003852 InsertValue(ArgIt);
Reid Spencer14310612006-12-31 05:40:51 +00003853 Idx++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003854 }
Reid Spencera132e042006-12-03 05:46:11 +00003855
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003856 delete yyvsp[-4].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00003857 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003858 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003859;
3860 break;}
3861case 211:
3862#line 2159 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3863{
3864 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003865
3866 // Make sure that we keep track of the linkage type even if there was a
3867 // previous "declare".
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003868 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
3869 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
3870;
3871 break;}
3872case 214:
3873#line 2170 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3874{
3875 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00003876 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003877;
3878 break;}
3879case 215:
3880#line 2175 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3881{
3882 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
3883 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
3884 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00003885 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003886 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003887 ;
3888 break;}
3889case 216:
3890#line 2187 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3891{
3892 yyval.BoolVal = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003893 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003894 ;
3895 break;}
3896case 217:
3897#line 2191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3898{
3899 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00003900 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003901 ;
3902 break;}
3903case 218:
3904#line 2196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3905{ // A reference to a direct constant
3906 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Reid Spencer6f407902007-01-13 05:00:46 +00003907 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003908 ;
3909 break;}
3910case 219:
3911#line 2200 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3912{
3913 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003914 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003915 ;
3916 break;}
3917case 220:
3918#line 2204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3919{ // Perhaps it's an FP constant?
3920 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003921 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003922 ;
3923 break;}
3924case 221:
3925#line 2208 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3926{
3927 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003928 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003929 ;
3930 break;}
3931case 222:
3932#line 2212 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3933{
3934 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
Zhou Sheng6b6b6ef2007-01-11 12:24:14 +00003935 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003936 ;
3937 break;}
3938case 223:
3939#line 2216 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3940{
3941 yyval.ValIDVal = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00003942 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003943 ;
3944 break;}
3945case 224:
3946#line 2220 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3947{
3948 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00003949 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003950 ;
3951 break;}
3952case 225:
3953#line 2224 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3954{ // A vector zero constant.
3955 yyval.ValIDVal = ValID::createZeroInit();
Reid Spencer61c83e02006-08-18 08:43:06 +00003956 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003957 ;
3958 break;}
3959case 226:
3960#line 2228 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3961{ // Nonempty unsized packed vector
3962 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3963 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003964
3965 PackedType* pt = PackedType::get(ETy, NumElements);
3966 PATypeHolder* PTy = new PATypeHolder(
Reid Spencera132e042006-12-03 05:46:11 +00003967 HandleUpRefs(
3968 PackedType::get(
3969 ETy,
3970 NumElements)
3971 )
3972 );
Reid Spencer68a24bd2005-08-27 18:50:39 +00003973
3974 // Verify all elements are correct type!
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003975 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3976 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003977 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003978 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003979 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003980 }
3981
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003982 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3983 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer6f407902007-01-13 05:00:46 +00003984 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003985 ;
3986 break;}
3987case 227:
3988#line 2253 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3989{
3990 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00003991 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00003992 ;
3993 break;}
3994case 228:
3995#line 2257 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3996{
3997 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3998 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3999 End = UnEscapeLexed(yyvsp[0].StrVal, true);
4000 std::string Constraints = std::string(yyvsp[0].StrVal, End);
4001 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
4002 free(yyvsp[-2].StrVal);
4003 free(yyvsp[0].StrVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004004 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004005 ;
4006 break;}
4007case 229:
4008#line 2271 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4009{ // Is it an integer reference...?
4010 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004011 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004012 ;
4013 break;}
4014case 230:
4015#line 2275 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4016{ // Is it a named reference...?
4017 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004018 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004019 ;
4020 break;}
4021case 233:
4022#line 2287 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4023{
Reid Spencer6f407902007-01-13 05:00:46 +00004024 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004025 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4026 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4027 delete yyvsp[-1].TypeVal;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004028 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004029 ;
4030 break;}
4031case 234:
4032#line 2296 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4033{
4034 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004035 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004036 ;
4037 break;}
4038case 235:
4039#line 2300 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4040{ // Do not allow functions with 0 basic blocks
4041 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004042 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004043 ;
4044 break;}
4045case 236:
4046#line 2309 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4047{
4048 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004049 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004050 InsertValue(yyvsp[0].TermInstVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004051
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004052 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4053 InsertValue(yyvsp[-2].BasicBlockVal);
4054 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004055 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004056 ;
4057 break;}
4058case 237:
4059#line 2320 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4060{
4061 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
Reid Spencer6f407902007-01-13 05:00:46 +00004062 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4063 if (CI2->getParent() == 0)
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004064 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4065 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4066 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004067 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004068 ;
4069 break;}
4070case 238:
4071#line 2329 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4072{
4073 yyval.BasicBlockVal = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004074 CHECK_FOR_ERROR
4075
4076 // Make sure to move the basic block to the correct location in the
4077 // function, instead of leaving it inserted wherever it was first
4078 // referenced.
4079 Function::BasicBlockListType &BBL =
4080 CurFun.CurrentFunction->getBasicBlockList();
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004081 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004082 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004083 ;
4084 break;}
4085case 239:
4086#line 2341 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4087{
4088 yyval.BasicBlockVal = getBBVal(ValID::create(yyvsp[0].StrVal), true);
Reid Spencere4d87aa2006-12-23 06:05:41 +00004089 CHECK_FOR_ERROR
4090
4091 // Make sure to move the basic block to the correct location in the
4092 // function, instead of leaving it inserted wherever it was first
4093 // referenced.
4094 Function::BasicBlockListType &BBL =
4095 CurFun.CurrentFunction->getBasicBlockList();
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004096 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencer3822ff52006-11-08 06:47:33 +00004097 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004098 ;
4099 break;}
4100case 240:
4101#line 2354 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4102{ // Return with a result...
4103 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4104 CHECK_FOR_ERROR
4105 ;
4106 break;}
4107case 241:
4108#line 2358 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4109{ // Return with no result...
4110 yyval.TermInstVal = new ReturnInst();
4111 CHECK_FOR_ERROR
4112 ;
4113 break;}
4114case 242:
4115#line 2362 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4116{ // Unconditional Branch...
4117 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4118 CHECK_FOR_ERROR
4119 yyval.TermInstVal = new BranchInst(tmpBB);
4120 ;
4121 break;}
4122case 243:
4123#line 2367 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4124{
4125 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4126 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4127 CHECK_FOR_ERROR
4128 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4129 CHECK_FOR_ERROR
4130 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4131 CHECK_FOR_ERROR
4132 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4133 ;
4134 break;}
4135case 244:
4136#line 2377 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4137{
4138 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4139 CHECK_FOR_ERROR
4140 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4141 CHECK_FOR_ERROR
4142 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4143 yyval.TermInstVal = S;
Reid Spencer3822ff52006-11-08 06:47:33 +00004144
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004145 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4146 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004147 for (; I != E; ++I) {
4148 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4149 S->addCase(CI, I->second);
4150 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004151 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004152 }
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004153 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00004154 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004155 ;
4156 break;}
4157case 245:
4158#line 2396 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4159{
4160 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004161 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004162 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004163 CHECK_FOR_ERROR
4164 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004165 yyval.TermInstVal = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004166 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004167 ;
4168 break;}
4169case 246:
4170#line 2406 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4171{
Reid Spencer3822ff52006-11-08 06:47:33 +00004172
Reid Spencer14310612006-12-31 05:40:51 +00004173 // Handle the short syntax
4174 const PointerType *PFTy = 0;
4175 const FunctionType *Ty = 0;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004176 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004177 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4178 // Pull out the types of all of the arguments...
4179 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00004180 FunctionType::ParamAttrsList ParamAttrs;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004181 ParamAttrs.push_back(yyvsp[-6].ParamAttrs);
4182 for (ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004183 const Type *Ty = I->Val->getType();
4184 if (Ty == Type::VoidTy)
4185 GEN_ERROR("Short call syntax cannot be used with varargs");
4186 ParamTypes.push_back(Ty);
4187 ParamAttrs.push_back(I->Attrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004188 }
4189
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004190 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, ParamAttrs);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004191 PFTy = PointerType::get(Ty);
4192 }
4193
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004194 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004195 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004196 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004197 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004198 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004199 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004200
Reid Spencer14310612006-12-31 05:40:51 +00004201 // Check the arguments
4202 ValueList Args;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004203 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
Reid Spencer14310612006-12-31 05:40:51 +00004204 // Make sure no arguments is a good thing!
4205 if (Ty->getNumParams() != 0)
4206 GEN_ERROR("No arguments passed to a function that "
4207 "expects arguments!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004208 } else { // Has arguments?
4209 // Loop through FunctionType's arguments and ensure they are specified
4210 // correctly!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004211 FunctionType::param_iterator I = Ty->param_begin();
4212 FunctionType::param_iterator E = Ty->param_end();
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004213 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004214
Reid Spencer14310612006-12-31 05:40:51 +00004215 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4216 if (ArgI->Val->getType() != *I)
4217 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Reid Spencera132e042006-12-03 05:46:11 +00004218 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00004219 Args.push_back(ArgI->Val);
4220 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004221
Reid Spencer14310612006-12-31 05:40:51 +00004222 if (Ty->isVarArg()) {
4223 if (I == E)
4224 for (; ArgI != ArgE; ++ArgI)
4225 Args.push_back(ArgI->Val); // push the remaining varargs
4226 } else if (I != E || ArgI != ArgE)
Reid Spencer61c83e02006-08-18 08:43:06 +00004227 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004228 }
Reid Spencer14310612006-12-31 05:40:51 +00004229
4230 // Create the InvokeInst
4231 InvokeInst *II = new InvokeInst(V, Normal, Except, Args);
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004232 II->setCallingConv(yyvsp[-12].UIntVal);
4233 yyval.TermInstVal = II;
4234 delete yyvsp[-8].ValueRefList;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004235 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004236 ;
4237 break;}
4238case 247:
4239#line 2472 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4240{
4241 yyval.TermInstVal = new UnwindInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004242 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004243 ;
4244 break;}
4245case 248:
4246#line 2476 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4247{
4248 yyval.TermInstVal = new UnreachableInst();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004249 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004250 ;
4251 break;}
4252case 249:
4253#line 2483 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4254{
4255 yyval.JumpTable = yyvsp[-5].JumpTable;
4256 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004257 CHECK_FOR_ERROR
4258 if (V == 0)
4259 GEN_ERROR("May only switch on a constant pool value!");
4260
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004261 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004262 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004263 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4264 ;
4265 break;}
4266case 250:
4267#line 2494 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4268{
4269 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4270 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Andrew Lenharth6353e052006-12-08 18:07:09 +00004271 CHECK_FOR_ERROR
4272
4273 if (V == 0)
4274 GEN_ERROR("May only switch on a constant pool value!");
4275
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004276 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004277 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004278 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4279 ;
4280 break;}
4281case 251:
4282#line 2507 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4283{
Andrew Lenharth6353e052006-12-08 18:07:09 +00004284 // Is this definition named?? if so, assign the name...
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004285 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004286 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004287 InsertValue(yyvsp[0].InstVal);
4288 yyval.InstVal = yyvsp[0].InstVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004289 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004290;
4291 break;}
4292case 252:
4293#line 2516 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4294{ // Used for PHI nodes
Reid Spencer14310612006-12-31 05:40:51 +00004295 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004296 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4297 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4298 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004299 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004300 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004301 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004302 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4303 delete yyvsp[-5].TypeVal;
4304 ;
4305 break;}
4306case 253:
4307#line 2527 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4308{
4309 yyval.PHIList = yyvsp[-6].PHIList;
4310 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004311 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004312 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004313 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004314 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4315 ;
4316 break;}
4317case 254:
4318#line 2537 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4319{
Reid Spencer6f407902007-01-13 05:00:46 +00004320 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004321 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
Reid Spencer6f407902007-01-13 05:00:46 +00004322 // Used for call and invoke instructions
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004323 yyval.ValueRefList = new ValueRefList();
4324 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4325 yyval.ValueRefList->push_back(E);
4326 ;
4327 break;}
4328case 255:
4329#line 2545 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4330{
Reid Spencer14310612006-12-31 05:40:51 +00004331 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004332 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4333 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4334 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4335 yyval.ValueRefList->push_back(E);
Reid Spencer6f407902007-01-13 05:00:46 +00004336 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004337 ;
4338 break;}
4339case 256:
4340#line 2553 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4341{ yyval.ValueRefList = new ValueRefList(); ;
4342 break;}
4343case 257:
4344#line 2556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4345{ yyval.ValueList = new std::vector<Value*>(); ;
4346 break;}
4347case 258:
4348#line 2557 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4349{
4350 yyval.ValueList = yyvsp[-2].ValueList;
4351 yyval.ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencer14310612006-12-31 05:40:51 +00004352 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004353 ;
4354 break;}
4355case 259:
4356#line 2564 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4357{
4358 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004359 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004360 ;
4361 break;}
4362case 260:
4363#line 2568 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4364{
4365 yyval.BoolVal = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004366 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004367 ;
4368 break;}
4369case 261:
4370#line 2573 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4371{
Reid Spencer14310612006-12-31 05:40:51 +00004372 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004373 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
Chris Lattner42a75512007-01-15 02:27:26 +00004374 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004375 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004376 GEN_ERROR(
4377 "Arithmetic operator requires integer, FP, or packed operands!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004378 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) &&
4379 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4380 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4381 yyvsp[-4].BinaryOpVal == Instruction::FRem))
Reid Spencere4d87aa2006-12-23 06:05:41 +00004382 GEN_ERROR("U/S/FRem not supported on packed types!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004383 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004384 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004385 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004386 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004387 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4388 if (yyval.InstVal == 0)
Reid Spencere4d87aa2006-12-23 06:05:41 +00004389 GEN_ERROR("binary operator returned null!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004390 delete yyvsp[-3].TypeVal;
4391 ;
4392 break;}
4393case 262:
4394#line 2594 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4395{
Reid Spencer6f407902007-01-13 05:00:46 +00004396 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004397 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
Chris Lattner42a75512007-01-15 02:27:26 +00004398 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004399 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
Chris Lattner42a75512007-01-15 02:27:26 +00004400 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
Reid Spencer6f407902007-01-13 05:00:46 +00004401 GEN_ERROR("Logical operator requires integral operands!");
4402 }
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004403 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004404 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004405 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004406 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004407 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4408 if (yyval.InstVal == 0)
Reid Spencer6f407902007-01-13 05:00:46 +00004409 GEN_ERROR("binary operator returned null!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004410 delete yyvsp[-3].TypeVal;
4411 ;
4412 break;}
4413case 263:
4414#line 2611 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4415{
Reid Spencer14310612006-12-31 05:40:51 +00004416 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004417 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4418 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencerac4a1dd2007-01-04 02:57:52 +00004419 GEN_ERROR("Packed types not supported by icmp instruction");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004420 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004421 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004422 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004423 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004424 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4425 if (yyval.InstVal == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004426 GEN_ERROR("icmp operator returned null!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004427 ;
4428 break;}
4429case 264:
4430#line 2624 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4431{
Reid Spencer14310612006-12-31 05:40:51 +00004432 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004433 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4434 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencerac4a1dd2007-01-04 02:57:52 +00004435 GEN_ERROR("Packed types not supported by fcmp instruction");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004436 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004437 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004438 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004439 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004440 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4441 if (yyval.InstVal == 0)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004442 GEN_ERROR("fcmp operator returned null!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004443 ;
4444 break;}
4445case 265:
4446#line 2637 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4447{
4448 if (yyvsp[0].ValueVal->getType() != Type::Int8Ty)
Reid Spencer14310612006-12-31 05:40:51 +00004449 GEN_ERROR("Shift amount must be i8 type!");
Chris Lattner42a75512007-01-15 02:27:26 +00004450 if (!yyvsp[-2].ValueVal->getType()->isInteger())
Andrew Lenharth6353e052006-12-08 18:07:09 +00004451 GEN_ERROR("Shift constant expression requires integer operand!");
4452 CHECK_FOR_ERROR;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004453 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004454 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004455 ;
4456 break;}
4457case 266:
4458#line 2646 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4459{
Reid Spencer14310612006-12-31 05:40:51 +00004460 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004461 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4462 Value* Val = yyvsp[-2].ValueVal;
4463 const Type* Ty = yyvsp[0].TypeVal->get();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004464 if (!Val->getType()->isFirstClassType())
4465 GEN_ERROR("cast from a non-primitive type: '" +
4466 Val->getType()->getDescription() + "'!");
4467 if (!Ty->isFirstClassType())
4468 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004469 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, yyvsp[0].TypeVal->get());
4470 delete yyvsp[0].TypeVal;
4471 ;
4472 break;}
4473case 267:
4474#line 2659 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4475{
4476 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00004477 GEN_ERROR("select condition must be boolean!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004478 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Reid Spencer6f407902007-01-13 05:00:46 +00004479 GEN_ERROR("select value types should match!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004480 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004481 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004482 ;
4483 break;}
4484case 268:
4485#line 2667 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4486{
Reid Spencer6f407902007-01-13 05:00:46 +00004487 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004488 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4489 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4490 delete yyvsp[0].TypeVal;
Andrew Lenharth6353e052006-12-08 18:07:09 +00004491 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004492 ;
4493 break;}
4494case 269:
4495#line 2674 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4496{
4497 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer6f407902007-01-13 05:00:46 +00004498 GEN_ERROR("Invalid extractelement operands!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004499 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004500 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004501 ;
4502 break;}
4503case 270:
4504#line 2680 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4505{
4506 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer6f407902007-01-13 05:00:46 +00004507 GEN_ERROR("Invalid insertelement operands!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004508 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004509 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004510 ;
4511 break;}
4512case 271:
4513#line 2686 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4514{
4515 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer6f407902007-01-13 05:00:46 +00004516 GEN_ERROR("Invalid shufflevector operands!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004517 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004518 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004519 ;
4520 break;}
4521case 272:
4522#line 2692 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4523{
4524 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Reid Spencer6f407902007-01-13 05:00:46 +00004525 if (!Ty->isFirstClassType())
4526 GEN_ERROR("PHI node operands must be of first class type!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004527 yyval.InstVal = new PHINode(Ty);
4528 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4529 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4530 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Reid Spencer6f407902007-01-13 05:00:46 +00004531 GEN_ERROR("All elements of a PHI node must be of the same type!");
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004532 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4533 yyvsp[0].PHIList->pop_front();
Reid Spencer6f407902007-01-13 05:00:46 +00004534 }
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004535 delete yyvsp[0].PHIList; // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00004536 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004537 ;
4538 break;}
4539case 273:
4540#line 2708 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4541{
Reid Spencer14310612006-12-31 05:40:51 +00004542
4543 // Handle the short syntax
Andrew Lenharth6353e052006-12-08 18:07:09 +00004544 const PointerType *PFTy = 0;
4545 const FunctionType *Ty = 0;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004546 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
Andrew Lenharth6353e052006-12-08 18:07:09 +00004547 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4548 // Pull out the types of all of the arguments...
4549 std::vector<const Type*> ParamTypes;
Reid Spencer14310612006-12-31 05:40:51 +00004550 FunctionType::ParamAttrsList ParamAttrs;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004551 ParamAttrs.push_back(yyvsp[0].ParamAttrs);
4552 for (ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end(); I != E; ++I) {
Reid Spencer14310612006-12-31 05:40:51 +00004553 const Type *Ty = I->Val->getType();
4554 if (Ty == Type::VoidTy)
4555 GEN_ERROR("Short call syntax cannot be used with varargs");
4556 ParamTypes.push_back(Ty);
4557 ParamAttrs.push_back(I->Attrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004558 }
4559
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004560 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, ParamAttrs);
Andrew Lenharth6353e052006-12-08 18:07:09 +00004561 PFTy = PointerType::get(Ty);
4562 }
4563
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004564 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
Andrew Lenharth6353e052006-12-08 18:07:09 +00004565 CHECK_FOR_ERROR
4566
Reid Spencer14310612006-12-31 05:40:51 +00004567 // Check the arguments
4568 ValueList Args;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004569 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
Andrew Lenharth6353e052006-12-08 18:07:09 +00004570 // Make sure no arguments is a good thing!
4571 if (Ty->getNumParams() != 0)
4572 GEN_ERROR("No arguments passed to a function that "
4573 "expects arguments!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004574 } else { // Has arguments?
4575 // Loop through FunctionType's arguments and ensure they are specified
4576 // correctly!
4577 //
4578 FunctionType::param_iterator I = Ty->param_begin();
4579 FunctionType::param_iterator E = Ty->param_end();
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004580 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
Andrew Lenharth6353e052006-12-08 18:07:09 +00004581
Reid Spencer14310612006-12-31 05:40:51 +00004582 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4583 if (ArgI->Val->getType() != *I)
4584 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
Andrew Lenharth6353e052006-12-08 18:07:09 +00004585 (*I)->getDescription() + "'!");
Reid Spencer14310612006-12-31 05:40:51 +00004586 Args.push_back(ArgI->Val);
4587 }
4588 if (Ty->isVarArg()) {
4589 if (I == E)
4590 for (; ArgI != ArgE; ++ArgI)
4591 Args.push_back(ArgI->Val); // push the remaining varargs
4592 } else if (I != E || ArgI != ArgE)
Andrew Lenharth6353e052006-12-08 18:07:09 +00004593 GEN_ERROR("Invalid number of parameters detected!");
Andrew Lenharth6353e052006-12-08 18:07:09 +00004594 }
Reid Spencer14310612006-12-31 05:40:51 +00004595 // Create the call node
4596 CallInst *CI = new CallInst(V, Args);
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004597 CI->setTailCall(yyvsp[-7].BoolVal);
4598 CI->setCallingConv(yyvsp[-6].UIntVal);
4599 yyval.InstVal = CI;
4600 delete yyvsp[-2].ValueRefList;
Reid Spencer6f407902007-01-13 05:00:46 +00004601 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004602 ;
4603 break;}
4604case 274:
4605#line 2770 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4606{
4607 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004608 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004609 ;
4610 break;}
4611case 275:
4612#line 2775 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4613{
4614 yyval.BoolVal = true;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004615 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004616 ;
4617 break;}
4618case 276:
4619#line 2779 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4620{
4621 yyval.BoolVal = false;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004622 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004623 ;
4624 break;}
4625case 277:
4626#line 2786 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4627{
Reid Spencer14310612006-12-31 05:40:51 +00004628 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004629 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4630 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4631 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004632 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004633 ;
4634 break;}
4635case 278:
4636#line 2793 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4637{
Reid Spencer6f407902007-01-13 05:00:46 +00004638 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004639 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4640 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer6f407902007-01-13 05:00:46 +00004641 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004642 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4643 delete yyvsp[-4].TypeVal;
4644 ;
4645 break;}
4646case 279:
4647#line 2801 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4648{
Reid Spencer14310612006-12-31 05:40:51 +00004649 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004650 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4651 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4652 delete yyvsp[-1].TypeVal;
Reid Spencere4d87aa2006-12-23 06:05:41 +00004653 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004654 ;
4655 break;}
4656case 280:
4657#line 2808 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4658{
Reid Spencer14310612006-12-31 05:40:51 +00004659 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004660 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4661 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004662 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004663 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4664 delete yyvsp[-4].TypeVal;
4665 ;
4666 break;}
4667case 281:
4668#line 2816 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4669{
4670 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Reid Spencer6f407902007-01-13 05:00:46 +00004671 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004672 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4673 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004674 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004675 ;
4676 break;}
4677case 282:
4678#line 2824 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4679{
Reid Spencer6f407902007-01-13 05:00:46 +00004680 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004681 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4682 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
Reid Spencer6f407902007-01-13 05:00:46 +00004683 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004684 (*yyvsp[-1].TypeVal)->getDescription());
4685 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
Reid Spencer6f407902007-01-13 05:00:46 +00004686 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004687 (*yyvsp[-1].TypeVal)->getDescription());
4688 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004689 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004690 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal);
4691 delete yyvsp[-1].TypeVal;
4692 ;
4693 break;}
4694case 283:
4695#line 2838 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4696{
Reid Spencer14310612006-12-31 05:40:51 +00004697 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004698 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4699 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer6f407902007-01-13 05:00:46 +00004700 if (!PT)
4701 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004702 (*yyvsp[-1].TypeVal)->getDescription());
Reid Spencer6f407902007-01-13 05:00:46 +00004703 const Type *ElTy = PT->getElementType();
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004704 if (ElTy != yyvsp[-3].ValueVal->getType())
4705 GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
Reid Spencer6f407902007-01-13 05:00:46 +00004706 "' into space of type '" + ElTy->getDescription() + "'!");
4707
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004708 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004709 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004710 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal);
4711 delete yyvsp[-1].TypeVal;
4712 ;
4713 break;}
4714case 284:
4715#line 2855 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4716{
Reid Spencer14310612006-12-31 05:40:51 +00004717 if (!UpRefs.empty())
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004718 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4719 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004720 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004721
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004722 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
Reid Spencer61c83e02006-08-18 08:43:06 +00004723 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004724 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4725 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004726 CHECK_FOR_ERROR
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004727 yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList);
4728 delete yyvsp[-2].TypeVal;
4729 delete yyvsp[0].ValueList;
4730 ;
4731 break;}
4732}
4733 /* the action file gets copied in in place of this dollarsign */
4734#line 543 "/usr/share/bison.simple"
Reid Spencer6f407902007-01-13 05:00:46 +00004735
4736 yyvsp -= yylen;
4737 yyssp -= yylen;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004738#ifdef YYLSP_NEEDED
4739 yylsp -= yylen;
4740#endif
Reid Spencer6f407902007-01-13 05:00:46 +00004741
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004742#if YYDEBUG != 0
4743 if (yydebug)
4744 {
4745 short *ssp1 = yyss - 1;
4746 fprintf (stderr, "state stack now");
4747 while (ssp1 != yyssp)
4748 fprintf (stderr, " %d", *++ssp1);
4749 fprintf (stderr, "\n");
4750 }
4751#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004752
4753 *++yyvsp = yyval;
4754
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004755#ifdef YYLSP_NEEDED
4756 yylsp++;
4757 if (yylen == 0)
4758 {
4759 yylsp->first_line = yylloc.first_line;
4760 yylsp->first_column = yylloc.first_column;
4761 yylsp->last_line = (yylsp-1)->last_line;
4762 yylsp->last_column = (yylsp-1)->last_column;
4763 yylsp->text = 0;
4764 }
4765 else
4766 {
4767 yylsp->last_line = (yylsp+yylen-1)->last_line;
4768 yylsp->last_column = (yylsp+yylen-1)->last_column;
4769 }
4770#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004771
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004772 /* Now "shift" the result of the reduction.
4773 Determine what state that goes to,
4774 based on the state we popped back to
4775 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004776
4777 yyn = yyr1[yyn];
4778
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004779 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4780 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004781 yystate = yytable[yystate];
4782 else
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004783 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00004784
4785 goto yynewstate;
4786
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004787yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004788
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004789 if (! yyerrstatus)
4790 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004791 {
4792 ++yynerrs;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004793
4794#ifdef YYERROR_VERBOSE
Reid Spencer6f407902007-01-13 05:00:46 +00004795 yyn = yypact[yystate];
Chris Lattner0fab59c2007-01-12 18:33:30 +00004796
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004797 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer6f407902007-01-13 05:00:46 +00004798 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004799 int size = 0;
4800 char *msg;
4801 int x, count;
Reid Spencer6f407902007-01-13 05:00:46 +00004802
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004803 count = 0;
4804 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4805 for (x = (yyn < 0 ? -yyn : 0);
4806 x < (sizeof(yytname) / sizeof(char *)); x++)
4807 if (yycheck[x + yyn] == x)
4808 size += strlen(yytname[x]) + 15, count++;
4809 msg = (char *) malloc(size + 15);
4810 if (msg != 0)
Reid Spencer6f407902007-01-13 05:00:46 +00004811 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004812 strcpy(msg, "parse error");
4813
4814 if (count < 5)
Reid Spencer6f407902007-01-13 05:00:46 +00004815 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004816 count = 0;
4817 for (x = (yyn < 0 ? -yyn : 0);
4818 x < (sizeof(yytname) / sizeof(char *)); x++)
4819 if (yycheck[x + yyn] == x)
4820 {
4821 strcat(msg, count == 0 ? ", expecting `" : " or `");
4822 strcat(msg, yytname[x]);
4823 strcat(msg, "'");
4824 count++;
4825 }
Reid Spencer6f407902007-01-13 05:00:46 +00004826 }
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004827 yyerror(msg);
4828 free(msg);
Reid Spencer6f407902007-01-13 05:00:46 +00004829 }
4830 else
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004831 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer6f407902007-01-13 05:00:46 +00004832 }
4833 else
4834#endif /* YYERROR_VERBOSE */
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004835 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004836 }
4837
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004838 goto yyerrlab1;
4839yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004840
4841 if (yyerrstatus == 3)
4842 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004843 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004844
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004845 /* return failure if at end of input */
4846 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004847 YYABORT;
4848
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004849#if YYDEBUG != 0
4850 if (yydebug)
4851 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4852#endif
Reid Spencere4d87aa2006-12-23 06:05:41 +00004853
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004854 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004855 }
4856
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004857 /* Else will try to reuse lookahead token
4858 after shifting the error token. */
4859
4860 yyerrstatus = 3; /* Each real token shifted decrements this */
4861
4862 goto yyerrhandle;
4863
4864yyerrdefault: /* current state does not do anything special for the error token. */
4865
4866#if 0
4867 /* This is wrong; only states that explicitly want error tokens
4868 should shift them. */
4869 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4870 if (yyn) goto yydefault;
4871#endif
4872
4873yyerrpop: /* pop the current state because it cannot handle the error token */
4874
4875 if (yyssp == yyss) YYABORT;
4876 yyvsp--;
4877 yystate = *--yyssp;
4878#ifdef YYLSP_NEEDED
4879 yylsp--;
4880#endif
4881
4882#if YYDEBUG != 0
4883 if (yydebug)
4884 {
4885 short *ssp1 = yyss - 1;
4886 fprintf (stderr, "Error: state stack now");
4887 while (ssp1 != yyssp)
4888 fprintf (stderr, " %d", *++ssp1);
4889 fprintf (stderr, "\n");
4890 }
4891#endif
4892
4893yyerrhandle:
4894
4895 yyn = yypact[yystate];
4896 if (yyn == YYFLAG)
4897 goto yyerrdefault;
4898
4899 yyn += YYTERROR;
4900 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4901 goto yyerrdefault;
4902
4903 yyn = yytable[yyn];
4904 if (yyn < 0)
4905 {
4906 if (yyn == YYFLAG)
4907 goto yyerrpop;
4908 yyn = -yyn;
4909 goto yyreduce;
4910 }
4911 else if (yyn == 0)
4912 goto yyerrpop;
4913
Reid Spencer68a24bd2005-08-27 18:50:39 +00004914 if (yyn == YYFINAL)
4915 YYACCEPT;
4916
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004917#if YYDEBUG != 0
4918 if (yydebug)
4919 fprintf(stderr, "Shifting error token, ");
4920#endif
4921
Reid Spencer68a24bd2005-08-27 18:50:39 +00004922 *++yyvsp = yylval;
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004923#ifdef YYLSP_NEEDED
4924 *++yylsp = yylloc;
4925#endif
Reid Spencere4d87aa2006-12-23 06:05:41 +00004926
Reid Spencer68a24bd2005-08-27 18:50:39 +00004927 yystate = yyn;
4928 goto yynewstate;
4929
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004930 yyacceptlab:
4931 /* YYACCEPT comes here. */
4932 if (yyfree_stacks)
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004933 {
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004934 free (yyss);
4935 free (yyvs);
4936#ifdef YYLSP_NEEDED
4937 free (yyls);
Anton Korobeynikov178a3522007-01-12 19:22:51 +00004938#endif
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004939 }
4940 return 0;
4941
4942 yyabortlab:
4943 /* YYABORT comes here. */
4944 if (yyfree_stacks)
4945 {
4946 free (yyss);
4947 free (yyvs);
4948#ifdef YYLSP_NEEDED
4949 free (yyls);
4950#endif
4951 }
4952 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004953}
Chris Lattnerb25c4ca2007-01-15 02:12:07 +00004954#line 2872 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004955
4956
Reid Spencer14310612006-12-31 05:40:51 +00004957// common code from the two 'RunVMAsmParser' functions
4958static Module* RunParser(Module * M) {
4959
4960 llvmAsmlineno = 1; // Reset the current line number...
4961 CurModule.CurrentModule = M;
4962#if YYDEBUG
4963 yydebug = Debug;
4964#endif
4965
4966 // Check to make sure the parser succeeded
4967 if (yyparse()) {
4968 if (ParserResult)
4969 delete ParserResult;
4970 return 0;
4971 }
4972
4973 // Check to make sure that parsing produced a result
4974 if (!ParserResult)
4975 return 0;
4976
4977 // Reset ParserResult variable while saving its value for the result.
4978 Module *Result = ParserResult;
4979 ParserResult = 0;
4980
4981 return Result;
4982}
4983
Reid Spencer61c83e02006-08-18 08:43:06 +00004984void llvm::GenerateError(const std::string &message, int LineNo) {
4985 if (LineNo == -1) LineNo = llvmAsmlineno;
4986 // TODO: column number in exception
4987 if (TheParseError)
4988 TheParseError->setError(CurFilename, message, LineNo);
4989 TriggerError = 1;
4990}
Reid Spencer68a24bd2005-08-27 18:50:39 +00004991
4992int yyerror(const char *ErrorMsg) {
4993 std::string where
4994 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4995 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4996 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4997 if (yychar == YYEMPTY || yychar == 0)
4998 errMsg += "end-of-file.";
4999 else
5000 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005001 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005002 return 0;
5003}