blob: c5774e146ba87f49ce5b86cefae917b02714728c [file] [log] [blame]
Reid Spencer3822ff52006-11-08 06:47:33 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer3822ff52006-11-08 06:47:33 +00003/* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Reid Spencer68a24bd2005-08-27 18:50:39 +00005
Reid Spencer3822ff52006-11-08 06:47:33 +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.
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +000010
Reid Spencer3822ff52006-11-08 06:47:33 +000011 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Bison version. */
40#define YYBISON_VERSION "2.1"
41
42/* Skeleton name. */
43#define YYSKELETON_NAME "yacc.c"
44
45/* Pure parsers. */
46#define YYPURE 0
47
48/* Using locations. */
49#define YYLSP_NEEDED 0
50
51/* Substitute the variable and function names. */
Reid Spencer68a24bd2005-08-27 18:50:39 +000052#define yyparse llvmAsmparse
Reid Spencer3822ff52006-11-08 06:47:33 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer3822ff52006-11-08 06:47:33 +000055#define yylval llvmAsmlval
56#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000057#define yydebug llvmAsmdebug
58#define yynerrs llvmAsmnerrs
59
Reid Spencer3822ff52006-11-08 06:47:33 +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,
133 X86_STDCALLCC_TOK = 324,
134 X86_FASTCALLCC_TOK = 325,
135 DATALAYOUT = 326,
136 RET = 327,
137 BR = 328,
138 SWITCH = 329,
139 INVOKE = 330,
140 UNWIND = 331,
141 UNREACHABLE = 332,
142 ADD = 333,
143 SUB = 334,
144 MUL = 335,
145 UDIV = 336,
146 SDIV = 337,
147 FDIV = 338,
148 UREM = 339,
149 SREM = 340,
150 FREM = 341,
151 AND = 342,
152 OR = 343,
153 XOR = 344,
154 SETLE = 345,
155 SETGE = 346,
156 SETLT = 347,
157 SETGT = 348,
158 SETEQ = 349,
159 SETNE = 350,
160 MALLOC = 351,
161 ALLOCA = 352,
162 FREE = 353,
163 LOAD = 354,
164 STORE = 355,
165 GETELEMENTPTR = 356,
Reid Spencer3da59db2006-11-27 01:05:10 +0000166 TRUNC = 357,
167 ZEXT = 358,
168 SEXT = 359,
169 FPTRUNC = 360,
170 FPEXT = 361,
171 BITCAST = 362,
172 UITOFP = 363,
173 SITOFP = 364,
174 FPTOUI = 365,
175 FPTOSI = 366,
176 INTTOPTR = 367,
177 PTRTOINT = 368,
178 PHI_TOK = 369,
179 SELECT = 370,
180 SHL = 371,
181 LSHR = 372,
182 ASHR = 373,
183 VAARG = 374,
184 EXTRACTELEMENT = 375,
185 INSERTELEMENT = 376,
186 SHUFFLEVECTOR = 377,
187 VAARG_old = 378,
188 VANEXT_old = 379
Reid Spencer3822ff52006-11-08 06:47:33 +0000189 };
190#endif
191/* Tokens. */
192#define ESINT64VAL 258
193#define EUINT64VAL 259
194#define SINTVAL 260
195#define UINTVAL 261
196#define FPVAL 262
197#define VOID 263
198#define BOOL 264
199#define SBYTE 265
200#define UBYTE 266
201#define SHORT 267
202#define USHORT 268
203#define INT 269
204#define UINT 270
205#define LONG 271
206#define ULONG 272
207#define FLOAT 273
208#define DOUBLE 274
209#define TYPE 275
210#define LABEL 276
211#define VAR_ID 277
212#define LABELSTR 278
213#define STRINGCONSTANT 279
214#define IMPLEMENTATION 280
215#define ZEROINITIALIZER 281
216#define TRUETOK 282
217#define FALSETOK 283
218#define BEGINTOK 284
219#define ENDTOK 285
220#define DECLARE 286
221#define GLOBAL 287
222#define CONSTANT 288
223#define SECTION 289
224#define VOLATILE 290
225#define TO 291
226#define DOTDOTDOT 292
227#define NULL_TOK 293
228#define UNDEF 294
229#define CONST 295
230#define INTERNAL 296
231#define LINKONCE 297
232#define WEAK 298
233#define APPENDING 299
234#define DLLIMPORT 300
235#define DLLEXPORT 301
236#define EXTERN_WEAK 302
237#define OPAQUE 303
238#define NOT 304
239#define EXTERNAL 305
240#define TARGET 306
241#define TRIPLE 307
242#define ENDIAN 308
243#define POINTERSIZE 309
244#define LITTLE 310
245#define BIG 311
246#define ALIGN 312
247#define DEPLIBS 313
248#define CALL 314
249#define TAIL 315
250#define ASM_TOK 316
251#define MODULE 317
252#define SIDEEFFECT 318
253#define CC_TOK 319
254#define CCC_TOK 320
255#define CSRETCC_TOK 321
256#define FASTCC_TOK 322
257#define COLDCC_TOK 323
258#define X86_STDCALLCC_TOK 324
259#define X86_FASTCALLCC_TOK 325
260#define DATALAYOUT 326
261#define RET 327
262#define BR 328
263#define SWITCH 329
264#define INVOKE 330
265#define UNWIND 331
266#define UNREACHABLE 332
267#define ADD 333
268#define SUB 334
269#define MUL 335
270#define UDIV 336
271#define SDIV 337
272#define FDIV 338
273#define UREM 339
274#define SREM 340
275#define FREM 341
276#define AND 342
277#define OR 343
278#define XOR 344
279#define SETLE 345
280#define SETGE 346
281#define SETLT 347
282#define SETGT 348
283#define SETEQ 349
284#define SETNE 350
285#define MALLOC 351
286#define ALLOCA 352
287#define FREE 353
288#define LOAD 354
289#define STORE 355
290#define GETELEMENTPTR 356
Reid Spencer3da59db2006-11-27 01:05:10 +0000291#define TRUNC 357
292#define ZEXT 358
293#define SEXT 359
294#define FPTRUNC 360
295#define FPEXT 361
296#define BITCAST 362
297#define UITOFP 363
298#define SITOFP 364
299#define FPTOUI 365
300#define FPTOSI 366
301#define INTTOPTR 367
302#define PTRTOINT 368
303#define PHI_TOK 369
304#define SELECT 370
305#define SHL 371
306#define LSHR 372
307#define ASHR 373
308#define VAARG 374
309#define EXTRACTELEMENT 375
310#define INSERTELEMENT 376
311#define SHUFFLEVECTOR 377
312#define VAARG_old 378
313#define VANEXT_old 379
Reid Spencer3822ff52006-11-08 06:47:33 +0000314
315
316
317
318/* Copy the first part of user declarations. */
Reid Spencer3da59db2006-11-27 01:05:10 +0000319#line 14 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000320
321#include "ParserInternals.h"
322#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000323#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000324#include "llvm/Instructions.h"
325#include "llvm/Module.h"
326#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000327#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000328#include "llvm/Support/GetElementPtrTypeIterator.h"
329#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000330#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000331#include <algorithm>
332#include <iostream>
333#include <list>
334#include <utility>
335
Reid Spencere4f47592006-08-18 17:32:55 +0000336// The following is a gross hack. In order to rid the libAsmParser library of
337// exceptions, we have to have a way of getting the yyparse function to go into
338// an error situation. So, whenever we want an error to occur, the GenerateError
339// function (see bottom of file) sets TriggerError. Then, at the end of each
340// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
341// (a goto) to put YACC in error state. Furthermore, several calls to
342// GenerateError are made from inside productions and they must simulate the
343// previous exception behavior by exiting the production immediately. We have
344// replaced these with the GEN_ERROR macro which calls GeneratError and then
345// immediately invokes YYERROR. This would be so much cleaner if it was a
346// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000347static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000348#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000349#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
350
Reid Spencer68a24bd2005-08-27 18:50:39 +0000351int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
352int yylex(); // declaration" of xxx warnings.
353int yyparse();
354
355namespace llvm {
356 std::string CurFilename;
357}
358using namespace llvm;
359
360static Module *ParserResult;
361
362// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
363// relating to upreferences in the input stream.
364//
365//#define DEBUG_UPREFS 1
366#ifdef DEBUG_UPREFS
367#define UR_OUT(X) std::cerr << X
368#else
369#define UR_OUT(X)
370#endif
371
372#define YYERROR_VERBOSE 1
373
374static bool ObsoleteVarArgs;
375static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000376static BasicBlock *CurBB;
377static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000378
379
380// This contains info used when building the body of a function. It is
381// destroyed when the function is completed.
382//
383typedef std::vector<Value *> ValueList; // Numbered defs
384static void
385ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
386 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
387
388static struct PerModuleInfo {
389 Module *CurrentModule;
390 std::map<const Type *, ValueList> Values; // Module level numbered definitions
391 std::map<const Type *,ValueList> LateResolveValues;
Reid Spencer3da59db2006-11-27 01:05:10 +0000392 std::vector<TypeInfo> Types;
393 std::map<ValID, TypeInfo> LateResolveTypes;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000394
395 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000396 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000397 /// that we can resolve them later and print error messages as appropriate.
398 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
399
400 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
401 // references to global values. Global values may be referenced before they
402 // are defined, and if so, the temporary object that they represent is held
403 // here. This is used for forward references of GlobalValues.
404 //
405 typedef std::map<std::pair<const PointerType *,
406 ValID>, GlobalValue*> GlobalRefsType;
407 GlobalRefsType GlobalRefs;
408
409 void ModuleDone() {
410 // If we could not resolve some functions at function compilation time
411 // (calls to functions before they are defined), resolve them now... Types
412 // are resolved when the constant pool has been completely parsed.
413 //
414 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000415 if (TriggerError)
416 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000417
418 // Check to make sure that all global value forward references have been
419 // resolved!
420 //
421 if (!GlobalRefs.empty()) {
422 std::string UndefinedReferences = "Unresolved global references exist:\n";
423
424 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
425 I != E; ++I) {
426 UndefinedReferences += " " + I->first.first->getDescription() + " " +
427 I->first.second.getName() + "\n";
428 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000429 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000430 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000431 }
432
Reid Spencere812fb22006-01-19 01:21:04 +0000433 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattnerd5efe842006-04-08 01:18:56 +0000434 for (Module::iterator FI = CurrentModule->begin(),
435 FE = CurrentModule->end(); FI != FE; )
Chris Lattnerc2c60382006-03-04 07:53:41 +0000436 UpgradeCallsToIntrinsic(FI++);
Reid Spencer0b118202006-01-16 21:12:35 +0000437
Reid Spencer68a24bd2005-08-27 18:50:39 +0000438 Values.clear(); // Clear out function local definitions
439 Types.clear();
440 CurrentModule = 0;
441 }
442
Reid Spencer68a24bd2005-08-27 18:50:39 +0000443 // GetForwardRefForGlobal - Check to see if there is a forward reference
444 // for this global. If so, remove it from the GlobalRefs map and return it.
445 // If not, just return null.
446 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
447 // Check to see if there is a forward reference to this global variable...
448 // if there is, eliminate it and patch the reference to use the new def'n.
449 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
450 GlobalValue *Ret = 0;
451 if (I != GlobalRefs.end()) {
452 Ret = I->second;
453 GlobalRefs.erase(I);
454 }
455 return Ret;
456 }
457} CurModule;
458
459static struct PerFunctionInfo {
460 Function *CurrentFunction; // Pointer to current function being created
461
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000462 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000463 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000464 bool isDeclare; // Is this function a forward declararation?
465 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000466
467 /// BBForwardRefs - When we see forward references to basic blocks, keep
468 /// track of them here.
469 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
470 std::vector<BasicBlock*> NumberedBlocks;
471 unsigned NextBBNum;
472
473 inline PerFunctionInfo() {
474 CurrentFunction = 0;
475 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000476 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000477 }
478
479 inline void FunctionStart(Function *M) {
480 CurrentFunction = M;
481 NextBBNum = 0;
482 }
483
484 void FunctionDone() {
485 NumberedBlocks.clear();
486
487 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000488 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000489 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000490 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000491 return;
492 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000493
494 // Resolve all forward references now.
495 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
496
497 Values.clear(); // Clear out function local definitions
498 CurrentFunction = 0;
499 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000500 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000501 }
502} CurFun; // Info for the current function...
503
504static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
505
506
507//===----------------------------------------------------------------------===//
508// Code to handle definitions of all the types
509//===----------------------------------------------------------------------===//
510
511static int InsertValue(Value *V,
512 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
513 if (V->hasName()) return -1; // Is this a numbered definition?
514
515 // Yes, insert the value into the value table...
516 ValueList &List = ValueTab[V->getType()];
517 List.push_back(V);
518 return List.size()-1;
519}
520
521static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
522 switch (D.Type) {
523 case ValID::NumberVal: // Is it a numbered definition?
524 // Module constants occupy the lowest numbered slots...
525 if ((unsigned)D.Num < CurModule.Types.size())
Reid Spencer3da59db2006-11-27 01:05:10 +0000526 return CurModule.Types[(unsigned)D.Num].type->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000527 break;
528 case ValID::NameVal: // Is it a named definition?
529 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
530 D.destroy(); // Free old strdup'd memory...
531 return N;
532 }
533 break;
534 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000535 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000536 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000537 }
538
539 // If we reached here, we referenced either a symbol that we don't know about
540 // or an id number that hasn't been read yet. We may be referencing something
541 // forward, so just create an entry to be resolved later and get to it...
542 //
543 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
544
545
546 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000547 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000548 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000549 return 0;
550 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000551 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000552 return 0;
553 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000554 }
555
Reid Spencer3da59db2006-11-27 01:05:10 +0000556 std::map<ValID, TypeInfo>::iterator I =CurModule.LateResolveTypes.find(D);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000557 if (I != CurModule.LateResolveTypes.end())
Reid Spencer3da59db2006-11-27 01:05:10 +0000558 return I->second.type->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000559
Reid Spencer3da59db2006-11-27 01:05:10 +0000560 TypeInfo TI;
561 TI.type = new PATypeHolder(OpaqueType::get());
562 TI.signedness = isSignless;
563 CurModule.LateResolveTypes.insert(std::make_pair(D, TI));
564 return TI.type->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +0000565 }
566
567static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
568 SymbolTable &SymTab =
569 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
570 CurModule.CurrentModule->getSymbolTable();
571 return SymTab.lookup(Ty, Name);
572}
573
574// getValNonImprovising - Look up the value specified by the provided type and
575// the provided ValID. If the value exists and has already been defined, return
576// it. Otherwise return null.
577//
578static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000579 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000580 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000581 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000582 return 0;
583 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000584
585 switch (D.Type) {
586 case ValID::NumberVal: { // Is it a numbered definition?
587 unsigned Num = (unsigned)D.Num;
588
589 // Module constants occupy the lowest numbered slots...
590 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
591 if (VI != CurModule.Values.end()) {
592 if (Num < VI->second.size())
593 return VI->second[Num];
594 Num -= VI->second.size();
595 }
596
597 // Make sure that our type is within bounds
598 VI = CurFun.Values.find(Ty);
599 if (VI == CurFun.Values.end()) return 0;
600
601 // Check that the number is within bounds...
602 if (VI->second.size() <= Num) return 0;
603
604 return VI->second[Num];
605 }
606
607 case ValID::NameVal: { // Is it a named definition?
608 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
609 if (N == 0) return 0;
610
611 D.destroy(); // Free old strdup'd memory...
612 return N;
613 }
614
615 // Check to make sure that "Ty" is an integral type, and that our
616 // value will fit into the specified type...
617 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000618 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000619 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000620 itostr(D.ConstPool64) + "' is invalid for type '" +
621 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000622 return 0;
623 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000624 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000625
626 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000627 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
628 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000629 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000630 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000631 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000632 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000633 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000634 }
635 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000636 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000637 }
638
639 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000640 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000641 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000642 return 0;
643 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000644 return ConstantFP::get(Ty, D.ConstPoolFP);
645
646 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000647 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000648 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000649 return 0;
650 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000651 return ConstantPointerNull::get(cast<PointerType>(Ty));
652
653 case ValID::ConstUndefVal: // Is it an undef value?
654 return UndefValue::get(Ty);
655
Chris Lattner7aa61892005-12-21 17:53:23 +0000656 case ValID::ConstZeroVal: // Is it a zero value?
657 return Constant::getNullValue(Ty);
658
Reid Spencer68a24bd2005-08-27 18:50:39 +0000659 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000660 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000661 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000662 return 0;
663 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000664 return D.ConstantValue;
665
Chris Lattner0e9c3762006-01-25 22:27:16 +0000666 case ValID::InlineAsmVal: { // Inline asm expression
667 const PointerType *PTy = dyn_cast<PointerType>(Ty);
668 const FunctionType *FTy =
669 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000670 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000671 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000672 return 0;
673 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000674 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
675 D.IAD->HasSideEffects);
676 D.destroy(); // Free InlineAsmDescriptor.
677 return IA;
678 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000679 default:
680 assert(0 && "Unhandled case!");
681 return 0;
682 } // End of switch
683
684 assert(0 && "Unhandled case!");
685 return 0;
686}
687
688// getVal - This function is identical to getValNonImprovising, except that if a
689// value is not already defined, it "improvises" by creating a placeholder var
690// that looks and acts just like the requested variable. When the value is
691// defined later, all uses of the placeholder variable are replaced with the
692// real thing.
693//
694static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000695 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000696 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000697 return 0;
698 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000699
700 // See if the value has already been defined.
701 Value *V = getValNonImprovising(Ty, ID);
702 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000703 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000704
Reid Spencer5b7e7532006-09-28 19:28:24 +0000705 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000706 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000707 return 0;
708 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000709
710 // If we reached here, we referenced either a symbol that we don't know about
711 // or an id number that hasn't been read yet. We may be referencing something
712 // forward, so just create an entry to be resolved later and get to it...
713 //
714 V = new Argument(Ty);
715
716 // Remember where this forward reference came from. FIXME, shouldn't we try
717 // to recycle these things??
718 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
719 llvmAsmlineno)));
720
721 if (inFunctionScope())
722 InsertValue(V, CurFun.LateResolveValues);
723 else
724 InsertValue(V, CurModule.LateResolveValues);
725 return V;
726}
727
728/// getBBVal - This is used for two purposes:
729/// * If isDefinition is true, a new basic block with the specified ID is being
730/// defined.
731/// * If isDefinition is true, this is a reference to a basic block, which may
732/// or may not be a forward reference.
733///
734static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
735 assert(inFunctionScope() && "Can't get basic block at global scope!");
736
737 std::string Name;
738 BasicBlock *BB = 0;
739 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000740 default:
741 GenerateError("Illegal label reference " + ID.getName());
742 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000743 case ValID::NumberVal: // Is it a numbered definition?
744 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
745 CurFun.NumberedBlocks.resize(ID.Num+1);
746 BB = CurFun.NumberedBlocks[ID.Num];
747 break;
748 case ValID::NameVal: // Is it a named definition?
749 Name = ID.Name;
750 if (Value *N = CurFun.CurrentFunction->
751 getSymbolTable().lookup(Type::LabelTy, Name))
752 BB = cast<BasicBlock>(N);
753 break;
754 }
755
756 // See if the block has already been defined.
757 if (BB) {
758 // If this is the definition of the block, make sure the existing value was
759 // just a forward reference. If it was a forward reference, there will be
760 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000761 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000762 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000763 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000764 return 0;
765 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000766
767 ID.destroy(); // Free strdup'd memory.
768 return BB;
769 }
770
771 // Otherwise this block has not been seen before.
772 BB = new BasicBlock("", CurFun.CurrentFunction);
773 if (ID.Type == ValID::NameVal) {
774 BB->setName(ID.Name);
775 } else {
776 CurFun.NumberedBlocks[ID.Num] = BB;
777 }
778
779 // If this is not a definition, keep track of it so we can use it as a forward
780 // reference.
781 if (!isDefinition) {
782 // Remember where this forward reference came from.
783 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
784 } else {
785 // The forward declaration could have been inserted anywhere in the
786 // function: insert it into the correct place now.
787 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
788 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
789 }
790 ID.destroy();
791 return BB;
792}
793
794
795//===----------------------------------------------------------------------===//
796// Code to handle forward references in instructions
797//===----------------------------------------------------------------------===//
798//
799// This code handles the late binding needed with statements that reference
800// values not defined yet... for example, a forward branch, or the PHI node for
801// a loop body.
802//
803// This keeps a table (CurFun.LateResolveValues) of all such forward references
804// and back patchs after we are done.
805//
806
807// ResolveDefinitions - If we could not resolve some defs at parsing
808// time (forward branches, phi functions for loops, etc...) resolve the
809// defs now...
810//
811static void
812ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
813 std::map<const Type*,ValueList> *FutureLateResolvers) {
814 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
815 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
816 E = LateResolvers.end(); LRI != E; ++LRI) {
817 ValueList &List = LRI->second;
818 while (!List.empty()) {
819 Value *V = List.back();
820 List.pop_back();
821
822 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
823 CurModule.PlaceHolderInfo.find(V);
824 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
825
826 ValID &DID = PHI->second.first;
827
828 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000829 if (TriggerError)
830 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000831 if (TheRealValue) {
832 V->replaceAllUsesWith(TheRealValue);
833 delete V;
834 CurModule.PlaceHolderInfo.erase(PHI);
835 } else if (FutureLateResolvers) {
836 // Functions have their unresolved items forwarded to the module late
837 // resolver table
838 InsertValue(V, *FutureLateResolvers);
839 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000840 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000841 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000842 "' of type '" + V->getType()->getDescription() + "'",
843 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000844 return;
845 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000846 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000847 itostr(DID.Num) + " of type '" +
848 V->getType()->getDescription() + "'",
849 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000850 return;
851 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000852 }
853 }
854 }
855
856 LateResolvers.clear();
857}
858
859// ResolveTypeTo - A brand new type was just declared. This means that (if
860// name is not null) things referencing Name can be resolved. Otherwise, things
861// refering to the number can be resolved. Do this now.
862//
863static void ResolveTypeTo(char *Name, const Type *ToTy) {
864 ValID D;
865 if (Name) D = ValID::create(Name);
866 else D = ValID::create((int)CurModule.Types.size());
867
Reid Spencer3da59db2006-11-27 01:05:10 +0000868 std::map<ValID, TypeInfo>::iterator I =
Reid Spencer68a24bd2005-08-27 18:50:39 +0000869 CurModule.LateResolveTypes.find(D);
870 if (I != CurModule.LateResolveTypes.end()) {
Reid Spencer3da59db2006-11-27 01:05:10 +0000871 ((DerivedType*)I->second.type->get())->refineAbstractTypeTo(ToTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000872 CurModule.LateResolveTypes.erase(I);
873 }
874}
875
876// setValueName - Set the specified value to the name given. The name may be
877// null potentially, in which case this is a noop. The string passed in is
878// assumed to be a malloc'd string buffer, and is free'd by this function.
879//
880static void setValueName(Value *V, char *NameStr) {
881 if (NameStr) {
882 std::string Name(NameStr); // Copy string
883 free(NameStr); // Free old string
884
Reid Spencer5b7e7532006-09-28 19:28:24 +0000885 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000886 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000887 return;
888 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000889
890 assert(inFunctionScope() && "Must be in function scope!");
891 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000892 if (ST.lookup(V->getType(), Name)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000893 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000894 V->getType()->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000895 return;
896 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000897
898 // Set the name.
899 V->setName(Name);
900 }
901}
902
903/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
904/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000905static GlobalVariable *
906ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
907 bool isConstantGlobal, const Type *Ty,
908 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000909 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000910 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000911 return 0;
912 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000913
914 const PointerType *PTy = PointerType::get(Ty);
915
916 std::string Name;
917 if (NameStr) {
918 Name = NameStr; // Copy string
919 free(NameStr); // Free old string
920 }
921
922 // See if this global value was forward referenced. If so, recycle the
923 // object.
924 ValID ID;
925 if (!Name.empty()) {
926 ID = ValID::create((char*)Name.c_str());
927 } else {
928 ID = ValID::create((int)CurModule.Values[PTy].size());
929 }
930
931 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
932 // Move the global to the end of the list, from whereever it was
933 // previously inserted.
934 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
935 CurModule.CurrentModule->getGlobalList().remove(GV);
936 CurModule.CurrentModule->getGlobalList().push_back(GV);
937 GV->setInitializer(Initializer);
938 GV->setLinkage(Linkage);
939 GV->setConstant(isConstantGlobal);
940 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000941 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000942 }
943
944 // If this global has a name, check to see if there is already a definition
945 // of this global in the module. If so, merge as appropriate. Note that
946 // this is really just a hack around problems in the CFE. :(
947 if (!Name.empty()) {
948 // We are a simple redefinition of a value, check to see if it is defined
949 // the same as the old one.
950 if (GlobalVariable *EGV =
951 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
952 // We are allowed to redefine a global variable in two circumstances:
953 // 1. If at least one of the globals is uninitialized or
954 // 2. If both initializers have the same value.
955 //
956 if (!EGV->hasInitializer() || !Initializer ||
957 EGV->getInitializer() == Initializer) {
958
959 // Make sure the existing global version gets the initializer! Make
960 // sure that it also gets marked const if the new version is.
961 if (Initializer && !EGV->hasInitializer())
962 EGV->setInitializer(Initializer);
963 if (isConstantGlobal)
964 EGV->setConstant(true);
965 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000966 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000967 }
968
Reid Spencer61c83e02006-08-18 08:43:06 +0000969 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000970 "' in the '" + Ty->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000971 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000972 }
973 }
974
975 // Otherwise there is no existing GV to use, create one now.
976 GlobalVariable *GV =
977 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
978 CurModule.CurrentModule);
979 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000980 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000981}
982
983// setTypeName - Set the specified type to the name given. The name may be
984// null potentially, in which case this is a noop. The string passed in is
985// assumed to be a malloc'd string buffer, and is freed by this function.
986//
987// This function returns true if the type has already been defined, but is
988// allowed to be redefined in the specified context. If the name is a new name
989// for the type plane, it is inserted and false is returned.
990static bool setTypeName(const Type *T, char *NameStr) {
991 assert(!inFunctionScope() && "Can't give types function-local names!");
992 if (NameStr == 0) return false;
993
994 std::string Name(NameStr); // Copy string
995 free(NameStr); // Free old string
996
997 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000998 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000999 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001000 return false;
1001 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001002
1003 // Set the type name, checking for conflicts as we do so.
1004 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
1005
1006 if (AlreadyExists) { // Inserting a name that is already defined???
1007 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
1008 assert(Existing && "Conflict but no matching type?");
1009
1010 // There is only one case where this is allowed: when we are refining an
1011 // opaque type. In this case, Existing will be an opaque type.
1012 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
1013 // We ARE replacing an opaque type!
1014 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
1015 return true;
1016 }
1017
1018 // Otherwise, this is an attempt to redefine a type. That's okay if
1019 // the redefinition is identical to the original. This will be so if
1020 // Existing and T point to the same Type object. In this one case we
1021 // allow the equivalent redefinition.
1022 if (Existing == T) return true; // Yes, it's equal.
1023
1024 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer61c83e02006-08-18 08:43:06 +00001025 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00001026 T->getDescription() + "' type plane!");
1027 }
1028
1029 return false;
1030}
1031
1032//===----------------------------------------------------------------------===//
1033// Code for handling upreferences in type names...
1034//
1035
1036// TypeContains - Returns true if Ty directly contains E in it.
1037//
1038static bool TypeContains(const Type *Ty, const Type *E) {
1039 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1040 E) != Ty->subtype_end();
1041}
1042
1043namespace {
1044 struct UpRefRecord {
1045 // NestingLevel - The number of nesting levels that need to be popped before
1046 // this type is resolved.
1047 unsigned NestingLevel;
1048
1049 // LastContainedTy - This is the type at the current binding level for the
1050 // type. Every time we reduce the nesting level, this gets updated.
1051 const Type *LastContainedTy;
1052
1053 // UpRefTy - This is the actual opaque type that the upreference is
1054 // represented with.
1055 OpaqueType *UpRefTy;
1056
1057 UpRefRecord(unsigned NL, OpaqueType *URTy)
1058 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1059 };
1060}
1061
1062// UpRefs - A list of the outstanding upreferences that need to be resolved.
1063static std::vector<UpRefRecord> UpRefs;
1064
1065/// HandleUpRefs - Every time we finish a new layer of types, this function is
1066/// called. It loops through the UpRefs vector, which is a list of the
1067/// currently active types. For each type, if the up reference is contained in
1068/// the newly completed type, we decrement the level count. When the level
1069/// count reaches zero, the upreferenced type is the type that is passed in:
1070/// thus we can complete the cycle.
1071///
1072static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001073 // If Ty isn't abstract, or if there are no up-references in it, then there is
1074 // nothing to resolve here.
1075 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1076
Reid Spencer68a24bd2005-08-27 18:50:39 +00001077 PATypeHolder Ty(ty);
1078 UR_OUT("Type '" << Ty->getDescription() <<
1079 "' newly formed. Resolving upreferences.\n" <<
1080 UpRefs.size() << " upreferences active!\n");
1081
1082 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1083 // to zero), we resolve them all together before we resolve them to Ty. At
1084 // the end of the loop, if there is anything to resolve to Ty, it will be in
1085 // this variable.
1086 OpaqueType *TypeToResolve = 0;
1087
1088 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1089 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1090 << UpRefs[i].second->getDescription() << ") = "
1091 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1092 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1093 // Decrement level of upreference
1094 unsigned Level = --UpRefs[i].NestingLevel;
1095 UpRefs[i].LastContainedTy = Ty;
1096 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1097 if (Level == 0) { // Upreference should be resolved!
1098 if (!TypeToResolve) {
1099 TypeToResolve = UpRefs[i].UpRefTy;
1100 } else {
1101 UR_OUT(" * Resolving upreference for "
1102 << UpRefs[i].second->getDescription() << "\n";
1103 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1104 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1105 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1106 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1107 }
1108 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1109 --i; // Do not skip the next element...
1110 }
1111 }
1112 }
1113
1114 if (TypeToResolve) {
1115 UR_OUT(" * Resolving upreference for "
1116 << UpRefs[i].second->getDescription() << "\n";
1117 std::string OldName = TypeToResolve->getDescription());
1118 TypeToResolve->refineAbstractTypeTo(Ty);
1119 }
1120
1121 return Ty;
1122}
1123
Reid Spencer1628cec2006-10-26 06:15:43 +00001124/// This function is used to obtain the correct opcode for an instruction when
1125/// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both
1126/// an opcode and an "obsolete" flag. These are generated by the lexer and
1127/// the "obsolete" member will be true when the lexer encounters the token for
1128/// an obsolete opcode. For example, "div" was replaced by [usf]div but we need
1129/// to maintain backwards compatibility for asm files that still have the "div"
1130/// instruction. This function handles converting div -> [usf]div appropriately.
Reid Spencer3822ff52006-11-08 06:47:33 +00001131/// @brief Convert obsolete BinaryOps opcodes to new values
Reid Spencer1628cec2006-10-26 06:15:43 +00001132static void
Reid Spencer3da59db2006-11-27 01:05:10 +00001133sanitizeOpcode(OpcodeInfo<Instruction::BinaryOps> &OI, const Type *Ty)
Reid Spencer1628cec2006-10-26 06:15:43 +00001134{
1135 // If its not obsolete, don't do anything
1136 if (!OI.obsolete)
1137 return;
1138
1139 // If its a packed type we want to use the element type
Reid Spencer3da59db2006-11-27 01:05:10 +00001140 if (const PackedType *PTy = dyn_cast<PackedType>(Ty))
Reid Spencer1628cec2006-10-26 06:15:43 +00001141 Ty = PTy->getElementType();
1142
1143 // Depending on the opcode ..
1144 switch (OI.opcode) {
1145 default:
Reid Spencer3ed469c2006-11-02 20:25:50 +00001146 GenerateError("Invalid obsolete opCode (check Lexer.l)");
Reid Spencer1628cec2006-10-26 06:15:43 +00001147 break;
1148 case Instruction::UDiv:
1149 // Handle cases where the opcode needs to change
1150 if (Ty->isFloatingPoint())
1151 OI.opcode = Instruction::FDiv;
1152 else if (Ty->isSigned())
1153 OI.opcode = Instruction::SDiv;
1154 break;
Reid Spencer3ed469c2006-11-02 20:25:50 +00001155 case Instruction::URem:
1156 if (Ty->isFloatingPoint())
1157 OI.opcode = Instruction::FRem;
1158 else if (Ty->isSigned())
1159 OI.opcode = Instruction::SRem;
1160 break;
Reid Spencer1628cec2006-10-26 06:15:43 +00001161 }
1162 // Its not obsolete any more, we fixed it.
1163 OI.obsolete = false;
1164}
Reid Spencer3822ff52006-11-08 06:47:33 +00001165
Reid Spencer3da59db2006-11-27 01:05:10 +00001166/// This function is similar to the previous overload of sanitizeOpcode but
Reid Spencer3822ff52006-11-08 06:47:33 +00001167/// operates on Instruction::OtherOps instead of Instruction::BinaryOps.
1168/// @brief Convert obsolete OtherOps opcodes to new values
1169static void
Reid Spencer3da59db2006-11-27 01:05:10 +00001170sanitizeOpcode(OpcodeInfo<Instruction::OtherOps> &OI, const Type *Ty)
Reid Spencer3822ff52006-11-08 06:47:33 +00001171{
1172 // If its not obsolete, don't do anything
1173 if (!OI.obsolete)
1174 return;
1175
Reid Spencer3822ff52006-11-08 06:47:33 +00001176 switch (OI.opcode) {
1177 default:
1178 GenerateError("Invalid obsolete opcode (check Lexer.l)");
1179 break;
1180 case Instruction::LShr:
1181 if (Ty->isSigned())
1182 OI.opcode = Instruction::AShr;
1183 break;
1184 }
1185 // Its not obsolete any more, we fixed it.
1186 OI.obsolete = false;
1187}
1188
Reid Spencer68a24bd2005-08-27 18:50:39 +00001189// common code from the two 'RunVMAsmParser' functions
Reid Spencer5b7e7532006-09-28 19:28:24 +00001190static Module* RunParser(Module * M) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001191
1192 llvmAsmlineno = 1; // Reset the current line number...
1193 ObsoleteVarArgs = false;
1194 NewVarArgs = false;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001195 CurModule.CurrentModule = M;
Reid Spencerf63697d2006-10-09 17:36:59 +00001196
1197 // Check to make sure the parser succeeded
1198 if (yyparse()) {
1199 if (ParserResult)
1200 delete ParserResult;
1201 return 0;
1202 }
1203
1204 // Check to make sure that parsing produced a result
Reid Spencer61c83e02006-08-18 08:43:06 +00001205 if (!ParserResult)
1206 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001207
Reid Spencerf63697d2006-10-09 17:36:59 +00001208 // Reset ParserResult variable while saving its value for the result.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001209 Module *Result = ParserResult;
1210 ParserResult = 0;
1211
1212 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1213 {
1214 Function* F;
1215 if ((F = Result->getNamedFunction("llvm.va_start"))
1216 && F->getFunctionType()->getNumParams() == 0)
1217 ObsoleteVarArgs = true;
1218 if((F = Result->getNamedFunction("llvm.va_copy"))
1219 && F->getFunctionType()->getNumParams() == 1)
1220 ObsoleteVarArgs = true;
1221 }
1222
Reid Spencer5b7e7532006-09-28 19:28:24 +00001223 if (ObsoleteVarArgs && NewVarArgs) {
1224 GenerateError(
1225 "This file is corrupt: it uses both new and old style varargs");
1226 return 0;
1227 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001228
1229 if(ObsoleteVarArgs) {
1230 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001231 if (F->arg_size() != 0) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001232 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001233 return 0;
1234 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001235
1236 //foo = va_start()
1237 // ->
1238 //bar = alloca typeof(foo)
1239 //va_start(bar)
1240 //foo = load bar
1241
1242 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1243 const Type* ArgTy = F->getFunctionType()->getReturnType();
1244 const Type* ArgTyPtr = PointerType::get(ArgTy);
1245 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001246 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001247
1248 while (!F->use_empty()) {
1249 CallInst* CI = cast<CallInst>(F->use_back());
1250 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1251 new CallInst(NF, bar, "", CI);
1252 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1253 CI->replaceAllUsesWith(foo);
1254 CI->getParent()->getInstList().erase(CI);
1255 }
1256 Result->getFunctionList().erase(F);
1257 }
1258
1259 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001260 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001261 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001262 return 0;
1263 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001264
1265 //vaend foo
1266 // ->
1267 //bar = alloca 1 of typeof(foo)
1268 //vaend bar
1269 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1270 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1271 const Type* ArgTyPtr = PointerType::get(ArgTy);
1272 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001273 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001274
1275 while (!F->use_empty()) {
1276 CallInst* CI = cast<CallInst>(F->use_back());
1277 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1278 new StoreInst(CI->getOperand(1), bar, CI);
1279 new CallInst(NF, bar, "", CI);
1280 CI->getParent()->getInstList().erase(CI);
1281 }
1282 Result->getFunctionList().erase(F);
1283 }
1284
1285 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001286 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001287 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001288 return 0;
1289 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001290 //foo = vacopy(bar)
1291 // ->
1292 //a = alloca 1 of typeof(foo)
1293 //b = alloca 1 of typeof(foo)
1294 //store bar -> b
1295 //vacopy(a, b)
1296 //foo = load a
1297
1298 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1299 const Type* ArgTy = F->getFunctionType()->getReturnType();
1300 const Type* ArgTyPtr = PointerType::get(ArgTy);
1301 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001302 RetTy, ArgTyPtr, ArgTyPtr,
1303 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001304
1305 while (!F->use_empty()) {
1306 CallInst* CI = cast<CallInst>(F->use_back());
1307 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1308 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1309 new StoreInst(CI->getOperand(1), b, CI);
1310 new CallInst(NF, a, b, "", CI);
1311 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1312 CI->replaceAllUsesWith(foo);
1313 CI->getParent()->getInstList().erase(CI);
1314 }
1315 Result->getFunctionList().erase(F);
1316 }
1317 }
1318
1319 return Result;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001320}
Reid Spencer68a24bd2005-08-27 18:50:39 +00001321
1322//===----------------------------------------------------------------------===//
1323// RunVMAsmParser - Define an interface to this parser
1324//===----------------------------------------------------------------------===//
1325//
1326Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1327 set_scan_file(F);
1328
1329 CurFilename = Filename;
1330 return RunParser(new Module(CurFilename));
1331}
1332
1333Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1334 set_scan_string(AsmString);
1335
1336 CurFilename = "from_memory";
1337 if (M == NULL) {
1338 return RunParser(new Module (CurFilename));
1339 } else {
1340 return RunParser(M);
1341 }
1342}
1343
1344
Reid Spencer3822ff52006-11-08 06:47:33 +00001345
1346/* Enabling traces. */
1347#ifndef YYDEBUG
1348# define YYDEBUG 0
1349#endif
1350
1351/* Enabling verbose error messages. */
1352#ifdef YYERROR_VERBOSE
1353# undef YYERROR_VERBOSE
1354# define YYERROR_VERBOSE 1
1355#else
1356# define YYERROR_VERBOSE 0
1357#endif
1358
1359/* Enabling the token table. */
1360#ifndef YYTOKEN_TABLE
1361# define YYTOKEN_TABLE 0
1362#endif
1363
1364#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer3da59db2006-11-27 01:05:10 +00001365#line 1040 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00001366typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001367 llvm::Module *ModuleVal;
1368 llvm::Function *FunctionVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00001369 std::pair<TypeInfo, char*> *ArgVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001370 llvm::BasicBlock *BasicBlockVal;
1371 llvm::TerminatorInst *TermInstVal;
1372 llvm::Instruction *InstVal;
1373 llvm::Constant *ConstVal;
1374
Reid Spencer3da59db2006-11-27 01:05:10 +00001375 TypeInfo TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001376 llvm::Value *ValueVal;
1377
Reid Spencer3da59db2006-11-27 01:05:10 +00001378 std::vector<std::pair<TypeInfo,char*> >*ArgList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001379 std::vector<llvm::Value*> *ValueList;
Reid Spencer3da59db2006-11-27 01:05:10 +00001380 std::list<TypeInfo> *TypeList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001381 // Represent the RHS of PHI node
1382 std::list<std::pair<llvm::Value*,
1383 llvm::BasicBlock*> > *PHIList;
1384 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1385 std::vector<llvm::Constant*> *ConstVector;
1386
1387 llvm::GlobalValue::LinkageTypes Linkage;
1388 int64_t SInt64Val;
1389 uint64_t UInt64Val;
1390 int SIntVal;
1391 unsigned UIntVal;
1392 double FPVal;
1393 bool BoolVal;
1394
1395 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001396 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001397
Reid Spencer1628cec2006-10-26 06:15:43 +00001398 BinaryOpInfo BinaryOpVal;
1399 TermOpInfo TermOpVal;
1400 MemOpInfo MemOpVal;
Reid Spencer3da59db2006-11-27 01:05:10 +00001401 CastOpInfo CastOpVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00001402 OtherOpInfo OtherOpVal;
1403 llvm::Module::Endianness Endianness;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001404} YYSTYPE;
Reid Spencer3822ff52006-11-08 06:47:33 +00001405/* Line 196 of yacc.c. */
Reid Spencer3da59db2006-11-27 01:05:10 +00001406#line 1407 "llvmAsmParser.tab.c"
Reid Spencer3822ff52006-11-08 06:47:33 +00001407# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1408# define YYSTYPE_IS_DECLARED 1
1409# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001410#endif
1411
1412
1413
Reid Spencer3822ff52006-11-08 06:47:33 +00001414/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001415
1416
Reid Spencer3822ff52006-11-08 06:47:33 +00001417/* Line 219 of yacc.c. */
Reid Spencer3da59db2006-11-27 01:05:10 +00001418#line 1419 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001419
Reid Spencer3822ff52006-11-08 06:47:33 +00001420#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1421# define YYSIZE_T __SIZE_TYPE__
1422#endif
1423#if ! defined (YYSIZE_T) && defined (size_t)
1424# define YYSIZE_T size_t
1425#endif
1426#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1427# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1428# define YYSIZE_T size_t
1429#endif
1430#if ! defined (YYSIZE_T)
1431# define YYSIZE_T unsigned int
1432#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001433
Reid Spencer3822ff52006-11-08 06:47:33 +00001434#ifndef YY_
1435# if YYENABLE_NLS
1436# if ENABLE_NLS
1437# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1438# define YY_(msgid) dgettext ("bison-runtime", msgid)
1439# endif
1440# endif
1441# ifndef YY_
1442# define YY_(msgid) msgid
1443# endif
1444#endif
1445
1446#if ! defined (yyoverflow) || YYERROR_VERBOSE
1447
1448/* The parser invokes alloca or malloc; define the necessary symbols. */
1449
1450# ifdef YYSTACK_USE_ALLOCA
1451# if YYSTACK_USE_ALLOCA
1452# ifdef __GNUC__
1453# define YYSTACK_ALLOC __builtin_alloca
1454# else
1455# define YYSTACK_ALLOC alloca
1456# if defined (__STDC__) || defined (__cplusplus)
1457# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1458# define YYINCLUDED_STDLIB_H
1459# endif
1460# endif
1461# endif
1462# endif
1463
1464# ifdef YYSTACK_ALLOC
1465 /* Pacify GCC's `empty if-body' warning. */
1466# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1467# ifndef YYSTACK_ALLOC_MAXIMUM
1468 /* The OS might guarantee only one guard page at the bottom of the stack,
1469 and a page size can be as small as 4096 bytes. So we cannot safely
1470 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1471 to allow for a few compiler-allocated temporary stack slots. */
1472# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1473# endif
1474# else
1475# define YYSTACK_ALLOC YYMALLOC
1476# define YYSTACK_FREE YYFREE
1477# ifndef YYSTACK_ALLOC_MAXIMUM
1478# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1479# endif
1480# ifdef __cplusplus
1481extern "C" {
1482# endif
1483# ifndef YYMALLOC
1484# define YYMALLOC malloc
1485# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1486 && (defined (__STDC__) || defined (__cplusplus)))
1487void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1488# endif
1489# endif
1490# ifndef YYFREE
1491# define YYFREE free
1492# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1493 && (defined (__STDC__) || defined (__cplusplus)))
1494void free (void *); /* INFRINGES ON USER NAME SPACE */
1495# endif
1496# endif
1497# ifdef __cplusplus
1498}
1499# endif
1500# endif
1501#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1502
1503
1504#if (! defined (yyoverflow) \
1505 && (! defined (__cplusplus) \
1506 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1507
1508/* A type that is properly aligned for any stack member. */
1509union yyalloc
1510{
1511 short int yyss;
1512 YYSTYPE yyvs;
1513 };
1514
1515/* The size of the maximum gap between one aligned stack and the next. */
1516# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1517
1518/* The size of an array large to enough to hold all stacks, each with
1519 N elements. */
1520# define YYSTACK_BYTES(N) \
1521 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1522 + YYSTACK_GAP_MAXIMUM)
1523
1524/* Copy COUNT objects from FROM to TO. The source and destination do
1525 not overlap. */
1526# ifndef YYCOPY
1527# if defined (__GNUC__) && 1 < __GNUC__
1528# define YYCOPY(To, From, Count) \
1529 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1530# else
1531# define YYCOPY(To, From, Count) \
1532 do \
1533 { \
1534 YYSIZE_T yyi; \
1535 for (yyi = 0; yyi < (Count); yyi++) \
1536 (To)[yyi] = (From)[yyi]; \
1537 } \
1538 while (0)
1539# endif
1540# endif
1541
1542/* Relocate STACK from its old location to the new one. The
1543 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1544 elements in the stack, and YYPTR gives the new location of the
1545 stack. Advance YYPTR to a properly aligned location for the next
1546 stack. */
1547# define YYSTACK_RELOCATE(Stack) \
1548 do \
1549 { \
1550 YYSIZE_T yynewbytes; \
1551 YYCOPY (&yyptr->Stack, Stack, yysize); \
1552 Stack = &yyptr->Stack; \
1553 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1554 yyptr += yynewbytes / sizeof (*yyptr); \
1555 } \
1556 while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001557
1558#endif
1559
Reid Spencer3822ff52006-11-08 06:47:33 +00001560#if defined (__STDC__) || defined (__cplusplus)
1561 typedef signed char yysigned_char;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001562#else
Reid Spencer3822ff52006-11-08 06:47:33 +00001563 typedef short int yysigned_char;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001564#endif
1565
Reid Spencer3822ff52006-11-08 06:47:33 +00001566/* YYFINAL -- State number of the termination state. */
1567#define YYFINAL 4
1568/* YYLAST -- Last index in YYTABLE. */
Reid Spencer3da59db2006-11-27 01:05:10 +00001569#define YYLAST 1410
Reid Spencer3822ff52006-11-08 06:47:33 +00001570
1571/* YYNTOKENS -- Number of terminals. */
Reid Spencer3da59db2006-11-27 01:05:10 +00001572#define YYNTOKENS 139
Reid Spencer3822ff52006-11-08 06:47:33 +00001573/* YYNNTS -- Number of nonterminals. */
Reid Spencer3da59db2006-11-27 01:05:10 +00001574#define YYNNTS 76
Reid Spencer3822ff52006-11-08 06:47:33 +00001575/* YYNRULES -- Number of rules. */
Reid Spencer3da59db2006-11-27 01:05:10 +00001576#define YYNRULES 269
Reid Spencer3822ff52006-11-08 06:47:33 +00001577/* YYNRULES -- Number of states. */
Reid Spencer3da59db2006-11-27 01:05:10 +00001578#define YYNSTATES 534
Reid Spencer3822ff52006-11-08 06:47:33 +00001579
1580/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1581#define YYUNDEFTOK 2
Reid Spencer3da59db2006-11-27 01:05:10 +00001582#define YYMAXUTOK 379
Reid Spencer3822ff52006-11-08 06:47:33 +00001583
1584#define YYTRANSLATE(YYX) \
1585 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1586
1587/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1588static const unsigned char yytranslate[] =
1589{
1590 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1591 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1592 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1593 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3da59db2006-11-27 01:05:10 +00001594 128, 129, 137, 2, 126, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001595 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3da59db2006-11-27 01:05:10 +00001596 133, 125, 134, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001597 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1598 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3da59db2006-11-27 01:05:10 +00001599 2, 130, 127, 132, 2, 2, 2, 2, 2, 138,
Reid Spencer3822ff52006-11-08 06:47:33 +00001600 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1601 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3da59db2006-11-27 01:05:10 +00001602 131, 2, 2, 135, 2, 136, 2, 2, 2, 2,
Reid Spencer3822ff52006-11-08 06:47:33 +00001603 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1604 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1605 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1606 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1607 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1608 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1609 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1610 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1611 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1612 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1613 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1614 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1615 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1616 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1617 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1618 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1619 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1620 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1621 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1622 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1623 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1624 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1625 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
Reid Spencer3da59db2006-11-27 01:05:10 +00001626 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1627 115, 116, 117, 118, 119, 120, 121, 122, 123, 124
Reid Spencer3822ff52006-11-08 06:47:33 +00001628};
1629
1630#if YYDEBUG
1631/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1632 YYRHS. */
1633static const unsigned short int yyprhs[] =
1634{
1635 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1636 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1637 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
1638 59, 61, 63, 65, 67, 69, 71, 73, 75, 77,
Reid Spencer3da59db2006-11-27 01:05:10 +00001639 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
1640 99, 101, 104, 105, 107, 109, 111, 113, 115, 117,
1641 119, 120, 121, 123, 125, 127, 129, 131, 133, 136,
1642 137, 140, 141, 145, 148, 149, 151, 152, 156, 158,
Reid Spencer3822ff52006-11-08 06:47:33 +00001643 161, 163, 165, 167, 169, 171, 173, 175, 177, 179,
Reid Spencer3da59db2006-11-27 01:05:10 +00001644 181, 183, 185, 187, 189, 191, 193, 195, 197, 199,
1645 201, 203, 206, 211, 217, 223, 227, 230, 233, 235,
1646 239, 241, 245, 247, 248, 253, 257, 261, 266, 271,
1647 275, 278, 281, 284, 287, 290, 293, 296, 299, 302,
1648 305, 312, 318, 327, 334, 341, 348, 355, 362, 371,
1649 380, 384, 386, 388, 390, 392, 395, 398, 403, 406,
1650 408, 413, 416, 421, 422, 430, 431, 439, 440, 448,
1651 449, 457, 461, 466, 467, 469, 471, 473, 477, 481,
1652 485, 489, 493, 497, 499, 500, 502, 504, 506, 507,
1653 510, 514, 516, 518, 522, 524, 525, 534, 536, 538,
1654 542, 544, 546, 549, 550, 552, 554, 555, 560, 561,
1655 563, 565, 567, 569, 571, 573, 575, 577, 579, 583,
1656 585, 591, 593, 595, 597, 599, 602, 605, 608, 612,
1657 615, 616, 618, 621, 624, 628, 638, 648, 657, 671,
1658 673, 675, 682, 688, 691, 698, 706, 708, 712, 714,
1659 715, 718, 720, 726, 732, 738, 741, 746, 751, 758,
1660 763, 768, 773, 778, 785, 792, 795, 803, 805, 808,
1661 809, 811, 812, 816, 823, 827, 834, 837, 842, 849
Reid Spencer3822ff52006-11-08 06:47:33 +00001662};
1663
1664/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1665static const short int yyrhs[] =
1666{
Reid Spencer3da59db2006-11-27 01:05:10 +00001667 171, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencer3822ff52006-11-08 06:47:33 +00001668 -1, 78, -1, 79, -1, 80, -1, 81, -1, 82,
1669 -1, 83, -1, 84, -1, 85, -1, 86, -1, 87,
1670 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
Reid Spencer3da59db2006-11-27 01:05:10 +00001671 -1, 93, -1, 94, -1, 95, -1, 102, -1, 103,
1672 -1, 104, -1, 105, -1, 106, -1, 107, -1, 108,
1673 -1, 109, -1, 110, -1, 111, -1, 112, -1, 113,
1674 -1, 116, -1, 117, -1, 118, -1, 16, -1, 14,
1675 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
1676 -1, 11, -1, 147, -1, 148, -1, 18, -1, 19,
1677 -1, 183, 125, -1, -1, 41, -1, 42, -1, 43,
1678 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
1679 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
1680 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
1681 -1, 126, 57, 4, -1, 34, 24, -1, -1, 156,
1682 -1, -1, 126, 159, 158, -1, 156, -1, 57, 4,
1683 -1, 162, -1, 8, -1, 164, -1, 8, -1, 164,
1684 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
1685 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
1686 -1, 19, -1, 20, -1, 21, -1, 48, -1, 163,
1687 -1, 198, -1, 127, 4, -1, 161, 128, 166, 129,
1688 -1, 130, 4, 131, 164, 132, -1, 133, 4, 131,
1689 164, 134, -1, 135, 165, 136, -1, 135, 136, -1,
1690 164, 137, -1, 164, -1, 165, 126, 164, -1, 165,
1691 -1, 165, 126, 37, -1, 37, -1, -1, 162, 130,
1692 169, 132, -1, 162, 130, 132, -1, 162, 138, 24,
1693 -1, 162, 133, 169, 134, -1, 162, 135, 169, 136,
1694 -1, 162, 135, 136, -1, 162, 38, -1, 162, 39,
1695 -1, 162, 198, -1, 162, 168, -1, 162, 26, -1,
1696 147, 141, -1, 148, 4, -1, 9, 27, -1, 9,
1697 28, -1, 150, 7, -1, 145, 128, 167, 36, 162,
1698 129, -1, 101, 128, 167, 212, 129, -1, 115, 128,
1699 167, 126, 167, 126, 167, 129, -1, 142, 128, 167,
1700 126, 167, 129, -1, 143, 128, 167, 126, 167, 129,
1701 -1, 144, 128, 167, 126, 167, 129, -1, 146, 128,
1702 167, 126, 167, 129, -1, 120, 128, 167, 126, 167,
1703 129, -1, 121, 128, 167, 126, 167, 126, 167, 129,
1704 -1, 122, 128, 167, 126, 167, 126, 167, 129, -1,
1705 169, 126, 167, -1, 167, -1, 32, -1, 33, -1,
1706 172, -1, 172, 192, -1, 172, 194, -1, 172, 62,
1707 61, 178, -1, 172, 25, -1, 173, -1, 173, 151,
1708 20, 160, -1, 173, 194, -1, 173, 62, 61, 178,
1709 -1, -1, 173, 151, 152, 170, 167, 174, 158, -1,
1710 -1, 173, 151, 50, 170, 162, 175, 158, -1, -1,
1711 173, 151, 45, 170, 162, 176, 158, -1, -1, 173,
1712 151, 47, 170, 162, 177, 158, -1, 173, 51, 180,
1713 -1, 173, 58, 125, 181, -1, -1, 24, -1, 56,
1714 -1, 55, -1, 53, 125, 179, -1, 54, 125, 4,
1715 -1, 52, 125, 24, -1, 71, 125, 24, -1, 130,
1716 182, 132, -1, 182, 126, 24, -1, 24, -1, -1,
1717 22, -1, 24, -1, 183, -1, -1, 162, 184, -1,
1718 186, 126, 185, -1, 185, -1, 186, -1, 186, 126,
1719 37, -1, 37, -1, -1, 153, 160, 183, 128, 187,
1720 129, 157, 154, -1, 29, -1, 135, -1, 152, 188,
1721 189, -1, 30, -1, 136, -1, 201, 191, -1, -1,
1722 45, -1, 47, -1, -1, 31, 195, 193, 188, -1,
1723 -1, 63, -1, 3, -1, 4, -1, 7, -1, 27,
1724 -1, 28, -1, 38, -1, 39, -1, 26, -1, 133,
1725 169, 134, -1, 168, -1, 61, 196, 24, 126, 24,
1726 -1, 140, -1, 183, -1, 198, -1, 197, -1, 162,
1727 199, -1, 201, 202, -1, 190, 202, -1, 203, 151,
1728 204, -1, 203, 206, -1, -1, 23, -1, 72, 200,
1729 -1, 72, 8, -1, 73, 21, 199, -1, 73, 9,
1730 199, 126, 21, 199, 126, 21, 199, -1, 74, 149,
1731 199, 126, 21, 199, 130, 205, 132, -1, 74, 149,
1732 199, 126, 21, 199, 130, 132, -1, 75, 153, 160,
1733 199, 128, 209, 129, 36, 21, 199, 76, 21, 199,
1734 -1, 76, -1, 77, -1, 205, 149, 197, 126, 21,
1735 199, -1, 149, 197, 126, 21, 199, -1, 151, 211,
1736 -1, 162, 130, 199, 126, 199, 132, -1, 207, 126,
1737 130, 199, 126, 199, 132, -1, 200, -1, 208, 126,
1738 200, -1, 208, -1, -1, 60, 59, -1, 59, -1,
1739 142, 162, 199, 126, 199, -1, 143, 162, 199, 126,
1740 199, -1, 144, 162, 199, 126, 199, -1, 49, 200,
1741 -1, 146, 200, 126, 200, -1, 145, 200, 36, 162,
1742 -1, 115, 200, 126, 200, 126, 200, -1, 119, 200,
1743 126, 162, -1, 123, 200, 126, 162, -1, 124, 200,
1744 126, 162, -1, 120, 200, 126, 200, -1, 121, 200,
1745 126, 200, 126, 200, -1, 122, 200, 126, 200, 126,
1746 200, -1, 114, 207, -1, 210, 153, 160, 199, 128,
1747 209, 129, -1, 214, -1, 126, 208, -1, -1, 35,
1748 -1, -1, 96, 162, 155, -1, 96, 162, 126, 15,
1749 199, 155, -1, 97, 162, 155, -1, 97, 162, 126,
1750 15, 199, 155, -1, 98, 200, -1, 213, 99, 162,
1751 199, -1, 213, 100, 200, 126, 162, 199, -1, 101,
1752 162, 199, 212, -1
Reid Spencer3822ff52006-11-08 06:47:33 +00001753};
1754
1755/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1756static const unsigned short int yyrline[] =
1757{
Reid Spencer3da59db2006-11-27 01:05:10 +00001758 0, 1168, 1168, 1169, 1177, 1178, 1188, 1188, 1188, 1188,
1759 1188, 1188, 1188, 1188, 1188, 1189, 1189, 1189, 1190, 1190,
1760 1190, 1190, 1190, 1190, 1191, 1191, 1191, 1191, 1191, 1191,
1761 1192, 1192, 1192, 1192, 1192, 1192, 1193, 1193, 1193, 1197,
1762 1197, 1197, 1197, 1198, 1198, 1198, 1198, 1199, 1199, 1200,
1763 1200, 1203, 1207, 1212, 1213, 1214, 1215, 1216, 1217, 1218,
1764 1219, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1237,
1765 1238, 1244, 1245, 1253, 1261, 1262, 1267, 1268, 1269, 1274,
1766 1288, 1288, 1292, 1292, 1297, 1308, 1308, 1308, 1308, 1308,
1767 1308, 1308, 1309, 1309, 1309, 1309, 1309, 1309, 1310, 1315,
1768 1319, 1328, 1337, 1352, 1359, 1373, 1384, 1389, 1401, 1406,
1769 1412, 1413, 1419, 1425, 1436, 1462, 1476, 1506, 1532, 1553,
1770 1566, 1576, 1581, 1642, 1649, 1658, 1664, 1670, 1674, 1678,
1771 1686, 1712, 1744, 1752, 1779, 1790, 1796, 1807, 1813, 1819,
1772 1828, 1832, 1840, 1840, 1850, 1858, 1863, 1867, 1871, 1875,
1773 1890, 1912, 1915, 1918, 1918, 1926, 1926, 1935, 1935, 1944,
1774 1944, 1954, 1957, 1960, 1964, 1977, 1978, 1980, 1984, 1993,
1775 1997, 2002, 2004, 2009, 2014, 2023, 2023, 2024, 2024, 2026,
1776 2033, 2039, 2046, 2050, 2058, 2066, 2071, 2165, 2165, 2167,
1777 2175, 2175, 2177, 2182, 2183, 2184, 2186, 2186, 2196, 2200,
1778 2205, 2209, 2213, 2217, 2221, 2225, 2229, 2233, 2237, 2257,
1779 2261, 2275, 2279, 2285, 2285, 2291, 2296, 2300, 2309, 2320,
1780 2329, 2341, 2354, 2358, 2362, 2367, 2376, 2395, 2404, 2460,
1781 2464, 2471, 2482, 2495, 2504, 2513, 2523, 2527, 2534, 2534,
1782 2536, 2540, 2545, 2567, 2582, 2596, 2609, 2620, 2646, 2654,
1783 2660, 2680, 2703, 2709, 2715, 2721, 2736, 2796, 2803, 2806,
1784 2811, 2815, 2822, 2827, 2833, 2838, 2844, 2852, 2864, 2879
Reid Spencer3822ff52006-11-08 06:47:33 +00001785};
1786#endif
1787
1788#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1789/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1790 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1791static const char *const yytname[] =
1792{
1793 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1794 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1795 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1796 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1797 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1798 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1799 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
1800 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1801 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
1802 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1803 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
1804 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1805 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
1806 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1807 "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "MALLOC",
Reid Spencer3da59db2006-11-27 01:05:10 +00001808 "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "TRUNC", "ZEXT",
1809 "SEXT", "FPTRUNC", "FPEXT", "BITCAST", "UITOFP", "SITOFP", "FPTOUI",
1810 "FPTOSI", "INTTOPTR", "PTRTOINT", "PHI_TOK", "SELECT", "SHL", "LSHR",
1811 "ASHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1812 "VAARG_old", "VANEXT_old", "'='", "','", "'\\\\'", "'('", "')'", "'['",
1813 "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept",
1814 "INTVAL", "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps",
1815 "CastOps", "ShiftOps", "SIntType", "UIntType", "IntType", "FPType",
1816 "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", "OptCAlign",
1817 "SectionString", "OptSection", "GlobalVarAttributes",
1818 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
1819 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
1820 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
1821 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
1822 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
1823 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
1824 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
1825 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
Reid Spencer3822ff52006-11-08 06:47:33 +00001826 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1827 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList",
1828 "ValueRefListE", "OptTailCall", "InstVal", "IndexList", "OptVolatile",
1829 "MemoryInst", 0
1830};
1831#endif
1832
1833# ifdef YYPRINT
1834/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1835 token YYLEX-NUM. */
1836static const unsigned short int yytoknum[] =
1837{
1838 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1839 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1840 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1841 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1842 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1843 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1844 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1845 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1846 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1847 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1848 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
Reid Spencer3da59db2006-11-27 01:05:10 +00001849 365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1850 375, 376, 377, 378, 379, 61, 44, 92, 40, 41,
1851 91, 120, 93, 60, 62, 123, 125, 42, 99
Reid Spencer3822ff52006-11-08 06:47:33 +00001852};
1853# endif
1854
1855/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1856static const unsigned char yyr1[] =
1857{
Reid Spencer3da59db2006-11-27 01:05:10 +00001858 0, 139, 140, 140, 141, 141, 142, 142, 142, 142,
1859 142, 142, 142, 142, 142, 143, 143, 143, 144, 144,
1860 144, 144, 144, 144, 145, 145, 145, 145, 145, 145,
1861 145, 145, 145, 145, 145, 145, 146, 146, 146, 147,
1862 147, 147, 147, 148, 148, 148, 148, 149, 149, 150,
1863 150, 151, 151, 152, 152, 152, 152, 152, 152, 152,
1864 152, 153, 153, 153, 153, 153, 153, 153, 153, 154,
1865 154, 155, 155, 156, 157, 157, 158, 158, 159, 159,
1866 160, 160, 161, 161, 162, 163, 163, 163, 163, 163,
1867 163, 163, 163, 163, 163, 163, 163, 163, 164, 164,
1868 164, 164, 164, 164, 164, 164, 164, 164, 165, 165,
1869 166, 166, 166, 166, 167, 167, 167, 167, 167, 167,
1870 167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
1871 168, 168, 168, 168, 168, 168, 168, 168, 168, 168,
1872 169, 169, 170, 170, 171, 172, 172, 172, 172, 172,
1873 173, 173, 173, 174, 173, 175, 173, 176, 173, 177,
1874 173, 173, 173, 173, 178, 179, 179, 180, 180, 180,
1875 180, 181, 182, 182, 182, 183, 183, 184, 184, 185,
1876 186, 186, 187, 187, 187, 187, 188, 189, 189, 190,
1877 191, 191, 192, 193, 193, 193, 195, 194, 196, 196,
1878 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1879 197, 198, 198, 199, 199, 200, 201, 201, 202, 203,
1880 203, 203, 204, 204, 204, 204, 204, 204, 204, 204,
1881 204, 205, 205, 206, 207, 207, 208, 208, 209, 209,
1882 210, 210, 211, 211, 211, 211, 211, 211, 211, 211,
1883 211, 211, 211, 211, 211, 211, 211, 211, 212, 212,
1884 213, 213, 214, 214, 214, 214, 214, 214, 214, 214
Reid Spencer3822ff52006-11-08 06:47:33 +00001885};
1886
1887/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1888static const unsigned char yyr2[] =
1889{
1890 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1891 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1892 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3822ff52006-11-08 06:47:33 +00001893 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3da59db2006-11-27 01:05:10 +00001894 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1895 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
1896 0, 0, 1, 1, 1, 1, 1, 1, 2, 0,
1897 2, 0, 3, 2, 0, 1, 0, 3, 1, 2,
1898 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1899 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1900 1, 2, 4, 5, 5, 3, 2, 2, 1, 3,
1901 1, 3, 1, 0, 4, 3, 3, 4, 4, 3,
1902 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1903 6, 5, 8, 6, 6, 6, 6, 6, 8, 8,
1904 3, 1, 1, 1, 1, 2, 2, 4, 2, 1,
1905 4, 2, 4, 0, 7, 0, 7, 0, 7, 0,
1906 7, 3, 4, 0, 1, 1, 1, 3, 3, 3,
1907 3, 3, 3, 1, 0, 1, 1, 1, 0, 2,
1908 3, 1, 1, 3, 1, 0, 8, 1, 1, 3,
1909 1, 1, 2, 0, 1, 1, 0, 4, 0, 1,
1910 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
1911 5, 1, 1, 1, 1, 2, 2, 2, 3, 2,
1912 0, 1, 2, 2, 3, 9, 9, 8, 13, 1,
1913 1, 6, 5, 2, 6, 7, 1, 3, 1, 0,
1914 2, 1, 5, 5, 5, 2, 4, 4, 6, 4,
1915 4, 4, 4, 6, 6, 2, 7, 1, 2, 0,
1916 1, 0, 3, 6, 3, 6, 2, 4, 6, 4
Reid Spencer3822ff52006-11-08 06:47:33 +00001917};
1918
1919/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1920 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1921 means the default is an error. */
1922static const unsigned short int yydefact[] =
1923{
Reid Spencer3da59db2006-11-27 01:05:10 +00001924 163, 0, 60, 149, 1, 148, 196, 53, 54, 55,
1925 56, 57, 58, 59, 0, 61, 220, 145, 146, 220,
1926 175, 176, 0, 0, 0, 60, 0, 151, 193, 0,
1927 0, 62, 63, 64, 65, 66, 67, 0, 0, 221,
1928 217, 52, 190, 191, 192, 216, 0, 0, 0, 0,
1929 161, 0, 0, 0, 0, 0, 0, 0, 51, 194,
1930 195, 61, 164, 147, 68, 2, 3, 81, 85, 86,
1931 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1932 97, 98, 0, 0, 0, 0, 211, 0, 0, 80,
1933 99, 84, 212, 100, 187, 188, 189, 261, 219, 0,
1934 0, 0, 0, 174, 162, 152, 150, 142, 143, 0,
1935 0, 0, 0, 197, 101, 0, 0, 83, 106, 108,
1936 0, 0, 113, 107, 260, 0, 241, 0, 0, 0,
1937 0, 61, 229, 230, 6, 7, 8, 9, 10, 11,
Reid Spencer3822ff52006-11-08 06:47:33 +00001938 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
Reid Spencer3da59db2006-11-27 01:05:10 +00001939 22, 23, 0, 0, 0, 0, 24, 25, 26, 27,
1940 28, 29, 30, 31, 32, 33, 34, 35, 0, 0,
1941 36, 37, 38, 0, 0, 0, 0, 0, 0, 0,
1942 0, 0, 0, 0, 218, 61, 233, 0, 257, 169,
1943 166, 165, 167, 168, 170, 173, 0, 157, 159, 155,
1944 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1945 95, 0, 0, 0, 0, 153, 0, 0, 0, 105,
1946 185, 112, 110, 0, 0, 245, 240, 223, 222, 0,
1947 0, 42, 46, 41, 45, 40, 44, 39, 43, 47,
1948 48, 0, 0, 71, 71, 266, 0, 0, 255, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00001949 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00001950 0, 0, 0, 0, 0, 171, 76, 76, 76, 127,
1951 128, 4, 5, 125, 126, 129, 124, 120, 121, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00001952 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00001953 0, 0, 0, 123, 122, 76, 82, 82, 109, 184,
1954 178, 181, 182, 0, 0, 102, 200, 201, 202, 207,
1955 203, 204, 205, 206, 198, 0, 209, 214, 213, 215,
1956 0, 224, 0, 0, 0, 262, 0, 264, 259, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00001957 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00001958 0, 0, 0, 0, 0, 0, 172, 0, 158, 160,
1959 156, 0, 0, 0, 0, 0, 115, 141, 0, 0,
1960 119, 0, 116, 0, 0, 0, 0, 0, 154, 103,
1961 104, 177, 179, 0, 74, 111, 199, 0, 0, 0,
1962 0, 0, 0, 0, 0, 0, 269, 0, 0, 0,
1963 249, 252, 0, 0, 250, 251, 0, 0, 0, 247,
1964 246, 0, 267, 0, 0, 0, 78, 76, 259, 0,
1965 0, 0, 0, 0, 114, 117, 118, 0, 0, 0,
1966 0, 0, 183, 180, 75, 69, 0, 208, 0, 0,
1967 239, 71, 72, 71, 236, 258, 0, 0, 0, 0,
1968 0, 242, 243, 244, 239, 0, 73, 79, 77, 0,
1969 0, 0, 0, 0, 140, 0, 0, 0, 0, 0,
1970 0, 186, 0, 0, 0, 238, 0, 0, 263, 265,
1971 0, 0, 0, 248, 253, 254, 0, 268, 131, 0,
1972 0, 0, 0, 0, 0, 0, 0, 0, 70, 210,
1973 0, 0, 0, 237, 234, 0, 256, 0, 137, 0,
1974 0, 133, 134, 135, 130, 136, 0, 227, 0, 0,
1975 0, 235, 0, 0, 0, 225, 0, 226, 0, 0,
1976 132, 138, 139, 0, 0, 0, 0, 0, 0, 232,
1977 0, 0, 231, 228
Reid Spencer3822ff52006-11-08 06:47:33 +00001978};
1979
1980/* YYDEFGOTO[NTERM-NUM]. */
1981static const short int yydefgoto[] =
1982{
Reid Spencer3da59db2006-11-27 01:05:10 +00001983 -1, 86, 273, 288, 289, 290, 291, 292, 211, 212,
1984 241, 213, 25, 15, 37, 461, 325, 406, 425, 348,
1985 407, 87, 88, 214, 90, 91, 120, 223, 357, 316,
1986 358, 109, 1, 2, 3, 295, 268, 266, 267, 63,
1987 192, 50, 104, 196, 92, 372, 301, 302, 303, 38,
1988 96, 16, 44, 17, 61, 18, 28, 377, 317, 93,
1989 319, 434, 19, 40, 41, 184, 509, 98, 248, 465,
1990 466, 185, 186, 386, 187, 188
Reid Spencer3822ff52006-11-08 06:47:33 +00001991};
1992
1993/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1994 STATE-NUM. */
Reid Spencer3da59db2006-11-27 01:05:10 +00001995#define YYPACT_NINF -472
Reid Spencer3822ff52006-11-08 06:47:33 +00001996static const short int yypact[] =
1997{
Reid Spencer3da59db2006-11-27 01:05:10 +00001998 -472, 24, 395, 501, -472, -472, -472, -472, -472, -472,
1999 -472, -472, -472, -472, -13, 112, 46, -472, -472, -11,
2000 -472, -472, -18, -41, 45, 51, -1, -472, 40, 106,
2001 131, -472, -472, -472, -472, -472, -472, 1136, -23, -472,
2002 -472, 81, -472, -472, -472, -472, 30, 33, 49, 61,
2003 -472, 57, 106, 1136, 78, 78, 78, 78, -472, -472,
2004 -472, 112, -472, -472, -472, -472, -472, 62, -472, -472,
2005 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
2006 -472, -472, 185, 187, 188, 619, -472, 81, 67, -472,
2007 -472, -71, -472, -472, -472, -472, -472, 1286, -472, 174,
2008 58, 196, 177, 178, -472, -472, -472, -472, -472, 1177,
2009 1177, 1177, 1197, -472, -472, 72, 73, -472, -472, -71,
2010 -89, 79, 151, -472, -472, 1177, -472, 147, 1222, 12,
2011 218, 112, -472, -472, -472, -472, -472, -472, -472, -472,
2012 -472, -472, -472, -472, -472, -472, -472, -472, -472, -472,
2013 -472, -472, 1177, 1177, 1177, 1177, -472, -472, -472, -472,
2014 -472, -472, -472, -472, -472, -472, -472, -472, 1177, 1177,
2015 -472, -472, -472, 1177, 1177, 1177, 1177, 1177, 1177, 1177,
2016 1177, 1177, 1177, 1177, -472, 112, -472, -55, -472, -472,
2017 -472, -472, -472, -472, -472, -472, -62, -472, -472, -472,
2018 95, 123, 204, 125, 205, 130, 206, 149, 207, 208,
2019 210, 181, 209, 214, 488, -472, 1177, 1177, 1177, -472,
2020 944, -472, 88, 93, 698, -472, -472, 62, -472, 698,
2021 698, -472, -472, -472, -472, -472, -472, -472, -472, -472,
2022 -472, 698, 1136, 97, 110, -472, 698, 108, 113, 114,
2023 120, 121, 124, 126, 133, 136, 698, 698, 698, 213,
2024 139, 1136, 1177, 1177, 227, -472, 140, 140, 140, -472,
2025 -472, -472, -472, -472, -472, -472, -472, -472, -472, 141,
2026 142, 143, 145, 146, 985, 1197, 639, 243, 148, 154,
2027 155, 157, 165, -472, -472, 140, -28, -51, -71, -472,
2028 81, -472, 153, 172, 1005, -472, -472, -472, -472, -472,
2029 -472, -472, -472, -472, 244, 1197, -472, -472, -472, -472,
2030 180, -472, 182, 698, -7, -472, -6, -472, 183, 698,
2031 138, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 184, 186,
2032 189, 1177, 1177, 698, 698, 190, -472, -17, -472, -472,
2033 -472, 1197, 1197, 1197, 1197, 1197, -472, -472, -24, -85,
2034 -472, -80, -472, 1197, 1197, 1197, 1197, 1197, -472, -472,
2035 -472, -472, -472, 1046, 277, -472, -472, 289, -27, 293,
2036 296, 191, 698, 314, 698, 1177, -472, 194, 698, 195,
2037 -472, -472, 200, 201, -472, -472, 698, 698, 698, -472,
2038 -472, 202, -472, 1177, 298, 324, -472, 140, 183, 203,
2039 211, 212, 224, 1197, -472, -472, -472, 225, 226, 230,
2040 295, 232, -472, -472, -472, 275, 233, -472, 698, 698,
2041 1177, 235, -472, 235, -472, 239, 698, 241, 1177, 1177,
2042 1177, -472, -472, -472, 1177, 698, -472, -472, -472, 215,
2043 1197, 1197, 1197, 1197, -472, 1197, 1197, 1197, 1177, 1197,
2044 329, -472, 310, 242, 223, 239, 240, 278, -472, -472,
2045 1177, 238, 698, -472, -472, -472, 247, -472, -472, 245,
2046 250, 246, 255, 254, 256, 257, 259, 262, -472, -472,
2047 318, 15, 337, -472, -472, 252, -472, 1197, -472, 1197,
2048 1197, -472, -472, -472, -472, -472, 698, -472, 818, 65,
2049 371, -472, 265, 267, 268, -472, 272, -472, 818, 698,
2050 -472, -472, -472, 378, 274, 328, 698, 384, 385, -472,
2051 698, 698, -472, -472
Reid Spencer3822ff52006-11-08 06:47:33 +00002052};
2053
2054/* YYPGOTO[NTERM-NUM]. */
2055static const short int yypgoto[] =
2056{
Reid Spencer3da59db2006-11-27 01:05:10 +00002057 -472, -472, -472, 311, 312, 313, 315, 317, -129, -127,
2058 -471, -472, 370, 392, -120, -472, -237, 50, -472, -253,
2059 -472, -49, -472, -37, -472, -67, 301, -472, -110, 220,
2060 -263, 64, -472, -472, -472, -472, -472, -472, -472, 373,
2061 -472, -472, -472, -472, 2, -472, 70, -472, -472, 374,
2062 -472, -472, -472, -472, -472, 441, -472, -472, -418, 34,
2063 31, -115, -472, 426, -472, -472, -472, -472, -472, 63,
2064 3, -472, -472, 38, -472, -472
Reid Spencer3822ff52006-11-08 06:47:33 +00002065};
2066
2067/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2068 positive, shift that token. If negative, reduce the rule which
2069 number is the opposite. If zero, do what YYDEFACT says.
2070 If YYTABLE_NINF, syntax error. */
Reid Spencer3da59db2006-11-27 01:05:10 +00002071#define YYTABLE_NINF -145
Reid Spencer3822ff52006-11-08 06:47:33 +00002072static const short int yytable[] =
2073{
Reid Spencer3da59db2006-11-27 01:05:10 +00002074 89, 239, 215, 240, 106, 26, 94, 327, 382, 384,
2075 225, 242, 39, 228, 349, 350, 89, 404, 119, 42,
2076 508, 229, 359, 361, 4, 231, 232, 233, 234, 235,
2077 236, 237, 238, 230, 46, 47, 48, 218, 518, 245,
2078 405, 413, 368, 26, 262, 263, 413, 219, 29, 415,
2079 383, 383, 378, 49, 249, 119, 416, -82, 250, 251,
2080 252, 253, 254, 255, 264, 261, 123, 259, 260, 39,
2081 265, 53, 197, 198, 199, 231, 232, 233, 234, 235,
2082 236, 237, 238, 370, 51, 59, 123, 60, 224, 121,
2083 516, 224, 7, 8, 9, 10, 54, 12, 55, 413,
2084 524, 56, 413, 20, 369, 21, 52, 427, 414, 123,
2085 107, 108, 95, 190, 191, 243, 244, 224, 246, 110,
2086 111, 112, 269, 270, 58, 43, -42, -42, -41, -41,
2087 62, 247, 224, -40, -40, 64, 224, 224, 224, 224,
2088 224, 224, 256, 257, 258, 224, 224, 507, 345, 296,
2089 297, 298, -39, -39, 448, 99, 65, 66, 100, 117,
2090 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2091 78, 79, 80, 20, 101, 21, 30, 31, 32, 33,
2092 34, 35, 36, 300, 271, 272, 102, 103, 221, 114,
2093 -83, 115, 116, 323, 468, 122, 469, 517, 189, 81,
2094 193, 194, 195, 216, 217, 89, 226, 220, -46, -45,
2095 -44, -43, 343, 274, 304, -49, 389, -50, 391, 392,
2096 393, 275, 305, 324, 89, 344, 224, 400, 231, 232,
2097 233, 234, 235, 236, 237, 238, 326, 298, 329, 330,
2098 331, 408, 409, 410, 411, 412, 332, 333, 294, 341,
2099 334, 346, 335, 417, 418, 419, 420, 421, 318, 336,
2100 320, 321, 337, 318, 318, 342, 347, 362, 388, 351,
2101 352, 353, 322, 354, 355, 318, 363, 328, 82, 373,
2102 318, 83, 364, 365, 84, 366, 85, 338, 339, 340,
2103 318, 318, 318, 367, 224, 390, 224, 224, 224, 394,
2104 395, 374, 371, 454, 399, 224, 379, 376, 380, 385,
2105 396, 404, 397, 426, 428, 398, 403, 429, 432, 430,
2106 436, 438, 446, 473, 474, 475, 439, 440, 447, 450,
2107 444, 458, 460, 488, 489, 383, 300, 451, 452, 506,
2108 479, 480, 481, 482, 478, 483, 484, 485, 224, 487,
2109 453, 455, 456, 491, 381, 493, 457, 318, 459, 462,
2110 387, 467, 239, 318, 240, 470, 445, 472, 490, 492,
2111 494, 497, 499, 510, 401, 402, 496, 318, 318, 498,
2112 239, 500, 240, 501, 511, 502, 503, 512, 504, 513,
2113 514, 505, 519, 224, 520, -144, 521, 522, 523, 526,
2114 527, 224, 224, 224, 528, 530, 531, 224, 179, 180,
2115 181, 97, 182, 431, 183, 433, 318, 57, 318, 437,
2116 5, 486, 318, 222, 424, 105, 6, 441, 442, 443,
2117 318, 318, 318, 224, 293, 113, 7, 8, 9, 10,
2118 11, 12, 13, 423, 27, 45, 449, 476, 435, 0,
2119 0, 0, 0, 0, 0, 0, 0, 14, 0, 463,
2120 464, 0, 318, 318, 0, 0, 0, 471, 0, 0,
2121 318, 0, 0, 0, 0, 0, 477, 0, 0, 318,
Reid Spencer3822ff52006-11-08 06:47:33 +00002122 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00002123 0, 0, 0, 65, 66, 0, 0, 0, 0, 0,
2124 0, 0, 0, 495, 0, 0, 318, 0, 0, 0,
2125 20, 0, 21, 0, 276, 0, 0, 0, 0, 0,
2126 0, -52, 0, 20, 0, 21, 277, 278, 0, 0,
2127 0, 0, 6, -52, -52, 0, 0, 515, 0, 0,
2128 318, 0, -52, -52, -52, -52, -52, -52, -52, 0,
2129 525, -52, 22, 318, 0, 0, 0, 529, 0, 23,
2130 318, 532, 533, 24, 318, 318, 134, 135, 136, 137,
2131 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2132 148, 149, 150, 151, 0, 0, 0, 0, 0, 279,
2133 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
2134 166, 167, 0, 280, 170, 171, 172, 0, 281, 282,
2135 283, 0, 0, 0, 0, 0, 0, 0, 284, 0,
2136 0, 285, 0, 286, 65, 66, 287, 117, 68, 69,
2137 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2138 80, 20, 0, 21, 65, 66, 0, 117, 200, 201,
2139 202, 203, 204, 205, 206, 207, 208, 209, 210, 79,
2140 80, 20, 0, 21, 0, 0, 0, 81, 0, 0,
2141 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2142 0, 0, 0, 0, 0, 0, 0, 81, 0, 0,
2143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2144 0, 306, 307, 65, 66, 308, 0, 0, 0, 0,
2145 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2146 20, 0, 21, 0, 309, 310, 311, 0, 0, 0,
2147 0, 0, 0, 0, 0, 0, 312, 313, 0, 0,
2148 0, 0, 0, 0, 0, 0, 82, 0, 0, 83,
2149 0, 0, 84, 0, 85, 118, 0, 0, 0, 314,
2150 0, 0, 0, 0, 0, 0, 82, 0, 0, 83,
2151 0, 0, 84, 0, 85, 360, 134, 135, 136, 137,
2152 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2153 148, 149, 150, 151, 0, 0, 0, 0, 0, 279,
2154 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
2155 166, 167, 0, 280, 170, 171, 172, 0, 281, 282,
2156 283, 306, 307, 0, 0, 308, 0, 0, 0, 0,
2157 0, 315, 0, 0, 0, 0, 0, 0, 0, 0,
2158 0, 0, 0, 0, 309, 310, 311, 0, 0, 0,
2159 0, 0, 0, 0, 0, 0, 312, 313, 0, 0,
2160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2161 0, 0, 0, 0, 0, 0, 0, 0, 0, 314,
2162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00002163 0, 0, 0, 0, 0, 0, 134, 135, 136, 137,
2164 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
Reid Spencer3da59db2006-11-27 01:05:10 +00002165 148, 149, 150, 151, 0, 0, 0, 0, 0, 279,
2166 156, 157, 158, 159, 160, 161, 162, 163, 164, 165,
2167 166, 167, 0, 280, 170, 171, 172, 0, 281, 282,
2168 283, 0, 0, 0, 0, 0, 0, 0, 0, 65,
2169 66, 315, 117, 68, 69, 70, 71, 72, 73, 74,
Reid Spencer3822ff52006-11-08 06:47:33 +00002170 75, 76, 77, 78, 79, 80, 20, 0, 21, 0,
2171 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00002172 0, 299, 0, 0, 0, 0, 0, 0, 0, 0,
2173 65, 66, 81, 117, 200, 201, 202, 203, 204, 205,
2174 206, 207, 208, 209, 210, 79, 80, 20, 0, 21,
2175 65, 66, 0, 117, 68, 69, 70, 71, 72, 73,
2176 74, 75, 76, 77, 78, 79, 80, 20, 0, 21,
2177 0, 0, 0, 81, 0, 0, 0, 0, 0, 0,
2178 0, 0, 375, 0, 0, 0, 0, 0, 0, 0,
2179 0, 65, 66, 81, 117, 68, 69, 70, 71, 72,
2180 73, 74, 75, 76, 77, 78, 79, 80, 20, 0,
2181 21, 82, 0, 0, 83, 0, 0, 84, 0, 85,
2182 0, 0, 0, 422, 0, 0, 0, 0, 0, 0,
2183 0, 0, 0, 0, 81, 0, 0, 0, 0, 0,
Reid Spencer3822ff52006-11-08 06:47:33 +00002184 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3da59db2006-11-27 01:05:10 +00002185 0, 0, 82, 0, 0, 83, 0, 356, 84, 0,
2186 85, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2187 0, 0, 82, 0, 0, 83, 0, 0, 84, 0,
2188 85, 65, 66, 0, 67, 68, 69, 70, 71, 72,
2189 73, 74, 75, 76, 77, 78, 79, 80, 20, 0,
2190 21, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2191 0, 0, 0, 82, 0, 0, 83, 0, 0, 84,
2192 0, 85, 65, 66, 81, 117, 68, 69, 70, 71,
2193 72, 73, 74, 75, 76, 77, 78, 79, 80, 20,
2194 0, 21, 65, 66, 0, 117, 200, 201, 202, 203,
2195 204, 205, 206, 207, 208, 209, 210, 79, 80, 20,
2196 0, 21, 0, 0, 0, 81, 0, 65, 66, 0,
2197 227, 68, 69, 70, 71, 72, 73, 74, 75, 76,
2198 77, 78, 79, 80, 20, 81, 21, 0, 0, 0,
2199 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2200 0, 0, 0, 82, 0, 0, 83, 0, 0, 84,
2201 81, 85, 0, 0, 0, 0, 0, 0, 0, 0,
2202 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2203 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2204 0, 0, 0, 0, 82, 0, 0, 83, 0, 0,
2205 84, 0, 85, 0, 0, 0, 0, 0, 0, 0,
2206 0, 124, 0, 0, 82, 0, 0, 83, 0, 0,
2207 84, 0, 85, 0, 0, 125, 0, 0, 0, 0,
2208 0, 0, 0, 0, 0, 126, 127, 0, 0, 82,
2209 0, 0, 83, 0, 0, 84, 0, 85, 128, 129,
2210 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
2211 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2212 150, 151, 152, 153, 154, 0, 0, 155, 156, 157,
2213 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
2214 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
2215 178
Reid Spencer3822ff52006-11-08 06:47:33 +00002216};
2217
2218static const short int yycheck[] =
2219{
Reid Spencer3da59db2006-11-27 01:05:10 +00002220 37, 130, 112, 130, 53, 3, 29, 244, 15, 15,
2221 125, 131, 23, 128, 267, 268, 53, 34, 85, 30,
2222 491, 9, 285, 286, 0, 10, 11, 12, 13, 14,
2223 15, 16, 17, 21, 52, 53, 54, 126, 509, 154,
2224 57, 126, 295, 41, 99, 100, 126, 136, 61, 134,
2225 57, 57, 315, 71, 169, 122, 136, 128, 173, 174,
2226 175, 176, 177, 178, 126, 185, 137, 182, 183, 23,
2227 132, 20, 109, 110, 111, 10, 11, 12, 13, 14,
2228 15, 16, 17, 134, 125, 45, 137, 47, 125, 87,
2229 508, 128, 41, 42, 43, 44, 45, 46, 47, 126,
2230 518, 50, 126, 22, 132, 24, 61, 134, 132, 137,
2231 32, 33, 135, 55, 56, 152, 153, 154, 155, 55,
2232 56, 57, 27, 28, 125, 136, 3, 4, 3, 4,
2233 24, 168, 169, 3, 4, 4, 173, 174, 175, 176,
2234 177, 178, 179, 180, 181, 182, 183, 132, 263, 216,
2235 217, 218, 3, 4, 407, 125, 5, 6, 125, 8,
2236 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2237 19, 20, 21, 22, 125, 24, 64, 65, 66, 67,
2238 68, 69, 70, 220, 3, 4, 125, 130, 37, 4,
2239 128, 4, 4, 242, 431, 128, 433, 132, 24, 48,
2240 4, 24, 24, 131, 131, 242, 59, 128, 4, 4,
2241 4, 4, 261, 4, 126, 7, 331, 7, 333, 334,
2242 335, 7, 129, 126, 261, 262, 263, 342, 10, 11,
2243 12, 13, 14, 15, 16, 17, 126, 304, 130, 126,
2244 126, 351, 352, 353, 354, 355, 126, 126, 214, 36,
2245 126, 24, 126, 363, 364, 365, 366, 367, 224, 126,
2246 229, 230, 126, 229, 230, 126, 126, 24, 130, 128,
2247 128, 128, 241, 128, 128, 241, 128, 246, 127, 126,
2248 246, 130, 128, 128, 133, 128, 135, 256, 257, 258,
2249 256, 257, 258, 128, 331, 332, 333, 334, 335, 336,
2250 337, 129, 300, 413, 341, 342, 126, 63, 126, 126,
2251 126, 34, 126, 24, 21, 126, 126, 21, 4, 128,
2252 126, 126, 24, 438, 439, 440, 126, 126, 4, 126,
2253 128, 36, 57, 4, 24, 57, 373, 126, 126, 21,
2254 450, 451, 452, 453, 129, 455, 456, 457, 385, 459,
2255 126, 126, 126, 130, 323, 470, 126, 323, 126, 126,
2256 329, 126, 491, 329, 491, 126, 403, 126, 126, 129,
2257 132, 126, 126, 36, 343, 344, 129, 343, 344, 129,
2258 509, 126, 509, 129, 132, 129, 129, 497, 129, 499,
2259 500, 129, 21, 430, 129, 0, 129, 129, 126, 21,
2260 126, 438, 439, 440, 76, 21, 21, 444, 97, 97,
2261 97, 41, 97, 382, 97, 384, 382, 25, 384, 388,
2262 25, 458, 388, 122, 374, 52, 31, 396, 397, 398,
2263 396, 397, 398, 470, 214, 61, 41, 42, 43, 44,
2264 45, 46, 47, 373, 3, 19, 408, 444, 385, -1,
2265 -1, -1, -1, -1, -1, -1, -1, 62, -1, 428,
2266 429, -1, 428, 429, -1, -1, -1, 436, -1, -1,
2267 436, -1, -1, -1, -1, -1, 445, -1, -1, 445,
Reid Spencer3822ff52006-11-08 06:47:33 +00002268 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002269 -1, -1, -1, 5, 6, -1, -1, -1, -1, -1,
2270 -1, -1, -1, 472, -1, -1, 472, -1, -1, -1,
2271 22, -1, 24, -1, 26, -1, -1, -1, -1, -1,
2272 -1, 20, -1, 22, -1, 24, 38, 39, -1, -1,
2273 -1, -1, 31, 32, 33, -1, -1, 506, -1, -1,
2274 506, -1, 41, 42, 43, 44, 45, 46, 47, -1,
2275 519, 50, 51, 519, -1, -1, -1, 526, -1, 58,
2276 526, 530, 531, 62, 530, 531, 78, 79, 80, 81,
2277 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2278 92, 93, 94, 95, -1, -1, -1, -1, -1, 101,
2279 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
2280 112, 113, -1, 115, 116, 117, 118, -1, 120, 121,
2281 122, -1, -1, -1, -1, -1, -1, -1, 130, -1,
2282 -1, 133, -1, 135, 5, 6, 138, 8, 9, 10,
2283 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2284 21, 22, -1, 24, 5, 6, -1, 8, 9, 10,
2285 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2286 21, 22, -1, 24, -1, -1, -1, 48, -1, -1,
2287 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2288 -1, -1, -1, -1, -1, -1, -1, 48, -1, -1,
2289 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2290 -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
2291 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2292 22, -1, 24, -1, 26, 27, 28, -1, -1, -1,
2293 -1, -1, -1, -1, -1, -1, 38, 39, -1, -1,
2294 -1, -1, -1, -1, -1, -1, 127, -1, -1, 130,
2295 -1, -1, 133, -1, 135, 136, -1, -1, -1, 61,
2296 -1, -1, -1, -1, -1, -1, 127, -1, -1, 130,
2297 -1, -1, 133, -1, 135, 136, 78, 79, 80, 81,
2298 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2299 92, 93, 94, 95, -1, -1, -1, -1, -1, 101,
2300 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
2301 112, 113, -1, 115, 116, 117, 118, -1, 120, 121,
2302 122, 3, 4, -1, -1, 7, -1, -1, -1, -1,
2303 -1, 133, -1, -1, -1, -1, -1, -1, -1, -1,
2304 -1, -1, -1, -1, 26, 27, 28, -1, -1, -1,
2305 -1, -1, -1, -1, -1, -1, 38, 39, -1, -1,
2306 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2307 -1, -1, -1, -1, -1, -1, -1, -1, -1, 61,
2308 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3822ff52006-11-08 06:47:33 +00002309 -1, -1, -1, -1, -1, -1, 78, 79, 80, 81,
2310 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2311 92, 93, 94, 95, -1, -1, -1, -1, -1, 101,
Reid Spencer3da59db2006-11-27 01:05:10 +00002312 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
2313 112, 113, -1, 115, 116, 117, 118, -1, 120, 121,
2314 122, -1, -1, -1, -1, -1, -1, -1, -1, 5,
2315 6, 133, 8, 9, 10, 11, 12, 13, 14, 15,
Reid Spencer3822ff52006-11-08 06:47:33 +00002316 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2317 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2318 -1, 37, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002319 5, 6, 48, 8, 9, 10, 11, 12, 13, 14,
2320 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
2321 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
2322 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
2323 -1, -1, -1, 48, -1, -1, -1, -1, -1, -1,
2324 -1, -1, 37, -1, -1, -1, -1, -1, -1, -1,
2325 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2326 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2327 24, 127, -1, -1, 130, -1, -1, 133, -1, 135,
2328 -1, -1, -1, 37, -1, -1, -1, -1, -1, -1,
2329 -1, -1, -1, -1, 48, -1, -1, -1, -1, -1,
Reid Spencer3822ff52006-11-08 06:47:33 +00002330 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3da59db2006-11-27 01:05:10 +00002331 -1, -1, 127, -1, -1, 130, -1, 132, 133, -1,
2332 135, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2333 -1, -1, 127, -1, -1, 130, -1, -1, 133, -1,
2334 135, 5, 6, -1, 8, 9, 10, 11, 12, 13,
2335 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2336 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2337 -1, -1, -1, 127, -1, -1, 130, -1, -1, 133,
2338 -1, 135, 5, 6, 48, 8, 9, 10, 11, 12,
2339 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
2340 -1, 24, 5, 6, -1, 8, 9, 10, 11, 12,
2341 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
2342 -1, 24, -1, -1, -1, 48, -1, 5, 6, -1,
2343 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2344 18, 19, 20, 21, 22, 48, 24, -1, -1, -1,
2345 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2346 -1, -1, -1, 127, -1, -1, 130, -1, -1, 133,
2347 48, 135, -1, -1, -1, -1, -1, -1, -1, -1,
2348 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2349 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2350 -1, -1, -1, -1, 127, -1, -1, 130, -1, -1,
2351 133, -1, 135, -1, -1, -1, -1, -1, -1, -1,
2352 -1, 35, -1, -1, 127, -1, -1, 130, -1, -1,
2353 133, -1, 135, -1, -1, 49, -1, -1, -1, -1,
2354 -1, -1, -1, -1, -1, 59, 60, -1, -1, 127,
2355 -1, -1, 130, -1, -1, 133, -1, 135, 72, 73,
2356 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2357 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2358 94, 95, 96, 97, 98, -1, -1, 101, 102, 103,
2359 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
2360 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
2361 124
Reid Spencer3822ff52006-11-08 06:47:33 +00002362};
2363
2364/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2365 symbol of state STATE-NUM. */
2366static const unsigned char yystos[] =
2367{
Reid Spencer3da59db2006-11-27 01:05:10 +00002368 0, 171, 172, 173, 0, 25, 31, 41, 42, 43,
2369 44, 45, 46, 47, 62, 152, 190, 192, 194, 201,
2370 22, 24, 51, 58, 62, 151, 183, 194, 195, 61,
2371 64, 65, 66, 67, 68, 69, 70, 153, 188, 23,
2372 202, 203, 30, 136, 191, 202, 52, 53, 54, 71,
2373 180, 125, 61, 20, 45, 47, 50, 152, 125, 45,
2374 47, 193, 24, 178, 4, 5, 6, 8, 9, 10,
Reid Spencer3822ff52006-11-08 06:47:33 +00002375 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Reid Spencer3da59db2006-11-27 01:05:10 +00002376 21, 48, 127, 130, 133, 135, 140, 160, 161, 162,
2377 163, 164, 183, 198, 29, 135, 189, 151, 206, 125,
2378 125, 125, 125, 130, 181, 178, 160, 32, 33, 170,
2379 170, 170, 170, 188, 4, 4, 4, 8, 136, 164,
2380 165, 183, 128, 137, 35, 49, 59, 60, 72, 73,
Reid Spencer3822ff52006-11-08 06:47:33 +00002381 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2382 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2383 94, 95, 96, 97, 98, 101, 102, 103, 104, 105,
Reid Spencer3da59db2006-11-27 01:05:10 +00002384 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
2385 116, 117, 118, 119, 120, 121, 122, 123, 124, 142,
2386 143, 144, 145, 146, 204, 210, 211, 213, 214, 24,
2387 55, 56, 179, 4, 24, 24, 182, 162, 162, 162,
2388 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2389 19, 147, 148, 150, 162, 167, 131, 131, 126, 136,
2390 128, 37, 165, 166, 162, 200, 59, 8, 200, 9,
2391 21, 10, 11, 12, 13, 14, 15, 16, 17, 147,
2392 148, 149, 153, 162, 162, 200, 162, 162, 207, 200,
2393 200, 200, 200, 200, 200, 200, 162, 162, 162, 200,
2394 200, 153, 99, 100, 126, 132, 176, 177, 175, 27,
2395 28, 3, 4, 141, 4, 7, 26, 38, 39, 101,
2396 115, 120, 121, 122, 130, 133, 135, 138, 142, 143,
2397 144, 145, 146, 168, 198, 174, 164, 164, 164, 37,
2398 162, 185, 186, 187, 126, 129, 3, 4, 7, 26,
2399 27, 28, 38, 39, 61, 133, 168, 197, 198, 199,
2400 199, 199, 199, 160, 126, 155, 126, 155, 199, 130,
2401 126, 126, 126, 126, 126, 126, 126, 126, 199, 199,
2402 199, 36, 126, 160, 162, 200, 24, 126, 158, 158,
2403 158, 128, 128, 128, 128, 128, 132, 167, 169, 169,
2404 136, 169, 24, 128, 128, 128, 128, 128, 158, 132,
2405 134, 183, 184, 126, 129, 37, 63, 196, 169, 126,
2406 126, 199, 15, 57, 15, 126, 212, 199, 130, 200,
2407 162, 200, 200, 200, 162, 162, 126, 126, 126, 162,
2408 200, 199, 199, 126, 34, 57, 156, 159, 167, 167,
2409 167, 167, 167, 126, 132, 134, 136, 167, 167, 167,
2410 167, 167, 37, 185, 156, 157, 24, 134, 21, 21,
2411 128, 199, 4, 199, 200, 208, 126, 199, 126, 126,
2412 126, 199, 199, 199, 128, 162, 24, 4, 158, 212,
2413 126, 126, 126, 126, 167, 126, 126, 126, 36, 126,
2414 57, 154, 126, 199, 199, 208, 209, 126, 155, 155,
2415 126, 199, 126, 200, 200, 200, 209, 199, 129, 167,
2416 167, 167, 167, 167, 167, 167, 162, 167, 4, 24,
2417 126, 130, 129, 200, 132, 199, 129, 126, 129, 126,
2418 126, 129, 129, 129, 129, 129, 21, 132, 149, 205,
2419 36, 132, 167, 167, 167, 199, 197, 132, 149, 21,
2420 129, 129, 129, 126, 197, 199, 21, 126, 76, 199,
2421 21, 21, 199, 199
Reid Spencer3822ff52006-11-08 06:47:33 +00002422};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002423
2424#define yyerrok (yyerrstatus = 0)
2425#define yyclearin (yychar = YYEMPTY)
Reid Spencer3822ff52006-11-08 06:47:33 +00002426#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002427#define YYEOF 0
Reid Spencer3822ff52006-11-08 06:47:33 +00002428
Reid Spencer68a24bd2005-08-27 18:50:39 +00002429#define YYACCEPT goto yyacceptlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002430#define YYABORT goto yyabortlab
2431#define YYERROR goto yyerrorlab
2432
2433
2434/* Like YYERROR except do call yyerror. This remains here temporarily
2435 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002436 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002437
Reid Spencer68a24bd2005-08-27 18:50:39 +00002438#define YYFAIL goto yyerrlab
Reid Spencer3822ff52006-11-08 06:47:33 +00002439
Reid Spencer68a24bd2005-08-27 18:50:39 +00002440#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer3822ff52006-11-08 06:47:33 +00002441
2442#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002443do \
2444 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer3822ff52006-11-08 06:47:33 +00002445 { \
2446 yychar = (Token); \
2447 yylval = (Value); \
2448 yytoken = YYTRANSLATE (yychar); \
Reid Spencer5b7e7532006-09-28 19:28:24 +00002449 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002450 goto yybackup; \
2451 } \
2452 else \
Reid Spencer3822ff52006-11-08 06:47:33 +00002453 { \
2454 yyerror (YY_("syntax error: cannot back up")); \
2455 YYERROR; \
2456 } \
Reid Spencer5b7e7532006-09-28 19:28:24 +00002457while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002458
Reid Spencer3822ff52006-11-08 06:47:33 +00002459
Reid Spencer68a24bd2005-08-27 18:50:39 +00002460#define YYTERROR 1
2461#define YYERRCODE 256
2462
Reid Spencer3822ff52006-11-08 06:47:33 +00002463
2464/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2465 If N is 0, then set CURRENT to the empty location which ends
2466 the previous symbol: RHS[0] (always defined). */
2467
2468#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2469#ifndef YYLLOC_DEFAULT
2470# define YYLLOC_DEFAULT(Current, Rhs, N) \
2471 do \
2472 if (N) \
2473 { \
2474 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2475 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2476 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2477 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2478 } \
2479 else \
2480 { \
2481 (Current).first_line = (Current).last_line = \
2482 YYRHSLOC (Rhs, 0).last_line; \
2483 (Current).first_column = (Current).last_column = \
2484 YYRHSLOC (Rhs, 0).last_column; \
2485 } \
2486 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002487#endif
2488
Reid Spencer3822ff52006-11-08 06:47:33 +00002489
2490/* YY_LOCATION_PRINT -- Print the location on the stream.
2491 This macro was not mandated originally: define only if we know
2492 we won't break user code: when these are the locations we know. */
2493
2494#ifndef YY_LOCATION_PRINT
2495# if YYLTYPE_IS_TRIVIAL
2496# define YY_LOCATION_PRINT(File, Loc) \
2497 fprintf (File, "%d.%d-%d.%d", \
2498 (Loc).first_line, (Loc).first_column, \
2499 (Loc).last_line, (Loc).last_column)
2500# else
2501# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2502# endif
2503#endif
2504
2505
2506/* YYLEX -- calling `yylex' with the right arguments. */
2507
Reid Spencer68a24bd2005-08-27 18:50:39 +00002508#ifdef YYLEX_PARAM
Reid Spencer3822ff52006-11-08 06:47:33 +00002509# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002510#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002511# define YYLEX yylex ()
Chris Lattnerf49c1762006-11-08 05:58:47 +00002512#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002513
2514/* Enable debugging if requested. */
2515#if YYDEBUG
2516
2517# ifndef YYFPRINTF
2518# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2519# define YYFPRINTF fprintf
2520# endif
2521
2522# define YYDPRINTF(Args) \
2523do { \
2524 if (yydebug) \
2525 YYFPRINTF Args; \
2526} while (0)
2527
2528# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2529do { \
2530 if (yydebug) \
2531 { \
2532 YYFPRINTF (stderr, "%s ", Title); \
2533 yysymprint (stderr, \
2534 Type, Value); \
2535 YYFPRINTF (stderr, "\n"); \
2536 } \
2537} while (0)
2538
2539/*------------------------------------------------------------------.
2540| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2541| TOP (included). |
2542`------------------------------------------------------------------*/
2543
2544#if defined (__STDC__) || defined (__cplusplus)
2545static void
2546yy_stack_print (short int *bottom, short int *top)
Chris Lattnerf49c1762006-11-08 05:58:47 +00002547#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002548static void
2549yy_stack_print (bottom, top)
2550 short int *bottom;
2551 short int *top;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002552#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002553{
2554 YYFPRINTF (stderr, "Stack now");
2555 for (/* Nothing. */; bottom <= top; ++bottom)
2556 YYFPRINTF (stderr, " %d", *bottom);
2557 YYFPRINTF (stderr, "\n");
2558}
2559
2560# define YY_STACK_PRINT(Bottom, Top) \
2561do { \
2562 if (yydebug) \
2563 yy_stack_print ((Bottom), (Top)); \
2564} while (0)
2565
2566
2567/*------------------------------------------------.
2568| Report that the YYRULE is going to be reduced. |
2569`------------------------------------------------*/
2570
2571#if defined (__STDC__) || defined (__cplusplus)
2572static void
2573yy_reduce_print (int yyrule)
2574#else
2575static void
2576yy_reduce_print (yyrule)
2577 int yyrule;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002578#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002579{
2580 int yyi;
2581 unsigned long int yylno = yyrline[yyrule];
2582 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2583 yyrule - 1, yylno);
2584 /* Print the symbols being reduced, and their result. */
2585 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2586 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2587 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2588}
Reid Spencer21be8652006-10-22 07:03:43 +00002589
Reid Spencer3822ff52006-11-08 06:47:33 +00002590# define YY_REDUCE_PRINT(Rule) \
2591do { \
2592 if (yydebug) \
2593 yy_reduce_print (Rule); \
2594} while (0)
Reid Spencer21be8652006-10-22 07:03:43 +00002595
Reid Spencer3822ff52006-11-08 06:47:33 +00002596/* Nonzero means print parse trace. It is left uninitialized so that
2597 multiple parsers can coexist. */
2598int yydebug;
2599#else /* !YYDEBUG */
2600# define YYDPRINTF(Args)
2601# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2602# define YY_STACK_PRINT(Bottom, Top)
2603# define YY_REDUCE_PRINT(Rule)
2604#endif /* !YYDEBUG */
Reid Spencer21be8652006-10-22 07:03:43 +00002605
Reid Spencer21be8652006-10-22 07:03:43 +00002606
Reid Spencer3822ff52006-11-08 06:47:33 +00002607/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002608#ifndef YYINITDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002609# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002610#endif
2611
Reid Spencer3822ff52006-11-08 06:47:33 +00002612/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2613 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002614
Reid Spencer3822ff52006-11-08 06:47:33 +00002615 Do not make this value too large; the results are undefined if
2616 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2617 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002618
2619#ifndef YYMAXDEPTH
Reid Spencer3822ff52006-11-08 06:47:33 +00002620# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002621#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00002622
Reid Spencer68a24bd2005-08-27 18:50:39 +00002623
2624
Reid Spencer3822ff52006-11-08 06:47:33 +00002625#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002626
Reid Spencer3822ff52006-11-08 06:47:33 +00002627# ifndef yystrlen
2628# if defined (__GLIBC__) && defined (_STRING_H)
2629# define yystrlen strlen
2630# else
2631/* Return the length of YYSTR. */
2632static YYSIZE_T
2633# if defined (__STDC__) || defined (__cplusplus)
2634yystrlen (const char *yystr)
2635# else
2636yystrlen (yystr)
2637 const char *yystr;
2638# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002639{
Reid Spencer3822ff52006-11-08 06:47:33 +00002640 const char *yys = yystr;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002641
Reid Spencer3822ff52006-11-08 06:47:33 +00002642 while (*yys++ != '\0')
2643 continue;
2644
2645 return yys - yystr - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002646}
Reid Spencer3822ff52006-11-08 06:47:33 +00002647# endif
2648# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002649
Reid Spencer3822ff52006-11-08 06:47:33 +00002650# ifndef yystpcpy
2651# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2652# define yystpcpy stpcpy
2653# else
2654/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2655 YYDEST. */
2656static char *
2657# if defined (__STDC__) || defined (__cplusplus)
2658yystpcpy (char *yydest, const char *yysrc)
2659# else
2660yystpcpy (yydest, yysrc)
2661 char *yydest;
2662 const char *yysrc;
2663# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002664{
Reid Spencer3822ff52006-11-08 06:47:33 +00002665 char *yyd = yydest;
2666 const char *yys = yysrc;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002667
Reid Spencer3822ff52006-11-08 06:47:33 +00002668 while ((*yyd++ = *yys++) != '\0')
2669 continue;
2670
2671 return yyd - 1;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002672}
Reid Spencer3822ff52006-11-08 06:47:33 +00002673# endif
2674# endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002675
Reid Spencer3822ff52006-11-08 06:47:33 +00002676# ifndef yytnamerr
2677/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2678 quotes and backslashes, so that it's suitable for yyerror. The
2679 heuristic is that double-quoting is unnecessary unless the string
2680 contains an apostrophe, a comma, or backslash (other than
2681 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2682 null, do not copy; instead, return the length of what the result
2683 would have been. */
2684static YYSIZE_T
2685yytnamerr (char *yyres, const char *yystr)
2686{
2687 if (*yystr == '"')
2688 {
2689 size_t yyn = 0;
2690 char const *yyp = yystr;
2691
2692 for (;;)
2693 switch (*++yyp)
2694 {
2695 case '\'':
2696 case ',':
2697 goto do_not_strip_quotes;
2698
2699 case '\\':
2700 if (*++yyp != '\\')
2701 goto do_not_strip_quotes;
2702 /* Fall through. */
2703 default:
2704 if (yyres)
2705 yyres[yyn] = *yyp;
2706 yyn++;
2707 break;
2708
2709 case '"':
2710 if (yyres)
2711 yyres[yyn] = '\0';
2712 return yyn;
2713 }
2714 do_not_strip_quotes: ;
2715 }
2716
2717 if (! yyres)
2718 return yystrlen (yystr);
2719
2720 return yystpcpy (yyres, yystr) - yyres;
2721}
2722# endif
2723
2724#endif /* YYERROR_VERBOSE */
2725
Reid Spencer21be8652006-10-22 07:03:43 +00002726
2727
Reid Spencer3822ff52006-11-08 06:47:33 +00002728#if YYDEBUG
2729/*--------------------------------.
2730| Print this symbol on YYOUTPUT. |
2731`--------------------------------*/
Reid Spencer21be8652006-10-22 07:03:43 +00002732
Reid Spencer3822ff52006-11-08 06:47:33 +00002733#if defined (__STDC__) || defined (__cplusplus)
2734static void
2735yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattnerf49c1762006-11-08 05:58:47 +00002736#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002737static void
2738yysymprint (yyoutput, yytype, yyvaluep)
2739 FILE *yyoutput;
2740 int yytype;
2741 YYSTYPE *yyvaluep;
2742#endif
2743{
2744 /* Pacify ``unused variable'' warnings. */
2745 (void) yyvaluep;
2746
2747 if (yytype < YYNTOKENS)
2748 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2749 else
2750 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2751
2752
2753# ifdef YYPRINT
2754 if (yytype < YYNTOKENS)
2755 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2756# endif
2757 switch (yytype)
2758 {
2759 default:
2760 break;
2761 }
2762 YYFPRINTF (yyoutput, ")");
2763}
2764
2765#endif /* ! YYDEBUG */
2766/*-----------------------------------------------.
2767| Release the memory associated to this symbol. |
2768`-----------------------------------------------*/
2769
2770#if defined (__STDC__) || defined (__cplusplus)
2771static void
2772yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2773#else
2774static void
2775yydestruct (yymsg, yytype, yyvaluep)
2776 const char *yymsg;
2777 int yytype;
2778 YYSTYPE *yyvaluep;
2779#endif
2780{
2781 /* Pacify ``unused variable'' warnings. */
2782 (void) yyvaluep;
2783
2784 if (!yymsg)
2785 yymsg = "Deleting";
2786 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2787
2788 switch (yytype)
2789 {
2790
2791 default:
2792 break;
2793 }
2794}
2795
2796
2797/* Prevent warnings from -Wmissing-prototypes. */
2798
2799#ifdef YYPARSE_PARAM
2800# if defined (__STDC__) || defined (__cplusplus)
2801int yyparse (void *YYPARSE_PARAM);
2802# else
2803int yyparse ();
2804# endif
2805#else /* ! YYPARSE_PARAM */
2806#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002807int yyparse (void);
Chris Lattnerf49c1762006-11-08 05:58:47 +00002808#else
Reid Spencer3822ff52006-11-08 06:47:33 +00002809int yyparse ();
2810#endif
2811#endif /* ! YYPARSE_PARAM */
2812
2813
2814
2815/* The look-ahead symbol. */
2816int yychar;
2817
2818/* The semantic value of the look-ahead symbol. */
2819YYSTYPE yylval;
2820
2821/* Number of syntax errors so far. */
2822int yynerrs;
2823
2824
2825
2826/*----------.
2827| yyparse. |
2828`----------*/
2829
2830#ifdef YYPARSE_PARAM
2831# if defined (__STDC__) || defined (__cplusplus)
2832int yyparse (void *YYPARSE_PARAM)
2833# else
2834int yyparse (YYPARSE_PARAM)
2835 void *YYPARSE_PARAM;
2836# endif
2837#else /* ! YYPARSE_PARAM */
2838#if defined (__STDC__) || defined (__cplusplus)
2839int
2840yyparse (void)
2841#else
2842int
2843yyparse ()
2844
2845#endif
2846#endif
2847{
2848
2849 int yystate;
2850 int yyn;
2851 int yyresult;
2852 /* Number of tokens to shift before error messages enabled. */
2853 int yyerrstatus;
2854 /* Look-ahead token as an internal (translated) token number. */
2855 int yytoken = 0;
2856
2857 /* Three stacks and their tools:
2858 `yyss': related to states,
2859 `yyvs': related to semantic values,
2860 `yyls': related to locations.
2861
2862 Refer to the stacks thru separate pointers, to allow yyoverflow
2863 to reallocate them elsewhere. */
2864
2865 /* The state stack. */
2866 short int yyssa[YYINITDEPTH];
2867 short int *yyss = yyssa;
2868 short int *yyssp;
2869
2870 /* The semantic value stack. */
2871 YYSTYPE yyvsa[YYINITDEPTH];
2872 YYSTYPE *yyvs = yyvsa;
2873 YYSTYPE *yyvsp;
2874
2875
2876
Reid Spencer5b7e7532006-09-28 19:28:24 +00002877#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002878
Reid Spencer3822ff52006-11-08 06:47:33 +00002879 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002880
Reid Spencer3822ff52006-11-08 06:47:33 +00002881 /* The variables used to return semantic value and location from the
2882 action routines. */
2883 YYSTYPE yyval;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002884
2885
Reid Spencer3822ff52006-11-08 06:47:33 +00002886 /* When reducing, the number of symbols on the RHS of the reduced
2887 rule. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002888 int yylen;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002889
Reid Spencer3822ff52006-11-08 06:47:33 +00002890 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002891
Reid Spencer68a24bd2005-08-27 18:50:39 +00002892 yystate = 0;
2893 yyerrstatus = 0;
2894 yynerrs = 0;
2895 yychar = YYEMPTY; /* Cause a token to be read. */
2896
2897 /* Initialize stack pointers.
2898 Waste one element of value and location stack
2899 so that they stay on the same level as the state stack.
2900 The wasted elements are never initialized. */
2901
Reid Spencer3822ff52006-11-08 06:47:33 +00002902 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002903 yyvsp = yyvs;
2904
Reid Spencer3822ff52006-11-08 06:47:33 +00002905 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002906
Reid Spencer3822ff52006-11-08 06:47:33 +00002907/*------------------------------------------------------------.
2908| yynewstate -- Push a new state, which is found in yystate. |
2909`------------------------------------------------------------*/
2910 yynewstate:
2911 /* In all cases, when you get here, the value and location stacks
2912 have just been pushed. so pushing a state here evens the stacks.
2913 */
2914 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002915
Reid Spencer3822ff52006-11-08 06:47:33 +00002916 yysetstate:
2917 *yyssp = yystate;
2918
2919 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002920 {
2921 /* Get the current used size of the three stacks, in elements. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002922 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002923
2924#ifdef yyoverflow
Reid Spencer3822ff52006-11-08 06:47:33 +00002925 {
2926 /* Give user a chance to reallocate the stack. Use copies of
2927 these so that the &'s don't force the real ones into
2928 memory. */
2929 YYSTYPE *yyvs1 = yyvs;
2930 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002931
Reid Spencer3822ff52006-11-08 06:47:33 +00002932
2933 /* Each stack pointer address is followed by the size of the
2934 data in use in that stack, in bytes. This used to be a
2935 conditional around just the two extra args, but that might
2936 be undefined if yyoverflow is a macro. */
2937 yyoverflow (YY_("memory exhausted"),
2938 &yyss1, yysize * sizeof (*yyssp),
2939 &yyvs1, yysize * sizeof (*yyvsp),
2940
2941 &yystacksize);
2942
2943 yyss = yyss1;
2944 yyvs = yyvs1;
2945 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002946#else /* no yyoverflow */
Reid Spencer3822ff52006-11-08 06:47:33 +00002947# ifndef YYSTACK_RELOCATE
2948 goto yyexhaustedlab;
2949# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002950 /* Extend the stack our own way. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002951 if (YYMAXDEPTH <= yystacksize)
2952 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002953 yystacksize *= 2;
Reid Spencer3822ff52006-11-08 06:47:33 +00002954 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002955 yystacksize = YYMAXDEPTH;
Reid Spencer3822ff52006-11-08 06:47:33 +00002956
2957 {
2958 short int *yyss1 = yyss;
2959 union yyalloc *yyptr =
2960 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2961 if (! yyptr)
2962 goto yyexhaustedlab;
2963 YYSTACK_RELOCATE (yyss);
2964 YYSTACK_RELOCATE (yyvs);
2965
2966# undef YYSTACK_RELOCATE
2967 if (yyss1 != yyssa)
2968 YYSTACK_FREE (yyss1);
2969 }
2970# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002971#endif /* no yyoverflow */
2972
Reid Spencer3822ff52006-11-08 06:47:33 +00002973 yyssp = yyss + yysize - 1;
2974 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002975
2976
Reid Spencer3822ff52006-11-08 06:47:33 +00002977 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2978 (unsigned long int) yystacksize));
2979
2980 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002981 YYABORT;
2982 }
2983
Reid Spencer3822ff52006-11-08 06:47:33 +00002984 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002985
2986 goto yybackup;
Reid Spencer3822ff52006-11-08 06:47:33 +00002987
2988/*-----------.
2989| yybackup. |
2990`-----------*/
2991yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002992
Reid Spencer5b7e7532006-09-28 19:28:24 +00002993/* Do appropriate processing given the current state. */
Reid Spencer3822ff52006-11-08 06:47:33 +00002994/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002995/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002996
Reid Spencer3822ff52006-11-08 06:47:33 +00002997 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002998
Reid Spencer68a24bd2005-08-27 18:50:39 +00002999 yyn = yypact[yystate];
Reid Spencer3822ff52006-11-08 06:47:33 +00003000 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003001 goto yydefault;
3002
Reid Spencer3822ff52006-11-08 06:47:33 +00003003 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003004
Reid Spencer3822ff52006-11-08 06:47:33 +00003005 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003006 if (yychar == YYEMPTY)
3007 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003008 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003009 yychar = YYLEX;
3010 }
3011
Reid Spencer3822ff52006-11-08 06:47:33 +00003012 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003013 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003014 yychar = yytoken = YYEOF;
3015 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003016 }
3017 else
3018 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003019 yytoken = YYTRANSLATE (yychar);
3020 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003021 }
3022
Reid Spencer3822ff52006-11-08 06:47:33 +00003023 /* If the proper action on seeing token YYTOKEN is to reduce or to
3024 detect an error, take that action. */
3025 yyn += yytoken;
3026 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003027 goto yydefault;
3028 yyn = yytable[yyn];
Reid Spencer3822ff52006-11-08 06:47:33 +00003029 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003030 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003031 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003032 goto yyerrlab;
3033 yyn = -yyn;
3034 goto yyreduce;
3035 }
3036
3037 if (yyn == YYFINAL)
3038 YYACCEPT;
3039
Reid Spencer3822ff52006-11-08 06:47:33 +00003040 /* Shift the look-ahead token. */
3041 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003042
3043 /* Discard the token being shifted unless it is eof. */
3044 if (yychar != YYEOF)
3045 yychar = YYEMPTY;
3046
3047 *++yyvsp = yylval;
3048
Reid Spencer3822ff52006-11-08 06:47:33 +00003049
3050 /* Count tokens shifted since error; after three, turn off error
3051 status. */
3052 if (yyerrstatus)
3053 yyerrstatus--;
Chris Lattner224f84f2006-08-18 17:34:45 +00003054
Reid Spencer68a24bd2005-08-27 18:50:39 +00003055 yystate = yyn;
3056 goto yynewstate;
3057
Chris Lattnerf49c1762006-11-08 05:58:47 +00003058
Reid Spencer3822ff52006-11-08 06:47:33 +00003059/*-----------------------------------------------------------.
3060| yydefault -- do the default action for the current state. |
3061`-----------------------------------------------------------*/
3062yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00003063 yyn = yydefact[yystate];
3064 if (yyn == 0)
3065 goto yyerrlab;
Reid Spencer3822ff52006-11-08 06:47:33 +00003066 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003067
Reid Spencer3822ff52006-11-08 06:47:33 +00003068
3069/*-----------------------------.
3070| yyreduce -- Do a reduction. |
3071`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00003072yyreduce:
Reid Spencer3822ff52006-11-08 06:47:33 +00003073 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003074 yylen = yyr2[yyn];
3075
Reid Spencer3822ff52006-11-08 06:47:33 +00003076 /* If YYLEN is nonzero, implement the default value of the action:
3077 `$$ = $1'.
3078
3079 Otherwise, the following line sets YYVAL to garbage.
3080 This behavior is undocumented and Bison
3081 users should not rely upon it. Assigning to YYVAL
3082 unconditionally makes the parser a bit smaller, and it avoids a
3083 GCC warning that YYVAL may be used uninitialized. */
3084 yyval = yyvsp[1-yylen];
3085
3086
3087 YY_REDUCE_PRINT (yyn);
3088 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003089 {
Reid Spencer3822ff52006-11-08 06:47:33 +00003090 case 3:
Reid Spencer3da59db2006-11-27 01:05:10 +00003091#line 1169 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003092 {
3093 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003094 GEN_ERROR("Value too large for type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003095 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003096 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003097;}
3098 break;
3099
3100 case 5:
Reid Spencer3da59db2006-11-27 01:05:10 +00003101#line 1178 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003102 {
3103 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003104 GEN_ERROR("Value too large for type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003105 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003106 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003107;}
3108 break;
3109
Reid Spencer3da59db2006-11-27 01:05:10 +00003110 case 51:
3111#line 1203 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003112 {
3113 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003114 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003115 ;}
3116 break;
3117
Reid Spencer3da59db2006-11-27 01:05:10 +00003118 case 52:
3119#line 1207 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003120 {
3121 (yyval.StrVal) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003122 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003123 ;}
3124 break;
3125
Reid Spencer3da59db2006-11-27 01:05:10 +00003126 case 53:
3127#line 1212 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003128 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3129 break;
3130
Reid Spencer3da59db2006-11-27 01:05:10 +00003131 case 54:
3132#line 1213 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003133 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3134 break;
3135
Reid Spencer3da59db2006-11-27 01:05:10 +00003136 case 55:
3137#line 1214 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003138 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3139 break;
3140
Reid Spencer3da59db2006-11-27 01:05:10 +00003141 case 56:
3142#line 1215 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003143 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3144 break;
3145
Reid Spencer3da59db2006-11-27 01:05:10 +00003146 case 57:
3147#line 1216 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003148 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3149 break;
3150
Reid Spencer3da59db2006-11-27 01:05:10 +00003151 case 58:
3152#line 1217 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003153 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3154 break;
3155
Reid Spencer3da59db2006-11-27 01:05:10 +00003156 case 59:
3157#line 1218 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003158 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3159 break;
3160
Reid Spencer3da59db2006-11-27 01:05:10 +00003161 case 60:
3162#line 1219 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003163 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3164 break;
3165
Reid Spencer3da59db2006-11-27 01:05:10 +00003166 case 61:
3167#line 1221 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003168 { (yyval.UIntVal) = CallingConv::C; ;}
3169 break;
3170
Reid Spencer3da59db2006-11-27 01:05:10 +00003171 case 62:
3172#line 1222 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003173 { (yyval.UIntVal) = CallingConv::C; ;}
3174 break;
3175
Reid Spencer3da59db2006-11-27 01:05:10 +00003176 case 63:
3177#line 1223 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003178 { (yyval.UIntVal) = CallingConv::CSRet; ;}
3179 break;
3180
Reid Spencer3da59db2006-11-27 01:05:10 +00003181 case 64:
3182#line 1224 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003183 { (yyval.UIntVal) = CallingConv::Fast; ;}
3184 break;
3185
Reid Spencer3da59db2006-11-27 01:05:10 +00003186 case 65:
3187#line 1225 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003188 { (yyval.UIntVal) = CallingConv::Cold; ;}
3189 break;
3190
Reid Spencer3da59db2006-11-27 01:05:10 +00003191 case 66:
3192#line 1226 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003193 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3194 break;
3195
Reid Spencer3da59db2006-11-27 01:05:10 +00003196 case 67:
3197#line 1227 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003198 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3199 break;
3200
Reid Spencer3da59db2006-11-27 01:05:10 +00003201 case 68:
3202#line 1228 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003203 {
3204 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003205 GEN_ERROR("Calling conv too large!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003206 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003207 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003208 ;}
3209 break;
3210
Reid Spencer3da59db2006-11-27 01:05:10 +00003211 case 69:
3212#line 1237 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003213 { (yyval.UIntVal) = 0; ;}
3214 break;
3215
Reid Spencer3da59db2006-11-27 01:05:10 +00003216 case 70:
3217#line 1238 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003218 {
3219 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3220 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer1628cec2006-10-26 06:15:43 +00003221 GEN_ERROR("Alignment must be a power of two!");
3222 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003223;}
3224 break;
3225
Reid Spencer3da59db2006-11-27 01:05:10 +00003226 case 71:
3227#line 1244 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003228 { (yyval.UIntVal) = 0; ;}
3229 break;
3230
Reid Spencer3da59db2006-11-27 01:05:10 +00003231 case 72:
3232#line 1245 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003233 {
3234 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3235 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer3ed469c2006-11-02 20:25:50 +00003236 GEN_ERROR("Alignment must be a power of two!");
3237 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003238;}
3239 break;
3240
Reid Spencer3da59db2006-11-27 01:05:10 +00003241 case 73:
3242#line 1253 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003243 {
3244 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3245 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer61c83e02006-08-18 08:43:06 +00003246 GEN_ERROR("Invalid character in section name!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003247 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003248 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003249;}
3250 break;
3251
Reid Spencer3da59db2006-11-27 01:05:10 +00003252 case 74:
3253#line 1261 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003254 { (yyval.StrVal) = 0; ;}
3255 break;
3256
Reid Spencer3da59db2006-11-27 01:05:10 +00003257 case 75:
3258#line 1262 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003259 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3260 break;
3261
Reid Spencer3da59db2006-11-27 01:05:10 +00003262 case 76:
3263#line 1267 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003264 {;}
3265 break;
3266
Reid Spencer3da59db2006-11-27 01:05:10 +00003267 case 77:
3268#line 1268 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003269 {;}
3270 break;
3271
Reid Spencer3da59db2006-11-27 01:05:10 +00003272 case 78:
3273#line 1269 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003274 {
3275 CurGV->setSection((yyvsp[0].StrVal));
3276 free((yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003277 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003278 ;}
3279 break;
3280
Reid Spencer3da59db2006-11-27 01:05:10 +00003281 case 79:
3282#line 1274 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003283 {
3284 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003285 GEN_ERROR("Alignment must be a power of two!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003286 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003287 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003288 ;}
3289 break;
3290
Reid Spencer3da59db2006-11-27 01:05:10 +00003291 case 81:
3292#line 1288 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3293 {
3294 (yyval.TypeVal).type = new PATypeHolder((yyvsp[0].TypeVal).type->get());
3295 (yyval.TypeVal).signedness = (yyvsp[0].TypeVal).signedness;
Reid Spencer3822ff52006-11-08 06:47:33 +00003296;}
3297 break;
3298
Reid Spencer3da59db2006-11-27 01:05:10 +00003299 case 83:
3300#line 1292 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3301 {
3302 (yyval.TypeVal).type = new PATypeHolder((yyvsp[0].TypeVal).type->get());
3303 (yyval.TypeVal).signedness = (yyvsp[0].TypeVal).signedness;
3304;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003305 break;
3306
Reid Spencer3da59db2006-11-27 01:05:10 +00003307 case 84:
3308#line 1297 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003309 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003310 if (!UpRefs.empty())
3311 GEN_ERROR("Invalid upreference in type: " +
3312 ((yyvsp[0].TypeVal).type->get())->getDescription());
3313 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003314 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00003315;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003316 break;
3317
Reid Spencer3da59db2006-11-27 01:05:10 +00003318 case 98:
3319#line 1310 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003320 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003321 (yyval.TypeVal).type = new PATypeHolder(OpaqueType::get());
3322 (yyval.TypeVal).signedness = isSignless;
Reid Spencer61c83e02006-08-18 08:43:06 +00003323 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003324 ;}
3325 break;
3326
3327 case 99:
Reid Spencer3da59db2006-11-27 01:05:10 +00003328#line 1315 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003329 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003330 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003331 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003332 ;}
3333 break;
3334
3335 case 100:
Reid Spencer3da59db2006-11-27 01:05:10 +00003336#line 1319 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3337 { // Named types are also simple types...
3338 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
3339 CHECK_FOR_ERROR
3340 (yyval.TypeVal).type = new PATypeHolder(tmp);
3341 (yyval.TypeVal).signedness = isSignless;
3342;}
Reid Spencer3822ff52006-11-08 06:47:33 +00003343 break;
3344
3345 case 101:
Reid Spencer3da59db2006-11-27 01:05:10 +00003346#line 1328 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3347 { // Type UpReference
3348 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
3349 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
3350 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3351 (yyval.TypeVal).type = new PATypeHolder(OT);
3352 (yyval.TypeVal).signedness = isSignless;
3353 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003354 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003355 ;}
3356 break;
3357
3358 case 102:
Reid Spencer3da59db2006-11-27 01:05:10 +00003359#line 1337 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3360 { // Function derived type?
3361 std::vector<const Type*> Params;
3362 for (std::list<TypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
3363 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
3364 Params.push_back(I->type->get());
3365 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3366 if (isVarArg) Params.pop_back();
3367
3368 (yyval.TypeVal).type = new PATypeHolder(HandleUpRefs(
3369 FunctionType::get((yyvsp[-3].TypeVal).type->get(),Params,isVarArg)));
3370 (yyval.TypeVal).signedness = isSignless;
3371 delete (yyvsp[-1].TypeList); // Delete the argument list
3372 delete (yyvsp[-3].TypeVal).type;
3373 CHECK_FOR_ERROR
3374 ;}
3375 break;
3376
3377 case 103:
3378#line 1352 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3379 { // Sized array type?
3380 (yyval.TypeVal).type = new PATypeHolder(HandleUpRefs(
3381 ArrayType::get((yyvsp[-1].TypeVal).type->get(), (unsigned)(yyvsp[-3].UInt64Val))));
3382 (yyval.TypeVal).signedness = isSignless;
3383 delete (yyvsp[-1].TypeVal).type;
3384 CHECK_FOR_ERROR
3385 ;}
3386 break;
3387
3388 case 104:
3389#line 1359 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3390 { // Packed array type?
3391 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal).type->get();
3392 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
3393 GEN_ERROR("Unsigned result not equal to signed result");
3394 if (!ElemTy->isPrimitiveType())
3395 GEN_ERROR("Elemental type of a PackedType must be primitive");
3396 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
3397 GEN_ERROR("Vector length should be a power of 2!");
3398 (yyval.TypeVal).type = new PATypeHolder(HandleUpRefs(
3399 PackedType::get((yyvsp[-1].TypeVal).type->get(), (unsigned)(yyvsp[-3].UInt64Val))));
3400 (yyval.TypeVal).signedness = isSignless;
3401 delete (yyvsp[-1].TypeVal).type;
3402 CHECK_FOR_ERROR
3403 ;}
3404 break;
3405
3406 case 105:
3407#line 1373 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3408 { // Structure type?
3409 std::vector<const Type*> Elements;
3410 for (std::list<TypeInfo>::iterator I = (yyvsp[-1].TypeList)->begin(),
3411 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
3412 Elements.push_back(I->type->get());
3413
3414 (yyval.TypeVal).type = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3415 (yyval.TypeVal).signedness = isSignless;
3416 delete (yyvsp[-1].TypeList);
3417 CHECK_FOR_ERROR
3418 ;}
3419 break;
3420
3421 case 106:
3422#line 1384 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3423 { // Empty structure type?
3424 (yyval.TypeVal).type = new PATypeHolder(StructType::get(std::vector<const Type*>()));
3425 (yyval.TypeVal).signedness = isSignless;
3426 CHECK_FOR_ERROR
3427 ;}
3428 break;
3429
3430 case 107:
3431#line 1389 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3432 { // Pointer type?
3433 if ((yyvsp[-1].TypeVal).type->get() == Type::LabelTy)
3434 GEN_ERROR("Cannot form a pointer to a basic block");
3435 (yyval.TypeVal).type = new PATypeHolder(HandleUpRefs(PointerType::get((yyvsp[-1].TypeVal).type->get())));
3436 (yyval.TypeVal).signedness = (yyvsp[-1].TypeVal).signedness;
3437 delete (yyvsp[-1].TypeVal).type;
3438 CHECK_FOR_ERROR
3439 ;}
3440 break;
3441
3442 case 108:
3443#line 1401 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3444 {
3445 (yyval.TypeList) = new std::list<TypeInfo>();
3446 (yyval.TypeList)->push_back((yyvsp[0].TypeVal));
3447 CHECK_FOR_ERROR
3448 ;}
3449 break;
3450
3451 case 109:
3452#line 1406 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3453 {
3454 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back((yyvsp[0].TypeVal));
3455 CHECK_FOR_ERROR
3456 ;}
3457 break;
3458
3459 case 111:
3460#line 1413 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3461 {
3462 TypeInfo TI;
3463 TI.type = new PATypeHolder(Type::VoidTy); TI.signedness = isSignless;
3464 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(TI);
3465 CHECK_FOR_ERROR
3466 ;}
3467 break;
3468
3469 case 112:
3470#line 1419 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3471 {
3472 TypeInfo TI;
3473 TI.type = new PATypeHolder(Type::VoidTy); TI.signedness = isSignless;
3474 ((yyval.TypeList) = new std::list<TypeInfo>())->push_back(TI);
3475 CHECK_FOR_ERROR
3476 ;}
3477 break;
3478
3479 case 113:
3480#line 1425 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
3481 {
3482 (yyval.TypeList) = new std::list<TypeInfo>();
3483 CHECK_FOR_ERROR
3484 ;}
3485 break;
3486
3487 case 114:
3488#line 1436 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003489 { // Nonempty unsized arr
Reid Spencer3da59db2006-11-27 01:05:10 +00003490 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal).type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003491 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003492 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003493 ((yyvsp[-3].TypeVal).type->get())->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003494 const Type *ETy = ATy->getElementType();
3495 int NumElements = ATy->getNumElements();
3496
3497 // Verify that we have the correct size...
Reid Spencer3822ff52006-11-08 06:47:33 +00003498 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00003499 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer3822ff52006-11-08 06:47:33 +00003500 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003501 itostr(NumElements) + "!");
3502
3503 // Verify all elements are correct type!
Reid Spencer3822ff52006-11-08 06:47:33 +00003504 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3505 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003506 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003507 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer3822ff52006-11-08 06:47:33 +00003508 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003509 }
3510
Reid Spencer3822ff52006-11-08 06:47:33 +00003511 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
Reid Spencer3da59db2006-11-27 01:05:10 +00003512 delete (yyvsp[-3].TypeVal).type; delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003513 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003514 ;}
3515 break;
3516
Reid Spencer3da59db2006-11-27 01:05:10 +00003517 case 115:
3518#line 1462 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003519 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003520 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003521 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003522 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003523 ((yyvsp[-2].TypeVal).type->get())->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003524
3525 int NumElements = ATy->getNumElements();
3526 if (NumElements != -1 && NumElements != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003527 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003528 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003529 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
Reid Spencer3da59db2006-11-27 01:05:10 +00003530 delete (yyvsp[-2].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00003531 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003532 ;}
3533 break;
3534
Reid Spencer3da59db2006-11-27 01:05:10 +00003535 case 116:
3536#line 1476 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003537 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003538 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal).type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003539 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003540 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003541 ((yyvsp[-2].TypeVal).type->get())->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003542
3543 int NumElements = ATy->getNumElements();
3544 const Type *ETy = ATy->getElementType();
Reid Spencer3822ff52006-11-08 06:47:33 +00003545 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3546 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003547 GEN_ERROR("Can't build string constant of size " +
Reid Spencer3822ff52006-11-08 06:47:33 +00003548 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003549 " when array has size " + itostr(NumElements) + "!");
3550 std::vector<Constant*> Vals;
3551 if (ETy == Type::SByteTy) {
Reid Spencer3822ff52006-11-08 06:47:33 +00003552 for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00003553 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003554 } else if (ETy == Type::UByteTy) {
Reid Spencer3822ff52006-11-08 06:47:33 +00003555 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003556 C != (unsigned char*)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00003557 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003558 } else {
Reid Spencer3822ff52006-11-08 06:47:33 +00003559 free((yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003560 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003561 }
Reid Spencer3822ff52006-11-08 06:47:33 +00003562 free((yyvsp[0].StrVal));
3563 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
Reid Spencer3da59db2006-11-27 01:05:10 +00003564 delete (yyvsp[-2].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00003565 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003566 ;}
3567 break;
3568
Reid Spencer3da59db2006-11-27 01:05:10 +00003569 case 117:
3570#line 1506 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003571 { // Nonempty unsized arr
Reid Spencer3da59db2006-11-27 01:05:10 +00003572 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal).type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003573 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003574 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003575 (yyvsp[-3].TypeVal).type->get()->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003576 const Type *ETy = PTy->getElementType();
3577 int NumElements = PTy->getNumElements();
3578
3579 // Verify that we have the correct size...
Reid Spencer3822ff52006-11-08 06:47:33 +00003580 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00003581 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer3822ff52006-11-08 06:47:33 +00003582 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003583 itostr(NumElements) + "!");
3584
3585 // Verify all elements are correct type!
Reid Spencer3822ff52006-11-08 06:47:33 +00003586 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3587 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003588 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003589 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer3822ff52006-11-08 06:47:33 +00003590 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003591 }
3592
Reid Spencer3822ff52006-11-08 06:47:33 +00003593 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
Reid Spencer3da59db2006-11-27 01:05:10 +00003594 delete (yyvsp[-3].TypeVal).type; delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003595 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003596 ;}
3597 break;
3598
Reid Spencer3da59db2006-11-27 01:05:10 +00003599 case 118:
3600#line 1532 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003601 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003602 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal).type->get());
Reid Spencer61c83e02006-08-18 08:43:06 +00003603 if (STy == 0)
3604 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003605 (yyvsp[-3].TypeVal).type->get()->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003606
Reid Spencer3822ff52006-11-08 06:47:33 +00003607 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer61c83e02006-08-18 08:43:06 +00003608 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003609
3610 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer3822ff52006-11-08 06:47:33 +00003611 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3612 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer61c83e02006-08-18 08:43:06 +00003613 GEN_ERROR("Expected type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003614 STy->getElementType(i)->getDescription() +
3615 "' for element #" + utostr(i) +
3616 " of structure initializer!");
3617
Reid Spencer3822ff52006-11-08 06:47:33 +00003618 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
Reid Spencer3da59db2006-11-27 01:05:10 +00003619 delete (yyvsp[-3].TypeVal).type; delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003620 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003621 ;}
3622 break;
3623
Reid Spencer3da59db2006-11-27 01:05:10 +00003624 case 119:
3625#line 1553 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003626 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003627 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal).type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003628 if (STy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003629 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003630 (yyvsp[-2].TypeVal).type->get()->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003631
3632 if (STy->getNumContainedTypes() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003633 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003634
Reid Spencer3822ff52006-11-08 06:47:33 +00003635 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
Reid Spencer3da59db2006-11-27 01:05:10 +00003636 delete (yyvsp[-2].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00003637 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003638 ;}
3639 break;
3640
Reid Spencer3da59db2006-11-27 01:05:10 +00003641 case 120:
3642#line 1566 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003643 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003644 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal).type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003645 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003646 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003647 (yyvsp[-1].TypeVal).type->get()->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003648
Reid Spencer3822ff52006-11-08 06:47:33 +00003649 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
Reid Spencer3da59db2006-11-27 01:05:10 +00003650 delete (yyvsp[-1].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00003651 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003652 ;}
3653 break;
3654
Reid Spencer3da59db2006-11-27 01:05:10 +00003655 case 121:
3656#line 1576 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003657 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003658 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal).type->get());
3659 delete (yyvsp[-1].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00003660 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003661 ;}
3662 break;
3663
Reid Spencer3da59db2006-11-27 01:05:10 +00003664 case 122:
3665#line 1581 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003666 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003667 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal).type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003668 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003669 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003670
3671 // ConstExprs can exist in the body of a function, thus creating
3672 // GlobalValues whenever they refer to a variable. Because we are in
3673 // the context of a function, getValNonImprovising will search the functions
3674 // symbol table instead of the module symbol table for the global symbol,
3675 // which throws things all off. To get around this, we just tell
3676 // getValNonImprovising that we are at global scope here.
3677 //
3678 Function *SavedCurFn = CurFun.CurrentFunction;
3679 CurFun.CurrentFunction = 0;
3680
Reid Spencer3822ff52006-11-08 06:47:33 +00003681 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003682 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003683
3684 CurFun.CurrentFunction = SavedCurFn;
3685
3686 // If this is an initializer for a constant pointer, which is referencing a
3687 // (currently) undefined variable, create a stub now that shall be replaced
3688 // in the future with the right type of variable.
3689 //
3690 if (V == 0) {
3691 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3692 const PointerType *PT = cast<PointerType>(Ty);
3693
3694 // First check to see if the forward references value is already created!
3695 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer3822ff52006-11-08 06:47:33 +00003696 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003697
3698 if (I != CurModule.GlobalRefs.end()) {
3699 V = I->second; // Placeholder already exists, use it...
Reid Spencer3822ff52006-11-08 06:47:33 +00003700 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003701 } else {
3702 std::string Name;
Reid Spencer3822ff52006-11-08 06:47:33 +00003703 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003704
3705 // Create the forward referenced global.
3706 GlobalValue *GV;
3707 if (const FunctionType *FTy =
3708 dyn_cast<FunctionType>(PT->getElementType())) {
3709 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3710 CurModule.CurrentModule);
3711 } else {
3712 GV = new GlobalVariable(PT->getElementType(), false,
3713 GlobalValue::ExternalLinkage, 0,
3714 Name, CurModule.CurrentModule);
3715 }
3716
3717 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer3822ff52006-11-08 06:47:33 +00003718 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003719 V = GV;
3720 }
3721 }
3722
Reid Spencer3822ff52006-11-08 06:47:33 +00003723 (yyval.ConstVal) = cast<GlobalValue>(V);
Reid Spencer3da59db2006-11-27 01:05:10 +00003724 delete (yyvsp[-1].TypeVal).type; // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003725 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003726 ;}
3727 break;
3728
Reid Spencer3da59db2006-11-27 01:05:10 +00003729 case 123:
3730#line 1642 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003731 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003732 if ((yyvsp[-1].TypeVal).type->get() != (yyvsp[0].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003733 GEN_ERROR("Mismatched types for constant expression!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003734 (yyval.ConstVal) = (yyvsp[0].ConstVal);
Reid Spencer3da59db2006-11-27 01:05:10 +00003735 delete (yyvsp[-1].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00003736 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003737 ;}
3738 break;
3739
Reid Spencer3da59db2006-11-27 01:05:10 +00003740 case 124:
3741#line 1649 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003742 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003743 const Type *Ty = (yyvsp[-1].TypeVal).type->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003744 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +00003745 GEN_ERROR("Cannot create a null initialized value of this type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003746 (yyval.ConstVal) = Constant::getNullValue(Ty);
Reid Spencer3da59db2006-11-27 01:05:10 +00003747 delete (yyvsp[-1].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00003748 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003749 ;}
3750 break;
3751
Reid Spencer3da59db2006-11-27 01:05:10 +00003752 case 125:
3753#line 1658 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003754 { // integral constants
Reid Spencer3da59db2006-11-27 01:05:10 +00003755 if (!ConstantInt::isValueValidForType((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].SInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003756 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencer3da59db2006-11-27 01:05:10 +00003757 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].SInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003758 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003759 ;}
3760 break;
3761
Reid Spencer3da59db2006-11-27 01:05:10 +00003762 case 126:
3763#line 1664 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003764 { // integral constants
Reid Spencer3da59db2006-11-27 01:05:10 +00003765 if (!ConstantInt::isValueValidForType((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003766 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencer3da59db2006-11-27 01:05:10 +00003767 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003768 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003769 ;}
3770 break;
3771
Reid Spencer3da59db2006-11-27 01:05:10 +00003772 case 127:
3773#line 1670 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003774 { // Boolean constants
3775 (yyval.ConstVal) = ConstantBool::getTrue();
Reid Spencer61c83e02006-08-18 08:43:06 +00003776 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003777 ;}
3778 break;
3779
Reid Spencer3da59db2006-11-27 01:05:10 +00003780 case 128:
3781#line 1674 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003782 { // Boolean constants
3783 (yyval.ConstVal) = ConstantBool::getFalse();
Reid Spencer61c83e02006-08-18 08:43:06 +00003784 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003785 ;}
3786 break;
3787
Reid Spencer3da59db2006-11-27 01:05:10 +00003788 case 129:
3789#line 1678 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003790 { // Float & Double constants
Reid Spencer3da59db2006-11-27 01:05:10 +00003791 if (!ConstantFP::isValueValidForType((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].FPVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003792 GEN_ERROR("Floating point constant invalid for type!!");
Reid Spencer3da59db2006-11-27 01:05:10 +00003793 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003794 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003795 ;}
3796 break;
3797
Reid Spencer3da59db2006-11-27 01:05:10 +00003798 case 130:
3799#line 1686 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003800 {
Reid Spencer3da59db2006-11-27 01:05:10 +00003801 Constant *Val = (yyvsp[-3].ConstVal);
3802 const Type *Ty = (yyvsp[-1].TypeVal).type->get();
3803 if (!Val->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003804 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003805 Val->getType()->getDescription() + "'!");
3806 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003807 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00003808 Ty->getDescription() + "'!");
3809 if ((yyvsp[-5].CastOpVal).obsolete) {
3810 if (Ty == Type::BoolTy) {
3811 // The previous definition of cast to bool was a compare against zero.
3812 // We have to retain that semantic so we do it here.
3813 (yyval.ConstVal) = ConstantExpr::get(Instruction::SetNE, Val,
3814 Constant::getNullValue(Val->getType()));
3815 } else if (Val->getType()->isFloatingPoint() && isa<PointerType>(Ty)) {
3816 Constant *CE = ConstantExpr::getFPToUI(Val, Type::ULongTy);
3817 (yyval.ConstVal) = ConstantExpr::getIntToPtr(CE, Ty);
3818 } else {
3819 (yyval.ConstVal) = ConstantExpr::getCast(Val, Ty);
3820 }
3821 } else {
3822 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal).type->get());
3823 }
3824 delete (yyvsp[-1].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00003825 ;}
3826 break;
3827
Reid Spencer3da59db2006-11-27 01:05:10 +00003828 case 131:
3829#line 1712 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003830 {
3831 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00003832 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003833
3834 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3835 // indices to uint struct indices for compatibility.
3836 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer3822ff52006-11-08 06:47:33 +00003837 GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()),
3838 GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end());
3839 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003840 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer3822ff52006-11-08 06:47:33 +00003841 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003842 if (CUI->getType() == Type::UByteTy)
Reid Spencer3822ff52006-11-08 06:47:33 +00003843 (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003844
3845 const Type *IdxTy =
Reid Spencer3822ff52006-11-08 06:47:33 +00003846 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003847 if (!IdxTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003848 GEN_ERROR("Index list invalid for constant getelementptr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003849
3850 std::vector<Constant*> IdxVec;
Reid Spencer3822ff52006-11-08 06:47:33 +00003851 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
3852 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003853 IdxVec.push_back(C);
3854 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003855 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003856
Reid Spencer3822ff52006-11-08 06:47:33 +00003857 delete (yyvsp[-1].ValueList);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003858
Reid Spencer3822ff52006-11-08 06:47:33 +00003859 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
Reid Spencer61c83e02006-08-18 08:43:06 +00003860 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003861 ;}
3862 break;
3863
Reid Spencer3da59db2006-11-27 01:05:10 +00003864 case 132:
3865#line 1744 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003866 {
3867 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003868 GEN_ERROR("Select condition must be of boolean type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003869 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003870 GEN_ERROR("Select operand types must match!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003871 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003872 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003873 ;}
3874 break;
3875
Reid Spencer3da59db2006-11-27 01:05:10 +00003876 case 133:
3877#line 1752 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003878 {
3879 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003880 GEN_ERROR("Binary operator types must match!");
Reid Spencer1628cec2006-10-26 06:15:43 +00003881 // First, make sure we're dealing with the right opcode by upgrading from
3882 // obsolete versions.
Reid Spencer3da59db2006-11-27 01:05:10 +00003883 sanitizeOpcode((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal)->getType());
Reid Spencer1628cec2006-10-26 06:15:43 +00003884 CHECK_FOR_ERROR;
3885
Reid Spencer68a24bd2005-08-27 18:50:39 +00003886 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3887 // To retain backward compatibility with these early compilers, we emit a
3888 // cast to the appropriate integer type automatically if we are in the
3889 // broken case. See PR424 for more information.
Reid Spencer3822ff52006-11-08 06:47:33 +00003890 if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) {
3891 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003892 } else {
3893 const Type *IntPtrTy = 0;
3894 switch (CurModule.CurrentModule->getPointerSize()) {
3895 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3896 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer61c83e02006-08-18 08:43:06 +00003897 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003898 }
Reid Spencer3822ff52006-11-08 06:47:33 +00003899 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy),
3900 ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy));
3901 (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003902 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003903 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003904 ;}
3905 break;
3906
Reid Spencer3da59db2006-11-27 01:05:10 +00003907 case 134:
3908#line 1779 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003909 {
3910 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003911 GEN_ERROR("Logical operator types must match!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003912 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
3913 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
3914 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00003915 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00003916 }
Reid Spencer3822ff52006-11-08 06:47:33 +00003917 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003918 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003919 ;}
3920 break;
3921
Reid Spencer3da59db2006-11-27 01:05:10 +00003922 case 135:
3923#line 1790 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003924 {
3925 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer1628cec2006-10-26 06:15:43 +00003926 GEN_ERROR("setcc operand types must match!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003927 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer1628cec2006-10-26 06:15:43 +00003928 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003929 ;}
3930 break;
3931
Reid Spencer3da59db2006-11-27 01:05:10 +00003932 case 136:
3933#line 1796 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003934 {
3935 if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy)
Reid Spencer1628cec2006-10-26 06:15:43 +00003936 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003937 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
Reid Spencer1628cec2006-10-26 06:15:43 +00003938 GEN_ERROR("Shift constant expression requires integer operand!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003939 // Handle opcode upgrade situations
Reid Spencer3da59db2006-11-27 01:05:10 +00003940 sanitizeOpcode((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal)->getType());
Reid Spencer3822ff52006-11-08 06:47:33 +00003941 CHECK_FOR_ERROR;
3942 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer1628cec2006-10-26 06:15:43 +00003943 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003944 ;}
3945 break;
3946
Reid Spencer3da59db2006-11-27 01:05:10 +00003947 case 137:
3948#line 1807 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003949 {
3950 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003951 GEN_ERROR("Invalid extractelement operands!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003952 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003953 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003954 ;}
3955 break;
3956
Reid Spencer3da59db2006-11-27 01:05:10 +00003957 case 138:
3958#line 1813 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003959 {
3960 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003961 GEN_ERROR("Invalid insertelement operands!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003962 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003963 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003964 ;}
3965 break;
3966
Reid Spencer3da59db2006-11-27 01:05:10 +00003967 case 139:
3968#line 1819 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003969 {
3970 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003971 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencer3822ff52006-11-08 06:47:33 +00003972 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003973 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003974 ;}
3975 break;
3976
Reid Spencer3da59db2006-11-27 01:05:10 +00003977 case 140:
3978#line 1828 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003979 {
3980 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003981 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003982 ;}
3983 break;
3984
Reid Spencer3da59db2006-11-27 01:05:10 +00003985 case 141:
3986#line 1832 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003987 {
3988 (yyval.ConstVector) = new std::vector<Constant*>();
3989 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003990 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00003991 ;}
3992 break;
3993
Reid Spencer3da59db2006-11-27 01:05:10 +00003994 case 142:
3995#line 1840 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00003996 { (yyval.BoolVal) = false; ;}
3997 break;
3998
Reid Spencer3da59db2006-11-27 01:05:10 +00003999 case 143:
4000#line 1840 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004001 { (yyval.BoolVal) = true; ;}
4002 break;
4003
Reid Spencer3da59db2006-11-27 01:05:10 +00004004 case 144:
4005#line 1850 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004006 {
4007 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004008 CurModule.ModuleDone();
Reid Spencerf63697d2006-10-09 17:36:59 +00004009 CHECK_FOR_ERROR;
Reid Spencer3822ff52006-11-08 06:47:33 +00004010;}
4011 break;
4012
Reid Spencer3da59db2006-11-27 01:05:10 +00004013 case 145:
4014#line 1858 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004015 {
4016 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004017 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004018 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004019 ;}
4020 break;
4021
Reid Spencer3da59db2006-11-27 01:05:10 +00004022 case 146:
4023#line 1863 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004024 {
4025 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer1628cec2006-10-26 06:15:43 +00004026 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004027 ;}
4028 break;
4029
Reid Spencer3da59db2006-11-27 01:05:10 +00004030 case 147:
4031#line 1867 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004032 {
4033 (yyval.ModuleVal) = (yyvsp[-3].ModuleVal);
Reid Spencer3ed469c2006-11-02 20:25:50 +00004034 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004035 ;}
4036 break;
4037
Reid Spencer3da59db2006-11-27 01:05:10 +00004038 case 148:
4039#line 1871 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004040 {
4041 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer3ed469c2006-11-02 20:25:50 +00004042 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004043 ;}
4044 break;
4045
Reid Spencer3da59db2006-11-27 01:05:10 +00004046 case 149:
4047#line 1875 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004048 {
4049 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004050 // Emit an error if there are any unresolved types left.
4051 if (!CurModule.LateResolveTypes.empty()) {
4052 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00004053 if (DID.Type == ValID::NameVal) {
4054 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
4055 } else {
4056 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
4057 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004058 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004059 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004060 ;}
4061 break;
4062
Reid Spencer3da59db2006-11-27 01:05:10 +00004063 case 150:
4064#line 1890 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004065 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004066 // Eagerly resolve types. This is not an optimization, this is a
4067 // requirement that is due to the fact that we could have this:
4068 //
4069 // %list = type { %list * }
4070 // %list = type { %list * } ; repeated type decl
4071 //
4072 // If types are not resolved eagerly, then the two types will not be
4073 // determined to be the same type!
4074 //
Reid Spencer3da59db2006-11-27 01:05:10 +00004075 ResolveTypeTo((yyvsp[-2].StrVal), (yyvsp[0].TypeVal).type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004076
Reid Spencer3da59db2006-11-27 01:05:10 +00004077 if (!setTypeName((yyvsp[0].TypeVal).type->get(), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004078 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004079 // If this is a named type that is not a redefinition, add it to the slot
4080 // table.
Reid Spencer3da59db2006-11-27 01:05:10 +00004081 CurModule.Types.push_back((yyvsp[0].TypeVal));
4082 } else {
4083 delete (yyvsp[0].TypeVal).type;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004084 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004085 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004086 ;}
4087 break;
4088
Reid Spencer3da59db2006-11-27 01:05:10 +00004089 case 151:
4090#line 1912 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004091 { // Function prototypes can be in const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00004092 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004093 ;}
4094 break;
4095
Reid Spencer3da59db2006-11-27 01:05:10 +00004096 case 152:
4097#line 1915 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004098 { // Asm blocks can be in the const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00004099 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004100 ;}
4101 break;
4102
Reid Spencer3da59db2006-11-27 01:05:10 +00004103 case 153:
4104#line 1918 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004105 {
4106 if ((yyvsp[0].ConstVal) == 0)
Reid Spencer5b7e7532006-09-28 19:28:24 +00004107 GEN_ERROR("Global value initializer is not a constant!");
Reid Spencer3822ff52006-11-08 06:47:33 +00004108 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004109 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004110 ;}
4111 break;
4112
Reid Spencer3da59db2006-11-27 01:05:10 +00004113 case 154:
4114#line 1923 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004115 {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004116 CurGV = 0;
Reid Spencer3822ff52006-11-08 06:47:33 +00004117 ;}
4118 break;
4119
Reid Spencer3da59db2006-11-27 01:05:10 +00004120 case 155:
4121#line 1926 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004122 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004123 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal),
4124 (yyvsp[0].TypeVal).type->get(), 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004125 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00004126 delete (yyvsp[0].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00004127 ;}
4128 break;
4129
Reid Spencer3da59db2006-11-27 01:05:10 +00004130 case 156:
4131#line 1931 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004132 {
Reid Spencer1628cec2006-10-26 06:15:43 +00004133 CurGV = 0;
4134 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004135 ;}
4136 break;
4137
Reid Spencer3da59db2006-11-27 01:05:10 +00004138 case 157:
4139#line 1935 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004140 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004141 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal),
4142 (yyvsp[0].TypeVal).type->get(), 0);
Reid Spencer3ed469c2006-11-02 20:25:50 +00004143 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00004144 delete (yyvsp[0].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00004145 ;}
4146 break;
4147
Reid Spencer3da59db2006-11-27 01:05:10 +00004148 case 158:
4149#line 1940 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004150 {
Reid Spencer3ed469c2006-11-02 20:25:50 +00004151 CurGV = 0;
4152 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004153 ;}
4154 break;
4155
Reid Spencer3da59db2006-11-27 01:05:10 +00004156 case 159:
4157#line 1944 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004158 {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004159 CurGV =
Reid Spencer3da59db2006-11-27 01:05:10 +00004160 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal),
4161 (yyvsp[0].TypeVal).type->get(), 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004162 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00004163 delete (yyvsp[0].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00004164 ;}
4165 break;
4166
Reid Spencer3da59db2006-11-27 01:05:10 +00004167 case 160:
4168#line 1950 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004169 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004170 CurGV = 0;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004171 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004172 ;}
4173 break;
4174
Reid Spencer3da59db2006-11-27 01:05:10 +00004175 case 161:
4176#line 1954 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004177 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004178 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004179 ;}
4180 break;
4181
Reid Spencer3da59db2006-11-27 01:05:10 +00004182 case 162:
4183#line 1957 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004184 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004185 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004186 ;}
4187 break;
4188
Reid Spencer3da59db2006-11-27 01:05:10 +00004189 case 163:
4190#line 1960 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004191 {
4192 ;}
4193 break;
4194
Reid Spencer3da59db2006-11-27 01:05:10 +00004195 case 164:
4196#line 1964 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004197 {
Chris Lattner66316012006-01-24 04:14:29 +00004198 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer3822ff52006-11-08 06:47:33 +00004199 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4200 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4201 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004202
4203 if (AsmSoFar.empty())
4204 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4205 else
4206 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004207 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004208;}
4209 break;
4210
Reid Spencer3da59db2006-11-27 01:05:10 +00004211 case 165:
4212#line 1977 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004213 { (yyval.Endianness) = Module::BigEndian; ;}
4214 break;
4215
Reid Spencer3da59db2006-11-27 01:05:10 +00004216 case 166:
4217#line 1978 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004218 { (yyval.Endianness) = Module::LittleEndian; ;}
4219 break;
4220
Reid Spencer3da59db2006-11-27 01:05:10 +00004221 case 167:
4222#line 1980 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004223 {
4224 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
Reid Spencer61c83e02006-08-18 08:43:06 +00004225 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004226 ;}
4227 break;
4228
Reid Spencer3da59db2006-11-27 01:05:10 +00004229 case 168:
4230#line 1984 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004231 {
4232 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004233 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Reid Spencer3822ff52006-11-08 06:47:33 +00004234 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004235 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4236 else
Reid Spencer3822ff52006-11-08 06:47:33 +00004237 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00004238 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004239 ;}
4240 break;
4241
Reid Spencer3da59db2006-11-27 01:05:10 +00004242 case 169:
4243#line 1993 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004244 {
4245 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4246 free((yyvsp[0].StrVal));
4247 ;}
4248 break;
4249
Reid Spencer3da59db2006-11-27 01:05:10 +00004250 case 170:
4251#line 1997 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004252 {
4253 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4254 free((yyvsp[0].StrVal));
4255 ;}
4256 break;
4257
Reid Spencer3da59db2006-11-27 01:05:10 +00004258 case 172:
4259#line 2004 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004260 {
4261 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4262 free((yyvsp[0].StrVal));
Reid Spencer3ed469c2006-11-02 20:25:50 +00004263 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004264 ;}
4265 break;
4266
Reid Spencer3da59db2006-11-27 01:05:10 +00004267 case 173:
4268#line 2009 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004269 {
4270 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4271 free((yyvsp[0].StrVal));
Reid Spencer3ed469c2006-11-02 20:25:50 +00004272 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004273 ;}
4274 break;
4275
Reid Spencer3da59db2006-11-27 01:05:10 +00004276 case 174:
4277#line 2014 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004278 {
Reid Spencer61c83e02006-08-18 08:43:06 +00004279 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004280 ;}
4281 break;
4282
Reid Spencer3da59db2006-11-27 01:05:10 +00004283 case 178:
4284#line 2024 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004285 { (yyval.StrVal) = 0; ;}
4286 break;
4287
Reid Spencer3da59db2006-11-27 01:05:10 +00004288 case 179:
4289#line 2026 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004290 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004291 if ((yyvsp[-1].TypeVal).type->get() == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004292 GEN_ERROR("void typed arguments are invalid!");
Reid Spencer3da59db2006-11-27 01:05:10 +00004293 (yyval.ArgVal) = new std::pair<TypeInfo, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004294 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004295;}
4296 break;
4297
Reid Spencer3da59db2006-11-27 01:05:10 +00004298 case 180:
4299#line 2033 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004300 {
4301 (yyval.ArgList) = (yyvsp[-2].ArgList);
4302 (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal));
4303 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004304 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004305 ;}
4306 break;
4307
Reid Spencer3da59db2006-11-27 01:05:10 +00004308 case 181:
4309#line 2039 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004310 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004311 (yyval.ArgList) = new std::vector<std::pair<TypeInfo,char*> >();
Reid Spencer3822ff52006-11-08 06:47:33 +00004312 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4313 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004314 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004315 ;}
4316 break;
4317
Reid Spencer3da59db2006-11-27 01:05:10 +00004318 case 182:
4319#line 2046 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004320 {
4321 (yyval.ArgList) = (yyvsp[0].ArgList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004322 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004323 ;}
4324 break;
4325
Reid Spencer3da59db2006-11-27 01:05:10 +00004326 case 183:
4327#line 2050 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004328 {
4329 (yyval.ArgList) = (yyvsp[-2].ArgList);
Reid Spencer3da59db2006-11-27 01:05:10 +00004330 TypeInfo TI;
4331 TI.type = new PATypeHolder(Type::VoidTy);
4332 TI.signedness = isSignless;
4333 (yyval.ArgList)->push_back(std::pair<TypeInfo,char*>(TI,(char*)0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004334 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004335 ;}
4336 break;
4337
Reid Spencer3da59db2006-11-27 01:05:10 +00004338 case 184:
4339#line 2058 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004340 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004341 (yyval.ArgList) = new std::vector<std::pair<TypeInfo,char*> >();
4342 TypeInfo TI;
4343 TI.type = new PATypeHolder(Type::VoidTy);
4344 TI.signedness = isSignless;
4345 (yyval.ArgList)->push_back(std::make_pair(TI, (char*)0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004346 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004347 ;}
4348 break;
4349
Reid Spencer3da59db2006-11-27 01:05:10 +00004350 case 185:
4351#line 2066 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004352 {
4353 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004354 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004355 ;}
4356 break;
4357
Reid Spencer3da59db2006-11-27 01:05:10 +00004358 case 186:
4359#line 2072 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004360 {
4361 UnEscapeLexed((yyvsp[-5].StrVal));
4362 std::string FunctionName((yyvsp[-5].StrVal));
4363 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004364
Reid Spencer3da59db2006-11-27 01:05:10 +00004365 if (!((yyvsp[-6].TypeVal).type->get())->isFirstClassType() && (yyvsp[-6].TypeVal).type->get() != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004366 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004367
4368 std::vector<const Type*> ParamTypeList;
Reid Spencer3822ff52006-11-08 06:47:33 +00004369 if ((yyvsp[-3].ArgList)) { // If there are arguments...
Reid Spencer3da59db2006-11-27 01:05:10 +00004370 for (std::vector<std::pair<TypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
Reid Spencer3822ff52006-11-08 06:47:33 +00004371 I != (yyvsp[-3].ArgList)->end(); ++I)
Reid Spencer3da59db2006-11-27 01:05:10 +00004372 ParamTypeList.push_back(I->first.type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004373 }
4374
4375 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4376 if (isVarArg) ParamTypeList.pop_back();
4377
Reid Spencer3da59db2006-11-27 01:05:10 +00004378 const FunctionType *FT = FunctionType::get((yyvsp[-6].TypeVal).type->get(), ParamTypeList,
4379 isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004380 const PointerType *PFT = PointerType::get(FT);
Reid Spencer3da59db2006-11-27 01:05:10 +00004381 delete (yyvsp[-6].TypeVal).type;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004382
4383 ValID ID;
4384 if (!FunctionName.empty()) {
4385 ID = ValID::create((char*)FunctionName.c_str());
4386 } else {
4387 ID = ValID::create((int)CurModule.Values[PFT].size());
4388 }
4389
4390 Function *Fn = 0;
4391 // See if this function was forward referenced. If so, recycle the object.
4392 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4393 // Move the function to the end of the list, from whereever it was
4394 // previously inserted.
4395 Fn = cast<Function>(FWRef);
4396 CurModule.CurrentModule->getFunctionList().remove(Fn);
4397 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4398 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4399 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4400 // If this is the case, either we need to be a forward decl, or it needs
4401 // to be.
4402 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004403 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004404
4405 // Make sure to strip off any argument names so we can't get conflicts.
4406 if (Fn->isExternal())
4407 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4408 AI != AE; ++AI)
4409 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004410 } else { // Not already defined?
4411 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4412 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004413
Reid Spencer68a24bd2005-08-27 18:50:39 +00004414 InsertValue(Fn, CurModule.Values);
4415 }
4416
4417 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004418
4419 if (CurFun.isDeclare) {
4420 // If we have declaration, always overwrite linkage. This will allow us to
4421 // correctly handle cases, when pointer to function is passed as argument to
4422 // another function.
4423 Fn->setLinkage(CurFun.Linkage);
4424 }
Reid Spencer3822ff52006-11-08 06:47:33 +00004425 Fn->setCallingConv((yyvsp[-7].UIntVal));
4426 Fn->setAlignment((yyvsp[0].UIntVal));
4427 if ((yyvsp[-1].StrVal)) {
4428 Fn->setSection((yyvsp[-1].StrVal));
4429 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004430 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004431
4432 // Add all of the arguments we parsed to the function...
Reid Spencer3822ff52006-11-08 06:47:33 +00004433 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004434 if (isVarArg) { // Nuke the last entry
Reid Spencer3da59db2006-11-27 01:05:10 +00004435 assert((yyvsp[-3].ArgList)->back().first.type->get() == Type::VoidTy &&
4436 (yyvsp[-3].ArgList)->back().second == 0 && "Not a varargs marker!");
4437 delete (yyvsp[-3].ArgList)->back().first.type;
Reid Spencer3822ff52006-11-08 06:47:33 +00004438 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004439 }
4440 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer3da59db2006-11-27 01:05:10 +00004441 for (std::vector<std::pair<TypeInfo,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
Reid Spencer3822ff52006-11-08 06:47:33 +00004442 I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencer3da59db2006-11-27 01:05:10 +00004443 delete I->first.type; // Delete the typeholder...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004444 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004445 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004446 InsertValue(ArgIt);
4447 }
Reid Spencer3822ff52006-11-08 06:47:33 +00004448 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004449 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004450 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004451;}
4452 break;
4453
Reid Spencer3da59db2006-11-27 01:05:10 +00004454 case 189:
4455#line 2167 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004456 {
4457 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004458
4459 // Make sure that we keep track of the linkage type even if there was a
4460 // previous "declare".
Reid Spencer3822ff52006-11-08 06:47:33 +00004461 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
4462;}
4463 break;
4464
Reid Spencer3da59db2006-11-27 01:05:10 +00004465 case 192:
4466#line 2177 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004467 {
4468 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004469 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004470;}
4471 break;
4472
Reid Spencer3da59db2006-11-27 01:05:10 +00004473 case 194:
4474#line 2183 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004475 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
4476 break;
4477
Reid Spencer3da59db2006-11-27 01:05:10 +00004478 case 195:
4479#line 2184 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004480 { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;}
4481 break;
4482
Reid Spencer3da59db2006-11-27 01:05:10 +00004483 case 196:
4484#line 2186 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004485 { CurFun.isDeclare = true; ;}
4486 break;
4487
Reid Spencer3da59db2006-11-27 01:05:10 +00004488 case 197:
4489#line 2186 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004490 {
4491 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004492 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004493 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004494 ;}
4495 break;
4496
Reid Spencer3da59db2006-11-27 01:05:10 +00004497 case 198:
4498#line 2196 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004499 {
4500 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004501 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004502 ;}
4503 break;
4504
Reid Spencer3da59db2006-11-27 01:05:10 +00004505 case 199:
4506#line 2200 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004507 {
4508 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004509 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004510 ;}
4511 break;
4512
Reid Spencer3da59db2006-11-27 01:05:10 +00004513 case 200:
4514#line 2205 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004515 { // A reference to a direct constant
4516 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00004517 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004518 ;}
4519 break;
4520
Reid Spencer3da59db2006-11-27 01:05:10 +00004521 case 201:
4522#line 2209 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004523 {
4524 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00004525 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004526 ;}
4527 break;
4528
Reid Spencer3da59db2006-11-27 01:05:10 +00004529 case 202:
4530#line 2213 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004531 { // Perhaps it's an FP constant?
4532 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004533 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004534 ;}
4535 break;
4536
Reid Spencer3da59db2006-11-27 01:05:10 +00004537 case 203:
4538#line 2217 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004539 {
4540 (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue());
Reid Spencer61c83e02006-08-18 08:43:06 +00004541 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004542 ;}
4543 break;
4544
Reid Spencer3da59db2006-11-27 01:05:10 +00004545 case 204:
4546#line 2221 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004547 {
4548 (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse());
Reid Spencer61c83e02006-08-18 08:43:06 +00004549 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004550 ;}
4551 break;
4552
Reid Spencer3da59db2006-11-27 01:05:10 +00004553 case 205:
4554#line 2225 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004555 {
4556 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004557 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004558 ;}
4559 break;
4560
Reid Spencer3da59db2006-11-27 01:05:10 +00004561 case 206:
4562#line 2229 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004563 {
4564 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004565 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004566 ;}
4567 break;
4568
Reid Spencer3da59db2006-11-27 01:05:10 +00004569 case 207:
4570#line 2233 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004571 { // A vector zero constant.
4572 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004573 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004574 ;}
4575 break;
4576
Reid Spencer3da59db2006-11-27 01:05:10 +00004577 case 208:
4578#line 2237 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004579 { // Nonempty unsized packed vector
4580 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4581 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004582
4583 PackedType* pt = PackedType::get(ETy, NumElements);
4584 PATypeHolder* PTy = new PATypeHolder(
Reid Spencer3da59db2006-11-27 01:05:10 +00004585 HandleUpRefs(PackedType::get( ETy, NumElements)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004586
4587 // Verify all elements are correct type!
Reid Spencer3822ff52006-11-08 06:47:33 +00004588 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4589 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004590 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004591 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer3822ff52006-11-08 06:47:33 +00004592 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004593 }
4594
Reid Spencer3822ff52006-11-08 06:47:33 +00004595 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4596 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00004597 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004598 ;}
4599 break;
Reid Spencer21be8652006-10-22 07:03:43 +00004600
Reid Spencer3da59db2006-11-27 01:05:10 +00004601 case 209:
4602#line 2257 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004603 {
4604 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Reid Spencer21be8652006-10-22 07:03:43 +00004605 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004606 ;}
4607 break;
4608
Reid Spencer3da59db2006-11-27 01:05:10 +00004609 case 210:
4610#line 2261 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004611 {
4612 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4613 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4614 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4615 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4616 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4617 free((yyvsp[-2].StrVal));
4618 free((yyvsp[0].StrVal));
Reid Spencer21be8652006-10-22 07:03:43 +00004619 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004620 ;}
4621 break;
4622
Reid Spencer3da59db2006-11-27 01:05:10 +00004623 case 211:
4624#line 2275 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004625 { // Is it an integer reference...?
4626 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4627 CHECK_FOR_ERROR
4628 ;}
4629 break;
4630
Reid Spencer3da59db2006-11-27 01:05:10 +00004631 case 212:
4632#line 2279 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004633 { // Is it a named reference...?
4634 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4635 CHECK_FOR_ERROR
4636 ;}
4637 break;
4638
Reid Spencer3da59db2006-11-27 01:05:10 +00004639 case 215:
4640#line 2291 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004641 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004642 (yyval.ValueVal) = getVal((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00004643 CHECK_FOR_ERROR
4644 ;}
4645 break;
4646
Reid Spencer3da59db2006-11-27 01:05:10 +00004647 case 216:
4648#line 2296 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004649 {
4650 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4651 CHECK_FOR_ERROR
4652 ;}
4653 break;
4654
Reid Spencer3da59db2006-11-27 01:05:10 +00004655 case 217:
4656#line 2300 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004657 { // Do not allow functions with 0 basic blocks
4658 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4659 CHECK_FOR_ERROR
4660 ;}
4661 break;
4662
Reid Spencer3da59db2006-11-27 01:05:10 +00004663 case 218:
4664#line 2309 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004665 {
4666 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4667 CHECK_FOR_ERROR
4668 InsertValue((yyvsp[0].TermInstVal));
4669
4670 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4671 InsertValue((yyvsp[-2].BasicBlockVal));
4672 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
4673 CHECK_FOR_ERROR
4674 ;}
4675 break;
4676
Reid Spencer3da59db2006-11-27 01:05:10 +00004677 case 219:
4678#line 2320 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004679 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004680 if (CastInst *CI1 = dyn_cast<CastInst>((yyvsp[0].InstVal)))
4681 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4682 if (CI2->getParent() == 0)
4683 (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2);
Reid Spencer3822ff52006-11-08 06:47:33 +00004684 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4685 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
4686 CHECK_FOR_ERROR
4687 ;}
4688 break;
4689
Reid Spencer3da59db2006-11-27 01:05:10 +00004690 case 220:
4691#line 2329 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004692 {
4693 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004694 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004695
4696 // Make sure to move the basic block to the correct location in the
4697 // function, instead of leaving it inserted wherever it was first
4698 // referenced.
4699 Function::BasicBlockListType &BBL =
4700 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3822ff52006-11-08 06:47:33 +00004701 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004702 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004703 ;}
4704 break;
4705
Reid Spencer3da59db2006-11-27 01:05:10 +00004706 case 221:
4707#line 2341 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004708 {
4709 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004710 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004711
4712 // Make sure to move the basic block to the correct location in the
4713 // function, instead of leaving it inserted wherever it was first
4714 // referenced.
4715 Function::BasicBlockListType &BBL =
4716 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer3822ff52006-11-08 06:47:33 +00004717 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004718 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004719 ;}
4720 break;
Reid Spencer61c83e02006-08-18 08:43:06 +00004721
Reid Spencer3da59db2006-11-27 01:05:10 +00004722 case 222:
4723#line 2354 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004724 { // Return with a result...
4725 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4726 CHECK_FOR_ERROR
4727 ;}
4728 break;
4729
Reid Spencer3da59db2006-11-27 01:05:10 +00004730 case 223:
4731#line 2358 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004732 { // Return with no result...
4733 (yyval.TermInstVal) = new ReturnInst();
4734 CHECK_FOR_ERROR
4735 ;}
4736 break;
4737
Reid Spencer3da59db2006-11-27 01:05:10 +00004738 case 224:
4739#line 2362 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004740 { // Unconditional Branch...
4741 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
4742 CHECK_FOR_ERROR
4743 (yyval.TermInstVal) = new BranchInst(tmpBB);
4744 ;}
4745 break;
4746
Reid Spencer3da59db2006-11-27 01:05:10 +00004747 case 225:
4748#line 2367 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004749 {
4750 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
4751 CHECK_FOR_ERROR
4752 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
4753 CHECK_FOR_ERROR
4754 Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal));
4755 CHECK_FOR_ERROR
4756 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4757 ;}
4758 break;
4759
Reid Spencer3da59db2006-11-27 01:05:10 +00004760 case 226:
4761#line 2376 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004762 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004763 Value* tmpVal = getVal((yyvsp[-7].TypeVal).type->get(), (yyvsp[-6].ValIDVal));
Reid Spencer3822ff52006-11-08 06:47:33 +00004764 CHECK_FOR_ERROR
4765 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
4766 CHECK_FOR_ERROR
4767 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
4768 (yyval.TermInstVal) = S;
4769
4770 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4771 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004772 for (; I != E; ++I) {
4773 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4774 S->addCase(CI, I->second);
4775 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004776 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004777 }
Reid Spencer3822ff52006-11-08 06:47:33 +00004778 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00004779 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004780 ;}
4781 break;
4782
Reid Spencer3da59db2006-11-27 01:05:10 +00004783 case 227:
4784#line 2395 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004785 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004786 Value* tmpVal = getVal((yyvsp[-6].TypeVal).type->get(), (yyvsp[-5].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004787 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004788 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004789 CHECK_FOR_ERROR
4790 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer3822ff52006-11-08 06:47:33 +00004791 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004792 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004793 ;}
4794 break;
4795
Reid Spencer3da59db2006-11-27 01:05:10 +00004796 case 228:
4797#line 2405 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004798 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004799 const PointerType *PFTy;
4800 const FunctionType *Ty;
4801
Reid Spencer3da59db2006-11-27 01:05:10 +00004802 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal).type->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004803 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4804 // Pull out the types of all of the arguments...
4805 std::vector<const Type*> ParamTypes;
Reid Spencer3822ff52006-11-08 06:47:33 +00004806 if ((yyvsp[-7].ValueList)) {
4807 for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004808 I != E; ++I)
4809 ParamTypes.push_back((*I)->getType());
4810 }
4811
4812 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4813 if (isVarArg) ParamTypes.pop_back();
4814
Reid Spencer3da59db2006-11-27 01:05:10 +00004815 Ty = FunctionType::get((yyvsp[-10].TypeVal).type->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004816 PFTy = PointerType::get(Ty);
4817 }
4818
Reid Spencer3822ff52006-11-08 06:47:33 +00004819 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004820 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004821 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004822 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004823 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004824 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004825
4826 // Create the call node...
Reid Spencer3822ff52006-11-08 06:47:33 +00004827 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
4828 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004829 } else { // Has arguments?
4830 // Loop through FunctionType's arguments and ensure they are specified
4831 // correctly!
4832 //
4833 FunctionType::param_iterator I = Ty->param_begin();
4834 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer3822ff52006-11-08 06:47:33 +00004835 std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004836
4837 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4838 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00004839 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004840 (*I)->getDescription() + "'!");
4841
4842 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004843 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004844
Reid Spencer3822ff52006-11-08 06:47:33 +00004845 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004846 }
Reid Spencer3822ff52006-11-08 06:47:33 +00004847 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004848
Reid Spencer3da59db2006-11-27 01:05:10 +00004849 delete (yyvsp[-10].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00004850 delete (yyvsp[-7].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004851 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004852 ;}
4853 break;
4854
Reid Spencer3da59db2006-11-27 01:05:10 +00004855 case 229:
4856#line 2460 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004857 {
4858 (yyval.TermInstVal) = new UnwindInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00004859 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004860 ;}
4861 break;
4862
Reid Spencer3da59db2006-11-27 01:05:10 +00004863 case 230:
4864#line 2464 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004865 {
4866 (yyval.TermInstVal) = new UnreachableInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00004867 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004868 ;}
4869 break;
4870
Reid Spencer3da59db2006-11-27 01:05:10 +00004871 case 231:
4872#line 2471 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004873 {
4874 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
Reid Spencer3da59db2006-11-27 01:05:10 +00004875 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].TypeVal).type->get(), (yyvsp[-3].ValIDVal)));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004876 CHECK_FOR_ERROR
Reid Spencer61c83e02006-08-18 08:43:06 +00004877 if (V == 0)
4878 GEN_ERROR("May only switch on a constant pool value!");
4879
Reid Spencer3822ff52006-11-08 06:47:33 +00004880 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004881 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004882 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
4883 ;}
4884 break;
4885
Reid Spencer3da59db2006-11-27 01:05:10 +00004886 case 232:
4887#line 2482 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004888 {
4889 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
Reid Spencer3da59db2006-11-27 01:05:10 +00004890 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].TypeVal).type->get(), (yyvsp[-3].ValIDVal)));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004891 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004892
4893 if (V == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004894 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004895
Reid Spencer3822ff52006-11-08 06:47:33 +00004896 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004897 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004898 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
4899 ;}
4900 break;
4901
Reid Spencer3da59db2006-11-27 01:05:10 +00004902 case 233:
4903#line 2495 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004904 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004905 // Is this definition named?? if so, assign the name...
Reid Spencer3822ff52006-11-08 06:47:33 +00004906 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004907 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004908 InsertValue((yyvsp[0].InstVal));
4909 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004910 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004911;}
4912 break;
4913
Reid Spencer3da59db2006-11-27 01:05:10 +00004914 case 234:
4915#line 2504 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004916 { // Used for PHI nodes
4917 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
Reid Spencer3da59db2006-11-27 01:05:10 +00004918 Value* tmpVal = getVal((yyvsp[-5].TypeVal).type->get(), (yyvsp[-3].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004919 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004920 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004921 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004922 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
Reid Spencer3da59db2006-11-27 01:05:10 +00004923 delete (yyvsp[-5].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00004924 ;}
4925 break;
4926
Reid Spencer3da59db2006-11-27 01:05:10 +00004927 case 235:
4928#line 2513 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004929 {
4930 (yyval.PHIList) = (yyvsp[-6].PHIList);
4931 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004932 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004933 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004934 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004935 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4936 ;}
4937 break;
4938
Reid Spencer3da59db2006-11-27 01:05:10 +00004939 case 236:
4940#line 2523 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004941 { // Used for call statements, and memory insts...
4942 (yyval.ValueList) = new std::vector<Value*>();
4943 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
4944 ;}
4945 break;
4946
Reid Spencer3da59db2006-11-27 01:05:10 +00004947 case 237:
4948#line 2527 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004949 {
4950 (yyval.ValueList) = (yyvsp[-2].ValueList);
4951 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004952 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004953 ;}
4954 break;
4955
Reid Spencer3da59db2006-11-27 01:05:10 +00004956 case 239:
4957#line 2534 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004958 { (yyval.ValueList) = 0; ;}
4959 break;
4960
Reid Spencer3da59db2006-11-27 01:05:10 +00004961 case 240:
4962#line 2536 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004963 {
4964 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004965 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004966 ;}
4967 break;
4968
Reid Spencer3da59db2006-11-27 01:05:10 +00004969 case 241:
4970#line 2540 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004971 {
4972 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004973 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004974 ;}
4975 break;
4976
Reid Spencer3da59db2006-11-27 01:05:10 +00004977 case 242:
4978#line 2545 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00004979 {
Reid Spencer3da59db2006-11-27 01:05:10 +00004980 if (!(yyvsp[-3].TypeVal).type->get()->isInteger() && !(yyvsp[-3].TypeVal).type->get()->isFloatingPoint() &&
4981 !isa<PackedType>((yyvsp[-3].TypeVal).type->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004982 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004983 "Arithmetic operator requires integer, FP, or packed operands!");
Reid Spencer3da59db2006-11-27 01:05:10 +00004984 if (isa<PackedType>((yyvsp[-3].TypeVal).type->get()) &&
Reid Spencer3822ff52006-11-08 06:47:33 +00004985 ((yyvsp[-4].BinaryOpVal).opcode == Instruction::URem ||
4986 (yyvsp[-4].BinaryOpVal).opcode == Instruction::SRem ||
4987 (yyvsp[-4].BinaryOpVal).opcode == Instruction::FRem))
Reid Spencer3ed469c2006-11-02 20:25:50 +00004988 GEN_ERROR("U/S/FRem not supported on packed types!");
Reid Spencer1628cec2006-10-26 06:15:43 +00004989 // Upgrade the opcode from obsolete versions before we do anything with it.
Reid Spencer3da59db2006-11-27 01:05:10 +00004990 sanitizeOpcode((yyvsp[-4].BinaryOpVal),(yyvsp[-3].TypeVal).type->get());
Reid Spencer1628cec2006-10-26 06:15:43 +00004991 CHECK_FOR_ERROR;
Reid Spencer3da59db2006-11-27 01:05:10 +00004992 Value* val1 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004993 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00004994 Value* val2 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004995 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00004996 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, val1, val2);
4997 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004998 GEN_ERROR("binary operator returned null!");
Reid Spencer3da59db2006-11-27 01:05:10 +00004999 delete (yyvsp[-3].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00005000 ;}
5001 break;
5002
Reid Spencer3da59db2006-11-27 01:05:10 +00005003 case 243:
5004#line 2567 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005005 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005006 if (!(yyvsp[-3].TypeVal).type->get()->isIntegral()) {
5007 if (!isa<PackedType>((yyvsp[-3].TypeVal).type->get()) ||
5008 !cast<PackedType>((yyvsp[-3].TypeVal).type->get())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00005009 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00005010 }
Reid Spencer3da59db2006-11-27 01:05:10 +00005011 Value* tmpVal1 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005012 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00005013 Value* tmpVal2 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005014 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005015 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2);
5016 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005017 GEN_ERROR("binary operator returned null!");
Reid Spencer3da59db2006-11-27 01:05:10 +00005018 delete (yyvsp[-3].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00005019 ;}
5020 break;
5021
Reid Spencer3da59db2006-11-27 01:05:10 +00005022 case 244:
5023#line 2582 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005024 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005025 if(isa<PackedType>((yyvsp[-3].TypeVal).type->get())) {
Reid Spencer61c83e02006-08-18 08:43:06 +00005026 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00005027 "PackedTypes currently not supported in setcc instructions!");
5028 }
Reid Spencer3da59db2006-11-27 01:05:10 +00005029 Value* tmpVal1 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005030 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00005031 Value* tmpVal2 = getVal((yyvsp[-3].TypeVal).type->get(), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00005032 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005033 (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2);
5034 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005035 GEN_ERROR("binary operator returned null!");
Reid Spencer3da59db2006-11-27 01:05:10 +00005036 delete (yyvsp[-3].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00005037 ;}
5038 break;
5039
Reid Spencer3da59db2006-11-27 01:05:10 +00005040 case 245:
5041#line 2596 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005042 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005043 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
5044 << " Replacing with 'xor'.\n";
5045
Reid Spencer3822ff52006-11-08 06:47:33 +00005046 Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005047 if (Ones == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005048 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005049
Reid Spencer3822ff52006-11-08 06:47:33 +00005050 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
5051 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005052 GEN_ERROR("Could not create a xor instruction!");
5053 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005054 ;}
5055 break;
5056
Reid Spencer3da59db2006-11-27 01:05:10 +00005057 case 246:
5058#line 2609 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005059 {
5060 if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005061 GEN_ERROR("Shift amount must be ubyte!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005062 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
Reid Spencer61c83e02006-08-18 08:43:06 +00005063 GEN_ERROR("Shift constant expression requires integer operand!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005064 // Handle opcode upgrade situations
Reid Spencer3da59db2006-11-27 01:05:10 +00005065 sanitizeOpcode((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal)->getType());
Reid Spencer3822ff52006-11-08 06:47:33 +00005066 CHECK_FOR_ERROR;
5067 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal).opcode, (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005068 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005069 ;}
5070 break;
5071
Reid Spencer3da59db2006-11-27 01:05:10 +00005072 case 247:
5073#line 2620 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005074 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005075 Value* Val = (yyvsp[-2].ValueVal);
5076 const Type* Ty = (yyvsp[0].TypeVal).type->get();
5077 if (!Val->getType()->isFirstClassType())
5078 GEN_ERROR("cast from a non-primitive type: '" +
5079 Val->getType()->getDescription() + "'!");
5080 if (!Ty->isFirstClassType())
5081 GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!");
5082
5083 if ((yyvsp[-3].CastOpVal).obsolete) {
5084 if (Ty == Type::BoolTy) {
5085 // The previous definition of cast to bool was a compare against zero.
5086 // We have to retain that semantic so we do it here.
5087 (yyval.InstVal) = new SetCondInst(Instruction::SetNE, (yyvsp[-2].ValueVal),
5088 Constant::getNullValue((yyvsp[-2].ValueVal)->getType()));
5089 } else if (Val->getType()->isFloatingPoint() && isa<PointerType>(Ty)) {
5090 CastInst *CI = new FPToUIInst(Val, Type::ULongTy);
5091 (yyval.InstVal) = new IntToPtrInst(CI, Ty);
5092 } else {
5093 (yyval.InstVal) = CastInst::createInferredCast(Val, Ty);
5094 }
5095 } else {
5096 (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal).opcode, (yyvsp[-2].ValueVal), (yyvsp[0].TypeVal).type->get());
5097 }
5098 delete (yyvsp[0].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00005099 ;}
5100 break;
5101
Reid Spencer3da59db2006-11-27 01:05:10 +00005102 case 248:
5103#line 2646 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005104 {
5105 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005106 GEN_ERROR("select condition must be boolean!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005107 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005108 GEN_ERROR("select value types should match!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005109 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005110 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005111 ;}
5112 break;
5113
Reid Spencer3da59db2006-11-27 01:05:10 +00005114 case 249:
5115#line 2654 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005116 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005117 NewVarArgs = true;
Reid Spencer3da59db2006-11-27 01:05:10 +00005118 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), (yyvsp[0].TypeVal).type->get());
5119 delete (yyvsp[0].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00005120 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005121 ;}
5122 break;
5123
Reid Spencer3da59db2006-11-27 01:05:10 +00005124 case 250:
5125#line 2660 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005126 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005127 ObsoleteVarArgs = true;
Reid Spencer3822ff52006-11-08 06:47:33 +00005128 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005129 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00005130 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005131
5132 //b = vaarg a, t ->
5133 //foo = alloca 1 of t
5134 //bar = vacopy a
5135 //store bar -> foo
5136 //b = vaarg foo, t
5137 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
5138 CurBB->getInstList().push_back(foo);
Reid Spencer3822ff52006-11-08 06:47:33 +00005139 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005140 CurBB->getInstList().push_back(bar);
5141 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer3da59db2006-11-27 01:05:10 +00005142 (yyval.InstVal) = new VAArgInst(foo, (yyvsp[0].TypeVal).type->get());
5143 delete (yyvsp[0].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00005144 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005145 ;}
5146 break;
5147
Reid Spencer3da59db2006-11-27 01:05:10 +00005148 case 251:
5149#line 2680 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005150 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005151 ObsoleteVarArgs = true;
Reid Spencer3822ff52006-11-08 06:47:33 +00005152 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005153 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00005154 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005155
5156 //b = vanext a, t ->
5157 //foo = alloca 1 of t
5158 //bar = vacopy a
5159 //store bar -> foo
5160 //tmp = vaarg foo, t
5161 //b = load foo
5162 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5163 CurBB->getInstList().push_back(foo);
Reid Spencer3822ff52006-11-08 06:47:33 +00005164 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005165 CurBB->getInstList().push_back(bar);
5166 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer3da59db2006-11-27 01:05:10 +00005167 Instruction* tmp = new VAArgInst(foo, (yyvsp[0].TypeVal).type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005168 CurBB->getInstList().push_back(tmp);
Reid Spencer3822ff52006-11-08 06:47:33 +00005169 (yyval.InstVal) = new LoadInst(foo);
Reid Spencer3da59db2006-11-27 01:05:10 +00005170 delete (yyvsp[0].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00005171 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005172 ;}
5173 break;
5174
Reid Spencer3da59db2006-11-27 01:05:10 +00005175 case 252:
5176#line 2703 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005177 {
5178 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005179 GEN_ERROR("Invalid extractelement operands!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005180 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005181 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005182 ;}
5183 break;
5184
Reid Spencer3da59db2006-11-27 01:05:10 +00005185 case 253:
5186#line 2709 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005187 {
5188 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005189 GEN_ERROR("Invalid insertelement operands!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005190 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005191 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005192 ;}
5193 break;
5194
Reid Spencer3da59db2006-11-27 01:05:10 +00005195 case 254:
5196#line 2715 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005197 {
5198 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005199 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005200 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005201 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005202 ;}
5203 break;
5204
Reid Spencer3da59db2006-11-27 01:05:10 +00005205 case 255:
5206#line 2721 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005207 {
5208 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005209 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005210 GEN_ERROR("PHI node operands must be of first class type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005211 (yyval.InstVal) = new PHINode(Ty);
5212 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5213 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5214 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencer61c83e02006-08-18 08:43:06 +00005215 GEN_ERROR("All elements of a PHI node must be of the same type!");
Reid Spencer3822ff52006-11-08 06:47:33 +00005216 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5217 (yyvsp[0].PHIList)->pop_front();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005218 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005219 delete (yyvsp[0].PHIList); // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005220 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005221 ;}
5222 break;
5223
Reid Spencer3da59db2006-11-27 01:05:10 +00005224 case 256:
5225#line 2736 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005226 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005227 const PointerType *PFTy = 0;
5228 const FunctionType *Ty = 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005229
Reid Spencer3da59db2006-11-27 01:05:10 +00005230 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal).type->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005231 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5232 // Pull out the types of all of the arguments...
5233 std::vector<const Type*> ParamTypes;
Reid Spencer3822ff52006-11-08 06:47:33 +00005234 if ((yyvsp[-1].ValueList)) {
5235 for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005236 I != E; ++I)
5237 ParamTypes.push_back((*I)->getType());
5238 }
5239
5240 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5241 if (isVarArg) ParamTypes.pop_back();
5242
Reid Spencer3da59db2006-11-27 01:05:10 +00005243 if (!(yyvsp[-4].TypeVal).type->get()->isFirstClassType() &&
5244 (yyvsp[-4].TypeVal).type->get() != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005245 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005246
Reid Spencer3da59db2006-11-27 01:05:10 +00005247 Ty = FunctionType::get((yyvsp[-4].TypeVal).type->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005248 PFTy = PointerType::get(Ty);
5249 }
5250
Reid Spencer3822ff52006-11-08 06:47:33 +00005251 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005252 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005253
5254 // Create the call node...
Reid Spencer3822ff52006-11-08 06:47:33 +00005255 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer68a24bd2005-08-27 18:50:39 +00005256 // Make sure no arguments is a good thing!
5257 if (Ty->getNumParams() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005258 GEN_ERROR("No arguments passed to a function that "
Reid Spencer68a24bd2005-08-27 18:50:39 +00005259 "expects arguments!");
5260
Reid Spencer3822ff52006-11-08 06:47:33 +00005261 (yyval.InstVal) = new CallInst(V, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005262 } else { // Has arguments?
5263 // Loop through FunctionType's arguments and ensure they are specified
5264 // correctly!
5265 //
5266 FunctionType::param_iterator I = Ty->param_begin();
5267 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer3822ff52006-11-08 06:47:33 +00005268 std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005269
5270 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5271 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00005272 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005273 (*I)->getDescription() + "'!");
5274
5275 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005276 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005277
Reid Spencer3822ff52006-11-08 06:47:33 +00005278 (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005279 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005280 cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal));
5281 cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal));
Reid Spencer3da59db2006-11-27 01:05:10 +00005282 delete (yyvsp[-4].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00005283 delete (yyvsp[-1].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00005284 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005285 ;}
5286 break;
5287
Reid Spencer3da59db2006-11-27 01:05:10 +00005288 case 257:
5289#line 2796 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005290 {
5291 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005292 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005293 ;}
5294 break;
5295
Reid Spencer3da59db2006-11-27 01:05:10 +00005296 case 258:
5297#line 2803 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005298 {
5299 (yyval.ValueList) = (yyvsp[0].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00005300 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005301 ;}
5302 break;
5303
Reid Spencer3da59db2006-11-27 01:05:10 +00005304 case 259:
5305#line 2806 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005306 {
5307 (yyval.ValueList) = new std::vector<Value*>();
Reid Spencer61c83e02006-08-18 08:43:06 +00005308 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005309 ;}
5310 break;
5311
Reid Spencer3da59db2006-11-27 01:05:10 +00005312 case 260:
5313#line 2811 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005314 {
5315 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00005316 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005317 ;}
5318 break;
5319
Reid Spencer3da59db2006-11-27 01:05:10 +00005320 case 261:
5321#line 2815 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005322 {
5323 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005324 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005325 ;}
5326 break;
5327
Reid Spencer3da59db2006-11-27 01:05:10 +00005328 case 262:
5329#line 2822 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005330 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005331 (yyval.InstVal) = new MallocInst((yyvsp[-1].TypeVal).type->get(), 0, (yyvsp[0].UIntVal));
5332 delete (yyvsp[-1].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00005333 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005334 ;}
5335 break;
5336
Reid Spencer3da59db2006-11-27 01:05:10 +00005337 case 263:
5338#line 2827 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005339 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005340 Value* tmpVal = getVal((yyvsp[-2].TypeVal).type->get(), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005341 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00005342 (yyval.InstVal) = new MallocInst((yyvsp[-4].TypeVal).type->get(), tmpVal, (yyvsp[0].UIntVal));
5343 delete (yyvsp[-4].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00005344 ;}
5345 break;
5346
Reid Spencer3da59db2006-11-27 01:05:10 +00005347 case 264:
5348#line 2833 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005349 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005350 (yyval.InstVal) = new AllocaInst((yyvsp[-1].TypeVal).type->get(), 0, (yyvsp[0].UIntVal));
5351 delete (yyvsp[-1].TypeVal).type;
Reid Spencer61c83e02006-08-18 08:43:06 +00005352 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005353 ;}
5354 break;
5355
Reid Spencer3da59db2006-11-27 01:05:10 +00005356 case 265:
5357#line 2838 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005358 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005359 Value* tmpVal = getVal((yyvsp[-2].TypeVal).type->get(), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005360 CHECK_FOR_ERROR
Reid Spencer3da59db2006-11-27 01:05:10 +00005361 (yyval.InstVal) = new AllocaInst((yyvsp[-4].TypeVal).type->get(), tmpVal, (yyvsp[0].UIntVal));
5362 delete (yyvsp[-4].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00005363 ;}
5364 break;
5365
Reid Spencer3da59db2006-11-27 01:05:10 +00005366 case 266:
5367#line 2844 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005368 {
5369 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005370 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer3822ff52006-11-08 06:47:33 +00005371 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
5372 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005373 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005374 ;}
5375 break;
5376
Reid Spencer3da59db2006-11-27 01:05:10 +00005377 case 267:
5378#line 2852 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005379 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005380 if (!isa<PointerType>((yyvsp[-1].TypeVal).type->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005381 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer3da59db2006-11-27 01:05:10 +00005382 (yyvsp[-1].TypeVal).type->get()->getDescription());
5383 if (!cast<PointerType>((yyvsp[-1].TypeVal).type->get())->getElementType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005384 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer3da59db2006-11-27 01:05:10 +00005385 (yyvsp[-1].TypeVal).type->get()->getDescription());
5386 Value* tmpVal = getVal((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005387 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005388 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
Reid Spencer3da59db2006-11-27 01:05:10 +00005389 delete (yyvsp[-1].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00005390 ;}
5391 break;
5392
Reid Spencer3da59db2006-11-27 01:05:10 +00005393 case 268:
5394#line 2864 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005395 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005396 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal).type->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005397 if (!PT)
Reid Spencer61c83e02006-08-18 08:43:06 +00005398 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer3da59db2006-11-27 01:05:10 +00005399 ((yyvsp[-1].TypeVal).type->get())->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005400 const Type *ElTy = PT->getElementType();
Reid Spencer3822ff52006-11-08 06:47:33 +00005401 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5402 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005403 "' into space of type '" + ElTy->getDescription() + "'!");
5404
Reid Spencer3da59db2006-11-27 01:05:10 +00005405 Value* tmpVal = getVal((yyvsp[-1].TypeVal).type->get(), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005406 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005407 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
Reid Spencer3da59db2006-11-27 01:05:10 +00005408 delete (yyvsp[-1].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00005409 ;}
5410 break;
5411
Reid Spencer3da59db2006-11-27 01:05:10 +00005412 case 269:
5413#line 2879 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer3822ff52006-11-08 06:47:33 +00005414 {
Reid Spencer3da59db2006-11-27 01:05:10 +00005415 if (!isa<PointerType>((yyvsp[-2].TypeVal).type->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005416 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005417
5418 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
5419 // indices to uint struct indices for compatibility.
5420 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer3da59db2006-11-27 01:05:10 +00005421 GTI = gep_type_begin((yyvsp[-2].TypeVal).type->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()),
5422 GTE = gep_type_end((yyvsp[-2].TypeVal).type->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end());
Reid Spencer3822ff52006-11-08 06:47:33 +00005423 for (unsigned i = 0, e = (yyvsp[0].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005424 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer3822ff52006-11-08 06:47:33 +00005425 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[0].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00005426 if (CUI->getType() == Type::UByteTy)
Reid Spencer3822ff52006-11-08 06:47:33 +00005427 (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005428
Reid Spencer3da59db2006-11-27 01:05:10 +00005429 if (!GetElementPtrInst::getIndexedType((yyvsp[-2].TypeVal).type->get(), *(yyvsp[0].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005430 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer3da59db2006-11-27 01:05:10 +00005431 (yyvsp[-2].TypeVal).type->get()->getDescription()+ "'!");
5432 Value* tmpVal = getVal((yyvsp[-2].TypeVal).type->get(), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005433 CHECK_FOR_ERROR
Reid Spencer3822ff52006-11-08 06:47:33 +00005434 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
Reid Spencer3da59db2006-11-27 01:05:10 +00005435 delete (yyvsp[-2].TypeVal).type;
Reid Spencer3822ff52006-11-08 06:47:33 +00005436 delete (yyvsp[0].ValueList);
5437 ;}
5438 break;
5439
5440
5441 default: break;
5442 }
5443
5444/* Line 1126 of yacc.c. */
Reid Spencer3da59db2006-11-27 01:05:10 +00005445#line 5446 "llvmAsmParser.tab.c"
Reid Spencer5b7e7532006-09-28 19:28:24 +00005446
5447 yyvsp -= yylen;
5448 yyssp -= yylen;
5449
Reid Spencer3822ff52006-11-08 06:47:33 +00005450
5451 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005452
5453 *++yyvsp = yyval;
5454
5455
Reid Spencer3822ff52006-11-08 06:47:33 +00005456 /* Now `shift' the result of the reduction. Determine what state
5457 that goes to, based on the state we popped back to and the rule
5458 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005459
5460 yyn = yyr1[yyn];
5461
Reid Spencer3822ff52006-11-08 06:47:33 +00005462 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5463 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005464 yystate = yytable[yystate];
5465 else
Reid Spencer3822ff52006-11-08 06:47:33 +00005466 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005467
5468 goto yynewstate;
5469
5470
Reid Spencer3822ff52006-11-08 06:47:33 +00005471/*------------------------------------.
5472| yyerrlab -- here on detecting error |
5473`------------------------------------*/
5474yyerrlab:
5475 /* If not already recovering from an error, report this error. */
5476 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005477 {
5478 ++yynerrs;
Reid Spencer3822ff52006-11-08 06:47:33 +00005479#if YYERROR_VERBOSE
Reid Spencer5b7e7532006-09-28 19:28:24 +00005480 yyn = yypact[yystate];
Chris Lattner224f84f2006-08-18 17:34:45 +00005481
Reid Spencer3822ff52006-11-08 06:47:33 +00005482 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencer5b7e7532006-09-28 19:28:24 +00005483 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005484 int yytype = YYTRANSLATE (yychar);
5485 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5486 YYSIZE_T yysize = yysize0;
5487 YYSIZE_T yysize1;
5488 int yysize_overflow = 0;
5489 char *yymsg = 0;
5490# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5491 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5492 int yyx;
Reid Spencer5b7e7532006-09-28 19:28:24 +00005493
Reid Spencer3822ff52006-11-08 06:47:33 +00005494#if 0
5495 /* This is so xgettext sees the translatable formats that are
5496 constructed on the fly. */
5497 YY_("syntax error, unexpected %s");
5498 YY_("syntax error, unexpected %s, expecting %s");
5499 YY_("syntax error, unexpected %s, expecting %s or %s");
5500 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5501 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5502#endif
5503 char *yyfmt;
5504 char const *yyf;
5505 static char const yyunexpected[] = "syntax error, unexpected %s";
5506 static char const yyexpecting[] = ", expecting %s";
5507 static char const yyor[] = " or %s";
5508 char yyformat[sizeof yyunexpected
5509 + sizeof yyexpecting - 1
5510 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5511 * (sizeof yyor - 1))];
5512 char const *yyprefix = yyexpecting;
5513
5514 /* Start YYX at -YYN if negative to avoid negative indexes in
5515 YYCHECK. */
5516 int yyxbegin = yyn < 0 ? -yyn : 0;
5517
5518 /* Stay within bounds of both yycheck and yytname. */
5519 int yychecklim = YYLAST - yyn;
5520 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5521 int yycount = 1;
5522
5523 yyarg[0] = yytname[yytype];
5524 yyfmt = yystpcpy (yyformat, yyunexpected);
5525
5526 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5527 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5528 {
5529 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5530 {
5531 yycount = 1;
5532 yysize = yysize0;
5533 yyformat[sizeof yyunexpected - 1] = '\0';
5534 break;
5535 }
5536 yyarg[yycount++] = yytname[yyx];
5537 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5538 yysize_overflow |= yysize1 < yysize;
5539 yysize = yysize1;
5540 yyfmt = yystpcpy (yyfmt, yyprefix);
5541 yyprefix = yyor;
5542 }
5543
5544 yyf = YY_(yyformat);
5545 yysize1 = yysize + yystrlen (yyf);
5546 yysize_overflow |= yysize1 < yysize;
5547 yysize = yysize1;
5548
5549 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5550 yymsg = (char *) YYSTACK_ALLOC (yysize);
5551 if (yymsg)
Reid Spencer5b7e7532006-09-28 19:28:24 +00005552 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005553 /* Avoid sprintf, as that infringes on the user's name space.
5554 Don't have undefined behavior even if the translation
5555 produced a string with the wrong number of "%s"s. */
5556 char *yyp = yymsg;
5557 int yyi = 0;
5558 while ((*yyp = *yyf))
Reid Spencer5b7e7532006-09-28 19:28:24 +00005559 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005560 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5561 {
5562 yyp += yytnamerr (yyp, yyarg[yyi++]);
5563 yyf += 2;
5564 }
5565 else
5566 {
5567 yyp++;
5568 yyf++;
5569 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00005570 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005571 yyerror (yymsg);
5572 YYSTACK_FREE (yymsg);
Reid Spencer5b7e7532006-09-28 19:28:24 +00005573 }
5574 else
Reid Spencer3822ff52006-11-08 06:47:33 +00005575 {
5576 yyerror (YY_("syntax error"));
5577 goto yyexhaustedlab;
5578 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00005579 }
5580 else
5581#endif /* YYERROR_VERBOSE */
Reid Spencer3822ff52006-11-08 06:47:33 +00005582 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005583 }
5584
Reid Spencer3822ff52006-11-08 06:47:33 +00005585
Reid Spencer68a24bd2005-08-27 18:50:39 +00005586
5587 if (yyerrstatus == 3)
5588 {
Reid Spencer3822ff52006-11-08 06:47:33 +00005589 /* If just tried and failed to reuse look-ahead token after an
5590 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005591
Reid Spencer3822ff52006-11-08 06:47:33 +00005592 if (yychar <= YYEOF)
5593 {
5594 /* Return failure if at end of input. */
5595 if (yychar == YYEOF)
5596 YYABORT;
5597 }
5598 else
5599 {
5600 yydestruct ("Error: discarding", yytoken, &yylval);
5601 yychar = YYEMPTY;
5602 }
5603 }
5604
5605 /* Else will try to reuse look-ahead token after shifting the error
5606 token. */
5607 goto yyerrlab1;
5608
5609
5610/*---------------------------------------------------.
5611| yyerrorlab -- error raised explicitly by YYERROR. |
5612`---------------------------------------------------*/
5613yyerrorlab:
5614
5615 /* Pacify compilers like GCC when the user code never invokes
5616 YYERROR and the label yyerrorlab therefore never appears in user
5617 code. */
5618 if (0)
5619 goto yyerrorlab;
5620
5621yyvsp -= yylen;
5622 yyssp -= yylen;
5623 yystate = *yyssp;
5624 goto yyerrlab1;
5625
5626
5627/*-------------------------------------------------------------.
5628| yyerrlab1 -- common code for both syntax error and YYERROR. |
5629`-------------------------------------------------------------*/
5630yyerrlab1:
5631 yyerrstatus = 3; /* Each real token shifted decrements this. */
5632
5633 for (;;)
5634 {
5635 yyn = yypact[yystate];
5636 if (yyn != YYPACT_NINF)
5637 {
5638 yyn += YYTERROR;
5639 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5640 {
5641 yyn = yytable[yyn];
5642 if (0 < yyn)
5643 break;
5644 }
5645 }
5646
5647 /* Pop the current state because it cannot handle the error token. */
5648 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005649 YYABORT;
5650
Chris Lattner8335e842006-01-23 23:05:42 +00005651
Reid Spencer3822ff52006-11-08 06:47:33 +00005652 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5653 YYPOPSTACK;
5654 yystate = *yyssp;
5655 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005656 }
5657
5658 if (yyn == YYFINAL)
5659 YYACCEPT;
5660
Reid Spencer68a24bd2005-08-27 18:50:39 +00005661 *++yyvsp = yylval;
Reid Spencer3822ff52006-11-08 06:47:33 +00005662
5663
5664 /* Shift the error token. */
5665 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005666
5667 yystate = yyn;
5668 goto yynewstate;
5669
Chris Lattnerf49c1762006-11-08 05:58:47 +00005670
Reid Spencer3822ff52006-11-08 06:47:33 +00005671/*-------------------------------------.
5672| yyacceptlab -- YYACCEPT comes here. |
5673`-------------------------------------*/
5674yyacceptlab:
5675 yyresult = 0;
5676 goto yyreturn;
5677
5678/*-----------------------------------.
5679| yyabortlab -- YYABORT comes here. |
5680`-----------------------------------*/
5681yyabortlab:
5682 yyresult = 1;
5683 goto yyreturn;
5684
5685#ifndef yyoverflow
5686/*-------------------------------------------------.
5687| yyexhaustedlab -- memory exhaustion comes here. |
5688`-------------------------------------------------*/
5689yyexhaustedlab:
5690 yyerror (YY_("memory exhausted"));
5691 yyresult = 2;
5692 /* Fall through. */
Chris Lattnerf49c1762006-11-08 05:58:47 +00005693#endif
Reid Spencer3822ff52006-11-08 06:47:33 +00005694
5695yyreturn:
5696 if (yychar != YYEOF && yychar != YYEMPTY)
5697 yydestruct ("Cleanup: discarding lookahead",
5698 yytoken, &yylval);
5699 while (yyssp != yyss)
5700 {
5701 yydestruct ("Cleanup: popping",
5702 yystos[*yyssp], yyvsp);
5703 YYPOPSTACK;
Chris Lattnerf49c1762006-11-08 05:58:47 +00005704 }
Reid Spencer3822ff52006-11-08 06:47:33 +00005705#ifndef yyoverflow
5706 if (yyss != yyssa)
5707 YYSTACK_FREE (yyss);
5708#endif
5709 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005710}
Reid Spencer3822ff52006-11-08 06:47:33 +00005711
5712
Reid Spencer3da59db2006-11-27 01:05:10 +00005713#line 2905 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005714
5715
5716void llvm::GenerateError(const std::string &message, int LineNo) {
5717 if (LineNo == -1) LineNo = llvmAsmlineno;
5718 // TODO: column number in exception
5719 if (TheParseError)
5720 TheParseError->setError(CurFilename, message, LineNo);
5721 TriggerError = 1;
5722}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005723
5724int yyerror(const char *ErrorMsg) {
5725 std::string where
5726 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5727 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5728 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5729 if (yychar == YYEMPTY || yychar == 0)
5730 errMsg += "end-of-file.";
5731 else
5732 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005733 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005734 return 0;
5735}
Reid Spencer3822ff52006-11-08 06:47:33 +00005736