blob: d54f66a1dac987f057aff26963f2a872101468f2 [file] [log] [blame]
Reid Spencer61c83e02006-08-18 08:43:06 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer61c83e02006-08-18 08:43:06 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005
Reid Spencer61c83e02006-08-18 08:43:06 +00006 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
Reid Spencer68a24bd2005-08-27 18:50:39 +000010
Reid Spencer61c83e02006-08-18 08:43:06 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
44
45/* Pure parsers. */
46#define YYPURE 0
47
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
51/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000052#define yyparse llvmAsmparse
Reid Spencer61c83e02006-08-18 08:43:06 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer61c83e02006-08-18 08:43:06 +000055#define yylval llvmAsmlval
56#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000057#define yydebug llvmAsmdebug
58#define yynerrs llvmAsmnerrs
59
Reid Spencer61c83e02006-08-18 08:43:06 +000060
61/* Tokens. */
62#ifndef YYTOKENTYPE
63# define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
67 ESINT64VAL = 258,
68 EUINT64VAL = 259,
69 SINTVAL = 260,
70 UINTVAL = 261,
71 FPVAL = 262,
72 VOID = 263,
73 BOOL = 264,
74 SBYTE = 265,
75 UBYTE = 266,
76 SHORT = 267,
77 USHORT = 268,
78 INT = 269,
79 UINT = 270,
80 LONG = 271,
81 ULONG = 272,
82 FLOAT = 273,
83 DOUBLE = 274,
84 TYPE = 275,
85 LABEL = 276,
86 VAR_ID = 277,
87 LABELSTR = 278,
88 STRINGCONSTANT = 279,
89 IMPLEMENTATION = 280,
90 ZEROINITIALIZER = 281,
91 TRUETOK = 282,
92 FALSETOK = 283,
93 BEGINTOK = 284,
94 ENDTOK = 285,
95 DECLARE = 286,
96 GLOBAL = 287,
97 CONSTANT = 288,
98 SECTION = 289,
99 VOLATILE = 290,
100 TO = 291,
101 DOTDOTDOT = 292,
102 NULL_TOK = 293,
103 UNDEF = 294,
104 CONST = 295,
105 INTERNAL = 296,
106 LINKONCE = 297,
107 WEAK = 298,
108 APPENDING = 299,
109 OPAQUE = 300,
110 NOT = 301,
111 EXTERNAL = 302,
112 TARGET = 303,
113 TRIPLE = 304,
114 ENDIAN = 305,
115 POINTERSIZE = 306,
116 LITTLE = 307,
117 BIG = 308,
118 ALIGN = 309,
119 DEPLIBS = 310,
120 CALL = 311,
121 TAIL = 312,
122 ASM_TOK = 313,
123 MODULE = 314,
124 SIDEEFFECT = 315,
125 CC_TOK = 316,
126 CCC_TOK = 317,
127 CSRETCC_TOK = 318,
128 FASTCC_TOK = 319,
129 COLDCC_TOK = 320,
130 RET = 321,
131 BR = 322,
132 SWITCH = 323,
133 INVOKE = 324,
134 UNWIND = 325,
135 UNREACHABLE = 326,
136 ADD = 327,
137 SUB = 328,
138 MUL = 329,
139 DIV = 330,
140 REM = 331,
141 AND = 332,
142 OR = 333,
143 XOR = 334,
144 SETLE = 335,
145 SETGE = 336,
146 SETLT = 337,
147 SETGT = 338,
148 SETEQ = 339,
149 SETNE = 340,
150 MALLOC = 341,
151 ALLOCA = 342,
152 FREE = 343,
153 LOAD = 344,
154 STORE = 345,
155 GETELEMENTPTR = 346,
156 PHI_TOK = 347,
157 CAST = 348,
158 SELECT = 349,
159 SHL = 350,
160 SHR = 351,
161 VAARG = 352,
162 EXTRACTELEMENT = 353,
163 INSERTELEMENT = 354,
164 SHUFFLEVECTOR = 355,
165 VAARG_old = 356,
166 VANEXT_old = 357
167 };
168#endif
169/* Tokens. */
170#define ESINT64VAL 258
171#define EUINT64VAL 259
172#define SINTVAL 260
173#define UINTVAL 261
174#define FPVAL 262
175#define VOID 263
176#define BOOL 264
177#define SBYTE 265
178#define UBYTE 266
179#define SHORT 267
180#define USHORT 268
181#define INT 269
182#define UINT 270
183#define LONG 271
184#define ULONG 272
185#define FLOAT 273
186#define DOUBLE 274
187#define TYPE 275
188#define LABEL 276
189#define VAR_ID 277
190#define LABELSTR 278
191#define STRINGCONSTANT 279
192#define IMPLEMENTATION 280
193#define ZEROINITIALIZER 281
194#define TRUETOK 282
195#define FALSETOK 283
196#define BEGINTOK 284
197#define ENDTOK 285
198#define DECLARE 286
199#define GLOBAL 287
200#define CONSTANT 288
201#define SECTION 289
202#define VOLATILE 290
203#define TO 291
204#define DOTDOTDOT 292
205#define NULL_TOK 293
206#define UNDEF 294
207#define CONST 295
208#define INTERNAL 296
209#define LINKONCE 297
210#define WEAK 298
211#define APPENDING 299
212#define OPAQUE 300
213#define NOT 301
214#define EXTERNAL 302
215#define TARGET 303
216#define TRIPLE 304
217#define ENDIAN 305
218#define POINTERSIZE 306
219#define LITTLE 307
220#define BIG 308
221#define ALIGN 309
222#define DEPLIBS 310
223#define CALL 311
224#define TAIL 312
225#define ASM_TOK 313
226#define MODULE 314
227#define SIDEEFFECT 315
228#define CC_TOK 316
229#define CCC_TOK 317
230#define CSRETCC_TOK 318
231#define FASTCC_TOK 319
232#define COLDCC_TOK 320
233#define RET 321
234#define BR 322
235#define SWITCH 323
236#define INVOKE 324
237#define UNWIND 325
238#define UNREACHABLE 326
239#define ADD 327
240#define SUB 328
241#define MUL 329
242#define DIV 330
243#define REM 331
244#define AND 332
245#define OR 333
246#define XOR 334
247#define SETLE 335
248#define SETGE 336
249#define SETLT 337
250#define SETGT 338
251#define SETEQ 339
252#define SETNE 340
253#define MALLOC 341
254#define ALLOCA 342
255#define FREE 343
256#define LOAD 344
257#define STORE 345
258#define GETELEMENTPTR 346
259#define PHI_TOK 347
260#define CAST 348
261#define SELECT 349
262#define SHL 350
263#define SHR 351
264#define VAARG 352
265#define EXTRACTELEMENT 353
266#define INSERTELEMENT 354
267#define SHUFFLEVECTOR 355
268#define VAARG_old 356
269#define VANEXT_old 357
270
271
272
273
274/* Copy the first part of user declarations. */
275#line 14 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000276
277#include "ParserInternals.h"
278#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000279#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000280#include "llvm/Instructions.h"
281#include "llvm/Module.h"
282#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000283#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000284#include "llvm/Support/GetElementPtrTypeIterator.h"
285#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000286#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000287#include <algorithm>
288#include <iostream>
289#include <list>
290#include <utility>
291
Reid Spencere4f47592006-08-18 17:32:55 +0000292// The following is a gross hack. In order to rid the libAsmParser library of
293// exceptions, we have to have a way of getting the yyparse function to go into
294// an error situation. So, whenever we want an error to occur, the GenerateError
295// function (see bottom of file) sets TriggerError. Then, at the end of each
296// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
297// (a goto) to put YACC in error state. Furthermore, several calls to
298// GenerateError are made from inside productions and they must simulate the
299// previous exception behavior by exiting the production immediately. We have
300// replaced these with the GEN_ERROR macro which calls GeneratError and then
301// immediately invokes YYERROR. This would be so much cleaner if it was a
302// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000303static bool TriggerError = false;
304#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYERROR; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000305#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
306
Reid Spencer68a24bd2005-08-27 18:50:39 +0000307int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
308int yylex(); // declaration" of xxx warnings.
309int yyparse();
310
311namespace llvm {
312 std::string CurFilename;
313}
314using namespace llvm;
315
316static Module *ParserResult;
317
318// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
319// relating to upreferences in the input stream.
320//
321//#define DEBUG_UPREFS 1
322#ifdef DEBUG_UPREFS
323#define UR_OUT(X) std::cerr << X
324#else
325#define UR_OUT(X)
326#endif
327
328#define YYERROR_VERBOSE 1
329
330static bool ObsoleteVarArgs;
331static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000332static BasicBlock *CurBB;
333static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000334
335
336// This contains info used when building the body of a function. It is
337// destroyed when the function is completed.
338//
339typedef std::vector<Value *> ValueList; // Numbered defs
340static void
341ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
342 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
343
344static struct PerModuleInfo {
345 Module *CurrentModule;
346 std::map<const Type *, ValueList> Values; // Module level numbered definitions
347 std::map<const Type *,ValueList> LateResolveValues;
348 std::vector<PATypeHolder> Types;
349 std::map<ValID, PATypeHolder> LateResolveTypes;
350
351 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000352 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000353 /// that we can resolve them later and print error messages as appropriate.
354 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
355
356 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
357 // references to global values. Global values may be referenced before they
358 // are defined, and if so, the temporary object that they represent is held
359 // here. This is used for forward references of GlobalValues.
360 //
361 typedef std::map<std::pair<const PointerType *,
362 ValID>, GlobalValue*> GlobalRefsType;
363 GlobalRefsType GlobalRefs;
364
365 void ModuleDone() {
366 // If we could not resolve some functions at function compilation time
367 // (calls to functions before they are defined), resolve them now... Types
368 // are resolved when the constant pool has been completely parsed.
369 //
370 ResolveDefinitions(LateResolveValues);
371
372 // Check to make sure that all global value forward references have been
373 // resolved!
374 //
375 if (!GlobalRefs.empty()) {
376 std::string UndefinedReferences = "Unresolved global references exist:\n";
377
378 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
379 I != E; ++I) {
380 UndefinedReferences += " " + I->first.first->getDescription() + " " +
381 I->first.second.getName() + "\n";
382 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000383 GenerateError(UndefinedReferences);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000384 }
385
Reid Spencere812fb22006-01-19 01:21:04 +0000386 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattnerd5efe842006-04-08 01:18:56 +0000387 for (Module::iterator FI = CurrentModule->begin(),
388 FE = CurrentModule->end(); FI != FE; )
Chris Lattnerc2c60382006-03-04 07:53:41 +0000389 UpgradeCallsToIntrinsic(FI++);
Reid Spencer0b118202006-01-16 21:12:35 +0000390
Reid Spencer68a24bd2005-08-27 18:50:39 +0000391 Values.clear(); // Clear out function local definitions
392 Types.clear();
393 CurrentModule = 0;
394 }
395
Reid Spencer68a24bd2005-08-27 18:50:39 +0000396 // GetForwardRefForGlobal - Check to see if there is a forward reference
397 // for this global. If so, remove it from the GlobalRefs map and return it.
398 // If not, just return null.
399 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
400 // Check to see if there is a forward reference to this global variable...
401 // if there is, eliminate it and patch the reference to use the new def'n.
402 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
403 GlobalValue *Ret = 0;
404 if (I != GlobalRefs.end()) {
405 Ret = I->second;
406 GlobalRefs.erase(I);
407 }
408 return Ret;
409 }
410} CurModule;
411
412static struct PerFunctionInfo {
413 Function *CurrentFunction; // Pointer to current function being created
414
415 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
416 std::map<const Type*, ValueList> LateResolveValues;
417 bool isDeclare; // Is this function a forward declararation?
418
419 /// BBForwardRefs - When we see forward references to basic blocks, keep
420 /// track of them here.
421 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
422 std::vector<BasicBlock*> NumberedBlocks;
423 unsigned NextBBNum;
424
425 inline PerFunctionInfo() {
426 CurrentFunction = 0;
427 isDeclare = false;
428 }
429
430 inline void FunctionStart(Function *M) {
431 CurrentFunction = M;
432 NextBBNum = 0;
433 }
434
435 void FunctionDone() {
436 NumberedBlocks.clear();
437
438 // Any forward referenced blocks left?
439 if (!BBForwardRefs.empty())
Reid Spencer61c83e02006-08-18 08:43:06 +0000440 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000441 BBForwardRefs.begin()->first->getName());
442
443 // Resolve all forward references now.
444 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
445
446 Values.clear(); // Clear out function local definitions
447 CurrentFunction = 0;
448 isDeclare = false;
449 }
450} CurFun; // Info for the current function...
451
452static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
453
454
455//===----------------------------------------------------------------------===//
456// Code to handle definitions of all the types
457//===----------------------------------------------------------------------===//
458
459static int InsertValue(Value *V,
460 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
461 if (V->hasName()) return -1; // Is this a numbered definition?
462
463 // Yes, insert the value into the value table...
464 ValueList &List = ValueTab[V->getType()];
465 List.push_back(V);
466 return List.size()-1;
467}
468
469static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
470 switch (D.Type) {
471 case ValID::NumberVal: // Is it a numbered definition?
472 // Module constants occupy the lowest numbered slots...
473 if ((unsigned)D.Num < CurModule.Types.size())
474 return CurModule.Types[(unsigned)D.Num];
475 break;
476 case ValID::NameVal: // Is it a named definition?
477 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
478 D.destroy(); // Free old strdup'd memory...
479 return N;
480 }
481 break;
482 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000483 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000484 }
485
486 // If we reached here, we referenced either a symbol that we don't know about
487 // or an id number that hasn't been read yet. We may be referencing something
488 // forward, so just create an entry to be resolved later and get to it...
489 //
490 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
491
492
493 if (inFunctionScope()) {
494 if (D.Type == ValID::NameVal)
Reid Spencer61c83e02006-08-18 08:43:06 +0000495 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000496 else
Reid Spencer61c83e02006-08-18 08:43:06 +0000497 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer68a24bd2005-08-27 18:50:39 +0000498 }
499
500 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
501 if (I != CurModule.LateResolveTypes.end())
502 return I->second;
503
504 Type *Typ = OpaqueType::get();
505 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
506 return Typ;
507 }
508
509static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
510 SymbolTable &SymTab =
511 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
512 CurModule.CurrentModule->getSymbolTable();
513 return SymTab.lookup(Ty, Name);
514}
515
516// getValNonImprovising - Look up the value specified by the provided type and
517// the provided ValID. If the value exists and has already been defined, return
518// it. Otherwise return null.
519//
520static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
521 if (isa<FunctionType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +0000522 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000523 "must be referenced as pointers");
524
525 switch (D.Type) {
526 case ValID::NumberVal: { // Is it a numbered definition?
527 unsigned Num = (unsigned)D.Num;
528
529 // Module constants occupy the lowest numbered slots...
530 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
531 if (VI != CurModule.Values.end()) {
532 if (Num < VI->second.size())
533 return VI->second[Num];
534 Num -= VI->second.size();
535 }
536
537 // Make sure that our type is within bounds
538 VI = CurFun.Values.find(Ty);
539 if (VI == CurFun.Values.end()) return 0;
540
541 // Check that the number is within bounds...
542 if (VI->second.size() <= Num) return 0;
543
544 return VI->second[Num];
545 }
546
547 case ValID::NameVal: { // Is it a named definition?
548 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
549 if (N == 0) return 0;
550
551 D.destroy(); // Free old strdup'd memory...
552 return N;
553 }
554
555 // Check to make sure that "Ty" is an integral type, and that our
556 // value will fit into the specified type...
557 case ValID::ConstSIntVal: // Is it a constant pool reference??
558 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
Reid Spencer61c83e02006-08-18 08:43:06 +0000559 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000560 itostr(D.ConstPool64) + "' is invalid for type '" +
561 Ty->getDescription() + "'!");
562 return ConstantSInt::get(Ty, D.ConstPool64);
563
564 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
565 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
566 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000567 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000568 "' is invalid or out of range!");
569 } else { // This is really a signed reference. Transmogrify.
570 return ConstantSInt::get(Ty, D.ConstPool64);
571 }
572 } else {
573 return ConstantUInt::get(Ty, D.UConstPool64);
574 }
575
576 case ValID::ConstFPVal: // Is it a floating point const pool reference?
577 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
Reid Spencer61c83e02006-08-18 08:43:06 +0000578 GenerateError("FP constant invalid for type!!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000579 return ConstantFP::get(Ty, D.ConstPoolFP);
580
581 case ValID::ConstNullVal: // Is it a null value?
582 if (!isa<PointerType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +0000583 GenerateError("Cannot create a a non pointer null!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584 return ConstantPointerNull::get(cast<PointerType>(Ty));
585
586 case ValID::ConstUndefVal: // Is it an undef value?
587 return UndefValue::get(Ty);
588
Chris Lattner7aa61892005-12-21 17:53:23 +0000589 case ValID::ConstZeroVal: // Is it a zero value?
590 return Constant::getNullValue(Ty);
591
Reid Spencer68a24bd2005-08-27 18:50:39 +0000592 case ValID::ConstantVal: // Fully resolved constant?
593 if (D.ConstantValue->getType() != Ty)
Reid Spencer61c83e02006-08-18 08:43:06 +0000594 GenerateError("Constant expression type different from required type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000595 return D.ConstantValue;
596
Chris Lattner0e9c3762006-01-25 22:27:16 +0000597 case ValID::InlineAsmVal: { // Inline asm expression
598 const PointerType *PTy = dyn_cast<PointerType>(Ty);
599 const FunctionType *FTy =
600 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
601 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints))
Reid Spencer61c83e02006-08-18 08:43:06 +0000602 GenerateError("Invalid type for asm constraint string!");
Chris Lattner0e9c3762006-01-25 22:27:16 +0000603 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
604 D.IAD->HasSideEffects);
605 D.destroy(); // Free InlineAsmDescriptor.
606 return IA;
607 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000608 default:
609 assert(0 && "Unhandled case!");
610 return 0;
611 } // End of switch
612
613 assert(0 && "Unhandled case!");
614 return 0;
615}
616
617// getVal - This function is identical to getValNonImprovising, except that if a
618// value is not already defined, it "improvises" by creating a placeholder var
619// that looks and acts just like the requested variable. When the value is
620// defined later, all uses of the placeholder variable are replaced with the
621// real thing.
622//
623static Value *getVal(const Type *Ty, const ValID &ID) {
624 if (Ty == Type::LabelTy)
Reid Spencer61c83e02006-08-18 08:43:06 +0000625 GenerateError("Cannot use a basic block here");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000626
627 // See if the value has already been defined.
628 Value *V = getValNonImprovising(Ty, ID);
629 if (V) return V;
630
631 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +0000632 GenerateError("Invalid use of a composite type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000633
634 // If we reached here, we referenced either a symbol that we don't know about
635 // or an id number that hasn't been read yet. We may be referencing something
636 // forward, so just create an entry to be resolved later and get to it...
637 //
638 V = new Argument(Ty);
639
640 // Remember where this forward reference came from. FIXME, shouldn't we try
641 // to recycle these things??
642 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
643 llvmAsmlineno)));
644
645 if (inFunctionScope())
646 InsertValue(V, CurFun.LateResolveValues);
647 else
648 InsertValue(V, CurModule.LateResolveValues);
649 return V;
650}
651
652/// getBBVal - This is used for two purposes:
653/// * If isDefinition is true, a new basic block with the specified ID is being
654/// defined.
655/// * If isDefinition is true, this is a reference to a basic block, which may
656/// or may not be a forward reference.
657///
658static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
659 assert(inFunctionScope() && "Can't get basic block at global scope!");
660
661 std::string Name;
662 BasicBlock *BB = 0;
663 switch (ID.Type) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000664 default: GenerateError("Illegal label reference " + ID.getName());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000665 case ValID::NumberVal: // Is it a numbered definition?
666 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
667 CurFun.NumberedBlocks.resize(ID.Num+1);
668 BB = CurFun.NumberedBlocks[ID.Num];
669 break;
670 case ValID::NameVal: // Is it a named definition?
671 Name = ID.Name;
672 if (Value *N = CurFun.CurrentFunction->
673 getSymbolTable().lookup(Type::LabelTy, Name))
674 BB = cast<BasicBlock>(N);
675 break;
676 }
677
678 // See if the block has already been defined.
679 if (BB) {
680 // If this is the definition of the block, make sure the existing value was
681 // just a forward reference. If it was a forward reference, there will be
682 // an entry for it in the PlaceHolderInfo map.
683 if (isDefinition && !CurFun.BBForwardRefs.erase(BB))
684 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000685 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer68a24bd2005-08-27 18:50:39 +0000686
687 ID.destroy(); // Free strdup'd memory.
688 return BB;
689 }
690
691 // Otherwise this block has not been seen before.
692 BB = new BasicBlock("", CurFun.CurrentFunction);
693 if (ID.Type == ValID::NameVal) {
694 BB->setName(ID.Name);
695 } else {
696 CurFun.NumberedBlocks[ID.Num] = BB;
697 }
698
699 // If this is not a definition, keep track of it so we can use it as a forward
700 // reference.
701 if (!isDefinition) {
702 // Remember where this forward reference came from.
703 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
704 } else {
705 // The forward declaration could have been inserted anywhere in the
706 // function: insert it into the correct place now.
707 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
708 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
709 }
710 ID.destroy();
711 return BB;
712}
713
714
715//===----------------------------------------------------------------------===//
716// Code to handle forward references in instructions
717//===----------------------------------------------------------------------===//
718//
719// This code handles the late binding needed with statements that reference
720// values not defined yet... for example, a forward branch, or the PHI node for
721// a loop body.
722//
723// This keeps a table (CurFun.LateResolveValues) of all such forward references
724// and back patchs after we are done.
725//
726
727// ResolveDefinitions - If we could not resolve some defs at parsing
728// time (forward branches, phi functions for loops, etc...) resolve the
729// defs now...
730//
731static void
732ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
733 std::map<const Type*,ValueList> *FutureLateResolvers) {
734 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
735 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
736 E = LateResolvers.end(); LRI != E; ++LRI) {
737 ValueList &List = LRI->second;
738 while (!List.empty()) {
739 Value *V = List.back();
740 List.pop_back();
741
742 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
743 CurModule.PlaceHolderInfo.find(V);
744 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
745
746 ValID &DID = PHI->second.first;
747
748 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
749 if (TheRealValue) {
750 V->replaceAllUsesWith(TheRealValue);
751 delete V;
752 CurModule.PlaceHolderInfo.erase(PHI);
753 } else if (FutureLateResolvers) {
754 // Functions have their unresolved items forwarded to the module late
755 // resolver table
756 InsertValue(V, *FutureLateResolvers);
757 } else {
758 if (DID.Type == ValID::NameVal)
Reid Spencer61c83e02006-08-18 08:43:06 +0000759 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000760 "' of type '" + V->getType()->getDescription() + "'",
761 PHI->second.second);
762 else
Reid Spencer61c83e02006-08-18 08:43:06 +0000763 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000764 itostr(DID.Num) + " of type '" +
765 V->getType()->getDescription() + "'",
766 PHI->second.second);
767 }
768 }
769 }
770
771 LateResolvers.clear();
772}
773
774// ResolveTypeTo - A brand new type was just declared. This means that (if
775// name is not null) things referencing Name can be resolved. Otherwise, things
776// refering to the number can be resolved. Do this now.
777//
778static void ResolveTypeTo(char *Name, const Type *ToTy) {
779 ValID D;
780 if (Name) D = ValID::create(Name);
781 else D = ValID::create((int)CurModule.Types.size());
782
783 std::map<ValID, PATypeHolder>::iterator I =
784 CurModule.LateResolveTypes.find(D);
785 if (I != CurModule.LateResolveTypes.end()) {
786 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
787 CurModule.LateResolveTypes.erase(I);
788 }
789}
790
791// setValueName - Set the specified value to the name given. The name may be
792// null potentially, in which case this is a noop. The string passed in is
793// assumed to be a malloc'd string buffer, and is free'd by this function.
794//
795static void setValueName(Value *V, char *NameStr) {
796 if (NameStr) {
797 std::string Name(NameStr); // Copy string
798 free(NameStr); // Free old string
799
800 if (V->getType() == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +0000801 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000802
803 assert(inFunctionScope() && "Must be in function scope!");
804 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
805 if (ST.lookup(V->getType(), Name))
Reid Spencer61c83e02006-08-18 08:43:06 +0000806 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000807 V->getType()->getDescription() + "' type plane!");
808
809 // Set the name.
810 V->setName(Name);
811 }
812}
813
814/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
815/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000816static GlobalVariable *
817ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
818 bool isConstantGlobal, const Type *Ty,
819 Constant *Initializer) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000820 if (isa<FunctionType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +0000821 GenerateError("Cannot declare global vars of function type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000822
823 const PointerType *PTy = PointerType::get(Ty);
824
825 std::string Name;
826 if (NameStr) {
827 Name = NameStr; // Copy string
828 free(NameStr); // Free old string
829 }
830
831 // See if this global value was forward referenced. If so, recycle the
832 // object.
833 ValID ID;
834 if (!Name.empty()) {
835 ID = ValID::create((char*)Name.c_str());
836 } else {
837 ID = ValID::create((int)CurModule.Values[PTy].size());
838 }
839
840 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
841 // Move the global to the end of the list, from whereever it was
842 // previously inserted.
843 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
844 CurModule.CurrentModule->getGlobalList().remove(GV);
845 CurModule.CurrentModule->getGlobalList().push_back(GV);
846 GV->setInitializer(Initializer);
847 GV->setLinkage(Linkage);
848 GV->setConstant(isConstantGlobal);
849 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000850 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000851 }
852
853 // If this global has a name, check to see if there is already a definition
854 // of this global in the module. If so, merge as appropriate. Note that
855 // this is really just a hack around problems in the CFE. :(
856 if (!Name.empty()) {
857 // We are a simple redefinition of a value, check to see if it is defined
858 // the same as the old one.
859 if (GlobalVariable *EGV =
860 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
861 // We are allowed to redefine a global variable in two circumstances:
862 // 1. If at least one of the globals is uninitialized or
863 // 2. If both initializers have the same value.
864 //
865 if (!EGV->hasInitializer() || !Initializer ||
866 EGV->getInitializer() == Initializer) {
867
868 // Make sure the existing global version gets the initializer! Make
869 // sure that it also gets marked const if the new version is.
870 if (Initializer && !EGV->hasInitializer())
871 EGV->setInitializer(Initializer);
872 if (isConstantGlobal)
873 EGV->setConstant(true);
874 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000875 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000876 }
877
Reid Spencer61c83e02006-08-18 08:43:06 +0000878 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000879 "' in the '" + Ty->getDescription() + "' type plane!");
880 }
881 }
882
883 // Otherwise there is no existing GV to use, create one now.
884 GlobalVariable *GV =
885 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
886 CurModule.CurrentModule);
887 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000888 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000889}
890
891// setTypeName - Set the specified type to the name given. The name may be
892// null potentially, in which case this is a noop. The string passed in is
893// assumed to be a malloc'd string buffer, and is freed by this function.
894//
895// This function returns true if the type has already been defined, but is
896// allowed to be redefined in the specified context. If the name is a new name
897// for the type plane, it is inserted and false is returned.
898static bool setTypeName(const Type *T, char *NameStr) {
899 assert(!inFunctionScope() && "Can't give types function-local names!");
900 if (NameStr == 0) return false;
901
902 std::string Name(NameStr); // Copy string
903 free(NameStr); // Free old string
904
905 // We don't allow assigning names to void type
906 if (T == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +0000907 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +0000908
909 // Set the type name, checking for conflicts as we do so.
910 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
911
912 if (AlreadyExists) { // Inserting a name that is already defined???
913 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
914 assert(Existing && "Conflict but no matching type?");
915
916 // There is only one case where this is allowed: when we are refining an
917 // opaque type. In this case, Existing will be an opaque type.
918 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
919 // We ARE replacing an opaque type!
920 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
921 return true;
922 }
923
924 // Otherwise, this is an attempt to redefine a type. That's okay if
925 // the redefinition is identical to the original. This will be so if
926 // Existing and T point to the same Type object. In this one case we
927 // allow the equivalent redefinition.
928 if (Existing == T) return true; // Yes, it's equal.
929
930 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer61c83e02006-08-18 08:43:06 +0000931 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000932 T->getDescription() + "' type plane!");
933 }
934
935 return false;
936}
937
938//===----------------------------------------------------------------------===//
939// Code for handling upreferences in type names...
940//
941
942// TypeContains - Returns true if Ty directly contains E in it.
943//
944static bool TypeContains(const Type *Ty, const Type *E) {
945 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
946 E) != Ty->subtype_end();
947}
948
949namespace {
950 struct UpRefRecord {
951 // NestingLevel - The number of nesting levels that need to be popped before
952 // this type is resolved.
953 unsigned NestingLevel;
954
955 // LastContainedTy - This is the type at the current binding level for the
956 // type. Every time we reduce the nesting level, this gets updated.
957 const Type *LastContainedTy;
958
959 // UpRefTy - This is the actual opaque type that the upreference is
960 // represented with.
961 OpaqueType *UpRefTy;
962
963 UpRefRecord(unsigned NL, OpaqueType *URTy)
964 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
965 };
966}
967
968// UpRefs - A list of the outstanding upreferences that need to be resolved.
969static std::vector<UpRefRecord> UpRefs;
970
971/// HandleUpRefs - Every time we finish a new layer of types, this function is
972/// called. It loops through the UpRefs vector, which is a list of the
973/// currently active types. For each type, if the up reference is contained in
974/// the newly completed type, we decrement the level count. When the level
975/// count reaches zero, the upreferenced type is the type that is passed in:
976/// thus we can complete the cycle.
977///
978static PATypeHolder HandleUpRefs(const Type *ty) {
979 if (!ty->isAbstract()) return ty;
980 PATypeHolder Ty(ty);
981 UR_OUT("Type '" << Ty->getDescription() <<
982 "' newly formed. Resolving upreferences.\n" <<
983 UpRefs.size() << " upreferences active!\n");
984
985 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
986 // to zero), we resolve them all together before we resolve them to Ty. At
987 // the end of the loop, if there is anything to resolve to Ty, it will be in
988 // this variable.
989 OpaqueType *TypeToResolve = 0;
990
991 for (unsigned i = 0; i != UpRefs.size(); ++i) {
992 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
993 << UpRefs[i].second->getDescription() << ") = "
994 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
995 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
996 // Decrement level of upreference
997 unsigned Level = --UpRefs[i].NestingLevel;
998 UpRefs[i].LastContainedTy = Ty;
999 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1000 if (Level == 0) { // Upreference should be resolved!
1001 if (!TypeToResolve) {
1002 TypeToResolve = UpRefs[i].UpRefTy;
1003 } else {
1004 UR_OUT(" * Resolving upreference for "
1005 << UpRefs[i].second->getDescription() << "\n";
1006 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1007 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1008 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1009 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1010 }
1011 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1012 --i; // Do not skip the next element...
1013 }
1014 }
1015 }
1016
1017 if (TypeToResolve) {
1018 UR_OUT(" * Resolving upreference for "
1019 << UpRefs[i].second->getDescription() << "\n";
1020 std::string OldName = TypeToResolve->getDescription());
1021 TypeToResolve->refineAbstractTypeTo(Ty);
1022 }
1023
1024 return Ty;
1025}
1026
1027
1028// common code from the two 'RunVMAsmParser' functions
1029 static Module * RunParser(Module * M) {
1030
1031 llvmAsmlineno = 1; // Reset the current line number...
1032 ObsoleteVarArgs = false;
1033 NewVarArgs = false;
1034
1035 CurModule.CurrentModule = M;
1036 yyparse(); // Parse the file, potentially throwing exception
Reid Spencer61c83e02006-08-18 08:43:06 +00001037 if (!ParserResult)
1038 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001039
1040 Module *Result = ParserResult;
1041 ParserResult = 0;
1042
1043 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1044 {
1045 Function* F;
1046 if ((F = Result->getNamedFunction("llvm.va_start"))
1047 && F->getFunctionType()->getNumParams() == 0)
1048 ObsoleteVarArgs = true;
1049 if((F = Result->getNamedFunction("llvm.va_copy"))
1050 && F->getFunctionType()->getNumParams() == 1)
1051 ObsoleteVarArgs = true;
1052 }
1053
1054 if (ObsoleteVarArgs && NewVarArgs)
Reid Spencer61c83e02006-08-18 08:43:06 +00001055 GenerateError("This file is corrupt: it uses both new and old style varargs");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001056
1057 if(ObsoleteVarArgs) {
1058 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
1059 if (F->arg_size() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00001060 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001061
1062 //foo = va_start()
1063 // ->
1064 //bar = alloca typeof(foo)
1065 //va_start(bar)
1066 //foo = load bar
1067
1068 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1069 const Type* ArgTy = F->getFunctionType()->getReturnType();
1070 const Type* ArgTyPtr = PointerType::get(ArgTy);
1071 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001072 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001073
1074 while (!F->use_empty()) {
1075 CallInst* CI = cast<CallInst>(F->use_back());
1076 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1077 new CallInst(NF, bar, "", CI);
1078 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1079 CI->replaceAllUsesWith(foo);
1080 CI->getParent()->getInstList().erase(CI);
1081 }
1082 Result->getFunctionList().erase(F);
1083 }
1084
1085 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
1086 if(F->arg_size() != 1)
Reid Spencer61c83e02006-08-18 08:43:06 +00001087 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001088
1089 //vaend foo
1090 // ->
1091 //bar = alloca 1 of typeof(foo)
1092 //vaend bar
1093 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1094 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1095 const Type* ArgTyPtr = PointerType::get(ArgTy);
1096 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001097 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001098
1099 while (!F->use_empty()) {
1100 CallInst* CI = cast<CallInst>(F->use_back());
1101 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1102 new StoreInst(CI->getOperand(1), bar, CI);
1103 new CallInst(NF, bar, "", CI);
1104 CI->getParent()->getInstList().erase(CI);
1105 }
1106 Result->getFunctionList().erase(F);
1107 }
1108
1109 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
1110 if(F->arg_size() != 1)
Reid Spencer61c83e02006-08-18 08:43:06 +00001111 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00001112 //foo = vacopy(bar)
1113 // ->
1114 //a = alloca 1 of typeof(foo)
1115 //b = alloca 1 of typeof(foo)
1116 //store bar -> b
1117 //vacopy(a, b)
1118 //foo = load a
1119
1120 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1121 const Type* ArgTy = F->getFunctionType()->getReturnType();
1122 const Type* ArgTyPtr = PointerType::get(ArgTy);
1123 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001124 RetTy, ArgTyPtr, ArgTyPtr,
1125 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001126
1127 while (!F->use_empty()) {
1128 CallInst* CI = cast<CallInst>(F->use_back());
1129 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1130 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1131 new StoreInst(CI->getOperand(1), b, CI);
1132 new CallInst(NF, a, b, "", CI);
1133 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1134 CI->replaceAllUsesWith(foo);
1135 CI->getParent()->getInstList().erase(CI);
1136 }
1137 Result->getFunctionList().erase(F);
1138 }
1139 }
1140
1141 return Result;
1142
1143 }
1144
1145//===----------------------------------------------------------------------===//
1146// RunVMAsmParser - Define an interface to this parser
1147//===----------------------------------------------------------------------===//
1148//
1149Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1150 set_scan_file(F);
1151
1152 CurFilename = Filename;
1153 return RunParser(new Module(CurFilename));
1154}
1155
1156Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1157 set_scan_string(AsmString);
1158
1159 CurFilename = "from_memory";
1160 if (M == NULL) {
1161 return RunParser(new Module (CurFilename));
1162 } else {
1163 return RunParser(M);
1164 }
1165}
1166
1167
Reid Spencer61c83e02006-08-18 08:43:06 +00001168
1169/* Enabling traces. */
1170#ifndef YYDEBUG
1171# define YYDEBUG 0
1172#endif
1173
1174/* Enabling verbose error messages. */
1175#ifdef YYERROR_VERBOSE
1176# undef YYERROR_VERBOSE
1177# define YYERROR_VERBOSE 1
1178#else
1179# define YYERROR_VERBOSE 0
1180#endif
1181
1182/* Enabling the token table. */
1183#ifndef YYTOKEN_TABLE
1184# define YYTOKEN_TABLE 0
1185#endif
1186
1187#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencere4f47592006-08-18 17:32:55 +00001188#line 907 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00001189typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001190 llvm::Module *ModuleVal;
1191 llvm::Function *FunctionVal;
1192 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1193 llvm::BasicBlock *BasicBlockVal;
1194 llvm::TerminatorInst *TermInstVal;
1195 llvm::Instruction *InstVal;
1196 llvm::Constant *ConstVal;
1197
1198 const llvm::Type *PrimType;
1199 llvm::PATypeHolder *TypeVal;
1200 llvm::Value *ValueVal;
1201
1202 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1203 std::vector<llvm::Value*> *ValueList;
1204 std::list<llvm::PATypeHolder> *TypeList;
1205 // Represent the RHS of PHI node
1206 std::list<std::pair<llvm::Value*,
1207 llvm::BasicBlock*> > *PHIList;
1208 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1209 std::vector<llvm::Constant*> *ConstVector;
1210
1211 llvm::GlobalValue::LinkageTypes Linkage;
1212 int64_t SInt64Val;
1213 uint64_t UInt64Val;
1214 int SIntVal;
1215 unsigned UIntVal;
1216 double FPVal;
1217 bool BoolVal;
1218
1219 char *StrVal; // This memory is strdup'd!
1220 llvm::ValID ValIDVal; // strdup'd memory maybe!
1221
1222 llvm::Instruction::BinaryOps BinaryOpVal;
1223 llvm::Instruction::TermOps TermOpVal;
1224 llvm::Instruction::MemoryOps MemOpVal;
1225 llvm::Instruction::OtherOps OtherOpVal;
1226 llvm::Module::Endianness Endianness;
1227} YYSTYPE;
Reid Spencer61c83e02006-08-18 08:43:06 +00001228/* Line 196 of yacc.c. */
Reid Spencere4f47592006-08-18 17:32:55 +00001229#line 1230 "llvmAsmParser.tab.c"
Reid Spencer61c83e02006-08-18 08:43:06 +00001230# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1231# define YYSTYPE_IS_DECLARED 1
1232# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001233#endif
1234
1235
1236
Reid Spencer61c83e02006-08-18 08:43:06 +00001237/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001238
1239
Reid Spencer61c83e02006-08-18 08:43:06 +00001240/* Line 219 of yacc.c. */
Reid Spencere4f47592006-08-18 17:32:55 +00001241#line 1242 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001242
Reid Spencer61c83e02006-08-18 08:43:06 +00001243#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1244# define YYSIZE_T __SIZE_TYPE__
1245#endif
1246#if ! defined (YYSIZE_T) && defined (size_t)
1247# define YYSIZE_T size_t
1248#endif
1249#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1250# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1251# define YYSIZE_T size_t
1252#endif
1253#if ! defined (YYSIZE_T)
1254# define YYSIZE_T unsigned int
1255#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001256
Reid Spencer61c83e02006-08-18 08:43:06 +00001257#ifndef YY_
1258# if YYENABLE_NLS
1259# if ENABLE_NLS
1260# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1261# define YY_(msgid) dgettext ("bison-runtime", msgid)
1262# endif
1263# endif
1264# ifndef YY_
1265# define YY_(msgid) msgid
1266# endif
1267#endif
1268
1269#if ! defined (yyoverflow) || YYERROR_VERBOSE
1270
1271/* The parser invokes alloca or malloc; define the necessary symbols. */
1272
1273# ifdef YYSTACK_USE_ALLOCA
1274# if YYSTACK_USE_ALLOCA
1275# ifdef __GNUC__
1276# define YYSTACK_ALLOC __builtin_alloca
1277# else
1278# define YYSTACK_ALLOC alloca
1279# if defined (__STDC__) || defined (__cplusplus)
1280# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1281# define YYINCLUDED_STDLIB_H
1282# endif
1283# endif
1284# endif
1285# endif
1286
1287# ifdef YYSTACK_ALLOC
1288 /* Pacify GCC's `empty if-body' warning. */
1289# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1290# ifndef YYSTACK_ALLOC_MAXIMUM
1291 /* The OS might guarantee only one guard page at the bottom of the stack,
1292 and a page size can be as small as 4096 bytes. So we cannot safely
1293 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1294 to allow for a few compiler-allocated temporary stack slots. */
1295# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1296# endif
1297# else
1298# define YYSTACK_ALLOC YYMALLOC
1299# define YYSTACK_FREE YYFREE
1300# ifndef YYSTACK_ALLOC_MAXIMUM
1301# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1302# endif
1303# ifdef __cplusplus
1304extern "C" {
1305# endif
1306# ifndef YYMALLOC
1307# define YYMALLOC malloc
1308# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1309 && (defined (__STDC__) || defined (__cplusplus)))
1310void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1311# endif
1312# endif
1313# ifndef YYFREE
1314# define YYFREE free
1315# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1316 && (defined (__STDC__) || defined (__cplusplus)))
1317void free (void *); /* INFRINGES ON USER NAME SPACE */
1318# endif
1319# endif
1320# ifdef __cplusplus
1321}
1322# endif
1323# endif
1324#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1325
1326
1327#if (! defined (yyoverflow) \
1328 && (! defined (__cplusplus) \
1329 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1330
1331/* A type that is properly aligned for any stack member. */
1332union yyalloc
1333{
1334 short int yyss;
1335 YYSTYPE yyvs;
1336 };
1337
1338/* The size of the maximum gap between one aligned stack and the next. */
1339# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1340
1341/* The size of an array large to enough to hold all stacks, each with
1342 N elements. */
1343# define YYSTACK_BYTES(N) \
1344 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1345 + YYSTACK_GAP_MAXIMUM)
1346
1347/* Copy COUNT objects from FROM to TO. The source and destination do
1348 not overlap. */
1349# ifndef YYCOPY
1350# if defined (__GNUC__) && 1 < __GNUC__
1351# define YYCOPY(To, From, Count) \
1352 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1353# else
1354# define YYCOPY(To, From, Count) \
1355 do \
1356 { \
1357 YYSIZE_T yyi; \
1358 for (yyi = 0; yyi < (Count); yyi++) \
1359 (To)[yyi] = (From)[yyi]; \
1360 } \
1361 while (0)
1362# endif
1363# endif
1364
1365/* Relocate STACK from its old location to the new one. The
1366 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1367 elements in the stack, and YYPTR gives the new location of the
1368 stack. Advance YYPTR to a properly aligned location for the next
1369 stack. */
1370# define YYSTACK_RELOCATE(Stack) \
1371 do \
1372 { \
1373 YYSIZE_T yynewbytes; \
1374 YYCOPY (&yyptr->Stack, Stack, yysize); \
1375 Stack = &yyptr->Stack; \
1376 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1377 yyptr += yynewbytes / sizeof (*yyptr); \
1378 } \
1379 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001380
1381#endif
1382
Reid Spencer61c83e02006-08-18 08:43:06 +00001383#if defined (__STDC__) || defined (__cplusplus)
1384 typedef signed char yysigned_char;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001385#else
Reid Spencer61c83e02006-08-18 08:43:06 +00001386 typedef short int yysigned_char;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001387#endif
1388
Reid Spencer61c83e02006-08-18 08:43:06 +00001389/* YYFINAL -- State number of the termination state. */
1390#define YYFINAL 4
1391/* YYLAST -- Last index in YYTABLE. */
1392#define YYLAST 1278
1393
1394/* YYNTOKENS -- Number of terminals. */
1395#define YYNTOKENS 117
1396/* YYNNTS -- Number of nonterminals. */
1397#define YYNNTS 72
1398/* YYNRULES -- Number of rules. */
1399#define YYNRULES 239
1400/* YYNRULES -- Number of states. */
1401#define YYNSTATES 496
1402
1403/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1404#define YYUNDEFTOK 2
1405#define YYMAXUTOK 357
1406
1407#define YYTRANSLATE(YYX) \
1408 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1409
1410/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1411static const unsigned char yytranslate[] =
1412{
1413 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1417 106, 107, 115, 2, 104, 2, 2, 2, 2, 2,
1418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1419 111, 103, 112, 2, 2, 2, 2, 2, 2, 2,
1420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1422 2, 108, 105, 110, 2, 2, 2, 2, 2, 116,
1423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1425 109, 2, 2, 113, 2, 114, 2, 2, 2, 2,
1426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1436 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1438 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1439 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1440 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1441 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1442 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1443 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1444 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1445 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1446 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1447 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1448 95, 96, 97, 98, 99, 100, 101, 102
1449};
1450
1451#if YYDEBUG
1452/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1453 YYRHS. */
1454static const unsigned short int yyprhs[] =
1455{
1456 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1457 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1458 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1459 59, 61, 63, 65, 67, 70, 71, 73, 75, 77,
1460 79, 80, 81, 83, 85, 87, 89, 92, 93, 96,
1461 97, 101, 104, 105, 107, 108, 112, 114, 117, 119,
1462 121, 123, 125, 127, 129, 131, 133, 135, 137, 139,
1463 141, 143, 145, 147, 149, 151, 153, 155, 157, 159,
1464 162, 167, 173, 179, 183, 186, 189, 191, 195, 197,
1465 201, 203, 204, 209, 213, 217, 222, 227, 231, 234,
1466 237, 240, 243, 246, 249, 252, 255, 258, 261, 268,
1467 274, 283, 290, 297, 304, 311, 318, 327, 336, 340,
1468 342, 344, 346, 348, 351, 354, 359, 362, 364, 369,
1469 372, 377, 378, 386, 387, 395, 399, 404, 405, 407,
1470 409, 411, 415, 419, 423, 427, 431, 433, 434, 436,
1471 438, 440, 441, 444, 448, 450, 452, 456, 458, 459,
1472 468, 470, 472, 476, 478, 480, 483, 484, 488, 489,
1473 491, 493, 495, 497, 499, 501, 503, 505, 507, 511,
1474 513, 519, 521, 523, 525, 527, 530, 533, 536, 540,
1475 543, 544, 546, 549, 552, 556, 566, 576, 585, 599,
1476 601, 603, 610, 616, 619, 626, 634, 636, 640, 642,
1477 643, 646, 648, 654, 660, 666, 669, 674, 679, 686,
1478 691, 696, 701, 706, 713, 720, 723, 731, 733, 736,
1479 737, 739, 740, 744, 751, 755, 762, 765, 770, 777
1480};
1481
1482/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1483static const short int yyrhs[] =
1484{
1485 148, 0, -1, 5, -1, 6, -1, 3, -1, 4,
1486 -1, 72, -1, 73, -1, 74, -1, 75, -1, 76,
1487 -1, 77, -1, 78, -1, 79, -1, 80, -1, 81,
1488 -1, 82, -1, 83, -1, 84, -1, 85, -1, 95,
1489 -1, 96, -1, 16, -1, 14, -1, 12, -1, 10,
1490 -1, 17, -1, 15, -1, 13, -1, 11, -1, 124,
1491 -1, 125, -1, 18, -1, 19, -1, 158, 103, -1,
1492 -1, 41, -1, 42, -1, 43, -1, 44, -1, -1,
1493 -1, 62, -1, 63, -1, 64, -1, 65, -1, 61,
1494 4, -1, -1, 54, 4, -1, -1, 104, 54, 4,
1495 -1, 34, 24, -1, -1, 133, -1, -1, 104, 136,
1496 135, -1, 133, -1, 54, 4, -1, 139, -1, 8,
1497 -1, 141, -1, 8, -1, 141, -1, 9, -1, 10,
1498 -1, 11, -1, 12, -1, 13, -1, 14, -1, 15,
1499 -1, 16, -1, 17, -1, 18, -1, 19, -1, 20,
1500 -1, 21, -1, 45, -1, 140, -1, 172, -1, 105,
1501 4, -1, 138, 106, 143, 107, -1, 108, 4, 109,
1502 141, 110, -1, 111, 4, 109, 141, 112, -1, 113,
1503 142, 114, -1, 113, 114, -1, 141, 115, -1, 141,
1504 -1, 142, 104, 141, -1, 142, -1, 142, 104, 37,
1505 -1, 37, -1, -1, 139, 108, 146, 110, -1, 139,
1506 108, 110, -1, 139, 116, 24, -1, 139, 111, 146,
1507 112, -1, 139, 113, 146, 114, -1, 139, 113, 114,
1508 -1, 139, 38, -1, 139, 39, -1, 139, 172, -1,
1509 139, 145, -1, 139, 26, -1, 124, 119, -1, 125,
1510 4, -1, 9, 27, -1, 9, 28, -1, 127, 7,
1511 -1, 93, 106, 144, 36, 139, 107, -1, 91, 106,
1512 144, 186, 107, -1, 94, 106, 144, 104, 144, 104,
1513 144, 107, -1, 120, 106, 144, 104, 144, 107, -1,
1514 121, 106, 144, 104, 144, 107, -1, 122, 106, 144,
1515 104, 144, 107, -1, 123, 106, 144, 104, 144, 107,
1516 -1, 98, 106, 144, 104, 144, 107, -1, 99, 106,
1517 144, 104, 144, 104, 144, 107, -1, 100, 106, 144,
1518 104, 144, 104, 144, 107, -1, 146, 104, 144, -1,
1519 144, -1, 32, -1, 33, -1, 149, -1, 149, 167,
1520 -1, 149, 168, -1, 149, 59, 58, 153, -1, 149,
1521 25, -1, 150, -1, 150, 128, 20, 137, -1, 150,
1522 168, -1, 150, 59, 58, 153, -1, -1, 150, 128,
1523 129, 147, 144, 151, 135, -1, -1, 150, 128, 47,
1524 147, 139, 152, 135, -1, 150, 48, 155, -1, 150,
1525 55, 103, 156, -1, -1, 24, -1, 53, -1, 52,
1526 -1, 50, 103, 154, -1, 51, 103, 4, -1, 49,
1527 103, 24, -1, 108, 157, 110, -1, 157, 104, 24,
1528 -1, 24, -1, -1, 22, -1, 24, -1, 158, -1,
1529 -1, 139, 159, -1, 161, 104, 160, -1, 160, -1,
1530 161, -1, 161, 104, 37, -1, 37, -1, -1, 130,
1531 137, 158, 106, 162, 107, 134, 131, -1, 29, -1,
1532 113, -1, 129, 163, 164, -1, 30, -1, 114, -1,
1533 175, 166, -1, -1, 31, 169, 163, -1, -1, 60,
1534 -1, 3, -1, 4, -1, 7, -1, 27, -1, 28,
1535 -1, 38, -1, 39, -1, 26, -1, 111, 146, 112,
1536 -1, 145, -1, 58, 170, 24, 104, 24, -1, 118,
1537 -1, 158, -1, 172, -1, 171, -1, 139, 173, -1,
1538 175, 176, -1, 165, 176, -1, 177, 128, 178, -1,
1539 177, 180, -1, -1, 23, -1, 66, 174, -1, 66,
1540 8, -1, 67, 21, 173, -1, 67, 9, 173, 104,
1541 21, 173, 104, 21, 173, -1, 68, 126, 173, 104,
1542 21, 173, 108, 179, 110, -1, 68, 126, 173, 104,
1543 21, 173, 108, 110, -1, 69, 130, 137, 173, 106,
1544 183, 107, 36, 21, 173, 70, 21, 173, -1, 70,
1545 -1, 71, -1, 179, 126, 171, 104, 21, 173, -1,
1546 126, 171, 104, 21, 173, -1, 128, 185, -1, 139,
1547 108, 173, 104, 173, 110, -1, 181, 104, 108, 173,
1548 104, 173, 110, -1, 174, -1, 182, 104, 174, -1,
1549 182, -1, -1, 57, 56, -1, 56, -1, 120, 139,
1550 173, 104, 173, -1, 121, 139, 173, 104, 173, -1,
1551 122, 139, 173, 104, 173, -1, 46, 174, -1, 123,
1552 174, 104, 174, -1, 93, 174, 36, 139, -1, 94,
1553 174, 104, 174, 104, 174, -1, 97, 174, 104, 139,
1554 -1, 101, 174, 104, 139, -1, 102, 174, 104, 139,
1555 -1, 98, 174, 104, 174, -1, 99, 174, 104, 174,
1556 104, 174, -1, 100, 174, 104, 174, 104, 174, -1,
1557 92, 181, -1, 184, 130, 137, 173, 106, 183, 107,
1558 -1, 188, -1, 104, 182, -1, -1, 35, -1, -1,
1559 86, 139, 132, -1, 86, 139, 104, 15, 173, 132,
1560 -1, 87, 139, 132, -1, 87, 139, 104, 15, 173,
1561 132, -1, 88, 174, -1, 187, 89, 139, 173, -1,
1562 187, 90, 174, 104, 139, 173, -1, 91, 139, 173,
1563 186, -1
1564};
1565
1566/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1567static const unsigned short int yyrline[] =
1568{
Reid Spencere4f47592006-08-18 17:32:55 +00001569 0, 1027, 1027, 1028, 1036, 1037, 1047, 1047, 1047, 1047,
1570 1047, 1048, 1048, 1048, 1049, 1049, 1049, 1049, 1049, 1049,
1571 1051, 1051, 1055, 1055, 1055, 1055, 1056, 1056, 1056, 1056,
1572 1057, 1057, 1058, 1058, 1061, 1065, 1070, 1071, 1072, 1073,
1573 1074, 1076, 1077, 1078, 1079, 1080, 1081, 1090, 1091, 1097,
1574 1098, 1106, 1114, 1115, 1120, 1121, 1122, 1127, 1141, 1141,
1575 1142, 1142, 1144, 1154, 1154, 1154, 1154, 1154, 1154, 1154,
1576 1155, 1155, 1155, 1155, 1155, 1155, 1156, 1160, 1164, 1171,
1577 1179, 1192, 1197, 1209, 1219, 1223, 1232, 1237, 1243, 1244,
1578 1248, 1252, 1263, 1289, 1303, 1333, 1359, 1380, 1393, 1403,
1579 1408, 1468, 1475, 1484, 1490, 1496, 1500, 1504, 1512, 1523,
1580 1555, 1563, 1585, 1596, 1602, 1610, 1616, 1622, 1631, 1635,
1581 1643, 1643, 1653, 1661, 1666, 1670, 1674, 1678, 1693, 1714,
1582 1717, 1720, 1720, 1727, 1727, 1735, 1738, 1741, 1745, 1758,
1583 1759, 1761, 1765, 1774, 1780, 1782, 1787, 1792, 1801, 1801,
1584 1802, 1802, 1804, 1811, 1817, 1824, 1828, 1834, 1839, 1844,
1585 1931, 1931, 1933, 1941, 1941, 1943, 1948, 1948, 1958, 1962,
1586 1967, 1971, 1975, 1979, 1983, 1987, 1991, 1995, 1999, 2024,
1587 2028, 2042, 2046, 2052, 2052, 2058, 2063, 2067, 2076, 2086,
1588 2091, 2102, 2114, 2118, 2122, 2126, 2130, 2145, 2150, 2204,
1589 2208, 2215, 2224, 2235, 2243, 2249, 2257, 2262, 2269, 2269,
1590 2271, 2275, 2282, 2295, 2307, 2318, 2331, 2339, 2347, 2355,
1591 2361, 2381, 2404, 2410, 2416, 2422, 2437, 2495, 2502, 2505,
1592 2510, 2514, 2521, 2526, 2531, 2536, 2541, 2549, 2560, 2574
Reid Spencer61c83e02006-08-18 08:43:06 +00001593};
1594#endif
1595
1596#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1597/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1598 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1599static const char *const yytname[] =
1600{
1601 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1602 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1603 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1604 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1605 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1606 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1607 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
1608 "WEAK", "APPENDING", "OPAQUE", "NOT", "EXTERNAL", "TARGET", "TRIPLE",
1609 "ENDIAN", "POINTERSIZE", "LITTLE", "BIG", "ALIGN", "DEPLIBS", "CALL",
1610 "TAIL", "ASM_TOK", "MODULE", "SIDEEFFECT", "CC_TOK", "CCC_TOK",
1611 "CSRETCC_TOK", "FASTCC_TOK", "COLDCC_TOK", "RET", "BR", "SWITCH",
1612 "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "DIV", "REM",
1613 "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE",
1614 "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK",
1615 "CAST", "SELECT", "SHL", "SHR", "VAARG", "EXTRACTELEMENT",
1616 "INSERTELEMENT", "SHUFFLEVECTOR", "VAARG_old", "VANEXT_old", "'='",
1617 "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'",
1618 "'}'", "'*'", "'c'", "$accept", "INTVAL", "EINT64VAL", "ArithmeticOps",
1619 "LogicalOps", "SetCondOps", "ShiftOps", "SIntType", "UIntType",
1620 "IntType", "FPType", "OptAssign", "OptLinkage", "OptCallingConv",
1621 "OptAlign", "OptCAlign", "SectionString", "OptSection",
1622 "GlobalVarAttributes", "GlobalVarAttribute", "TypesV", "UpRTypesV",
1623 "Types", "PrimType", "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal",
1624 "ConstExpr", "ConstVector", "GlobalType", "Module", "FunctionList",
1625 "ConstPool", "@1", "@2", "AsmBlock", "BigOrLittle", "TargetDefinition",
1626 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
1627 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
1628 "END", "Function", "FunctionProto", "@3", "OptSideEffect",
1629 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1630 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1631 "JumpTable", "Inst", "PHIList", "ValueRefList", "ValueRefListE",
1632 "OptTailCall", "InstVal", "IndexList", "OptVolatile", "MemoryInst", 0
1633};
1634#endif
1635
1636# ifdef YYPRINT
1637/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1638 token YYLEX-NUM. */
1639static const unsigned short int yytoknum[] =
1640{
1641 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1642 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1643 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1644 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1645 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1646 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1647 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1648 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1649 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1650 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1651 355, 356, 357, 61, 44, 92, 40, 41, 91, 120,
1652 93, 60, 62, 123, 125, 42, 99
1653};
1654# endif
1655
1656/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1657static const unsigned char yyr1[] =
1658{
1659 0, 117, 118, 118, 119, 119, 120, 120, 120, 120,
1660 120, 121, 121, 121, 122, 122, 122, 122, 122, 122,
1661 123, 123, 124, 124, 124, 124, 125, 125, 125, 125,
1662 126, 126, 127, 127, 128, 128, 129, 129, 129, 129,
1663 129, 130, 130, 130, 130, 130, 130, 131, 131, 132,
1664 132, 133, 134, 134, 135, 135, 136, 136, 137, 137,
1665 138, 138, 139, 140, 140, 140, 140, 140, 140, 140,
1666 140, 140, 140, 140, 140, 140, 141, 141, 141, 141,
1667 141, 141, 141, 141, 141, 141, 142, 142, 143, 143,
1668 143, 143, 144, 144, 144, 144, 144, 144, 144, 144,
1669 144, 144, 144, 144, 144, 144, 144, 144, 145, 145,
1670 145, 145, 145, 145, 145, 145, 145, 145, 146, 146,
1671 147, 147, 148, 149, 149, 149, 149, 149, 150, 150,
1672 150, 151, 150, 152, 150, 150, 150, 150, 153, 154,
1673 154, 155, 155, 155, 156, 157, 157, 157, 158, 158,
1674 159, 159, 160, 161, 161, 162, 162, 162, 162, 163,
1675 164, 164, 165, 166, 166, 167, 169, 168, 170, 170,
1676 171, 171, 171, 171, 171, 171, 171, 171, 171, 171,
1677 171, 172, 172, 173, 173, 174, 175, 175, 176, 177,
1678 177, 177, 178, 178, 178, 178, 178, 178, 178, 178,
1679 178, 179, 179, 180, 181, 181, 182, 182, 183, 183,
1680 184, 184, 185, 185, 185, 185, 185, 185, 185, 185,
1681 185, 185, 185, 185, 185, 185, 185, 185, 186, 186,
1682 187, 187, 188, 188, 188, 188, 188, 188, 188, 188
1683};
1684
1685/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1686static const unsigned char yyr2[] =
1687{
1688 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1689 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1690 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1691 1, 1, 1, 1, 2, 0, 1, 1, 1, 1,
1692 0, 0, 1, 1, 1, 1, 2, 0, 2, 0,
1693 3, 2, 0, 1, 0, 3, 1, 2, 1, 1,
1694 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1695 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
1696 4, 5, 5, 3, 2, 2, 1, 3, 1, 3,
1697 1, 0, 4, 3, 3, 4, 4, 3, 2, 2,
1698 2, 2, 2, 2, 2, 2, 2, 2, 6, 5,
1699 8, 6, 6, 6, 6, 6, 8, 8, 3, 1,
1700 1, 1, 1, 2, 2, 4, 2, 1, 4, 2,
1701 4, 0, 7, 0, 7, 3, 4, 0, 1, 1,
1702 1, 3, 3, 3, 3, 3, 1, 0, 1, 1,
1703 1, 0, 2, 3, 1, 1, 3, 1, 0, 8,
1704 1, 1, 3, 1, 1, 2, 0, 3, 0, 1,
1705 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
1706 5, 1, 1, 1, 1, 2, 2, 2, 3, 2,
1707 0, 1, 2, 2, 3, 9, 9, 8, 13, 1,
1708 1, 6, 5, 2, 6, 7, 1, 3, 1, 0,
1709 2, 1, 5, 5, 5, 2, 4, 4, 6, 4,
1710 4, 4, 4, 6, 6, 2, 7, 1, 2, 0,
1711 1, 0, 3, 6, 3, 6, 2, 4, 6, 4
1712};
1713
1714/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1715 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1716 means the default is an error. */
1717static const unsigned char yydefact[] =
1718{
1719 137, 0, 40, 127, 1, 126, 166, 36, 37, 38,
1720 39, 0, 41, 190, 123, 124, 190, 148, 149, 0,
1721 0, 0, 40, 0, 129, 41, 0, 0, 42, 43,
1722 44, 45, 0, 0, 191, 187, 35, 163, 164, 165,
1723 186, 0, 0, 0, 135, 0, 0, 0, 0, 0,
1724 34, 167, 138, 125, 46, 2, 3, 59, 63, 64,
1725 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1726 75, 76, 0, 0, 0, 0, 181, 0, 0, 58,
1727 77, 62, 182, 78, 160, 161, 162, 231, 189, 0,
1728 0, 0, 147, 136, 130, 128, 120, 121, 0, 0,
1729 79, 0, 0, 61, 84, 86, 0, 0, 91, 85,
1730 230, 0, 211, 0, 0, 0, 0, 41, 199, 200,
1731 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1732 16, 17, 18, 19, 0, 0, 0, 0, 0, 0,
1733 0, 20, 21, 0, 0, 0, 0, 0, 0, 0,
1734 0, 0, 0, 188, 41, 203, 0, 227, 143, 140,
1735 139, 141, 142, 146, 0, 133, 63, 64, 65, 66,
1736 67, 68, 69, 70, 71, 72, 73, 0, 0, 0,
1737 0, 131, 0, 0, 0, 83, 158, 90, 88, 0,
1738 0, 215, 210, 193, 192, 0, 0, 25, 29, 24,
1739 28, 23, 27, 22, 26, 30, 31, 0, 0, 49,
1740 49, 236, 0, 0, 225, 0, 0, 0, 0, 0,
1741 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1742 0, 144, 54, 105, 106, 4, 5, 103, 104, 107,
1743 102, 98, 99, 0, 0, 0, 0, 0, 0, 0,
1744 0, 0, 0, 0, 0, 0, 0, 101, 100, 54,
1745 60, 60, 87, 157, 151, 154, 155, 0, 0, 80,
1746 170, 171, 172, 177, 173, 174, 175, 176, 168, 0,
1747 179, 184, 183, 185, 0, 194, 0, 0, 0, 232,
1748 0, 234, 229, 0, 0, 0, 0, 0, 0, 0,
1749 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1750 145, 0, 134, 0, 0, 0, 0, 0, 0, 93,
1751 119, 0, 0, 97, 0, 94, 0, 0, 0, 0,
1752 132, 81, 82, 150, 152, 0, 52, 89, 169, 0,
1753 0, 0, 0, 0, 0, 0, 0, 0, 239, 0,
1754 0, 217, 0, 219, 222, 0, 0, 220, 221, 0,
1755 0, 0, 216, 0, 237, 0, 0, 0, 56, 54,
1756 229, 0, 0, 0, 0, 0, 0, 92, 95, 96,
1757 0, 0, 0, 0, 156, 153, 53, 47, 0, 178,
1758 0, 0, 209, 49, 50, 49, 206, 228, 0, 0,
1759 0, 0, 0, 212, 213, 214, 209, 0, 51, 57,
1760 55, 0, 0, 0, 0, 0, 0, 118, 0, 0,
1761 0, 0, 0, 159, 0, 0, 0, 208, 0, 0,
1762 233, 235, 0, 0, 0, 218, 223, 224, 0, 238,
1763 109, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1764 48, 180, 0, 0, 0, 207, 204, 0, 226, 108,
1765 0, 115, 0, 0, 111, 112, 113, 114, 0, 197,
1766 0, 0, 0, 205, 0, 0, 0, 195, 0, 196,
1767 0, 0, 110, 116, 117, 0, 0, 0, 0, 0,
1768 0, 202, 0, 0, 201, 198
1769};
1770
1771/* YYDEFGOTO[NTERM-NUM]. */
1772static const short int yydefgoto[] =
1773{
1774 -1, 76, 237, 253, 254, 255, 256, 177, 178, 207,
1775 179, 22, 12, 32, 423, 289, 368, 387, 312, 369,
1776 77, 78, 180, 80, 81, 106, 189, 320, 280, 321,
1777 98, 1, 2, 3, 259, 232, 53, 161, 44, 93,
1778 164, 82, 334, 265, 266, 267, 33, 86, 13, 39,
1779 14, 15, 25, 339, 281, 83, 283, 396, 16, 35,
1780 36, 153, 471, 88, 214, 427, 428, 154, 155, 348,
1781 156, 157
1782};
1783
1784/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1785 STATE-NUM. */
1786#define YYPACT_NINF -442
1787static const short int yypact[] =
1788{
1789 -442, 25, 181, 372, -442, -442, -442, -442, -442, -442,
1790 -442, -16, 33, 42, -442, -442, -14, -442, -442, 12,
1791 -57, 18, 44, -25, -442, 33, 75, 106, -442, -442,
1792 -442, -442, 1012, -21, -442, -442, 4, -442, -442, -442,
1793 -442, 29, 32, 49, -442, 47, 75, 1012, 97, 97,
1794 -442, -442, -442, -442, -442, -442, -442, 63, -442, -442,
1795 -442, -442, -442, -442, -442, -442, -442, -442, -442, -442,
1796 -442, -442, 170, 171, 173, 524, -442, 4, 72, -442,
1797 -442, -84, -442, -442, -442, -442, -442, 1176, -442, 156,
1798 94, 175, 158, -442, -442, -442, -442, -442, 1050, 1088,
1799 -442, 74, 76, -442, -442, -84, -37, 78, 819, -442,
1800 -442, 1050, -442, 131, 1126, 14, 128, 33, -442, -442,
1801 -442, -442, -442, -442, -442, -442, -442, -442, -442, -442,
1802 -442, -442, -442, -442, 1050, 1050, 1050, 1050, 1050, 1050,
1803 1050, -442, -442, 1050, 1050, 1050, 1050, 1050, 1050, 1050,
1804 1050, 1050, 1050, -442, 33, -442, 60, -442, -442, -442,
1805 -442, -442, -442, -442, 23, -442, 129, 155, 190, 157,
1806 194, 159, 196, 167, 197, 195, 198, 169, 199, 200,
1807 406, -442, 1050, 1050, 1050, -442, 857, -442, 100, 101,
1808 617, -442, -442, 63, -442, 617, 617, -442, -442, -442,
1809 -442, -442, -442, -442, -442, -442, -442, 617, 1012, 105,
1810 107, -442, 617, 118, 109, 178, 111, 123, 132, 133,
1811 134, 135, 137, 617, 617, 617, 138, 1012, 1050, 1050,
1812 209, -442, 139, -442, -442, -442, -442, -442, -442, -442,
1813 -442, -442, -442, 140, 141, 144, 145, 146, 147, 895,
1814 1088, 566, 211, 148, 149, 150, 151, -442, -442, 139,
1815 -66, -88, -84, -442, 4, -442, 154, 152, 936, -442,
1816 -442, -442, -442, -442, -442, -442, -442, -442, 184, 1088,
1817 -442, -442, -442, -442, 168, -442, 172, 617, 5, -442,
1818 6, -442, 174, 617, 153, 1050, 1050, 1050, 1050, 1050,
1819 1050, 1050, 1050, 176, 177, 179, 1050, 617, 617, 180,
1820 -442, -20, -442, 1088, 1088, 1088, 1088, 1088, 1088, -442,
1821 -442, 24, -23, -442, -24, -442, 1088, 1088, 1088, 1088,
1822 -442, -442, -442, -442, -442, 974, 226, -442, -442, 221,
1823 -3, 241, 252, 182, 617, 271, 617, 1050, -442, 185,
1824 617, -442, 186, -442, -442, 188, 192, -442, -442, 617,
1825 617, 617, -442, 191, -442, 1050, 253, 278, -442, 139,
1826 174, 250, 201, 202, 203, 204, 1088, -442, -442, -442,
1827 205, 206, 207, 208, -442, -442, -442, 244, 210, -442,
1828 617, 617, 1050, 216, -442, 216, -442, 222, 617, 223,
1829 1050, 1050, 1050, -442, -442, -442, 1050, 617, -442, -442,
1830 -442, 227, 1050, 1088, 1088, 1088, 1088, -442, 1088, 1088,
1831 1088, 1088, 295, -442, 280, 224, 228, 222, 230, 259,
1832 -442, -442, 1050, 219, 617, -442, -442, -442, 234, -442,
1833 -442, 235, 231, 236, 240, 242, 238, 243, 245, 246,
1834 -442, -442, 309, 41, 311, -442, -442, 239, -442, -442,
1835 1088, -442, 1088, 1088, -442, -442, -442, -442, 617, -442,
1836 715, 58, 330, -442, 247, 248, 257, -442, 255, -442,
1837 715, 617, -442, -442, -442, 336, 263, 301, 617, 351,
1838 355, -442, 617, 617, -442, -442
1839};
1840
1841/* YYPGOTO[NTERM-NUM]. */
1842static const short int yypgoto[] =
1843{
1844 -442, -442, -442, 290, 292, 294, 296, -115, -113, -441,
1845 -442, 346, 362, -106, -442, -205, 50, -442, -246, -442,
1846 -41, -442, -32, -442, -58, 277, -442, -97, 213, -232,
1847 338, -442, -442, -442, -442, -442, 342, -442, -442, -442,
1848 -442, 7, -442, 62, -442, -442, 370, -442, -442, -442,
1849 -442, 395, -442, -442, -387, -59, 166, -107, -442, 383,
1850 -442, -442, -442, -442, -442, 54, -4, -442, -442, 36,
1851 -442, -442
1852};
1853
1854/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1855 positive, shift that token. If negative, reduce the rule which
1856 number is the opposite. If zero, do what YYDEFACT says.
1857 If YYTABLE_NINF, syntax error. */
1858#define YYTABLE_NINF -123
1859static const short int yytable[] =
1860{
1861 79, 205, 181, 206, 191, 291, 95, 194, 84, 34,
1862 23, 208, 470, 330, 366, 79, 37, 105, 322, 324,
1863 344, 346, -60, 195, 332, 4, 17, 109, 18, 211,
1864 480, 109, 215, 216, 367, 196, 217, 218, 219, 220,
1865 221, 222, 26, 23, 331, 226, 45, 340, 227, 109,
1866 105, 197, 198, 199, 200, 201, 202, 203, 204, 345,
1867 345, 41, 42, 43, 47, 34, 165, 184, 197, 198,
1868 199, 200, 201, 202, 203, 204, 46, 185, 50, 190,
1869 376, 376, 190, 478, 107, 7, 8, 9, 10, 378,
1870 379, 48, 85, 486, 27, 28, 29, 30, 31, 52,
1871 38, 376, 209, 210, 190, 212, 213, 190, 190, 389,
1872 54, 190, 190, 190, 190, 190, 190, 223, 224, 225,
1873 190, 258, 309, 410, 260, 261, 262, 230, 376, 96,
1874 97, 282, 89, 231, 377, 90, 282, 282, 197, 198,
1875 199, 200, 201, 202, 203, 204, 159, 160, 282, 228,
1876 229, 469, 91, 282, 264, 92, 233, 234, -25, -25,
1877 -24, -24, -23, -23, 282, 282, 282, 287, 479, -61,
1878 -22, -22, 235, 236, 100, 101, 79, 102, 108, 162,
1879 158, -122, 163, 182, 186, 183, 307, 192, 430, 352,
1880 431, 354, 355, 356, -29, 79, 308, 190, -28, 362,
1881 -27, -26, -32, 238, 268, -33, 5, 239, 269, 288,
1882 262, 290, 6, 294, 295, 296, 370, 371, 372, 373,
1883 374, 375, 7, 8, 9, 10, 293, 297, 282, 380,
1884 381, 382, 383, 310, 282, 325, 298, 299, 300, 301,
1885 11, 302, 306, 311, 338, 388, 313, 314, 282, 282,
1886 315, 316, 317, 318, 326, 327, 328, 329, 335, 336,
1887 366, 350, 390, 351, 190, 353, 190, 190, 190, 357,
1888 358, 333, 341, 391, 190, 394, 342, 408, 347, 417,
1889 359, 360, 409, 361, 365, 282, 412, 282, 392, 398,
1890 400, 282, 401, 435, 436, 437, 402, 406, 422, 450,
1891 282, 282, 282, 264, 451, 413, 414, 415, 416, 418,
1892 419, 420, 421, 345, 424, 190, 442, 443, 444, 445,
1893 429, 446, 447, 448, 449, 455, 432, 434, 452, 456,
1894 468, 282, 282, 407, 440, 460, 453, 454, 205, 282,
1895 206, 458, 459, 461, 462, 464, 463, 472, 282, 473,
1896 465, 481, 466, 467, 482, 483, 205, 488, 206, 485,
1897 190, 284, 285, 474, 484, 475, 476, 489, 190, 190,
1898 190, 490, 492, 286, 190, 282, 493, 149, 292, 150,
1899 441, 151, 87, 152, 49, 188, 386, 99, 94, 303,
1900 304, 305, -35, 257, 17, 51, 18, 385, 24, 40,
1901 190, 397, 438, 6, -35, -35, 411, 0, 0, 282,
1902 0, 55, 56, -35, -35, -35, -35, 0, 0, -35,
1903 19, 0, 282, 0, 0, 0, 0, 20, 17, 282,
1904 18, 21, 240, 282, 282, 0, 0, 0, 0, 0,
1905 0, 0, 0, 0, 241, 242, 0, 0, 0, 0,
1906 0, 0, 0, 343, 0, 0, 0, 0, 0, 349,
1907 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1908 0, 0, 0, 363, 364, 0, 0, 0, 120, 121,
1909 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
1910 132, 133, 0, 0, 0, 0, 0, 243, 0, 244,
1911 245, 141, 142, 0, 246, 247, 248, 0, 0, 0,
1912 393, 0, 395, 0, 249, 0, 399, 250, 0, 251,
1913 0, 0, 252, 0, 0, 403, 404, 405, 0, 55,
1914 56, 0, 103, 58, 59, 60, 61, 62, 63, 64,
1915 65, 66, 67, 68, 69, 70, 17, 0, 18, 0,
1916 0, 0, 0, 0, 0, 0, 425, 426, 0, 0,
1917 0, 0, 0, 0, 433, 0, 0, 0, 0, 71,
1918 0, 55, 56, 439, 103, 166, 167, 168, 169, 170,
1919 171, 172, 173, 174, 175, 176, 69, 70, 17, 0,
1920 18, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1921 457, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1922 0, 71, 0, 0, 0, 0, 0, 0, 0, 0,
1923 270, 271, 55, 56, 272, 0, 0, 0, 0, 72,
1924 0, 0, 73, 0, 477, 74, 0, 75, 104, 17,
1925 0, 18, 0, 273, 274, 275, 0, 487, 0, 0,
1926 0, 0, 0, 0, 491, 276, 277, 0, 494, 495,
1927 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1928 0, 72, 0, 0, 73, 278, 0, 74, 0, 75,
1929 323, 0, 0, 0, 0, 0, 0, 0, 0, 120,
1930 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
1931 131, 132, 133, 0, 0, 0, 0, 0, 243, 0,
1932 244, 245, 141, 142, 0, 246, 247, 248, 270, 271,
1933 0, 0, 272, 0, 0, 0, 0, 0, 279, 0,
1934 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1935 0, 273, 274, 275, 0, 0, 0, 0, 0, 0,
1936 0, 0, 0, 276, 277, 0, 0, 0, 0, 0,
1937 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1938 0, 0, 0, 278, 0, 0, 0, 0, 0, 0,
1939 0, 0, 0, 0, 0, 0, 0, 120, 121, 122,
1940 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,
1941 133, 0, 0, 0, 0, 0, 243, 0, 244, 245,
1942 141, 142, 0, 246, 247, 248, 0, 0, 0, 0,
1943 0, 0, 0, 0, 55, 56, 279, 103, 58, 59,
1944 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
1945 70, 17, 0, 18, 0, 0, 0, 0, 0, 0,
1946 0, 0, 0, 0, 0, 0, 187, 0, 0, 0,
1947 0, 0, 55, 56, 71, 103, 58, 59, 60, 61,
1948 62, 63, 64, 65, 66, 67, 68, 69, 70, 17,
1949 0, 18, 0, 0, 0, 0, 0, 0, 0, 0,
1950 0, 0, 0, 0, 263, 0, 0, 0, 0, 0,
1951 55, 56, 71, 103, 166, 167, 168, 169, 170, 171,
1952 172, 173, 174, 175, 176, 69, 70, 17, 0, 18,
1953 0, 0, 0, 0, 72, 0, 0, 73, 0, 0,
1954 74, 0, 75, 0, 0, 0, 0, 0, 0, 0,
1955 71, 55, 56, 0, 103, 58, 59, 60, 61, 62,
1956 63, 64, 65, 66, 67, 68, 69, 70, 17, 0,
1957 18, 0, 72, 0, 0, 73, 0, 0, 74, 0,
1958 75, 0, 0, 337, 0, 0, 0, 0, 0, 55,
1959 56, 71, 103, 58, 59, 60, 61, 62, 63, 64,
1960 65, 66, 67, 68, 69, 70, 17, 0, 18, 0,
1961 72, 0, 0, 73, 0, 319, 74, 0, 75, 0,
1962 0, 384, 0, 0, 0, 0, 0, 55, 56, 71,
1963 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1964 67, 68, 69, 70, 17, 0, 18, 0, 0, 0,
1965 0, 72, 0, 0, 73, 0, 0, 74, 0, 75,
1966 0, 0, 0, 0, 0, 55, 56, 71, 103, 58,
1967 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
1968 69, 70, 17, 0, 18, 0, 0, 0, 0, 72,
1969 0, 0, 73, 0, 0, 74, 0, 75, 0, 0,
1970 0, 0, 0, 55, 56, 71, 103, 166, 167, 168,
1971 169, 170, 171, 172, 173, 174, 175, 176, 69, 70,
1972 17, 0, 18, 0, 0, 0, 0, 72, 0, 0,
1973 73, 0, 0, 74, 0, 75, 0, 0, 0, 0,
1974 0, 55, 56, 71, 193, 58, 59, 60, 61, 62,
1975 63, 64, 65, 66, 67, 68, 69, 70, 17, 0,
1976 18, 0, 0, 0, 0, 72, 0, 0, 73, 0,
1977 0, 74, 0, 75, 0, 0, 0, 0, 0, 0,
1978 0, 71, 0, 0, 0, 0, 0, 0, 0, 0,
1979 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1980 0, 0, 0, 72, 0, 0, 73, 0, 0, 74,
1981 0, 75, 0, 0, 0, 0, 0, 0, 0, 0,
1982 0, 110, 0, 0, 0, 0, 0, 0, 0, 0,
1983 0, 0, 111, 0, 0, 0, 0, 0, 0, 0,
1984 0, 72, 112, 113, 73, 0, 0, 74, 0, 75,
1985 0, 0, 114, 115, 116, 117, 118, 119, 120, 121,
1986 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
1987 132, 133, 134, 135, 136, 0, 0, 137, 138, 139,
1988 140, 141, 142, 143, 144, 145, 146, 147, 148
1989};
1990
1991static const short int yycheck[] =
1992{
1993 32, 116, 99, 116, 111, 210, 47, 114, 29, 23,
1994 3, 117, 453, 259, 34, 47, 30, 75, 250, 251,
1995 15, 15, 106, 9, 112, 0, 22, 115, 24, 136,
1996 471, 115, 139, 140, 54, 21, 143, 144, 145, 146,
1997 147, 148, 58, 36, 110, 152, 103, 279, 154, 115,
1998 108, 10, 11, 12, 13, 14, 15, 16, 17, 54,
1999 54, 49, 50, 51, 20, 23, 98, 104, 10, 11,
2000 12, 13, 14, 15, 16, 17, 58, 114, 103, 111,
2001 104, 104, 114, 470, 77, 41, 42, 43, 44, 112,
2002 114, 47, 113, 480, 61, 62, 63, 64, 65, 24,
2003 114, 104, 134, 135, 136, 137, 138, 139, 140, 112,
2004 4, 143, 144, 145, 146, 147, 148, 149, 150, 151,
2005 152, 180, 229, 369, 182, 183, 184, 104, 104, 32,
2006 33, 190, 103, 110, 110, 103, 195, 196, 10, 11,
2007 12, 13, 14, 15, 16, 17, 52, 53, 207, 89,
2008 90, 110, 103, 212, 186, 108, 27, 28, 3, 4,
2009 3, 4, 3, 4, 223, 224, 225, 208, 110, 106,
2010 3, 4, 3, 4, 4, 4, 208, 4, 106, 4,
2011 24, 0, 24, 109, 106, 109, 227, 56, 393, 296,
2012 395, 298, 299, 300, 4, 227, 228, 229, 4, 306,
2013 4, 4, 7, 4, 104, 7, 25, 7, 107, 104,
2014 268, 104, 31, 104, 36, 104, 313, 314, 315, 316,
2015 317, 318, 41, 42, 43, 44, 108, 104, 287, 326,
2016 327, 328, 329, 24, 293, 24, 104, 104, 104, 104,
2017 59, 104, 104, 104, 60, 24, 106, 106, 307, 308,
2018 106, 106, 106, 106, 106, 106, 106, 106, 104, 107,
2019 34, 108, 21, 295, 296, 297, 298, 299, 300, 301,
2020 302, 264, 104, 21, 306, 4, 104, 24, 104, 376,
2021 104, 104, 4, 104, 104, 344, 36, 346, 106, 104,
2022 104, 350, 104, 400, 401, 402, 104, 106, 54, 4,
2023 359, 360, 361, 335, 24, 104, 104, 104, 104, 104,
2024 104, 104, 104, 54, 104, 347, 413, 414, 415, 416,
2025 104, 418, 419, 420, 421, 432, 104, 104, 104, 110,
2026 21, 390, 391, 365, 107, 104, 108, 107, 453, 398,
2027 453, 107, 107, 107, 104, 107, 104, 36, 407, 110,
2028 107, 21, 107, 107, 107, 107, 471, 21, 471, 104,
2029 392, 195, 196, 460, 107, 462, 463, 104, 400, 401,
2030 402, 70, 21, 207, 406, 434, 21, 87, 212, 87,
2031 412, 87, 36, 87, 22, 108, 336, 49, 46, 223,
2032 224, 225, 20, 180, 22, 25, 24, 335, 3, 16,
2033 432, 347, 406, 31, 32, 33, 370, -1, -1, 468,
2034 -1, 5, 6, 41, 42, 43, 44, -1, -1, 47,
2035 48, -1, 481, -1, -1, -1, -1, 55, 22, 488,
2036 24, 59, 26, 492, 493, -1, -1, -1, -1, -1,
2037 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
2038 -1, -1, -1, 287, -1, -1, -1, -1, -1, 293,
2039 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2040 -1, -1, -1, 307, 308, -1, -1, -1, 72, 73,
2041 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2042 84, 85, -1, -1, -1, -1, -1, 91, -1, 93,
2043 94, 95, 96, -1, 98, 99, 100, -1, -1, -1,
2044 344, -1, 346, -1, 108, -1, 350, 111, -1, 113,
2045 -1, -1, 116, -1, -1, 359, 360, 361, -1, 5,
2046 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
2047 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2048 -1, -1, -1, -1, -1, -1, 390, 391, -1, -1,
2049 -1, -1, -1, -1, 398, -1, -1, -1, -1, 45,
2050 -1, 5, 6, 407, 8, 9, 10, 11, 12, 13,
2051 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2052 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2053 434, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2054 -1, 45, -1, -1, -1, -1, -1, -1, -1, -1,
2055 3, 4, 5, 6, 7, -1, -1, -1, -1, 105,
2056 -1, -1, 108, -1, 468, 111, -1, 113, 114, 22,
2057 -1, 24, -1, 26, 27, 28, -1, 481, -1, -1,
2058 -1, -1, -1, -1, 488, 38, 39, -1, 492, 493,
2059 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2060 -1, 105, -1, -1, 108, 58, -1, 111, -1, 113,
2061 114, -1, -1, -1, -1, -1, -1, -1, -1, 72,
2062 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
2063 83, 84, 85, -1, -1, -1, -1, -1, 91, -1,
2064 93, 94, 95, 96, -1, 98, 99, 100, 3, 4,
2065 -1, -1, 7, -1, -1, -1, -1, -1, 111, -1,
2066 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2067 -1, 26, 27, 28, -1, -1, -1, -1, -1, -1,
2068 -1, -1, -1, 38, 39, -1, -1, -1, -1, -1,
2069 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2070 -1, -1, -1, 58, -1, -1, -1, -1, -1, -1,
2071 -1, -1, -1, -1, -1, -1, -1, 72, 73, 74,
2072 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2073 85, -1, -1, -1, -1, -1, 91, -1, 93, 94,
2074 95, 96, -1, 98, 99, 100, -1, -1, -1, -1,
2075 -1, -1, -1, -1, 5, 6, 111, 8, 9, 10,
2076 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2077 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2078 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2079 -1, -1, 5, 6, 45, 8, 9, 10, 11, 12,
2080 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
2081 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2082 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
2083 5, 6, 45, 8, 9, 10, 11, 12, 13, 14,
2084 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
2085 -1, -1, -1, -1, 105, -1, -1, 108, -1, -1,
2086 111, -1, 113, -1, -1, -1, -1, -1, -1, -1,
2087 45, 5, 6, -1, 8, 9, 10, 11, 12, 13,
2088 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2089 24, -1, 105, -1, -1, 108, -1, -1, 111, -1,
2090 113, -1, -1, 37, -1, -1, -1, -1, -1, 5,
2091 6, 45, 8, 9, 10, 11, 12, 13, 14, 15,
2092 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2093 105, -1, -1, 108, -1, 110, 111, -1, 113, -1,
2094 -1, 37, -1, -1, -1, -1, -1, 5, 6, 45,
2095 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2096 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
2097 -1, 105, -1, -1, 108, -1, -1, 111, -1, 113,
2098 -1, -1, -1, -1, -1, 5, 6, 45, 8, 9,
2099 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2100 20, 21, 22, -1, 24, -1, -1, -1, -1, 105,
2101 -1, -1, 108, -1, -1, 111, -1, 113, -1, -1,
2102 -1, -1, -1, 5, 6, 45, 8, 9, 10, 11,
2103 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2104 22, -1, 24, -1, -1, -1, -1, 105, -1, -1,
2105 108, -1, -1, 111, -1, 113, -1, -1, -1, -1,
2106 -1, 5, 6, 45, 8, 9, 10, 11, 12, 13,
2107 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2108 24, -1, -1, -1, -1, 105, -1, -1, 108, -1,
2109 -1, 111, -1, 113, -1, -1, -1, -1, -1, -1,
2110 -1, 45, -1, -1, -1, -1, -1, -1, -1, -1,
2111 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2112 -1, -1, -1, 105, -1, -1, 108, -1, -1, 111,
2113 -1, 113, -1, -1, -1, -1, -1, -1, -1, -1,
2114 -1, 35, -1, -1, -1, -1, -1, -1, -1, -1,
2115 -1, -1, 46, -1, -1, -1, -1, -1, -1, -1,
2116 -1, 105, 56, 57, 108, -1, -1, 111, -1, 113,
2117 -1, -1, 66, 67, 68, 69, 70, 71, 72, 73,
2118 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2119 84, 85, 86, 87, 88, -1, -1, 91, 92, 93,
2120 94, 95, 96, 97, 98, 99, 100, 101, 102
2121};
2122
2123/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2124 symbol of state STATE-NUM. */
2125static const unsigned char yystos[] =
2126{
2127 0, 148, 149, 150, 0, 25, 31, 41, 42, 43,
2128 44, 59, 129, 165, 167, 168, 175, 22, 24, 48,
2129 55, 59, 128, 158, 168, 169, 58, 61, 62, 63,
2130 64, 65, 130, 163, 23, 176, 177, 30, 114, 166,
2131 176, 49, 50, 51, 155, 103, 58, 20, 47, 129,
2132 103, 163, 24, 153, 4, 5, 6, 8, 9, 10,
2133 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2134 21, 45, 105, 108, 111, 113, 118, 137, 138, 139,
2135 140, 141, 158, 172, 29, 113, 164, 128, 180, 103,
2136 103, 103, 108, 156, 153, 137, 32, 33, 147, 147,
2137 4, 4, 4, 8, 114, 141, 142, 158, 106, 115,
2138 35, 46, 56, 57, 66, 67, 68, 69, 70, 71,
2139 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2140 82, 83, 84, 85, 86, 87, 88, 91, 92, 93,
2141 94, 95, 96, 97, 98, 99, 100, 101, 102, 120,
2142 121, 122, 123, 178, 184, 185, 187, 188, 24, 52,
2143 53, 154, 4, 24, 157, 139, 9, 10, 11, 12,
2144 13, 14, 15, 16, 17, 18, 19, 124, 125, 127,
2145 139, 144, 109, 109, 104, 114, 106, 37, 142, 143,
2146 139, 174, 56, 8, 174, 9, 21, 10, 11, 12,
2147 13, 14, 15, 16, 17, 124, 125, 126, 130, 139,
2148 139, 174, 139, 139, 181, 174, 174, 174, 174, 174,
2149 174, 174, 174, 139, 139, 139, 174, 130, 89, 90,
2150 104, 110, 152, 27, 28, 3, 4, 119, 4, 7,
2151 26, 38, 39, 91, 93, 94, 98, 99, 100, 108,
2152 111, 113, 116, 120, 121, 122, 123, 145, 172, 151,
2153 141, 141, 141, 37, 139, 160, 161, 162, 104, 107,
2154 3, 4, 7, 26, 27, 28, 38, 39, 58, 111,
2155 145, 171, 172, 173, 173, 173, 173, 137, 104, 132,
2156 104, 132, 173, 108, 104, 36, 104, 104, 104, 104,
2157 104, 104, 104, 173, 173, 173, 104, 137, 139, 174,
2158 24, 104, 135, 106, 106, 106, 106, 106, 106, 110,
2159 144, 146, 146, 114, 146, 24, 106, 106, 106, 106,
2160 135, 110, 112, 158, 159, 104, 107, 37, 60, 170,
2161 146, 104, 104, 173, 15, 54, 15, 104, 186, 173,
2162 108, 139, 174, 139, 174, 174, 174, 139, 139, 104,
2163 104, 104, 174, 173, 173, 104, 34, 54, 133, 136,
2164 144, 144, 144, 144, 144, 144, 104, 110, 112, 114,
2165 144, 144, 144, 144, 37, 160, 133, 134, 24, 112,
2166 21, 21, 106, 173, 4, 173, 174, 182, 104, 173,
2167 104, 104, 104, 173, 173, 173, 106, 139, 24, 4,
2168 135, 186, 36, 104, 104, 104, 104, 144, 104, 104,
2169 104, 104, 54, 131, 104, 173, 173, 182, 183, 104,
2170 132, 132, 104, 173, 104, 174, 174, 174, 183, 173,
2171 107, 139, 144, 144, 144, 144, 144, 144, 144, 144,
2172 4, 24, 104, 108, 107, 174, 110, 173, 107, 107,
2173 104, 107, 104, 104, 107, 107, 107, 107, 21, 110,
2174 126, 179, 36, 110, 144, 144, 144, 173, 171, 110,
2175 126, 21, 107, 107, 107, 104, 171, 173, 21, 104,
2176 70, 173, 21, 21, 173, 173
2177};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002178
2179#define yyerrok (yyerrstatus = 0)
2180#define yyclearin (yychar = YYEMPTY)
Reid Spencer61c83e02006-08-18 08:43:06 +00002181#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002182#define YYEOF 0
Reid Spencer61c83e02006-08-18 08:43:06 +00002183
Reid Spencer68a24bd2005-08-27 18:50:39 +00002184#define YYACCEPT goto yyacceptlab
Reid Spencer61c83e02006-08-18 08:43:06 +00002185#define YYABORT goto yyabortlab
2186#define YYERROR goto yyerrorlab
2187
2188
2189/* Like YYERROR except do call yyerror. This remains here temporarily
2190 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002191 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer61c83e02006-08-18 08:43:06 +00002192
Reid Spencer68a24bd2005-08-27 18:50:39 +00002193#define YYFAIL goto yyerrlab
Reid Spencer61c83e02006-08-18 08:43:06 +00002194
Reid Spencer68a24bd2005-08-27 18:50:39 +00002195#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer61c83e02006-08-18 08:43:06 +00002196
2197#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002198do \
2199 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer61c83e02006-08-18 08:43:06 +00002200 { \
2201 yychar = (Token); \
2202 yylval = (Value); \
2203 yytoken = YYTRANSLATE (yychar); \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002204 YYPOPSTACK; \
2205 goto yybackup; \
2206 } \
2207 else \
Reid Spencer61c83e02006-08-18 08:43:06 +00002208 { \
2209 yyerror (YY_("syntax error: cannot back up")); \
2210 YYERROR; \
2211 } \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002212while (0)
2213
Reid Spencer61c83e02006-08-18 08:43:06 +00002214
Reid Spencer68a24bd2005-08-27 18:50:39 +00002215#define YYTERROR 1
2216#define YYERRCODE 256
2217
Reid Spencer61c83e02006-08-18 08:43:06 +00002218
2219/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2220 If N is 0, then set CURRENT to the empty location which ends
2221 the previous symbol: RHS[0] (always defined). */
2222
2223#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2224#ifndef YYLLOC_DEFAULT
2225# define YYLLOC_DEFAULT(Current, Rhs, N) \
2226 do \
2227 if (N) \
2228 { \
2229 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2230 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2231 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2232 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2233 } \
2234 else \
2235 { \
2236 (Current).first_line = (Current).last_line = \
2237 YYRHSLOC (Rhs, 0).last_line; \
2238 (Current).first_column = (Current).last_column = \
2239 YYRHSLOC (Rhs, 0).last_column; \
2240 } \
2241 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002242#endif
2243
Reid Spencer61c83e02006-08-18 08:43:06 +00002244
2245/* YY_LOCATION_PRINT -- Print the location on the stream.
2246 This macro was not mandated originally: define only if we know
2247 we won't break user code: when these are the locations we know. */
2248
2249#ifndef YY_LOCATION_PRINT
2250# if YYLTYPE_IS_TRIVIAL
2251# define YY_LOCATION_PRINT(File, Loc) \
2252 fprintf (File, "%d.%d-%d.%d", \
2253 (Loc).first_line, (Loc).first_column, \
2254 (Loc).last_line, (Loc).last_column)
2255# else
2256# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2257# endif
2258#endif
2259
2260
2261/* YYLEX -- calling `yylex' with the right arguments. */
2262
Reid Spencer68a24bd2005-08-27 18:50:39 +00002263#ifdef YYLEX_PARAM
Reid Spencer61c83e02006-08-18 08:43:06 +00002264# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002265#else
Reid Spencer61c83e02006-08-18 08:43:06 +00002266# define YYLEX yylex ()
Chris Lattner8335e842006-01-23 23:05:42 +00002267#endif
Reid Spencer61c83e02006-08-18 08:43:06 +00002268
2269/* Enable debugging if requested. */
2270#if YYDEBUG
2271
2272# ifndef YYFPRINTF
2273# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2274# define YYFPRINTF fprintf
2275# endif
2276
2277# define YYDPRINTF(Args) \
2278do { \
2279 if (yydebug) \
2280 YYFPRINTF Args; \
2281} while (0)
2282
2283# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2284do { \
2285 if (yydebug) \
2286 { \
2287 YYFPRINTF (stderr, "%s ", Title); \
2288 yysymprint (stderr, \
2289 Type, Value); \
2290 YYFPRINTF (stderr, "\n"); \
2291 } \
2292} while (0)
2293
2294/*------------------------------------------------------------------.
2295| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2296| TOP (included). |
2297`------------------------------------------------------------------*/
2298
2299#if defined (__STDC__) || defined (__cplusplus)
2300static void
2301yy_stack_print (short int *bottom, short int *top)
Chris Lattner8335e842006-01-23 23:05:42 +00002302#else
Reid Spencer61c83e02006-08-18 08:43:06 +00002303static void
2304yy_stack_print (bottom, top)
2305 short int *bottom;
2306 short int *top;
Chris Lattner8335e842006-01-23 23:05:42 +00002307#endif
Reid Spencer61c83e02006-08-18 08:43:06 +00002308{
2309 YYFPRINTF (stderr, "Stack now");
2310 for (/* Nothing. */; bottom <= top; ++bottom)
2311 YYFPRINTF (stderr, " %d", *bottom);
2312 YYFPRINTF (stderr, "\n");
2313}
2314
2315# define YY_STACK_PRINT(Bottom, Top) \
2316do { \
2317 if (yydebug) \
2318 yy_stack_print ((Bottom), (Top)); \
2319} while (0)
2320
2321
2322/*------------------------------------------------.
2323| Report that the YYRULE is going to be reduced. |
2324`------------------------------------------------*/
2325
2326#if defined (__STDC__) || defined (__cplusplus)
2327static void
2328yy_reduce_print (int yyrule)
2329#else
2330static void
2331yy_reduce_print (yyrule)
2332 int yyrule;
Robert Bocchino2def1b32006-01-17 20:06:25 +00002333#endif
Reid Spencer61c83e02006-08-18 08:43:06 +00002334{
2335 int yyi;
2336 unsigned long int yylno = yyrline[yyrule];
2337 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2338 yyrule - 1, yylno);
2339 /* Print the symbols being reduced, and their result. */
2340 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2341 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2342 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2343}
Reid Spencere812fb22006-01-19 01:21:04 +00002344
Reid Spencer61c83e02006-08-18 08:43:06 +00002345# define YY_REDUCE_PRINT(Rule) \
2346do { \
2347 if (yydebug) \
2348 yy_reduce_print (Rule); \
2349} while (0)
Reid Spencere812fb22006-01-19 01:21:04 +00002350
Reid Spencer61c83e02006-08-18 08:43:06 +00002351/* Nonzero means print parse trace. It is left uninitialized so that
2352 multiple parsers can coexist. */
2353int yydebug;
2354#else /* !YYDEBUG */
2355# define YYDPRINTF(Args)
2356# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2357# define YY_STACK_PRINT(Bottom, Top)
2358# define YY_REDUCE_PRINT(Rule)
2359#endif /* !YYDEBUG */
Reid Spencere812fb22006-01-19 01:21:04 +00002360
Reid Spencere812fb22006-01-19 01:21:04 +00002361
Reid Spencer61c83e02006-08-18 08:43:06 +00002362/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002363#ifndef YYINITDEPTH
Reid Spencer61c83e02006-08-18 08:43:06 +00002364# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002365#endif
2366
Reid Spencer61c83e02006-08-18 08:43:06 +00002367/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2368 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002369
Reid Spencer61c83e02006-08-18 08:43:06 +00002370 Do not make this value too large; the results are undefined if
2371 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2372 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002373
2374#ifndef YYMAXDEPTH
Reid Spencer61c83e02006-08-18 08:43:06 +00002375# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002376#endif
Reid Spencer61c83e02006-08-18 08:43:06 +00002377
Reid Spencer68a24bd2005-08-27 18:50:39 +00002378
2379
Reid Spencer61c83e02006-08-18 08:43:06 +00002380#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002381
Reid Spencer61c83e02006-08-18 08:43:06 +00002382# ifndef yystrlen
2383# if defined (__GLIBC__) && defined (_STRING_H)
2384# define yystrlen strlen
2385# else
2386/* Return the length of YYSTR. */
2387static YYSIZE_T
2388# if defined (__STDC__) || defined (__cplusplus)
2389yystrlen (const char *yystr)
2390# else
2391yystrlen (yystr)
2392 const char *yystr;
2393# endif
Chris Lattner8335e842006-01-23 23:05:42 +00002394{
Reid Spencer61c83e02006-08-18 08:43:06 +00002395 const char *yys = yystr;
Chris Lattner8335e842006-01-23 23:05:42 +00002396
Reid Spencer61c83e02006-08-18 08:43:06 +00002397 while (*yys++ != '\0')
2398 continue;
2399
2400 return yys - yystr - 1;
Chris Lattner8335e842006-01-23 23:05:42 +00002401}
Reid Spencer61c83e02006-08-18 08:43:06 +00002402# endif
2403# endif
Chris Lattner8335e842006-01-23 23:05:42 +00002404
Reid Spencer61c83e02006-08-18 08:43:06 +00002405# ifndef yystpcpy
2406# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2407# define yystpcpy stpcpy
2408# else
2409/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2410 YYDEST. */
2411static char *
2412# if defined (__STDC__) || defined (__cplusplus)
2413yystpcpy (char *yydest, const char *yysrc)
2414# else
2415yystpcpy (yydest, yysrc)
2416 char *yydest;
2417 const char *yysrc;
2418# endif
Chris Lattner8335e842006-01-23 23:05:42 +00002419{
Reid Spencer61c83e02006-08-18 08:43:06 +00002420 char *yyd = yydest;
2421 const char *yys = yysrc;
Chris Lattner8335e842006-01-23 23:05:42 +00002422
Reid Spencer61c83e02006-08-18 08:43:06 +00002423 while ((*yyd++ = *yys++) != '\0')
2424 continue;
2425
2426 return yyd - 1;
Chris Lattner8335e842006-01-23 23:05:42 +00002427}
Reid Spencer61c83e02006-08-18 08:43:06 +00002428# endif
2429# endif
Chris Lattner8335e842006-01-23 23:05:42 +00002430
Reid Spencer61c83e02006-08-18 08:43:06 +00002431# ifndef yytnamerr
2432/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2433 quotes and backslashes, so that it's suitable for yyerror. The
2434 heuristic is that double-quoting is unnecessary unless the string
2435 contains an apostrophe, a comma, or backslash (other than
2436 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2437 null, do not copy; instead, return the length of what the result
2438 would have been. */
2439static YYSIZE_T
2440yytnamerr (char *yyres, const char *yystr)
2441{
2442 if (*yystr == '"')
2443 {
2444 size_t yyn = 0;
2445 char const *yyp = yystr;
2446
2447 for (;;)
2448 switch (*++yyp)
2449 {
2450 case '\'':
2451 case ',':
2452 goto do_not_strip_quotes;
2453
2454 case '\\':
2455 if (*++yyp != '\\')
2456 goto do_not_strip_quotes;
2457 /* Fall through. */
2458 default:
2459 if (yyres)
2460 yyres[yyn] = *yyp;
2461 yyn++;
2462 break;
2463
2464 case '"':
2465 if (yyres)
2466 yyres[yyn] = '\0';
2467 return yyn;
2468 }
2469 do_not_strip_quotes: ;
2470 }
2471
2472 if (! yyres)
2473 return yystrlen (yystr);
2474
2475 return yystpcpy (yyres, yystr) - yyres;
2476}
2477# endif
2478
2479#endif /* YYERROR_VERBOSE */
2480
Reid Spencere812fb22006-01-19 01:21:04 +00002481
2482
Reid Spencer61c83e02006-08-18 08:43:06 +00002483#if YYDEBUG
2484/*--------------------------------.
2485| Print this symbol on YYOUTPUT. |
2486`--------------------------------*/
Reid Spencere812fb22006-01-19 01:21:04 +00002487
Reid Spencer61c83e02006-08-18 08:43:06 +00002488#if defined (__STDC__) || defined (__cplusplus)
2489static void
2490yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner8335e842006-01-23 23:05:42 +00002491#else
Reid Spencer61c83e02006-08-18 08:43:06 +00002492static void
2493yysymprint (yyoutput, yytype, yyvaluep)
2494 FILE *yyoutput;
2495 int yytype;
2496 YYSTYPE *yyvaluep;
2497#endif
2498{
2499 /* Pacify ``unused variable'' warnings. */
2500 (void) yyvaluep;
2501
2502 if (yytype < YYNTOKENS)
2503 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2504 else
2505 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2506
2507
2508# ifdef YYPRINT
2509 if (yytype < YYNTOKENS)
2510 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2511# endif
2512 switch (yytype)
2513 {
2514 default:
2515 break;
2516 }
2517 YYFPRINTF (yyoutput, ")");
2518}
2519
2520#endif /* ! YYDEBUG */
2521/*-----------------------------------------------.
2522| Release the memory associated to this symbol. |
2523`-----------------------------------------------*/
2524
2525#if defined (__STDC__) || defined (__cplusplus)
2526static void
2527yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2528#else
2529static void
2530yydestruct (yymsg, yytype, yyvaluep)
2531 const char *yymsg;
2532 int yytype;
2533 YYSTYPE *yyvaluep;
2534#endif
2535{
2536 /* Pacify ``unused variable'' warnings. */
2537 (void) yyvaluep;
2538
2539 if (!yymsg)
2540 yymsg = "Deleting";
2541 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2542
2543 switch (yytype)
2544 {
2545
2546 default:
2547 break;
2548 }
2549}
2550
2551
2552/* Prevent warnings from -Wmissing-prototypes. */
2553
2554#ifdef YYPARSE_PARAM
2555# if defined (__STDC__) || defined (__cplusplus)
2556int yyparse (void *YYPARSE_PARAM);
2557# else
2558int yyparse ();
2559# endif
2560#else /* ! YYPARSE_PARAM */
2561#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002562int yyparse (void);
Chris Lattner8335e842006-01-23 23:05:42 +00002563#else
Reid Spencer61c83e02006-08-18 08:43:06 +00002564int yyparse ();
2565#endif
2566#endif /* ! YYPARSE_PARAM */
2567
2568
2569
2570/* The look-ahead symbol. */
2571int yychar;
2572
2573/* The semantic value of the look-ahead symbol. */
2574YYSTYPE yylval;
2575
2576/* Number of syntax errors so far. */
2577int yynerrs;
2578
2579
2580
2581/*----------.
2582| yyparse. |
2583`----------*/
2584
2585#ifdef YYPARSE_PARAM
2586# if defined (__STDC__) || defined (__cplusplus)
2587int yyparse (void *YYPARSE_PARAM)
2588# else
2589int yyparse (YYPARSE_PARAM)
2590 void *YYPARSE_PARAM;
2591# endif
2592#else /* ! YYPARSE_PARAM */
2593#if defined (__STDC__) || defined (__cplusplus)
2594int
2595yyparse (void)
2596#else
2597int
2598yyparse ()
2599
2600#endif
2601#endif
2602{
2603
2604 int yystate;
2605 int yyn;
2606 int yyresult;
2607 /* Number of tokens to shift before error messages enabled. */
2608 int yyerrstatus;
2609 /* Look-ahead token as an internal (translated) token number. */
2610 int yytoken = 0;
2611
2612 /* Three stacks and their tools:
2613 `yyss': related to states,
2614 `yyvs': related to semantic values,
2615 `yyls': related to locations.
2616
2617 Refer to the stacks thru separate pointers, to allow yyoverflow
2618 to reallocate them elsewhere. */
2619
2620 /* The state stack. */
2621 short int yyssa[YYINITDEPTH];
2622 short int *yyss = yyssa;
2623 short int *yyssp;
2624
2625 /* The semantic value stack. */
2626 YYSTYPE yyvsa[YYINITDEPTH];
2627 YYSTYPE *yyvs = yyvsa;
2628 YYSTYPE *yyvsp;
2629
2630
2631
Reid Spencer68a24bd2005-08-27 18:50:39 +00002632#define YYPOPSTACK (yyvsp--, yyssp--)
2633
Reid Spencer61c83e02006-08-18 08:43:06 +00002634 YYSIZE_T yystacksize = YYINITDEPTH;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002635
Reid Spencer61c83e02006-08-18 08:43:06 +00002636 /* The variables used to return semantic value and location from the
2637 action routines. */
2638 YYSTYPE yyval;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002639
2640
Reid Spencer61c83e02006-08-18 08:43:06 +00002641 /* When reducing, the number of symbols on the RHS of the reduced
2642 rule. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002643 int yylen;
2644
Reid Spencer61c83e02006-08-18 08:43:06 +00002645 YYDPRINTF ((stderr, "Starting parse\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002646
2647 yystate = 0;
2648 yyerrstatus = 0;
2649 yynerrs = 0;
2650 yychar = YYEMPTY; /* Cause a token to be read. */
2651
2652 /* Initialize stack pointers.
2653 Waste one element of value and location stack
2654 so that they stay on the same level as the state stack.
2655 The wasted elements are never initialized. */
2656
Reid Spencer61c83e02006-08-18 08:43:06 +00002657 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002658 yyvsp = yyvs;
2659
Reid Spencer61c83e02006-08-18 08:43:06 +00002660 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002661
Reid Spencer61c83e02006-08-18 08:43:06 +00002662/*------------------------------------------------------------.
2663| yynewstate -- Push a new state, which is found in yystate. |
2664`------------------------------------------------------------*/
2665 yynewstate:
2666 /* In all cases, when you get here, the value and location stacks
2667 have just been pushed. so pushing a state here evens the stacks.
2668 */
2669 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002670
Reid Spencer61c83e02006-08-18 08:43:06 +00002671 yysetstate:
2672 *yyssp = yystate;
2673
2674 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002675 {
2676 /* Get the current used size of the three stacks, in elements. */
Reid Spencer61c83e02006-08-18 08:43:06 +00002677 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002678
2679#ifdef yyoverflow
Reid Spencer61c83e02006-08-18 08:43:06 +00002680 {
2681 /* Give user a chance to reallocate the stack. Use copies of
2682 these so that the &'s don't force the real ones into
2683 memory. */
2684 YYSTYPE *yyvs1 = yyvs;
2685 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002686
Reid Spencer61c83e02006-08-18 08:43:06 +00002687
2688 /* Each stack pointer address is followed by the size of the
2689 data in use in that stack, in bytes. This used to be a
2690 conditional around just the two extra args, but that might
2691 be undefined if yyoverflow is a macro. */
2692 yyoverflow (YY_("memory exhausted"),
2693 &yyss1, yysize * sizeof (*yyssp),
2694 &yyvs1, yysize * sizeof (*yyvsp),
2695
2696 &yystacksize);
2697
2698 yyss = yyss1;
2699 yyvs = yyvs1;
2700 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002701#else /* no yyoverflow */
Reid Spencer61c83e02006-08-18 08:43:06 +00002702# ifndef YYSTACK_RELOCATE
2703 goto yyexhaustedlab;
2704# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002705 /* Extend the stack our own way. */
Reid Spencer61c83e02006-08-18 08:43:06 +00002706 if (YYMAXDEPTH <= yystacksize)
2707 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002708 yystacksize *= 2;
Reid Spencer61c83e02006-08-18 08:43:06 +00002709 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002710 yystacksize = YYMAXDEPTH;
Reid Spencer61c83e02006-08-18 08:43:06 +00002711
2712 {
2713 short int *yyss1 = yyss;
2714 union yyalloc *yyptr =
2715 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2716 if (! yyptr)
2717 goto yyexhaustedlab;
2718 YYSTACK_RELOCATE (yyss);
2719 YYSTACK_RELOCATE (yyvs);
2720
2721# undef YYSTACK_RELOCATE
2722 if (yyss1 != yyssa)
2723 YYSTACK_FREE (yyss1);
2724 }
2725# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002726#endif /* no yyoverflow */
2727
Reid Spencer61c83e02006-08-18 08:43:06 +00002728 yyssp = yyss + yysize - 1;
2729 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002730
2731
Reid Spencer61c83e02006-08-18 08:43:06 +00002732 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2733 (unsigned long int) yystacksize));
2734
2735 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002736 YYABORT;
2737 }
2738
Reid Spencer61c83e02006-08-18 08:43:06 +00002739 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002740
2741 goto yybackup;
Reid Spencer61c83e02006-08-18 08:43:06 +00002742
2743/*-----------.
2744| yybackup. |
2745`-----------*/
2746yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002747
2748/* Do appropriate processing given the current state. */
Reid Spencer61c83e02006-08-18 08:43:06 +00002749/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002750/* yyresume: */
2751
Reid Spencer61c83e02006-08-18 08:43:06 +00002752 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002753
2754 yyn = yypact[yystate];
Reid Spencer61c83e02006-08-18 08:43:06 +00002755 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002756 goto yydefault;
2757
Reid Spencer61c83e02006-08-18 08:43:06 +00002758 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002759
Reid Spencer61c83e02006-08-18 08:43:06 +00002760 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002761 if (yychar == YYEMPTY)
2762 {
Reid Spencer61c83e02006-08-18 08:43:06 +00002763 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002764 yychar = YYLEX;
2765 }
2766
Reid Spencer61c83e02006-08-18 08:43:06 +00002767 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002768 {
Reid Spencer61c83e02006-08-18 08:43:06 +00002769 yychar = yytoken = YYEOF;
2770 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002771 }
2772 else
2773 {
Reid Spencer61c83e02006-08-18 08:43:06 +00002774 yytoken = YYTRANSLATE (yychar);
2775 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002776 }
2777
Reid Spencer61c83e02006-08-18 08:43:06 +00002778 /* If the proper action on seeing token YYTOKEN is to reduce or to
2779 detect an error, take that action. */
2780 yyn += yytoken;
2781 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002782 goto yydefault;
2783 yyn = yytable[yyn];
Reid Spencer61c83e02006-08-18 08:43:06 +00002784 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002785 {
Reid Spencer61c83e02006-08-18 08:43:06 +00002786 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002787 goto yyerrlab;
2788 yyn = -yyn;
2789 goto yyreduce;
2790 }
2791
2792 if (yyn == YYFINAL)
2793 YYACCEPT;
2794
Reid Spencer61c83e02006-08-18 08:43:06 +00002795 /* Shift the look-ahead token. */
2796 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002797
2798 /* Discard the token being shifted unless it is eof. */
2799 if (yychar != YYEOF)
2800 yychar = YYEMPTY;
2801
2802 *++yyvsp = yylval;
2803
Reid Spencer61c83e02006-08-18 08:43:06 +00002804
2805 /* Count tokens shifted since error; after three, turn off error
2806 status. */
2807 if (yyerrstatus)
2808 yyerrstatus--;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002809
2810 yystate = yyn;
2811 goto yynewstate;
2812
Chris Lattner8335e842006-01-23 23:05:42 +00002813
Reid Spencer61c83e02006-08-18 08:43:06 +00002814/*-----------------------------------------------------------.
2815| yydefault -- do the default action for the current state. |
2816`-----------------------------------------------------------*/
2817yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002818 yyn = yydefact[yystate];
2819 if (yyn == 0)
2820 goto yyerrlab;
Reid Spencer61c83e02006-08-18 08:43:06 +00002821 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002822
Reid Spencer61c83e02006-08-18 08:43:06 +00002823
2824/*-----------------------------.
2825| yyreduce -- Do a reduction. |
2826`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002827yyreduce:
Reid Spencer61c83e02006-08-18 08:43:06 +00002828 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002829 yylen = yyr2[yyn];
2830
Reid Spencer61c83e02006-08-18 08:43:06 +00002831 /* If YYLEN is nonzero, implement the default value of the action:
2832 `$$ = $1'.
2833
2834 Otherwise, the following line sets YYVAL to garbage.
2835 This behavior is undocumented and Bison
2836 users should not rely upon it. Assigning to YYVAL
2837 unconditionally makes the parser a bit smaller, and it avoids a
2838 GCC warning that YYVAL may be used uninitialized. */
2839 yyval = yyvsp[1-yylen];
2840
2841
2842 YY_REDUCE_PRINT (yyn);
2843 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002844 {
Reid Spencer61c83e02006-08-18 08:43:06 +00002845 case 3:
Reid Spencere4f47592006-08-18 17:32:55 +00002846#line 1028 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002847 {
2848 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
2849 GEN_ERROR("Value too large for type!");
2850 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
2851 CHECK_FOR_ERROR
2852;}
2853 break;
Chris Lattner8335e842006-01-23 23:05:42 +00002854
Reid Spencer61c83e02006-08-18 08:43:06 +00002855 case 5:
Reid Spencere4f47592006-08-18 17:32:55 +00002856#line 1037 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002857 {
2858 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
2859 GEN_ERROR("Value too large for type!");
2860 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
2861 CHECK_FOR_ERROR
2862;}
2863 break;
Chris Lattner8335e842006-01-23 23:05:42 +00002864
Reid Spencer61c83e02006-08-18 08:43:06 +00002865 case 34:
Reid Spencere4f47592006-08-18 17:32:55 +00002866#line 1061 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002867 {
2868 (yyval.StrVal) = (yyvsp[-1].StrVal);
2869 CHECK_FOR_ERROR
2870 ;}
2871 break;
Chris Lattner8335e842006-01-23 23:05:42 +00002872
Reid Spencer61c83e02006-08-18 08:43:06 +00002873 case 35:
Reid Spencere4f47592006-08-18 17:32:55 +00002874#line 1065 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002875 {
2876 (yyval.StrVal) = 0;
2877 CHECK_FOR_ERROR
2878 ;}
2879 break;
Chris Lattner8335e842006-01-23 23:05:42 +00002880
Reid Spencer61c83e02006-08-18 08:43:06 +00002881 case 36:
Reid Spencere4f47592006-08-18 17:32:55 +00002882#line 1070 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002883 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
2884 break;
Chris Lattner8335e842006-01-23 23:05:42 +00002885
Reid Spencer61c83e02006-08-18 08:43:06 +00002886 case 37:
Reid Spencere4f47592006-08-18 17:32:55 +00002887#line 1071 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002888 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
2889 break;
2890
2891 case 38:
Reid Spencere4f47592006-08-18 17:32:55 +00002892#line 1072 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002893 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
2894 break;
2895
2896 case 39:
Reid Spencere4f47592006-08-18 17:32:55 +00002897#line 1073 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002898 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
2899 break;
2900
2901 case 40:
Reid Spencere4f47592006-08-18 17:32:55 +00002902#line 1074 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002903 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
2904 break;
2905
2906 case 41:
Reid Spencere4f47592006-08-18 17:32:55 +00002907#line 1076 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002908 { (yyval.UIntVal) = CallingConv::C; ;}
2909 break;
2910
2911 case 42:
Reid Spencere4f47592006-08-18 17:32:55 +00002912#line 1077 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002913 { (yyval.UIntVal) = CallingConv::C; ;}
2914 break;
2915
2916 case 43:
Reid Spencere4f47592006-08-18 17:32:55 +00002917#line 1078 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002918 { (yyval.UIntVal) = CallingConv::CSRet; ;}
2919 break;
2920
2921 case 44:
Reid Spencere4f47592006-08-18 17:32:55 +00002922#line 1079 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002923 { (yyval.UIntVal) = CallingConv::Fast; ;}
2924 break;
2925
2926 case 45:
Reid Spencere4f47592006-08-18 17:32:55 +00002927#line 1080 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002928 { (yyval.UIntVal) = CallingConv::Cold; ;}
2929 break;
2930
2931 case 46:
Reid Spencere4f47592006-08-18 17:32:55 +00002932#line 1081 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002933 {
2934 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
2935 GEN_ERROR("Calling conv too large!");
2936 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
2937 CHECK_FOR_ERROR
2938 ;}
2939 break;
2940
2941 case 47:
Reid Spencere4f47592006-08-18 17:32:55 +00002942#line 1090 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002943 { (yyval.UIntVal) = 0; ;}
2944 break;
2945
2946 case 48:
Reid Spencere4f47592006-08-18 17:32:55 +00002947#line 1091 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002948 {
2949 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
2950 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
2951 GEN_ERROR("Alignment must be a power of two!");
2952 CHECK_FOR_ERROR
2953;}
2954 break;
2955
2956 case 49:
Reid Spencere4f47592006-08-18 17:32:55 +00002957#line 1097 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002958 { (yyval.UIntVal) = 0; ;}
2959 break;
2960
2961 case 50:
Reid Spencere4f47592006-08-18 17:32:55 +00002962#line 1098 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002963 {
2964 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
2965 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
2966 GEN_ERROR("Alignment must be a power of two!");
2967 CHECK_FOR_ERROR
2968;}
2969 break;
2970
2971 case 51:
Reid Spencere4f47592006-08-18 17:32:55 +00002972#line 1106 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002973 {
2974 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
2975 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
2976 GEN_ERROR("Invalid character in section name!");
2977 (yyval.StrVal) = (yyvsp[0].StrVal);
2978 CHECK_FOR_ERROR
2979;}
2980 break;
2981
2982 case 52:
Reid Spencere4f47592006-08-18 17:32:55 +00002983#line 1114 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002984 { (yyval.StrVal) = 0; ;}
2985 break;
2986
2987 case 53:
Reid Spencere4f47592006-08-18 17:32:55 +00002988#line 1115 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002989 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
2990 break;
2991
2992 case 54:
Reid Spencere4f47592006-08-18 17:32:55 +00002993#line 1120 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002994 {;}
2995 break;
2996
2997 case 55:
Reid Spencere4f47592006-08-18 17:32:55 +00002998#line 1121 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00002999 {;}
3000 break;
3001
3002 case 56:
Reid Spencere4f47592006-08-18 17:32:55 +00003003#line 1122 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003004 {
3005 CurGV->setSection((yyvsp[0].StrVal));
3006 free((yyvsp[0].StrVal));
3007 CHECK_FOR_ERROR
3008 ;}
3009 break;
3010
3011 case 57:
Reid Spencere4f47592006-08-18 17:32:55 +00003012#line 1127 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003013 {
3014 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
3015 GEN_ERROR("Alignment must be a power of two!");
3016 CurGV->setAlignment((yyvsp[0].UInt64Val));
3017 CHECK_FOR_ERROR
3018 ;}
3019 break;
3020
3021 case 59:
Reid Spencere4f47592006-08-18 17:32:55 +00003022#line 1141 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003023 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
3024 break;
3025
3026 case 61:
Reid Spencere4f47592006-08-18 17:32:55 +00003027#line 1142 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003028 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
3029 break;
3030
3031 case 62:
Reid Spencere4f47592006-08-18 17:32:55 +00003032#line 1144 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003033 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003034 if (!UpRefs.empty())
Reid Spencer61c83e02006-08-18 08:43:06 +00003035 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3036 (yyval.TypeVal) = (yyvsp[0].TypeVal);
3037 CHECK_FOR_ERROR
3038 ;}
3039 break;
3040
3041 case 76:
Reid Spencere4f47592006-08-18 17:32:55 +00003042#line 1156 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003043 {
3044 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
3045 CHECK_FOR_ERROR
3046 ;}
3047 break;
3048
3049 case 77:
Reid Spencere4f47592006-08-18 17:32:55 +00003050#line 1160 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003051 {
3052 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
3053 CHECK_FOR_ERROR
3054 ;}
3055 break;
3056
3057 case 78:
Reid Spencere4f47592006-08-18 17:32:55 +00003058#line 1164 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003059 { // Named types are also simple types...
3060 (yyval.TypeVal) = new PATypeHolder(getTypeVal((yyvsp[0].ValIDVal)));
3061 CHECK_FOR_ERROR
3062;}
3063 break;
3064
3065 case 79:
Reid Spencere4f47592006-08-18 17:32:55 +00003066#line 1171 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003067 { // Type UpReference
3068 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003069 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer61c83e02006-08-18 08:43:06 +00003070 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3071 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003072 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003073 CHECK_FOR_ERROR
3074 ;}
3075 break;
3076
3077 case 80:
Reid Spencere4f47592006-08-18 17:32:55 +00003078#line 1179 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003079 { // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003080 std::vector<const Type*> Params;
Reid Spencer61c83e02006-08-18 08:43:06 +00003081 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3082 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003083 Params.push_back(*I);
3084 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3085 if (isVarArg) Params.pop_back();
3086
Reid Spencer61c83e02006-08-18 08:43:06 +00003087 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg)));
3088 delete (yyvsp[-1].TypeList); // Delete the argument list
3089 delete (yyvsp[-3].TypeVal); // Delete the return type handle
3090 CHECK_FOR_ERROR
3091 ;}
3092 break;
3093
3094 case 81:
Reid Spencere4f47592006-08-18 17:32:55 +00003095#line 1192 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003096 { // Sized array type?
3097 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3098 delete (yyvsp[-1].TypeVal);
3099 CHECK_FOR_ERROR
3100 ;}
3101 break;
3102
3103 case 82:
Reid Spencere4f47592006-08-18 17:32:55 +00003104#line 1197 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003105 { // Packed array type?
3106 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3107 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
3108 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00003109 if (!ElemTy->isPrimitiveType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003110 GEN_ERROR("Elemental type of a PackedType must be primitive");
3111 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
3112 GEN_ERROR("Vector length should be a power of 2!");
3113 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3114 delete (yyvsp[-1].TypeVal);
3115 CHECK_FOR_ERROR
3116 ;}
3117 break;
3118
3119 case 83:
Reid Spencere4f47592006-08-18 17:32:55 +00003120#line 1209 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003121 { // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003122 std::vector<const Type*> Elements;
Reid Spencer61c83e02006-08-18 08:43:06 +00003123 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3124 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003125 Elements.push_back(*I);
3126
Reid Spencer61c83e02006-08-18 08:43:06 +00003127 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3128 delete (yyvsp[-1].TypeList);
3129 CHECK_FOR_ERROR
3130 ;}
3131 break;
3132
3133 case 84:
Reid Spencere4f47592006-08-18 17:32:55 +00003134#line 1219 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003135 { // Empty structure type?
3136 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
3137 CHECK_FOR_ERROR
3138 ;}
3139 break;
3140
3141 case 85:
Reid Spencere4f47592006-08-18 17:32:55 +00003142#line 1223 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003143 { // Pointer type?
3144 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3145 delete (yyvsp[-1].TypeVal);
3146 CHECK_FOR_ERROR
3147 ;}
3148 break;
3149
3150 case 86:
Reid Spencere4f47592006-08-18 17:32:55 +00003151#line 1232 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003152 {
3153 (yyval.TypeList) = new std::list<PATypeHolder>();
3154 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
3155 CHECK_FOR_ERROR
3156 ;}
3157 break;
3158
3159 case 87:
Reid Spencere4f47592006-08-18 17:32:55 +00003160#line 1237 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003161 {
3162 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
3163 CHECK_FOR_ERROR
3164 ;}
3165 break;
3166
3167 case 89:
Reid Spencere4f47592006-08-18 17:32:55 +00003168#line 1244 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003169 {
3170 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy);
3171 CHECK_FOR_ERROR
3172 ;}
3173 break;
3174
3175 case 90:
Reid Spencere4f47592006-08-18 17:32:55 +00003176#line 1248 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003177 {
3178 ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
3179 CHECK_FOR_ERROR
3180 ;}
3181 break;
3182
3183 case 91:
Reid Spencere4f47592006-08-18 17:32:55 +00003184#line 1252 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003185 {
3186 (yyval.TypeList) = new std::list<PATypeHolder>();
3187 CHECK_FOR_ERROR
3188 ;}
3189 break;
3190
3191 case 92:
Reid Spencere4f47592006-08-18 17:32:55 +00003192#line 1263 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003193 { // Nonempty unsized arr
3194 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003195 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003196 GEN_ERROR("Cannot make array constant with type: '" +
3197 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003198 const Type *ETy = ATy->getElementType();
3199 int NumElements = ATy->getNumElements();
3200
3201 // Verify that we have the correct size...
Reid Spencer61c83e02006-08-18 08:43:06 +00003202 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
3203 GEN_ERROR("Type mismatch: constant sized array initialized with " +
3204 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003205 itostr(NumElements) + "!");
3206
3207 // Verify all elements are correct type!
Reid Spencer61c83e02006-08-18 08:43:06 +00003208 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3209 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
3210 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003211 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer61c83e02006-08-18 08:43:06 +00003212 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003213 }
3214
Reid Spencer61c83e02006-08-18 08:43:06 +00003215 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3216 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
3217 CHECK_FOR_ERROR
3218 ;}
3219 break;
3220
3221 case 93:
Reid Spencere4f47592006-08-18 17:32:55 +00003222#line 1289 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003223 {
3224 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003225 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003226 GEN_ERROR("Cannot make array constant with type: '" +
3227 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003228
3229 int NumElements = ATy->getNumElements();
3230 if (NumElements != -1 && NumElements != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003231 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003232 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003233 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3234 delete (yyvsp[-2].TypeVal);
3235 CHECK_FOR_ERROR
3236 ;}
3237 break;
3238
3239 case 94:
Reid Spencere4f47592006-08-18 17:32:55 +00003240#line 1303 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003241 {
3242 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003243 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003244 GEN_ERROR("Cannot make array constant with type: '" +
3245 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003246
3247 int NumElements = ATy->getNumElements();
3248 const Type *ETy = ATy->getElementType();
Reid Spencer61c83e02006-08-18 08:43:06 +00003249 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3250 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
3251 GEN_ERROR("Can't build string constant of size " +
3252 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003253 " when array has size " + itostr(NumElements) + "!");
3254 std::vector<Constant*> Vals;
3255 if (ETy == Type::SByteTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00003256 for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003257 Vals.push_back(ConstantSInt::get(ETy, *C));
3258 } else if (ETy == Type::UByteTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +00003259 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003260 C != (unsigned char*)EndStr; ++C)
3261 Vals.push_back(ConstantUInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003262 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +00003263 free((yyvsp[0].StrVal));
3264 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003265 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003266 free((yyvsp[0].StrVal));
3267 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3268 delete (yyvsp[-2].TypeVal);
3269 CHECK_FOR_ERROR
3270 ;}
3271 break;
3272
3273 case 95:
Reid Spencere4f47592006-08-18 17:32:55 +00003274#line 1333 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003275 { // Nonempty unsized arr
3276 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003277 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003278 GEN_ERROR("Cannot make packed constant with type: '" +
3279 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003280 const Type *ETy = PTy->getElementType();
3281 int NumElements = PTy->getNumElements();
3282
3283 // Verify that we have the correct size...
Reid Spencer61c83e02006-08-18 08:43:06 +00003284 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
3285 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
3286 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003287 itostr(NumElements) + "!");
3288
3289 // Verify all elements are correct type!
Reid Spencer61c83e02006-08-18 08:43:06 +00003290 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3291 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
3292 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003293 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer61c83e02006-08-18 08:43:06 +00003294 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003295 }
3296
Reid Spencer61c83e02006-08-18 08:43:06 +00003297 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3298 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
3299 CHECK_FOR_ERROR
3300 ;}
3301 break;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003302
Reid Spencer61c83e02006-08-18 08:43:06 +00003303 case 96:
Reid Spencere4f47592006-08-18 17:32:55 +00003304#line 1359 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003305 {
3306 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
3307 if (STy == 0)
3308 GEN_ERROR("Cannot make struct constant with type: '" +
3309 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
3310
3311 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
3312 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003313
3314 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer61c83e02006-08-18 08:43:06 +00003315 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3316 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
3317 GEN_ERROR("Expected type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003318 STy->getElementType(i)->getDescription() +
3319 "' for element #" + utostr(i) +
3320 " of structure initializer!");
3321
Reid Spencer61c83e02006-08-18 08:43:06 +00003322 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3323 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
3324 CHECK_FOR_ERROR
3325 ;}
3326 break;
3327
3328 case 97:
Reid Spencere4f47592006-08-18 17:32:55 +00003329#line 1380 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003330 {
3331 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003332 if (STy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003333 GEN_ERROR("Cannot make struct constant with type: '" +
3334 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003335
3336 if (STy->getNumContainedTypes() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003337 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003338
Reid Spencer61c83e02006-08-18 08:43:06 +00003339 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3340 delete (yyvsp[-2].TypeVal);
3341 CHECK_FOR_ERROR
3342 ;}
3343 break;
3344
3345 case 98:
Reid Spencere4f47592006-08-18 17:32:55 +00003346#line 1393 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003347 {
3348 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003349 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003350 GEN_ERROR("Cannot make null pointer constant with type: '" +
3351 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003352
Reid Spencer61c83e02006-08-18 08:43:06 +00003353 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3354 delete (yyvsp[-1].TypeVal);
3355 CHECK_FOR_ERROR
3356 ;}
3357 break;
3358
3359 case 99:
Reid Spencere4f47592006-08-18 17:32:55 +00003360#line 1403 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003361 {
3362 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3363 delete (yyvsp[-1].TypeVal);
3364 CHECK_FOR_ERROR
3365 ;}
3366 break;
3367
3368 case 100:
Reid Spencere4f47592006-08-18 17:32:55 +00003369#line 1408 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003370 {
3371 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003372 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003373 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003374
3375 // ConstExprs can exist in the body of a function, thus creating
3376 // GlobalValues whenever they refer to a variable. Because we are in
3377 // the context of a function, getValNonImprovising will search the functions
3378 // symbol table instead of the module symbol table for the global symbol,
3379 // which throws things all off. To get around this, we just tell
3380 // getValNonImprovising that we are at global scope here.
3381 //
3382 Function *SavedCurFn = CurFun.CurrentFunction;
3383 CurFun.CurrentFunction = 0;
3384
Reid Spencer61c83e02006-08-18 08:43:06 +00003385 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003386
3387 CurFun.CurrentFunction = SavedCurFn;
3388
3389 // If this is an initializer for a constant pointer, which is referencing a
3390 // (currently) undefined variable, create a stub now that shall be replaced
3391 // in the future with the right type of variable.
3392 //
3393 if (V == 0) {
3394 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3395 const PointerType *PT = cast<PointerType>(Ty);
3396
3397 // First check to see if the forward references value is already created!
3398 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer61c83e02006-08-18 08:43:06 +00003399 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003400
3401 if (I != CurModule.GlobalRefs.end()) {
3402 V = I->second; // Placeholder already exists, use it...
Reid Spencer61c83e02006-08-18 08:43:06 +00003403 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003404 } else {
3405 std::string Name;
Reid Spencer61c83e02006-08-18 08:43:06 +00003406 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003407
3408 // Create the forward referenced global.
3409 GlobalValue *GV;
3410 if (const FunctionType *FTy =
3411 dyn_cast<FunctionType>(PT->getElementType())) {
3412 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3413 CurModule.CurrentModule);
3414 } else {
3415 GV = new GlobalVariable(PT->getElementType(), false,
3416 GlobalValue::ExternalLinkage, 0,
3417 Name, CurModule.CurrentModule);
3418 }
3419
3420 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer61c83e02006-08-18 08:43:06 +00003421 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003422 V = GV;
3423 }
3424 }
3425
Reid Spencer61c83e02006-08-18 08:43:06 +00003426 (yyval.ConstVal) = cast<GlobalValue>(V);
3427 delete (yyvsp[-1].TypeVal); // Free the type handle
3428 CHECK_FOR_ERROR
3429 ;}
3430 break;
3431
3432 case 101:
Reid Spencere4f47592006-08-18 17:32:55 +00003433#line 1468 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003434 {
3435 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
3436 GEN_ERROR("Mismatched types for constant expression!");
3437 (yyval.ConstVal) = (yyvsp[0].ConstVal);
3438 delete (yyvsp[-1].TypeVal);
3439 CHECK_FOR_ERROR
3440 ;}
3441 break;
3442
3443 case 102:
Reid Spencere4f47592006-08-18 17:32:55 +00003444#line 1475 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003445 {
3446 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003447 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +00003448 GEN_ERROR("Cannot create a null initialized value of this type!");
3449 (yyval.ConstVal) = Constant::getNullValue(Ty);
3450 delete (yyvsp[-1].TypeVal);
3451 CHECK_FOR_ERROR
3452 ;}
3453 break;
3454
3455 case 103:
Reid Spencere4f47592006-08-18 17:32:55 +00003456#line 1484 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003457 { // integral constants
3458 if (!ConstantSInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
3459 GEN_ERROR("Constant value doesn't fit in type!");
3460 (yyval.ConstVal) = ConstantSInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
3461 CHECK_FOR_ERROR
3462 ;}
3463 break;
3464
3465 case 104:
Reid Spencere4f47592006-08-18 17:32:55 +00003466#line 1490 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003467 { // integral constants
3468 if (!ConstantUInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
3469 GEN_ERROR("Constant value doesn't fit in type!");
3470 (yyval.ConstVal) = ConstantUInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
3471 CHECK_FOR_ERROR
3472 ;}
3473 break;
3474
3475 case 105:
Reid Spencere4f47592006-08-18 17:32:55 +00003476#line 1496 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003477 { // Boolean constants
3478 (yyval.ConstVal) = ConstantBool::True;
3479 CHECK_FOR_ERROR
3480 ;}
3481 break;
3482
3483 case 106:
Reid Spencere4f47592006-08-18 17:32:55 +00003484#line 1500 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003485 { // Boolean constants
3486 (yyval.ConstVal) = ConstantBool::False;
3487 CHECK_FOR_ERROR
3488 ;}
3489 break;
3490
3491 case 107:
Reid Spencere4f47592006-08-18 17:32:55 +00003492#line 1504 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003493 { // Float & Double constants
3494 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
3495 GEN_ERROR("Floating point constant invalid for type!!");
3496 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
3497 CHECK_FOR_ERROR
3498 ;}
3499 break;
3500
3501 case 108:
Reid Spencere4f47592006-08-18 17:32:55 +00003502#line 1512 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003503 {
3504 if (!(yyvsp[-3].ConstVal)->getType()->isFirstClassType())
3505 GEN_ERROR("cast constant expression from a non-primitive type: '" +
3506 (yyvsp[-3].ConstVal)->getType()->getDescription() + "'!");
3507 if (!(yyvsp[-1].TypeVal)->get()->isFirstClassType())
3508 GEN_ERROR("cast constant expression to a non-primitive type: '" +
3509 (yyvsp[-1].TypeVal)->get()->getDescription() + "'!");
3510 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get());
3511 delete (yyvsp[-1].TypeVal);
3512 CHECK_FOR_ERROR
3513 ;}
3514 break;
3515
3516 case 109:
Reid Spencere4f47592006-08-18 17:32:55 +00003517#line 1523 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003518 {
3519 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
3520 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003521
3522 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3523 // indices to uint struct indices for compatibility.
3524 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer61c83e02006-08-18 08:43:06 +00003525 GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()),
3526 GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end());
3527 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003528 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer61c83e02006-08-18 08:43:06 +00003529 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003530 if (CUI->getType() == Type::UByteTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003531 (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003532
3533 const Type *IdxTy =
Reid Spencer61c83e02006-08-18 08:43:06 +00003534 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003535 if (!IdxTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003536 GEN_ERROR("Index list invalid for constant getelementptr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003537
3538 std::vector<Constant*> IdxVec;
Reid Spencer61c83e02006-08-18 08:43:06 +00003539 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
3540 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003541 IdxVec.push_back(C);
3542 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003543 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003544
Reid Spencer61c83e02006-08-18 08:43:06 +00003545 delete (yyvsp[-1].ValueList);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003546
Reid Spencer61c83e02006-08-18 08:43:06 +00003547 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
3548 CHECK_FOR_ERROR
3549 ;}
3550 break;
3551
3552 case 110:
Reid Spencere4f47592006-08-18 17:32:55 +00003553#line 1555 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003554 {
3555 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
3556 GEN_ERROR("Select condition must be of boolean type!");
3557 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3558 GEN_ERROR("Select operand types must match!");
3559 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3560 CHECK_FOR_ERROR
3561 ;}
3562 break;
3563
3564 case 111:
Reid Spencere4f47592006-08-18 17:32:55 +00003565#line 1563 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003566 {
3567 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3568 GEN_ERROR("Binary operator types must match!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003569 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3570 // To retain backward compatibility with these early compilers, we emit a
3571 // cast to the appropriate integer type automatically if we are in the
3572 // broken case. See PR424 for more information.
Reid Spencer61c83e02006-08-18 08:43:06 +00003573 if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) {
3574 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003575 } else {
3576 const Type *IntPtrTy = 0;
3577 switch (CurModule.CurrentModule->getPointerSize()) {
3578 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3579 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer61c83e02006-08-18 08:43:06 +00003580 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003581 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003582 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy),
3583 ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy));
3584 (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003585 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003586 CHECK_FOR_ERROR
3587 ;}
3588 break;
3589
3590 case 112:
Reid Spencere4f47592006-08-18 17:32:55 +00003591#line 1585 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003592 {
3593 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3594 GEN_ERROR("Logical operator types must match!");
3595 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
3596 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
3597 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
3598 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00003599 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003600 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3601 CHECK_FOR_ERROR
3602 ;}
3603 break;
3604
3605 case 113:
Reid Spencere4f47592006-08-18 17:32:55 +00003606#line 1596 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003607 {
3608 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3609 GEN_ERROR("setcc operand types must match!");
3610 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3611 CHECK_FOR_ERROR
3612 ;}
3613 break;
3614
3615 case 114:
Reid Spencere4f47592006-08-18 17:32:55 +00003616#line 1602 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003617 {
3618 if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy)
3619 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
3620 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
3621 GEN_ERROR("Shift constant expression requires integer operand!");
3622 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3623 CHECK_FOR_ERROR
3624 ;}
3625 break;
3626
3627 case 115:
Reid Spencere4f47592006-08-18 17:32:55 +00003628#line 1610 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003629 {
3630 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3631 GEN_ERROR("Invalid extractelement operands!");
3632 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3633 CHECK_FOR_ERROR
3634 ;}
3635 break;
3636
3637 case 116:
Reid Spencere4f47592006-08-18 17:32:55 +00003638#line 1616 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003639 {
3640 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3641 GEN_ERROR("Invalid insertelement operands!");
3642 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3643 CHECK_FOR_ERROR
3644 ;}
3645 break;
3646
3647 case 117:
Reid Spencere4f47592006-08-18 17:32:55 +00003648#line 1622 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003649 {
3650 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
3651 GEN_ERROR("Invalid shufflevector operands!");
3652 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3653 CHECK_FOR_ERROR
3654 ;}
3655 break;
3656
3657 case 118:
Reid Spencere4f47592006-08-18 17:32:55 +00003658#line 1631 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003659 {
3660 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
3661 CHECK_FOR_ERROR
3662 ;}
3663 break;
3664
3665 case 119:
Reid Spencere4f47592006-08-18 17:32:55 +00003666#line 1635 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003667 {
3668 (yyval.ConstVector) = new std::vector<Constant*>();
3669 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
3670 CHECK_FOR_ERROR
3671 ;}
3672 break;
3673
3674 case 120:
Reid Spencere4f47592006-08-18 17:32:55 +00003675#line 1643 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003676 { (yyval.BoolVal) = false; ;}
3677 break;
3678
3679 case 121:
Reid Spencere4f47592006-08-18 17:32:55 +00003680#line 1643 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003681 { (yyval.BoolVal) = true; ;}
3682 break;
3683
3684 case 122:
Reid Spencere4f47592006-08-18 17:32:55 +00003685#line 1653 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003686 {
3687 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003688 CurModule.ModuleDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003689 CHECK_FOR_ERROR
3690;}
3691 break;
3692
3693 case 123:
Reid Spencere4f47592006-08-18 17:32:55 +00003694#line 1661 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003695 {
3696 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003697 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003698 CHECK_FOR_ERROR
3699 ;}
3700 break;
3701
3702 case 124:
Reid Spencere4f47592006-08-18 17:32:55 +00003703#line 1666 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003704 {
3705 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
3706 CHECK_FOR_ERROR
3707 ;}
3708 break;
3709
3710 case 125:
Reid Spencere4f47592006-08-18 17:32:55 +00003711#line 1670 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003712 {
3713 (yyval.ModuleVal) = (yyvsp[-3].ModuleVal);
3714 CHECK_FOR_ERROR
3715 ;}
3716 break;
3717
3718 case 126:
Reid Spencere4f47592006-08-18 17:32:55 +00003719#line 1674 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003720 {
3721 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
3722 CHECK_FOR_ERROR
3723 ;}
3724 break;
3725
3726 case 127:
Reid Spencere4f47592006-08-18 17:32:55 +00003727#line 1678 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003728 {
3729 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003730 // Emit an error if there are any unresolved types left.
3731 if (!CurModule.LateResolveTypes.empty()) {
3732 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00003733 if (DID.Type == ValID::NameVal) {
3734 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3735 } else {
3736 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3737 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003738 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003739 CHECK_FOR_ERROR
3740 ;}
3741 break;
3742
3743 case 128:
Reid Spencere4f47592006-08-18 17:32:55 +00003744#line 1693 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003745 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003746 // Eagerly resolve types. This is not an optimization, this is a
3747 // requirement that is due to the fact that we could have this:
3748 //
3749 // %list = type { %list * }
3750 // %list = type { %list * } ; repeated type decl
3751 //
3752 // If types are not resolved eagerly, then the two types will not be
3753 // determined to be the same type!
3754 //
Reid Spencer61c83e02006-08-18 08:43:06 +00003755 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003756
Reid Spencer61c83e02006-08-18 08:43:06 +00003757 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003758 // If this is a named type that is not a redefinition, add it to the slot
3759 // table.
Reid Spencer61c83e02006-08-18 08:43:06 +00003760 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003761 }
3762
Reid Spencer61c83e02006-08-18 08:43:06 +00003763 delete (yyvsp[0].TypeVal);
3764 CHECK_FOR_ERROR
3765 ;}
3766 break;
3767
3768 case 129:
Reid Spencere4f47592006-08-18 17:32:55 +00003769#line 1714 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003770 { // Function prototypes can be in const pool
3771 CHECK_FOR_ERROR
3772 ;}
3773 break;
3774
3775 case 130:
Reid Spencere4f47592006-08-18 17:32:55 +00003776#line 1717 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003777 { // Asm blocks can be in the const pool
3778 CHECK_FOR_ERROR
3779 ;}
3780 break;
3781
3782 case 131:
Reid Spencere4f47592006-08-18 17:32:55 +00003783#line 1720 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003784 {
3785 if ((yyvsp[0].ConstVal) == 0) GEN_ERROR("Global value initializer is not a constant!");
3786 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
3787 ;}
3788 break;
3789
3790 case 132:
Reid Spencere4f47592006-08-18 17:32:55 +00003791#line 1723 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003792 {
Chris Lattnerb475c422005-11-12 18:22:38 +00003793 CurGV = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003794 CHECK_FOR_ERROR
3795 ;}
3796 break;
3797
3798 case 133:
Reid Spencere4f47592006-08-18 17:32:55 +00003799#line 1727 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003800 {
3801 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage,
3802 (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
3803 delete (yyvsp[0].TypeVal);
3804 ;}
3805 break;
3806
3807 case 134:
Reid Spencere4f47592006-08-18 17:32:55 +00003808#line 1731 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003809 {
Chris Lattnerb475c422005-11-12 18:22:38 +00003810 CurGV = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003811 CHECK_FOR_ERROR
3812 ;}
3813 break;
3814
3815 case 135:
Reid Spencere4f47592006-08-18 17:32:55 +00003816#line 1735 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003817 {
3818 CHECK_FOR_ERROR
3819 ;}
3820 break;
3821
3822 case 136:
Reid Spencere4f47592006-08-18 17:32:55 +00003823#line 1738 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003824 {
3825 CHECK_FOR_ERROR
3826 ;}
3827 break;
3828
3829 case 137:
Reid Spencere4f47592006-08-18 17:32:55 +00003830#line 1741 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003831 {
3832 ;}
3833 break;
3834
3835 case 138:
Reid Spencere4f47592006-08-18 17:32:55 +00003836#line 1745 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003837 {
Chris Lattner66316012006-01-24 04:14:29 +00003838 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer61c83e02006-08-18 08:43:06 +00003839 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3840 std::string NewAsm((yyvsp[0].StrVal), EndStr);
3841 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00003842
3843 if (AsmSoFar.empty())
3844 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3845 else
3846 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00003847 CHECK_FOR_ERROR
3848;}
3849 break;
3850
3851 case 139:
Reid Spencere4f47592006-08-18 17:32:55 +00003852#line 1758 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003853 { (yyval.Endianness) = Module::BigEndian; ;}
3854 break;
3855
3856 case 140:
Reid Spencere4f47592006-08-18 17:32:55 +00003857#line 1759 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003858 { (yyval.Endianness) = Module::LittleEndian; ;}
3859 break;
3860
3861 case 141:
Reid Spencere4f47592006-08-18 17:32:55 +00003862#line 1761 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003863 {
3864 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
3865 CHECK_FOR_ERROR
3866 ;}
3867 break;
3868
3869 case 142:
Reid Spencere4f47592006-08-18 17:32:55 +00003870#line 1765 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003871 {
3872 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003873 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Reid Spencer61c83e02006-08-18 08:43:06 +00003874 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003875 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3876 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003877 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
3878 CHECK_FOR_ERROR
3879 ;}
3880 break;
3881
3882 case 143:
Reid Spencere4f47592006-08-18 17:32:55 +00003883#line 1774 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003884 {
3885 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
3886 free((yyvsp[0].StrVal));
3887 CHECK_FOR_ERROR
3888 ;}
3889 break;
3890
3891 case 145:
Reid Spencere4f47592006-08-18 17:32:55 +00003892#line 1782 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003893 {
3894 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
3895 free((yyvsp[0].StrVal));
3896 CHECK_FOR_ERROR
3897 ;}
3898 break;
3899
3900 case 146:
Reid Spencere4f47592006-08-18 17:32:55 +00003901#line 1787 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003902 {
3903 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
3904 free((yyvsp[0].StrVal));
3905 CHECK_FOR_ERROR
3906 ;}
3907 break;
3908
3909 case 147:
Reid Spencere4f47592006-08-18 17:32:55 +00003910#line 1792 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003911 {
3912 CHECK_FOR_ERROR
3913 ;}
3914 break;
3915
3916 case 151:
Reid Spencere4f47592006-08-18 17:32:55 +00003917#line 1802 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003918 { (yyval.StrVal) = 0; ;}
3919 break;
3920
3921 case 152:
Reid Spencere4f47592006-08-18 17:32:55 +00003922#line 1804 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003923 {
3924 if (*(yyvsp[-1].TypeVal) == Type::VoidTy)
3925 GEN_ERROR("void typed arguments are invalid!");
3926 (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
3927 CHECK_FOR_ERROR
3928;}
3929 break;
3930
3931 case 153:
Reid Spencere4f47592006-08-18 17:32:55 +00003932#line 1811 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003933 {
3934 (yyval.ArgList) = (yyvsp[-2].ArgList);
3935 (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal));
3936 delete (yyvsp[0].ArgVal);
3937 CHECK_FOR_ERROR
3938 ;}
3939 break;
3940
3941 case 154:
Reid Spencere4f47592006-08-18 17:32:55 +00003942#line 1817 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003943 {
3944 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
3945 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
3946 delete (yyvsp[0].ArgVal);
3947 CHECK_FOR_ERROR
3948 ;}
3949 break;
3950
3951 case 155:
Reid Spencere4f47592006-08-18 17:32:55 +00003952#line 1824 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003953 {
3954 (yyval.ArgList) = (yyvsp[0].ArgList);
3955 CHECK_FOR_ERROR
3956 ;}
3957 break;
3958
3959 case 156:
Reid Spencere4f47592006-08-18 17:32:55 +00003960#line 1828 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003961 {
3962 (yyval.ArgList) = (yyvsp[-2].ArgList);
3963 (yyval.ArgList)->push_back(std::pair<PATypeHolder*,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003964 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer61c83e02006-08-18 08:43:06 +00003965 CHECK_FOR_ERROR
3966 ;}
3967 break;
3968
3969 case 157:
Reid Spencere4f47592006-08-18 17:32:55 +00003970#line 1834 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003971 {
3972 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
3973 (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
3974 CHECK_FOR_ERROR
3975 ;}
3976 break;
3977
3978 case 158:
Reid Spencere4f47592006-08-18 17:32:55 +00003979#line 1839 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003980 {
3981 (yyval.ArgList) = 0;
3982 CHECK_FOR_ERROR
3983 ;}
3984 break;
3985
3986 case 159:
Reid Spencere4f47592006-08-18 17:32:55 +00003987#line 1845 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00003988 {
3989 UnEscapeLexed((yyvsp[-5].StrVal));
3990 std::string FunctionName((yyvsp[-5].StrVal));
3991 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003992
Reid Spencer61c83e02006-08-18 08:43:06 +00003993 if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy)
3994 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003995
3996 std::vector<const Type*> ParamTypeList;
Reid Spencer61c83e02006-08-18 08:43:06 +00003997 if ((yyvsp[-3].ArgList)) { // If there are arguments...
3998 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
3999 I != (yyvsp[-3].ArgList)->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004000 ParamTypeList.push_back(I->first->get());
4001 }
4002
4003 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4004 if (isVarArg) ParamTypeList.pop_back();
4005
Reid Spencer61c83e02006-08-18 08:43:06 +00004006 const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004007 const PointerType *PFT = PointerType::get(FT);
Reid Spencer61c83e02006-08-18 08:43:06 +00004008 delete (yyvsp[-6].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004009
4010 ValID ID;
4011 if (!FunctionName.empty()) {
4012 ID = ValID::create((char*)FunctionName.c_str());
4013 } else {
4014 ID = ValID::create((int)CurModule.Values[PFT].size());
4015 }
4016
4017 Function *Fn = 0;
4018 // See if this function was forward referenced. If so, recycle the object.
4019 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4020 // Move the function to the end of the list, from whereever it was
4021 // previously inserted.
4022 Fn = cast<Function>(FWRef);
4023 CurModule.CurrentModule->getFunctionList().remove(Fn);
4024 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4025 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4026 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4027 // If this is the case, either we need to be a forward decl, or it needs
4028 // to be.
4029 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004030 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004031
4032 // Make sure to strip off any argument names so we can't get conflicts.
4033 if (Fn->isExternal())
4034 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4035 AI != AE; ++AI)
4036 AI->setName("");
4037
4038 } else { // Not already defined?
4039 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4040 CurModule.CurrentModule);
4041 InsertValue(Fn, CurModule.Values);
4042 }
4043
4044 CurFun.FunctionStart(Fn);
Reid Spencer61c83e02006-08-18 08:43:06 +00004045 Fn->setCallingConv((yyvsp[-7].UIntVal));
4046 Fn->setAlignment((yyvsp[0].UIntVal));
4047 if ((yyvsp[-1].StrVal)) {
4048 Fn->setSection((yyvsp[-1].StrVal));
4049 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004050 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004051
4052 // Add all of the arguments we parsed to the function...
Reid Spencer61c83e02006-08-18 08:43:06 +00004053 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004054 if (isVarArg) { // Nuke the last entry
Reid Spencer61c83e02006-08-18 08:43:06 +00004055 assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00004056 "Not a varargs marker!");
Reid Spencer61c83e02006-08-18 08:43:06 +00004057 delete (yyvsp[-3].ArgList)->back().first;
4058 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004059 }
4060 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer61c83e02006-08-18 08:43:06 +00004061 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4062 I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004063 delete I->first; // Delete the typeholder...
4064
4065 setValueName(ArgIt, I->second); // Insert arg into symtab...
4066 InsertValue(ArgIt);
4067 }
4068
Reid Spencer61c83e02006-08-18 08:43:06 +00004069 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004070 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004071 CHECK_FOR_ERROR
4072;}
4073 break;
4074
4075 case 162:
Reid Spencere4f47592006-08-18 17:32:55 +00004076#line 1933 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004077 {
4078 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004079
4080 // Make sure that we keep track of the linkage type even if there was a
4081 // previous "declare".
Reid Spencer61c83e02006-08-18 08:43:06 +00004082 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
4083;}
4084 break;
4085
4086 case 165:
Reid Spencere4f47592006-08-18 17:32:55 +00004087#line 1943 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004088 {
4089 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4090 CHECK_FOR_ERROR
4091;}
4092 break;
4093
4094 case 166:
Reid Spencere4f47592006-08-18 17:32:55 +00004095#line 1948 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004096 { CurFun.isDeclare = true; ;}
4097 break;
4098
4099 case 167:
Reid Spencere4f47592006-08-18 17:32:55 +00004100#line 1948 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004101 {
4102 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004103 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004104 CHECK_FOR_ERROR
4105;}
4106 break;
4107
4108 case 168:
Reid Spencere4f47592006-08-18 17:32:55 +00004109#line 1958 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004110 {
4111 (yyval.BoolVal) = false;
4112 CHECK_FOR_ERROR
4113 ;}
4114 break;
4115
4116 case 169:
Reid Spencere4f47592006-08-18 17:32:55 +00004117#line 1962 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004118 {
4119 (yyval.BoolVal) = true;
4120 CHECK_FOR_ERROR
4121 ;}
4122 break;
4123
4124 case 170:
Reid Spencere4f47592006-08-18 17:32:55 +00004125#line 1967 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004126 { // A reference to a direct constant
4127 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
4128 CHECK_FOR_ERROR
4129 ;}
4130 break;
4131
4132 case 171:
Reid Spencere4f47592006-08-18 17:32:55 +00004133#line 1971 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004134 {
4135 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
4136 CHECK_FOR_ERROR
4137 ;}
4138 break;
4139
4140 case 172:
Reid Spencere4f47592006-08-18 17:32:55 +00004141#line 1975 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004142 { // Perhaps it's an FP constant?
4143 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
4144 CHECK_FOR_ERROR
4145 ;}
4146 break;
4147
4148 case 173:
Reid Spencere4f47592006-08-18 17:32:55 +00004149#line 1979 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004150 {
4151 (yyval.ValIDVal) = ValID::create(ConstantBool::True);
4152 CHECK_FOR_ERROR
4153 ;}
4154 break;
4155
4156 case 174:
Reid Spencere4f47592006-08-18 17:32:55 +00004157#line 1983 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004158 {
4159 (yyval.ValIDVal) = ValID::create(ConstantBool::False);
4160 CHECK_FOR_ERROR
4161 ;}
4162 break;
4163
4164 case 175:
Reid Spencere4f47592006-08-18 17:32:55 +00004165#line 1987 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004166 {
4167 (yyval.ValIDVal) = ValID::createNull();
4168 CHECK_FOR_ERROR
4169 ;}
4170 break;
4171
4172 case 176:
Reid Spencere4f47592006-08-18 17:32:55 +00004173#line 1991 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004174 {
4175 (yyval.ValIDVal) = ValID::createUndef();
4176 CHECK_FOR_ERROR
4177 ;}
4178 break;
4179
4180 case 177:
Reid Spencere4f47592006-08-18 17:32:55 +00004181#line 1995 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004182 { // A vector zero constant.
4183 (yyval.ValIDVal) = ValID::createZeroInit();
4184 CHECK_FOR_ERROR
4185 ;}
4186 break;
4187
4188 case 178:
Reid Spencere4f47592006-08-18 17:32:55 +00004189#line 1999 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004190 { // Nonempty unsized packed vector
4191 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4192 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004193
4194 PackedType* pt = PackedType::get(ETy, NumElements);
4195 PATypeHolder* PTy = new PATypeHolder(
4196 HandleUpRefs(
4197 PackedType::get(
4198 ETy,
4199 NumElements)
4200 )
4201 );
4202
4203 // Verify all elements are correct type!
Reid Spencer61c83e02006-08-18 08:43:06 +00004204 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4205 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
4206 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004207 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer61c83e02006-08-18 08:43:06 +00004208 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004209 }
4210
Reid Spencer61c83e02006-08-18 08:43:06 +00004211 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4212 delete PTy; delete (yyvsp[-1].ConstVector);
4213 CHECK_FOR_ERROR
4214 ;}
4215 break;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004216
Reid Spencer61c83e02006-08-18 08:43:06 +00004217 case 179:
Reid Spencere4f47592006-08-18 17:32:55 +00004218#line 2024 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004219 {
4220 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
4221 CHECK_FOR_ERROR
4222 ;}
4223 break;
4224
4225 case 180:
Reid Spencere4f47592006-08-18 17:32:55 +00004226#line 2028 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004227 {
4228 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4229 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4230 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4231 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4232 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4233 free((yyvsp[-2].StrVal));
4234 free((yyvsp[0].StrVal));
4235 CHECK_FOR_ERROR
4236 ;}
4237 break;
4238
4239 case 181:
Reid Spencere4f47592006-08-18 17:32:55 +00004240#line 2042 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004241 { // Is it an integer reference...?
4242 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4243 CHECK_FOR_ERROR
4244 ;}
4245 break;
4246
4247 case 182:
Reid Spencere4f47592006-08-18 17:32:55 +00004248#line 2046 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004249 { // Is it a named reference...?
4250 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4251 CHECK_FOR_ERROR
4252 ;}
4253 break;
4254
4255 case 185:
Reid Spencere4f47592006-08-18 17:32:55 +00004256#line 2058 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004257 {
4258 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal);
4259 CHECK_FOR_ERROR
4260 ;}
4261 break;
4262
4263 case 186:
Reid Spencere4f47592006-08-18 17:32:55 +00004264#line 2063 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004265 {
4266 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4267 CHECK_FOR_ERROR
4268 ;}
4269 break;
4270
4271 case 187:
Reid Spencere4f47592006-08-18 17:32:55 +00004272#line 2067 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004273 { // Do not allow functions with 0 basic blocks
4274 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4275 CHECK_FOR_ERROR
4276 ;}
4277 break;
4278
4279 case 188:
Reid Spencere4f47592006-08-18 17:32:55 +00004280#line 2076 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004281 {
4282 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4283 InsertValue((yyvsp[0].TermInstVal));
4284
4285 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4286 InsertValue((yyvsp[-2].BasicBlockVal));
4287 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
4288 CHECK_FOR_ERROR
4289 ;}
4290 break;
4291
4292 case 189:
Reid Spencere4f47592006-08-18 17:32:55 +00004293#line 2086 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004294 {
4295 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4296 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
4297 CHECK_FOR_ERROR
4298 ;}
4299 break;
4300
4301 case 190:
Reid Spencere4f47592006-08-18 17:32:55 +00004302#line 2091 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004303 {
4304 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004305
4306 // Make sure to move the basic block to the correct location in the
4307 // function, instead of leaving it inserted wherever it was first
4308 // referenced.
4309 Function::BasicBlockListType &BBL =
4310 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer61c83e02006-08-18 08:43:06 +00004311 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
4312 CHECK_FOR_ERROR
4313 ;}
4314 break;
4315
4316 case 191:
Reid Spencere4f47592006-08-18 17:32:55 +00004317#line 2102 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004318 {
4319 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004320
4321 // Make sure to move the basic block to the correct location in the
4322 // function, instead of leaving it inserted wherever it was first
4323 // referenced.
4324 Function::BasicBlockListType &BBL =
4325 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer61c83e02006-08-18 08:43:06 +00004326 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
4327 CHECK_FOR_ERROR
4328 ;}
4329 break;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004330
Reid Spencer61c83e02006-08-18 08:43:06 +00004331 case 192:
Reid Spencere4f47592006-08-18 17:32:55 +00004332#line 2114 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004333 { // Return with a result...
4334 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4335 CHECK_FOR_ERROR
4336 ;}
4337 break;
4338
4339 case 193:
Reid Spencere4f47592006-08-18 17:32:55 +00004340#line 2118 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004341 { // Return with no result...
4342 (yyval.TermInstVal) = new ReturnInst();
4343 CHECK_FOR_ERROR
4344 ;}
4345 break;
4346
4347 case 194:
Reid Spencere4f47592006-08-18 17:32:55 +00004348#line 2122 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004349 { // Unconditional Branch...
4350 (yyval.TermInstVal) = new BranchInst(getBBVal((yyvsp[0].ValIDVal)));
4351 CHECK_FOR_ERROR
4352 ;}
4353 break;
4354
4355 case 195:
Reid Spencere4f47592006-08-18 17:32:55 +00004356#line 2126 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004357 {
4358 (yyval.TermInstVal) = new BranchInst(getBBVal((yyvsp[-3].ValIDVal)), getBBVal((yyvsp[0].ValIDVal)), getVal(Type::BoolTy, (yyvsp[-6].ValIDVal)));
4359 CHECK_FOR_ERROR
4360 ;}
4361 break;
4362
4363 case 196:
Reid Spencere4f47592006-08-18 17:32:55 +00004364#line 2130 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004365 {
4366 SwitchInst *S = new SwitchInst(getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)), getBBVal((yyvsp[-3].ValIDVal)), (yyvsp[-1].JumpTable)->size());
4367 (yyval.TermInstVal) = S;
4368
4369 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4370 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004371 for (; I != E; ++I) {
4372 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4373 S->addCase(CI, I->second);
4374 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004375 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004376 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004377 delete (yyvsp[-1].JumpTable);
4378 CHECK_FOR_ERROR
4379 ;}
4380 break;
4381
4382 case 197:
Reid Spencere4f47592006-08-18 17:32:55 +00004383#line 2145 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004384 {
4385 SwitchInst *S = new SwitchInst(getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)), getBBVal((yyvsp[-2].ValIDVal)), 0);
4386 (yyval.TermInstVal) = S;
4387 CHECK_FOR_ERROR
4388 ;}
4389 break;
4390
4391 case 198:
Reid Spencere4f47592006-08-18 17:32:55 +00004392#line 2151 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004393 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004394 const PointerType *PFTy;
4395 const FunctionType *Ty;
4396
Reid Spencer61c83e02006-08-18 08:43:06 +00004397 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004398 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4399 // Pull out the types of all of the arguments...
4400 std::vector<const Type*> ParamTypes;
Reid Spencer61c83e02006-08-18 08:43:06 +00004401 if ((yyvsp[-7].ValueList)) {
4402 for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004403 I != E; ++I)
4404 ParamTypes.push_back((*I)->getType());
4405 }
4406
4407 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4408 if (isVarArg) ParamTypes.pop_back();
4409
Reid Spencer61c83e02006-08-18 08:43:06 +00004410 Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004411 PFTy = PointerType::get(Ty);
4412 }
4413
Reid Spencer61c83e02006-08-18 08:43:06 +00004414 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004415
Reid Spencer61c83e02006-08-18 08:43:06 +00004416 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
4417 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004418
4419 // Create the call node...
Reid Spencer61c83e02006-08-18 08:43:06 +00004420 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
4421 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004422 } else { // Has arguments?
4423 // Loop through FunctionType's arguments and ensure they are specified
4424 // correctly!
4425 //
4426 FunctionType::param_iterator I = Ty->param_begin();
4427 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer61c83e02006-08-18 08:43:06 +00004428 std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004429
4430 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4431 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00004432 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004433 (*I)->getDescription() + "'!");
4434
4435 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004436 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004437
Reid Spencer61c83e02006-08-18 08:43:06 +00004438 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004439 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004440 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004441
Reid Spencer61c83e02006-08-18 08:43:06 +00004442 delete (yyvsp[-10].TypeVal);
4443 delete (yyvsp[-7].ValueList);
4444 CHECK_FOR_ERROR
4445 ;}
4446 break;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004447
Reid Spencer61c83e02006-08-18 08:43:06 +00004448 case 199:
Reid Spencere4f47592006-08-18 17:32:55 +00004449#line 2204 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004450 {
4451 (yyval.TermInstVal) = new UnwindInst();
4452 CHECK_FOR_ERROR
4453 ;}
4454 break;
4455
4456 case 200:
Reid Spencere4f47592006-08-18 17:32:55 +00004457#line 2208 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004458 {
4459 (yyval.TermInstVal) = new UnreachableInst();
4460 CHECK_FOR_ERROR
4461 ;}
4462 break;
4463
4464 case 201:
Reid Spencere4f47592006-08-18 17:32:55 +00004465#line 2215 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004466 {
4467 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
4468 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
4469 if (V == 0)
4470 GEN_ERROR("May only switch on a constant pool value!");
4471
4472 (yyval.JumpTable)->push_back(std::make_pair(V, getBBVal((yyvsp[0].ValIDVal))));
4473 CHECK_FOR_ERROR
4474 ;}
4475 break;
4476
4477 case 202:
Reid Spencere4f47592006-08-18 17:32:55 +00004478#line 2224 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004479 {
4480 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
4481 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004482
4483 if (V == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004484 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004485
Reid Spencer61c83e02006-08-18 08:43:06 +00004486 (yyval.JumpTable)->push_back(std::make_pair(V, getBBVal((yyvsp[0].ValIDVal))));
4487 CHECK_FOR_ERROR
4488 ;}
4489 break;
4490
4491 case 203:
Reid Spencere4f47592006-08-18 17:32:55 +00004492#line 2235 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004493 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004494 // Is this definition named?? if so, assign the name...
Reid Spencer61c83e02006-08-18 08:43:06 +00004495 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
4496 InsertValue((yyvsp[0].InstVal));
4497 (yyval.InstVal) = (yyvsp[0].InstVal);
4498 CHECK_FOR_ERROR
4499;}
4500 break;
4501
4502 case 204:
Reid Spencere4f47592006-08-18 17:32:55 +00004503#line 2243 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004504 { // Used for PHI nodes
4505 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
4506 (yyval.PHIList)->push_back(std::make_pair(getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)), getBBVal((yyvsp[-1].ValIDVal))));
4507 delete (yyvsp[-5].TypeVal);
4508 CHECK_FOR_ERROR
4509 ;}
4510 break;
4511
4512 case 205:
Reid Spencere4f47592006-08-18 17:32:55 +00004513#line 2249 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004514 {
4515 (yyval.PHIList) = (yyvsp[-6].PHIList);
4516 (yyvsp[-6].PHIList)->push_back(std::make_pair(getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)),
4517 getBBVal((yyvsp[-1].ValIDVal))));
4518 CHECK_FOR_ERROR
4519 ;}
4520 break;
4521
4522 case 206:
Reid Spencere4f47592006-08-18 17:32:55 +00004523#line 2257 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004524 { // Used for call statements, and memory insts...
4525 (yyval.ValueList) = new std::vector<Value*>();
4526 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
4527 CHECK_FOR_ERROR
4528 ;}
4529 break;
4530
4531 case 207:
Reid Spencere4f47592006-08-18 17:32:55 +00004532#line 2262 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004533 {
4534 (yyval.ValueList) = (yyvsp[-2].ValueList);
4535 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
4536 CHECK_FOR_ERROR
4537 ;}
4538 break;
4539
4540 case 209:
Reid Spencere4f47592006-08-18 17:32:55 +00004541#line 2269 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004542 { (yyval.ValueList) = 0; ;}
4543 break;
4544
4545 case 210:
Reid Spencere4f47592006-08-18 17:32:55 +00004546#line 2271 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004547 {
4548 (yyval.BoolVal) = true;
4549 CHECK_FOR_ERROR
4550 ;}
4551 break;
4552
4553 case 211:
Reid Spencere4f47592006-08-18 17:32:55 +00004554#line 2275 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004555 {
4556 (yyval.BoolVal) = false;
4557 CHECK_FOR_ERROR
4558 ;}
4559 break;
4560
4561 case 212:
Reid Spencere4f47592006-08-18 17:32:55 +00004562#line 2282 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004563 {
4564 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
4565 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
4566 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004567 "Arithmetic operator requires integer, FP, or packed operands!");
Reid Spencer61c83e02006-08-18 08:43:06 +00004568 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) && (yyvsp[-4].BinaryOpVal) == Instruction::Rem)
4569 GEN_ERROR("Rem not supported on packed types!");
4570 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)), getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)));
4571 if ((yyval.InstVal) == 0)
4572 GEN_ERROR("binary operator returned null!");
4573 delete (yyvsp[-3].TypeVal);
4574 CHECK_FOR_ERROR
4575 ;}
4576 break;
4577
4578 case 213:
Reid Spencere4f47592006-08-18 17:32:55 +00004579#line 2295 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004580 {
4581 if (!(*(yyvsp[-3].TypeVal))->isIntegral()) {
4582 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
4583 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral())
4584 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00004585 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004586 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)), getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)));
4587 if ((yyval.InstVal) == 0)
4588 GEN_ERROR("binary operator returned null!");
4589 delete (yyvsp[-3].TypeVal);
4590 CHECK_FOR_ERROR
4591 ;}
4592 break;
4593
4594 case 214:
Reid Spencere4f47592006-08-18 17:32:55 +00004595#line 2307 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004596 {
4597 if(isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) {
4598 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004599 "PackedTypes currently not supported in setcc instructions!");
4600 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004601 (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal), getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)), getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)));
4602 if ((yyval.InstVal) == 0)
4603 GEN_ERROR("binary operator returned null!");
4604 delete (yyvsp[-3].TypeVal);
4605 CHECK_FOR_ERROR
4606 ;}
4607 break;
4608
4609 case 215:
Reid Spencere4f47592006-08-18 17:32:55 +00004610#line 2318 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004611 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004612 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4613 << " Replacing with 'xor'.\n";
4614
Reid Spencer61c83e02006-08-18 08:43:06 +00004615 Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004616 if (Ones == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004617 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004618
Reid Spencer61c83e02006-08-18 08:43:06 +00004619 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
4620 if ((yyval.InstVal) == 0)
4621 GEN_ERROR("Could not create a xor instruction!");
4622 CHECK_FOR_ERROR
4623 ;}
4624 break;
4625
4626 case 216:
Reid Spencere4f47592006-08-18 17:32:55 +00004627#line 2331 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004628 {
4629 if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy)
4630 GEN_ERROR("Shift amount must be ubyte!");
4631 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
4632 GEN_ERROR("Shift constant expression requires integer operand!");
4633 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
4634 CHECK_FOR_ERROR
4635 ;}
4636 break;
4637
4638 case 217:
Reid Spencere4f47592006-08-18 17:32:55 +00004639#line 2339 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004640 {
4641 if (!(yyvsp[0].TypeVal)->get()->isFirstClassType())
4642 GEN_ERROR("cast instruction to a non-primitive type: '" +
4643 (yyvsp[0].TypeVal)->get()->getDescription() + "'!");
4644 (yyval.InstVal) = new CastInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
4645 delete (yyvsp[0].TypeVal);
4646 CHECK_FOR_ERROR
4647 ;}
4648 break;
4649
4650 case 218:
Reid Spencere4f47592006-08-18 17:32:55 +00004651#line 2347 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004652 {
4653 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
4654 GEN_ERROR("select condition must be boolean!");
4655 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
4656 GEN_ERROR("select value types should match!");
4657 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
4658 CHECK_FOR_ERROR
4659 ;}
4660 break;
4661
4662 case 219:
Reid Spencere4f47592006-08-18 17:32:55 +00004663#line 2355 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004664 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004665 NewVarArgs = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004666 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
4667 delete (yyvsp[0].TypeVal);
4668 CHECK_FOR_ERROR
4669 ;}
4670 break;
4671
4672 case 220:
Reid Spencere4f47592006-08-18 17:32:55 +00004673#line 2361 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004674 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004675 ObsoleteVarArgs = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004676 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004677 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004678 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004679
4680 //b = vaarg a, t ->
4681 //foo = alloca 1 of t
4682 //bar = vacopy a
4683 //store bar -> foo
4684 //b = vaarg foo, t
4685 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4686 CurBB->getInstList().push_back(foo);
Reid Spencer61c83e02006-08-18 08:43:06 +00004687 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004688 CurBB->getInstList().push_back(bar);
4689 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer61c83e02006-08-18 08:43:06 +00004690 (yyval.InstVal) = new VAArgInst(foo, *(yyvsp[0].TypeVal));
4691 delete (yyvsp[0].TypeVal);
4692 CHECK_FOR_ERROR
4693 ;}
4694 break;
4695
4696 case 221:
Reid Spencere4f47592006-08-18 17:32:55 +00004697#line 2381 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004698 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004699 ObsoleteVarArgs = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004700 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004701 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004702 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004703
4704 //b = vanext a, t ->
4705 //foo = alloca 1 of t
4706 //bar = vacopy a
4707 //store bar -> foo
4708 //tmp = vaarg foo, t
4709 //b = load foo
4710 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4711 CurBB->getInstList().push_back(foo);
Reid Spencer61c83e02006-08-18 08:43:06 +00004712 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004713 CurBB->getInstList().push_back(bar);
4714 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer61c83e02006-08-18 08:43:06 +00004715 Instruction* tmp = new VAArgInst(foo, *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004716 CurBB->getInstList().push_back(tmp);
Reid Spencer61c83e02006-08-18 08:43:06 +00004717 (yyval.InstVal) = new LoadInst(foo);
4718 delete (yyvsp[0].TypeVal);
4719 CHECK_FOR_ERROR
4720 ;}
4721 break;
4722
4723 case 222:
Reid Spencere4f47592006-08-18 17:32:55 +00004724#line 2404 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004725 {
4726 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
4727 GEN_ERROR("Invalid extractelement operands!");
4728 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
4729 CHECK_FOR_ERROR
4730 ;}
4731 break;
4732
4733 case 223:
Reid Spencere4f47592006-08-18 17:32:55 +00004734#line 2410 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004735 {
4736 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
4737 GEN_ERROR("Invalid insertelement operands!");
4738 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
4739 CHECK_FOR_ERROR
4740 ;}
4741 break;
4742
4743 case 224:
Reid Spencere4f47592006-08-18 17:32:55 +00004744#line 2416 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004745 {
4746 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
4747 GEN_ERROR("Invalid shufflevector operands!");
4748 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
4749 CHECK_FOR_ERROR
4750 ;}
4751 break;
4752
4753 case 225:
Reid Spencere4f47592006-08-18 17:32:55 +00004754#line 2422 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004755 {
4756 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004757 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004758 GEN_ERROR("PHI node operands must be of first class type!");
4759 (yyval.InstVal) = new PHINode(Ty);
4760 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
4761 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
4762 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
4763 GEN_ERROR("All elements of a PHI node must be of the same type!");
4764 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
4765 (yyvsp[0].PHIList)->pop_front();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004766 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004767 delete (yyvsp[0].PHIList); // Free the list...
4768 CHECK_FOR_ERROR
4769 ;}
4770 break;
4771
4772 case 226:
Reid Spencere4f47592006-08-18 17:32:55 +00004773#line 2437 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004774 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004775 const PointerType *PFTy;
4776 const FunctionType *Ty;
4777
Reid Spencer61c83e02006-08-18 08:43:06 +00004778 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004779 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4780 // Pull out the types of all of the arguments...
4781 std::vector<const Type*> ParamTypes;
Reid Spencer61c83e02006-08-18 08:43:06 +00004782 if ((yyvsp[-1].ValueList)) {
4783 for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004784 I != E; ++I)
4785 ParamTypes.push_back((*I)->getType());
4786 }
4787
4788 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4789 if (isVarArg) ParamTypes.pop_back();
4790
Reid Spencer61c83e02006-08-18 08:43:06 +00004791 if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy)
4792 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004793
Reid Spencer61c83e02006-08-18 08:43:06 +00004794 Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004795 PFTy = PointerType::get(Ty);
4796 }
4797
Reid Spencer61c83e02006-08-18 08:43:06 +00004798 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004799
4800 // Create the call node...
Reid Spencer61c83e02006-08-18 08:43:06 +00004801 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer68a24bd2005-08-27 18:50:39 +00004802 // Make sure no arguments is a good thing!
4803 if (Ty->getNumParams() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004804 GEN_ERROR("No arguments passed to a function that "
Reid Spencer68a24bd2005-08-27 18:50:39 +00004805 "expects arguments!");
4806
Reid Spencer61c83e02006-08-18 08:43:06 +00004807 (yyval.InstVal) = new CallInst(V, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004808 } else { // Has arguments?
4809 // Loop through FunctionType's arguments and ensure they are specified
4810 // correctly!
4811 //
4812 FunctionType::param_iterator I = Ty->param_begin();
4813 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer61c83e02006-08-18 08:43:06 +00004814 std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004815
4816 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4817 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00004818 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004819 (*I)->getDescription() + "'!");
4820
4821 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004822 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004823
Reid Spencer61c83e02006-08-18 08:43:06 +00004824 (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004825 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004826 cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal));
4827 cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal));
4828 delete (yyvsp[-4].TypeVal);
4829 delete (yyvsp[-1].ValueList);
4830 CHECK_FOR_ERROR
4831 ;}
4832 break;
4833
4834 case 227:
Reid Spencere4f47592006-08-18 17:32:55 +00004835#line 2495 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004836 {
4837 (yyval.InstVal) = (yyvsp[0].InstVal);
4838 CHECK_FOR_ERROR
4839 ;}
4840 break;
4841
4842 case 228:
Reid Spencere4f47592006-08-18 17:32:55 +00004843#line 2502 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004844 {
4845 (yyval.ValueList) = (yyvsp[0].ValueList);
4846 CHECK_FOR_ERROR
4847 ;}
4848 break;
4849
4850 case 229:
Reid Spencere4f47592006-08-18 17:32:55 +00004851#line 2505 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004852 {
4853 (yyval.ValueList) = new std::vector<Value*>();
4854 CHECK_FOR_ERROR
4855 ;}
4856 break;
4857
4858 case 230:
Reid Spencere4f47592006-08-18 17:32:55 +00004859#line 2510 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004860 {
4861 (yyval.BoolVal) = true;
4862 CHECK_FOR_ERROR
4863 ;}
4864 break;
4865
4866 case 231:
Reid Spencere4f47592006-08-18 17:32:55 +00004867#line 2514 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004868 {
4869 (yyval.BoolVal) = false;
4870 CHECK_FOR_ERROR
4871 ;}
4872 break;
4873
4874 case 232:
Reid Spencere4f47592006-08-18 17:32:55 +00004875#line 2521 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004876 {
4877 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
4878 delete (yyvsp[-1].TypeVal);
4879 CHECK_FOR_ERROR
4880 ;}
4881 break;
4882
4883 case 233:
Reid Spencere4f47592006-08-18 17:32:55 +00004884#line 2526 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004885 {
4886 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
4887 delete (yyvsp[-4].TypeVal);
4888 CHECK_FOR_ERROR
4889 ;}
4890 break;
4891
4892 case 234:
Reid Spencere4f47592006-08-18 17:32:55 +00004893#line 2531 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004894 {
4895 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
4896 delete (yyvsp[-1].TypeVal);
4897 CHECK_FOR_ERROR
4898 ;}
4899 break;
4900
4901 case 235:
Reid Spencere4f47592006-08-18 17:32:55 +00004902#line 2536 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004903 {
4904 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)), (yyvsp[0].UIntVal));
4905 delete (yyvsp[-4].TypeVal);
4906 CHECK_FOR_ERROR
4907 ;}
4908 break;
4909
4910 case 236:
Reid Spencere4f47592006-08-18 17:32:55 +00004911#line 2541 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004912 {
4913 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
4914 GEN_ERROR("Trying to free nonpointer type " +
4915 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
4916 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
4917 CHECK_FOR_ERROR
4918 ;}
4919 break;
4920
4921 case 237:
Reid Spencere4f47592006-08-18 17:32:55 +00004922#line 2549 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004923 {
4924 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
4925 GEN_ERROR("Can't load from nonpointer type: " +
4926 (*(yyvsp[-1].TypeVal))->getDescription());
4927 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
4928 GEN_ERROR("Can't load from pointer of non-first-class type: " +
4929 (*(yyvsp[-1].TypeVal))->getDescription());
4930 (yyval.InstVal) = new LoadInst(getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)), "", (yyvsp[-3].BoolVal));
4931 delete (yyvsp[-1].TypeVal);
4932 CHECK_FOR_ERROR
4933 ;}
4934 break;
4935
4936 case 238:
Reid Spencere4f47592006-08-18 17:32:55 +00004937#line 2560 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004938 {
4939 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004940 if (!PT)
Reid Spencer61c83e02006-08-18 08:43:06 +00004941 GEN_ERROR("Can't store to a nonpointer type: " +
4942 (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004943 const Type *ElTy = PT->getElementType();
Reid Spencer61c83e02006-08-18 08:43:06 +00004944 if (ElTy != (yyvsp[-3].ValueVal)->getType())
4945 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004946 "' into space of type '" + ElTy->getDescription() + "'!");
4947
Reid Spencer61c83e02006-08-18 08:43:06 +00004948 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)), (yyvsp[-5].BoolVal));
4949 delete (yyvsp[-1].TypeVal);
4950 CHECK_FOR_ERROR
4951 ;}
4952 break;
4953
4954 case 239:
Reid Spencere4f47592006-08-18 17:32:55 +00004955#line 2574 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004956 {
4957 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
4958 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004959
4960 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4961 // indices to uint struct indices for compatibility.
4962 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer61c83e02006-08-18 08:43:06 +00004963 GTI = gep_type_begin((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()),
4964 GTE = gep_type_end((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end());
4965 for (unsigned i = 0, e = (yyvsp[0].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004966 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer61c83e02006-08-18 08:43:06 +00004967 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*(yyvsp[0].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00004968 if (CUI->getType() == Type::UByteTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004969 (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004970
Reid Spencer61c83e02006-08-18 08:43:06 +00004971 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
4972 GEN_ERROR("Invalid getelementptr indices for type '" +
4973 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
4974 (yyval.InstVal) = new GetElementPtrInst(getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal)), *(yyvsp[0].ValueList));
4975 delete (yyvsp[-2].TypeVal); delete (yyvsp[0].ValueList);
4976 CHECK_FOR_ERROR
4977 ;}
4978 break;
4979
4980
4981 default: break;
4982 }
4983
4984/* Line 1126 of yacc.c. */
Reid Spencere4f47592006-08-18 17:32:55 +00004985#line 4986 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00004986
4987 yyvsp -= yylen;
4988 yyssp -= yylen;
4989
Reid Spencer61c83e02006-08-18 08:43:06 +00004990
4991 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004992
4993 *++yyvsp = yyval;
4994
4995
Reid Spencer61c83e02006-08-18 08:43:06 +00004996 /* Now `shift' the result of the reduction. Determine what state
4997 that goes to, based on the state we popped back to and the rule
4998 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004999
5000 yyn = yyr1[yyn];
5001
Reid Spencer61c83e02006-08-18 08:43:06 +00005002 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5003 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005004 yystate = yytable[yystate];
5005 else
Reid Spencer61c83e02006-08-18 08:43:06 +00005006 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005007
5008 goto yynewstate;
5009
5010
Reid Spencer61c83e02006-08-18 08:43:06 +00005011/*------------------------------------.
5012| yyerrlab -- here on detecting error |
5013`------------------------------------*/
5014yyerrlab:
5015 /* If not already recovering from an error, report this error. */
5016 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005017 {
5018 ++yynerrs;
Reid Spencer61c83e02006-08-18 08:43:06 +00005019#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00005020 yyn = yypact[yystate];
5021
Reid Spencer61c83e02006-08-18 08:43:06 +00005022 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005023 {
Reid Spencer61c83e02006-08-18 08:43:06 +00005024 int yytype = YYTRANSLATE (yychar);
5025 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5026 YYSIZE_T yysize = yysize0;
5027 YYSIZE_T yysize1;
5028 int yysize_overflow = 0;
5029 char *yymsg = 0;
5030# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5031 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5032 int yyx;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005033
Reid Spencer61c83e02006-08-18 08:43:06 +00005034#if 0
5035 /* This is so xgettext sees the translatable formats that are
5036 constructed on the fly. */
5037 YY_("syntax error, unexpected %s");
5038 YY_("syntax error, unexpected %s, expecting %s");
5039 YY_("syntax error, unexpected %s, expecting %s or %s");
5040 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5041 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5042#endif
5043 char *yyfmt;
5044 char const *yyf;
5045 static char const yyunexpected[] = "syntax error, unexpected %s";
5046 static char const yyexpecting[] = ", expecting %s";
5047 static char const yyor[] = " or %s";
5048 char yyformat[sizeof yyunexpected
5049 + sizeof yyexpecting - 1
5050 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5051 * (sizeof yyor - 1))];
5052 char const *yyprefix = yyexpecting;
5053
5054 /* Start YYX at -YYN if negative to avoid negative indexes in
5055 YYCHECK. */
5056 int yyxbegin = yyn < 0 ? -yyn : 0;
5057
5058 /* Stay within bounds of both yycheck and yytname. */
5059 int yychecklim = YYLAST - yyn;
5060 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5061 int yycount = 1;
5062
5063 yyarg[0] = yytname[yytype];
5064 yyfmt = yystpcpy (yyformat, yyunexpected);
5065
5066 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5067 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5068 {
5069 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5070 {
5071 yycount = 1;
5072 yysize = yysize0;
5073 yyformat[sizeof yyunexpected - 1] = '\0';
5074 break;
5075 }
5076 yyarg[yycount++] = yytname[yyx];
5077 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5078 yysize_overflow |= yysize1 < yysize;
5079 yysize = yysize1;
5080 yyfmt = yystpcpy (yyfmt, yyprefix);
5081 yyprefix = yyor;
5082 }
5083
5084 yyf = YY_(yyformat);
5085 yysize1 = yysize + yystrlen (yyf);
5086 yysize_overflow |= yysize1 < yysize;
5087 yysize = yysize1;
5088
5089 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5090 yymsg = (char *) YYSTACK_ALLOC (yysize);
5091 if (yymsg)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005092 {
Reid Spencer61c83e02006-08-18 08:43:06 +00005093 /* Avoid sprintf, as that infringes on the user's name space.
5094 Don't have undefined behavior even if the translation
5095 produced a string with the wrong number of "%s"s. */
5096 char *yyp = yymsg;
5097 int yyi = 0;
5098 while ((*yyp = *yyf))
Reid Spencer68a24bd2005-08-27 18:50:39 +00005099 {
Reid Spencer61c83e02006-08-18 08:43:06 +00005100 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5101 {
5102 yyp += yytnamerr (yyp, yyarg[yyi++]);
5103 yyf += 2;
5104 }
5105 else
5106 {
5107 yyp++;
5108 yyf++;
5109 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005110 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005111 yyerror (yymsg);
5112 YYSTACK_FREE (yymsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005113 }
5114 else
Reid Spencer61c83e02006-08-18 08:43:06 +00005115 {
5116 yyerror (YY_("syntax error"));
5117 goto yyexhaustedlab;
5118 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00005119 }
5120 else
5121#endif /* YYERROR_VERBOSE */
Reid Spencer61c83e02006-08-18 08:43:06 +00005122 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005123 }
5124
Reid Spencer61c83e02006-08-18 08:43:06 +00005125
Reid Spencer68a24bd2005-08-27 18:50:39 +00005126
5127 if (yyerrstatus == 3)
5128 {
Reid Spencer61c83e02006-08-18 08:43:06 +00005129 /* If just tried and failed to reuse look-ahead token after an
5130 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005131
Reid Spencer61c83e02006-08-18 08:43:06 +00005132 if (yychar <= YYEOF)
5133 {
5134 /* Return failure if at end of input. */
5135 if (yychar == YYEOF)
5136 YYABORT;
5137 }
5138 else
5139 {
5140 yydestruct ("Error: discarding", yytoken, &yylval);
5141 yychar = YYEMPTY;
5142 }
5143 }
5144
5145 /* Else will try to reuse look-ahead token after shifting the error
5146 token. */
5147 goto yyerrlab1;
5148
5149
5150/*---------------------------------------------------.
5151| yyerrorlab -- error raised explicitly by YYERROR. |
5152`---------------------------------------------------*/
5153yyerrorlab:
5154
5155 /* Pacify compilers like GCC when the user code never invokes
5156 YYERROR and the label yyerrorlab therefore never appears in user
5157 code. */
5158 if (0)
5159 goto yyerrorlab;
5160
5161yyvsp -= yylen;
5162 yyssp -= yylen;
5163 yystate = *yyssp;
5164 goto yyerrlab1;
5165
5166
5167/*-------------------------------------------------------------.
5168| yyerrlab1 -- common code for both syntax error and YYERROR. |
5169`-------------------------------------------------------------*/
5170yyerrlab1:
5171 yyerrstatus = 3; /* Each real token shifted decrements this. */
5172
5173 for (;;)
5174 {
5175 yyn = yypact[yystate];
5176 if (yyn != YYPACT_NINF)
5177 {
5178 yyn += YYTERROR;
5179 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5180 {
5181 yyn = yytable[yyn];
5182 if (0 < yyn)
5183 break;
5184 }
5185 }
5186
5187 /* Pop the current state because it cannot handle the error token. */
5188 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005189 YYABORT;
5190
Chris Lattner8335e842006-01-23 23:05:42 +00005191
Reid Spencer61c83e02006-08-18 08:43:06 +00005192 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5193 YYPOPSTACK;
5194 yystate = *yyssp;
5195 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005196 }
5197
5198 if (yyn == YYFINAL)
5199 YYACCEPT;
5200
Reid Spencer68a24bd2005-08-27 18:50:39 +00005201 *++yyvsp = yylval;
Reid Spencer61c83e02006-08-18 08:43:06 +00005202
5203
5204 /* Shift the error token. */
5205 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005206
5207 yystate = yyn;
5208 goto yynewstate;
5209
Reid Spencere812fb22006-01-19 01:21:04 +00005210
Reid Spencer61c83e02006-08-18 08:43:06 +00005211/*-------------------------------------.
5212| yyacceptlab -- YYACCEPT comes here. |
5213`-------------------------------------*/
5214yyacceptlab:
5215 yyresult = 0;
5216 goto yyreturn;
5217
5218/*-----------------------------------.
5219| yyabortlab -- YYABORT comes here. |
5220`-----------------------------------*/
5221yyabortlab:
5222 yyresult = 1;
5223 goto yyreturn;
5224
5225#ifndef yyoverflow
5226/*-------------------------------------------------.
5227| yyexhaustedlab -- memory exhaustion comes here. |
5228`-------------------------------------------------*/
5229yyexhaustedlab:
5230 yyerror (YY_("memory exhausted"));
5231 yyresult = 2;
5232 /* Fall through. */
Reid Spencere812fb22006-01-19 01:21:04 +00005233#endif
Reid Spencer61c83e02006-08-18 08:43:06 +00005234
5235yyreturn:
5236 if (yychar != YYEOF && yychar != YYEMPTY)
5237 yydestruct ("Cleanup: discarding lookahead",
5238 yytoken, &yylval);
5239 while (yyssp != yyss)
5240 {
5241 yydestruct ("Cleanup: popping",
5242 yystos[*yyssp], yyvsp);
5243 YYPOPSTACK;
Chris Lattner8335e842006-01-23 23:05:42 +00005244 }
Reid Spencer61c83e02006-08-18 08:43:06 +00005245#ifndef yyoverflow
5246 if (yyss != yyssa)
5247 YYSTACK_FREE (yyss);
5248#endif
5249 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005250}
Reid Spencer61c83e02006-08-18 08:43:06 +00005251
5252
Reid Spencere4f47592006-08-18 17:32:55 +00005253#line 2598 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005254
5255
5256void llvm::GenerateError(const std::string &message, int LineNo) {
5257 if (LineNo == -1) LineNo = llvmAsmlineno;
5258 // TODO: column number in exception
5259 if (TheParseError)
5260 TheParseError->setError(CurFilename, message, LineNo);
5261 TriggerError = 1;
5262}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005263
5264int yyerror(const char *ErrorMsg) {
5265 std::string where
5266 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5267 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5268 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5269 if (yychar == YYEMPTY || yychar == 0)
5270 errMsg += "end-of-file.";
5271 else
5272 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005273 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005274 return 0;
5275}
Reid Spencer61c83e02006-08-18 08:43:06 +00005276