blob: 0cac3c82334c6ad170a9848c639bd38f97b0c93a [file] [log] [blame]
Reid Spencer309080a2006-09-28 19:28:24 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002
Reid Spencer309080a2006-09-28 19:28:24 +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 Spencerdfb3fb42005-08-27 18:50:39 +00005
Anton Korobeynikov73441cd2006-09-14 18:25:26 +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.
10
11 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
Reid Spencer309080a2006-09-28 19:28:24 +000021/* 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. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +000025
Reid Spencer309080a2006-09-28 19:28:24 +000026/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +000028
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. */
Reid Spencer309080a2006-09-28 19:28:24 +000040#define YYBISON_VERSION "2.1"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +000041
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 Spencerdfb3fb42005-08-27 18:50:39 +000052#define yyparse llvmAsmparse
Anton Korobeynikov73441cd2006-09-14 18:25:26 +000053#define yylex llvmAsmlex
Reid Spencerdfb3fb42005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Anton Korobeynikov73441cd2006-09-14 18:25:26 +000055#define yylval llvmAsmlval
56#define yychar llvmAsmchar
Reid Spencerdfb3fb42005-08-27 18:50:39 +000057#define yydebug llvmAsmdebug
58#define yynerrs llvmAsmnerrs
59
Anton Korobeynikov73441cd2006-09-14 18:25:26 +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 DLLIMPORT = 300,
110 DLLEXPORT = 301,
111 EXTERN_WEAK = 302,
112 OPAQUE = 303,
113 NOT = 304,
114 EXTERNAL = 305,
115 TARGET = 306,
116 TRIPLE = 307,
117 ENDIAN = 308,
118 POINTERSIZE = 309,
119 LITTLE = 310,
120 BIG = 311,
121 ALIGN = 312,
122 DEPLIBS = 313,
123 CALL = 314,
124 TAIL = 315,
125 ASM_TOK = 316,
126 MODULE = 317,
127 SIDEEFFECT = 318,
128 CC_TOK = 319,
129 CCC_TOK = 320,
130 CSRETCC_TOK = 321,
131 FASTCC_TOK = 322,
132 COLDCC_TOK = 323,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +0000133 X86_STDCALLCC_TOK = 324,
134 X86_FASTCALLCC_TOK = 325,
135 RET = 326,
136 BR = 327,
137 SWITCH = 328,
138 INVOKE = 329,
139 UNWIND = 330,
140 UNREACHABLE = 331,
141 ADD = 332,
142 SUB = 333,
143 MUL = 334,
144 DIV = 335,
145 REM = 336,
146 AND = 337,
147 OR = 338,
148 XOR = 339,
149 SETLE = 340,
150 SETGE = 341,
151 SETLT = 342,
152 SETGT = 343,
153 SETEQ = 344,
154 SETNE = 345,
155 MALLOC = 346,
156 ALLOCA = 347,
157 FREE = 348,
158 LOAD = 349,
159 STORE = 350,
160 GETELEMENTPTR = 351,
161 PHI_TOK = 352,
162 CAST = 353,
163 SELECT = 354,
164 SHL = 355,
165 SHR = 356,
166 VAARG = 357,
167 EXTRACTELEMENT = 358,
168 INSERTELEMENT = 359,
169 SHUFFLEVECTOR = 360,
170 VAARG_old = 361,
171 VANEXT_old = 362
Anton Korobeynikov73441cd2006-09-14 18:25:26 +0000172 };
173#endif
174/* Tokens. */
175#define ESINT64VAL 258
176#define EUINT64VAL 259
177#define SINTVAL 260
178#define UINTVAL 261
179#define FPVAL 262
180#define VOID 263
181#define BOOL 264
182#define SBYTE 265
183#define UBYTE 266
184#define SHORT 267
185#define USHORT 268
186#define INT 269
187#define UINT 270
188#define LONG 271
189#define ULONG 272
190#define FLOAT 273
191#define DOUBLE 274
192#define TYPE 275
193#define LABEL 276
194#define VAR_ID 277
195#define LABELSTR 278
196#define STRINGCONSTANT 279
197#define IMPLEMENTATION 280
198#define ZEROINITIALIZER 281
199#define TRUETOK 282
200#define FALSETOK 283
201#define BEGINTOK 284
202#define ENDTOK 285
203#define DECLARE 286
204#define GLOBAL 287
205#define CONSTANT 288
206#define SECTION 289
207#define VOLATILE 290
208#define TO 291
209#define DOTDOTDOT 292
210#define NULL_TOK 293
211#define UNDEF 294
212#define CONST 295
213#define INTERNAL 296
214#define LINKONCE 297
215#define WEAK 298
216#define APPENDING 299
217#define DLLIMPORT 300
218#define DLLEXPORT 301
219#define EXTERN_WEAK 302
220#define OPAQUE 303
221#define NOT 304
222#define EXTERNAL 305
223#define TARGET 306
224#define TRIPLE 307
225#define ENDIAN 308
226#define POINTERSIZE 309
227#define LITTLE 310
228#define BIG 311
229#define ALIGN 312
230#define DEPLIBS 313
231#define CALL 314
232#define TAIL 315
233#define ASM_TOK 316
234#define MODULE 317
235#define SIDEEFFECT 318
236#define CC_TOK 319
237#define CCC_TOK 320
238#define CSRETCC_TOK 321
239#define FASTCC_TOK 322
240#define COLDCC_TOK 323
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +0000241#define X86_STDCALLCC_TOK 324
242#define X86_FASTCALLCC_TOK 325
243#define RET 326
244#define BR 327
245#define SWITCH 328
246#define INVOKE 329
247#define UNWIND 330
248#define UNREACHABLE 331
249#define ADD 332
250#define SUB 333
251#define MUL 334
252#define DIV 335
253#define REM 336
254#define AND 337
255#define OR 338
256#define XOR 339
257#define SETLE 340
258#define SETGE 341
259#define SETLT 342
260#define SETGT 343
261#define SETEQ 344
262#define SETNE 345
263#define MALLOC 346
264#define ALLOCA 347
265#define FREE 348
266#define LOAD 349
267#define STORE 350
268#define GETELEMENTPTR 351
269#define PHI_TOK 352
270#define CAST 353
271#define SELECT 354
272#define SHL 355
273#define SHR 356
274#define VAARG 357
275#define EXTRACTELEMENT 358
276#define INSERTELEMENT 359
277#define SHUFFLEVECTOR 360
278#define VAARG_old 361
279#define VANEXT_old 362
Anton Korobeynikov73441cd2006-09-14 18:25:26 +0000280
281
282
283
284/* Copy the first part of user declarations. */
Reid Spencer309080a2006-09-28 19:28:24 +0000285#line 14 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000286
287#include "ParserInternals.h"
288#include "llvm/CallingConv.h"
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000289#include "llvm/InlineAsm.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000290#include "llvm/Instructions.h"
291#include "llvm/Module.h"
292#include "llvm/SymbolTable.h"
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000293#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000294#include "llvm/Support/GetElementPtrTypeIterator.h"
295#include "llvm/ADT/STLExtras.h"
Chris Lattner840f7892005-11-06 06:46:53 +0000296#include "llvm/Support/MathExtras.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000297#include <algorithm>
298#include <iostream>
299#include <list>
300#include <utility>
301
Reid Spencerb50974a2006-08-18 17:32:55 +0000302// The following is a gross hack. In order to rid the libAsmParser library of
303// exceptions, we have to have a way of getting the yyparse function to go into
304// an error situation. So, whenever we want an error to occur, the GenerateError
305// function (see bottom of file) sets TriggerError. Then, at the end of each
306// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
307// (a goto) to put YACC in error state. Furthermore, several calls to
308// GenerateError are made from inside productions and they must simulate the
309// previous exception behavior by exiting the production immediately. We have
310// replaced these with the GEN_ERROR macro which calls GeneratError and then
311// immediately invokes YYERROR. This would be so much cleaner if it was a
312// recursive descent parser.
Reid Spencer713eedc2006-08-18 08:43:06 +0000313static bool TriggerError = false;
314#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYERROR; } }
Reid Spencer713eedc2006-08-18 08:43:06 +0000315#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
316
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000317int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
318int yylex(); // declaration" of xxx warnings.
319int yyparse();
320
321namespace llvm {
322 std::string CurFilename;
323}
324using namespace llvm;
325
326static Module *ParserResult;
327
328// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
329// relating to upreferences in the input stream.
330//
331//#define DEBUG_UPREFS 1
332#ifdef DEBUG_UPREFS
333#define UR_OUT(X) std::cerr << X
334#else
335#define UR_OUT(X)
336#endif
337
338#define YYERROR_VERBOSE 1
339
340static bool ObsoleteVarArgs;
341static bool NewVarArgs;
Chris Lattner11ca4d62005-11-12 18:22:38 +0000342static BasicBlock *CurBB;
343static GlobalVariable *CurGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000344
345
346// This contains info used when building the body of a function. It is
347// destroyed when the function is completed.
348//
349typedef std::vector<Value *> ValueList; // Numbered defs
350static void
351ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
352 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
353
354static struct PerModuleInfo {
355 Module *CurrentModule;
356 std::map<const Type *, ValueList> Values; // Module level numbered definitions
357 std::map<const Type *,ValueList> LateResolveValues;
358 std::vector<PATypeHolder> Types;
359 std::map<ValID, PATypeHolder> LateResolveTypes;
360
361 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner7aa45902006-06-21 16:53:00 +0000362 /// how they were referenced and on which line of the input they came from so
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000363 /// that we can resolve them later and print error messages as appropriate.
364 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
365
366 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
367 // references to global values. Global values may be referenced before they
368 // are defined, and if so, the temporary object that they represent is held
369 // here. This is used for forward references of GlobalValues.
370 //
371 typedef std::map<std::pair<const PointerType *,
372 ValID>, GlobalValue*> GlobalRefsType;
373 GlobalRefsType GlobalRefs;
374
375 void ModuleDone() {
376 // If we could not resolve some functions at function compilation time
377 // (calls to functions before they are defined), resolve them now... Types
378 // are resolved when the constant pool has been completely parsed.
379 //
380 ResolveDefinitions(LateResolveValues);
Reid Spencer309080a2006-09-28 19:28:24 +0000381 if (TriggerError)
382 return;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000383
384 // Check to make sure that all global value forward references have been
385 // resolved!
386 //
387 if (!GlobalRefs.empty()) {
388 std::string UndefinedReferences = "Unresolved global references exist:\n";
389
390 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
391 I != E; ++I) {
392 UndefinedReferences += " " + I->first.first->getDescription() + " " +
393 I->first.second.getName() + "\n";
394 }
Reid Spencer713eedc2006-08-18 08:43:06 +0000395 GenerateError(UndefinedReferences);
Reid Spencer309080a2006-09-28 19:28:24 +0000396 return;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000397 }
398
Reid Spencerc8a9faf2006-01-19 01:21:04 +0000399 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattner9ff96a72006-04-08 01:18:56 +0000400 for (Module::iterator FI = CurrentModule->begin(),
401 FE = CurrentModule->end(); FI != FE; )
Chris Lattneradf5ec62006-03-04 07:53:41 +0000402 UpgradeCallsToIntrinsic(FI++);
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000403
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000404 Values.clear(); // Clear out function local definitions
405 Types.clear();
406 CurrentModule = 0;
407 }
408
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000409 // GetForwardRefForGlobal - Check to see if there is a forward reference
410 // for this global. If so, remove it from the GlobalRefs map and return it.
411 // If not, just return null.
412 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
413 // Check to see if there is a forward reference to this global variable...
414 // if there is, eliminate it and patch the reference to use the new def'n.
415 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
416 GlobalValue *Ret = 0;
417 if (I != GlobalRefs.end()) {
418 Ret = I->second;
419 GlobalRefs.erase(I);
420 }
421 return Ret;
422 }
423} CurModule;
424
425static struct PerFunctionInfo {
426 Function *CurrentFunction; // Pointer to current function being created
427
Anton Korobeynikov73441cd2006-09-14 18:25:26 +0000428 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000429 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +0000430 bool isDeclare; // Is this function a forward declararation?
431 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000432
433 /// BBForwardRefs - When we see forward references to basic blocks, keep
434 /// track of them here.
435 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
436 std::vector<BasicBlock*> NumberedBlocks;
437 unsigned NextBBNum;
438
439 inline PerFunctionInfo() {
440 CurrentFunction = 0;
441 isDeclare = false;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +0000442 Linkage = GlobalValue::ExternalLinkage;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000443 }
444
445 inline void FunctionStart(Function *M) {
446 CurrentFunction = M;
447 NextBBNum = 0;
448 }
449
450 void FunctionDone() {
451 NumberedBlocks.clear();
452
453 // Any forward referenced blocks left?
Reid Spencer309080a2006-09-28 19:28:24 +0000454 if (!BBForwardRefs.empty()) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000455 GenerateError("Undefined reference to label " +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000456 BBForwardRefs.begin()->first->getName());
Reid Spencer309080a2006-09-28 19:28:24 +0000457 return;
458 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000459
460 // Resolve all forward references now.
461 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
462
463 Values.clear(); // Clear out function local definitions
464 CurrentFunction = 0;
465 isDeclare = false;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +0000466 Linkage = GlobalValue::ExternalLinkage;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000467 }
468} CurFun; // Info for the current function...
469
470static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
471
472
473//===----------------------------------------------------------------------===//
474// Code to handle definitions of all the types
475//===----------------------------------------------------------------------===//
476
477static int InsertValue(Value *V,
478 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
479 if (V->hasName()) return -1; // Is this a numbered definition?
480
481 // Yes, insert the value into the value table...
482 ValueList &List = ValueTab[V->getType()];
483 List.push_back(V);
484 return List.size()-1;
485}
486
487static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
488 switch (D.Type) {
489 case ValID::NumberVal: // Is it a numbered definition?
490 // Module constants occupy the lowest numbered slots...
491 if ((unsigned)D.Num < CurModule.Types.size())
492 return CurModule.Types[(unsigned)D.Num];
493 break;
494 case ValID::NameVal: // Is it a named definition?
495 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
496 D.destroy(); // Free old strdup'd memory...
497 return N;
498 }
499 break;
500 default:
Reid Spencer713eedc2006-08-18 08:43:06 +0000501 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer309080a2006-09-28 19:28:24 +0000502 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000503 }
504
505 // If we reached here, we referenced either a symbol that we don't know about
506 // or an id number that hasn't been read yet. We may be referencing something
507 // forward, so just create an entry to be resolved later and get to it...
508 //
509 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
510
511
512 if (inFunctionScope()) {
Reid Spencer309080a2006-09-28 19:28:24 +0000513 if (D.Type == ValID::NameVal) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000514 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer309080a2006-09-28 19:28:24 +0000515 return 0;
516 } else {
Reid Spencer713eedc2006-08-18 08:43:06 +0000517 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer309080a2006-09-28 19:28:24 +0000518 return 0;
519 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000520 }
521
522 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
523 if (I != CurModule.LateResolveTypes.end())
524 return I->second;
525
526 Type *Typ = OpaqueType::get();
527 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
528 return Typ;
529 }
530
531static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
532 SymbolTable &SymTab =
533 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
534 CurModule.CurrentModule->getSymbolTable();
535 return SymTab.lookup(Ty, Name);
536}
537
538// getValNonImprovising - Look up the value specified by the provided type and
539// the provided ValID. If the value exists and has already been defined, return
540// it. Otherwise return null.
541//
542static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer309080a2006-09-28 19:28:24 +0000543 if (isa<FunctionType>(Ty)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000544 GenerateError("Functions are not values and "
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000545 "must be referenced as pointers");
Reid Spencer309080a2006-09-28 19:28:24 +0000546 return 0;
547 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000548
549 switch (D.Type) {
550 case ValID::NumberVal: { // Is it a numbered definition?
551 unsigned Num = (unsigned)D.Num;
552
553 // Module constants occupy the lowest numbered slots...
554 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
555 if (VI != CurModule.Values.end()) {
556 if (Num < VI->second.size())
557 return VI->second[Num];
558 Num -= VI->second.size();
559 }
560
561 // Make sure that our type is within bounds
562 VI = CurFun.Values.find(Ty);
563 if (VI == CurFun.Values.end()) return 0;
564
565 // Check that the number is within bounds...
566 if (VI->second.size() <= Num) return 0;
567
568 return VI->second[Num];
569 }
570
571 case ValID::NameVal: { // Is it a named definition?
572 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
573 if (N == 0) return 0;
574
575 D.destroy(); // Free old strdup'd memory...
576 return N;
577 }
578
579 // Check to make sure that "Ty" is an integral type, and that our
580 // value will fit into the specified type...
581 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencer309080a2006-09-28 19:28:24 +0000582 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000583 GenerateError("Signed integral constant '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000584 itostr(D.ConstPool64) + "' is invalid for type '" +
585 Ty->getDescription() + "'!");
Reid Spencer309080a2006-09-28 19:28:24 +0000586 return 0;
587 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000588 return ConstantSInt::get(Ty, D.ConstPool64);
589
590 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
591 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
592 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000593 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000594 "' is invalid or out of range!");
Reid Spencer309080a2006-09-28 19:28:24 +0000595 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000596 } else { // This is really a signed reference. Transmogrify.
597 return ConstantSInt::get(Ty, D.ConstPool64);
598 }
599 } else {
600 return ConstantUInt::get(Ty, D.UConstPool64);
601 }
602
603 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer309080a2006-09-28 19:28:24 +0000604 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000605 GenerateError("FP constant invalid for type!!");
Reid Spencer309080a2006-09-28 19:28:24 +0000606 return 0;
607 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000608 return ConstantFP::get(Ty, D.ConstPoolFP);
609
610 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer309080a2006-09-28 19:28:24 +0000611 if (!isa<PointerType>(Ty)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000612 GenerateError("Cannot create a a non pointer null!");
Reid Spencer309080a2006-09-28 19:28:24 +0000613 return 0;
614 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000615 return ConstantPointerNull::get(cast<PointerType>(Ty));
616
617 case ValID::ConstUndefVal: // Is it an undef value?
618 return UndefValue::get(Ty);
619
Chris Lattnera054d122005-12-21 17:53:23 +0000620 case ValID::ConstZeroVal: // Is it a zero value?
621 return Constant::getNullValue(Ty);
622
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000623 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer309080a2006-09-28 19:28:24 +0000624 if (D.ConstantValue->getType() != Ty) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000625 GenerateError("Constant expression type different from required type!");
Reid Spencer309080a2006-09-28 19:28:24 +0000626 return 0;
627 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000628 return D.ConstantValue;
629
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000630 case ValID::InlineAsmVal: { // Inline asm expression
631 const PointerType *PTy = dyn_cast<PointerType>(Ty);
632 const FunctionType *FTy =
633 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer309080a2006-09-28 19:28:24 +0000634 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000635 GenerateError("Invalid type for asm constraint string!");
Reid Spencer309080a2006-09-28 19:28:24 +0000636 return 0;
637 }
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000638 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
639 D.IAD->HasSideEffects);
640 D.destroy(); // Free InlineAsmDescriptor.
641 return IA;
642 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000643 default:
644 assert(0 && "Unhandled case!");
645 return 0;
646 } // End of switch
647
648 assert(0 && "Unhandled case!");
649 return 0;
650}
651
652// getVal - This function is identical to getValNonImprovising, except that if a
653// value is not already defined, it "improvises" by creating a placeholder var
654// that looks and acts just like the requested variable. When the value is
655// defined later, all uses of the placeholder variable are replaced with the
656// real thing.
657//
658static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer309080a2006-09-28 19:28:24 +0000659 if (Ty == Type::LabelTy) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000660 GenerateError("Cannot use a basic block here");
Reid Spencer309080a2006-09-28 19:28:24 +0000661 return 0;
662 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000663
664 // See if the value has already been defined.
665 Value *V = getValNonImprovising(Ty, ID);
666 if (V) return V;
Reid Spencer309080a2006-09-28 19:28:24 +0000667 if (TriggerError) return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000668
Reid Spencer309080a2006-09-28 19:28:24 +0000669 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000670 GenerateError("Invalid use of a composite type!");
Reid Spencer309080a2006-09-28 19:28:24 +0000671 return 0;
672 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000673
674 // If we reached here, we referenced either a symbol that we don't know about
675 // or an id number that hasn't been read yet. We may be referencing something
676 // forward, so just create an entry to be resolved later and get to it...
677 //
678 V = new Argument(Ty);
679
680 // Remember where this forward reference came from. FIXME, shouldn't we try
681 // to recycle these things??
682 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
683 llvmAsmlineno)));
684
685 if (inFunctionScope())
686 InsertValue(V, CurFun.LateResolveValues);
687 else
688 InsertValue(V, CurModule.LateResolveValues);
689 return V;
690}
691
692/// getBBVal - This is used for two purposes:
693/// * If isDefinition is true, a new basic block with the specified ID is being
694/// defined.
695/// * If isDefinition is true, this is a reference to a basic block, which may
696/// or may not be a forward reference.
697///
698static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
699 assert(inFunctionScope() && "Can't get basic block at global scope!");
700
701 std::string Name;
702 BasicBlock *BB = 0;
703 switch (ID.Type) {
Reid Spencer309080a2006-09-28 19:28:24 +0000704 default:
705 GenerateError("Illegal label reference " + ID.getName());
706 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000707 case ValID::NumberVal: // Is it a numbered definition?
708 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
709 CurFun.NumberedBlocks.resize(ID.Num+1);
710 BB = CurFun.NumberedBlocks[ID.Num];
711 break;
712 case ValID::NameVal: // Is it a named definition?
713 Name = ID.Name;
714 if (Value *N = CurFun.CurrentFunction->
715 getSymbolTable().lookup(Type::LabelTy, Name))
716 BB = cast<BasicBlock>(N);
717 break;
718 }
719
720 // See if the block has already been defined.
721 if (BB) {
722 // If this is the definition of the block, make sure the existing value was
723 // just a forward reference. If it was a forward reference, there will be
724 // an entry for it in the PlaceHolderInfo map.
Reid Spencer309080a2006-09-28 19:28:24 +0000725 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000726 // The existing value was a definition, not a forward reference.
Reid Spencer713eedc2006-08-18 08:43:06 +0000727 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer309080a2006-09-28 19:28:24 +0000728 return 0;
729 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000730
731 ID.destroy(); // Free strdup'd memory.
732 return BB;
733 }
734
735 // Otherwise this block has not been seen before.
736 BB = new BasicBlock("", CurFun.CurrentFunction);
737 if (ID.Type == ValID::NameVal) {
738 BB->setName(ID.Name);
739 } else {
740 CurFun.NumberedBlocks[ID.Num] = BB;
741 }
742
743 // If this is not a definition, keep track of it so we can use it as a forward
744 // reference.
745 if (!isDefinition) {
746 // Remember where this forward reference came from.
747 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
748 } else {
749 // The forward declaration could have been inserted anywhere in the
750 // function: insert it into the correct place now.
751 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
752 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
753 }
754 ID.destroy();
755 return BB;
756}
757
758
759//===----------------------------------------------------------------------===//
760// Code to handle forward references in instructions
761//===----------------------------------------------------------------------===//
762//
763// This code handles the late binding needed with statements that reference
764// values not defined yet... for example, a forward branch, or the PHI node for
765// a loop body.
766//
767// This keeps a table (CurFun.LateResolveValues) of all such forward references
768// and back patchs after we are done.
769//
770
771// ResolveDefinitions - If we could not resolve some defs at parsing
772// time (forward branches, phi functions for loops, etc...) resolve the
773// defs now...
774//
775static void
776ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
777 std::map<const Type*,ValueList> *FutureLateResolvers) {
778 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
779 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
780 E = LateResolvers.end(); LRI != E; ++LRI) {
781 ValueList &List = LRI->second;
782 while (!List.empty()) {
783 Value *V = List.back();
784 List.pop_back();
785
786 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
787 CurModule.PlaceHolderInfo.find(V);
788 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
789
790 ValID &DID = PHI->second.first;
791
792 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer309080a2006-09-28 19:28:24 +0000793 if (TriggerError)
794 return;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000795 if (TheRealValue) {
796 V->replaceAllUsesWith(TheRealValue);
797 delete V;
798 CurModule.PlaceHolderInfo.erase(PHI);
799 } else if (FutureLateResolvers) {
800 // Functions have their unresolved items forwarded to the module late
801 // resolver table
802 InsertValue(V, *FutureLateResolvers);
803 } else {
Reid Spencer309080a2006-09-28 19:28:24 +0000804 if (DID.Type == ValID::NameVal) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000805 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000806 "' of type '" + V->getType()->getDescription() + "'",
807 PHI->second.second);
Reid Spencer309080a2006-09-28 19:28:24 +0000808 return;
809 } else {
Reid Spencer713eedc2006-08-18 08:43:06 +0000810 GenerateError("Reference to an invalid definition: #" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000811 itostr(DID.Num) + " of type '" +
812 V->getType()->getDescription() + "'",
813 PHI->second.second);
Reid Spencer309080a2006-09-28 19:28:24 +0000814 return;
815 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000816 }
817 }
818 }
819
820 LateResolvers.clear();
821}
822
823// ResolveTypeTo - A brand new type was just declared. This means that (if
824// name is not null) things referencing Name can be resolved. Otherwise, things
825// refering to the number can be resolved. Do this now.
826//
827static void ResolveTypeTo(char *Name, const Type *ToTy) {
828 ValID D;
829 if (Name) D = ValID::create(Name);
830 else D = ValID::create((int)CurModule.Types.size());
831
832 std::map<ValID, PATypeHolder>::iterator I =
833 CurModule.LateResolveTypes.find(D);
834 if (I != CurModule.LateResolveTypes.end()) {
835 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
836 CurModule.LateResolveTypes.erase(I);
837 }
838}
839
840// setValueName - Set the specified value to the name given. The name may be
841// null potentially, in which case this is a noop. The string passed in is
842// assumed to be a malloc'd string buffer, and is free'd by this function.
843//
844static void setValueName(Value *V, char *NameStr) {
845 if (NameStr) {
846 std::string Name(NameStr); // Copy string
847 free(NameStr); // Free old string
848
Reid Spencer309080a2006-09-28 19:28:24 +0000849 if (V->getType() == Type::VoidTy) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000850 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer309080a2006-09-28 19:28:24 +0000851 return;
852 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000853
854 assert(inFunctionScope() && "Must be in function scope!");
855 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
Reid Spencer309080a2006-09-28 19:28:24 +0000856 if (ST.lookup(V->getType(), Name)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000857 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000858 V->getType()->getDescription() + "' type plane!");
Reid Spencer309080a2006-09-28 19:28:24 +0000859 return;
860 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000861
862 // Set the name.
863 V->setName(Name);
864 }
865}
866
867/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
868/// this is a declaration, otherwise it is a definition.
Chris Lattner11ca4d62005-11-12 18:22:38 +0000869static GlobalVariable *
870ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
871 bool isConstantGlobal, const Type *Ty,
872 Constant *Initializer) {
Reid Spencer309080a2006-09-28 19:28:24 +0000873 if (isa<FunctionType>(Ty)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000874 GenerateError("Cannot declare global vars of function type!");
Reid Spencer309080a2006-09-28 19:28:24 +0000875 return 0;
876 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000877
878 const PointerType *PTy = PointerType::get(Ty);
879
880 std::string Name;
881 if (NameStr) {
882 Name = NameStr; // Copy string
883 free(NameStr); // Free old string
884 }
885
886 // See if this global value was forward referenced. If so, recycle the
887 // object.
888 ValID ID;
889 if (!Name.empty()) {
890 ID = ValID::create((char*)Name.c_str());
891 } else {
892 ID = ValID::create((int)CurModule.Values[PTy].size());
893 }
894
895 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
896 // Move the global to the end of the list, from whereever it was
897 // previously inserted.
898 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
899 CurModule.CurrentModule->getGlobalList().remove(GV);
900 CurModule.CurrentModule->getGlobalList().push_back(GV);
901 GV->setInitializer(Initializer);
902 GV->setLinkage(Linkage);
903 GV->setConstant(isConstantGlobal);
904 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000905 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000906 }
907
908 // If this global has a name, check to see if there is already a definition
909 // of this global in the module. If so, merge as appropriate. Note that
910 // this is really just a hack around problems in the CFE. :(
911 if (!Name.empty()) {
912 // We are a simple redefinition of a value, check to see if it is defined
913 // the same as the old one.
914 if (GlobalVariable *EGV =
915 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
916 // We are allowed to redefine a global variable in two circumstances:
917 // 1. If at least one of the globals is uninitialized or
918 // 2. If both initializers have the same value.
919 //
920 if (!EGV->hasInitializer() || !Initializer ||
921 EGV->getInitializer() == Initializer) {
922
923 // Make sure the existing global version gets the initializer! Make
924 // sure that it also gets marked const if the new version is.
925 if (Initializer && !EGV->hasInitializer())
926 EGV->setInitializer(Initializer);
927 if (isConstantGlobal)
928 EGV->setConstant(true);
929 EGV->setLinkage(Linkage);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000930 return EGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000931 }
932
Reid Spencer713eedc2006-08-18 08:43:06 +0000933 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000934 "' in the '" + Ty->getDescription() + "' type plane!");
Reid Spencer309080a2006-09-28 19:28:24 +0000935 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000936 }
937 }
938
939 // Otherwise there is no existing GV to use, create one now.
940 GlobalVariable *GV =
941 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
942 CurModule.CurrentModule);
943 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000944 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000945}
946
947// setTypeName - Set the specified type to the name given. The name may be
948// null potentially, in which case this is a noop. The string passed in is
949// assumed to be a malloc'd string buffer, and is freed by this function.
950//
951// This function returns true if the type has already been defined, but is
952// allowed to be redefined in the specified context. If the name is a new name
953// for the type plane, it is inserted and false is returned.
954static bool setTypeName(const Type *T, char *NameStr) {
955 assert(!inFunctionScope() && "Can't give types function-local names!");
956 if (NameStr == 0) return false;
957
958 std::string Name(NameStr); // Copy string
959 free(NameStr); // Free old string
960
961 // We don't allow assigning names to void type
Reid Spencer309080a2006-09-28 19:28:24 +0000962 if (T == Type::VoidTy) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000963 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer309080a2006-09-28 19:28:24 +0000964 return false;
965 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000966
967 // Set the type name, checking for conflicts as we do so.
968 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
969
970 if (AlreadyExists) { // Inserting a name that is already defined???
971 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
972 assert(Existing && "Conflict but no matching type?");
973
974 // There is only one case where this is allowed: when we are refining an
975 // opaque type. In this case, Existing will be an opaque type.
976 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
977 // We ARE replacing an opaque type!
978 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
979 return true;
980 }
981
982 // Otherwise, this is an attempt to redefine a type. That's okay if
983 // the redefinition is identical to the original. This will be so if
984 // Existing and T point to the same Type object. In this one case we
985 // allow the equivalent redefinition.
986 if (Existing == T) return true; // Yes, it's equal.
987
988 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer713eedc2006-08-18 08:43:06 +0000989 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000990 T->getDescription() + "' type plane!");
991 }
992
993 return false;
994}
995
996//===----------------------------------------------------------------------===//
997// Code for handling upreferences in type names...
998//
999
1000// TypeContains - Returns true if Ty directly contains E in it.
1001//
1002static bool TypeContains(const Type *Ty, const Type *E) {
1003 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1004 E) != Ty->subtype_end();
1005}
1006
1007namespace {
1008 struct UpRefRecord {
1009 // NestingLevel - The number of nesting levels that need to be popped before
1010 // this type is resolved.
1011 unsigned NestingLevel;
1012
1013 // LastContainedTy - This is the type at the current binding level for the
1014 // type. Every time we reduce the nesting level, this gets updated.
1015 const Type *LastContainedTy;
1016
1017 // UpRefTy - This is the actual opaque type that the upreference is
1018 // represented with.
1019 OpaqueType *UpRefTy;
1020
1021 UpRefRecord(unsigned NL, OpaqueType *URTy)
1022 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1023 };
1024}
1025
1026// UpRefs - A list of the outstanding upreferences that need to be resolved.
1027static std::vector<UpRefRecord> UpRefs;
1028
1029/// HandleUpRefs - Every time we finish a new layer of types, this function is
1030/// called. It loops through the UpRefs vector, which is a list of the
1031/// currently active types. For each type, if the up reference is contained in
1032/// the newly completed type, we decrement the level count. When the level
1033/// count reaches zero, the upreferenced type is the type that is passed in:
1034/// thus we can complete the cycle.
1035///
1036static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner680aab62006-08-18 17:34:45 +00001037 // If Ty isn't abstract, or if there are no up-references in it, then there is
1038 // nothing to resolve here.
1039 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1040
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001041 PATypeHolder Ty(ty);
1042 UR_OUT("Type '" << Ty->getDescription() <<
1043 "' newly formed. Resolving upreferences.\n" <<
1044 UpRefs.size() << " upreferences active!\n");
1045
1046 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1047 // to zero), we resolve them all together before we resolve them to Ty. At
1048 // the end of the loop, if there is anything to resolve to Ty, it will be in
1049 // this variable.
1050 OpaqueType *TypeToResolve = 0;
1051
1052 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1053 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1054 << UpRefs[i].second->getDescription() << ") = "
1055 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1056 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1057 // Decrement level of upreference
1058 unsigned Level = --UpRefs[i].NestingLevel;
1059 UpRefs[i].LastContainedTy = Ty;
1060 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1061 if (Level == 0) { // Upreference should be resolved!
1062 if (!TypeToResolve) {
1063 TypeToResolve = UpRefs[i].UpRefTy;
1064 } else {
1065 UR_OUT(" * Resolving upreference for "
1066 << UpRefs[i].second->getDescription() << "\n";
1067 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1068 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1069 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1070 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1071 }
1072 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1073 --i; // Do not skip the next element...
1074 }
1075 }
1076 }
1077
1078 if (TypeToResolve) {
1079 UR_OUT(" * Resolving upreference for "
1080 << UpRefs[i].second->getDescription() << "\n";
1081 std::string OldName = TypeToResolve->getDescription());
1082 TypeToResolve->refineAbstractTypeTo(Ty);
1083 }
1084
1085 return Ty;
1086}
1087
1088
1089// common code from the two 'RunVMAsmParser' functions
Reid Spencer309080a2006-09-28 19:28:24 +00001090static Module* RunParser(Module * M) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001091
1092 llvmAsmlineno = 1; // Reset the current line number...
1093 ObsoleteVarArgs = false;
1094 NewVarArgs = false;
1095
1096 CurModule.CurrentModule = M;
1097 yyparse(); // Parse the file, potentially throwing exception
Reid Spencer713eedc2006-08-18 08:43:06 +00001098 if (!ParserResult)
1099 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001100
1101 Module *Result = ParserResult;
1102 ParserResult = 0;
1103
1104 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1105 {
1106 Function* F;
1107 if ((F = Result->getNamedFunction("llvm.va_start"))
1108 && F->getFunctionType()->getNumParams() == 0)
1109 ObsoleteVarArgs = true;
1110 if((F = Result->getNamedFunction("llvm.va_copy"))
1111 && F->getFunctionType()->getNumParams() == 1)
1112 ObsoleteVarArgs = true;
1113 }
1114
Reid Spencer309080a2006-09-28 19:28:24 +00001115 if (ObsoleteVarArgs && NewVarArgs) {
1116 GenerateError(
1117 "This file is corrupt: it uses both new and old style varargs");
1118 return 0;
1119 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001120
1121 if(ObsoleteVarArgs) {
1122 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
Reid Spencer309080a2006-09-28 19:28:24 +00001123 if (F->arg_size() != 0) {
Reid Spencer713eedc2006-08-18 08:43:06 +00001124 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencer309080a2006-09-28 19:28:24 +00001125 return 0;
1126 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001127
1128 //foo = va_start()
1129 // ->
1130 //bar = alloca typeof(foo)
1131 //va_start(bar)
1132 //foo = load bar
1133
1134 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1135 const Type* ArgTy = F->getFunctionType()->getReturnType();
1136 const Type* ArgTyPtr = PointerType::get(ArgTy);
1137 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen11e26b52005-10-23 04:37:20 +00001138 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001139
1140 while (!F->use_empty()) {
1141 CallInst* CI = cast<CallInst>(F->use_back());
1142 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1143 new CallInst(NF, bar, "", CI);
1144 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1145 CI->replaceAllUsesWith(foo);
1146 CI->getParent()->getInstList().erase(CI);
1147 }
1148 Result->getFunctionList().erase(F);
1149 }
1150
1151 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
Reid Spencer309080a2006-09-28 19:28:24 +00001152 if(F->arg_size() != 1) {
Reid Spencer713eedc2006-08-18 08:43:06 +00001153 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencer309080a2006-09-28 19:28:24 +00001154 return 0;
1155 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001156
1157 //vaend foo
1158 // ->
1159 //bar = alloca 1 of typeof(foo)
1160 //vaend bar
1161 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1162 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1163 const Type* ArgTyPtr = PointerType::get(ArgTy);
1164 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen11e26b52005-10-23 04:37:20 +00001165 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001166
1167 while (!F->use_empty()) {
1168 CallInst* CI = cast<CallInst>(F->use_back());
1169 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1170 new StoreInst(CI->getOperand(1), bar, CI);
1171 new CallInst(NF, bar, "", CI);
1172 CI->getParent()->getInstList().erase(CI);
1173 }
1174 Result->getFunctionList().erase(F);
1175 }
1176
1177 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
Reid Spencer309080a2006-09-28 19:28:24 +00001178 if(F->arg_size() != 1) {
Reid Spencer713eedc2006-08-18 08:43:06 +00001179 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencer309080a2006-09-28 19:28:24 +00001180 return 0;
1181 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001182 //foo = vacopy(bar)
1183 // ->
1184 //a = alloca 1 of typeof(foo)
1185 //b = alloca 1 of typeof(foo)
1186 //store bar -> b
1187 //vacopy(a, b)
1188 //foo = load a
1189
1190 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1191 const Type* ArgTy = F->getFunctionType()->getReturnType();
1192 const Type* ArgTyPtr = PointerType::get(ArgTy);
1193 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen11e26b52005-10-23 04:37:20 +00001194 RetTy, ArgTyPtr, ArgTyPtr,
1195 (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001196
1197 while (!F->use_empty()) {
1198 CallInst* CI = cast<CallInst>(F->use_back());
1199 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1200 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1201 new StoreInst(CI->getOperand(1), b, CI);
1202 new CallInst(NF, a, b, "", CI);
1203 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1204 CI->replaceAllUsesWith(foo);
1205 CI->getParent()->getInstList().erase(CI);
1206 }
1207 Result->getFunctionList().erase(F);
1208 }
1209 }
1210
1211 return Result;
Reid Spencer309080a2006-09-28 19:28:24 +00001212}
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001213
1214//===----------------------------------------------------------------------===//
1215// RunVMAsmParser - Define an interface to this parser
1216//===----------------------------------------------------------------------===//
1217//
1218Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1219 set_scan_file(F);
1220
1221 CurFilename = Filename;
1222 return RunParser(new Module(CurFilename));
1223}
1224
1225Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1226 set_scan_string(AsmString);
1227
1228 CurFilename = "from_memory";
1229 if (M == NULL) {
1230 return RunParser(new Module (CurFilename));
1231 } else {
1232 return RunParser(M);
1233 }
1234}
1235
1236
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001237
1238/* Enabling traces. */
1239#ifndef YYDEBUG
1240# define YYDEBUG 0
1241#endif
1242
1243/* Enabling verbose error messages. */
1244#ifdef YYERROR_VERBOSE
1245# undef YYERROR_VERBOSE
1246# define YYERROR_VERBOSE 1
1247#else
1248# define YYERROR_VERBOSE 0
1249#endif
1250
1251/* Enabling the token table. */
1252#ifndef YYTOKEN_TABLE
1253# define YYTOKEN_TABLE 0
1254#endif
1255
Reid Spencer309080a2006-09-28 19:28:24 +00001256#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
1257#line 966 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
1258typedef union YYSTYPE {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001259 llvm::Module *ModuleVal;
1260 llvm::Function *FunctionVal;
1261 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1262 llvm::BasicBlock *BasicBlockVal;
1263 llvm::TerminatorInst *TermInstVal;
1264 llvm::Instruction *InstVal;
1265 llvm::Constant *ConstVal;
1266
1267 const llvm::Type *PrimType;
1268 llvm::PATypeHolder *TypeVal;
1269 llvm::Value *ValueVal;
1270
1271 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1272 std::vector<llvm::Value*> *ValueList;
1273 std::list<llvm::PATypeHolder> *TypeList;
1274 // Represent the RHS of PHI node
1275 std::list<std::pair<llvm::Value*,
1276 llvm::BasicBlock*> > *PHIList;
1277 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1278 std::vector<llvm::Constant*> *ConstVector;
1279
1280 llvm::GlobalValue::LinkageTypes Linkage;
1281 int64_t SInt64Val;
1282 uint64_t UInt64Val;
1283 int SIntVal;
1284 unsigned UIntVal;
1285 double FPVal;
1286 bool BoolVal;
1287
1288 char *StrVal; // This memory is strdup'd!
1289 llvm::ValID ValIDVal; // strdup'd memory maybe!
1290
1291 llvm::Instruction::BinaryOps BinaryOpVal;
1292 llvm::Instruction::TermOps TermOpVal;
1293 llvm::Instruction::MemoryOps MemOpVal;
1294 llvm::Instruction::OtherOps OtherOpVal;
1295 llvm::Module::Endianness Endianness;
Reid Spencer309080a2006-09-28 19:28:24 +00001296} YYSTYPE;
1297/* Line 196 of yacc.c. */
1298#line 1299 "llvmAsmParser.tab.c"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001299# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1300# define YYSTYPE_IS_DECLARED 1
1301# define YYSTYPE_IS_TRIVIAL 1
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001302#endif
1303
1304
1305
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001306/* Copy the second part of user declarations. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001307
1308
Reid Spencer309080a2006-09-28 19:28:24 +00001309/* Line 219 of yacc.c. */
1310#line 1311 "llvmAsmParser.tab.c"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001311
Reid Spencer309080a2006-09-28 19:28:24 +00001312#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1313# define YYSIZE_T __SIZE_TYPE__
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001314#endif
Reid Spencer309080a2006-09-28 19:28:24 +00001315#if ! defined (YYSIZE_T) && defined (size_t)
1316# define YYSIZE_T size_t
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001317#endif
Reid Spencer309080a2006-09-28 19:28:24 +00001318#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1319# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1320# define YYSIZE_T size_t
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001321#endif
Reid Spencer309080a2006-09-28 19:28:24 +00001322#if ! defined (YYSIZE_T)
1323# define YYSIZE_T unsigned int
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001324#endif
1325
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001326#ifndef YY_
1327# if YYENABLE_NLS
1328# if ENABLE_NLS
1329# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1330# define YY_(msgid) dgettext ("bison-runtime", msgid)
1331# endif
1332# endif
1333# ifndef YY_
1334# define YY_(msgid) msgid
1335# endif
1336#endif
1337
Reid Spencer309080a2006-09-28 19:28:24 +00001338#if ! defined (yyoverflow) || YYERROR_VERBOSE
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001339
1340/* The parser invokes alloca or malloc; define the necessary symbols. */
1341
1342# ifdef YYSTACK_USE_ALLOCA
1343# if YYSTACK_USE_ALLOCA
1344# ifdef __GNUC__
1345# define YYSTACK_ALLOC __builtin_alloca
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001346# else
1347# define YYSTACK_ALLOC alloca
Reid Spencer309080a2006-09-28 19:28:24 +00001348# if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001349# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
Reid Spencer309080a2006-09-28 19:28:24 +00001350# define YYINCLUDED_STDLIB_H
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001351# endif
1352# endif
1353# endif
1354# endif
1355
1356# ifdef YYSTACK_ALLOC
Reid Spencer309080a2006-09-28 19:28:24 +00001357 /* Pacify GCC's `empty if-body' warning. */
1358# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001359# ifndef YYSTACK_ALLOC_MAXIMUM
1360 /* The OS might guarantee only one guard page at the bottom of the stack,
1361 and a page size can be as small as 4096 bytes. So we cannot safely
1362 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1363 to allow for a few compiler-allocated temporary stack slots. */
Reid Spencer309080a2006-09-28 19:28:24 +00001364# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001365# endif
1366# else
1367# define YYSTACK_ALLOC YYMALLOC
1368# define YYSTACK_FREE YYFREE
1369# ifndef YYSTACK_ALLOC_MAXIMUM
Reid Spencer309080a2006-09-28 19:28:24 +00001370# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001371# endif
Reid Spencer309080a2006-09-28 19:28:24 +00001372# ifdef __cplusplus
1373extern "C" {
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001374# endif
1375# ifndef YYMALLOC
1376# define YYMALLOC malloc
Reid Spencer309080a2006-09-28 19:28:24 +00001377# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1378 && (defined (__STDC__) || defined (__cplusplus)))
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001379void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1380# endif
1381# endif
1382# ifndef YYFREE
1383# define YYFREE free
Reid Spencer309080a2006-09-28 19:28:24 +00001384# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1385 && (defined (__STDC__) || defined (__cplusplus)))
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001386void free (void *); /* INFRINGES ON USER NAME SPACE */
1387# endif
1388# endif
Reid Spencer309080a2006-09-28 19:28:24 +00001389# ifdef __cplusplus
1390}
1391# endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001392# endif
Reid Spencer309080a2006-09-28 19:28:24 +00001393#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001394
1395
Reid Spencer309080a2006-09-28 19:28:24 +00001396#if (! defined (yyoverflow) \
1397 && (! defined (__cplusplus) \
1398 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001399
1400/* A type that is properly aligned for any stack member. */
1401union yyalloc
1402{
Reid Spencer309080a2006-09-28 19:28:24 +00001403 short int yyss;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001404 YYSTYPE yyvs;
1405 };
1406
1407/* The size of the maximum gap between one aligned stack and the next. */
1408# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1409
1410/* The size of an array large to enough to hold all stacks, each with
1411 N elements. */
1412# define YYSTACK_BYTES(N) \
Reid Spencer309080a2006-09-28 19:28:24 +00001413 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001414 + YYSTACK_GAP_MAXIMUM)
1415
1416/* Copy COUNT objects from FROM to TO. The source and destination do
1417 not overlap. */
1418# ifndef YYCOPY
Reid Spencer309080a2006-09-28 19:28:24 +00001419# if defined (__GNUC__) && 1 < __GNUC__
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001420# define YYCOPY(To, From, Count) \
1421 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1422# else
1423# define YYCOPY(To, From, Count) \
1424 do \
1425 { \
1426 YYSIZE_T yyi; \
1427 for (yyi = 0; yyi < (Count); yyi++) \
1428 (To)[yyi] = (From)[yyi]; \
1429 } \
Reid Spencer309080a2006-09-28 19:28:24 +00001430 while (0)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001431# endif
1432# endif
1433
1434/* Relocate STACK from its old location to the new one. The
1435 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1436 elements in the stack, and YYPTR gives the new location of the
1437 stack. Advance YYPTR to a properly aligned location for the next
1438 stack. */
1439# define YYSTACK_RELOCATE(Stack) \
1440 do \
1441 { \
1442 YYSIZE_T yynewbytes; \
1443 YYCOPY (&yyptr->Stack, Stack, yysize); \
1444 Stack = &yyptr->Stack; \
1445 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1446 yyptr += yynewbytes / sizeof (*yyptr); \
1447 } \
Reid Spencer309080a2006-09-28 19:28:24 +00001448 while (0)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001449
1450#endif
1451
Reid Spencer309080a2006-09-28 19:28:24 +00001452#if defined (__STDC__) || defined (__cplusplus)
1453 typedef signed char yysigned_char;
1454#else
1455 typedef short int yysigned_char;
1456#endif
1457
1458/* YYFINAL -- State number of the termination state. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001459#define YYFINAL 4
1460/* YYLAST -- Last index in YYTABLE. */
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001461#define YYLAST 1330
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001462
Reid Spencer309080a2006-09-28 19:28:24 +00001463/* YYNTOKENS -- Number of terminals. */
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001464#define YYNTOKENS 122
Reid Spencer309080a2006-09-28 19:28:24 +00001465/* YYNNTS -- Number of nonterminals. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001466#define YYNNTS 75
Reid Spencer309080a2006-09-28 19:28:24 +00001467/* YYNRULES -- Number of rules. */
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001468#define YYNRULES 251
Reid Spencer309080a2006-09-28 19:28:24 +00001469/* YYNRULES -- Number of states. */
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001470#define YYNSTATES 514
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001471
1472/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1473#define YYUNDEFTOK 2
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001474#define YYMAXUTOK 362
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001475
1476#define YYTRANSLATE(YYX) \
1477 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1478
1479/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
Reid Spencer309080a2006-09-28 19:28:24 +00001480static const unsigned char yytranslate[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001481{
1482 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1483 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1484 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1485 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001486 111, 112, 120, 2, 109, 2, 2, 2, 2, 2,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001487 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001488 116, 108, 117, 2, 2, 2, 2, 2, 2, 2,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001489 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1490 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001491 2, 113, 110, 115, 2, 2, 2, 2, 2, 121,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001492 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1493 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001494 114, 2, 2, 118, 2, 119, 2, 2, 2, 2,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001495 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1497 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1498 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1499 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1500 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1501 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1505 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1507 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1508 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1509 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1510 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1511 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1512 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1513 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1514 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1515 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1516 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1517 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001518 105, 106, 107
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001519};
1520
1521#if YYDEBUG
1522/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1523 YYRHS. */
Reid Spencer309080a2006-09-28 19:28:24 +00001524static const unsigned short int yyprhs[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001525{
1526 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1527 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1528 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1529 59, 61, 63, 65, 67, 70, 71, 73, 75, 77,
1530 79, 81, 83, 85, 86, 87, 89, 91, 93, 95,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001531 97, 99, 102, 103, 106, 107, 111, 114, 115, 117,
1532 118, 122, 124, 127, 129, 131, 133, 135, 137, 139,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001533 141, 143, 145, 147, 149, 151, 153, 155, 157, 159,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001534 161, 163, 165, 167, 169, 172, 177, 183, 189, 193,
1535 196, 199, 201, 205, 207, 211, 213, 214, 219, 223,
1536 227, 232, 237, 241, 244, 247, 250, 253, 256, 259,
1537 262, 265, 268, 271, 278, 284, 293, 300, 307, 314,
1538 321, 328, 337, 346, 350, 352, 354, 356, 358, 361,
1539 364, 369, 372, 374, 379, 382, 387, 388, 396, 397,
1540 405, 406, 414, 415, 423, 427, 432, 433, 435, 437,
1541 439, 443, 447, 451, 455, 459, 461, 462, 464, 466,
1542 468, 469, 472, 476, 478, 480, 484, 486, 487, 496,
1543 498, 500, 504, 506, 508, 511, 512, 514, 516, 517,
1544 522, 523, 525, 527, 529, 531, 533, 535, 537, 539,
1545 541, 545, 547, 553, 555, 557, 559, 561, 564, 567,
1546 570, 574, 577, 578, 580, 583, 586, 590, 600, 610,
1547 619, 633, 635, 637, 644, 650, 653, 660, 668, 670,
1548 674, 676, 677, 680, 682, 688, 694, 700, 703, 708,
1549 713, 720, 725, 730, 735, 740, 747, 754, 757, 765,
1550 767, 770, 771, 773, 774, 778, 785, 789, 796, 799,
1551 804, 811
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001552};
1553
Reid Spencer309080a2006-09-28 19:28:24 +00001554/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1555static const short int yyrhs[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001556{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001557 153, 0, -1, 5, -1, 6, -1, 3, -1, 4,
1558 -1, 77, -1, 78, -1, 79, -1, 80, -1, 81,
1559 -1, 82, -1, 83, -1, 84, -1, 85, -1, 86,
1560 -1, 87, -1, 88, -1, 89, -1, 90, -1, 100,
1561 -1, 101, -1, 16, -1, 14, -1, 12, -1, 10,
1562 -1, 17, -1, 15, -1, 13, -1, 11, -1, 129,
1563 -1, 130, -1, 18, -1, 19, -1, 165, 108, -1,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001564 -1, 41, -1, 42, -1, 43, -1, 44, -1, 45,
1565 -1, 46, -1, 47, -1, -1, -1, 65, -1, 66,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001566 -1, 67, -1, 68, -1, 69, -1, 70, -1, 64,
1567 4, -1, -1, 57, 4, -1, -1, 109, 57, 4,
1568 -1, 34, 24, -1, -1, 138, -1, -1, 109, 141,
1569 140, -1, 138, -1, 57, 4, -1, 144, -1, 8,
1570 -1, 146, -1, 8, -1, 146, -1, 9, -1, 10,
1571 -1, 11, -1, 12, -1, 13, -1, 14, -1, 15,
1572 -1, 16, -1, 17, -1, 18, -1, 19, -1, 20,
1573 -1, 21, -1, 48, -1, 145, -1, 180, -1, 110,
1574 4, -1, 143, 111, 148, 112, -1, 113, 4, 114,
1575 146, 115, -1, 116, 4, 114, 146, 117, -1, 118,
1576 147, 119, -1, 118, 119, -1, 146, 120, -1, 146,
1577 -1, 147, 109, 146, -1, 147, -1, 147, 109, 37,
1578 -1, 37, -1, -1, 144, 113, 151, 115, -1, 144,
1579 113, 115, -1, 144, 121, 24, -1, 144, 116, 151,
1580 117, -1, 144, 118, 151, 119, -1, 144, 118, 119,
1581 -1, 144, 38, -1, 144, 39, -1, 144, 180, -1,
1582 144, 150, -1, 144, 26, -1, 129, 124, -1, 130,
1583 4, -1, 9, 27, -1, 9, 28, -1, 132, 7,
1584 -1, 98, 111, 149, 36, 144, 112, -1, 96, 111,
1585 149, 194, 112, -1, 99, 111, 149, 109, 149, 109,
1586 149, 112, -1, 125, 111, 149, 109, 149, 112, -1,
1587 126, 111, 149, 109, 149, 112, -1, 127, 111, 149,
1588 109, 149, 112, -1, 128, 111, 149, 109, 149, 112,
1589 -1, 103, 111, 149, 109, 149, 112, -1, 104, 111,
1590 149, 109, 149, 109, 149, 112, -1, 105, 111, 149,
1591 109, 149, 109, 149, 112, -1, 151, 109, 149, -1,
1592 149, -1, 32, -1, 33, -1, 154, -1, 154, 174,
1593 -1, 154, 176, -1, 154, 62, 61, 160, -1, 154,
1594 25, -1, 155, -1, 155, 133, 20, 142, -1, 155,
1595 176, -1, 155, 62, 61, 160, -1, -1, 155, 133,
1596 134, 152, 149, 156, 140, -1, -1, 155, 133, 50,
1597 152, 144, 157, 140, -1, -1, 155, 133, 45, 152,
1598 144, 158, 140, -1, -1, 155, 133, 47, 152, 144,
1599 159, 140, -1, 155, 51, 162, -1, 155, 58, 108,
1600 163, -1, -1, 24, -1, 56, -1, 55, -1, 53,
1601 108, 161, -1, 54, 108, 4, -1, 52, 108, 24,
1602 -1, 113, 164, 115, -1, 164, 109, 24, -1, 24,
1603 -1, -1, 22, -1, 24, -1, 165, -1, -1, 144,
1604 166, -1, 168, 109, 167, -1, 167, -1, 168, -1,
1605 168, 109, 37, -1, 37, -1, -1, 135, 142, 165,
1606 111, 169, 112, 139, 136, -1, 29, -1, 118, -1,
1607 134, 170, 171, -1, 30, -1, 119, -1, 183, 173,
1608 -1, -1, 45, -1, 47, -1, -1, 31, 177, 175,
1609 170, -1, -1, 63, -1, 3, -1, 4, -1, 7,
1610 -1, 27, -1, 28, -1, 38, -1, 39, -1, 26,
1611 -1, 116, 151, 117, -1, 150, -1, 61, 178, 24,
1612 109, 24, -1, 123, -1, 165, -1, 180, -1, 179,
1613 -1, 144, 181, -1, 183, 184, -1, 172, 184, -1,
1614 185, 133, 186, -1, 185, 188, -1, -1, 23, -1,
1615 71, 182, -1, 71, 8, -1, 72, 21, 181, -1,
1616 72, 9, 181, 109, 21, 181, 109, 21, 181, -1,
1617 73, 131, 181, 109, 21, 181, 113, 187, 115, -1,
1618 73, 131, 181, 109, 21, 181, 113, 115, -1, 74,
1619 135, 142, 181, 111, 191, 112, 36, 21, 181, 75,
1620 21, 181, -1, 75, -1, 76, -1, 187, 131, 179,
1621 109, 21, 181, -1, 131, 179, 109, 21, 181, -1,
1622 133, 193, -1, 144, 113, 181, 109, 181, 115, -1,
1623 189, 109, 113, 181, 109, 181, 115, -1, 182, -1,
1624 190, 109, 182, -1, 190, -1, -1, 60, 59, -1,
1625 59, -1, 125, 144, 181, 109, 181, -1, 126, 144,
1626 181, 109, 181, -1, 127, 144, 181, 109, 181, -1,
1627 49, 182, -1, 128, 182, 109, 182, -1, 98, 182,
1628 36, 144, -1, 99, 182, 109, 182, 109, 182, -1,
1629 102, 182, 109, 144, -1, 106, 182, 109, 144, -1,
1630 107, 182, 109, 144, -1, 103, 182, 109, 182, -1,
1631 104, 182, 109, 182, 109, 182, -1, 105, 182, 109,
1632 182, 109, 182, -1, 97, 189, -1, 192, 135, 142,
1633 181, 111, 191, 112, -1, 196, -1, 109, 190, -1,
1634 -1, 35, -1, -1, 91, 144, 137, -1, 91, 144,
1635 109, 15, 181, 137, -1, 92, 144, 137, -1, 92,
1636 144, 109, 15, 181, 137, -1, 93, 182, -1, 195,
1637 94, 144, 181, -1, 195, 95, 182, 109, 144, 181,
1638 -1, 96, 144, 181, 194, -1
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001639};
1640
1641/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
Reid Spencer309080a2006-09-28 19:28:24 +00001642static const unsigned short int yyrline[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001643{
Reid Spencer309080a2006-09-28 19:28:24 +00001644 0, 1088, 1088, 1089, 1097, 1098, 1108, 1108, 1108, 1108,
1645 1108, 1109, 1109, 1109, 1110, 1110, 1110, 1110, 1110, 1110,
1646 1112, 1112, 1116, 1116, 1116, 1116, 1117, 1117, 1117, 1117,
1647 1118, 1118, 1119, 1119, 1122, 1126, 1131, 1132, 1133, 1134,
1648 1135, 1136, 1137, 1138, 1140, 1141, 1142, 1143, 1144, 1145,
1649 1146, 1147, 1156, 1157, 1163, 1164, 1172, 1180, 1181, 1186,
1650 1187, 1188, 1193, 1207, 1207, 1208, 1208, 1210, 1220, 1220,
1651 1220, 1220, 1220, 1220, 1220, 1221, 1221, 1221, 1221, 1221,
1652 1221, 1222, 1226, 1230, 1238, 1246, 1259, 1264, 1276, 1286,
1653 1290, 1299, 1304, 1310, 1311, 1315, 1319, 1330, 1356, 1370,
1654 1400, 1426, 1447, 1460, 1470, 1475, 1536, 1543, 1552, 1558,
1655 1564, 1568, 1572, 1580, 1591, 1623, 1631, 1653, 1664, 1670,
1656 1678, 1684, 1690, 1699, 1703, 1711, 1711, 1721, 1729, 1734,
1657 1738, 1742, 1746, 1761, 1783, 1786, 1789, 1789, 1797, 1797,
1658 1805, 1805, 1813, 1813, 1822, 1825, 1828, 1832, 1845, 1846,
1659 1848, 1852, 1861, 1867, 1869, 1874, 1879, 1888, 1888, 1889,
1660 1889, 1891, 1898, 1904, 1911, 1915, 1921, 1926, 1931, 2026,
1661 2026, 2028, 2036, 2036, 2038, 2043, 2044, 2045, 2047, 2047,
1662 2057, 2061, 2066, 2070, 2074, 2078, 2082, 2086, 2090, 2094,
1663 2098, 2123, 2127, 2141, 2145, 2151, 2151, 2157, 2162, 2166,
1664 2175, 2186, 2191, 2203, 2216, 2220, 2224, 2229, 2238, 2257,
1665 2266, 2322, 2326, 2333, 2344, 2357, 2366, 2375, 2385, 2389,
1666 2396, 2396, 2398, 2402, 2407, 2423, 2438, 2452, 2465, 2473,
1667 2481, 2489, 2495, 2515, 2538, 2544, 2550, 2556, 2571, 2630,
1668 2637, 2640, 2645, 2649, 2656, 2661, 2667, 2672, 2678, 2686,
1669 2698, 2713
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001670};
1671#endif
1672
1673#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1674/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
Reid Spencer309080a2006-09-28 19:28:24 +00001675 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001676static const char *const yytname[] =
1677{
1678 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1679 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1680 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1681 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1682 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1683 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1684 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
1685 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1686 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
1687 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1688 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001689 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "RET", "BR",
1690 "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB", "MUL", "DIV",
1691 "REM", "AND", "OR", "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ",
1692 "SETNE", "MALLOC", "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR",
1693 "PHI_TOK", "CAST", "SELECT", "SHL", "SHR", "VAARG", "EXTRACTELEMENT",
1694 "INSERTELEMENT", "SHUFFLEVECTOR", "VAARG_old", "VANEXT_old", "'='",
1695 "','", "'\\\\'", "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'",
1696 "'}'", "'*'", "'c'", "$accept", "INTVAL", "EINT64VAL", "ArithmeticOps",
1697 "LogicalOps", "SetCondOps", "ShiftOps", "SIntType", "UIntType",
1698 "IntType", "FPType", "OptAssign", "OptLinkage", "OptCallingConv",
1699 "OptAlign", "OptCAlign", "SectionString", "OptSection",
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001700 "GlobalVarAttributes", "GlobalVarAttribute", "TypesV", "UpRTypesV",
1701 "Types", "PrimType", "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal",
1702 "ConstExpr", "ConstVector", "GlobalType", "Module", "FunctionList",
1703 "ConstPool", "@1", "@2", "@3", "@4", "AsmBlock", "BigOrLittle",
1704 "TargetDefinition", "LibrariesDefinition", "LibList", "Name", "OptName",
1705 "ArgVal", "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN",
1706 "FunctionHeader", "END", "Function", "FnDeclareLinkage", "FunctionProto",
1707 "@5", "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
1708 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1709 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList",
1710 "ValueRefListE", "OptTailCall", "InstVal", "IndexList", "OptVolatile",
1711 "MemoryInst", 0
1712};
1713#endif
1714
1715# ifdef YYPRINT
1716/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1717 token YYLEX-NUM. */
Reid Spencer309080a2006-09-28 19:28:24 +00001718static const unsigned short int yytoknum[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001719{
1720 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1721 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1722 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1723 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1724 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1725 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1726 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1727 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1728 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1729 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001730 355, 356, 357, 358, 359, 360, 361, 362, 61, 44,
1731 92, 40, 41, 91, 120, 93, 60, 62, 123, 125,
1732 42, 99
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001733};
1734# endif
1735
1736/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
Reid Spencer309080a2006-09-28 19:28:24 +00001737static const unsigned char yyr1[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001738{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001739 0, 122, 123, 123, 124, 124, 125, 125, 125, 125,
1740 125, 126, 126, 126, 127, 127, 127, 127, 127, 127,
1741 128, 128, 129, 129, 129, 129, 130, 130, 130, 130,
1742 131, 131, 132, 132, 133, 133, 134, 134, 134, 134,
1743 134, 134, 134, 134, 135, 135, 135, 135, 135, 135,
1744 135, 135, 136, 136, 137, 137, 138, 139, 139, 140,
1745 140, 141, 141, 142, 142, 143, 143, 144, 145, 145,
1746 145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
1747 145, 146, 146, 146, 146, 146, 146, 146, 146, 146,
1748 146, 147, 147, 148, 148, 148, 148, 149, 149, 149,
1749 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
1750 149, 149, 149, 150, 150, 150, 150, 150, 150, 150,
1751 150, 150, 150, 151, 151, 152, 152, 153, 154, 154,
1752 154, 154, 154, 155, 155, 155, 156, 155, 157, 155,
1753 158, 155, 159, 155, 155, 155, 155, 160, 161, 161,
1754 162, 162, 162, 163, 164, 164, 164, 165, 165, 166,
1755 166, 167, 168, 168, 169, 169, 169, 169, 170, 171,
1756 171, 172, 173, 173, 174, 175, 175, 175, 177, 176,
1757 178, 178, 179, 179, 179, 179, 179, 179, 179, 179,
1758 179, 179, 179, 180, 180, 181, 181, 182, 183, 183,
1759 184, 185, 185, 185, 186, 186, 186, 186, 186, 186,
1760 186, 186, 186, 187, 187, 188, 189, 189, 190, 190,
1761 191, 191, 192, 192, 193, 193, 193, 193, 193, 193,
1762 193, 193, 193, 193, 193, 193, 193, 193, 193, 193,
1763 194, 194, 195, 195, 196, 196, 196, 196, 196, 196,
1764 196, 196
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001765};
1766
1767/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
Reid Spencer309080a2006-09-28 19:28:24 +00001768static const unsigned char yyr2[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001769{
1770 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1771 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1772 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1773 1, 1, 1, 1, 2, 0, 1, 1, 1, 1,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001774 1, 1, 1, 0, 0, 1, 1, 1, 1, 1,
1775 1, 2, 0, 2, 0, 3, 2, 0, 1, 0,
1776 3, 1, 2, 1, 1, 1, 1, 1, 1, 1,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001777 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001778 1, 1, 1, 1, 2, 4, 5, 5, 3, 2,
1779 2, 1, 3, 1, 3, 1, 0, 4, 3, 3,
1780 4, 4, 3, 2, 2, 2, 2, 2, 2, 2,
1781 2, 2, 2, 6, 5, 8, 6, 6, 6, 6,
1782 6, 8, 8, 3, 1, 1, 1, 1, 2, 2,
1783 4, 2, 1, 4, 2, 4, 0, 7, 0, 7,
1784 0, 7, 0, 7, 3, 4, 0, 1, 1, 1,
1785 3, 3, 3, 3, 3, 1, 0, 1, 1, 1,
1786 0, 2, 3, 1, 1, 3, 1, 0, 8, 1,
1787 1, 3, 1, 1, 2, 0, 1, 1, 0, 4,
1788 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1789 3, 1, 5, 1, 1, 1, 1, 2, 2, 2,
1790 3, 2, 0, 1, 2, 2, 3, 9, 9, 8,
1791 13, 1, 1, 6, 5, 2, 6, 7, 1, 3,
1792 1, 0, 2, 1, 5, 5, 5, 2, 4, 4,
1793 6, 4, 4, 4, 4, 6, 6, 2, 7, 1,
1794 2, 0, 1, 0, 3, 6, 3, 6, 2, 4,
1795 6, 4
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001796};
1797
1798/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1799 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1800 means the default is an error. */
Reid Spencer309080a2006-09-28 19:28:24 +00001801static const unsigned char yydefact[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001802{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001803 146, 0, 43, 132, 1, 131, 178, 36, 37, 38,
1804 39, 40, 41, 42, 0, 44, 202, 128, 129, 202,
1805 157, 158, 0, 0, 0, 43, 0, 134, 175, 0,
1806 0, 45, 46, 47, 48, 49, 50, 0, 0, 203,
1807 199, 35, 172, 173, 174, 198, 0, 0, 0, 144,
1808 0, 0, 0, 0, 0, 0, 0, 34, 176, 177,
1809 44, 147, 130, 51, 2, 3, 64, 68, 69, 70,
1810 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
1811 81, 0, 0, 0, 0, 193, 0, 0, 63, 82,
1812 67, 194, 83, 169, 170, 171, 243, 201, 0, 0,
1813 0, 156, 145, 135, 133, 125, 126, 0, 0, 0,
1814 0, 179, 84, 0, 0, 66, 89, 91, 0, 0,
1815 96, 90, 242, 0, 223, 0, 0, 0, 0, 44,
1816 211, 212, 6, 7, 8, 9, 10, 11, 12, 13,
1817 14, 15, 16, 17, 18, 19, 0, 0, 0, 0,
1818 0, 0, 0, 20, 21, 0, 0, 0, 0, 0,
1819 0, 0, 0, 0, 0, 200, 44, 215, 0, 239,
1820 152, 149, 148, 150, 151, 155, 0, 140, 142, 138,
1821 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1822 78, 0, 0, 0, 0, 136, 0, 0, 0, 88,
1823 167, 95, 93, 0, 0, 227, 222, 205, 204, 0,
1824 0, 25, 29, 24, 28, 23, 27, 22, 26, 30,
1825 31, 0, 0, 54, 54, 248, 0, 0, 237, 0,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001826 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001827 0, 0, 0, 0, 0, 153, 59, 59, 59, 110,
1828 111, 4, 5, 108, 109, 112, 107, 103, 104, 0,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001829 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001830 0, 0, 0, 106, 105, 59, 65, 65, 92, 166,
1831 160, 163, 164, 0, 0, 85, 182, 183, 184, 189,
1832 185, 186, 187, 188, 180, 0, 191, 196, 195, 197,
1833 0, 206, 0, 0, 0, 244, 0, 246, 241, 0,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001834 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001835 0, 0, 0, 0, 0, 0, 154, 0, 141, 143,
1836 139, 0, 0, 0, 0, 0, 0, 98, 124, 0,
1837 0, 102, 0, 99, 0, 0, 0, 0, 137, 86,
1838 87, 159, 161, 0, 57, 94, 181, 0, 0, 0,
1839 0, 0, 0, 0, 0, 0, 251, 0, 0, 229,
1840 0, 231, 234, 0, 0, 232, 233, 0, 0, 0,
1841 228, 0, 249, 0, 0, 0, 61, 59, 241, 0,
1842 0, 0, 0, 0, 0, 97, 100, 101, 0, 0,
1843 0, 0, 165, 162, 58, 52, 0, 190, 0, 0,
1844 221, 54, 55, 54, 218, 240, 0, 0, 0, 0,
1845 0, 224, 225, 226, 221, 0, 56, 62, 60, 0,
1846 0, 0, 0, 0, 0, 123, 0, 0, 0, 0,
1847 0, 168, 0, 0, 0, 220, 0, 0, 245, 247,
1848 0, 0, 0, 230, 235, 236, 0, 250, 114, 0,
1849 0, 0, 0, 0, 0, 0, 0, 0, 53, 192,
1850 0, 0, 0, 219, 216, 0, 238, 113, 0, 120,
1851 0, 0, 116, 117, 118, 119, 0, 209, 0, 0,
1852 0, 217, 0, 0, 0, 207, 0, 208, 0, 0,
1853 115, 121, 122, 0, 0, 0, 0, 0, 0, 214,
1854 0, 0, 213, 210
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001855};
1856
Reid Spencer309080a2006-09-28 19:28:24 +00001857/* YYDEFGOTO[NTERM-NUM]. */
1858static const short int yydefgoto[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001859{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001860 -1, 85, 253, 269, 270, 271, 272, 191, 192, 221,
1861 193, 25, 15, 37, 441, 305, 386, 405, 328, 387,
1862 86, 87, 194, 89, 90, 118, 203, 338, 296, 339,
1863 107, 1, 2, 3, 275, 248, 246, 247, 62, 173,
1864 49, 102, 176, 91, 352, 281, 282, 283, 38, 95,
1865 16, 44, 17, 60, 18, 28, 357, 297, 92, 299,
1866 414, 19, 40, 41, 165, 489, 97, 228, 445, 446,
1867 166, 167, 366, 168, 169
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001868};
1869
1870/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1871 STATE-NUM. */
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001872#define YYPACT_NINF -428
Reid Spencer309080a2006-09-28 19:28:24 +00001873static const short int yypact[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001874{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001875 -428, 45, 194, 602, -428, -428, -428, -428, -428, -428,
1876 -428, -428, -428, -428, 26, 14, 85, -428, -428, -13,
1877 -428, -428, 91, 28, 90, 49, 33, -428, 21, 155,
1878 158, -428, -428, -428, -428, -428, -428, 1052, -20, -428,
1879 -428, 80, -428, -428, -428, -428, 75, 76, 79, -428,
1880 73, 155, 1052, 84, 84, 84, 84, -428, -428, -428,
1881 14, -428, -428, -428, -428, -428, 77, -428, -428, -428,
1882 -428, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1883 -428, 185, 187, 191, 569, -428, 80, 86, -428, -428,
1884 -44, -428, -428, -428, -428, -428, 1223, -428, 175, 78,
1885 192, 176, -428, -428, -428, -428, -428, 1093, 1093, 1093,
1886 1134, -428, -428, 87, 88, -428, -428, -44, -95, 92,
1887 847, -428, -428, 1093, -428, 139, 1175, 52, 144, 14,
1888 -428, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1889 -428, -428, -428, -428, -428, -428, 1093, 1093, 1093, 1093,
1890 1093, 1093, 1093, -428, -428, 1093, 1093, 1093, 1093, 1093,
1891 1093, 1093, 1093, 1093, 1093, -428, 14, -428, 44, -428,
1892 -428, -428, -428, -428, -428, -428, -12, -428, -428, -428,
1893 138, 164, 203, 167, 204, 169, 205, 172, 206, 210,
1894 211, 174, 208, 213, 412, -428, 1093, 1093, 1093, -428,
1895 888, -428, 113, 111, 635, -428, -428, 77, -428, 635,
1896 635, -428, -428, -428, -428, -428, -428, -428, -428, -428,
1897 -428, 635, 1052, 115, 117, -428, 635, 114, 119, 212,
1898 140, 141, 142, 145, 146, 148, 149, 635, 635, 635,
1899 150, 1052, 1093, 1093, 223, -428, 151, 151, 151, -428,
1900 -428, -428, -428, -428, -428, -428, -428, -428, -428, 152,
1901 153, 154, 157, 159, 162, 929, 1134, 589, 229, 173,
1902 178, 179, 180, -428, -428, 151, -15, 15, -44, -428,
1903 80, -428, 160, 181, 970, -428, -428, -428, -428, -428,
1904 -428, -428, -428, -428, 198, 1134, -428, -428, -428, -428,
1905 177, -428, 186, 635, -4, -428, 3, -428, 188, 635,
1906 183, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 189,
1907 193, 195, 1093, 635, 635, 197, -428, -11, -428, -428,
1908 -428, 1134, 1134, 1134, 1134, 1134, 1134, -428, -428, -8,
1909 -96, -428, -45, -428, 1134, 1134, 1134, 1134, -428, -428,
1910 -428, -428, -428, 1011, 228, -428, -428, 263, -32, 273,
1911 282, 199, 635, 304, 635, 1093, -428, 200, 635, -428,
1912 214, -428, -428, 215, 216, -428, -428, 635, 635, 635,
1913 -428, 201, -428, 1093, 289, 310, -428, 151, 188, 279,
1914 217, 218, 224, 230, 1134, -428, -428, -428, 231, 232,
1915 233, 234, -428, -428, -428, 281, 238, -428, 635, 635,
1916 1093, 239, -428, 239, -428, 241, 635, 244, 1093, 1093,
1917 1093, -428, -428, -428, 1093, 635, -428, -428, -428, 242,
1918 1093, 1134, 1134, 1134, 1134, -428, 1134, 1134, 1134, 1134,
1919 351, -428, 332, 248, 245, 241, 249, 303, -428, -428,
1920 1093, 251, 635, -428, -428, -428, 252, -428, -428, 255,
1921 260, 258, 265, 266, 268, 272, 276, 277, -428, -428,
1922 356, 16, 336, -428, -428, 275, -428, -428, 1134, -428,
1923 1134, 1134, -428, -428, -428, -428, 635, -428, 738, 25,
1924 370, -428, 280, 284, 285, -428, 290, -428, 738, 635,
1925 -428, -428, -428, 373, 291, 323, 635, 380, 381, -428,
1926 635, 635, -428, -428
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001927};
1928
1929/* YYPGOTO[NTERM-NUM]. */
Reid Spencer309080a2006-09-28 19:28:24 +00001930static const short int yypgoto[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001931{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001932 -428, -428, -428, 307, 308, 309, 311, -127, -126, -427,
1933 -428, 365, 383, -117, -428, -221, 55, -428, -241, -428,
1934 -48, -428, -37, -428, -68, 292, -428, -102, 220, -247,
1935 94, -428, -428, -428, -428, -428, -428, -428, 359, -428,
1936 -428, -428, -428, 2, -428, 58, -428, -428, 355, -428,
1937 -428, -428, -428, -428, 413, -428, -428, -423, -57, 62,
1938 -101, -428, 400, -428, -428, -428, -428, -428, 56, -2,
1939 -428, -428, 32, -428, -428
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001940};
1941
1942/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1943 positive, shift that token. If negative, reduce the rule which
1944 number is the opposite. If zero, do what YYDEFACT says.
1945 If YYTABLE_NINF, syntax error. */
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001946#define YYTABLE_NINF -128
Reid Spencer309080a2006-09-28 19:28:24 +00001947static const short int yytable[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001948{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001949 88, 219, 220, 307, 104, 26, 329, 330, 195, 93,
1950 39, 362, 222, 394, 198, 88, 117, 42, 364, 340,
1951 342, 396, 205, 384, 199, 208, 211, 212, 213, 214,
1952 215, 216, 217, 218, 348, 211, 212, 213, 214, 215,
1953 216, 217, 218, 26, 488, 4, 385, 225, 358, 241,
1954 229, 230, 117, 363, 231, 232, 233, 234, 235, 236,
1955 363, 209, 498, 240, 394, 496, 58, -65, 59, 52,
1956 177, 178, 179, 210, 397, 504, 121, 394, 30, 31,
1957 32, 33, 34, 35, 36, 407, 204, 29, 119, 204,
1958 7, 8, 9, 10, 53, 12, 54, 244, 94, 55,
1959 349, 394, 20, 245, 21, 121, 43, 395, 39, 223,
1960 224, 204, 226, 227, 204, 204, 105, 106, 204, 204,
1961 204, 204, 204, 204, 237, 238, 239, 204, 276, 277,
1962 278, 487, 350, 171, 172, 121, 50, 274, 242, 243,
1963 497, 57, 325, 46, 47, 48, 428, 298, 108, 109,
1964 110, 51, 298, 298, 211, 212, 213, 214, 215, 216,
1965 217, 218, 63, 280, 298, 249, 250, -25, -25, 298,
1966 -24, -24, -23, -23, 303, -22, -22, 251, 252, 61,
1967 298, 298, 298, 98, 99, 88, 101, 100, -66, 112,
1968 448, 113, 449, 323, -127, 114, 174, 120, 206, 170,
1969 175, 196, 197, 200, 88, 324, 204, -29, -28, -27,
1970 -26, 370, 254, 372, 373, 374, 278, -32, -33, 5,
1971 255, 380, 284, 285, 304, 6, 306, 309, 310, 388,
1972 389, 390, 391, 392, 393, 7, 8, 9, 10, 11,
1973 12, 13, 398, 399, 400, 401, 298, 326, 311, 312,
1974 313, 314, 298, 343, 315, 316, 14, 317, 318, 322,
1975 327, 356, 384, 331, 332, 333, 298, 298, 334, 353,
1976 335, 300, 301, 336, 369, 204, 371, 204, 204, 204,
1977 375, 376, 351, 302, 344, 204, 359, 406, 308, 345,
1978 346, 347, 435, 354, 408, 360, 368, 365, 377, 319,
1979 320, 321, 378, 409, 379, 298, 383, 298, 412, 416,
1980 410, 298, 424, 426, 427, 430, 280, 453, 454, 455,
1981 298, 298, 298, 418, 419, 420, 431, 432, 204, 460,
1982 461, 462, 463, 433, 464, 465, 466, 467, 440, 434,
1983 436, 437, 438, 439, 219, 220, 425, 442, 447, 473,
1984 450, 298, 298, 452, 458, 468, 469, 470, 471, 298,
1985 363, 472, 219, 220, 476, 361, 474, 477, 298, 478,
1986 479, 367, 490, 204, 480, 481, 492, 486, 493, 494,
1987 482, 204, 204, 204, 483, 381, 382, 204, 484, 485,
1988 491, 499, 500, 459, 506, 298, 501, 502, 508, 503,
1989 507, 510, 511, 161, 162, 163, 96, 164, 56, 404,
1990 103, 403, 202, 204, 273, 111, 27, 64, 65, 45,
1991 429, 415, 456, 0, 411, 0, 413, 0, 0, 298,
1992 417, 0, 0, 0, 20, 0, 21, 0, 256, 421,
1993 422, 423, 298, 0, 0, 0, 0, 0, 0, 298,
1994 257, 258, 0, 298, 298, 0, 0, 0, 0, 0,
1995 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1996 443, 444, 0, 0, 0, 0, 0, 0, 451, 0,
1997 0, 0, 0, 0, 0, 0, 0, 457, 0, 132,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001998 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00001999 143, 144, 145, 0, 0, 0, 0, 0, 259, 0,
2000 260, 261, 153, 154, 475, 262, 263, 264, 0, 0,
2001 0, 0, 0, 0, 0, 265, 0, 0, 266, 0,
2002 267, 0, 0, 268, 0, 0, 0, 0, 0, 0,
2003 0, 0, 0, 0, 0, 0, 0, 0, 495, 0,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002004 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002005 0, 505, 0, 0, 0, 0, 0, 0, 509, 0,
2006 0, 0, 512, 513, 64, 65, 0, 115, 67, 68,
2007 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2008 79, 20, 0, 21, 64, 65, 0, 115, 180, 181,
2009 182, 183, 184, 185, 186, 187, 188, 189, 190, 78,
2010 79, 20, 0, 21, 0, 0, 0, 80, 0, 0,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002011 0, 0, -35, 0, 20, 0, 21, 0, 0, 0,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002012 0, 0, 0, 6, -35, -35, 0, 80, 286, 287,
2013 64, 65, 288, -35, -35, -35, -35, -35, -35, -35,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002014 0, 0, -35, 22, 0, 0, 0, 20, 0, 21,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002015 23, 289, 290, 291, 24, 0, 0, 0, 0, 0,
2016 0, 0, 0, 292, 293, 0, 0, 0, 0, 81,
2017 0, 0, 82, 0, 0, 83, 0, 84, 116, 0,
2018 0, 0, 0, 0, 0, 0, 294, 0, 0, 81,
2019 0, 0, 82, 0, 0, 83, 0, 84, 341, 0,
2020 0, 0, 132, 133, 134, 135, 136, 137, 138, 139,
2021 140, 141, 142, 143, 144, 145, 0, 0, 0, 0,
2022 0, 259, 0, 260, 261, 153, 154, 0, 262, 263,
2023 264, 286, 287, 0, 0, 288, 0, 0, 0, 0,
2024 0, 295, 0, 0, 0, 0, 0, 0, 0, 0,
2025 0, 0, 0, 0, 289, 290, 291, 0, 0, 0,
2026 0, 0, 0, 0, 0, 0, 292, 293, 0, 0,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002027 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002028 0, 0, 0, 0, 0, 0, 0, 0, 0, 294,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002029 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002030 0, 0, 0, 0, 0, 132, 133, 134, 135, 136,
2031 137, 138, 139, 140, 141, 142, 143, 144, 145, 0,
2032 0, 0, 0, 0, 259, 0, 260, 261, 153, 154,
2033 0, 262, 263, 264, 0, 0, 0, 0, 0, 0,
2034 0, 0, 64, 65, 295, 115, 67, 68, 69, 70,
2035 71, 72, 73, 74, 75, 76, 77, 78, 79, 20,
2036 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2037 0, 0, 0, 0, 201, 0, 0, 0, 0, 0,
2038 0, 0, 0, 64, 65, 80, 115, 67, 68, 69,
2039 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2040 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2041 0, 0, 0, 0, 0, 279, 0, 0, 0, 0,
2042 0, 0, 0, 0, 64, 65, 80, 115, 180, 181,
2043 182, 183, 184, 185, 186, 187, 188, 189, 190, 78,
2044 79, 20, 0, 21, 0, 0, 0, 81, 0, 0,
2045 82, 0, 0, 83, 0, 84, 0, 0, 0, 0,
2046 0, 0, 0, 0, 0, 64, 65, 80, 115, 67,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002047 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002048 78, 79, 20, 0, 21, 0, 0, 0, 81, 0,
2049 0, 82, 0, 0, 83, 0, 84, 355, 0, 0,
2050 0, 0, 0, 0, 0, 0, 64, 65, 80, 115,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002051 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002052 77, 78, 79, 20, 0, 21, 0, 0, 0, 81,
2053 0, 0, 82, 0, 337, 83, 0, 84, 402, 0,
2054 0, 0, 0, 0, 0, 0, 0, 64, 65, 80,
2055 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
2056 76, 77, 78, 79, 20, 0, 21, 0, 0, 0,
2057 81, 0, 0, 82, 0, 0, 83, 0, 84, 0,
2058 0, 0, 0, 0, 0, 0, 0, 0, 64, 65,
2059 80, 115, 67, 68, 69, 70, 71, 72, 73, 74,
2060 75, 76, 77, 78, 79, 20, 0, 21, 0, 0,
2061 0, 81, 0, 0, 82, 0, 0, 83, 0, 84,
2062 0, 0, 0, 0, 0, 0, 0, 0, 0, 64,
2063 65, 80, 115, 180, 181, 182, 183, 184, 185, 186,
2064 187, 188, 189, 190, 78, 79, 20, 0, 21, 0,
2065 0, 0, 81, 0, 0, 82, 0, 0, 83, 0,
2066 84, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2067 64, 65, 80, 207, 67, 68, 69, 70, 71, 72,
2068 73, 74, 75, 76, 77, 78, 79, 20, 0, 21,
2069 0, 0, 0, 81, 0, 0, 82, 0, 0, 83,
2070 0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
2071 0, 0, 0, 80, 0, 0, 0, 0, 0, 0,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002072 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002073 0, 0, 0, 0, 81, 0, 0, 82, 0, 0,
2074 83, 0, 84, 0, 0, 0, 0, 0, 122, 0,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002075 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002076 0, 0, 123, 0, 0, 0, 0, 0, 0, 0,
2077 0, 0, 124, 125, 0, 81, 0, 0, 82, 0,
2078 0, 83, 0, 84, 126, 127, 128, 129, 130, 131,
2079 132, 133, 134, 135, 136, 137, 138, 139, 140, 141,
2080 142, 143, 144, 145, 146, 147, 148, 0, 0, 149,
2081 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
2082 160
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002083};
2084
Reid Spencer309080a2006-09-28 19:28:24 +00002085static const short int yycheck[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002086{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002087 37, 128, 128, 224, 52, 3, 247, 248, 110, 29,
2088 23, 15, 129, 109, 109, 52, 84, 30, 15, 266,
2089 267, 117, 123, 34, 119, 126, 10, 11, 12, 13,
2090 14, 15, 16, 17, 275, 10, 11, 12, 13, 14,
2091 15, 16, 17, 41, 471, 0, 57, 148, 295, 166,
2092 151, 152, 120, 57, 155, 156, 157, 158, 159, 160,
2093 57, 9, 489, 164, 109, 488, 45, 111, 47, 20,
2094 107, 108, 109, 21, 119, 498, 120, 109, 64, 65,
2095 66, 67, 68, 69, 70, 117, 123, 61, 86, 126,
2096 41, 42, 43, 44, 45, 46, 47, 109, 118, 50,
2097 115, 109, 22, 115, 24, 120, 119, 115, 23, 146,
2098 147, 148, 149, 150, 151, 152, 32, 33, 155, 156,
2099 157, 158, 159, 160, 161, 162, 163, 164, 196, 197,
2100 198, 115, 117, 55, 56, 120, 108, 194, 94, 95,
2101 115, 108, 243, 52, 53, 54, 387, 204, 54, 55,
2102 56, 61, 209, 210, 10, 11, 12, 13, 14, 15,
2103 16, 17, 4, 200, 221, 27, 28, 3, 4, 226,
2104 3, 4, 3, 4, 222, 3, 4, 3, 4, 24,
2105 237, 238, 239, 108, 108, 222, 113, 108, 111, 4,
2106 411, 4, 413, 241, 0, 4, 4, 111, 59, 24,
2107 24, 114, 114, 111, 241, 242, 243, 4, 4, 4,
2108 4, 312, 4, 314, 315, 316, 284, 7, 7, 25,
2109 7, 322, 109, 112, 109, 31, 109, 113, 109, 331,
2110 332, 333, 334, 335, 336, 41, 42, 43, 44, 45,
2111 46, 47, 344, 345, 346, 347, 303, 24, 36, 109,
2112 109, 109, 309, 24, 109, 109, 62, 109, 109, 109,
2113 109, 63, 34, 111, 111, 111, 323, 324, 111, 109,
2114 111, 209, 210, 111, 311, 312, 313, 314, 315, 316,
2115 317, 318, 280, 221, 111, 322, 109, 24, 226, 111,
2116 111, 111, 394, 112, 21, 109, 113, 109, 109, 237,
2117 238, 239, 109, 21, 109, 362, 109, 364, 4, 109,
2118 111, 368, 111, 24, 4, 36, 353, 418, 419, 420,
2119 377, 378, 379, 109, 109, 109, 109, 109, 365, 431,
2120 432, 433, 434, 109, 436, 437, 438, 439, 57, 109,
2121 109, 109, 109, 109, 471, 471, 383, 109, 109, 450,
2122 109, 408, 409, 109, 112, 4, 24, 109, 113, 416,
2123 57, 112, 489, 489, 112, 303, 115, 112, 425, 109,
2124 112, 309, 36, 410, 109, 109, 478, 21, 480, 481,
2125 112, 418, 419, 420, 112, 323, 324, 424, 112, 112,
2126 115, 21, 112, 430, 21, 452, 112, 112, 75, 109,
2127 109, 21, 21, 96, 96, 96, 41, 96, 25, 354,
2128 51, 353, 120, 450, 194, 60, 3, 5, 6, 19,
2129 388, 365, 424, -1, 362, -1, 364, -1, -1, 486,
2130 368, -1, -1, -1, 22, -1, 24, -1, 26, 377,
2131 378, 379, 499, -1, -1, -1, -1, -1, -1, 506,
2132 38, 39, -1, 510, 511, -1, -1, -1, -1, -1,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002133 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002134 408, 409, -1, -1, -1, -1, -1, -1, 416, -1,
2135 -1, -1, -1, -1, -1, -1, -1, 425, -1, 77,
2136 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
2137 88, 89, 90, -1, -1, -1, -1, -1, 96, -1,
2138 98, 99, 100, 101, 452, 103, 104, 105, -1, -1,
2139 -1, -1, -1, -1, -1, 113, -1, -1, 116, -1,
2140 118, -1, -1, 121, -1, -1, -1, -1, -1, -1,
2141 -1, -1, -1, -1, -1, -1, -1, -1, 486, -1,
2142 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2143 -1, 499, -1, -1, -1, -1, -1, -1, 506, -1,
2144 -1, -1, 510, 511, 5, 6, -1, 8, 9, 10,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002145 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2146 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2147 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2148 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2149 -1, -1, 20, -1, 22, -1, 24, -1, -1, -1,
2150 -1, -1, -1, 31, 32, 33, -1, 48, 3, 4,
2151 5, 6, 7, 41, 42, 43, 44, 45, 46, 47,
2152 -1, -1, 50, 51, -1, -1, -1, 22, -1, 24,
2153 58, 26, 27, 28, 62, -1, -1, -1, -1, -1,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002154 -1, -1, -1, 38, 39, -1, -1, -1, -1, 110,
2155 -1, -1, 113, -1, -1, 116, -1, 118, 119, -1,
2156 -1, -1, -1, -1, -1, -1, 61, -1, -1, 110,
2157 -1, -1, 113, -1, -1, 116, -1, 118, 119, -1,
2158 -1, -1, 77, 78, 79, 80, 81, 82, 83, 84,
2159 85, 86, 87, 88, 89, 90, -1, -1, -1, -1,
2160 -1, 96, -1, 98, 99, 100, 101, -1, 103, 104,
2161 105, 3, 4, -1, -1, 7, -1, -1, -1, -1,
2162 -1, 116, -1, -1, -1, -1, -1, -1, -1, -1,
2163 -1, -1, -1, -1, 26, 27, 28, -1, -1, -1,
2164 -1, -1, -1, -1, -1, -1, 38, 39, -1, -1,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002165 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002166 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002167 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002168 -1, -1, -1, -1, -1, 77, 78, 79, 80, 81,
2169 82, 83, 84, 85, 86, 87, 88, 89, 90, -1,
2170 -1, -1, -1, -1, 96, -1, 98, 99, 100, 101,
2171 -1, 103, 104, 105, -1, -1, -1, -1, -1, -1,
2172 -1, -1, 5, 6, 116, 8, 9, 10, 11, 12,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002173 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002174 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2175 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002176 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
2177 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002178 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2179 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002180 -1, -1, -1, -1, 5, 6, 48, 8, 9, 10,
2181 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002182 21, 22, -1, 24, -1, -1, -1, 110, -1, -1,
2183 113, -1, -1, 116, -1, 118, -1, -1, -1, -1,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002184 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2185 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002186 20, 21, 22, -1, 24, -1, -1, -1, 110, -1,
2187 -1, 113, -1, -1, 116, -1, 118, 37, -1, -1,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002188 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
2189 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002190 19, 20, 21, 22, -1, 24, -1, -1, -1, 110,
2191 -1, -1, 113, -1, 115, 116, -1, 118, 37, -1,
2192 -1, -1, -1, -1, -1, -1, -1, 5, 6, 48,
2193 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2194 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
2195 110, -1, -1, 113, -1, -1, 116, -1, 118, -1,
2196 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
2197 48, 8, 9, 10, 11, 12, 13, 14, 15, 16,
2198 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
2199 -1, 110, -1, -1, 113, -1, -1, 116, -1, 118,
2200 -1, -1, -1, -1, -1, -1, -1, -1, -1, 5,
2201 6, 48, 8, 9, 10, 11, 12, 13, 14, 15,
2202 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2203 -1, -1, 110, -1, -1, 113, -1, -1, 116, -1,
2204 118, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2205 5, 6, 48, 8, 9, 10, 11, 12, 13, 14,
2206 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
2207 -1, -1, -1, 110, -1, -1, 113, -1, -1, 116,
2208 -1, 118, -1, -1, -1, -1, -1, -1, -1, -1,
2209 -1, -1, -1, 48, -1, -1, -1, -1, -1, -1,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002210 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002211 -1, -1, -1, -1, 110, -1, -1, 113, -1, -1,
2212 116, -1, 118, -1, -1, -1, -1, -1, 35, -1,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002213 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002214 -1, -1, 49, -1, -1, -1, -1, -1, -1, -1,
2215 -1, -1, 59, 60, -1, 110, -1, -1, 113, -1,
2216 -1, 116, -1, 118, 71, 72, 73, 74, 75, 76,
2217 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2218 87, 88, 89, 90, 91, 92, 93, -1, -1, 96,
2219 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
2220 107
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002221};
2222
2223/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2224 symbol of state STATE-NUM. */
Reid Spencer309080a2006-09-28 19:28:24 +00002225static const unsigned char yystos[] =
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002226{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002227 0, 153, 154, 155, 0, 25, 31, 41, 42, 43,
2228 44, 45, 46, 47, 62, 134, 172, 174, 176, 183,
2229 22, 24, 51, 58, 62, 133, 165, 176, 177, 61,
2230 64, 65, 66, 67, 68, 69, 70, 135, 170, 23,
2231 184, 185, 30, 119, 173, 184, 52, 53, 54, 162,
2232 108, 61, 20, 45, 47, 50, 134, 108, 45, 47,
2233 175, 24, 160, 4, 5, 6, 8, 9, 10, 11,
2234 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2235 48, 110, 113, 116, 118, 123, 142, 143, 144, 145,
2236 146, 165, 180, 29, 118, 171, 133, 188, 108, 108,
2237 108, 113, 163, 160, 142, 32, 33, 152, 152, 152,
2238 152, 170, 4, 4, 4, 8, 119, 146, 147, 165,
2239 111, 120, 35, 49, 59, 60, 71, 72, 73, 74,
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002240 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00002241 85, 86, 87, 88, 89, 90, 91, 92, 93, 96,
2242 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
2243 107, 125, 126, 127, 128, 186, 192, 193, 195, 196,
2244 24, 55, 56, 161, 4, 24, 164, 144, 144, 144,
2245 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2246 19, 129, 130, 132, 144, 149, 114, 114, 109, 119,
2247 111, 37, 147, 148, 144, 182, 59, 8, 182, 9,
2248 21, 10, 11, 12, 13, 14, 15, 16, 17, 129,
2249 130, 131, 135, 144, 144, 182, 144, 144, 189, 182,
2250 182, 182, 182, 182, 182, 182, 182, 144, 144, 144,
2251 182, 135, 94, 95, 109, 115, 158, 159, 157, 27,
2252 28, 3, 4, 124, 4, 7, 26, 38, 39, 96,
2253 98, 99, 103, 104, 105, 113, 116, 118, 121, 125,
2254 126, 127, 128, 150, 180, 156, 146, 146, 146, 37,
2255 144, 167, 168, 169, 109, 112, 3, 4, 7, 26,
2256 27, 28, 38, 39, 61, 116, 150, 179, 180, 181,
2257 181, 181, 181, 142, 109, 137, 109, 137, 181, 113,
2258 109, 36, 109, 109, 109, 109, 109, 109, 109, 181,
2259 181, 181, 109, 142, 144, 182, 24, 109, 140, 140,
2260 140, 111, 111, 111, 111, 111, 111, 115, 149, 151,
2261 151, 119, 151, 24, 111, 111, 111, 111, 140, 115,
2262 117, 165, 166, 109, 112, 37, 63, 178, 151, 109,
2263 109, 181, 15, 57, 15, 109, 194, 181, 113, 144,
2264 182, 144, 182, 182, 182, 144, 144, 109, 109, 109,
2265 182, 181, 181, 109, 34, 57, 138, 141, 149, 149,
2266 149, 149, 149, 149, 109, 115, 117, 119, 149, 149,
2267 149, 149, 37, 167, 138, 139, 24, 117, 21, 21,
2268 111, 181, 4, 181, 182, 190, 109, 181, 109, 109,
2269 109, 181, 181, 181, 111, 144, 24, 4, 140, 194,
2270 36, 109, 109, 109, 109, 149, 109, 109, 109, 109,
2271 57, 136, 109, 181, 181, 190, 191, 109, 137, 137,
2272 109, 181, 109, 182, 182, 182, 191, 181, 112, 144,
2273 149, 149, 149, 149, 149, 149, 149, 149, 4, 24,
2274 109, 113, 112, 182, 115, 181, 112, 112, 109, 112,
2275 109, 109, 112, 112, 112, 112, 21, 115, 131, 187,
2276 36, 115, 149, 149, 149, 181, 179, 115, 131, 21,
2277 112, 112, 112, 109, 179, 181, 21, 109, 75, 181,
2278 21, 21, 181, 181
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002279};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002280
2281#define yyerrok (yyerrstatus = 0)
2282#define yyclearin (yychar = YYEMPTY)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002283#define YYEMPTY (-2)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002284#define YYEOF 0
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002285
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002286#define YYACCEPT goto yyacceptlab
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002287#define YYABORT goto yyabortlab
2288#define YYERROR goto yyerrorlab
2289
2290
2291/* Like YYERROR except do call yyerror. This remains here temporarily
2292 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002293 Once GCC version 2 has supplanted version 1, this can go. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002294
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002295#define YYFAIL goto yyerrlab
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002296
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002297#define YYRECOVERING() (!!yyerrstatus)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002298
2299#define YYBACKUP(Token, Value) \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002300do \
2301 if (yychar == YYEMPTY && yylen == 1) \
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002302 { \
2303 yychar = (Token); \
2304 yylval = (Value); \
2305 yytoken = YYTRANSLATE (yychar); \
Reid Spencer309080a2006-09-28 19:28:24 +00002306 YYPOPSTACK; \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002307 goto yybackup; \
2308 } \
2309 else \
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002310 { \
2311 yyerror (YY_("syntax error: cannot back up")); \
2312 YYERROR; \
2313 } \
Reid Spencer309080a2006-09-28 19:28:24 +00002314while (0)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002315
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002316
2317#define YYTERROR 1
2318#define YYERRCODE 256
2319
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002320
2321/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2322 If N is 0, then set CURRENT to the empty location which ends
2323 the previous symbol: RHS[0] (always defined). */
2324
2325#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2326#ifndef YYLLOC_DEFAULT
2327# define YYLLOC_DEFAULT(Current, Rhs, N) \
2328 do \
Reid Spencer309080a2006-09-28 19:28:24 +00002329 if (N) \
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002330 { \
2331 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2332 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2333 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2334 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2335 } \
2336 else \
2337 { \
2338 (Current).first_line = (Current).last_line = \
2339 YYRHSLOC (Rhs, 0).last_line; \
2340 (Current).first_column = (Current).last_column = \
2341 YYRHSLOC (Rhs, 0).last_column; \
2342 } \
Reid Spencer309080a2006-09-28 19:28:24 +00002343 while (0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002344#endif
2345
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002346
2347/* YY_LOCATION_PRINT -- Print the location on the stream.
2348 This macro was not mandated originally: define only if we know
2349 we won't break user code: when these are the locations we know. */
2350
2351#ifndef YY_LOCATION_PRINT
2352# if YYLTYPE_IS_TRIVIAL
2353# define YY_LOCATION_PRINT(File, Loc) \
2354 fprintf (File, "%d.%d-%d.%d", \
Reid Spencer309080a2006-09-28 19:28:24 +00002355 (Loc).first_line, (Loc).first_column, \
2356 (Loc).last_line, (Loc).last_column)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002357# else
2358# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2359# endif
2360#endif
2361
2362
2363/* YYLEX -- calling `yylex' with the right arguments. */
2364
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002365#ifdef YYLEX_PARAM
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002366# define YYLEX yylex (YYLEX_PARAM)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002367#else
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002368# define YYLEX yylex ()
Chris Lattner680aab62006-08-18 17:34:45 +00002369#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002370
2371/* Enable debugging if requested. */
2372#if YYDEBUG
2373
2374# ifndef YYFPRINTF
2375# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2376# define YYFPRINTF fprintf
2377# endif
2378
2379# define YYDPRINTF(Args) \
2380do { \
2381 if (yydebug) \
2382 YYFPRINTF Args; \
Reid Spencer309080a2006-09-28 19:28:24 +00002383} while (0)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002384
Reid Spencer309080a2006-09-28 19:28:24 +00002385# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2386do { \
2387 if (yydebug) \
2388 { \
2389 YYFPRINTF (stderr, "%s ", Title); \
2390 yysymprint (stderr, \
2391 Type, Value); \
2392 YYFPRINTF (stderr, "\n"); \
2393 } \
2394} while (0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002395
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002396/*------------------------------------------------------------------.
2397| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2398| TOP (included). |
2399`------------------------------------------------------------------*/
Reid Spencer713eedc2006-08-18 08:43:06 +00002400
Reid Spencer309080a2006-09-28 19:28:24 +00002401#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002402static void
Reid Spencer309080a2006-09-28 19:28:24 +00002403yy_stack_print (short int *bottom, short int *top)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002404#else
2405static void
2406yy_stack_print (bottom, top)
Reid Spencer309080a2006-09-28 19:28:24 +00002407 short int *bottom;
2408 short int *top;
Chris Lattneredd9b032006-01-23 23:05:42 +00002409#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002410{
2411 YYFPRINTF (stderr, "Stack now");
Reid Spencer309080a2006-09-28 19:28:24 +00002412 for (/* Nothing. */; bottom <= top; ++bottom)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002413 YYFPRINTF (stderr, " %d", *bottom);
2414 YYFPRINTF (stderr, "\n");
2415}
Reid Spencer713eedc2006-08-18 08:43:06 +00002416
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002417# define YY_STACK_PRINT(Bottom, Top) \
2418do { \
2419 if (yydebug) \
2420 yy_stack_print ((Bottom), (Top)); \
Reid Spencer309080a2006-09-28 19:28:24 +00002421} while (0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002422
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002423
2424/*------------------------------------------------.
2425| Report that the YYRULE is going to be reduced. |
2426`------------------------------------------------*/
2427
Reid Spencer309080a2006-09-28 19:28:24 +00002428#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002429static void
Reid Spencer309080a2006-09-28 19:28:24 +00002430yy_reduce_print (int yyrule)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002431#else
2432static void
Reid Spencer309080a2006-09-28 19:28:24 +00002433yy_reduce_print (yyrule)
2434 int yyrule;
Robert Bocchinofdf9e412006-01-17 20:06:25 +00002435#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002436{
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002437 int yyi;
2438 unsigned long int yylno = yyrline[yyrule];
Reid Spencer309080a2006-09-28 19:28:24 +00002439 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2440 yyrule - 1, yylno);
2441 /* Print the symbols being reduced, and their result. */
2442 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2443 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2444 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002445}
Reid Spencerc8a9faf2006-01-19 01:21:04 +00002446
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002447# define YY_REDUCE_PRINT(Rule) \
2448do { \
2449 if (yydebug) \
Reid Spencer309080a2006-09-28 19:28:24 +00002450 yy_reduce_print (Rule); \
2451} while (0)
Reid Spencerc8a9faf2006-01-19 01:21:04 +00002452
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002453/* Nonzero means print parse trace. It is left uninitialized so that
2454 multiple parsers can coexist. */
2455int yydebug;
2456#else /* !YYDEBUG */
2457# define YYDPRINTF(Args)
2458# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2459# define YY_STACK_PRINT(Bottom, Top)
2460# define YY_REDUCE_PRINT(Rule)
2461#endif /* !YYDEBUG */
2462
2463
2464/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002465#ifndef YYINITDEPTH
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002466# define YYINITDEPTH 200
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002467#endif
2468
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002469/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2470 if the built-in stack extension method is used).
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002471
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002472 Do not make this value too large; the results are undefined if
2473 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2474 evaluated with infinite-precision integer arithmetic. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002475
2476#ifndef YYMAXDEPTH
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002477# define YYMAXDEPTH 10000
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002478#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002479
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002480
2481
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002482#if YYERROR_VERBOSE
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002483
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002484# ifndef yystrlen
Reid Spencer309080a2006-09-28 19:28:24 +00002485# if defined (__GLIBC__) && defined (_STRING_H)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002486# define yystrlen strlen
2487# else
2488/* Return the length of YYSTR. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002489static YYSIZE_T
Reid Spencer309080a2006-09-28 19:28:24 +00002490# if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002491yystrlen (const char *yystr)
Reid Spencer309080a2006-09-28 19:28:24 +00002492# else
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002493yystrlen (yystr)
Reid Spencer309080a2006-09-28 19:28:24 +00002494 const char *yystr;
2495# endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002496{
Reid Spencer309080a2006-09-28 19:28:24 +00002497 const char *yys = yystr;
2498
2499 while (*yys++ != '\0')
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002500 continue;
Reid Spencer309080a2006-09-28 19:28:24 +00002501
2502 return yys - yystr - 1;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002503}
2504# endif
2505# endif
2506
2507# ifndef yystpcpy
Reid Spencer309080a2006-09-28 19:28:24 +00002508# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002509# define yystpcpy stpcpy
2510# else
2511/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2512 YYDEST. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002513static char *
Reid Spencer309080a2006-09-28 19:28:24 +00002514# if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002515yystpcpy (char *yydest, const char *yysrc)
Reid Spencer309080a2006-09-28 19:28:24 +00002516# else
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002517yystpcpy (yydest, yysrc)
Reid Spencer309080a2006-09-28 19:28:24 +00002518 char *yydest;
2519 const char *yysrc;
2520# endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002521{
2522 char *yyd = yydest;
2523 const char *yys = yysrc;
2524
2525 while ((*yyd++ = *yys++) != '\0')
2526 continue;
2527
2528 return yyd - 1;
2529}
2530# endif
2531# endif
2532
2533# ifndef yytnamerr
2534/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2535 quotes and backslashes, so that it's suitable for yyerror. The
2536 heuristic is that double-quoting is unnecessary unless the string
2537 contains an apostrophe, a comma, or backslash (other than
2538 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2539 null, do not copy; instead, return the length of what the result
2540 would have been. */
2541static YYSIZE_T
2542yytnamerr (char *yyres, const char *yystr)
2543{
2544 if (*yystr == '"')
2545 {
Reid Spencer309080a2006-09-28 19:28:24 +00002546 size_t yyn = 0;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002547 char const *yyp = yystr;
2548
2549 for (;;)
2550 switch (*++yyp)
2551 {
2552 case '\'':
2553 case ',':
2554 goto do_not_strip_quotes;
2555
2556 case '\\':
2557 if (*++yyp != '\\')
2558 goto do_not_strip_quotes;
2559 /* Fall through. */
2560 default:
2561 if (yyres)
2562 yyres[yyn] = *yyp;
2563 yyn++;
2564 break;
2565
2566 case '"':
2567 if (yyres)
2568 yyres[yyn] = '\0';
2569 return yyn;
2570 }
2571 do_not_strip_quotes: ;
2572 }
2573
2574 if (! yyres)
2575 return yystrlen (yystr);
2576
2577 return yystpcpy (yyres, yystr) - yyres;
2578}
2579# endif
2580
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002581#endif /* YYERROR_VERBOSE */
Reid Spencer309080a2006-09-28 19:28:24 +00002582
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002583
2584
Reid Spencer309080a2006-09-28 19:28:24 +00002585#if YYDEBUG
2586/*--------------------------------.
2587| Print this symbol on YYOUTPUT. |
2588`--------------------------------*/
2589
2590#if defined (__STDC__) || defined (__cplusplus)
2591static void
2592yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
2593#else
2594static void
2595yysymprint (yyoutput, yytype, yyvaluep)
2596 FILE *yyoutput;
2597 int yytype;
2598 YYSTYPE *yyvaluep;
2599#endif
2600{
2601 /* Pacify ``unused variable'' warnings. */
2602 (void) yyvaluep;
2603
2604 if (yytype < YYNTOKENS)
2605 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2606 else
2607 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2608
2609
2610# ifdef YYPRINT
2611 if (yytype < YYNTOKENS)
2612 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2613# endif
2614 switch (yytype)
2615 {
2616 default:
2617 break;
2618 }
2619 YYFPRINTF (yyoutput, ")");
2620}
2621
2622#endif /* ! YYDEBUG */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002623/*-----------------------------------------------.
2624| Release the memory associated to this symbol. |
2625`-----------------------------------------------*/
2626
Reid Spencer309080a2006-09-28 19:28:24 +00002627#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002628static void
2629yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2630#else
2631static void
2632yydestruct (yymsg, yytype, yyvaluep)
2633 const char *yymsg;
2634 int yytype;
2635 YYSTYPE *yyvaluep;
2636#endif
2637{
Reid Spencer309080a2006-09-28 19:28:24 +00002638 /* Pacify ``unused variable'' warnings. */
2639 (void) yyvaluep;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002640
2641 if (!yymsg)
2642 yymsg = "Deleting";
2643 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2644
2645 switch (yytype)
2646 {
2647
2648 default:
Reid Spencer309080a2006-09-28 19:28:24 +00002649 break;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002650 }
2651}
2652
2653
2654/* Prevent warnings from -Wmissing-prototypes. */
2655
2656#ifdef YYPARSE_PARAM
Reid Spencer309080a2006-09-28 19:28:24 +00002657# if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002658int yyparse (void *YYPARSE_PARAM);
Reid Spencer309080a2006-09-28 19:28:24 +00002659# else
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002660int yyparse ();
Reid Spencer309080a2006-09-28 19:28:24 +00002661# endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002662#else /* ! YYPARSE_PARAM */
Reid Spencer309080a2006-09-28 19:28:24 +00002663#if defined (__STDC__) || defined (__cplusplus)
Reid Spencerc8a9faf2006-01-19 01:21:04 +00002664int yyparse (void);
Chris Lattner680aab62006-08-18 17:34:45 +00002665#else
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002666int yyparse ();
Chris Lattner680aab62006-08-18 17:34:45 +00002667#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002668#endif /* ! YYPARSE_PARAM */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002669
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002670
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002671
2672/* The look-ahead symbol. */
2673int yychar;
2674
2675/* The semantic value of the look-ahead symbol. */
2676YYSTYPE yylval;
2677
2678/* Number of syntax errors so far. */
2679int yynerrs;
2680
2681
2682
2683/*----------.
2684| yyparse. |
2685`----------*/
2686
2687#ifdef YYPARSE_PARAM
Reid Spencer309080a2006-09-28 19:28:24 +00002688# if defined (__STDC__) || defined (__cplusplus)
2689int yyparse (void *YYPARSE_PARAM)
2690# else
2691int yyparse (YYPARSE_PARAM)
2692 void *YYPARSE_PARAM;
2693# endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002694#else /* ! YYPARSE_PARAM */
Reid Spencer309080a2006-09-28 19:28:24 +00002695#if defined (__STDC__) || defined (__cplusplus)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002696int
2697yyparse (void)
2698#else
2699int
2700yyparse ()
2701
Chris Lattner680aab62006-08-18 17:34:45 +00002702#endif
2703#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002704{
2705
2706 int yystate;
2707 int yyn;
2708 int yyresult;
2709 /* Number of tokens to shift before error messages enabled. */
2710 int yyerrstatus;
2711 /* Look-ahead token as an internal (translated) token number. */
2712 int yytoken = 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002713
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002714 /* Three stacks and their tools:
2715 `yyss': related to states,
2716 `yyvs': related to semantic values,
2717 `yyls': related to locations.
2718
2719 Refer to the stacks thru separate pointers, to allow yyoverflow
2720 to reallocate them elsewhere. */
2721
2722 /* The state stack. */
Reid Spencer309080a2006-09-28 19:28:24 +00002723 short int yyssa[YYINITDEPTH];
2724 short int *yyss = yyssa;
2725 short int *yyssp;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002726
2727 /* The semantic value stack. */
2728 YYSTYPE yyvsa[YYINITDEPTH];
2729 YYSTYPE *yyvs = yyvsa;
2730 YYSTYPE *yyvsp;
2731
2732
2733
Reid Spencer309080a2006-09-28 19:28:24 +00002734#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002735
2736 YYSIZE_T yystacksize = YYINITDEPTH;
2737
2738 /* The variables used to return semantic value and location from the
2739 action routines. */
2740 YYSTYPE yyval;
2741
2742
Reid Spencer309080a2006-09-28 19:28:24 +00002743 /* When reducing, the number of symbols on the RHS of the reduced
2744 rule. */
2745 int yylen;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002746
2747 YYDPRINTF ((stderr, "Starting parse\n"));
2748
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002749 yystate = 0;
2750 yyerrstatus = 0;
2751 yynerrs = 0;
2752 yychar = YYEMPTY; /* Cause a token to be read. */
2753
2754 /* Initialize stack pointers.
2755 Waste one element of value and location stack
2756 so that they stay on the same level as the state stack.
2757 The wasted elements are never initialized. */
2758
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002759 yyssp = yyss;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002760 yyvsp = yyvs;
2761
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002762 goto yysetstate;
Jeff Cohen11e26b52005-10-23 04:37:20 +00002763
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002764/*------------------------------------------------------------.
2765| yynewstate -- Push a new state, which is found in yystate. |
2766`------------------------------------------------------------*/
2767 yynewstate:
2768 /* In all cases, when you get here, the value and location stacks
Reid Spencer309080a2006-09-28 19:28:24 +00002769 have just been pushed. so pushing a state here evens the stacks.
2770 */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002771 yyssp++;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002772
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002773 yysetstate:
2774 *yyssp = yystate;
2775
2776 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002777 {
2778 /* Get the current used size of the three stacks, in elements. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002779 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002780
2781#ifdef yyoverflow
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002782 {
Reid Spencer309080a2006-09-28 19:28:24 +00002783 /* Give user a chance to reallocate the stack. Use copies of
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002784 these so that the &'s don't force the real ones into
2785 memory. */
2786 YYSTYPE *yyvs1 = yyvs;
Reid Spencer309080a2006-09-28 19:28:24 +00002787 short int *yyss1 = yyss;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002788
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002789
2790 /* Each stack pointer address is followed by the size of the
2791 data in use in that stack, in bytes. This used to be a
2792 conditional around just the two extra args, but that might
2793 be undefined if yyoverflow is a macro. */
2794 yyoverflow (YY_("memory exhausted"),
2795 &yyss1, yysize * sizeof (*yyssp),
2796 &yyvs1, yysize * sizeof (*yyvsp),
2797
2798 &yystacksize);
2799
2800 yyss = yyss1;
2801 yyvs = yyvs1;
2802 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002803#else /* no yyoverflow */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002804# ifndef YYSTACK_RELOCATE
2805 goto yyexhaustedlab;
2806# else
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002807 /* Extend the stack our own way. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002808 if (YYMAXDEPTH <= yystacksize)
2809 goto yyexhaustedlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002810 yystacksize *= 2;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002811 if (YYMAXDEPTH < yystacksize)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002812 yystacksize = YYMAXDEPTH;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002813
2814 {
Reid Spencer309080a2006-09-28 19:28:24 +00002815 short int *yyss1 = yyss;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002816 union yyalloc *yyptr =
2817 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2818 if (! yyptr)
2819 goto yyexhaustedlab;
2820 YYSTACK_RELOCATE (yyss);
2821 YYSTACK_RELOCATE (yyvs);
2822
2823# undef YYSTACK_RELOCATE
2824 if (yyss1 != yyssa)
2825 YYSTACK_FREE (yyss1);
2826 }
2827# endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002828#endif /* no yyoverflow */
2829
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002830 yyssp = yyss + yysize - 1;
2831 yyvsp = yyvs + yysize - 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002832
2833
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002834 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2835 (unsigned long int) yystacksize));
2836
2837 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002838 YYABORT;
2839 }
2840
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002841 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002842
2843 goto yybackup;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002844
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002845/*-----------.
2846| yybackup. |
2847`-----------*/
2848yybackup:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002849
Reid Spencer309080a2006-09-28 19:28:24 +00002850/* Do appropriate processing given the current state. */
2851/* Read a look-ahead token if we need one and don't already have one. */
2852/* yyresume: */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002853
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002854 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer309080a2006-09-28 19:28:24 +00002855
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002856 yyn = yypact[yystate];
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002857 if (yyn == YYPACT_NINF)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002858 goto yydefault;
2859
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002860 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002861
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002862 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002863 if (yychar == YYEMPTY)
2864 {
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002865 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002866 yychar = YYLEX;
2867 }
2868
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002869 if (yychar <= YYEOF)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002870 {
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002871 yychar = yytoken = YYEOF;
2872 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002873 }
2874 else
2875 {
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002876 yytoken = YYTRANSLATE (yychar);
2877 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002878 }
2879
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002880 /* If the proper action on seeing token YYTOKEN is to reduce or to
2881 detect an error, take that action. */
2882 yyn += yytoken;
2883 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002884 goto yydefault;
2885 yyn = yytable[yyn];
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002886 if (yyn <= 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002887 {
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002888 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002889 goto yyerrlab;
2890 yyn = -yyn;
2891 goto yyreduce;
2892 }
2893
2894 if (yyn == YYFINAL)
2895 YYACCEPT;
2896
Reid Spencer309080a2006-09-28 19:28:24 +00002897 /* Shift the look-ahead token. */
2898 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
2899
2900 /* Discard the token being shifted unless it is eof. */
2901 if (yychar != YYEOF)
2902 yychar = YYEMPTY;
2903
2904 *++yyvsp = yylval;
2905
2906
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002907 /* Count tokens shifted since error; after three, turn off error
2908 status. */
2909 if (yyerrstatus)
2910 yyerrstatus--;
Chris Lattner680aab62006-08-18 17:34:45 +00002911
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002912 yystate = yyn;
2913 goto yynewstate;
2914
Chris Lattner680aab62006-08-18 17:34:45 +00002915
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002916/*-----------------------------------------------------------.
2917| yydefault -- do the default action for the current state. |
2918`-----------------------------------------------------------*/
2919yydefault:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002920 yyn = yydefact[yystate];
2921 if (yyn == 0)
2922 goto yyerrlab;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002923 goto yyreduce;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002924
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002925
2926/*-----------------------------.
2927| yyreduce -- Do a reduction. |
2928`-----------------------------*/
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002929yyreduce:
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002930 /* yyn is the number of a rule to reduce with. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002931 yylen = yyr2[yyn];
2932
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002933 /* If YYLEN is nonzero, implement the default value of the action:
2934 `$$ = $1'.
2935
2936 Otherwise, the following line sets YYVAL to garbage.
2937 This behavior is undocumented and Bison
2938 users should not rely upon it. Assigning to YYVAL
2939 unconditionally makes the parser a bit smaller, and it avoids a
2940 GCC warning that YYVAL may be used uninitialized. */
2941 yyval = yyvsp[1-yylen];
2942
2943
2944 YY_REDUCE_PRINT (yyn);
2945 switch (yyn)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002946 {
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002947 case 3:
Reid Spencer309080a2006-09-28 19:28:24 +00002948#line 1089 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002949 {
Reid Spencer309080a2006-09-28 19:28:24 +00002950 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer713eedc2006-08-18 08:43:06 +00002951 GEN_ERROR("Value too large for type!");
Reid Spencer309080a2006-09-28 19:28:24 +00002952 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002953 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002954;}
2955 break;
2956
2957 case 5:
Reid Spencer309080a2006-09-28 19:28:24 +00002958#line 1098 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002959 {
Reid Spencer309080a2006-09-28 19:28:24 +00002960 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer713eedc2006-08-18 08:43:06 +00002961 GEN_ERROR("Value too large for type!");
Reid Spencer309080a2006-09-28 19:28:24 +00002962 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00002963 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002964;}
2965 break;
2966
2967 case 34:
Reid Spencer309080a2006-09-28 19:28:24 +00002968#line 1122 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002969 {
Reid Spencer309080a2006-09-28 19:28:24 +00002970 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002971 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002972 ;}
2973 break;
2974
2975 case 35:
Reid Spencer309080a2006-09-28 19:28:24 +00002976#line 1126 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002977 {
2978 (yyval.StrVal) = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00002979 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002980 ;}
2981 break;
2982
2983 case 36:
Reid Spencer309080a2006-09-28 19:28:24 +00002984#line 1131 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002985 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
2986 break;
2987
2988 case 37:
Reid Spencer309080a2006-09-28 19:28:24 +00002989#line 1132 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002990 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
2991 break;
2992
2993 case 38:
Reid Spencer309080a2006-09-28 19:28:24 +00002994#line 1133 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002995 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
2996 break;
2997
2998 case 39:
Reid Spencer309080a2006-09-28 19:28:24 +00002999#line 1134 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003000 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3001 break;
3002
3003 case 40:
Reid Spencer309080a2006-09-28 19:28:24 +00003004#line 1135 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003005 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3006 break;
3007
3008 case 41:
Reid Spencer309080a2006-09-28 19:28:24 +00003009#line 1136 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003010 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3011 break;
3012
3013 case 42:
Reid Spencer309080a2006-09-28 19:28:24 +00003014#line 1137 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003015 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3016 break;
3017
3018 case 43:
Reid Spencer309080a2006-09-28 19:28:24 +00003019#line 1138 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003020 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3021 break;
3022
3023 case 44:
Reid Spencer309080a2006-09-28 19:28:24 +00003024#line 1140 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003025 { (yyval.UIntVal) = CallingConv::C; ;}
3026 break;
3027
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003028 case 45:
Reid Spencer309080a2006-09-28 19:28:24 +00003029#line 1141 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003030 { (yyval.UIntVal) = CallingConv::C; ;}
3031 break;
3032
3033 case 46:
Reid Spencer309080a2006-09-28 19:28:24 +00003034#line 1142 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003035 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3036 break;
3037
3038 case 47:
Reid Spencer309080a2006-09-28 19:28:24 +00003039#line 1143 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003040 { (yyval.UIntVal) = CallingConv::Fast; ;}
3041 break;
3042
3043 case 48:
Reid Spencer309080a2006-09-28 19:28:24 +00003044#line 1144 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003045 { (yyval.UIntVal) = CallingConv::Cold; ;}
3046 break;
3047
3048 case 49:
Reid Spencer309080a2006-09-28 19:28:24 +00003049#line 1145 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003050 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3051 break;
3052
3053 case 50:
Reid Spencer309080a2006-09-28 19:28:24 +00003054#line 1146 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003055 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3056 break;
3057
3058 case 51:
Reid Spencer309080a2006-09-28 19:28:24 +00003059#line 1147 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003060 {
Reid Spencer309080a2006-09-28 19:28:24 +00003061 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer713eedc2006-08-18 08:43:06 +00003062 GEN_ERROR("Calling conv too large!");
Reid Spencer309080a2006-09-28 19:28:24 +00003063 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00003064 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003065 ;}
3066 break;
3067
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003068 case 52:
Reid Spencer309080a2006-09-28 19:28:24 +00003069#line 1156 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003070 { (yyval.UIntVal) = 0; ;}
3071 break;
3072
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003073 case 53:
Reid Spencer309080a2006-09-28 19:28:24 +00003074#line 1157 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003075 {
Reid Spencer309080a2006-09-28 19:28:24 +00003076 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003077 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003078 GEN_ERROR("Alignment must be a power of two!");
3079 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003080;}
3081 break;
3082
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003083 case 54:
Reid Spencer309080a2006-09-28 19:28:24 +00003084#line 1163 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003085 { (yyval.UIntVal) = 0; ;}
3086 break;
3087
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003088 case 55:
Reid Spencer309080a2006-09-28 19:28:24 +00003089#line 1164 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003090 {
Reid Spencer309080a2006-09-28 19:28:24 +00003091 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003092 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003093 GEN_ERROR("Alignment must be a power of two!");
3094 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003095;}
3096 break;
3097
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003098 case 56:
Reid Spencer309080a2006-09-28 19:28:24 +00003099#line 1172 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003100 {
Reid Spencer309080a2006-09-28 19:28:24 +00003101 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3102 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer713eedc2006-08-18 08:43:06 +00003103 GEN_ERROR("Invalid character in section name!");
Reid Spencer309080a2006-09-28 19:28:24 +00003104 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003105 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003106;}
3107 break;
3108
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003109 case 57:
Reid Spencer309080a2006-09-28 19:28:24 +00003110#line 1180 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003111 { (yyval.StrVal) = 0; ;}
3112 break;
3113
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003114 case 58:
Reid Spencer309080a2006-09-28 19:28:24 +00003115#line 1181 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3116 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003117 break;
3118
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003119 case 59:
Reid Spencer309080a2006-09-28 19:28:24 +00003120#line 1186 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003121 {;}
3122 break;
3123
3124 case 60:
Reid Spencer309080a2006-09-28 19:28:24 +00003125#line 1187 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003126 {;}
3127 break;
3128
3129 case 61:
Reid Spencer309080a2006-09-28 19:28:24 +00003130#line 1188 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003131 {
Reid Spencer309080a2006-09-28 19:28:24 +00003132 CurGV->setSection((yyvsp[0].StrVal));
3133 free((yyvsp[0].StrVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003134 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003135 ;}
3136 break;
3137
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003138 case 62:
Reid Spencer309080a2006-09-28 19:28:24 +00003139#line 1193 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003140 {
Reid Spencer309080a2006-09-28 19:28:24 +00003141 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003142 GEN_ERROR("Alignment must be a power of two!");
Reid Spencer309080a2006-09-28 19:28:24 +00003143 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer713eedc2006-08-18 08:43:06 +00003144 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003145 ;}
3146 break;
3147
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003148 case 64:
Reid Spencer309080a2006-09-28 19:28:24 +00003149#line 1207 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3150 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003151 break;
3152
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003153 case 66:
Reid Spencer309080a2006-09-28 19:28:24 +00003154#line 1208 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3155 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003156 break;
3157
3158 case 67:
Reid Spencer309080a2006-09-28 19:28:24 +00003159#line 1210 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003160 {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003161 if (!UpRefs.empty())
Reid Spencer309080a2006-09-28 19:28:24 +00003162 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3163 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003164 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003165 ;}
3166 break;
3167
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003168 case 81:
Reid Spencer309080a2006-09-28 19:28:24 +00003169#line 1222 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003170 {
3171 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer713eedc2006-08-18 08:43:06 +00003172 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003173 ;}
3174 break;
3175
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003176 case 82:
Reid Spencer309080a2006-09-28 19:28:24 +00003177#line 1226 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003178 {
Reid Spencer309080a2006-09-28 19:28:24 +00003179 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer713eedc2006-08-18 08:43:06 +00003180 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003181 ;}
3182 break;
3183
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003184 case 83:
Reid Spencer309080a2006-09-28 19:28:24 +00003185#line 1230 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003186 { // Named types are also simple types...
Reid Spencer309080a2006-09-28 19:28:24 +00003187 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003188 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00003189 (yyval.TypeVal) = new PATypeHolder(tmp);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003190;}
3191 break;
3192
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003193 case 84:
Reid Spencer309080a2006-09-28 19:28:24 +00003194#line 1238 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003195 { // Type UpReference
Reid Spencer309080a2006-09-28 19:28:24 +00003196 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003197 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer309080a2006-09-28 19:28:24 +00003198 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003199 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003200 UR_OUT("New Upreference!\n");
Reid Spencer713eedc2006-08-18 08:43:06 +00003201 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003202 ;}
3203 break;
3204
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003205 case 85:
Reid Spencer309080a2006-09-28 19:28:24 +00003206#line 1246 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003207 { // Function derived type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003208 std::vector<const Type*> Params;
Reid Spencer309080a2006-09-28 19:28:24 +00003209 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3210 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003211 Params.push_back(*I);
3212 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3213 if (isVarArg) Params.pop_back();
3214
Reid Spencer309080a2006-09-28 19:28:24 +00003215 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg)));
3216 delete (yyvsp[-1].TypeList); // Delete the argument list
3217 delete (yyvsp[-3].TypeVal); // Delete the return type handle
Reid Spencer713eedc2006-08-18 08:43:06 +00003218 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003219 ;}
3220 break;
3221
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003222 case 86:
Reid Spencer309080a2006-09-28 19:28:24 +00003223#line 1259 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003224 { // Sized array type?
Reid Spencer309080a2006-09-28 19:28:24 +00003225 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3226 delete (yyvsp[-1].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003227 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003228 ;}
3229 break;
3230
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003231 case 87:
Reid Spencer309080a2006-09-28 19:28:24 +00003232#line 1264 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003233 { // Packed array type?
Reid Spencer309080a2006-09-28 19:28:24 +00003234 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3235 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Reid Spencer713eedc2006-08-18 08:43:06 +00003236 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner625b9c82005-11-10 01:42:43 +00003237 if (!ElemTy->isPrimitiveType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003238 GEN_ERROR("Elemental type of a PackedType must be primitive");
Reid Spencer309080a2006-09-28 19:28:24 +00003239 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003240 GEN_ERROR("Vector length should be a power of 2!");
Reid Spencer309080a2006-09-28 19:28:24 +00003241 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3242 delete (yyvsp[-1].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003243 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003244 ;}
3245 break;
3246
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003247 case 88:
Reid Spencer309080a2006-09-28 19:28:24 +00003248#line 1276 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003249 { // Structure type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003250 std::vector<const Type*> Elements;
Reid Spencer309080a2006-09-28 19:28:24 +00003251 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3252 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003253 Elements.push_back(*I);
3254
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003255 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
Reid Spencer309080a2006-09-28 19:28:24 +00003256 delete (yyvsp[-1].TypeList);
Reid Spencer713eedc2006-08-18 08:43:06 +00003257 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003258 ;}
3259 break;
3260
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003261 case 89:
Reid Spencer309080a2006-09-28 19:28:24 +00003262#line 1286 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003263 { // Empty structure type?
3264 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer713eedc2006-08-18 08:43:06 +00003265 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003266 ;}
3267 break;
3268
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003269 case 90:
Reid Spencer309080a2006-09-28 19:28:24 +00003270#line 1290 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003271 { // Pointer type?
Reid Spencer309080a2006-09-28 19:28:24 +00003272 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3273 delete (yyvsp[-1].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003274 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003275 ;}
3276 break;
3277
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003278 case 91:
Reid Spencer309080a2006-09-28 19:28:24 +00003279#line 1299 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003280 {
3281 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer309080a2006-09-28 19:28:24 +00003282 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003283 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003284 ;}
3285 break;
3286
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003287 case 92:
Reid Spencer309080a2006-09-28 19:28:24 +00003288#line 1304 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003289 {
Reid Spencer309080a2006-09-28 19:28:24 +00003290 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003291 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003292 ;}
3293 break;
3294
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003295 case 94:
Reid Spencer309080a2006-09-28 19:28:24 +00003296#line 1311 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003297 {
Reid Spencer309080a2006-09-28 19:28:24 +00003298 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy);
Reid Spencer713eedc2006-08-18 08:43:06 +00003299 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003300 ;}
3301 break;
3302
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003303 case 95:
Reid Spencer309080a2006-09-28 19:28:24 +00003304#line 1315 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003305 {
3306 ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Reid Spencer713eedc2006-08-18 08:43:06 +00003307 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003308 ;}
3309 break;
3310
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003311 case 96:
Reid Spencer309080a2006-09-28 19:28:24 +00003312#line 1319 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003313 {
3314 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer713eedc2006-08-18 08:43:06 +00003315 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003316 ;}
3317 break;
3318
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003319 case 97:
Reid Spencer309080a2006-09-28 19:28:24 +00003320#line 1330 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003321 { // Nonempty unsized arr
Reid Spencer309080a2006-09-28 19:28:24 +00003322 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003323 if (ATy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003324 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer309080a2006-09-28 19:28:24 +00003325 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003326 const Type *ETy = ATy->getElementType();
3327 int NumElements = ATy->getNumElements();
3328
3329 // Verify that we have the correct size...
Reid Spencer309080a2006-09-28 19:28:24 +00003330 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer713eedc2006-08-18 08:43:06 +00003331 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer309080a2006-09-28 19:28:24 +00003332 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003333 itostr(NumElements) + "!");
3334
3335 // Verify all elements are correct type!
Reid Spencer309080a2006-09-28 19:28:24 +00003336 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3337 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003338 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003339 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer309080a2006-09-28 19:28:24 +00003340 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003341 }
3342
Reid Spencer309080a2006-09-28 19:28:24 +00003343 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3344 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer713eedc2006-08-18 08:43:06 +00003345 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003346 ;}
3347 break;
3348
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003349 case 98:
Reid Spencer309080a2006-09-28 19:28:24 +00003350#line 1356 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003351 {
Reid Spencer309080a2006-09-28 19:28:24 +00003352 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003353 if (ATy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003354 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer309080a2006-09-28 19:28:24 +00003355 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003356
3357 int NumElements = ATy->getNumElements();
3358 if (NumElements != -1 && NumElements != 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003359 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003360 " arguments, but has size of " + itostr(NumElements) +"!");
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003361 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencer309080a2006-09-28 19:28:24 +00003362 delete (yyvsp[-2].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003363 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003364 ;}
3365 break;
3366
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003367 case 99:
Reid Spencer309080a2006-09-28 19:28:24 +00003368#line 1370 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003369 {
Reid Spencer309080a2006-09-28 19:28:24 +00003370 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003371 if (ATy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003372 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer309080a2006-09-28 19:28:24 +00003373 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003374
3375 int NumElements = ATy->getNumElements();
3376 const Type *ETy = ATy->getElementType();
Reid Spencer309080a2006-09-28 19:28:24 +00003377 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3378 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003379 GEN_ERROR("Can't build string constant of size " +
Reid Spencer309080a2006-09-28 19:28:24 +00003380 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003381 " when array has size " + itostr(NumElements) + "!");
3382 std::vector<Constant*> Vals;
3383 if (ETy == Type::SByteTy) {
Reid Spencer309080a2006-09-28 19:28:24 +00003384 for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003385 Vals.push_back(ConstantSInt::get(ETy, *C));
3386 } else if (ETy == Type::UByteTy) {
Reid Spencer309080a2006-09-28 19:28:24 +00003387 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Chris Lattner8ebd2162006-01-24 04:14:29 +00003388 C != (unsigned char*)EndStr; ++C)
3389 Vals.push_back(ConstantUInt::get(ETy, *C));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003390 } else {
Reid Spencer309080a2006-09-28 19:28:24 +00003391 free((yyvsp[0].StrVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003392 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003393 }
Reid Spencer309080a2006-09-28 19:28:24 +00003394 free((yyvsp[0].StrVal));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003395 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
Reid Spencer309080a2006-09-28 19:28:24 +00003396 delete (yyvsp[-2].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003397 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003398 ;}
3399 break;
3400
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003401 case 100:
Reid Spencer309080a2006-09-28 19:28:24 +00003402#line 1400 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003403 { // Nonempty unsized arr
Reid Spencer309080a2006-09-28 19:28:24 +00003404 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003405 if (PTy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003406 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer309080a2006-09-28 19:28:24 +00003407 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003408 const Type *ETy = PTy->getElementType();
3409 int NumElements = PTy->getNumElements();
3410
3411 // Verify that we have the correct size...
Reid Spencer309080a2006-09-28 19:28:24 +00003412 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer713eedc2006-08-18 08:43:06 +00003413 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer309080a2006-09-28 19:28:24 +00003414 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003415 itostr(NumElements) + "!");
3416
3417 // Verify all elements are correct type!
Reid Spencer309080a2006-09-28 19:28:24 +00003418 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3419 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003420 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003421 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer309080a2006-09-28 19:28:24 +00003422 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003423 }
3424
Reid Spencer309080a2006-09-28 19:28:24 +00003425 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3426 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer713eedc2006-08-18 08:43:06 +00003427 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003428 ;}
3429 break;
3430
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003431 case 101:
Reid Spencer309080a2006-09-28 19:28:24 +00003432#line 1426 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003433 {
Reid Spencer309080a2006-09-28 19:28:24 +00003434 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer713eedc2006-08-18 08:43:06 +00003435 if (STy == 0)
3436 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer309080a2006-09-28 19:28:24 +00003437 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer713eedc2006-08-18 08:43:06 +00003438
Reid Spencer309080a2006-09-28 19:28:24 +00003439 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer713eedc2006-08-18 08:43:06 +00003440 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003441
3442 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer309080a2006-09-28 19:28:24 +00003443 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3444 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer713eedc2006-08-18 08:43:06 +00003445 GEN_ERROR("Expected type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003446 STy->getElementType(i)->getDescription() +
3447 "' for element #" + utostr(i) +
3448 " of structure initializer!");
3449
Reid Spencer309080a2006-09-28 19:28:24 +00003450 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3451 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer713eedc2006-08-18 08:43:06 +00003452 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003453 ;}
3454 break;
3455
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003456 case 102:
Reid Spencer309080a2006-09-28 19:28:24 +00003457#line 1447 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003458 {
Reid Spencer309080a2006-09-28 19:28:24 +00003459 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003460 if (STy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003461 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer309080a2006-09-28 19:28:24 +00003462 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003463
3464 if (STy->getNumContainedTypes() != 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003465 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003466
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003467 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencer309080a2006-09-28 19:28:24 +00003468 delete (yyvsp[-2].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003469 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003470 ;}
3471 break;
3472
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003473 case 103:
Reid Spencer309080a2006-09-28 19:28:24 +00003474#line 1460 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003475 {
Reid Spencer309080a2006-09-28 19:28:24 +00003476 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003477 if (PTy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003478 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer309080a2006-09-28 19:28:24 +00003479 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003480
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003481 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
Reid Spencer309080a2006-09-28 19:28:24 +00003482 delete (yyvsp[-1].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003483 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003484 ;}
3485 break;
3486
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003487 case 104:
Reid Spencer309080a2006-09-28 19:28:24 +00003488#line 1470 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003489 {
Reid Spencer309080a2006-09-28 19:28:24 +00003490 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3491 delete (yyvsp[-1].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003492 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003493 ;}
3494 break;
3495
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003496 case 105:
Reid Spencer309080a2006-09-28 19:28:24 +00003497#line 1475 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003498 {
Reid Spencer309080a2006-09-28 19:28:24 +00003499 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003500 if (Ty == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003501 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003502
3503 // ConstExprs can exist in the body of a function, thus creating
3504 // GlobalValues whenever they refer to a variable. Because we are in
3505 // the context of a function, getValNonImprovising will search the functions
3506 // symbol table instead of the module symbol table for the global symbol,
3507 // which throws things all off. To get around this, we just tell
3508 // getValNonImprovising that we are at global scope here.
3509 //
3510 Function *SavedCurFn = CurFun.CurrentFunction;
3511 CurFun.CurrentFunction = 0;
3512
Reid Spencer309080a2006-09-28 19:28:24 +00003513 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
3514 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003515
3516 CurFun.CurrentFunction = SavedCurFn;
3517
3518 // If this is an initializer for a constant pointer, which is referencing a
3519 // (currently) undefined variable, create a stub now that shall be replaced
3520 // in the future with the right type of variable.
3521 //
3522 if (V == 0) {
3523 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3524 const PointerType *PT = cast<PointerType>(Ty);
3525
3526 // First check to see if the forward references value is already created!
3527 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer309080a2006-09-28 19:28:24 +00003528 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003529
3530 if (I != CurModule.GlobalRefs.end()) {
3531 V = I->second; // Placeholder already exists, use it...
Reid Spencer309080a2006-09-28 19:28:24 +00003532 (yyvsp[0].ValIDVal).destroy();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003533 } else {
3534 std::string Name;
Reid Spencer309080a2006-09-28 19:28:24 +00003535 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003536
3537 // Create the forward referenced global.
3538 GlobalValue *GV;
3539 if (const FunctionType *FTy =
3540 dyn_cast<FunctionType>(PT->getElementType())) {
3541 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3542 CurModule.CurrentModule);
3543 } else {
3544 GV = new GlobalVariable(PT->getElementType(), false,
3545 GlobalValue::ExternalLinkage, 0,
3546 Name, CurModule.CurrentModule);
3547 }
3548
3549 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer309080a2006-09-28 19:28:24 +00003550 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003551 V = GV;
3552 }
3553 }
3554
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003555 (yyval.ConstVal) = cast<GlobalValue>(V);
Reid Spencer309080a2006-09-28 19:28:24 +00003556 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer713eedc2006-08-18 08:43:06 +00003557 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003558 ;}
3559 break;
3560
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003561 case 106:
Reid Spencer309080a2006-09-28 19:28:24 +00003562#line 1536 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003563 {
Reid Spencer309080a2006-09-28 19:28:24 +00003564 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003565 GEN_ERROR("Mismatched types for constant expression!");
Reid Spencer309080a2006-09-28 19:28:24 +00003566 (yyval.ConstVal) = (yyvsp[0].ConstVal);
3567 delete (yyvsp[-1].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003568 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003569 ;}
3570 break;
3571
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003572 case 107:
Reid Spencer309080a2006-09-28 19:28:24 +00003573#line 1543 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003574 {
Reid Spencer309080a2006-09-28 19:28:24 +00003575 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003576 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer713eedc2006-08-18 08:43:06 +00003577 GEN_ERROR("Cannot create a null initialized value of this type!");
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003578 (yyval.ConstVal) = Constant::getNullValue(Ty);
Reid Spencer309080a2006-09-28 19:28:24 +00003579 delete (yyvsp[-1].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003580 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003581 ;}
3582 break;
3583
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003584 case 108:
Reid Spencer309080a2006-09-28 19:28:24 +00003585#line 1552 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003586 { // integral constants
Reid Spencer309080a2006-09-28 19:28:24 +00003587 if (!ConstantSInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003588 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencer309080a2006-09-28 19:28:24 +00003589 (yyval.ConstVal) = ConstantSInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
Reid Spencer713eedc2006-08-18 08:43:06 +00003590 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003591 ;}
3592 break;
3593
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003594 case 109:
Reid Spencer309080a2006-09-28 19:28:24 +00003595#line 1558 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003596 { // integral constants
Reid Spencer309080a2006-09-28 19:28:24 +00003597 if (!ConstantUInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003598 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencer309080a2006-09-28 19:28:24 +00003599 (yyval.ConstVal) = ConstantUInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
Reid Spencer713eedc2006-08-18 08:43:06 +00003600 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003601 ;}
3602 break;
3603
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003604 case 110:
Reid Spencer309080a2006-09-28 19:28:24 +00003605#line 1564 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003606 { // Boolean constants
3607 (yyval.ConstVal) = ConstantBool::True;
Reid Spencer713eedc2006-08-18 08:43:06 +00003608 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003609 ;}
3610 break;
3611
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003612 case 111:
Reid Spencer309080a2006-09-28 19:28:24 +00003613#line 1568 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003614 { // Boolean constants
3615 (yyval.ConstVal) = ConstantBool::False;
Reid Spencer713eedc2006-08-18 08:43:06 +00003616 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003617 ;}
3618 break;
3619
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003620 case 112:
Reid Spencer309080a2006-09-28 19:28:24 +00003621#line 1572 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003622 { // Float & Double constants
Reid Spencer309080a2006-09-28 19:28:24 +00003623 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003624 GEN_ERROR("Floating point constant invalid for type!!");
Reid Spencer309080a2006-09-28 19:28:24 +00003625 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003626 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003627 ;}
3628 break;
3629
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003630 case 113:
Reid Spencer309080a2006-09-28 19:28:24 +00003631#line 1580 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003632 {
Reid Spencer309080a2006-09-28 19:28:24 +00003633 if (!(yyvsp[-3].ConstVal)->getType()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003634 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer309080a2006-09-28 19:28:24 +00003635 (yyvsp[-3].ConstVal)->getType()->getDescription() + "'!");
3636 if (!(yyvsp[-1].TypeVal)->get()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003637 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer309080a2006-09-28 19:28:24 +00003638 (yyvsp[-1].TypeVal)->get()->getDescription() + "'!");
3639 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get());
3640 delete (yyvsp[-1].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003641 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003642 ;}
3643 break;
3644
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003645 case 114:
Reid Spencer309080a2006-09-28 19:28:24 +00003646#line 1591 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003647 {
Reid Spencer309080a2006-09-28 19:28:24 +00003648 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencer713eedc2006-08-18 08:43:06 +00003649 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003650
3651 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3652 // indices to uint struct indices for compatibility.
3653 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer309080a2006-09-28 19:28:24 +00003654 GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()),
3655 GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end());
3656 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003657 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer309080a2006-09-28 19:28:24 +00003658 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*(yyvsp[-1].ValueList))[i]))
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003659 if (CUI->getType() == Type::UByteTy)
Reid Spencer309080a2006-09-28 19:28:24 +00003660 (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003661
3662 const Type *IdxTy =
Reid Spencer309080a2006-09-28 19:28:24 +00003663 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003664 if (!IdxTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003665 GEN_ERROR("Index list invalid for constant getelementptr!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003666
3667 std::vector<Constant*> IdxVec;
Reid Spencer309080a2006-09-28 19:28:24 +00003668 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
3669 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003670 IdxVec.push_back(C);
3671 else
Reid Spencer713eedc2006-08-18 08:43:06 +00003672 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003673
Reid Spencer309080a2006-09-28 19:28:24 +00003674 delete (yyvsp[-1].ValueList);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003675
Reid Spencer309080a2006-09-28 19:28:24 +00003676 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
Reid Spencer713eedc2006-08-18 08:43:06 +00003677 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003678 ;}
3679 break;
3680
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003681 case 115:
Reid Spencer309080a2006-09-28 19:28:24 +00003682#line 1623 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003683 {
Reid Spencer309080a2006-09-28 19:28:24 +00003684 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003685 GEN_ERROR("Select condition must be of boolean type!");
Reid Spencer309080a2006-09-28 19:28:24 +00003686 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003687 GEN_ERROR("Select operand types must match!");
Reid Spencer309080a2006-09-28 19:28:24 +00003688 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003689 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003690 ;}
3691 break;
3692
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003693 case 116:
Reid Spencer309080a2006-09-28 19:28:24 +00003694#line 1631 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003695 {
Reid Spencer309080a2006-09-28 19:28:24 +00003696 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003697 GEN_ERROR("Binary operator types must match!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003698 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3699 // To retain backward compatibility with these early compilers, we emit a
3700 // cast to the appropriate integer type automatically if we are in the
3701 // broken case. See PR424 for more information.
Reid Spencer309080a2006-09-28 19:28:24 +00003702 if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) {
3703 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003704 } else {
3705 const Type *IntPtrTy = 0;
3706 switch (CurModule.CurrentModule->getPointerSize()) {
3707 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3708 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer713eedc2006-08-18 08:43:06 +00003709 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003710 }
Reid Spencer309080a2006-09-28 19:28:24 +00003711 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy),
3712 ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy));
3713 (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003714 }
Reid Spencer713eedc2006-08-18 08:43:06 +00003715 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003716 ;}
3717 break;
3718
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003719 case 117:
Reid Spencer309080a2006-09-28 19:28:24 +00003720#line 1653 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003721 {
Reid Spencer309080a2006-09-28 19:28:24 +00003722 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003723 GEN_ERROR("Logical operator types must match!");
Reid Spencer309080a2006-09-28 19:28:24 +00003724 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
3725 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
3726 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
Reid Spencer713eedc2006-08-18 08:43:06 +00003727 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner15f5a182005-12-21 18:31:50 +00003728 }
Reid Spencer309080a2006-09-28 19:28:24 +00003729 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003730 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003731 ;}
3732 break;
3733
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003734 case 118:
Reid Spencer309080a2006-09-28 19:28:24 +00003735#line 1664 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003736 {
Reid Spencer309080a2006-09-28 19:28:24 +00003737 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003738 GEN_ERROR("setcc operand types must match!");
Reid Spencer309080a2006-09-28 19:28:24 +00003739 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003740 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003741 ;}
3742 break;
3743
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003744 case 119:
Reid Spencer309080a2006-09-28 19:28:24 +00003745#line 1670 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003746 {
Reid Spencer309080a2006-09-28 19:28:24 +00003747 if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003748 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
Reid Spencer309080a2006-09-28 19:28:24 +00003749 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
Reid Spencer713eedc2006-08-18 08:43:06 +00003750 GEN_ERROR("Shift constant expression requires integer operand!");
Reid Spencer309080a2006-09-28 19:28:24 +00003751 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003752 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003753 ;}
3754 break;
3755
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003756 case 120:
Reid Spencer309080a2006-09-28 19:28:24 +00003757#line 1678 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003758 {
Reid Spencer309080a2006-09-28 19:28:24 +00003759 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003760 GEN_ERROR("Invalid extractelement operands!");
Reid Spencer309080a2006-09-28 19:28:24 +00003761 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003762 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003763 ;}
3764 break;
3765
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003766 case 121:
Reid Spencer309080a2006-09-28 19:28:24 +00003767#line 1684 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003768 {
Reid Spencer309080a2006-09-28 19:28:24 +00003769 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003770 GEN_ERROR("Invalid insertelement operands!");
Reid Spencer309080a2006-09-28 19:28:24 +00003771 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003772 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003773 ;}
3774 break;
3775
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003776 case 122:
Reid Spencer309080a2006-09-28 19:28:24 +00003777#line 1690 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003778 {
Reid Spencer309080a2006-09-28 19:28:24 +00003779 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer713eedc2006-08-18 08:43:06 +00003780 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencer309080a2006-09-28 19:28:24 +00003781 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003782 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003783 ;}
3784 break;
3785
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003786 case 123:
Reid Spencer309080a2006-09-28 19:28:24 +00003787#line 1699 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003788 {
Reid Spencer309080a2006-09-28 19:28:24 +00003789 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003790 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003791 ;}
3792 break;
3793
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003794 case 124:
Reid Spencer309080a2006-09-28 19:28:24 +00003795#line 1703 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003796 {
3797 (yyval.ConstVector) = new std::vector<Constant*>();
Reid Spencer309080a2006-09-28 19:28:24 +00003798 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003799 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003800 ;}
3801 break;
3802
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003803 case 125:
Reid Spencer309080a2006-09-28 19:28:24 +00003804#line 1711 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003805 { (yyval.BoolVal) = false; ;}
3806 break;
3807
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003808 case 126:
Reid Spencer309080a2006-09-28 19:28:24 +00003809#line 1711 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003810 { (yyval.BoolVal) = true; ;}
3811 break;
3812
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003813 case 127:
Reid Spencer309080a2006-09-28 19:28:24 +00003814#line 1721 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003815 {
Reid Spencer309080a2006-09-28 19:28:24 +00003816 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003817 CurModule.ModuleDone();
Reid Spencer713eedc2006-08-18 08:43:06 +00003818 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003819;}
3820 break;
3821
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003822 case 128:
Reid Spencer309080a2006-09-28 19:28:24 +00003823#line 1729 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003824 {
Reid Spencer309080a2006-09-28 19:28:24 +00003825 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003826 CurFun.FunctionDone();
Reid Spencer713eedc2006-08-18 08:43:06 +00003827 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003828 ;}
3829 break;
3830
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003831 case 129:
Reid Spencer309080a2006-09-28 19:28:24 +00003832#line 1734 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003833 {
Reid Spencer309080a2006-09-28 19:28:24 +00003834 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003835 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003836 ;}
3837 break;
3838
3839 case 130:
Reid Spencer309080a2006-09-28 19:28:24 +00003840#line 1738 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003841 {
Reid Spencer309080a2006-09-28 19:28:24 +00003842 (yyval.ModuleVal) = (yyvsp[-3].ModuleVal);
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003843 CHECK_FOR_ERROR
3844 ;}
3845 break;
3846
3847 case 131:
Reid Spencer309080a2006-09-28 19:28:24 +00003848#line 1742 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003849 {
Reid Spencer309080a2006-09-28 19:28:24 +00003850 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003851 CHECK_FOR_ERROR
3852 ;}
3853 break;
3854
3855 case 132:
Reid Spencer309080a2006-09-28 19:28:24 +00003856#line 1746 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003857 {
3858 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003859 // Emit an error if there are any unresolved types left.
3860 if (!CurModule.LateResolveTypes.empty()) {
3861 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer713eedc2006-08-18 08:43:06 +00003862 if (DID.Type == ValID::NameVal) {
3863 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3864 } else {
3865 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3866 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003867 }
Reid Spencer713eedc2006-08-18 08:43:06 +00003868 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003869 ;}
3870 break;
3871
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003872 case 133:
Reid Spencer309080a2006-09-28 19:28:24 +00003873#line 1761 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003874 {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003875 // Eagerly resolve types. This is not an optimization, this is a
3876 // requirement that is due to the fact that we could have this:
3877 //
3878 // %list = type { %list * }
3879 // %list = type { %list * } ; repeated type decl
3880 //
3881 // If types are not resolved eagerly, then the two types will not be
3882 // determined to be the same type!
3883 //
Reid Spencer309080a2006-09-28 19:28:24 +00003884 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003885
Reid Spencer309080a2006-09-28 19:28:24 +00003886 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
3887 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003888 // If this is a named type that is not a redefinition, add it to the slot
3889 // table.
Reid Spencer309080a2006-09-28 19:28:24 +00003890 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003891 }
3892
Reid Spencer309080a2006-09-28 19:28:24 +00003893 delete (yyvsp[0].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003894 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003895 ;}
3896 break;
3897
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003898 case 134:
Reid Spencer309080a2006-09-28 19:28:24 +00003899#line 1783 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003900 { // Function prototypes can be in const pool
Reid Spencer713eedc2006-08-18 08:43:06 +00003901 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003902 ;}
3903 break;
3904
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003905 case 135:
Reid Spencer309080a2006-09-28 19:28:24 +00003906#line 1786 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003907 { // Asm blocks can be in the const pool
Reid Spencer713eedc2006-08-18 08:43:06 +00003908 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003909 ;}
3910 break;
3911
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003912 case 136:
Reid Spencer309080a2006-09-28 19:28:24 +00003913#line 1789 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003914 {
Reid Spencer309080a2006-09-28 19:28:24 +00003915 if ((yyvsp[0].ConstVal) == 0)
3916 GEN_ERROR("Global value initializer is not a constant!");
3917 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00003918 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003919 ;}
3920 break;
3921
Reid Spencer309080a2006-09-28 19:28:24 +00003922 case 137:
3923#line 1794 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003924 {
Reid Spencer309080a2006-09-28 19:28:24 +00003925 CurGV = 0;
3926 ;}
3927 break;
3928
3929 case 138:
3930#line 1797 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3931 {
3932 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
3933 CHECK_FOR_ERROR
3934 delete (yyvsp[0].TypeVal);
3935 ;}
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003936 break;
3937
3938 case 139:
Reid Spencer309080a2006-09-28 19:28:24 +00003939#line 1801 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003940 {
3941 CurGV = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00003942 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003943 ;}
3944 break;
3945
3946 case 140:
Reid Spencer309080a2006-09-28 19:28:24 +00003947#line 1805 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003948 {
Reid Spencer309080a2006-09-28 19:28:24 +00003949 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
3950 CHECK_FOR_ERROR
3951 delete (yyvsp[0].TypeVal);
3952 ;}
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003953 break;
3954
3955 case 141:
Reid Spencer309080a2006-09-28 19:28:24 +00003956#line 1809 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003957 {
3958 CurGV = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00003959 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003960 ;}
3961 break;
3962
3963 case 142:
Reid Spencer309080a2006-09-28 19:28:24 +00003964#line 1813 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003965 {
Reid Spencer309080a2006-09-28 19:28:24 +00003966 CurGV =
3967 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
3968 CHECK_FOR_ERROR
3969 delete (yyvsp[0].TypeVal);
3970 ;}
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003971 break;
3972
3973 case 143:
Reid Spencer309080a2006-09-28 19:28:24 +00003974#line 1818 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003975 {
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003976 CurGV = 0;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003977 CHECK_FOR_ERROR
3978 ;}
3979 break;
3980
3981 case 144:
Reid Spencer309080a2006-09-28 19:28:24 +00003982#line 1822 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003983 {
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003984 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003985 ;}
3986 break;
3987
3988 case 145:
Reid Spencer309080a2006-09-28 19:28:24 +00003989#line 1825 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003990 {
3991 CHECK_FOR_ERROR
3992 ;}
3993 break;
3994
3995 case 146:
Reid Spencer309080a2006-09-28 19:28:24 +00003996#line 1828 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003997 {
3998 ;}
3999 break;
4000
4001 case 147:
Reid Spencer309080a2006-09-28 19:28:24 +00004002#line 1832 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004003 {
Chris Lattner8ebd2162006-01-24 04:14:29 +00004004 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer309080a2006-09-28 19:28:24 +00004005 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4006 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4007 free((yyvsp[0].StrVal));
Chris Lattner8ebd2162006-01-24 04:14:29 +00004008
4009 if (AsmSoFar.empty())
4010 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4011 else
4012 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer713eedc2006-08-18 08:43:06 +00004013 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004014;}
4015 break;
4016
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004017 case 148:
Reid Spencer309080a2006-09-28 19:28:24 +00004018#line 1845 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004019 { (yyval.Endianness) = Module::BigEndian; ;}
4020 break;
4021
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004022 case 149:
Reid Spencer309080a2006-09-28 19:28:24 +00004023#line 1846 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004024 { (yyval.Endianness) = Module::LittleEndian; ;}
4025 break;
4026
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004027 case 150:
Reid Spencer309080a2006-09-28 19:28:24 +00004028#line 1848 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004029 {
Reid Spencer309080a2006-09-28 19:28:24 +00004030 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
Reid Spencer713eedc2006-08-18 08:43:06 +00004031 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004032 ;}
4033 break;
4034
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004035 case 151:
Reid Spencer309080a2006-09-28 19:28:24 +00004036#line 1852 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004037 {
Reid Spencer309080a2006-09-28 19:28:24 +00004038 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004039 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Reid Spencer309080a2006-09-28 19:28:24 +00004040 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004041 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4042 else
Reid Spencer309080a2006-09-28 19:28:24 +00004043 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
Reid Spencer713eedc2006-08-18 08:43:06 +00004044 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004045 ;}
4046 break;
4047
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004048 case 152:
Reid Spencer309080a2006-09-28 19:28:24 +00004049#line 1861 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004050 {
Reid Spencer309080a2006-09-28 19:28:24 +00004051 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4052 free((yyvsp[0].StrVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004053 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004054 ;}
4055 break;
4056
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004057 case 154:
Reid Spencer309080a2006-09-28 19:28:24 +00004058#line 1869 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004059 {
Reid Spencer309080a2006-09-28 19:28:24 +00004060 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4061 free((yyvsp[0].StrVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004062 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004063 ;}
4064 break;
4065
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004066 case 155:
Reid Spencer309080a2006-09-28 19:28:24 +00004067#line 1874 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004068 {
Reid Spencer309080a2006-09-28 19:28:24 +00004069 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4070 free((yyvsp[0].StrVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004071 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004072 ;}
4073 break;
4074
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004075 case 156:
Reid Spencer309080a2006-09-28 19:28:24 +00004076#line 1879 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004077 {
Reid Spencer713eedc2006-08-18 08:43:06 +00004078 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004079 ;}
4080 break;
4081
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004082 case 160:
Reid Spencer309080a2006-09-28 19:28:24 +00004083#line 1889 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004084 { (yyval.StrVal) = 0; ;}
4085 break;
4086
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004087 case 161:
Reid Spencer309080a2006-09-28 19:28:24 +00004088#line 1891 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004089 {
Reid Spencer309080a2006-09-28 19:28:24 +00004090 if (*(yyvsp[-1].TypeVal) == Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00004091 GEN_ERROR("void typed arguments are invalid!");
Reid Spencer309080a2006-09-28 19:28:24 +00004092 (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004093 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004094;}
4095 break;
4096
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004097 case 162:
Reid Spencer309080a2006-09-28 19:28:24 +00004098#line 1898 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004099 {
Reid Spencer309080a2006-09-28 19:28:24 +00004100 (yyval.ArgList) = (yyvsp[-2].ArgList);
4101 (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal));
4102 delete (yyvsp[0].ArgVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004103 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004104 ;}
4105 break;
4106
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004107 case 163:
Reid Spencer309080a2006-09-28 19:28:24 +00004108#line 1904 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004109 {
4110 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
Reid Spencer309080a2006-09-28 19:28:24 +00004111 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4112 delete (yyvsp[0].ArgVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004113 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004114 ;}
4115 break;
4116
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004117 case 164:
Reid Spencer309080a2006-09-28 19:28:24 +00004118#line 1911 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004119 {
Reid Spencer309080a2006-09-28 19:28:24 +00004120 (yyval.ArgList) = (yyvsp[0].ArgList);
Reid Spencer713eedc2006-08-18 08:43:06 +00004121 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004122 ;}
4123 break;
4124
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004125 case 165:
Reid Spencer309080a2006-09-28 19:28:24 +00004126#line 1915 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004127 {
Reid Spencer309080a2006-09-28 19:28:24 +00004128 (yyval.ArgList) = (yyvsp[-2].ArgList);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004129 (yyval.ArgList)->push_back(std::pair<PATypeHolder*,
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004130 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer713eedc2006-08-18 08:43:06 +00004131 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004132 ;}
4133 break;
4134
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004135 case 166:
Reid Spencer309080a2006-09-28 19:28:24 +00004136#line 1921 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004137 {
4138 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4139 (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Reid Spencer713eedc2006-08-18 08:43:06 +00004140 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004141 ;}
4142 break;
4143
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004144 case 167:
Reid Spencer309080a2006-09-28 19:28:24 +00004145#line 1926 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004146 {
4147 (yyval.ArgList) = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00004148 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004149 ;}
4150 break;
4151
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004152 case 168:
Reid Spencer309080a2006-09-28 19:28:24 +00004153#line 1932 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004154 {
Reid Spencer309080a2006-09-28 19:28:24 +00004155 UnEscapeLexed((yyvsp[-5].StrVal));
4156 std::string FunctionName((yyvsp[-5].StrVal));
4157 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004158
Reid Spencer309080a2006-09-28 19:28:24 +00004159 if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00004160 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004161
4162 std::vector<const Type*> ParamTypeList;
Reid Spencer309080a2006-09-28 19:28:24 +00004163 if ((yyvsp[-3].ArgList)) { // If there are arguments...
4164 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4165 I != (yyvsp[-3].ArgList)->end(); ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004166 ParamTypeList.push_back(I->first->get());
4167 }
4168
4169 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4170 if (isVarArg) ParamTypeList.pop_back();
4171
Reid Spencer309080a2006-09-28 19:28:24 +00004172 const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004173 const PointerType *PFT = PointerType::get(FT);
Reid Spencer309080a2006-09-28 19:28:24 +00004174 delete (yyvsp[-6].TypeVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004175
4176 ValID ID;
4177 if (!FunctionName.empty()) {
4178 ID = ValID::create((char*)FunctionName.c_str());
4179 } else {
4180 ID = ValID::create((int)CurModule.Values[PFT].size());
4181 }
4182
4183 Function *Fn = 0;
4184 // See if this function was forward referenced. If so, recycle the object.
4185 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4186 // Move the function to the end of the list, from whereever it was
4187 // previously inserted.
4188 Fn = cast<Function>(FWRef);
4189 CurModule.CurrentModule->getFunctionList().remove(Fn);
4190 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4191 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4192 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4193 // If this is the case, either we need to be a forward decl, or it needs
4194 // to be.
4195 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer713eedc2006-08-18 08:43:06 +00004196 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004197
4198 // Make sure to strip off any argument names so we can't get conflicts.
4199 if (Fn->isExternal())
4200 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4201 AI != AE; ++AI)
4202 AI->setName("");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004203 } else { // Not already defined?
4204 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4205 CurModule.CurrentModule);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004206
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004207 InsertValue(Fn, CurModule.Values);
4208 }
4209
4210 CurFun.FunctionStart(Fn);
Anton Korobeynikov0ab01ff2006-09-17 13:06:18 +00004211
4212 if (CurFun.isDeclare) {
4213 // If we have declaration, always overwrite linkage. This will allow us to
4214 // correctly handle cases, when pointer to function is passed as argument to
4215 // another function.
4216 Fn->setLinkage(CurFun.Linkage);
4217 }
Reid Spencer309080a2006-09-28 19:28:24 +00004218 Fn->setCallingConv((yyvsp[-7].UIntVal));
4219 Fn->setAlignment((yyvsp[0].UIntVal));
4220 if ((yyvsp[-1].StrVal)) {
4221 Fn->setSection((yyvsp[-1].StrVal));
4222 free((yyvsp[-1].StrVal));
Chris Lattnera0c20b42005-11-12 00:11:49 +00004223 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004224
4225 // Add all of the arguments we parsed to the function...
Reid Spencer309080a2006-09-28 19:28:24 +00004226 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004227 if (isVarArg) { // Nuke the last entry
Reid Spencer309080a2006-09-28 19:28:24 +00004228 assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&&
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004229 "Not a varargs marker!");
Reid Spencer309080a2006-09-28 19:28:24 +00004230 delete (yyvsp[-3].ArgList)->back().first;
4231 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004232 }
4233 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer309080a2006-09-28 19:28:24 +00004234 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4235 I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004236 delete I->first; // Delete the typeholder...
4237
4238 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer309080a2006-09-28 19:28:24 +00004239 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004240 InsertValue(ArgIt);
4241 }
4242
Reid Spencer309080a2006-09-28 19:28:24 +00004243 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004244 }
Reid Spencer713eedc2006-08-18 08:43:06 +00004245 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004246;}
4247 break;
4248
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004249 case 171:
Reid Spencer309080a2006-09-28 19:28:24 +00004250#line 2028 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004251 {
4252 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004253
4254 // Make sure that we keep track of the linkage type even if there was a
4255 // previous "declare".
Reid Spencer309080a2006-09-28 19:28:24 +00004256 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004257;}
4258 break;
4259
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004260 case 174:
Reid Spencer309080a2006-09-28 19:28:24 +00004261#line 2038 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004262 {
Reid Spencer309080a2006-09-28 19:28:24 +00004263 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004264 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004265;}
4266 break;
4267
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004268 case 176:
Reid Spencer309080a2006-09-28 19:28:24 +00004269#line 2044 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004270 { CurFun.Linkage = GlobalValue::DLLImportLinkage ;}
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004271 break;
4272
4273 case 177:
Reid Spencer309080a2006-09-28 19:28:24 +00004274#line 2045 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004275 { CurFun.Linkage = GlobalValue::DLLImportLinkage ;}
4276 break;
4277
4278 case 178:
Reid Spencer309080a2006-09-28 19:28:24 +00004279#line 2047 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004280 { CurFun.isDeclare = true; ;}
4281 break;
4282
4283 case 179:
Reid Spencer309080a2006-09-28 19:28:24 +00004284#line 2047 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004285 {
4286 (yyval.FunctionVal) = CurFun.CurrentFunction;
4287 CurFun.FunctionDone();
Reid Spencer713eedc2006-08-18 08:43:06 +00004288 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004289 ;}
4290 break;
4291
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004292 case 180:
Reid Spencer309080a2006-09-28 19:28:24 +00004293#line 2057 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004294 {
4295 (yyval.BoolVal) = false;
Reid Spencer713eedc2006-08-18 08:43:06 +00004296 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004297 ;}
4298 break;
4299
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004300 case 181:
Reid Spencer309080a2006-09-28 19:28:24 +00004301#line 2061 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004302 {
4303 (yyval.BoolVal) = true;
Reid Spencer713eedc2006-08-18 08:43:06 +00004304 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004305 ;}
4306 break;
4307
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004308 case 182:
Reid Spencer309080a2006-09-28 19:28:24 +00004309#line 2066 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004310 { // A reference to a direct constant
Reid Spencer309080a2006-09-28 19:28:24 +00004311 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencer713eedc2006-08-18 08:43:06 +00004312 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004313 ;}
4314 break;
4315
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004316 case 183:
Reid Spencer309080a2006-09-28 19:28:24 +00004317#line 2070 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004318 {
Reid Spencer309080a2006-09-28 19:28:24 +00004319 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer713eedc2006-08-18 08:43:06 +00004320 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004321 ;}
4322 break;
4323
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004324 case 184:
Reid Spencer309080a2006-09-28 19:28:24 +00004325#line 2074 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004326 { // Perhaps it's an FP constant?
Reid Spencer309080a2006-09-28 19:28:24 +00004327 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004328 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004329 ;}
4330 break;
4331
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004332 case 185:
Reid Spencer309080a2006-09-28 19:28:24 +00004333#line 2078 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004334 {
4335 (yyval.ValIDVal) = ValID::create(ConstantBool::True);
Reid Spencer713eedc2006-08-18 08:43:06 +00004336 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004337 ;}
4338 break;
4339
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004340 case 186:
Reid Spencer309080a2006-09-28 19:28:24 +00004341#line 2082 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004342 {
4343 (yyval.ValIDVal) = ValID::create(ConstantBool::False);
Reid Spencer713eedc2006-08-18 08:43:06 +00004344 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004345 ;}
4346 break;
4347
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004348 case 187:
Reid Spencer309080a2006-09-28 19:28:24 +00004349#line 2086 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004350 {
4351 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer713eedc2006-08-18 08:43:06 +00004352 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004353 ;}
4354 break;
4355
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004356 case 188:
Reid Spencer309080a2006-09-28 19:28:24 +00004357#line 2090 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004358 {
4359 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer713eedc2006-08-18 08:43:06 +00004360 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004361 ;}
4362 break;
4363
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004364 case 189:
Reid Spencer309080a2006-09-28 19:28:24 +00004365#line 2094 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004366 { // A vector zero constant.
4367 (yyval.ValIDVal) = ValID::createZeroInit();
4368 CHECK_FOR_ERROR
4369 ;}
4370 break;
4371
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004372 case 190:
Reid Spencer309080a2006-09-28 19:28:24 +00004373#line 2098 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004374 { // Nonempty unsized packed vector
Reid Spencer309080a2006-09-28 19:28:24 +00004375 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4376 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004377
4378 PackedType* pt = PackedType::get(ETy, NumElements);
4379 PATypeHolder* PTy = new PATypeHolder(
4380 HandleUpRefs(
4381 PackedType::get(
4382 ETy,
4383 NumElements)
4384 )
4385 );
4386
4387 // Verify all elements are correct type!
Reid Spencer309080a2006-09-28 19:28:24 +00004388 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4389 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00004390 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004391 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer309080a2006-09-28 19:28:24 +00004392 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004393 }
4394
Reid Spencer309080a2006-09-28 19:28:24 +00004395 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4396 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer713eedc2006-08-18 08:43:06 +00004397 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004398 ;}
4399 break;
Reid Spencer713eedc2006-08-18 08:43:06 +00004400
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004401 case 191:
Reid Spencer309080a2006-09-28 19:28:24 +00004402#line 2123 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004403 {
Reid Spencer309080a2006-09-28 19:28:24 +00004404 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004405 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004406 ;}
4407 break;
4408
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004409 case 192:
Reid Spencer309080a2006-09-28 19:28:24 +00004410#line 2127 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004411 {
Reid Spencer309080a2006-09-28 19:28:24 +00004412 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4413 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4414 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4415 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4416 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4417 free((yyvsp[-2].StrVal));
4418 free((yyvsp[0].StrVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004419 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004420 ;}
4421 break;
4422
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004423 case 193:
Reid Spencer309080a2006-09-28 19:28:24 +00004424#line 2141 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004425 { // Is it an integer reference...?
Reid Spencer309080a2006-09-28 19:28:24 +00004426 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004427 CHECK_FOR_ERROR
4428 ;}
4429 break;
4430
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004431 case 194:
Reid Spencer309080a2006-09-28 19:28:24 +00004432#line 2145 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004433 { // Is it a named reference...?
Reid Spencer309080a2006-09-28 19:28:24 +00004434 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004435 CHECK_FOR_ERROR
4436 ;}
4437 break;
4438
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004439 case 197:
Reid Spencer309080a2006-09-28 19:28:24 +00004440#line 2157 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004441 {
Reid Spencer309080a2006-09-28 19:28:24 +00004442 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004443 CHECK_FOR_ERROR
4444 ;}
4445 break;
4446
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004447 case 198:
Reid Spencer309080a2006-09-28 19:28:24 +00004448#line 2162 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004449 {
Reid Spencer309080a2006-09-28 19:28:24 +00004450 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004451 CHECK_FOR_ERROR
4452 ;}
4453 break;
4454
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004455 case 199:
Reid Spencer309080a2006-09-28 19:28:24 +00004456#line 2166 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004457 { // Do not allow functions with 0 basic blocks
Reid Spencer309080a2006-09-28 19:28:24 +00004458 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004459 CHECK_FOR_ERROR
4460 ;}
4461 break;
4462
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004463 case 200:
Reid Spencer309080a2006-09-28 19:28:24 +00004464#line 2175 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004465 {
Reid Spencer309080a2006-09-28 19:28:24 +00004466 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4467 CHECK_FOR_ERROR
4468 InsertValue((yyvsp[0].TermInstVal));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004469
Reid Spencer309080a2006-09-28 19:28:24 +00004470 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4471 InsertValue((yyvsp[-2].BasicBlockVal));
4472 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004473 CHECK_FOR_ERROR
4474 ;}
4475 break;
4476
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004477 case 201:
Reid Spencer309080a2006-09-28 19:28:24 +00004478#line 2186 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004479 {
Reid Spencer309080a2006-09-28 19:28:24 +00004480 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4481 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004482 CHECK_FOR_ERROR
4483 ;}
4484 break;
4485
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004486 case 202:
Reid Spencer309080a2006-09-28 19:28:24 +00004487#line 2191 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004488 {
4489 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer309080a2006-09-28 19:28:24 +00004490 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004491
4492 // Make sure to move the basic block to the correct location in the
4493 // function, instead of leaving it inserted wherever it was first
4494 // referenced.
4495 Function::BasicBlockListType &BBL =
4496 CurFun.CurrentFunction->getBasicBlockList();
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004497 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004498 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004499 ;}
4500 break;
4501
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004502 case 203:
Reid Spencer309080a2006-09-28 19:28:24 +00004503#line 2203 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004504 {
Reid Spencer309080a2006-09-28 19:28:24 +00004505 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
4506 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004507
4508 // Make sure to move the basic block to the correct location in the
4509 // function, instead of leaving it inserted wherever it was first
4510 // referenced.
4511 Function::BasicBlockListType &BBL =
4512 CurFun.CurrentFunction->getBasicBlockList();
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004513 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004514 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004515 ;}
4516 break;
Reid Spencer713eedc2006-08-18 08:43:06 +00004517
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004518 case 204:
Reid Spencer309080a2006-09-28 19:28:24 +00004519#line 2216 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004520 { // Return with a result...
Reid Spencer309080a2006-09-28 19:28:24 +00004521 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004522 CHECK_FOR_ERROR
4523 ;}
4524 break;
4525
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004526 case 205:
Reid Spencer309080a2006-09-28 19:28:24 +00004527#line 2220 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004528 { // Return with no result...
4529 (yyval.TermInstVal) = new ReturnInst();
4530 CHECK_FOR_ERROR
4531 ;}
4532 break;
4533
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004534 case 206:
Reid Spencer309080a2006-09-28 19:28:24 +00004535#line 2224 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004536 { // Unconditional Branch...
Reid Spencer309080a2006-09-28 19:28:24 +00004537 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004538 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00004539 (yyval.TermInstVal) = new BranchInst(tmpBB);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004540 ;}
4541 break;
4542
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004543 case 207:
Reid Spencer309080a2006-09-28 19:28:24 +00004544#line 2229 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004545 {
Reid Spencer309080a2006-09-28 19:28:24 +00004546 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004547 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00004548 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
4549 CHECK_FOR_ERROR
4550 Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal));
4551 CHECK_FOR_ERROR
4552 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004553 ;}
4554 break;
4555
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004556 case 208:
Reid Spencer309080a2006-09-28 19:28:24 +00004557#line 2238 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004558 {
Reid Spencer309080a2006-09-28 19:28:24 +00004559 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
4560 CHECK_FOR_ERROR
4561 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
4562 CHECK_FOR_ERROR
4563 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004564 (yyval.TermInstVal) = S;
4565
Reid Spencer309080a2006-09-28 19:28:24 +00004566 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4567 E = (yyvsp[-1].JumpTable)->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004568 for (; I != E; ++I) {
4569 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4570 S->addCase(CI, I->second);
4571 else
Reid Spencer713eedc2006-08-18 08:43:06 +00004572 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004573 }
Reid Spencer309080a2006-09-28 19:28:24 +00004574 delete (yyvsp[-1].JumpTable);
Reid Spencer713eedc2006-08-18 08:43:06 +00004575 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004576 ;}
4577 break;
4578
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004579 case 209:
Reid Spencer309080a2006-09-28 19:28:24 +00004580#line 2257 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004581 {
Reid Spencer309080a2006-09-28 19:28:24 +00004582 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
4583 CHECK_FOR_ERROR
4584 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
4585 CHECK_FOR_ERROR
4586 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004587 (yyval.TermInstVal) = S;
Reid Spencer713eedc2006-08-18 08:43:06 +00004588 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004589 ;}
4590 break;
4591
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004592 case 210:
Reid Spencer309080a2006-09-28 19:28:24 +00004593#line 2267 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004594 {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004595 const PointerType *PFTy;
4596 const FunctionType *Ty;
4597
Reid Spencer309080a2006-09-28 19:28:24 +00004598 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) ||
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004599 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4600 // Pull out the types of all of the arguments...
4601 std::vector<const Type*> ParamTypes;
Reid Spencer309080a2006-09-28 19:28:24 +00004602 if ((yyvsp[-7].ValueList)) {
4603 for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004604 I != E; ++I)
4605 ParamTypes.push_back((*I)->getType());
4606 }
4607
4608 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4609 if (isVarArg) ParamTypes.pop_back();
4610
Reid Spencer309080a2006-09-28 19:28:24 +00004611 Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004612 PFTy = PointerType::get(Ty);
4613 }
4614
Reid Spencer309080a2006-09-28 19:28:24 +00004615 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
4616 CHECK_FOR_ERROR
4617 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
4618 CHECK_FOR_ERROR
4619 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
4620 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004621
4622 // Create the call node...
Reid Spencer309080a2006-09-28 19:28:24 +00004623 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004624 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004625 } else { // Has arguments?
4626 // Loop through FunctionType's arguments and ensure they are specified
4627 // correctly!
4628 //
4629 FunctionType::param_iterator I = Ty->param_begin();
4630 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer309080a2006-09-28 19:28:24 +00004631 std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004632
4633 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4634 if ((*ArgI)->getType() != *I)
Reid Spencer713eedc2006-08-18 08:43:06 +00004635 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004636 (*I)->getDescription() + "'!");
4637
4638 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004639 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004640
Reid Spencer309080a2006-09-28 19:28:24 +00004641 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004642 }
Reid Spencer309080a2006-09-28 19:28:24 +00004643 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004644
Reid Spencer309080a2006-09-28 19:28:24 +00004645 delete (yyvsp[-10].TypeVal);
4646 delete (yyvsp[-7].ValueList);
Reid Spencer713eedc2006-08-18 08:43:06 +00004647 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004648 ;}
4649 break;
4650
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004651 case 211:
Reid Spencer309080a2006-09-28 19:28:24 +00004652#line 2322 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004653 {
4654 (yyval.TermInstVal) = new UnwindInst();
Reid Spencer713eedc2006-08-18 08:43:06 +00004655 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004656 ;}
4657 break;
4658
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004659 case 212:
Reid Spencer309080a2006-09-28 19:28:24 +00004660#line 2326 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004661 {
4662 (yyval.TermInstVal) = new UnreachableInst();
Reid Spencer713eedc2006-08-18 08:43:06 +00004663 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004664 ;}
4665 break;
4666
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004667 case 213:
Reid Spencer309080a2006-09-28 19:28:24 +00004668#line 2333 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004669 {
Reid Spencer309080a2006-09-28 19:28:24 +00004670 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
4671 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
4672 CHECK_FOR_ERROR
Reid Spencer713eedc2006-08-18 08:43:06 +00004673 if (V == 0)
4674 GEN_ERROR("May only switch on a constant pool value!");
4675
Reid Spencer309080a2006-09-28 19:28:24 +00004676 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004677 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00004678 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004679 ;}
4680 break;
4681
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004682 case 214:
Reid Spencer309080a2006-09-28 19:28:24 +00004683#line 2344 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004684 {
4685 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencer309080a2006-09-28 19:28:24 +00004686 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
4687 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004688
4689 if (V == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004690 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004691
Reid Spencer309080a2006-09-28 19:28:24 +00004692 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004693 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00004694 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004695 ;}
4696 break;
4697
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004698 case 215:
Reid Spencer309080a2006-09-28 19:28:24 +00004699#line 2357 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004700 {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004701 // Is this definition named?? if so, assign the name...
Reid Spencer309080a2006-09-28 19:28:24 +00004702 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
4703 CHECK_FOR_ERROR
4704 InsertValue((yyvsp[0].InstVal));
4705 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004706 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004707;}
4708 break;
4709
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004710 case 216:
Reid Spencer309080a2006-09-28 19:28:24 +00004711#line 2366 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004712 { // Used for PHI nodes
4713 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencer309080a2006-09-28 19:28:24 +00004714 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004715 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00004716 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
4717 CHECK_FOR_ERROR
4718 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4719 delete (yyvsp[-5].TypeVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004720 ;}
4721 break;
4722
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004723 case 217:
Reid Spencer309080a2006-09-28 19:28:24 +00004724#line 2375 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004725 {
Reid Spencer309080a2006-09-28 19:28:24 +00004726 (yyval.PHIList) = (yyvsp[-6].PHIList);
4727 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004728 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00004729 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
4730 CHECK_FOR_ERROR
4731 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004732 ;}
4733 break;
4734
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004735 case 218:
Reid Spencer309080a2006-09-28 19:28:24 +00004736#line 2385 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004737 { // Used for call statements, and memory insts...
4738 (yyval.ValueList) = new std::vector<Value*>();
Reid Spencer309080a2006-09-28 19:28:24 +00004739 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004740 ;}
4741 break;
4742
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004743 case 219:
Reid Spencer309080a2006-09-28 19:28:24 +00004744#line 2389 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004745 {
Reid Spencer309080a2006-09-28 19:28:24 +00004746 (yyval.ValueList) = (yyvsp[-2].ValueList);
4747 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004748 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004749 ;}
4750 break;
4751
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004752 case 221:
Reid Spencer309080a2006-09-28 19:28:24 +00004753#line 2396 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004754 { (yyval.ValueList) = 0; ;}
4755 break;
4756
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004757 case 222:
Reid Spencer309080a2006-09-28 19:28:24 +00004758#line 2398 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004759 {
4760 (yyval.BoolVal) = true;
Reid Spencer713eedc2006-08-18 08:43:06 +00004761 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004762 ;}
4763 break;
4764
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004765 case 223:
Reid Spencer309080a2006-09-28 19:28:24 +00004766#line 2402 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004767 {
4768 (yyval.BoolVal) = false;
Reid Spencer713eedc2006-08-18 08:43:06 +00004769 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004770 ;}
4771 break;
4772
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004773 case 224:
Reid Spencer309080a2006-09-28 19:28:24 +00004774#line 2407 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004775 {
Reid Spencer309080a2006-09-28 19:28:24 +00004776 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
4777 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004778 GEN_ERROR(
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004779 "Arithmetic operator requires integer, FP, or packed operands!");
Reid Spencer309080a2006-09-28 19:28:24 +00004780 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) && (yyvsp[-4].BinaryOpVal) == Instruction::Rem)
Reid Spencer713eedc2006-08-18 08:43:06 +00004781 GEN_ERROR("Rem not supported on packed types!");
Reid Spencer309080a2006-09-28 19:28:24 +00004782 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
4783 CHECK_FOR_ERROR
4784 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
4785 CHECK_FOR_ERROR
4786 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004787 if ((yyval.InstVal) == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004788 GEN_ERROR("binary operator returned null!");
Reid Spencer309080a2006-09-28 19:28:24 +00004789 delete (yyvsp[-3].TypeVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004790 ;}
4791 break;
4792
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004793 case 225:
Reid Spencer309080a2006-09-28 19:28:24 +00004794#line 2423 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004795 {
Reid Spencer309080a2006-09-28 19:28:24 +00004796 if (!(*(yyvsp[-3].TypeVal))->isIntegral()) {
4797 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
4798 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral())
Reid Spencer713eedc2006-08-18 08:43:06 +00004799 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner15f5a182005-12-21 18:31:50 +00004800 }
Reid Spencer309080a2006-09-28 19:28:24 +00004801 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
4802 CHECK_FOR_ERROR
4803 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
4804 CHECK_FOR_ERROR
4805 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004806 if ((yyval.InstVal) == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004807 GEN_ERROR("binary operator returned null!");
Reid Spencer309080a2006-09-28 19:28:24 +00004808 delete (yyvsp[-3].TypeVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004809 ;}
4810 break;
4811
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004812 case 226:
Reid Spencer309080a2006-09-28 19:28:24 +00004813#line 2438 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004814 {
Reid Spencer309080a2006-09-28 19:28:24 +00004815 if(isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) {
Reid Spencer713eedc2006-08-18 08:43:06 +00004816 GEN_ERROR(
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004817 "PackedTypes currently not supported in setcc instructions!");
4818 }
Reid Spencer309080a2006-09-28 19:28:24 +00004819 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
4820 CHECK_FOR_ERROR
4821 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
4822 CHECK_FOR_ERROR
4823 (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004824 if ((yyval.InstVal) == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004825 GEN_ERROR("binary operator returned null!");
Reid Spencer309080a2006-09-28 19:28:24 +00004826 delete (yyvsp[-3].TypeVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004827 ;}
4828 break;
4829
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004830 case 227:
Reid Spencer309080a2006-09-28 19:28:24 +00004831#line 2452 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004832 {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004833 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4834 << " Replacing with 'xor'.\n";
4835
Reid Spencer309080a2006-09-28 19:28:24 +00004836 Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004837 if (Ones == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004838 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004839
Reid Spencer309080a2006-09-28 19:28:24 +00004840 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004841 if ((yyval.InstVal) == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004842 GEN_ERROR("Could not create a xor instruction!");
4843 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004844 ;}
4845 break;
4846
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004847 case 228:
Reid Spencer309080a2006-09-28 19:28:24 +00004848#line 2465 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004849 {
Reid Spencer309080a2006-09-28 19:28:24 +00004850 if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00004851 GEN_ERROR("Shift amount must be ubyte!");
Reid Spencer309080a2006-09-28 19:28:24 +00004852 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
Reid Spencer713eedc2006-08-18 08:43:06 +00004853 GEN_ERROR("Shift constant expression requires integer operand!");
Reid Spencer309080a2006-09-28 19:28:24 +00004854 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004855 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004856 ;}
4857 break;
4858
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004859 case 229:
Reid Spencer309080a2006-09-28 19:28:24 +00004860#line 2473 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004861 {
Reid Spencer309080a2006-09-28 19:28:24 +00004862 if (!(yyvsp[0].TypeVal)->get()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00004863 GEN_ERROR("cast instruction to a non-primitive type: '" +
Reid Spencer309080a2006-09-28 19:28:24 +00004864 (yyvsp[0].TypeVal)->get()->getDescription() + "'!");
4865 (yyval.InstVal) = new CastInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
4866 delete (yyvsp[0].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004867 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004868 ;}
4869 break;
4870
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004871 case 230:
Reid Spencer309080a2006-09-28 19:28:24 +00004872#line 2481 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004873 {
Reid Spencer309080a2006-09-28 19:28:24 +00004874 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00004875 GEN_ERROR("select condition must be boolean!");
Reid Spencer309080a2006-09-28 19:28:24 +00004876 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00004877 GEN_ERROR("select value types should match!");
Reid Spencer309080a2006-09-28 19:28:24 +00004878 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004879 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004880 ;}
4881 break;
4882
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004883 case 231:
Reid Spencer309080a2006-09-28 19:28:24 +00004884#line 2489 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004885 {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004886 NewVarArgs = true;
Reid Spencer309080a2006-09-28 19:28:24 +00004887 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
4888 delete (yyvsp[0].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004889 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004890 ;}
4891 break;
4892
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004893 case 232:
Reid Spencer309080a2006-09-28 19:28:24 +00004894#line 2495 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004895 {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004896 ObsoleteVarArgs = true;
Reid Spencer309080a2006-09-28 19:28:24 +00004897 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004898 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00004899 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004900
4901 //b = vaarg a, t ->
4902 //foo = alloca 1 of t
4903 //bar = vacopy a
4904 //store bar -> foo
4905 //b = vaarg foo, t
4906 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4907 CurBB->getInstList().push_back(foo);
Reid Spencer309080a2006-09-28 19:28:24 +00004908 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004909 CurBB->getInstList().push_back(bar);
4910 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer309080a2006-09-28 19:28:24 +00004911 (yyval.InstVal) = new VAArgInst(foo, *(yyvsp[0].TypeVal));
4912 delete (yyvsp[0].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004913 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004914 ;}
4915 break;
4916
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004917 case 233:
Reid Spencer309080a2006-09-28 19:28:24 +00004918#line 2515 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004919 {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004920 ObsoleteVarArgs = true;
Reid Spencer309080a2006-09-28 19:28:24 +00004921 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004922 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00004923 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004924
4925 //b = vanext a, t ->
4926 //foo = alloca 1 of t
4927 //bar = vacopy a
4928 //store bar -> foo
4929 //tmp = vaarg foo, t
4930 //b = load foo
4931 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4932 CurBB->getInstList().push_back(foo);
Reid Spencer309080a2006-09-28 19:28:24 +00004933 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004934 CurBB->getInstList().push_back(bar);
4935 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer309080a2006-09-28 19:28:24 +00004936 Instruction* tmp = new VAArgInst(foo, *(yyvsp[0].TypeVal));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004937 CurBB->getInstList().push_back(tmp);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004938 (yyval.InstVal) = new LoadInst(foo);
Reid Spencer309080a2006-09-28 19:28:24 +00004939 delete (yyvsp[0].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004940 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004941 ;}
4942 break;
4943
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004944 case 234:
Reid Spencer309080a2006-09-28 19:28:24 +00004945#line 2538 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004946 {
Reid Spencer309080a2006-09-28 19:28:24 +00004947 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer713eedc2006-08-18 08:43:06 +00004948 GEN_ERROR("Invalid extractelement operands!");
Reid Spencer309080a2006-09-28 19:28:24 +00004949 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004950 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004951 ;}
4952 break;
4953
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004954 case 235:
Reid Spencer309080a2006-09-28 19:28:24 +00004955#line 2544 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004956 {
Reid Spencer309080a2006-09-28 19:28:24 +00004957 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer713eedc2006-08-18 08:43:06 +00004958 GEN_ERROR("Invalid insertelement operands!");
Reid Spencer309080a2006-09-28 19:28:24 +00004959 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004960 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004961 ;}
4962 break;
4963
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004964 case 236:
Reid Spencer309080a2006-09-28 19:28:24 +00004965#line 2550 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004966 {
Reid Spencer309080a2006-09-28 19:28:24 +00004967 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer713eedc2006-08-18 08:43:06 +00004968 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencer309080a2006-09-28 19:28:24 +00004969 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00004970 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004971 ;}
4972 break;
4973
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004974 case 237:
Reid Spencer309080a2006-09-28 19:28:24 +00004975#line 2556 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004976 {
Reid Spencer309080a2006-09-28 19:28:24 +00004977 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004978 if (!Ty->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00004979 GEN_ERROR("PHI node operands must be of first class type!");
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004980 (yyval.InstVal) = new PHINode(Ty);
Reid Spencer309080a2006-09-28 19:28:24 +00004981 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
4982 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
4983 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencer713eedc2006-08-18 08:43:06 +00004984 GEN_ERROR("All elements of a PHI node must be of the same type!");
Reid Spencer309080a2006-09-28 19:28:24 +00004985 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
4986 (yyvsp[0].PHIList)->pop_front();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004987 }
Reid Spencer309080a2006-09-28 19:28:24 +00004988 delete (yyvsp[0].PHIList); // Free the list...
Reid Spencer713eedc2006-08-18 08:43:06 +00004989 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004990 ;}
4991 break;
4992
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00004993 case 238:
Reid Spencer309080a2006-09-28 19:28:24 +00004994#line 2571 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004995 {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004996 const PointerType *PFTy;
4997 const FunctionType *Ty;
4998
Reid Spencer309080a2006-09-28 19:28:24 +00004999 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) ||
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005000 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5001 // Pull out the types of all of the arguments...
5002 std::vector<const Type*> ParamTypes;
Reid Spencer309080a2006-09-28 19:28:24 +00005003 if ((yyvsp[-1].ValueList)) {
5004 for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005005 I != E; ++I)
5006 ParamTypes.push_back((*I)->getType());
5007 }
5008
5009 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5010 if (isVarArg) ParamTypes.pop_back();
5011
Reid Spencer309080a2006-09-28 19:28:24 +00005012 if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00005013 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005014
Reid Spencer309080a2006-09-28 19:28:24 +00005015 Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005016 PFTy = PointerType::get(Ty);
5017 }
5018
Reid Spencer309080a2006-09-28 19:28:24 +00005019 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling...
5020 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005021
5022 // Create the call node...
Reid Spencer309080a2006-09-28 19:28:24 +00005023 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005024 // Make sure no arguments is a good thing!
5025 if (Ty->getNumParams() != 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00005026 GEN_ERROR("No arguments passed to a function that "
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005027 "expects arguments!");
5028
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005029 (yyval.InstVal) = new CallInst(V, std::vector<Value*>());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005030 } else { // Has arguments?
5031 // Loop through FunctionType's arguments and ensure they are specified
5032 // correctly!
5033 //
5034 FunctionType::param_iterator I = Ty->param_begin();
5035 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer309080a2006-09-28 19:28:24 +00005036 std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005037
5038 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5039 if ((*ArgI)->getType() != *I)
Reid Spencer713eedc2006-08-18 08:43:06 +00005040 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005041 (*I)->getDescription() + "'!");
5042
5043 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer713eedc2006-08-18 08:43:06 +00005044 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005045
Reid Spencer309080a2006-09-28 19:28:24 +00005046 (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005047 }
Reid Spencer309080a2006-09-28 19:28:24 +00005048 cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal));
5049 cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal));
5050 delete (yyvsp[-4].TypeVal);
5051 delete (yyvsp[-1].ValueList);
Reid Spencer713eedc2006-08-18 08:43:06 +00005052 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005053 ;}
5054 break;
5055
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005056 case 239:
Reid Spencer309080a2006-09-28 19:28:24 +00005057#line 2630 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005058 {
Reid Spencer309080a2006-09-28 19:28:24 +00005059 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00005060 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005061 ;}
5062 break;
5063
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005064 case 240:
Reid Spencer309080a2006-09-28 19:28:24 +00005065#line 2637 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005066 {
Reid Spencer309080a2006-09-28 19:28:24 +00005067 (yyval.ValueList) = (yyvsp[0].ValueList);
Reid Spencer713eedc2006-08-18 08:43:06 +00005068 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005069 ;}
5070 break;
5071
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005072 case 241:
Reid Spencer309080a2006-09-28 19:28:24 +00005073#line 2640 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005074 {
5075 (yyval.ValueList) = new std::vector<Value*>();
Reid Spencer713eedc2006-08-18 08:43:06 +00005076 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005077 ;}
5078 break;
5079
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005080 case 242:
Reid Spencer309080a2006-09-28 19:28:24 +00005081#line 2645 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005082 {
5083 (yyval.BoolVal) = true;
Reid Spencer713eedc2006-08-18 08:43:06 +00005084 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005085 ;}
5086 break;
5087
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005088 case 243:
Reid Spencer309080a2006-09-28 19:28:24 +00005089#line 2649 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005090 {
5091 (yyval.BoolVal) = false;
Reid Spencer713eedc2006-08-18 08:43:06 +00005092 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005093 ;}
5094 break;
5095
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005096 case 244:
Reid Spencer309080a2006-09-28 19:28:24 +00005097#line 2656 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005098 {
Reid Spencer309080a2006-09-28 19:28:24 +00005099 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5100 delete (yyvsp[-1].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00005101 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005102 ;}
5103 break;
5104
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005105 case 245:
Reid Spencer309080a2006-09-28 19:28:24 +00005106#line 2661 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005107 {
Reid Spencer309080a2006-09-28 19:28:24 +00005108 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00005109 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00005110 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5111 delete (yyvsp[-4].TypeVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005112 ;}
5113 break;
5114
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005115 case 246:
Reid Spencer309080a2006-09-28 19:28:24 +00005116#line 2667 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005117 {
Reid Spencer309080a2006-09-28 19:28:24 +00005118 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5119 delete (yyvsp[-1].TypeVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00005120 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005121 ;}
5122 break;
5123
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005124 case 247:
Reid Spencer309080a2006-09-28 19:28:24 +00005125#line 2672 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005126 {
Reid Spencer309080a2006-09-28 19:28:24 +00005127 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00005128 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00005129 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5130 delete (yyvsp[-4].TypeVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005131 ;}
5132 break;
5133
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005134 case 248:
Reid Spencer309080a2006-09-28 19:28:24 +00005135#line 2678 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005136 {
Reid Spencer309080a2006-09-28 19:28:24 +00005137 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Reid Spencer713eedc2006-08-18 08:43:06 +00005138 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer309080a2006-09-28 19:28:24 +00005139 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
5140 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00005141 CHECK_FOR_ERROR
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005142 ;}
5143 break;
5144
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005145 case 249:
Reid Spencer309080a2006-09-28 19:28:24 +00005146#line 2686 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005147 {
Reid Spencer309080a2006-09-28 19:28:24 +00005148 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Reid Spencer713eedc2006-08-18 08:43:06 +00005149 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer309080a2006-09-28 19:28:24 +00005150 (*(yyvsp[-1].TypeVal))->getDescription());
5151 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00005152 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer309080a2006-09-28 19:28:24 +00005153 (*(yyvsp[-1].TypeVal))->getDescription());
5154 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00005155 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00005156 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5157 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005158 ;}
5159 break;
5160
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005161 case 250:
Reid Spencer309080a2006-09-28 19:28:24 +00005162#line 2698 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005163 {
Reid Spencer309080a2006-09-28 19:28:24 +00005164 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005165 if (!PT)
Reid Spencer713eedc2006-08-18 08:43:06 +00005166 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer309080a2006-09-28 19:28:24 +00005167 (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005168 const Type *ElTy = PT->getElementType();
Reid Spencer309080a2006-09-28 19:28:24 +00005169 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5170 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005171 "' into space of type '" + ElTy->getDescription() + "'!");
5172
Reid Spencer309080a2006-09-28 19:28:24 +00005173 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00005174 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00005175 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5176 delete (yyvsp[-1].TypeVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005177 ;}
5178 break;
5179
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00005180 case 251:
Reid Spencer309080a2006-09-28 19:28:24 +00005181#line 2713 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005182 {
Reid Spencer309080a2006-09-28 19:28:24 +00005183 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencer713eedc2006-08-18 08:43:06 +00005184 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005185
5186 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
5187 // indices to uint struct indices for compatibility.
5188 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer309080a2006-09-28 19:28:24 +00005189 GTI = gep_type_begin((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()),
5190 GTE = gep_type_end((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end());
5191 for (unsigned i = 0, e = (yyvsp[0].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005192 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer309080a2006-09-28 19:28:24 +00005193 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*(yyvsp[0].ValueList))[i]))
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005194 if (CUI->getType() == Type::UByteTy)
Reid Spencer309080a2006-09-28 19:28:24 +00005195 (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005196
Reid Spencer309080a2006-09-28 19:28:24 +00005197 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
Reid Spencer713eedc2006-08-18 08:43:06 +00005198 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer309080a2006-09-28 19:28:24 +00005199 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
5200 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer713eedc2006-08-18 08:43:06 +00005201 CHECK_FOR_ERROR
Reid Spencer309080a2006-09-28 19:28:24 +00005202 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
5203 delete (yyvsp[-2].TypeVal);
5204 delete (yyvsp[0].ValueList);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005205 ;}
5206 break;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005207
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005208
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005209 default: break;
Chris Lattner680aab62006-08-18 17:34:45 +00005210 }
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005211
Reid Spencer309080a2006-09-28 19:28:24 +00005212/* Line 1126 of yacc.c. */
5213#line 5214 "llvmAsmParser.tab.c"
5214
5215 yyvsp -= yylen;
5216 yyssp -= yylen;
5217
5218
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005219 YY_STACK_PRINT (yyss, yyssp);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005220
5221 *++yyvsp = yyval;
5222
5223
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005224 /* Now `shift' the result of the reduction. Determine what state
5225 that goes to, based on the state we popped back to and the rule
5226 number reduced by. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005227
5228 yyn = yyr1[yyn];
5229
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005230 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5231 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005232 yystate = yytable[yystate];
5233 else
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005234 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005235
5236 goto yynewstate;
5237
5238
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005239/*------------------------------------.
5240| yyerrlab -- here on detecting error |
5241`------------------------------------*/
5242yyerrlab:
5243 /* If not already recovering from an error, report this error. */
5244 if (!yyerrstatus)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005245 {
5246 ++yynerrs;
Reid Spencer309080a2006-09-28 19:28:24 +00005247#if YYERROR_VERBOSE
5248 yyn = yypact[yystate];
Chris Lattner680aab62006-08-18 17:34:45 +00005249
Reid Spencer309080a2006-09-28 19:28:24 +00005250 if (YYPACT_NINF < yyn && yyn < YYLAST)
5251 {
5252 int yytype = YYTRANSLATE (yychar);
5253 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5254 YYSIZE_T yysize = yysize0;
5255 YYSIZE_T yysize1;
5256 int yysize_overflow = 0;
5257 char *yymsg = 0;
5258# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5259 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5260 int yyx;
5261
5262#if 0
5263 /* This is so xgettext sees the translatable formats that are
5264 constructed on the fly. */
5265 YY_("syntax error, unexpected %s");
5266 YY_("syntax error, unexpected %s, expecting %s");
5267 YY_("syntax error, unexpected %s, expecting %s or %s");
5268 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5269 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005270#endif
Reid Spencer309080a2006-09-28 19:28:24 +00005271 char *yyfmt;
5272 char const *yyf;
5273 static char const yyunexpected[] = "syntax error, unexpected %s";
5274 static char const yyexpecting[] = ", expecting %s";
5275 static char const yyor[] = " or %s";
5276 char yyformat[sizeof yyunexpected
5277 + sizeof yyexpecting - 1
5278 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5279 * (sizeof yyor - 1))];
5280 char const *yyprefix = yyexpecting;
5281
5282 /* Start YYX at -YYN if negative to avoid negative indexes in
5283 YYCHECK. */
5284 int yyxbegin = yyn < 0 ? -yyn : 0;
5285
5286 /* Stay within bounds of both yycheck and yytname. */
5287 int yychecklim = YYLAST - yyn;
5288 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5289 int yycount = 1;
5290
5291 yyarg[0] = yytname[yytype];
5292 yyfmt = yystpcpy (yyformat, yyunexpected);
5293
5294 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5295 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5296 {
5297 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5298 {
5299 yycount = 1;
5300 yysize = yysize0;
5301 yyformat[sizeof yyunexpected - 1] = '\0';
5302 break;
5303 }
5304 yyarg[yycount++] = yytname[yyx];
5305 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5306 yysize_overflow |= yysize1 < yysize;
5307 yysize = yysize1;
5308 yyfmt = yystpcpy (yyfmt, yyprefix);
5309 yyprefix = yyor;
5310 }
5311
5312 yyf = YY_(yyformat);
5313 yysize1 = yysize + yystrlen (yyf);
5314 yysize_overflow |= yysize1 < yysize;
5315 yysize = yysize1;
5316
5317 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5318 yymsg = (char *) YYSTACK_ALLOC (yysize);
5319 if (yymsg)
5320 {
5321 /* Avoid sprintf, as that infringes on the user's name space.
5322 Don't have undefined behavior even if the translation
5323 produced a string with the wrong number of "%s"s. */
5324 char *yyp = yymsg;
5325 int yyi = 0;
5326 while ((*yyp = *yyf))
5327 {
5328 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5329 {
5330 yyp += yytnamerr (yyp, yyarg[yyi++]);
5331 yyf += 2;
5332 }
5333 else
5334 {
5335 yyp++;
5336 yyf++;
5337 }
5338 }
5339 yyerror (yymsg);
5340 YYSTACK_FREE (yymsg);
5341 }
5342 else
5343 {
5344 yyerror (YY_("syntax error"));
5345 goto yyexhaustedlab;
5346 }
5347 }
5348 else
5349#endif /* YYERROR_VERBOSE */
5350 yyerror (YY_("syntax error"));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005351 }
5352
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005353
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005354
5355 if (yyerrstatus == 3)
5356 {
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005357 /* If just tried and failed to reuse look-ahead token after an
5358 error, discard it. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005359
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005360 if (yychar <= YYEOF)
Reid Spencer309080a2006-09-28 19:28:24 +00005361 {
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005362 /* Return failure if at end of input. */
5363 if (yychar == YYEOF)
5364 YYABORT;
Reid Spencer309080a2006-09-28 19:28:24 +00005365 }
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005366 else
5367 {
Reid Spencer309080a2006-09-28 19:28:24 +00005368 yydestruct ("Error: discarding", yytoken, &yylval);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005369 yychar = YYEMPTY;
5370 }
5371 }
5372
5373 /* Else will try to reuse look-ahead token after shifting the error
5374 token. */
5375 goto yyerrlab1;
5376
5377
5378/*---------------------------------------------------.
5379| yyerrorlab -- error raised explicitly by YYERROR. |
5380`---------------------------------------------------*/
5381yyerrorlab:
5382
5383 /* Pacify compilers like GCC when the user code never invokes
5384 YYERROR and the label yyerrorlab therefore never appears in user
5385 code. */
Reid Spencer309080a2006-09-28 19:28:24 +00005386 if (0)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005387 goto yyerrorlab;
5388
Reid Spencer309080a2006-09-28 19:28:24 +00005389yyvsp -= yylen;
5390 yyssp -= yylen;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005391 yystate = *yyssp;
5392 goto yyerrlab1;
5393
5394
5395/*-------------------------------------------------------------.
5396| yyerrlab1 -- common code for both syntax error and YYERROR. |
5397`-------------------------------------------------------------*/
5398yyerrlab1:
5399 yyerrstatus = 3; /* Each real token shifted decrements this. */
5400
5401 for (;;)
5402 {
5403 yyn = yypact[yystate];
5404 if (yyn != YYPACT_NINF)
5405 {
5406 yyn += YYTERROR;
5407 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5408 {
5409 yyn = yytable[yyn];
5410 if (0 < yyn)
5411 break;
5412 }
5413 }
5414
5415 /* Pop the current state because it cannot handle the error token. */
5416 if (yyssp == yyss)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005417 YYABORT;
5418
Chris Lattneredd9b032006-01-23 23:05:42 +00005419
Reid Spencer309080a2006-09-28 19:28:24 +00005420 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5421 YYPOPSTACK;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005422 yystate = *yyssp;
5423 YY_STACK_PRINT (yyss, yyssp);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005424 }
5425
5426 if (yyn == YYFINAL)
5427 YYACCEPT;
5428
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005429 *++yyvsp = yylval;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005430
5431
Reid Spencer309080a2006-09-28 19:28:24 +00005432 /* Shift the error token. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005433 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005434
5435 yystate = yyn;
5436 goto yynewstate;
5437
Chris Lattner680aab62006-08-18 17:34:45 +00005438
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005439/*-------------------------------------.
5440| yyacceptlab -- YYACCEPT comes here. |
5441`-------------------------------------*/
5442yyacceptlab:
5443 yyresult = 0;
5444 goto yyreturn;
5445
5446/*-----------------------------------.
5447| yyabortlab -- YYABORT comes here. |
5448`-----------------------------------*/
5449yyabortlab:
5450 yyresult = 1;
5451 goto yyreturn;
5452
5453#ifndef yyoverflow
5454/*-------------------------------------------------.
5455| yyexhaustedlab -- memory exhaustion comes here. |
5456`-------------------------------------------------*/
5457yyexhaustedlab:
5458 yyerror (YY_("memory exhausted"));
5459 yyresult = 2;
5460 /* Fall through. */
Chris Lattner680aab62006-08-18 17:34:45 +00005461#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005462
5463yyreturn:
5464 if (yychar != YYEOF && yychar != YYEMPTY)
5465 yydestruct ("Cleanup: discarding lookahead",
5466 yytoken, &yylval);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005467 while (yyssp != yyss)
5468 {
5469 yydestruct ("Cleanup: popping",
5470 yystos[*yyssp], yyvsp);
Reid Spencer309080a2006-09-28 19:28:24 +00005471 YYPOPSTACK;
Chris Lattner680aab62006-08-18 17:34:45 +00005472 }
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005473#ifndef yyoverflow
5474 if (yyss != yyssa)
5475 YYSTACK_FREE (yyss);
5476#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005477 return yyresult;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005478}
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005479
5480
Reid Spencer309080a2006-09-28 19:28:24 +00005481#line 2739 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer713eedc2006-08-18 08:43:06 +00005482
5483
5484void llvm::GenerateError(const std::string &message, int LineNo) {
5485 if (LineNo == -1) LineNo = llvmAsmlineno;
5486 // TODO: column number in exception
5487 if (TheParseError)
5488 TheParseError->setError(CurFilename, message, LineNo);
5489 TriggerError = 1;
5490}
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005491
5492int yyerror(const char *ErrorMsg) {
5493 std::string where
5494 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5495 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5496 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5497 if (yychar == YYEMPTY || yychar == 0)
5498 errMsg += "end-of-file.";
5499 else
5500 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer713eedc2006-08-18 08:43:06 +00005501 GenerateError(errMsg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00005502 return 0;
5503}
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00005504