blob: f8dba72ec0e9edd766a5e333411c1c61481dc44d [file] [log] [blame]
Reid Spencer21be8652006-10-22 07:03:43 +00001/* A Bison parser, made by GNU Bison 2.1. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002
Reid Spencer21be8652006-10-22 07:03:43 +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 Spencer21be8652006-10-22 07:03:43 +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 Spencer21be8652006-10-22 07:03:43 +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 Spencer21be8652006-10-22 07:03:43 +000053#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +000054#define yyerror llvmAsmerror
Reid Spencer21be8652006-10-22 07:03:43 +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 Spencer21be8652006-10-22 07:03:43 +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,
Reid Spencer1628cec2006-10-26 06:15:43 +0000145 UDIV = 336,
146 SDIV = 337,
147 FDIV = 338,
Reid Spencer3ed469c2006-11-02 20:25:50 +0000148 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,
166 PHI_TOK = 357,
167 CAST = 358,
168 SELECT = 359,
169 SHL = 360,
170 SHR = 361,
171 VAARG = 362,
172 EXTRACTELEMENT = 363,
173 INSERTELEMENT = 364,
174 SHUFFLEVECTOR = 365,
175 VAARG_old = 366,
176 VANEXT_old = 367
Reid Spencer21be8652006-10-22 07:03:43 +0000177 };
178#endif
179/* Tokens. */
180#define ESINT64VAL 258
181#define EUINT64VAL 259
182#define SINTVAL 260
183#define UINTVAL 261
184#define FPVAL 262
185#define VOID 263
186#define BOOL 264
187#define SBYTE 265
188#define UBYTE 266
189#define SHORT 267
190#define USHORT 268
191#define INT 269
192#define UINT 270
193#define LONG 271
194#define ULONG 272
195#define FLOAT 273
196#define DOUBLE 274
197#define TYPE 275
198#define LABEL 276
199#define VAR_ID 277
200#define LABELSTR 278
201#define STRINGCONSTANT 279
202#define IMPLEMENTATION 280
203#define ZEROINITIALIZER 281
204#define TRUETOK 282
205#define FALSETOK 283
206#define BEGINTOK 284
207#define ENDTOK 285
208#define DECLARE 286
209#define GLOBAL 287
210#define CONSTANT 288
211#define SECTION 289
212#define VOLATILE 290
213#define TO 291
214#define DOTDOTDOT 292
215#define NULL_TOK 293
216#define UNDEF 294
217#define CONST 295
218#define INTERNAL 296
219#define LINKONCE 297
220#define WEAK 298
221#define APPENDING 299
222#define DLLIMPORT 300
223#define DLLEXPORT 301
224#define EXTERN_WEAK 302
225#define OPAQUE 303
226#define NOT 304
227#define EXTERNAL 305
228#define TARGET 306
229#define TRIPLE 307
230#define ENDIAN 308
231#define POINTERSIZE 309
232#define LITTLE 310
233#define BIG 311
234#define ALIGN 312
235#define DEPLIBS 313
236#define CALL 314
237#define TAIL 315
238#define ASM_TOK 316
239#define MODULE 317
240#define SIDEEFFECT 318
241#define CC_TOK 319
242#define CCC_TOK 320
243#define CSRETCC_TOK 321
244#define FASTCC_TOK 322
245#define COLDCC_TOK 323
246#define X86_STDCALLCC_TOK 324
247#define X86_FASTCALLCC_TOK 325
248#define DATALAYOUT 326
249#define RET 327
250#define BR 328
251#define SWITCH 329
252#define INVOKE 330
253#define UNWIND 331
254#define UNREACHABLE 332
255#define ADD 333
256#define SUB 334
257#define MUL 335
Reid Spencer1628cec2006-10-26 06:15:43 +0000258#define UDIV 336
259#define SDIV 337
260#define FDIV 338
Reid Spencer3ed469c2006-11-02 20:25:50 +0000261#define UREM 339
262#define SREM 340
263#define FREM 341
264#define AND 342
265#define OR 343
266#define XOR 344
267#define SETLE 345
268#define SETGE 346
269#define SETLT 347
270#define SETGT 348
271#define SETEQ 349
272#define SETNE 350
273#define MALLOC 351
274#define ALLOCA 352
275#define FREE 353
276#define LOAD 354
277#define STORE 355
278#define GETELEMENTPTR 356
279#define PHI_TOK 357
280#define CAST 358
281#define SELECT 359
282#define SHL 360
283#define SHR 361
284#define VAARG 362
285#define EXTRACTELEMENT 363
286#define INSERTELEMENT 364
287#define SHUFFLEVECTOR 365
288#define VAARG_old 366
289#define VANEXT_old 367
Reid Spencer21be8652006-10-22 07:03:43 +0000290
291
292
293
294/* Copy the first part of user declarations. */
Reid Spencer3ed469c2006-11-02 20:25:50 +0000295#line 14 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000296
297#include "ParserInternals.h"
298#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000299#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000300#include "llvm/Instructions.h"
301#include "llvm/Module.h"
302#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000303#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000304#include "llvm/Support/GetElementPtrTypeIterator.h"
305#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000306#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000307#include <algorithm>
308#include <iostream>
309#include <list>
310#include <utility>
311
Reid Spencere4f47592006-08-18 17:32:55 +0000312// The following is a gross hack. In order to rid the libAsmParser library of
313// exceptions, we have to have a way of getting the yyparse function to go into
314// an error situation. So, whenever we want an error to occur, the GenerateError
315// function (see bottom of file) sets TriggerError. Then, at the end of each
316// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
317// (a goto) to put YACC in error state. Furthermore, several calls to
318// GenerateError are made from inside productions and they must simulate the
319// previous exception behavior by exiting the production immediately. We have
320// replaced these with the GEN_ERROR macro which calls GeneratError and then
321// immediately invokes YYERROR. This would be so much cleaner if it was a
322// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000323static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000324#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000325#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
326
Reid Spencer68a24bd2005-08-27 18:50:39 +0000327int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
328int yylex(); // declaration" of xxx warnings.
329int yyparse();
330
331namespace llvm {
332 std::string CurFilename;
333}
334using namespace llvm;
335
336static Module *ParserResult;
337
338// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
339// relating to upreferences in the input stream.
340//
341//#define DEBUG_UPREFS 1
342#ifdef DEBUG_UPREFS
343#define UR_OUT(X) std::cerr << X
344#else
345#define UR_OUT(X)
346#endif
347
348#define YYERROR_VERBOSE 1
349
350static bool ObsoleteVarArgs;
351static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000352static BasicBlock *CurBB;
353static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000354
355
356// This contains info used when building the body of a function. It is
357// destroyed when the function is completed.
358//
359typedef std::vector<Value *> ValueList; // Numbered defs
360static void
361ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
362 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
363
364static struct PerModuleInfo {
365 Module *CurrentModule;
366 std::map<const Type *, ValueList> Values; // Module level numbered definitions
367 std::map<const Type *,ValueList> LateResolveValues;
368 std::vector<PATypeHolder> Types;
369 std::map<ValID, PATypeHolder> LateResolveTypes;
370
371 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000372 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000373 /// that we can resolve them later and print error messages as appropriate.
374 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
375
376 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
377 // references to global values. Global values may be referenced before they
378 // are defined, and if so, the temporary object that they represent is held
379 // here. This is used for forward references of GlobalValues.
380 //
381 typedef std::map<std::pair<const PointerType *,
382 ValID>, GlobalValue*> GlobalRefsType;
383 GlobalRefsType GlobalRefs;
384
385 void ModuleDone() {
386 // If we could not resolve some functions at function compilation time
387 // (calls to functions before they are defined), resolve them now... Types
388 // are resolved when the constant pool has been completely parsed.
389 //
390 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000391 if (TriggerError)
392 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000393
394 // Check to make sure that all global value forward references have been
395 // resolved!
396 //
397 if (!GlobalRefs.empty()) {
398 std::string UndefinedReferences = "Unresolved global references exist:\n";
399
400 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
401 I != E; ++I) {
402 UndefinedReferences += " " + I->first.first->getDescription() + " " +
403 I->first.second.getName() + "\n";
404 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000405 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000406 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000407 }
408
Reid Spencere812fb22006-01-19 01:21:04 +0000409 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattnerd5efe842006-04-08 01:18:56 +0000410 for (Module::iterator FI = CurrentModule->begin(),
411 FE = CurrentModule->end(); FI != FE; )
Chris Lattnerc2c60382006-03-04 07:53:41 +0000412 UpgradeCallsToIntrinsic(FI++);
Reid Spencer0b118202006-01-16 21:12:35 +0000413
Reid Spencer68a24bd2005-08-27 18:50:39 +0000414 Values.clear(); // Clear out function local definitions
415 Types.clear();
416 CurrentModule = 0;
417 }
418
Reid Spencer68a24bd2005-08-27 18:50:39 +0000419 // GetForwardRefForGlobal - Check to see if there is a forward reference
420 // for this global. If so, remove it from the GlobalRefs map and return it.
421 // If not, just return null.
422 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
423 // Check to see if there is a forward reference to this global variable...
424 // if there is, eliminate it and patch the reference to use the new def'n.
425 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
426 GlobalValue *Ret = 0;
427 if (I != GlobalRefs.end()) {
428 Ret = I->second;
429 GlobalRefs.erase(I);
430 }
431 return Ret;
432 }
433} CurModule;
434
435static struct PerFunctionInfo {
436 Function *CurrentFunction; // Pointer to current function being created
437
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000438 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000439 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000440 bool isDeclare; // Is this function a forward declararation?
441 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000442
443 /// BBForwardRefs - When we see forward references to basic blocks, keep
444 /// track of them here.
445 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
446 std::vector<BasicBlock*> NumberedBlocks;
447 unsigned NextBBNum;
448
449 inline PerFunctionInfo() {
450 CurrentFunction = 0;
451 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000452 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000453 }
454
455 inline void FunctionStart(Function *M) {
456 CurrentFunction = M;
457 NextBBNum = 0;
458 }
459
460 void FunctionDone() {
461 NumberedBlocks.clear();
462
463 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000464 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000465 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000466 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000467 return;
468 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000469
470 // Resolve all forward references now.
471 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
472
473 Values.clear(); // Clear out function local definitions
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} CurFun; // Info for the current function...
479
480static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
481
482
483//===----------------------------------------------------------------------===//
484// Code to handle definitions of all the types
485//===----------------------------------------------------------------------===//
486
487static int InsertValue(Value *V,
488 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
489 if (V->hasName()) return -1; // Is this a numbered definition?
490
491 // Yes, insert the value into the value table...
492 ValueList &List = ValueTab[V->getType()];
493 List.push_back(V);
494 return List.size()-1;
495}
496
497static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
498 switch (D.Type) {
499 case ValID::NumberVal: // Is it a numbered definition?
500 // Module constants occupy the lowest numbered slots...
501 if ((unsigned)D.Num < CurModule.Types.size())
502 return CurModule.Types[(unsigned)D.Num];
503 break;
504 case ValID::NameVal: // Is it a named definition?
505 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
506 D.destroy(); // Free old strdup'd memory...
507 return N;
508 }
509 break;
510 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000511 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000512 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000513 }
514
515 // If we reached here, we referenced either a symbol that we don't know about
516 // or an id number that hasn't been read yet. We may be referencing something
517 // forward, so just create an entry to be resolved later and get to it...
518 //
519 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
520
521
522 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000523 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000524 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000525 return 0;
526 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000527 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000528 return 0;
529 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000530 }
531
532 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
533 if (I != CurModule.LateResolveTypes.end())
534 return I->second;
535
536 Type *Typ = OpaqueType::get();
537 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
538 return Typ;
539 }
540
541static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
542 SymbolTable &SymTab =
543 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
544 CurModule.CurrentModule->getSymbolTable();
545 return SymTab.lookup(Ty, Name);
546}
547
548// getValNonImprovising - Look up the value specified by the provided type and
549// the provided ValID. If the value exists and has already been defined, return
550// it. Otherwise return null.
551//
552static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000553 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000554 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000555 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000556 return 0;
557 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000558
559 switch (D.Type) {
560 case ValID::NumberVal: { // Is it a numbered definition?
561 unsigned Num = (unsigned)D.Num;
562
563 // Module constants occupy the lowest numbered slots...
564 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
565 if (VI != CurModule.Values.end()) {
566 if (Num < VI->second.size())
567 return VI->second[Num];
568 Num -= VI->second.size();
569 }
570
571 // Make sure that our type is within bounds
572 VI = CurFun.Values.find(Ty);
573 if (VI == CurFun.Values.end()) return 0;
574
575 // Check that the number is within bounds...
576 if (VI->second.size() <= Num) return 0;
577
578 return VI->second[Num];
579 }
580
581 case ValID::NameVal: { // Is it a named definition?
582 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
583 if (N == 0) return 0;
584
585 D.destroy(); // Free old strdup'd memory...
586 return N;
587 }
588
589 // Check to make sure that "Ty" is an integral type, and that our
590 // value will fit into the specified type...
591 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000592 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000593 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000594 itostr(D.ConstPool64) + "' is invalid for type '" +
595 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000596 return 0;
597 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000598 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000599
600 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000601 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
602 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000603 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000604 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000605 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000606 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000607 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000608 }
609 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000610 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000611 }
612
613 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000614 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000615 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000616 return 0;
617 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000618 return ConstantFP::get(Ty, D.ConstPoolFP);
619
620 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000621 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000622 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000623 return 0;
624 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000625 return ConstantPointerNull::get(cast<PointerType>(Ty));
626
627 case ValID::ConstUndefVal: // Is it an undef value?
628 return UndefValue::get(Ty);
629
Chris Lattner7aa61892005-12-21 17:53:23 +0000630 case ValID::ConstZeroVal: // Is it a zero value?
631 return Constant::getNullValue(Ty);
632
Reid Spencer68a24bd2005-08-27 18:50:39 +0000633 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000634 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000635 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000636 return 0;
637 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000638 return D.ConstantValue;
639
Chris Lattner0e9c3762006-01-25 22:27:16 +0000640 case ValID::InlineAsmVal: { // Inline asm expression
641 const PointerType *PTy = dyn_cast<PointerType>(Ty);
642 const FunctionType *FTy =
643 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000644 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000645 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000646 return 0;
647 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000648 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
649 D.IAD->HasSideEffects);
650 D.destroy(); // Free InlineAsmDescriptor.
651 return IA;
652 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000653 default:
654 assert(0 && "Unhandled case!");
655 return 0;
656 } // End of switch
657
658 assert(0 && "Unhandled case!");
659 return 0;
660}
661
662// getVal - This function is identical to getValNonImprovising, except that if a
663// value is not already defined, it "improvises" by creating a placeholder var
664// that looks and acts just like the requested variable. When the value is
665// defined later, all uses of the placeholder variable are replaced with the
666// real thing.
667//
668static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000669 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000670 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000671 return 0;
672 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000673
674 // See if the value has already been defined.
675 Value *V = getValNonImprovising(Ty, ID);
676 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000677 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000678
Reid Spencer5b7e7532006-09-28 19:28:24 +0000679 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000680 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000681 return 0;
682 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000683
684 // If we reached here, we referenced either a symbol that we don't know about
685 // or an id number that hasn't been read yet. We may be referencing something
686 // forward, so just create an entry to be resolved later and get to it...
687 //
688 V = new Argument(Ty);
689
690 // Remember where this forward reference came from. FIXME, shouldn't we try
691 // to recycle these things??
692 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
693 llvmAsmlineno)));
694
695 if (inFunctionScope())
696 InsertValue(V, CurFun.LateResolveValues);
697 else
698 InsertValue(V, CurModule.LateResolveValues);
699 return V;
700}
701
702/// getBBVal - This is used for two purposes:
703/// * If isDefinition is true, a new basic block with the specified ID is being
704/// defined.
705/// * If isDefinition is true, this is a reference to a basic block, which may
706/// or may not be a forward reference.
707///
708static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
709 assert(inFunctionScope() && "Can't get basic block at global scope!");
710
711 std::string Name;
712 BasicBlock *BB = 0;
713 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000714 default:
715 GenerateError("Illegal label reference " + ID.getName());
716 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000717 case ValID::NumberVal: // Is it a numbered definition?
718 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
719 CurFun.NumberedBlocks.resize(ID.Num+1);
720 BB = CurFun.NumberedBlocks[ID.Num];
721 break;
722 case ValID::NameVal: // Is it a named definition?
723 Name = ID.Name;
724 if (Value *N = CurFun.CurrentFunction->
725 getSymbolTable().lookup(Type::LabelTy, Name))
726 BB = cast<BasicBlock>(N);
727 break;
728 }
729
730 // See if the block has already been defined.
731 if (BB) {
732 // If this is the definition of the block, make sure the existing value was
733 // just a forward reference. If it was a forward reference, there will be
734 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000735 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000736 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000737 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000738 return 0;
739 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000740
741 ID.destroy(); // Free strdup'd memory.
742 return BB;
743 }
744
745 // Otherwise this block has not been seen before.
746 BB = new BasicBlock("", CurFun.CurrentFunction);
747 if (ID.Type == ValID::NameVal) {
748 BB->setName(ID.Name);
749 } else {
750 CurFun.NumberedBlocks[ID.Num] = BB;
751 }
752
753 // If this is not a definition, keep track of it so we can use it as a forward
754 // reference.
755 if (!isDefinition) {
756 // Remember where this forward reference came from.
757 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
758 } else {
759 // The forward declaration could have been inserted anywhere in the
760 // function: insert it into the correct place now.
761 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
762 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
763 }
764 ID.destroy();
765 return BB;
766}
767
768
769//===----------------------------------------------------------------------===//
770// Code to handle forward references in instructions
771//===----------------------------------------------------------------------===//
772//
773// This code handles the late binding needed with statements that reference
774// values not defined yet... for example, a forward branch, or the PHI node for
775// a loop body.
776//
777// This keeps a table (CurFun.LateResolveValues) of all such forward references
778// and back patchs after we are done.
779//
780
781// ResolveDefinitions - If we could not resolve some defs at parsing
782// time (forward branches, phi functions for loops, etc...) resolve the
783// defs now...
784//
785static void
786ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
787 std::map<const Type*,ValueList> *FutureLateResolvers) {
788 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
789 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
790 E = LateResolvers.end(); LRI != E; ++LRI) {
791 ValueList &List = LRI->second;
792 while (!List.empty()) {
793 Value *V = List.back();
794 List.pop_back();
795
796 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
797 CurModule.PlaceHolderInfo.find(V);
798 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
799
800 ValID &DID = PHI->second.first;
801
802 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000803 if (TriggerError)
804 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000805 if (TheRealValue) {
806 V->replaceAllUsesWith(TheRealValue);
807 delete V;
808 CurModule.PlaceHolderInfo.erase(PHI);
809 } else if (FutureLateResolvers) {
810 // Functions have their unresolved items forwarded to the module late
811 // resolver table
812 InsertValue(V, *FutureLateResolvers);
813 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000814 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000815 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000816 "' of type '" + V->getType()->getDescription() + "'",
817 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000818 return;
819 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000820 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000821 itostr(DID.Num) + " of type '" +
822 V->getType()->getDescription() + "'",
823 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000824 return;
825 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000826 }
827 }
828 }
829
830 LateResolvers.clear();
831}
832
833// ResolveTypeTo - A brand new type was just declared. This means that (if
834// name is not null) things referencing Name can be resolved. Otherwise, things
835// refering to the number can be resolved. Do this now.
836//
837static void ResolveTypeTo(char *Name, const Type *ToTy) {
838 ValID D;
839 if (Name) D = ValID::create(Name);
840 else D = ValID::create((int)CurModule.Types.size());
841
842 std::map<ValID, PATypeHolder>::iterator I =
843 CurModule.LateResolveTypes.find(D);
844 if (I != CurModule.LateResolveTypes.end()) {
845 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
846 CurModule.LateResolveTypes.erase(I);
847 }
848}
849
850// setValueName - Set the specified value to the name given. The name may be
851// null potentially, in which case this is a noop. The string passed in is
852// assumed to be a malloc'd string buffer, and is free'd by this function.
853//
854static void setValueName(Value *V, char *NameStr) {
855 if (NameStr) {
856 std::string Name(NameStr); // Copy string
857 free(NameStr); // Free old string
858
Reid Spencer5b7e7532006-09-28 19:28:24 +0000859 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000860 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000861 return;
862 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000863
864 assert(inFunctionScope() && "Must be in function scope!");
865 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000866 if (ST.lookup(V->getType(), Name)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000867 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000868 V->getType()->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000869 return;
870 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000871
872 // Set the name.
873 V->setName(Name);
874 }
875}
876
877/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
878/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000879static GlobalVariable *
880ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
881 bool isConstantGlobal, const Type *Ty,
882 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000883 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000884 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000885 return 0;
886 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000887
888 const PointerType *PTy = PointerType::get(Ty);
889
890 std::string Name;
891 if (NameStr) {
892 Name = NameStr; // Copy string
893 free(NameStr); // Free old string
894 }
895
896 // See if this global value was forward referenced. If so, recycle the
897 // object.
898 ValID ID;
899 if (!Name.empty()) {
900 ID = ValID::create((char*)Name.c_str());
901 } else {
902 ID = ValID::create((int)CurModule.Values[PTy].size());
903 }
904
905 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
906 // Move the global to the end of the list, from whereever it was
907 // previously inserted.
908 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
909 CurModule.CurrentModule->getGlobalList().remove(GV);
910 CurModule.CurrentModule->getGlobalList().push_back(GV);
911 GV->setInitializer(Initializer);
912 GV->setLinkage(Linkage);
913 GV->setConstant(isConstantGlobal);
914 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000915 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000916 }
917
918 // If this global has a name, check to see if there is already a definition
919 // of this global in the module. If so, merge as appropriate. Note that
920 // this is really just a hack around problems in the CFE. :(
921 if (!Name.empty()) {
922 // We are a simple redefinition of a value, check to see if it is defined
923 // the same as the old one.
924 if (GlobalVariable *EGV =
925 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
926 // We are allowed to redefine a global variable in two circumstances:
927 // 1. If at least one of the globals is uninitialized or
928 // 2. If both initializers have the same value.
929 //
930 if (!EGV->hasInitializer() || !Initializer ||
931 EGV->getInitializer() == Initializer) {
932
933 // Make sure the existing global version gets the initializer! Make
934 // sure that it also gets marked const if the new version is.
935 if (Initializer && !EGV->hasInitializer())
936 EGV->setInitializer(Initializer);
937 if (isConstantGlobal)
938 EGV->setConstant(true);
939 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000940 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000941 }
942
Reid Spencer61c83e02006-08-18 08:43:06 +0000943 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000944 "' in the '" + Ty->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000945 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000946 }
947 }
948
949 // Otherwise there is no existing GV to use, create one now.
950 GlobalVariable *GV =
951 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
952 CurModule.CurrentModule);
953 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000954 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000955}
956
957// setTypeName - Set the specified type to the name given. The name may be
958// null potentially, in which case this is a noop. The string passed in is
959// assumed to be a malloc'd string buffer, and is freed by this function.
960//
961// This function returns true if the type has already been defined, but is
962// allowed to be redefined in the specified context. If the name is a new name
963// for the type plane, it is inserted and false is returned.
964static bool setTypeName(const Type *T, char *NameStr) {
965 assert(!inFunctionScope() && "Can't give types function-local names!");
966 if (NameStr == 0) return false;
967
968 std::string Name(NameStr); // Copy string
969 free(NameStr); // Free old string
970
971 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000972 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000973 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000974 return false;
975 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000976
977 // Set the type name, checking for conflicts as we do so.
978 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
979
980 if (AlreadyExists) { // Inserting a name that is already defined???
981 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
982 assert(Existing && "Conflict but no matching type?");
983
984 // There is only one case where this is allowed: when we are refining an
985 // opaque type. In this case, Existing will be an opaque type.
986 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
987 // We ARE replacing an opaque type!
988 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
989 return true;
990 }
991
992 // Otherwise, this is an attempt to redefine a type. That's okay if
993 // the redefinition is identical to the original. This will be so if
994 // Existing and T point to the same Type object. In this one case we
995 // allow the equivalent redefinition.
996 if (Existing == T) return true; // Yes, it's equal.
997
998 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer61c83e02006-08-18 08:43:06 +0000999 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00001000 T->getDescription() + "' type plane!");
1001 }
1002
1003 return false;
1004}
1005
1006//===----------------------------------------------------------------------===//
1007// Code for handling upreferences in type names...
1008//
1009
1010// TypeContains - Returns true if Ty directly contains E in it.
1011//
1012static bool TypeContains(const Type *Ty, const Type *E) {
1013 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1014 E) != Ty->subtype_end();
1015}
1016
1017namespace {
1018 struct UpRefRecord {
1019 // NestingLevel - The number of nesting levels that need to be popped before
1020 // this type is resolved.
1021 unsigned NestingLevel;
1022
1023 // LastContainedTy - This is the type at the current binding level for the
1024 // type. Every time we reduce the nesting level, this gets updated.
1025 const Type *LastContainedTy;
1026
1027 // UpRefTy - This is the actual opaque type that the upreference is
1028 // represented with.
1029 OpaqueType *UpRefTy;
1030
1031 UpRefRecord(unsigned NL, OpaqueType *URTy)
1032 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1033 };
1034}
1035
1036// UpRefs - A list of the outstanding upreferences that need to be resolved.
1037static std::vector<UpRefRecord> UpRefs;
1038
1039/// HandleUpRefs - Every time we finish a new layer of types, this function is
1040/// called. It loops through the UpRefs vector, which is a list of the
1041/// currently active types. For each type, if the up reference is contained in
1042/// the newly completed type, we decrement the level count. When the level
1043/// count reaches zero, the upreferenced type is the type that is passed in:
1044/// thus we can complete the cycle.
1045///
1046static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001047 // If Ty isn't abstract, or if there are no up-references in it, then there is
1048 // nothing to resolve here.
1049 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1050
Reid Spencer68a24bd2005-08-27 18:50:39 +00001051 PATypeHolder Ty(ty);
1052 UR_OUT("Type '" << Ty->getDescription() <<
1053 "' newly formed. Resolving upreferences.\n" <<
1054 UpRefs.size() << " upreferences active!\n");
1055
1056 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1057 // to zero), we resolve them all together before we resolve them to Ty. At
1058 // the end of the loop, if there is anything to resolve to Ty, it will be in
1059 // this variable.
1060 OpaqueType *TypeToResolve = 0;
1061
1062 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1063 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1064 << UpRefs[i].second->getDescription() << ") = "
1065 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1066 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1067 // Decrement level of upreference
1068 unsigned Level = --UpRefs[i].NestingLevel;
1069 UpRefs[i].LastContainedTy = Ty;
1070 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1071 if (Level == 0) { // Upreference should be resolved!
1072 if (!TypeToResolve) {
1073 TypeToResolve = UpRefs[i].UpRefTy;
1074 } else {
1075 UR_OUT(" * Resolving upreference for "
1076 << UpRefs[i].second->getDescription() << "\n";
1077 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1078 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1079 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1080 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1081 }
1082 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1083 --i; // Do not skip the next element...
1084 }
1085 }
1086 }
1087
1088 if (TypeToResolve) {
1089 UR_OUT(" * Resolving upreference for "
1090 << UpRefs[i].second->getDescription() << "\n";
1091 std::string OldName = TypeToResolve->getDescription());
1092 TypeToResolve->refineAbstractTypeTo(Ty);
1093 }
1094
1095 return Ty;
1096}
1097
Reid Spencer1628cec2006-10-26 06:15:43 +00001098/// This function is used to obtain the correct opcode for an instruction when
1099/// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both
1100/// an opcode and an "obsolete" flag. These are generated by the lexer and
1101/// the "obsolete" member will be true when the lexer encounters the token for
1102/// an obsolete opcode. For example, "div" was replaced by [usf]div but we need
1103/// to maintain backwards compatibility for asm files that still have the "div"
1104/// instruction. This function handles converting div -> [usf]div appropriately.
1105/// @brief Convert obsolete opcodes to new values
1106static void
1107sanitizeOpCode(OpcodeInfo<Instruction::BinaryOps> &OI, const PATypeHolder& PATy)
1108{
1109 // If its not obsolete, don't do anything
1110 if (!OI.obsolete)
1111 return;
1112
1113 // If its a packed type we want to use the element type
1114 const Type* Ty = PATy;
1115 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1116 Ty = PTy->getElementType();
1117
1118 // Depending on the opcode ..
1119 switch (OI.opcode) {
1120 default:
Reid Spencer3ed469c2006-11-02 20:25:50 +00001121 GenerateError("Invalid obsolete opCode (check Lexer.l)");
Reid Spencer1628cec2006-10-26 06:15:43 +00001122 break;
1123 case Instruction::UDiv:
1124 // Handle cases where the opcode needs to change
1125 if (Ty->isFloatingPoint())
1126 OI.opcode = Instruction::FDiv;
1127 else if (Ty->isSigned())
1128 OI.opcode = Instruction::SDiv;
1129 break;
Reid Spencer3ed469c2006-11-02 20:25:50 +00001130 case Instruction::URem:
1131 if (Ty->isFloatingPoint())
1132 OI.opcode = Instruction::FRem;
1133 else if (Ty->isSigned())
1134 OI.opcode = Instruction::SRem;
1135 break;
Reid Spencer1628cec2006-10-26 06:15:43 +00001136 }
1137 // Its not obsolete any more, we fixed it.
1138 OI.obsolete = false;
1139}
Reid Spencer3ed469c2006-11-02 20:25:50 +00001140
Reid Spencer68a24bd2005-08-27 18:50:39 +00001141// common code from the two 'RunVMAsmParser' functions
Reid Spencer5b7e7532006-09-28 19:28:24 +00001142static Module* RunParser(Module * M) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001143
1144 llvmAsmlineno = 1; // Reset the current line number...
1145 ObsoleteVarArgs = false;
1146 NewVarArgs = false;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001147 CurModule.CurrentModule = M;
Reid Spencerf63697d2006-10-09 17:36:59 +00001148
1149 // Check to make sure the parser succeeded
1150 if (yyparse()) {
1151 if (ParserResult)
1152 delete ParserResult;
1153 return 0;
1154 }
1155
1156 // Check to make sure that parsing produced a result
Reid Spencer61c83e02006-08-18 08:43:06 +00001157 if (!ParserResult)
1158 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001159
Reid Spencerf63697d2006-10-09 17:36:59 +00001160 // Reset ParserResult variable while saving its value for the result.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001161 Module *Result = ParserResult;
1162 ParserResult = 0;
1163
1164 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1165 {
1166 Function* F;
1167 if ((F = Result->getNamedFunction("llvm.va_start"))
1168 && F->getFunctionType()->getNumParams() == 0)
1169 ObsoleteVarArgs = true;
1170 if((F = Result->getNamedFunction("llvm.va_copy"))
1171 && F->getFunctionType()->getNumParams() == 1)
1172 ObsoleteVarArgs = true;
1173 }
1174
Reid Spencer5b7e7532006-09-28 19:28:24 +00001175 if (ObsoleteVarArgs && NewVarArgs) {
1176 GenerateError(
1177 "This file is corrupt: it uses both new and old style varargs");
1178 return 0;
1179 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001180
1181 if(ObsoleteVarArgs) {
1182 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001183 if (F->arg_size() != 0) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001184 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001185 return 0;
1186 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001187
1188 //foo = va_start()
1189 // ->
1190 //bar = alloca typeof(foo)
1191 //va_start(bar)
1192 //foo = load bar
1193
1194 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1195 const Type* ArgTy = F->getFunctionType()->getReturnType();
1196 const Type* ArgTyPtr = PointerType::get(ArgTy);
1197 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001198 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001199
1200 while (!F->use_empty()) {
1201 CallInst* CI = cast<CallInst>(F->use_back());
1202 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1203 new CallInst(NF, bar, "", CI);
1204 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1205 CI->replaceAllUsesWith(foo);
1206 CI->getParent()->getInstList().erase(CI);
1207 }
1208 Result->getFunctionList().erase(F);
1209 }
1210
1211 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001212 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001213 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001214 return 0;
1215 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001216
1217 //vaend foo
1218 // ->
1219 //bar = alloca 1 of typeof(foo)
1220 //vaend bar
1221 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1222 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1223 const Type* ArgTyPtr = PointerType::get(ArgTy);
1224 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001225 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001226
1227 while (!F->use_empty()) {
1228 CallInst* CI = cast<CallInst>(F->use_back());
1229 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1230 new StoreInst(CI->getOperand(1), bar, CI);
1231 new CallInst(NF, bar, "", CI);
1232 CI->getParent()->getInstList().erase(CI);
1233 }
1234 Result->getFunctionList().erase(F);
1235 }
1236
1237 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001238 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001239 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001240 return 0;
1241 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001242 //foo = vacopy(bar)
1243 // ->
1244 //a = alloca 1 of typeof(foo)
1245 //b = alloca 1 of typeof(foo)
1246 //store bar -> b
1247 //vacopy(a, b)
1248 //foo = load a
1249
1250 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1251 const Type* ArgTy = F->getFunctionType()->getReturnType();
1252 const Type* ArgTyPtr = PointerType::get(ArgTy);
1253 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001254 RetTy, ArgTyPtr, ArgTyPtr,
1255 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001256
1257 while (!F->use_empty()) {
1258 CallInst* CI = cast<CallInst>(F->use_back());
1259 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1260 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1261 new StoreInst(CI->getOperand(1), b, CI);
1262 new CallInst(NF, a, b, "", CI);
1263 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1264 CI->replaceAllUsesWith(foo);
1265 CI->getParent()->getInstList().erase(CI);
1266 }
1267 Result->getFunctionList().erase(F);
1268 }
1269 }
1270
1271 return Result;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001272}
Reid Spencer68a24bd2005-08-27 18:50:39 +00001273
1274//===----------------------------------------------------------------------===//
1275// RunVMAsmParser - Define an interface to this parser
1276//===----------------------------------------------------------------------===//
1277//
1278Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1279 set_scan_file(F);
1280
1281 CurFilename = Filename;
1282 return RunParser(new Module(CurFilename));
1283}
1284
1285Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1286 set_scan_string(AsmString);
1287
1288 CurFilename = "from_memory";
1289 if (M == NULL) {
1290 return RunParser(new Module (CurFilename));
1291 } else {
1292 return RunParser(M);
1293 }
1294}
1295
1296
Reid Spencer21be8652006-10-22 07:03:43 +00001297
1298/* Enabling traces. */
1299#ifndef YYDEBUG
1300# define YYDEBUG 0
1301#endif
1302
1303/* Enabling verbose error messages. */
1304#ifdef YYERROR_VERBOSE
1305# undef YYERROR_VERBOSE
1306# define YYERROR_VERBOSE 1
1307#else
1308# define YYERROR_VERBOSE 0
1309#endif
1310
1311/* Enabling the token table. */
1312#ifndef YYTOKEN_TABLE
1313# define YYTOKEN_TABLE 0
1314#endif
1315
1316#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer3ed469c2006-11-02 20:25:50 +00001317#line 1016 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00001318typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001319 llvm::Module *ModuleVal;
1320 llvm::Function *FunctionVal;
1321 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1322 llvm::BasicBlock *BasicBlockVal;
1323 llvm::TerminatorInst *TermInstVal;
1324 llvm::Instruction *InstVal;
1325 llvm::Constant *ConstVal;
1326
1327 const llvm::Type *PrimType;
1328 llvm::PATypeHolder *TypeVal;
1329 llvm::Value *ValueVal;
1330
1331 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1332 std::vector<llvm::Value*> *ValueList;
1333 std::list<llvm::PATypeHolder> *TypeList;
1334 // Represent the RHS of PHI node
1335 std::list<std::pair<llvm::Value*,
1336 llvm::BasicBlock*> > *PHIList;
1337 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1338 std::vector<llvm::Constant*> *ConstVector;
1339
1340 llvm::GlobalValue::LinkageTypes Linkage;
1341 int64_t SInt64Val;
1342 uint64_t UInt64Val;
1343 int SIntVal;
1344 unsigned UIntVal;
1345 double FPVal;
1346 bool BoolVal;
1347
1348 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001349 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001350
Reid Spencer1628cec2006-10-26 06:15:43 +00001351 BinaryOpInfo BinaryOpVal;
1352 TermOpInfo TermOpVal;
1353 MemOpInfo MemOpVal;
1354 OtherOpInfo OtherOpVal;
1355 llvm::Module::Endianness Endianness;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001356} YYSTYPE;
Reid Spencer21be8652006-10-22 07:03:43 +00001357/* Line 196 of yacc.c. */
Reid Spencer3ed469c2006-11-02 20:25:50 +00001358#line 1359 "llvmAsmParser.tab.c"
Reid Spencer21be8652006-10-22 07:03:43 +00001359# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1360# define YYSTYPE_IS_DECLARED 1
1361# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001362#endif
1363
1364
1365
Reid Spencer21be8652006-10-22 07:03:43 +00001366/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001367
1368
Reid Spencer21be8652006-10-22 07:03:43 +00001369/* Line 219 of yacc.c. */
Reid Spencer3ed469c2006-11-02 20:25:50 +00001370#line 1371 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001371
Reid Spencer21be8652006-10-22 07:03:43 +00001372#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1373# define YYSIZE_T __SIZE_TYPE__
1374#endif
1375#if ! defined (YYSIZE_T) && defined (size_t)
1376# define YYSIZE_T size_t
1377#endif
1378#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1379# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1380# define YYSIZE_T size_t
1381#endif
1382#if ! defined (YYSIZE_T)
1383# define YYSIZE_T unsigned int
1384#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001385
Reid Spencer21be8652006-10-22 07:03:43 +00001386#ifndef YY_
1387# if YYENABLE_NLS
1388# if ENABLE_NLS
1389# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1390# define YY_(msgid) dgettext ("bison-runtime", msgid)
1391# endif
1392# endif
1393# ifndef YY_
1394# define YY_(msgid) msgid
1395# endif
1396#endif
1397
1398#if ! defined (yyoverflow) || YYERROR_VERBOSE
1399
1400/* The parser invokes alloca or malloc; define the necessary symbols. */
1401
1402# ifdef YYSTACK_USE_ALLOCA
1403# if YYSTACK_USE_ALLOCA
1404# ifdef __GNUC__
1405# define YYSTACK_ALLOC __builtin_alloca
1406# else
1407# define YYSTACK_ALLOC alloca
1408# if defined (__STDC__) || defined (__cplusplus)
1409# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1410# define YYINCLUDED_STDLIB_H
1411# endif
1412# endif
1413# endif
1414# endif
1415
1416# ifdef YYSTACK_ALLOC
1417 /* Pacify GCC's `empty if-body' warning. */
1418# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1419# ifndef YYSTACK_ALLOC_MAXIMUM
1420 /* The OS might guarantee only one guard page at the bottom of the stack,
1421 and a page size can be as small as 4096 bytes. So we cannot safely
1422 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1423 to allow for a few compiler-allocated temporary stack slots. */
1424# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1425# endif
1426# else
1427# define YYSTACK_ALLOC YYMALLOC
1428# define YYSTACK_FREE YYFREE
1429# ifndef YYSTACK_ALLOC_MAXIMUM
1430# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1431# endif
1432# ifdef __cplusplus
1433extern "C" {
1434# endif
1435# ifndef YYMALLOC
1436# define YYMALLOC malloc
1437# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1438 && (defined (__STDC__) || defined (__cplusplus)))
1439void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1440# endif
1441# endif
1442# ifndef YYFREE
1443# define YYFREE free
1444# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1445 && (defined (__STDC__) || defined (__cplusplus)))
1446void free (void *); /* INFRINGES ON USER NAME SPACE */
1447# endif
1448# endif
1449# ifdef __cplusplus
1450}
1451# endif
1452# endif
1453#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1454
1455
1456#if (! defined (yyoverflow) \
1457 && (! defined (__cplusplus) \
1458 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1459
1460/* A type that is properly aligned for any stack member. */
1461union yyalloc
1462{
1463 short int yyss;
1464 YYSTYPE yyvs;
1465 };
1466
1467/* The size of the maximum gap between one aligned stack and the next. */
1468# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1469
1470/* The size of an array large to enough to hold all stacks, each with
1471 N elements. */
1472# define YYSTACK_BYTES(N) \
1473 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1474 + YYSTACK_GAP_MAXIMUM)
1475
1476/* Copy COUNT objects from FROM to TO. The source and destination do
1477 not overlap. */
1478# ifndef YYCOPY
1479# if defined (__GNUC__) && 1 < __GNUC__
1480# define YYCOPY(To, From, Count) \
1481 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1482# else
1483# define YYCOPY(To, From, Count) \
1484 do \
1485 { \
1486 YYSIZE_T yyi; \
1487 for (yyi = 0; yyi < (Count); yyi++) \
1488 (To)[yyi] = (From)[yyi]; \
1489 } \
1490 while (0)
1491# endif
1492# endif
1493
1494/* Relocate STACK from its old location to the new one. The
1495 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1496 elements in the stack, and YYPTR gives the new location of the
1497 stack. Advance YYPTR to a properly aligned location for the next
1498 stack. */
1499# define YYSTACK_RELOCATE(Stack) \
1500 do \
1501 { \
1502 YYSIZE_T yynewbytes; \
1503 YYCOPY (&yyptr->Stack, Stack, yysize); \
1504 Stack = &yyptr->Stack; \
1505 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1506 yyptr += yynewbytes / sizeof (*yyptr); \
1507 } \
1508 while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001509
1510#endif
1511
Reid Spencer21be8652006-10-22 07:03:43 +00001512#if defined (__STDC__) || defined (__cplusplus)
1513 typedef signed char yysigned_char;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001514#else
Reid Spencer21be8652006-10-22 07:03:43 +00001515 typedef short int yysigned_char;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001516#endif
1517
Reid Spencer21be8652006-10-22 07:03:43 +00001518/* YYFINAL -- State number of the termination state. */
1519#define YYFINAL 4
1520/* YYLAST -- Last index in YYTABLE. */
Reid Spencer3ed469c2006-11-02 20:25:50 +00001521#define YYLAST 1357
Reid Spencer21be8652006-10-22 07:03:43 +00001522
1523/* YYNTOKENS -- Number of terminals. */
Reid Spencer3ed469c2006-11-02 20:25:50 +00001524#define YYNTOKENS 127
Reid Spencer21be8652006-10-22 07:03:43 +00001525/* YYNNTS -- Number of nonterminals. */
1526#define YYNNTS 75
1527/* YYNRULES -- Number of rules. */
Reid Spencer3ed469c2006-11-02 20:25:50 +00001528#define YYNRULES 256
Reid Spencer21be8652006-10-22 07:03:43 +00001529/* YYNRULES -- Number of states. */
Reid Spencer3ed469c2006-11-02 20:25:50 +00001530#define YYNSTATES 521
Reid Spencer21be8652006-10-22 07:03:43 +00001531
1532/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1533#define YYUNDEFTOK 2
Reid Spencer3ed469c2006-11-02 20:25:50 +00001534#define YYMAXUTOK 367
Reid Spencer21be8652006-10-22 07:03:43 +00001535
1536#define YYTRANSLATE(YYX) \
1537 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1538
1539/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1540static const unsigned char yytranslate[] =
1541{
1542 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001546 116, 117, 125, 2, 114, 2, 2, 2, 2, 2,
Reid Spencer21be8652006-10-22 07:03:43 +00001547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001548 121, 113, 122, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer21be8652006-10-22 07:03:43 +00001549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001551 2, 118, 115, 120, 2, 2, 2, 2, 2, 126,
Reid Spencer21be8652006-10-22 07:03:43 +00001552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001554 119, 2, 2, 123, 2, 124, 2, 2, 2, 2,
Reid Spencer21be8652006-10-22 07:03:43 +00001555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1567 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1568 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1569 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1570 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1571 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1572 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1573 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1574 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1575 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1576 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1577 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001578 105, 106, 107, 108, 109, 110, 111, 112
Reid Spencer21be8652006-10-22 07:03:43 +00001579};
1580
1581#if YYDEBUG
1582/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1583 YYRHS. */
1584static const unsigned short int yyprhs[] =
1585{
1586 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1587 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1588 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001589 59, 61, 63, 65, 67, 69, 71, 73, 75, 78,
1590 79, 81, 83, 85, 87, 89, 91, 93, 94, 95,
1591 97, 99, 101, 103, 105, 107, 110, 111, 114, 115,
1592 119, 122, 123, 125, 126, 130, 132, 135, 137, 139,
Reid Spencer21be8652006-10-22 07:03:43 +00001593 141, 143, 145, 147, 149, 151, 153, 155, 157, 159,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001594 161, 163, 165, 167, 169, 171, 173, 175, 177, 180,
1595 185, 191, 197, 201, 204, 207, 209, 213, 215, 219,
1596 221, 222, 227, 231, 235, 240, 245, 249, 252, 255,
1597 258, 261, 264, 267, 270, 273, 276, 279, 286, 292,
1598 301, 308, 315, 322, 329, 336, 345, 354, 358, 360,
1599 362, 364, 366, 369, 372, 377, 380, 382, 387, 390,
1600 395, 396, 404, 405, 413, 414, 422, 423, 431, 435,
1601 440, 441, 443, 445, 447, 451, 455, 459, 463, 467,
1602 471, 473, 474, 476, 478, 480, 481, 484, 488, 490,
1603 492, 496, 498, 499, 508, 510, 512, 516, 518, 520,
1604 523, 524, 526, 528, 529, 534, 535, 537, 539, 541,
1605 543, 545, 547, 549, 551, 553, 557, 559, 565, 567,
1606 569, 571, 573, 576, 579, 582, 586, 589, 590, 592,
1607 595, 598, 602, 612, 622, 631, 645, 647, 649, 656,
1608 662, 665, 672, 680, 682, 686, 688, 689, 692, 694,
1609 700, 706, 712, 715, 720, 725, 732, 737, 742, 747,
1610 752, 759, 766, 769, 777, 779, 782, 783, 785, 786,
1611 790, 797, 801, 808, 811, 816, 823
Reid Spencer21be8652006-10-22 07:03:43 +00001612};
1613
1614/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1615static const short int yyrhs[] =
1616{
Reid Spencer3ed469c2006-11-02 20:25:50 +00001617 158, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencer21be8652006-10-22 07:03:43 +00001618 -1, 78, -1, 79, -1, 80, -1, 81, -1, 82,
1619 -1, 83, -1, 84, -1, 85, -1, 86, -1, 87,
Reid Spencer1628cec2006-10-26 06:15:43 +00001620 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001621 -1, 93, -1, 94, -1, 95, -1, 105, -1, 106,
1622 -1, 16, -1, 14, -1, 12, -1, 10, -1, 17,
1623 -1, 15, -1, 13, -1, 11, -1, 134, -1, 135,
1624 -1, 18, -1, 19, -1, 170, 113, -1, -1, 41,
1625 -1, 42, -1, 43, -1, 44, -1, 45, -1, 46,
1626 -1, 47, -1, -1, -1, 65, -1, 66, -1, 67,
1627 -1, 68, -1, 69, -1, 70, -1, 64, 4, -1,
1628 -1, 57, 4, -1, -1, 114, 57, 4, -1, 34,
1629 24, -1, -1, 143, -1, -1, 114, 146, 145, -1,
1630 143, -1, 57, 4, -1, 149, -1, 8, -1, 151,
1631 -1, 8, -1, 151, -1, 9, -1, 10, -1, 11,
1632 -1, 12, -1, 13, -1, 14, -1, 15, -1, 16,
1633 -1, 17, -1, 18, -1, 19, -1, 20, -1, 21,
1634 -1, 48, -1, 150, -1, 185, -1, 115, 4, -1,
1635 148, 116, 153, 117, -1, 118, 4, 119, 151, 120,
1636 -1, 121, 4, 119, 151, 122, -1, 123, 152, 124,
1637 -1, 123, 124, -1, 151, 125, -1, 151, -1, 152,
1638 114, 151, -1, 152, -1, 152, 114, 37, -1, 37,
1639 -1, -1, 149, 118, 156, 120, -1, 149, 118, 120,
1640 -1, 149, 126, 24, -1, 149, 121, 156, 122, -1,
1641 149, 123, 156, 124, -1, 149, 123, 124, -1, 149,
1642 38, -1, 149, 39, -1, 149, 185, -1, 149, 155,
1643 -1, 149, 26, -1, 134, 129, -1, 135, 4, -1,
1644 9, 27, -1, 9, 28, -1, 137, 7, -1, 103,
1645 116, 154, 36, 149, 117, -1, 101, 116, 154, 199,
1646 117, -1, 104, 116, 154, 114, 154, 114, 154, 117,
1647 -1, 130, 116, 154, 114, 154, 117, -1, 131, 116,
1648 154, 114, 154, 117, -1, 132, 116, 154, 114, 154,
1649 117, -1, 133, 116, 154, 114, 154, 117, -1, 108,
1650 116, 154, 114, 154, 117, -1, 109, 116, 154, 114,
1651 154, 114, 154, 117, -1, 110, 116, 154, 114, 154,
1652 114, 154, 117, -1, 156, 114, 154, -1, 154, -1,
1653 32, -1, 33, -1, 159, -1, 159, 179, -1, 159,
1654 181, -1, 159, 62, 61, 165, -1, 159, 25, -1,
1655 160, -1, 160, 138, 20, 147, -1, 160, 181, -1,
1656 160, 62, 61, 165, -1, -1, 160, 138, 139, 157,
1657 154, 161, 145, -1, -1, 160, 138, 50, 157, 149,
1658 162, 145, -1, -1, 160, 138, 45, 157, 149, 163,
1659 145, -1, -1, 160, 138, 47, 157, 149, 164, 145,
1660 -1, 160, 51, 167, -1, 160, 58, 113, 168, -1,
1661 -1, 24, -1, 56, -1, 55, -1, 53, 113, 166,
1662 -1, 54, 113, 4, -1, 52, 113, 24, -1, 71,
1663 113, 24, -1, 118, 169, 120, -1, 169, 114, 24,
1664 -1, 24, -1, -1, 22, -1, 24, -1, 170, -1,
1665 -1, 149, 171, -1, 173, 114, 172, -1, 172, -1,
1666 173, -1, 173, 114, 37, -1, 37, -1, -1, 140,
1667 147, 170, 116, 174, 117, 144, 141, -1, 29, -1,
1668 123, -1, 139, 175, 176, -1, 30, -1, 124, -1,
1669 188, 178, -1, -1, 45, -1, 47, -1, -1, 31,
1670 182, 180, 175, -1, -1, 63, -1, 3, -1, 4,
1671 -1, 7, -1, 27, -1, 28, -1, 38, -1, 39,
1672 -1, 26, -1, 121, 156, 122, -1, 155, -1, 61,
1673 183, 24, 114, 24, -1, 128, -1, 170, -1, 185,
1674 -1, 184, -1, 149, 186, -1, 188, 189, -1, 177,
1675 189, -1, 190, 138, 191, -1, 190, 193, -1, -1,
1676 23, -1, 72, 187, -1, 72, 8, -1, 73, 21,
1677 186, -1, 73, 9, 186, 114, 21, 186, 114, 21,
1678 186, -1, 74, 136, 186, 114, 21, 186, 118, 192,
1679 120, -1, 74, 136, 186, 114, 21, 186, 118, 120,
1680 -1, 75, 140, 147, 186, 116, 196, 117, 36, 21,
1681 186, 76, 21, 186, -1, 76, -1, 77, -1, 192,
1682 136, 184, 114, 21, 186, -1, 136, 184, 114, 21,
1683 186, -1, 138, 198, -1, 149, 118, 186, 114, 186,
1684 120, -1, 194, 114, 118, 186, 114, 186, 120, -1,
1685 187, -1, 195, 114, 187, -1, 195, -1, -1, 60,
1686 59, -1, 59, -1, 130, 149, 186, 114, 186, -1,
1687 131, 149, 186, 114, 186, -1, 132, 149, 186, 114,
1688 186, -1, 49, 187, -1, 133, 187, 114, 187, -1,
1689 103, 187, 36, 149, -1, 104, 187, 114, 187, 114,
1690 187, -1, 107, 187, 114, 149, -1, 111, 187, 114,
1691 149, -1, 112, 187, 114, 149, -1, 108, 187, 114,
1692 187, -1, 109, 187, 114, 187, 114, 187, -1, 110,
1693 187, 114, 187, 114, 187, -1, 102, 194, -1, 197,
1694 140, 147, 186, 116, 196, 117, -1, 201, -1, 114,
1695 195, -1, -1, 35, -1, -1, 96, 149, 142, -1,
1696 96, 149, 114, 15, 186, 142, -1, 97, 149, 142,
1697 -1, 97, 149, 114, 15, 186, 142, -1, 98, 187,
1698 -1, 200, 99, 149, 186, -1, 200, 100, 187, 114,
1699 149, 186, -1, 101, 149, 186, 199, -1
Reid Spencer21be8652006-10-22 07:03:43 +00001700};
1701
1702/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1703static const unsigned short int yyrline[] =
1704{
Reid Spencer3ed469c2006-11-02 20:25:50 +00001705 0, 1139, 1139, 1140, 1148, 1149, 1159, 1159, 1159, 1159,
1706 1159, 1159, 1159, 1159, 1159, 1160, 1160, 1160, 1161, 1161,
1707 1161, 1161, 1161, 1161, 1163, 1163, 1167, 1167, 1167, 1167,
1708 1168, 1168, 1168, 1168, 1169, 1169, 1170, 1170, 1173, 1177,
1709 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1191, 1192,
1710 1193, 1194, 1195, 1196, 1197, 1198, 1207, 1208, 1214, 1215,
1711 1223, 1231, 1232, 1237, 1238, 1239, 1244, 1258, 1258, 1259,
1712 1259, 1261, 1271, 1271, 1271, 1271, 1271, 1271, 1271, 1272,
1713 1272, 1272, 1272, 1272, 1272, 1273, 1277, 1281, 1289, 1297,
1714 1310, 1315, 1327, 1337, 1341, 1352, 1357, 1363, 1364, 1368,
1715 1372, 1383, 1409, 1423, 1453, 1479, 1500, 1513, 1523, 1528,
1716 1589, 1596, 1605, 1611, 1617, 1621, 1625, 1633, 1644, 1676,
1717 1684, 1711, 1722, 1728, 1736, 1742, 1748, 1757, 1761, 1769,
1718 1769, 1779, 1787, 1792, 1796, 1800, 1804, 1819, 1841, 1844,
1719 1847, 1847, 1855, 1855, 1863, 1863, 1871, 1871, 1880, 1883,
1720 1886, 1890, 1903, 1904, 1906, 1910, 1919, 1923, 1928, 1930,
1721 1935, 1940, 1949, 1949, 1950, 1950, 1952, 1959, 1965, 1972,
1722 1976, 1982, 1987, 1992, 2087, 2087, 2089, 2097, 2097, 2099,
1723 2104, 2105, 2106, 2108, 2108, 2118, 2122, 2127, 2131, 2135,
1724 2139, 2143, 2147, 2151, 2155, 2159, 2184, 2188, 2202, 2206,
1725 2212, 2212, 2218, 2223, 2227, 2236, 2247, 2252, 2264, 2277,
1726 2281, 2285, 2290, 2299, 2318, 2327, 2383, 2387, 2394, 2405,
1727 2418, 2427, 2436, 2446, 2450, 2457, 2457, 2459, 2463, 2468,
1728 2490, 2505, 2519, 2532, 2540, 2548, 2556, 2562, 2582, 2605,
1729 2611, 2617, 2623, 2638, 2697, 2704, 2707, 2712, 2716, 2723,
1730 2728, 2734, 2739, 2745, 2753, 2765, 2780
Reid Spencer21be8652006-10-22 07:03:43 +00001731};
1732#endif
1733
1734#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1735/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1736 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1737static const char *const yytname[] =
1738{
1739 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1740 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1741 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1742 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1743 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1744 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1745 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
1746 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1747 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
1748 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1749 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
1750 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1751 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
Reid Spencer3ed469c2006-11-02 20:25:50 +00001752 "MUL", "UDIV", "SDIV", "FDIV", "UREM", "SREM", "FREM", "AND", "OR",
1753 "XOR", "SETLE", "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "MALLOC",
1754 "ALLOCA", "FREE", "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", "CAST",
1755 "SELECT", "SHL", "SHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT",
1756 "SHUFFLEVECTOR", "VAARG_old", "VANEXT_old", "'='", "','", "'\\\\'",
1757 "'('", "')'", "'['", "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'",
1758 "'c'", "$accept", "INTVAL", "EINT64VAL", "ArithmeticOps", "LogicalOps",
1759 "SetCondOps", "ShiftOps", "SIntType", "UIntType", "IntType", "FPType",
1760 "OptAssign", "OptLinkage", "OptCallingConv", "OptAlign", "OptCAlign",
1761 "SectionString", "OptSection", "GlobalVarAttributes",
1762 "GlobalVarAttribute", "TypesV", "UpRTypesV", "Types", "PrimType",
1763 "UpRTypes", "TypeListI", "ArgTypeListI", "ConstVal", "ConstExpr",
1764 "ConstVector", "GlobalType", "Module", "FunctionList", "ConstPool", "@1",
1765 "@2", "@3", "@4", "AsmBlock", "BigOrLittle", "TargetDefinition",
1766 "LibrariesDefinition", "LibList", "Name", "OptName", "ArgVal",
1767 "ArgListH", "ArgList", "FunctionHeaderH", "BEGIN", "FunctionHeader",
1768 "END", "Function", "FnDeclareLinkage", "FunctionProto", "@5",
1769 "OptSideEffect", "ConstValueRef", "SymbolicValueRef", "ValueRef",
1770 "ResolvedVal", "BasicBlockList", "BasicBlock", "InstructionList",
1771 "BBTerminatorInst", "JumpTable", "Inst", "PHIList", "ValueRefList",
1772 "ValueRefListE", "OptTailCall", "InstVal", "IndexList", "OptVolatile",
1773 "MemoryInst", 0
Reid Spencer21be8652006-10-22 07:03:43 +00001774};
1775#endif
1776
1777# ifdef YYPRINT
1778/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1779 token YYLEX-NUM. */
1780static const unsigned short int yytoknum[] =
1781{
1782 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1783 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1784 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1785 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1786 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1787 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1788 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1789 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1790 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1791 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
Reid Spencer1628cec2006-10-26 06:15:43 +00001792 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001793 365, 366, 367, 61, 44, 92, 40, 41, 91, 120,
1794 93, 60, 62, 123, 125, 42, 99
Reid Spencer21be8652006-10-22 07:03:43 +00001795};
1796# endif
1797
1798/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1799static const unsigned char yyr1[] =
1800{
Reid Spencer3ed469c2006-11-02 20:25:50 +00001801 0, 127, 128, 128, 129, 129, 130, 130, 130, 130,
1802 130, 130, 130, 130, 130, 131, 131, 131, 132, 132,
1803 132, 132, 132, 132, 133, 133, 134, 134, 134, 134,
1804 135, 135, 135, 135, 136, 136, 137, 137, 138, 138,
1805 139, 139, 139, 139, 139, 139, 139, 139, 140, 140,
1806 140, 140, 140, 140, 140, 140, 141, 141, 142, 142,
1807 143, 144, 144, 145, 145, 146, 146, 147, 147, 148,
1808 148, 149, 150, 150, 150, 150, 150, 150, 150, 150,
1809 150, 150, 150, 150, 150, 151, 151, 151, 151, 151,
1810 151, 151, 151, 151, 151, 152, 152, 153, 153, 153,
1811 153, 154, 154, 154, 154, 154, 154, 154, 154, 154,
1812 154, 154, 154, 154, 154, 154, 154, 155, 155, 155,
1813 155, 155, 155, 155, 155, 155, 155, 156, 156, 157,
1814 157, 158, 159, 159, 159, 159, 159, 160, 160, 160,
1815 161, 160, 162, 160, 163, 160, 164, 160, 160, 160,
1816 160, 165, 166, 166, 167, 167, 167, 167, 168, 169,
1817 169, 169, 170, 170, 171, 171, 172, 173, 173, 174,
1818 174, 174, 174, 175, 176, 176, 177, 178, 178, 179,
1819 180, 180, 180, 182, 181, 183, 183, 184, 184, 184,
1820 184, 184, 184, 184, 184, 184, 184, 184, 185, 185,
1821 186, 186, 187, 188, 188, 189, 190, 190, 190, 191,
1822 191, 191, 191, 191, 191, 191, 191, 191, 192, 192,
1823 193, 194, 194, 195, 195, 196, 196, 197, 197, 198,
1824 198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
1825 198, 198, 198, 198, 198, 199, 199, 200, 200, 201,
1826 201, 201, 201, 201, 201, 201, 201
Reid Spencer21be8652006-10-22 07:03:43 +00001827};
1828
1829/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1830static const unsigned char yyr2[] =
1831{
1832 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1833 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1834 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001835 1, 1, 1, 1, 1, 1, 1, 1, 2, 0,
1836 1, 1, 1, 1, 1, 1, 1, 0, 0, 1,
1837 1, 1, 1, 1, 1, 2, 0, 2, 0, 3,
1838 2, 0, 1, 0, 3, 1, 2, 1, 1, 1,
Reid Spencer21be8652006-10-22 07:03:43 +00001839 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001840 1, 1, 1, 1, 1, 1, 1, 1, 2, 4,
1841 5, 5, 3, 2, 2, 1, 3, 1, 3, 1,
1842 0, 4, 3, 3, 4, 4, 3, 2, 2, 2,
1843 2, 2, 2, 2, 2, 2, 2, 6, 5, 8,
1844 6, 6, 6, 6, 6, 8, 8, 3, 1, 1,
1845 1, 1, 2, 2, 4, 2, 1, 4, 2, 4,
1846 0, 7, 0, 7, 0, 7, 0, 7, 3, 4,
1847 0, 1, 1, 1, 3, 3, 3, 3, 3, 3,
1848 1, 0, 1, 1, 1, 0, 2, 3, 1, 1,
1849 3, 1, 0, 8, 1, 1, 3, 1, 1, 2,
1850 0, 1, 1, 0, 4, 0, 1, 1, 1, 1,
1851 1, 1, 1, 1, 1, 3, 1, 5, 1, 1,
1852 1, 1, 2, 2, 2, 3, 2, 0, 1, 2,
1853 2, 3, 9, 9, 8, 13, 1, 1, 6, 5,
1854 2, 6, 7, 1, 3, 1, 0, 2, 1, 5,
1855 5, 5, 2, 4, 4, 6, 4, 4, 4, 4,
1856 6, 6, 2, 7, 1, 2, 0, 1, 0, 3,
1857 6, 3, 6, 2, 4, 6, 4
Reid Spencer21be8652006-10-22 07:03:43 +00001858};
1859
1860/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1861 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1862 means the default is an error. */
Reid Spencer3ed469c2006-11-02 20:25:50 +00001863static const unsigned short int yydefact[] =
Reid Spencer21be8652006-10-22 07:03:43 +00001864{
Reid Spencer3ed469c2006-11-02 20:25:50 +00001865 150, 0, 47, 136, 1, 135, 183, 40, 41, 42,
1866 43, 44, 45, 46, 0, 48, 207, 132, 133, 207,
1867 162, 163, 0, 0, 0, 47, 0, 138, 180, 0,
1868 0, 49, 50, 51, 52, 53, 54, 0, 0, 208,
1869 204, 39, 177, 178, 179, 203, 0, 0, 0, 0,
1870 148, 0, 0, 0, 0, 0, 0, 0, 38, 181,
1871 182, 48, 151, 134, 55, 2, 3, 68, 72, 73,
1872 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
1873 84, 85, 0, 0, 0, 0, 198, 0, 0, 67,
1874 86, 71, 199, 87, 174, 175, 176, 248, 206, 0,
1875 0, 0, 0, 161, 149, 139, 137, 129, 130, 0,
1876 0, 0, 0, 184, 88, 0, 0, 70, 93, 95,
1877 0, 0, 100, 94, 247, 0, 228, 0, 0, 0,
1878 0, 48, 216, 217, 6, 7, 8, 9, 10, 11,
Reid Spencer1628cec2006-10-26 06:15:43 +00001879 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001880 22, 23, 0, 0, 0, 0, 0, 0, 0, 24,
1881 25, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1882 0, 205, 48, 220, 0, 244, 156, 153, 152, 154,
1883 155, 157, 160, 0, 144, 146, 142, 72, 73, 74,
1884 75, 76, 77, 78, 79, 80, 81, 82, 0, 0,
1885 0, 0, 140, 0, 0, 0, 92, 172, 99, 97,
1886 0, 0, 232, 227, 210, 209, 0, 0, 29, 33,
1887 28, 32, 27, 31, 26, 30, 34, 35, 0, 0,
1888 58, 58, 253, 0, 0, 242, 0, 0, 0, 0,
Reid Spencer1628cec2006-10-26 06:15:43 +00001889 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001890 0, 0, 158, 63, 63, 63, 114, 115, 4, 5,
1891 112, 113, 116, 111, 107, 108, 0, 0, 0, 0,
Reid Spencer1628cec2006-10-26 06:15:43 +00001892 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3ed469c2006-11-02 20:25:50 +00001893 110, 109, 63, 69, 69, 96, 171, 165, 168, 169,
1894 0, 0, 89, 187, 188, 189, 194, 190, 191, 192,
1895 193, 185, 0, 196, 201, 200, 202, 0, 211, 0,
1896 0, 0, 249, 0, 251, 246, 0, 0, 0, 0,
1897 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1898 0, 0, 0, 159, 0, 145, 147, 143, 0, 0,
1899 0, 0, 0, 0, 102, 128, 0, 0, 106, 0,
1900 103, 0, 0, 0, 0, 141, 90, 91, 164, 166,
1901 0, 61, 98, 186, 0, 0, 0, 0, 0, 0,
1902 0, 0, 0, 256, 0, 0, 234, 0, 236, 239,
1903 0, 0, 237, 238, 0, 0, 0, 233, 0, 254,
1904 0, 0, 0, 65, 63, 246, 0, 0, 0, 0,
1905 0, 0, 101, 104, 105, 0, 0, 0, 0, 170,
1906 167, 62, 56, 0, 195, 0, 0, 226, 58, 59,
1907 58, 223, 245, 0, 0, 0, 0, 0, 229, 230,
1908 231, 226, 0, 60, 66, 64, 0, 0, 0, 0,
1909 0, 0, 127, 0, 0, 0, 0, 0, 173, 0,
1910 0, 0, 225, 0, 0, 250, 252, 0, 0, 0,
1911 235, 240, 241, 0, 255, 118, 0, 0, 0, 0,
1912 0, 0, 0, 0, 0, 57, 197, 0, 0, 0,
1913 224, 221, 0, 243, 117, 0, 124, 0, 0, 120,
1914 121, 122, 123, 0, 214, 0, 0, 0, 222, 0,
1915 0, 0, 212, 0, 213, 0, 0, 119, 125, 126,
1916 0, 0, 0, 0, 0, 0, 219, 0, 0, 218,
1917 215
Reid Spencer21be8652006-10-22 07:03:43 +00001918};
1919
1920/* YYDEFGOTO[NTERM-NUM]. */
1921static const short int yydefgoto[] =
1922{
Reid Spencer3ed469c2006-11-02 20:25:50 +00001923 -1, 86, 260, 276, 277, 278, 279, 198, 199, 228,
1924 200, 25, 15, 37, 448, 312, 393, 412, 335, 394,
1925 87, 88, 201, 90, 91, 120, 210, 345, 303, 346,
1926 109, 1, 2, 3, 282, 255, 253, 254, 63, 179,
1927 50, 104, 183, 92, 359, 288, 289, 290, 38, 96,
1928 16, 44, 17, 61, 18, 28, 364, 304, 93, 306,
1929 421, 19, 40, 41, 171, 496, 98, 235, 452, 453,
1930 172, 173, 373, 174, 175
Reid Spencer21be8652006-10-22 07:03:43 +00001931};
1932
1933/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1934 STATE-NUM. */
Reid Spencer3ed469c2006-11-02 20:25:50 +00001935#define YYPACT_NINF -447
Reid Spencer21be8652006-10-22 07:03:43 +00001936static const short int yypact[] =
1937{
Reid Spencer3ed469c2006-11-02 20:25:50 +00001938 -447, 33, 122, 610, -447, -447, -447, -447, -447, -447,
1939 -447, -447, -447, -447, -13, 161, 47, -447, -447, -15,
1940 -447, -447, 15, 10, 91, -6, 48, -447, 19, 138,
1941 168, -447, -447, -447, -447, -447, -447, 1070, -20, -447,
1942 -447, 70, -447, -447, -447, -447, 60, 61, 64, 67,
1943 -447, 63, 138, 1070, 106, 106, 106, 106, -447, -447,
1944 -447, 161, -447, -447, -447, -447, -447, 59, -447, -447,
1945 -447, -447, -447, -447, -447, -447, -447, -447, -447, -447,
1946 -447, -447, 174, 178, 179, 576, -447, 70, 74, -447,
1947 -447, -54, -447, -447, -447, -447, -447, 1245, -447, 162,
1948 -44, 190, 171, 172, -447, -447, -447, -447, -447, 1111,
1949 1111, 1111, 1152, -447, -447, 78, 88, -447, -447, -54,
1950 -29, 92, 865, -447, -447, 1111, -447, 150, 1193, 75,
1951 189, 161, -447, -447, -447, -447, -447, -447, -447, -447,
1952 -447, -447, -447, -447, -447, -447, -447, -447, -447, -447,
1953 -447, -447, 1111, 1111, 1111, 1111, 1111, 1111, 1111, -447,
1954 -447, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111,
1955 1111, -447, 161, -447, 8, -447, -447, -447, -447, -447,
1956 -447, -447, -447, -10, -447, -447, -447, 113, 139, 206,
1957 145, 211, 147, 215, 152, 216, 214, 225, 154, 218,
1958 226, 419, -447, 1111, 1111, 1111, -447, 906, -447, 120,
1959 118, 643, -447, -447, 59, -447, 643, 643, -447, -447,
1960 -447, -447, -447, -447, -447, -447, -447, -447, 643, 1070,
1961 128, 129, -447, 643, 126, 131, 210, 133, 134, 140,
1962 141, 142, 143, 144, 643, 643, 643, 146, 1070, 1111,
1963 1111, 237, -447, 148, 148, 148, -447, -447, -447, -447,
1964 -447, -447, -447, -447, -447, -447, 149, 151, 153, 155,
1965 156, 159, 947, 1152, 596, 239, 160, 164, 175, 177,
1966 -447, -447, 148, -74, -23, -54, -447, 70, -447, 163,
1967 180, 988, -447, -447, -447, -447, -447, -447, -447, -447,
1968 -447, 201, 1152, -447, -447, -447, -447, 182, -447, 184,
1969 643, -2, -447, 6, -447, 186, 643, 176, 1111, 1111,
1970 1111, 1111, 1111, 1111, 1111, 1111, 187, 188, 191, 1111,
1971 643, 643, 195, -447, -12, -447, -447, -447, 1152, 1152,
1972 1152, 1152, 1152, 1152, -447, -447, -9, -21, -447, -27,
1973 -447, 1152, 1152, 1152, 1152, -447, -447, -447, -447, -447,
1974 1029, 232, -447, -447, 244, -16, 249, 282, 194, 643,
1975 300, 643, 1111, -447, 197, 643, -447, 199, -447, -447,
1976 202, 203, -447, -447, 643, 643, 643, -447, 208, -447,
1977 1111, 291, 315, -447, 148, 186, 289, 212, 217, 219,
1978 220, 1152, -447, -447, -447, 231, 233, 234, 240, -447,
1979 -447, -447, 273, 241, -447, 643, 643, 1111, 242, -447,
1980 242, -447, 243, 643, 246, 1111, 1111, 1111, -447, -447,
1981 -447, 1111, 643, -447, -447, -447, 223, 1111, 1152, 1152,
1982 1152, 1152, -447, 1152, 1152, 1152, 1152, 328, -447, 322,
1983 247, 245, 243, 248, 294, -447, -447, 1111, 250, 643,
1984 -447, -447, -447, 252, -447, -447, 254, 259, 257, 262,
1985 263, 264, 265, 267, 270, -447, -447, 341, 14, 343,
1986 -447, -447, 271, -447, -447, 1152, -447, 1152, 1152, -447,
1987 -447, -447, -447, 643, -447, 751, 65, 374, -447, 279,
1988 280, 281, -447, 285, -447, 751, 643, -447, -447, -447,
1989 380, 290, 288, 643, 382, 384, -447, 643, 643, -447,
1990 -447
Reid Spencer21be8652006-10-22 07:03:43 +00001991};
1992
1993/* YYPGOTO[NTERM-NUM]. */
1994static const short int yypgoto[] =
1995{
Reid Spencer3ed469c2006-11-02 20:25:50 +00001996 -447, -447, -447, 309, 310, 311, 312, -129, -128, -446,
1997 -447, 369, 386, -89, -447, -227, 51, -447, -248, -447,
1998 -50, -447, -37, -447, -68, 292, -447, -102, 221, -255,
1999 57, -447, -447, -447, -447, -447, -447, -447, 361, -447,
2000 -447, -447, -447, 2, -447, 55, -447, -447, 355, -447,
2001 -447, -447, -447, -447, 414, -447, -447, -405, -57, 62,
2002 -105, -447, 399, -447, -447, -447, -447, -447, 49, -8,
2003 -447, -447, 24, -447, -447
Reid Spencer21be8652006-10-22 07:03:43 +00002004};
2005
2006/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2007 positive, shift that token. If negative, reduce the rule which
2008 number is the opposite. If zero, do what YYDEFACT says.
2009 If YYTABLE_NINF, syntax error. */
Reid Spencer3ed469c2006-11-02 20:25:50 +00002010#define YYTABLE_NINF -132
Reid Spencer21be8652006-10-22 07:03:43 +00002011static const short int yytable[] =
2012{
Reid Spencer3ed469c2006-11-02 20:25:50 +00002013 89, 226, 227, 106, 314, 26, 336, 337, 39, 94,
2014 202, 177, 178, 369, 53, 42, 89, 119, 347, 349,
2015 212, 371, 391, 215, 218, 219, 220, 221, 222, 223,
2016 224, 225, 495, 4, 355, 7, 8, 9, 10, 54,
2017 12, 55, 229, 26, 56, 392, 356, 365, 29, 232,
2018 505, 123, 236, 237, 119, 370, 238, 239, 240, 241,
2019 242, 243, -69, 370, 59, 247, 60, 46, 47, 48,
2020 39, 123, 184, 185, 186, 218, 219, 220, 221, 222,
2021 223, 224, 225, 248, 216, 205, 49, 401, 211, 121,
2022 503, 211, 20, 401, 21, 206, 217, 404, 401, 357,
2023 511, 403, 123, 95, 251, 401, 414, 249, 250, 43,
2024 252, 402, 110, 111, 112, 230, 231, 211, 233, 234,
2025 211, 211, -131, 51, 211, 211, 211, 211, 211, 211,
2026 244, 245, 246, 211, 494, 283, 284, 285, 107, 108,
2027 256, 257, -29, -29, 281, 332, 435, 5, -28, -28,
2028 -27, -27, 52, 6, 305, -26, -26, 258, 259, 305,
2029 305, 58, 62, 7, 8, 9, 10, 11, 12, 13,
2030 287, 305, 64, 99, 100, -70, 305, 101, 114, 310,
2031 102, 103, 115, 116, 14, 504, 176, 305, 305, 305,
2032 122, 455, 89, 456, 180, 181, 182, 203, 330, 218,
2033 219, 220, 221, 222, 223, 224, 225, 204, 207, 213,
2034 -33, 89, 331, 211, 377, -32, 379, 380, 381, -31,
2035 -30, -36, 261, 285, 387, 30, 31, 32, 33, 34,
2036 35, 36, -37, 262, 291, 292, 395, 396, 397, 398,
2037 399, 400, 311, 313, 316, 317, 318, 319, 320, 405,
2038 406, 407, 408, 305, 321, 322, 323, 324, 325, 305,
2039 329, 333, 334, 350, 363, 338, 391, 339, 413, 340,
2040 415, 341, 342, 305, 305, 343, 351, 360, 307, 308,
2041 352, 376, 211, 378, 211, 211, 211, 382, 383, 358,
2042 309, 353, 211, 354, 375, 315, 366, 361, 367, 442,
2043 372, 384, 385, 416, 419, 386, 326, 327, 328, 390,
2044 417, 423, 305, 425, 305, 433, 426, 427, 305, 434,
2045 460, 461, 462, 287, 431, 437, 438, 305, 305, 305,
2046 447, 439, 475, 440, 441, 211, 467, 468, 469, 470,
2047 465, 471, 472, 473, 474, 443, 476, 444, 445, 226,
2048 227, 370, 480, 432, 446, 449, 454, 457, 305, 305,
2049 459, 477, 493, 478, 515, 479, 305, 226, 227, 483,
2050 481, 484, 368, 485, 486, 305, 487, 488, 374, 497,
2051 211, 489, 490, 499, 491, 500, 501, 492, 211, 211,
2052 211, 498, 388, 389, 211, 506, 507, 508, 509, 510,
2053 466, 513, 305, 517, 514, 518, 167, 168, 169, 170,
2054 97, 57, 411, 105, 209, 410, 113, 27, 45, 436,
2055 211, 422, 280, 463, 65, 66, 0, 0, 0, 0,
2056 0, 418, 0, 420, 0, 0, 305, 424, 0, 0,
2057 0, 20, 0, 21, 0, 263, 428, 429, 430, 305,
2058 0, 0, 0, 0, 0, 0, 305, 264, 265, 0,
2059 305, 305, 0, 0, 0, 0, 0, 0, 0, 0,
2060 0, 0, 0, 0, 0, 0, 0, 450, 451, 0,
2061 0, 0, 0, 0, 0, 458, 0, 0, 0, 0,
2062 0, 0, 0, 0, 464, 0, 0, 134, 135, 136,
2063 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
2064 147, 148, 149, 150, 151, 0, 0, 0, 0, 0,
2065 266, 482, 267, 268, 159, 160, 0, 269, 270, 271,
2066 0, 0, 0, 0, 0, 0, 0, 272, 0, 0,
2067 273, 0, 274, 0, 0, 275, 0, 0, 0, 0,
2068 0, 0, 0, 0, 0, 502, 0, 0, 0, 0,
2069 0, 0, 0, 0, 0, 0, 0, 0, 512, 0,
2070 0, 0, 0, 0, 0, 516, 0, 0, 0, 519,
2071 520, 65, 66, 0, 117, 68, 69, 70, 71, 72,
2072 73, 74, 75, 76, 77, 78, 79, 80, 20, 0,
2073 21, 65, 66, 0, 117, 187, 188, 189, 190, 191,
2074 192, 193, 194, 195, 196, 197, 79, 80, 20, 0,
2075 21, 0, 0, 0, 81, 0, 0, 0, 0, 0,
2076 -39, 0, 20, 0, 21, 0, 0, 0, 0, 0,
2077 0, 6, -39, -39, 81, 0, 293, 294, 65, 66,
2078 295, -39, -39, -39, -39, -39, -39, -39, 0, 0,
2079 -39, 22, 0, 0, 0, 20, 0, 21, 23, 296,
2080 297, 298, 24, 0, 0, 0, 0, 0, 0, 0,
2081 0, 299, 300, 0, 0, 0, 0, 0, 0, 0,
2082 0, 82, 0, 0, 83, 0, 0, 84, 0, 85,
2083 118, 0, 0, 0, 301, 0, 0, 0, 0, 0,
2084 0, 82, 0, 0, 83, 0, 0, 84, 0, 85,
2085 348, 134, 135, 136, 137, 138, 139, 140, 141, 142,
2086 143, 144, 145, 146, 147, 148, 149, 150, 151, 0,
2087 0, 0, 0, 0, 266, 0, 267, 268, 159, 160,
2088 0, 269, 270, 271, 293, 294, 0, 0, 295, 0,
2089 0, 0, 0, 0, 302, 0, 0, 0, 0, 0,
2090 0, 0, 0, 0, 0, 0, 0, 296, 297, 298,
2091 0, 0, 0, 0, 0, 0, 0, 0, 0, 299,
2092 300, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer21be8652006-10-22 07:03:43 +00002093 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002094 0, 0, 301, 0, 0, 0, 0, 0, 0, 0,
2095 0, 0, 0, 0, 0, 0, 0, 0, 0, 134,
2096 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
2097 145, 146, 147, 148, 149, 150, 151, 0, 0, 0,
2098 0, 0, 266, 0, 267, 268, 159, 160, 0, 269,
2099 270, 271, 0, 0, 0, 0, 0, 0, 0, 0,
2100 65, 66, 302, 117, 68, 69, 70, 71, 72, 73,
2101 74, 75, 76, 77, 78, 79, 80, 20, 0, 21,
Reid Spencer21be8652006-10-22 07:03:43 +00002102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002103 0, 0, 208, 0, 0, 0, 0, 0, 0, 0,
2104 0, 65, 66, 81, 117, 68, 69, 70, 71, 72,
2105 73, 74, 75, 76, 77, 78, 79, 80, 20, 0,
2106 21, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2107 0, 0, 0, 286, 0, 0, 0, 0, 0, 0,
2108 0, 0, 65, 66, 81, 117, 187, 188, 189, 190,
2109 191, 192, 193, 194, 195, 196, 197, 79, 80, 20,
2110 0, 21, 0, 0, 0, 0, 0, 0, 0, 0,
2111 82, 0, 0, 83, 0, 0, 84, 0, 85, 0,
2112 0, 0, 0, 65, 66, 81, 117, 68, 69, 70,
Reid Spencer21be8652006-10-22 07:03:43 +00002113 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
Reid Spencer1628cec2006-10-26 06:15:43 +00002114 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002115 0, 82, 0, 0, 83, 362, 0, 84, 0, 85,
Reid Spencer21be8652006-10-22 07:03:43 +00002116 0, 0, 0, 0, 65, 66, 81, 117, 68, 69,
2117 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
Reid Spencer1628cec2006-10-26 06:15:43 +00002118 80, 20, 0, 21, 0, 0, 0, 0, 0, 0,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002119 0, 0, 82, 0, 0, 83, 409, 344, 84, 0,
2120 85, 0, 0, 0, 0, 65, 66, 81, 67, 68,
2121 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
2122 79, 80, 20, 0, 21, 0, 0, 0, 0, 0,
2123 0, 0, 0, 82, 0, 0, 83, 0, 0, 84,
2124 0, 85, 0, 0, 0, 0, 65, 66, 81, 117,
2125 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
2126 78, 79, 80, 20, 0, 21, 0, 0, 0, 0,
2127 0, 0, 0, 0, 82, 0, 0, 83, 0, 0,
2128 84, 0, 85, 0, 0, 0, 0, 65, 66, 81,
2129 117, 187, 188, 189, 190, 191, 192, 193, 194, 195,
2130 196, 197, 79, 80, 20, 0, 21, 0, 0, 0,
2131 0, 0, 0, 0, 0, 82, 0, 0, 83, 0,
2132 0, 84, 0, 85, 0, 0, 0, 0, 65, 66,
2133 81, 214, 68, 69, 70, 71, 72, 73, 74, 75,
Reid Spencer21be8652006-10-22 07:03:43 +00002134 76, 77, 78, 79, 80, 20, 0, 21, 0, 0,
Reid Spencer1628cec2006-10-26 06:15:43 +00002135 0, 0, 0, 0, 0, 0, 82, 0, 0, 83,
2136 0, 0, 84, 0, 85, 0, 0, 0, 0, 0,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002137 0, 81, 0, 0, 0, 0, 0, 0, 0, 0,
2138 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2139 0, 0, 0, 0, 0, 0, 0, 82, 0, 0,
Reid Spencer1628cec2006-10-26 06:15:43 +00002140 83, 0, 0, 84, 0, 85, 0, 0, 0, 0,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002141 124, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2142 0, 0, 0, 0, 125, 0, 0, 0, 0, 0,
2143 0, 0, 0, 0, 126, 127, 0, 0, 82, 0,
2144 0, 83, 0, 0, 84, 0, 85, 128, 129, 130,
2145 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
2146 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
2147 151, 152, 153, 154, 0, 0, 155, 156, 157, 158,
2148 159, 160, 161, 162, 163, 164, 165, 166
Reid Spencer21be8652006-10-22 07:03:43 +00002149};
2150
2151static const short int yycheck[] =
2152{
Reid Spencer3ed469c2006-11-02 20:25:50 +00002153 37, 130, 130, 53, 231, 3, 254, 255, 23, 29,
2154 112, 55, 56, 15, 20, 30, 53, 85, 273, 274,
2155 125, 15, 34, 128, 10, 11, 12, 13, 14, 15,
2156 16, 17, 478, 0, 282, 41, 42, 43, 44, 45,
2157 46, 47, 131, 41, 50, 57, 120, 302, 61, 154,
2158 496, 125, 157, 158, 122, 57, 161, 162, 163, 164,
2159 165, 166, 116, 57, 45, 170, 47, 52, 53, 54,
2160 23, 125, 109, 110, 111, 10, 11, 12, 13, 14,
2161 15, 16, 17, 172, 9, 114, 71, 114, 125, 87,
2162 495, 128, 22, 114, 24, 124, 21, 124, 114, 122,
2163 505, 122, 125, 123, 114, 114, 122, 99, 100, 124,
2164 120, 120, 55, 56, 57, 152, 153, 154, 155, 156,
2165 157, 158, 0, 113, 161, 162, 163, 164, 165, 166,
2166 167, 168, 169, 170, 120, 203, 204, 205, 32, 33,
2167 27, 28, 3, 4, 201, 250, 394, 25, 3, 4,
2168 3, 4, 61, 31, 211, 3, 4, 3, 4, 216,
2169 217, 113, 24, 41, 42, 43, 44, 45, 46, 47,
2170 207, 228, 4, 113, 113, 116, 233, 113, 4, 229,
2171 113, 118, 4, 4, 62, 120, 24, 244, 245, 246,
2172 116, 418, 229, 420, 4, 24, 24, 119, 248, 10,
2173 11, 12, 13, 14, 15, 16, 17, 119, 116, 59,
2174 4, 248, 249, 250, 319, 4, 321, 322, 323, 4,
2175 4, 7, 4, 291, 329, 64, 65, 66, 67, 68,
2176 69, 70, 7, 7, 114, 117, 338, 339, 340, 341,
2177 342, 343, 114, 114, 118, 114, 36, 114, 114, 351,
2178 352, 353, 354, 310, 114, 114, 114, 114, 114, 316,
2179 114, 24, 114, 24, 63, 116, 34, 116, 24, 116,
2180 21, 116, 116, 330, 331, 116, 116, 114, 216, 217,
2181 116, 318, 319, 320, 321, 322, 323, 324, 325, 287,
2182 228, 116, 329, 116, 118, 233, 114, 117, 114, 401,
2183 114, 114, 114, 21, 4, 114, 244, 245, 246, 114,
2184 116, 114, 369, 114, 371, 24, 114, 114, 375, 4,
2185 425, 426, 427, 360, 116, 36, 114, 384, 385, 386,
2186 57, 114, 4, 114, 114, 372, 438, 439, 440, 441,
2187 117, 443, 444, 445, 446, 114, 24, 114, 114, 478,
2188 478, 57, 457, 390, 114, 114, 114, 114, 415, 416,
2189 114, 114, 21, 118, 76, 117, 423, 496, 496, 117,
2190 120, 117, 310, 114, 117, 432, 114, 114, 316, 36,
2191 417, 117, 117, 485, 117, 487, 488, 117, 425, 426,
2192 427, 120, 330, 331, 431, 21, 117, 117, 117, 114,
2193 437, 21, 459, 21, 114, 21, 97, 97, 97, 97,
2194 41, 25, 361, 52, 122, 360, 61, 3, 19, 395,
2195 457, 372, 201, 431, 5, 6, -1, -1, -1, -1,
2196 -1, 369, -1, 371, -1, -1, 493, 375, -1, -1,
2197 -1, 22, -1, 24, -1, 26, 384, 385, 386, 506,
2198 -1, -1, -1, -1, -1, -1, 513, 38, 39, -1,
2199 517, 518, -1, -1, -1, -1, -1, -1, -1, -1,
2200 -1, -1, -1, -1, -1, -1, -1, 415, 416, -1,
2201 -1, -1, -1, -1, -1, 423, -1, -1, -1, -1,
2202 -1, -1, -1, -1, 432, -1, -1, 78, 79, 80,
2203 81, 82, 83, 84, 85, 86, 87, 88, 89, 90,
2204 91, 92, 93, 94, 95, -1, -1, -1, -1, -1,
2205 101, 459, 103, 104, 105, 106, -1, 108, 109, 110,
2206 -1, -1, -1, -1, -1, -1, -1, 118, -1, -1,
2207 121, -1, 123, -1, -1, 126, -1, -1, -1, -1,
2208 -1, -1, -1, -1, -1, 493, -1, -1, -1, -1,
2209 -1, -1, -1, -1, -1, -1, -1, -1, 506, -1,
2210 -1, -1, -1, -1, -1, 513, -1, -1, -1, 517,
2211 518, 5, 6, -1, 8, 9, 10, 11, 12, 13,
2212 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2213 24, 5, 6, -1, 8, 9, 10, 11, 12, 13,
2214 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2215 24, -1, -1, -1, 48, -1, -1, -1, -1, -1,
2216 20, -1, 22, -1, 24, -1, -1, -1, -1, -1,
2217 -1, 31, 32, 33, 48, -1, 3, 4, 5, 6,
2218 7, 41, 42, 43, 44, 45, 46, 47, -1, -1,
2219 50, 51, -1, -1, -1, 22, -1, 24, 58, 26,
2220 27, 28, 62, -1, -1, -1, -1, -1, -1, -1,
2221 -1, 38, 39, -1, -1, -1, -1, -1, -1, -1,
2222 -1, 115, -1, -1, 118, -1, -1, 121, -1, 123,
2223 124, -1, -1, -1, 61, -1, -1, -1, -1, -1,
2224 -1, 115, -1, -1, 118, -1, -1, 121, -1, 123,
2225 124, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2226 87, 88, 89, 90, 91, 92, 93, 94, 95, -1,
2227 -1, -1, -1, -1, 101, -1, 103, 104, 105, 106,
2228 -1, 108, 109, 110, 3, 4, -1, -1, 7, -1,
2229 -1, -1, -1, -1, 121, -1, -1, -1, -1, -1,
2230 -1, -1, -1, -1, -1, -1, -1, 26, 27, 28,
2231 -1, -1, -1, -1, -1, -1, -1, -1, -1, 38,
2232 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2233 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2234 -1, -1, 61, -1, -1, -1, -1, -1, -1, -1,
2235 -1, -1, -1, -1, -1, -1, -1, -1, -1, 78,
2236 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2237 89, 90, 91, 92, 93, 94, 95, -1, -1, -1,
2238 -1, -1, 101, -1, 103, 104, 105, 106, -1, 108,
2239 109, 110, -1, -1, -1, -1, -1, -1, -1, -1,
2240 5, 6, 121, 8, 9, 10, 11, 12, 13, 14,
2241 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
2242 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2243 -1, -1, 37, -1, -1, -1, -1, -1, -1, -1,
2244 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2245 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2246 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2247 -1, -1, -1, 37, -1, -1, -1, -1, -1, -1,
2248 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
Reid Spencer1628cec2006-10-26 06:15:43 +00002249 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002250 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
2251 115, -1, -1, 118, -1, -1, 121, -1, 123, -1,
2252 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
Reid Spencer1628cec2006-10-26 06:15:43 +00002253 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2254 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002255 -1, 115, -1, -1, 118, 37, -1, 121, -1, 123,
Reid Spencer1628cec2006-10-26 06:15:43 +00002256 -1, -1, -1, -1, 5, 6, 48, 8, 9, 10,
2257 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2258 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002259 -1, -1, 115, -1, -1, 118, 37, 120, 121, -1,
2260 123, -1, -1, -1, -1, 5, 6, 48, 8, 9,
2261 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
2262 20, 21, 22, -1, 24, -1, -1, -1, -1, -1,
2263 -1, -1, -1, 115, -1, -1, 118, -1, -1, 121,
2264 -1, 123, -1, -1, -1, -1, 5, 6, 48, 8,
2265 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
2266 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
2267 -1, -1, -1, -1, 115, -1, -1, 118, -1, -1,
2268 121, -1, 123, -1, -1, -1, -1, 5, 6, 48,
2269 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2270 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
2271 -1, -1, -1, -1, -1, 115, -1, -1, 118, -1,
2272 -1, 121, -1, 123, -1, -1, -1, -1, 5, 6,
2273 48, 8, 9, 10, 11, 12, 13, 14, 15, 16,
Reid Spencer21be8652006-10-22 07:03:43 +00002274 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002275 -1, -1, -1, -1, -1, -1, 115, -1, -1, 118,
2276 -1, -1, 121, -1, 123, -1, -1, -1, -1, -1,
2277 -1, 48, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer21be8652006-10-22 07:03:43 +00002278 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002279 -1, -1, -1, -1, -1, -1, -1, 115, -1, -1,
2280 118, -1, -1, 121, -1, 123, -1, -1, -1, -1,
2281 35, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2282 -1, -1, -1, -1, 49, -1, -1, -1, -1, -1,
2283 -1, -1, -1, -1, 59, 60, -1, -1, 115, -1,
2284 -1, 118, -1, -1, 121, -1, 123, 72, 73, 74,
2285 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
2286 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
2287 95, 96, 97, 98, -1, -1, 101, 102, 103, 104,
2288 105, 106, 107, 108, 109, 110, 111, 112
Reid Spencer21be8652006-10-22 07:03:43 +00002289};
2290
2291/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2292 symbol of state STATE-NUM. */
2293static const unsigned char yystos[] =
2294{
Reid Spencer3ed469c2006-11-02 20:25:50 +00002295 0, 158, 159, 160, 0, 25, 31, 41, 42, 43,
2296 44, 45, 46, 47, 62, 139, 177, 179, 181, 188,
2297 22, 24, 51, 58, 62, 138, 170, 181, 182, 61,
2298 64, 65, 66, 67, 68, 69, 70, 140, 175, 23,
2299 189, 190, 30, 124, 178, 189, 52, 53, 54, 71,
2300 167, 113, 61, 20, 45, 47, 50, 139, 113, 45,
2301 47, 180, 24, 165, 4, 5, 6, 8, 9, 10,
Reid Spencer21be8652006-10-22 07:03:43 +00002302 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002303 21, 48, 115, 118, 121, 123, 128, 147, 148, 149,
2304 150, 151, 170, 185, 29, 123, 176, 138, 193, 113,
2305 113, 113, 113, 118, 168, 165, 147, 32, 33, 157,
2306 157, 157, 157, 175, 4, 4, 4, 8, 124, 151,
2307 152, 170, 116, 125, 35, 49, 59, 60, 72, 73,
Reid Spencer21be8652006-10-22 07:03:43 +00002308 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2309 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
Reid Spencer3ed469c2006-11-02 20:25:50 +00002310 94, 95, 96, 97, 98, 101, 102, 103, 104, 105,
2311 106, 107, 108, 109, 110, 111, 112, 130, 131, 132,
2312 133, 191, 197, 198, 200, 201, 24, 55, 56, 166,
2313 4, 24, 24, 169, 149, 149, 149, 9, 10, 11,
2314 12, 13, 14, 15, 16, 17, 18, 19, 134, 135,
2315 137, 149, 154, 119, 119, 114, 124, 116, 37, 152,
2316 153, 149, 187, 59, 8, 187, 9, 21, 10, 11,
2317 12, 13, 14, 15, 16, 17, 134, 135, 136, 140,
2318 149, 149, 187, 149, 149, 194, 187, 187, 187, 187,
2319 187, 187, 187, 187, 149, 149, 149, 187, 140, 99,
2320 100, 114, 120, 163, 164, 162, 27, 28, 3, 4,
2321 129, 4, 7, 26, 38, 39, 101, 103, 104, 108,
2322 109, 110, 118, 121, 123, 126, 130, 131, 132, 133,
2323 155, 185, 161, 151, 151, 151, 37, 149, 172, 173,
2324 174, 114, 117, 3, 4, 7, 26, 27, 28, 38,
2325 39, 61, 121, 155, 184, 185, 186, 186, 186, 186,
2326 147, 114, 142, 114, 142, 186, 118, 114, 36, 114,
2327 114, 114, 114, 114, 114, 114, 186, 186, 186, 114,
2328 147, 149, 187, 24, 114, 145, 145, 145, 116, 116,
2329 116, 116, 116, 116, 120, 154, 156, 156, 124, 156,
2330 24, 116, 116, 116, 116, 145, 120, 122, 170, 171,
2331 114, 117, 37, 63, 183, 156, 114, 114, 186, 15,
2332 57, 15, 114, 199, 186, 118, 149, 187, 149, 187,
2333 187, 187, 149, 149, 114, 114, 114, 187, 186, 186,
2334 114, 34, 57, 143, 146, 154, 154, 154, 154, 154,
2335 154, 114, 120, 122, 124, 154, 154, 154, 154, 37,
2336 172, 143, 144, 24, 122, 21, 21, 116, 186, 4,
2337 186, 187, 195, 114, 186, 114, 114, 114, 186, 186,
2338 186, 116, 149, 24, 4, 145, 199, 36, 114, 114,
2339 114, 114, 154, 114, 114, 114, 114, 57, 141, 114,
2340 186, 186, 195, 196, 114, 142, 142, 114, 186, 114,
2341 187, 187, 187, 196, 186, 117, 149, 154, 154, 154,
2342 154, 154, 154, 154, 154, 4, 24, 114, 118, 117,
2343 187, 120, 186, 117, 117, 114, 117, 114, 114, 117,
2344 117, 117, 117, 21, 120, 136, 192, 36, 120, 154,
2345 154, 154, 186, 184, 120, 136, 21, 117, 117, 117,
2346 114, 184, 186, 21, 114, 76, 186, 21, 21, 186,
2347 186
Reid Spencer21be8652006-10-22 07:03:43 +00002348};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002349
2350#define yyerrok (yyerrstatus = 0)
2351#define yyclearin (yychar = YYEMPTY)
Reid Spencer21be8652006-10-22 07:03:43 +00002352#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002353#define YYEOF 0
Reid Spencer21be8652006-10-22 07:03:43 +00002354
Reid Spencer68a24bd2005-08-27 18:50:39 +00002355#define YYACCEPT goto yyacceptlab
Reid Spencer21be8652006-10-22 07:03:43 +00002356#define YYABORT goto yyabortlab
2357#define YYERROR goto yyerrorlab
2358
2359
2360/* Like YYERROR except do call yyerror. This remains here temporarily
2361 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002362 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer21be8652006-10-22 07:03:43 +00002363
Reid Spencer68a24bd2005-08-27 18:50:39 +00002364#define YYFAIL goto yyerrlab
Reid Spencer21be8652006-10-22 07:03:43 +00002365
Reid Spencer68a24bd2005-08-27 18:50:39 +00002366#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer21be8652006-10-22 07:03:43 +00002367
2368#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002369do \
2370 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer21be8652006-10-22 07:03:43 +00002371 { \
2372 yychar = (Token); \
2373 yylval = (Value); \
2374 yytoken = YYTRANSLATE (yychar); \
Reid Spencer5b7e7532006-09-28 19:28:24 +00002375 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002376 goto yybackup; \
2377 } \
2378 else \
Reid Spencer21be8652006-10-22 07:03:43 +00002379 { \
2380 yyerror (YY_("syntax error: cannot back up")); \
2381 YYERROR; \
2382 } \
Reid Spencer5b7e7532006-09-28 19:28:24 +00002383while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002384
Reid Spencer21be8652006-10-22 07:03:43 +00002385
Reid Spencer68a24bd2005-08-27 18:50:39 +00002386#define YYTERROR 1
2387#define YYERRCODE 256
2388
Reid Spencer21be8652006-10-22 07:03:43 +00002389
2390/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2391 If N is 0, then set CURRENT to the empty location which ends
2392 the previous symbol: RHS[0] (always defined). */
2393
2394#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2395#ifndef YYLLOC_DEFAULT
2396# define YYLLOC_DEFAULT(Current, Rhs, N) \
2397 do \
2398 if (N) \
2399 { \
2400 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2401 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2402 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2403 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2404 } \
2405 else \
2406 { \
2407 (Current).first_line = (Current).last_line = \
2408 YYRHSLOC (Rhs, 0).last_line; \
2409 (Current).first_column = (Current).last_column = \
2410 YYRHSLOC (Rhs, 0).last_column; \
2411 } \
2412 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002413#endif
2414
Reid Spencer21be8652006-10-22 07:03:43 +00002415
2416/* YY_LOCATION_PRINT -- Print the location on the stream.
2417 This macro was not mandated originally: define only if we know
2418 we won't break user code: when these are the locations we know. */
2419
2420#ifndef YY_LOCATION_PRINT
2421# if YYLTYPE_IS_TRIVIAL
2422# define YY_LOCATION_PRINT(File, Loc) \
2423 fprintf (File, "%d.%d-%d.%d", \
2424 (Loc).first_line, (Loc).first_column, \
2425 (Loc).last_line, (Loc).last_column)
2426# else
2427# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2428# endif
2429#endif
2430
2431
2432/* YYLEX -- calling `yylex' with the right arguments. */
2433
Reid Spencer68a24bd2005-08-27 18:50:39 +00002434#ifdef YYLEX_PARAM
Reid Spencer21be8652006-10-22 07:03:43 +00002435# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002436#else
Reid Spencer21be8652006-10-22 07:03:43 +00002437# define YYLEX yylex ()
Chris Lattner1ae022f2006-10-22 06:08:13 +00002438#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002439
2440/* Enable debugging if requested. */
2441#if YYDEBUG
2442
2443# ifndef YYFPRINTF
2444# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2445# define YYFPRINTF fprintf
2446# endif
2447
2448# define YYDPRINTF(Args) \
2449do { \
2450 if (yydebug) \
2451 YYFPRINTF Args; \
2452} while (0)
2453
2454# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2455do { \
2456 if (yydebug) \
2457 { \
2458 YYFPRINTF (stderr, "%s ", Title); \
2459 yysymprint (stderr, \
2460 Type, Value); \
2461 YYFPRINTF (stderr, "\n"); \
2462 } \
2463} while (0)
2464
2465/*------------------------------------------------------------------.
2466| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2467| TOP (included). |
2468`------------------------------------------------------------------*/
2469
2470#if defined (__STDC__) || defined (__cplusplus)
2471static void
2472yy_stack_print (short int *bottom, short int *top)
Chris Lattner1ae022f2006-10-22 06:08:13 +00002473#else
Reid Spencer21be8652006-10-22 07:03:43 +00002474static void
2475yy_stack_print (bottom, top)
2476 short int *bottom;
2477 short int *top;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002478#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002479{
2480 YYFPRINTF (stderr, "Stack now");
2481 for (/* Nothing. */; bottom <= top; ++bottom)
2482 YYFPRINTF (stderr, " %d", *bottom);
2483 YYFPRINTF (stderr, "\n");
2484}
2485
2486# define YY_STACK_PRINT(Bottom, Top) \
2487do { \
2488 if (yydebug) \
2489 yy_stack_print ((Bottom), (Top)); \
2490} while (0)
2491
2492
2493/*------------------------------------------------.
2494| Report that the YYRULE is going to be reduced. |
2495`------------------------------------------------*/
2496
2497#if defined (__STDC__) || defined (__cplusplus)
2498static void
2499yy_reduce_print (int yyrule)
2500#else
2501static void
2502yy_reduce_print (yyrule)
2503 int yyrule;
Chris Lattner59c85e92006-10-15 23:27:25 +00002504#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002505{
2506 int yyi;
2507 unsigned long int yylno = yyrline[yyrule];
2508 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2509 yyrule - 1, yylno);
2510 /* Print the symbols being reduced, and their result. */
2511 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2512 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2513 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2514}
Reid Spencerb83eb642006-10-20 07:07:24 +00002515
Reid Spencer21be8652006-10-22 07:03:43 +00002516# define YY_REDUCE_PRINT(Rule) \
2517do { \
2518 if (yydebug) \
2519 yy_reduce_print (Rule); \
2520} while (0)
Reid Spencerb83eb642006-10-20 07:07:24 +00002521
Reid Spencer21be8652006-10-22 07:03:43 +00002522/* Nonzero means print parse trace. It is left uninitialized so that
2523 multiple parsers can coexist. */
2524int yydebug;
2525#else /* !YYDEBUG */
2526# define YYDPRINTF(Args)
2527# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2528# define YY_STACK_PRINT(Bottom, Top)
2529# define YY_REDUCE_PRINT(Rule)
2530#endif /* !YYDEBUG */
Reid Spencerb83eb642006-10-20 07:07:24 +00002531
Reid Spencerb83eb642006-10-20 07:07:24 +00002532
Reid Spencer21be8652006-10-22 07:03:43 +00002533/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002534#ifndef YYINITDEPTH
Reid Spencer21be8652006-10-22 07:03:43 +00002535# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002536#endif
2537
Reid Spencer21be8652006-10-22 07:03:43 +00002538/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2539 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002540
Reid Spencer21be8652006-10-22 07:03:43 +00002541 Do not make this value too large; the results are undefined if
2542 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2543 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002544
2545#ifndef YYMAXDEPTH
Reid Spencer21be8652006-10-22 07:03:43 +00002546# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002547#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002548
Reid Spencer68a24bd2005-08-27 18:50:39 +00002549
2550
Reid Spencer21be8652006-10-22 07:03:43 +00002551#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002552
Reid Spencer21be8652006-10-22 07:03:43 +00002553# ifndef yystrlen
2554# if defined (__GLIBC__) && defined (_STRING_H)
2555# define yystrlen strlen
2556# else
2557/* Return the length of YYSTR. */
2558static YYSIZE_T
2559# if defined (__STDC__) || defined (__cplusplus)
2560yystrlen (const char *yystr)
2561# else
2562yystrlen (yystr)
2563 const char *yystr;
2564# endif
Chris Lattner1ae022f2006-10-22 06:08:13 +00002565{
Reid Spencer21be8652006-10-22 07:03:43 +00002566 const char *yys = yystr;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002567
Reid Spencer21be8652006-10-22 07:03:43 +00002568 while (*yys++ != '\0')
2569 continue;
2570
2571 return yys - yystr - 1;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002572}
Reid Spencer21be8652006-10-22 07:03:43 +00002573# endif
2574# endif
Chris Lattner1ae022f2006-10-22 06:08:13 +00002575
Reid Spencer21be8652006-10-22 07:03:43 +00002576# ifndef yystpcpy
2577# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2578# define yystpcpy stpcpy
2579# else
2580/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2581 YYDEST. */
2582static char *
2583# if defined (__STDC__) || defined (__cplusplus)
2584yystpcpy (char *yydest, const char *yysrc)
2585# else
2586yystpcpy (yydest, yysrc)
2587 char *yydest;
2588 const char *yysrc;
2589# endif
Chris Lattner1ae022f2006-10-22 06:08:13 +00002590{
Reid Spencer21be8652006-10-22 07:03:43 +00002591 char *yyd = yydest;
2592 const char *yys = yysrc;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002593
Reid Spencer21be8652006-10-22 07:03:43 +00002594 while ((*yyd++ = *yys++) != '\0')
2595 continue;
2596
2597 return yyd - 1;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002598}
Reid Spencer21be8652006-10-22 07:03:43 +00002599# endif
2600# endif
Chris Lattner1ae022f2006-10-22 06:08:13 +00002601
Reid Spencer21be8652006-10-22 07:03:43 +00002602# ifndef yytnamerr
2603/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2604 quotes and backslashes, so that it's suitable for yyerror. The
2605 heuristic is that double-quoting is unnecessary unless the string
2606 contains an apostrophe, a comma, or backslash (other than
2607 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2608 null, do not copy; instead, return the length of what the result
2609 would have been. */
2610static YYSIZE_T
2611yytnamerr (char *yyres, const char *yystr)
2612{
2613 if (*yystr == '"')
2614 {
2615 size_t yyn = 0;
2616 char const *yyp = yystr;
2617
2618 for (;;)
2619 switch (*++yyp)
2620 {
2621 case '\'':
2622 case ',':
2623 goto do_not_strip_quotes;
2624
2625 case '\\':
2626 if (*++yyp != '\\')
2627 goto do_not_strip_quotes;
2628 /* Fall through. */
2629 default:
2630 if (yyres)
2631 yyres[yyn] = *yyp;
2632 yyn++;
2633 break;
2634
2635 case '"':
2636 if (yyres)
2637 yyres[yyn] = '\0';
2638 return yyn;
2639 }
2640 do_not_strip_quotes: ;
2641 }
2642
2643 if (! yyres)
2644 return yystrlen (yystr);
2645
2646 return yystpcpy (yyres, yystr) - yyres;
2647}
2648# endif
2649
2650#endif /* YYERROR_VERBOSE */
2651
Reid Spencerb83eb642006-10-20 07:07:24 +00002652
2653
Reid Spencer21be8652006-10-22 07:03:43 +00002654#if YYDEBUG
2655/*--------------------------------.
2656| Print this symbol on YYOUTPUT. |
2657`--------------------------------*/
Reid Spencerb83eb642006-10-20 07:07:24 +00002658
Reid Spencer21be8652006-10-22 07:03:43 +00002659#if defined (__STDC__) || defined (__cplusplus)
2660static void
2661yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner1ae022f2006-10-22 06:08:13 +00002662#else
Reid Spencer21be8652006-10-22 07:03:43 +00002663static void
2664yysymprint (yyoutput, yytype, yyvaluep)
2665 FILE *yyoutput;
2666 int yytype;
2667 YYSTYPE *yyvaluep;
2668#endif
2669{
2670 /* Pacify ``unused variable'' warnings. */
2671 (void) yyvaluep;
2672
2673 if (yytype < YYNTOKENS)
2674 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2675 else
2676 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2677
2678
2679# ifdef YYPRINT
2680 if (yytype < YYNTOKENS)
2681 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2682# endif
2683 switch (yytype)
2684 {
2685 default:
2686 break;
2687 }
2688 YYFPRINTF (yyoutput, ")");
2689}
2690
2691#endif /* ! YYDEBUG */
2692/*-----------------------------------------------.
2693| Release the memory associated to this symbol. |
2694`-----------------------------------------------*/
2695
2696#if defined (__STDC__) || defined (__cplusplus)
2697static void
2698yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2699#else
2700static void
2701yydestruct (yymsg, yytype, yyvaluep)
2702 const char *yymsg;
2703 int yytype;
2704 YYSTYPE *yyvaluep;
2705#endif
2706{
2707 /* Pacify ``unused variable'' warnings. */
2708 (void) yyvaluep;
2709
2710 if (!yymsg)
2711 yymsg = "Deleting";
2712 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2713
2714 switch (yytype)
2715 {
2716
2717 default:
2718 break;
2719 }
2720}
2721
2722
2723/* Prevent warnings from -Wmissing-prototypes. */
2724
2725#ifdef YYPARSE_PARAM
2726# if defined (__STDC__) || defined (__cplusplus)
2727int yyparse (void *YYPARSE_PARAM);
2728# else
2729int yyparse ();
2730# endif
2731#else /* ! YYPARSE_PARAM */
2732#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002733int yyparse (void);
Chris Lattner1ae022f2006-10-22 06:08:13 +00002734#else
Reid Spencer21be8652006-10-22 07:03:43 +00002735int yyparse ();
2736#endif
2737#endif /* ! YYPARSE_PARAM */
2738
2739
2740
2741/* The look-ahead symbol. */
2742int yychar;
2743
2744/* The semantic value of the look-ahead symbol. */
2745YYSTYPE yylval;
2746
2747/* Number of syntax errors so far. */
2748int yynerrs;
2749
2750
2751
2752/*----------.
2753| yyparse. |
2754`----------*/
2755
2756#ifdef YYPARSE_PARAM
2757# if defined (__STDC__) || defined (__cplusplus)
2758int yyparse (void *YYPARSE_PARAM)
2759# else
2760int yyparse (YYPARSE_PARAM)
2761 void *YYPARSE_PARAM;
2762# endif
2763#else /* ! YYPARSE_PARAM */
2764#if defined (__STDC__) || defined (__cplusplus)
2765int
2766yyparse (void)
2767#else
2768int
2769yyparse ()
2770
2771#endif
2772#endif
2773{
2774
2775 int yystate;
2776 int yyn;
2777 int yyresult;
2778 /* Number of tokens to shift before error messages enabled. */
2779 int yyerrstatus;
2780 /* Look-ahead token as an internal (translated) token number. */
2781 int yytoken = 0;
2782
2783 /* Three stacks and their tools:
2784 `yyss': related to states,
2785 `yyvs': related to semantic values,
2786 `yyls': related to locations.
2787
2788 Refer to the stacks thru separate pointers, to allow yyoverflow
2789 to reallocate them elsewhere. */
2790
2791 /* The state stack. */
2792 short int yyssa[YYINITDEPTH];
2793 short int *yyss = yyssa;
2794 short int *yyssp;
2795
2796 /* The semantic value stack. */
2797 YYSTYPE yyvsa[YYINITDEPTH];
2798 YYSTYPE *yyvs = yyvsa;
2799 YYSTYPE *yyvsp;
2800
2801
2802
Reid Spencer5b7e7532006-09-28 19:28:24 +00002803#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002804
Reid Spencer21be8652006-10-22 07:03:43 +00002805 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002806
Reid Spencer21be8652006-10-22 07:03:43 +00002807 /* The variables used to return semantic value and location from the
2808 action routines. */
2809 YYSTYPE yyval;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002810
2811
Reid Spencer21be8652006-10-22 07:03:43 +00002812 /* When reducing, the number of symbols on the RHS of the reduced
2813 rule. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002814 int yylen;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002815
Reid Spencer21be8652006-10-22 07:03:43 +00002816 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002817
Reid Spencer68a24bd2005-08-27 18:50:39 +00002818 yystate = 0;
2819 yyerrstatus = 0;
2820 yynerrs = 0;
2821 yychar = YYEMPTY; /* Cause a token to be read. */
2822
2823 /* Initialize stack pointers.
2824 Waste one element of value and location stack
2825 so that they stay on the same level as the state stack.
2826 The wasted elements are never initialized. */
2827
Reid Spencer21be8652006-10-22 07:03:43 +00002828 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002829 yyvsp = yyvs;
2830
Reid Spencer21be8652006-10-22 07:03:43 +00002831 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002832
Reid Spencer21be8652006-10-22 07:03:43 +00002833/*------------------------------------------------------------.
2834| yynewstate -- Push a new state, which is found in yystate. |
2835`------------------------------------------------------------*/
2836 yynewstate:
2837 /* In all cases, when you get here, the value and location stacks
2838 have just been pushed. so pushing a state here evens the stacks.
2839 */
2840 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002841
Reid Spencer21be8652006-10-22 07:03:43 +00002842 yysetstate:
2843 *yyssp = yystate;
2844
2845 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002846 {
2847 /* Get the current used size of the three stacks, in elements. */
Reid Spencer21be8652006-10-22 07:03:43 +00002848 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002849
2850#ifdef yyoverflow
Reid Spencer21be8652006-10-22 07:03:43 +00002851 {
2852 /* Give user a chance to reallocate the stack. Use copies of
2853 these so that the &'s don't force the real ones into
2854 memory. */
2855 YYSTYPE *yyvs1 = yyvs;
2856 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002857
Reid Spencer21be8652006-10-22 07:03:43 +00002858
2859 /* Each stack pointer address is followed by the size of the
2860 data in use in that stack, in bytes. This used to be a
2861 conditional around just the two extra args, but that might
2862 be undefined if yyoverflow is a macro. */
2863 yyoverflow (YY_("memory exhausted"),
2864 &yyss1, yysize * sizeof (*yyssp),
2865 &yyvs1, yysize * sizeof (*yyvsp),
2866
2867 &yystacksize);
2868
2869 yyss = yyss1;
2870 yyvs = yyvs1;
2871 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002872#else /* no yyoverflow */
Reid Spencer21be8652006-10-22 07:03:43 +00002873# ifndef YYSTACK_RELOCATE
2874 goto yyexhaustedlab;
2875# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002876 /* Extend the stack our own way. */
Reid Spencer21be8652006-10-22 07:03:43 +00002877 if (YYMAXDEPTH <= yystacksize)
2878 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002879 yystacksize *= 2;
Reid Spencer21be8652006-10-22 07:03:43 +00002880 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002881 yystacksize = YYMAXDEPTH;
Reid Spencer21be8652006-10-22 07:03:43 +00002882
2883 {
2884 short int *yyss1 = yyss;
2885 union yyalloc *yyptr =
2886 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2887 if (! yyptr)
2888 goto yyexhaustedlab;
2889 YYSTACK_RELOCATE (yyss);
2890 YYSTACK_RELOCATE (yyvs);
2891
2892# undef YYSTACK_RELOCATE
2893 if (yyss1 != yyssa)
2894 YYSTACK_FREE (yyss1);
2895 }
2896# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002897#endif /* no yyoverflow */
2898
Reid Spencer21be8652006-10-22 07:03:43 +00002899 yyssp = yyss + yysize - 1;
2900 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002901
2902
Reid Spencer21be8652006-10-22 07:03:43 +00002903 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2904 (unsigned long int) yystacksize));
2905
2906 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002907 YYABORT;
2908 }
2909
Reid Spencer21be8652006-10-22 07:03:43 +00002910 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002911
2912 goto yybackup;
Reid Spencer21be8652006-10-22 07:03:43 +00002913
2914/*-----------.
2915| yybackup. |
2916`-----------*/
2917yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002918
Reid Spencer5b7e7532006-09-28 19:28:24 +00002919/* Do appropriate processing given the current state. */
Reid Spencer21be8652006-10-22 07:03:43 +00002920/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002921/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002922
Reid Spencer21be8652006-10-22 07:03:43 +00002923 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002924
Reid Spencer68a24bd2005-08-27 18:50:39 +00002925 yyn = yypact[yystate];
Reid Spencer21be8652006-10-22 07:03:43 +00002926 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002927 goto yydefault;
2928
Reid Spencer21be8652006-10-22 07:03:43 +00002929 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002930
Reid Spencer21be8652006-10-22 07:03:43 +00002931 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002932 if (yychar == YYEMPTY)
2933 {
Reid Spencer21be8652006-10-22 07:03:43 +00002934 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002935 yychar = YYLEX;
2936 }
2937
Reid Spencer21be8652006-10-22 07:03:43 +00002938 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002939 {
Reid Spencer21be8652006-10-22 07:03:43 +00002940 yychar = yytoken = YYEOF;
2941 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002942 }
2943 else
2944 {
Reid Spencer21be8652006-10-22 07:03:43 +00002945 yytoken = YYTRANSLATE (yychar);
2946 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002947 }
2948
Reid Spencer21be8652006-10-22 07:03:43 +00002949 /* If the proper action on seeing token YYTOKEN is to reduce or to
2950 detect an error, take that action. */
2951 yyn += yytoken;
2952 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002953 goto yydefault;
2954 yyn = yytable[yyn];
Reid Spencer21be8652006-10-22 07:03:43 +00002955 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002956 {
Reid Spencer21be8652006-10-22 07:03:43 +00002957 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002958 goto yyerrlab;
2959 yyn = -yyn;
2960 goto yyreduce;
2961 }
2962
2963 if (yyn == YYFINAL)
2964 YYACCEPT;
2965
Reid Spencer21be8652006-10-22 07:03:43 +00002966 /* Shift the look-ahead token. */
2967 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5b7e7532006-09-28 19:28:24 +00002968
2969 /* Discard the token being shifted unless it is eof. */
2970 if (yychar != YYEOF)
2971 yychar = YYEMPTY;
2972
2973 *++yyvsp = yylval;
2974
Reid Spencer21be8652006-10-22 07:03:43 +00002975
2976 /* Count tokens shifted since error; after three, turn off error
2977 status. */
2978 if (yyerrstatus)
2979 yyerrstatus--;
Chris Lattner224f84f2006-08-18 17:34:45 +00002980
Reid Spencer68a24bd2005-08-27 18:50:39 +00002981 yystate = yyn;
2982 goto yynewstate;
2983
Chris Lattner1ae022f2006-10-22 06:08:13 +00002984
Reid Spencer21be8652006-10-22 07:03:43 +00002985/*-----------------------------------------------------------.
2986| yydefault -- do the default action for the current state. |
2987`-----------------------------------------------------------*/
2988yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002989 yyn = yydefact[yystate];
2990 if (yyn == 0)
2991 goto yyerrlab;
Reid Spencer21be8652006-10-22 07:03:43 +00002992 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002993
Reid Spencer21be8652006-10-22 07:03:43 +00002994
2995/*-----------------------------.
2996| yyreduce -- Do a reduction. |
2997`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002998yyreduce:
Reid Spencer21be8652006-10-22 07:03:43 +00002999 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00003000 yylen = yyr2[yyn];
3001
Reid Spencer21be8652006-10-22 07:03:43 +00003002 /* If YYLEN is nonzero, implement the default value of the action:
3003 `$$ = $1'.
3004
3005 Otherwise, the following line sets YYVAL to garbage.
3006 This behavior is undocumented and Bison
3007 users should not rely upon it. Assigning to YYVAL
3008 unconditionally makes the parser a bit smaller, and it avoids a
3009 GCC warning that YYVAL may be used uninitialized. */
3010 yyval = yyvsp[1-yylen];
3011
3012
3013 YY_REDUCE_PRINT (yyn);
3014 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003015 {
Reid Spencer21be8652006-10-22 07:03:43 +00003016 case 3:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003017#line 1140 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003018 {
3019 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003020 GEN_ERROR("Value too large for type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003021 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003022 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003023;}
3024 break;
3025
3026 case 5:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003027#line 1149 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003028 {
3029 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003030 GEN_ERROR("Value too large for type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003031 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003032 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003033;}
3034 break;
3035
Reid Spencer3ed469c2006-11-02 20:25:50 +00003036 case 38:
3037#line 1173 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003038 {
3039 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003040 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003041 ;}
3042 break;
3043
Reid Spencer3ed469c2006-11-02 20:25:50 +00003044 case 39:
3045#line 1177 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003046 {
3047 (yyval.StrVal) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003048 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003049 ;}
3050 break;
3051
Reid Spencer3ed469c2006-11-02 20:25:50 +00003052 case 40:
3053#line 1182 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003054 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3055 break;
3056
Reid Spencer3ed469c2006-11-02 20:25:50 +00003057 case 41:
3058#line 1183 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003059 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3060 break;
3061
Reid Spencer3ed469c2006-11-02 20:25:50 +00003062 case 42:
3063#line 1184 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003064 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3065 break;
3066
Reid Spencer3ed469c2006-11-02 20:25:50 +00003067 case 43:
3068#line 1185 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003069 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3070 break;
3071
Reid Spencer3ed469c2006-11-02 20:25:50 +00003072 case 44:
3073#line 1186 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003074 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3075 break;
3076
Reid Spencer3ed469c2006-11-02 20:25:50 +00003077 case 45:
3078#line 1187 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003079 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3080 break;
3081
Reid Spencer3ed469c2006-11-02 20:25:50 +00003082 case 46:
3083#line 1188 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003084 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3085 break;
3086
Reid Spencer3ed469c2006-11-02 20:25:50 +00003087 case 47:
3088#line 1189 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003089 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3090 break;
3091
Reid Spencer21be8652006-10-22 07:03:43 +00003092 case 48:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003093#line 1191 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3094 { (yyval.UIntVal) = CallingConv::C; ;}
Reid Spencer21be8652006-10-22 07:03:43 +00003095 break;
3096
3097 case 49:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003098#line 1192 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3099 { (yyval.UIntVal) = CallingConv::C; ;}
Reid Spencer21be8652006-10-22 07:03:43 +00003100 break;
3101
3102 case 50:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003103#line 1193 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3104 { (yyval.UIntVal) = CallingConv::CSRet; ;}
Reid Spencer21be8652006-10-22 07:03:43 +00003105 break;
3106
3107 case 51:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003108#line 1194 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3109 { (yyval.UIntVal) = CallingConv::Fast; ;}
Reid Spencer1628cec2006-10-26 06:15:43 +00003110 break;
3111
3112 case 52:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003113#line 1195 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3114 { (yyval.UIntVal) = CallingConv::Cold; ;}
Reid Spencer1628cec2006-10-26 06:15:43 +00003115 break;
3116
3117 case 53:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003118#line 1196 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3119 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3120 break;
3121
3122 case 54:
3123#line 1197 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3124 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3125 break;
3126
3127 case 55:
3128#line 1198 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003129 {
3130 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003131 GEN_ERROR("Calling conv too large!");
Reid Spencer21be8652006-10-22 07:03:43 +00003132 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003133 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003134 ;}
3135 break;
3136
Reid Spencer21be8652006-10-22 07:03:43 +00003137 case 56:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003138#line 1207 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1628cec2006-10-26 06:15:43 +00003139 { (yyval.UIntVal) = 0; ;}
3140 break;
3141
3142 case 57:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003143#line 1208 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1628cec2006-10-26 06:15:43 +00003144 {
3145 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3146 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3147 GEN_ERROR("Alignment must be a power of two!");
3148 CHECK_FOR_ERROR
3149;}
3150 break;
3151
3152 case 58:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003153#line 1214 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3154 { (yyval.UIntVal) = 0; ;}
3155 break;
3156
3157 case 59:
3158#line 1215 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3159 {
3160 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3161 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3162 GEN_ERROR("Alignment must be a power of two!");
3163 CHECK_FOR_ERROR
3164;}
3165 break;
3166
3167 case 60:
3168#line 1223 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003169 {
3170 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3171 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer61c83e02006-08-18 08:43:06 +00003172 GEN_ERROR("Invalid character in section name!");
Reid Spencer21be8652006-10-22 07:03:43 +00003173 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003174 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003175;}
3176 break;
3177
Reid Spencer3ed469c2006-11-02 20:25:50 +00003178 case 61:
3179#line 1231 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003180 { (yyval.StrVal) = 0; ;}
3181 break;
3182
Reid Spencer3ed469c2006-11-02 20:25:50 +00003183 case 62:
3184#line 1232 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003185 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3186 break;
3187
Reid Spencer1628cec2006-10-26 06:15:43 +00003188 case 63:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003189#line 1237 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3190 {;}
3191 break;
3192
3193 case 64:
3194#line 1238 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3195 {;}
3196 break;
3197
3198 case 65:
3199#line 1239 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003200 {
3201 CurGV->setSection((yyvsp[0].StrVal));
3202 free((yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003203 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003204 ;}
3205 break;
3206
Reid Spencer3ed469c2006-11-02 20:25:50 +00003207 case 66:
3208#line 1244 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003209 {
3210 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003211 GEN_ERROR("Alignment must be a power of two!");
Reid Spencer21be8652006-10-22 07:03:43 +00003212 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003213 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003214 ;}
3215 break;
3216
Reid Spencer1628cec2006-10-26 06:15:43 +00003217 case 68:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003218#line 1258 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1628cec2006-10-26 06:15:43 +00003219 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
3220 break;
3221
Reid Spencer3ed469c2006-11-02 20:25:50 +00003222 case 70:
3223#line 1259 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3224 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
3225 break;
3226
3227 case 71:
3228#line 1261 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003229 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003230 if (!UpRefs.empty())
Reid Spencer21be8652006-10-22 07:03:43 +00003231 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3232 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003233 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003234 ;}
3235 break;
3236
Reid Spencer3ed469c2006-11-02 20:25:50 +00003237 case 85:
3238#line 1273 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003239 {
3240 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer61c83e02006-08-18 08:43:06 +00003241 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003242 ;}
3243 break;
3244
Reid Spencer3ed469c2006-11-02 20:25:50 +00003245 case 86:
3246#line 1277 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003247 {
3248 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer61c83e02006-08-18 08:43:06 +00003249 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003250 ;}
3251 break;
3252
Reid Spencer3ed469c2006-11-02 20:25:50 +00003253 case 87:
3254#line 1281 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003255 { // Named types are also simple types...
3256 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003257 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003258 (yyval.TypeVal) = new PATypeHolder(tmp);
3259;}
3260 break;
3261
Reid Spencer3ed469c2006-11-02 20:25:50 +00003262 case 88:
3263#line 1289 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003264 { // Type UpReference
3265 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003266 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer21be8652006-10-22 07:03:43 +00003267 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3268 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003269 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003270 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003271 ;}
3272 break;
3273
Reid Spencer3ed469c2006-11-02 20:25:50 +00003274 case 89:
3275#line 1297 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003276 { // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003277 std::vector<const Type*> Params;
Reid Spencer21be8652006-10-22 07:03:43 +00003278 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3279 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003280 Params.push_back(*I);
3281 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3282 if (isVarArg) Params.pop_back();
3283
Reid Spencer21be8652006-10-22 07:03:43 +00003284 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg)));
3285 delete (yyvsp[-1].TypeList); // Delete the argument list
3286 delete (yyvsp[-3].TypeVal); // Delete the return type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003287 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003288 ;}
3289 break;
3290
Reid Spencer3ed469c2006-11-02 20:25:50 +00003291 case 90:
3292#line 1310 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003293 { // Sized array type?
3294 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3295 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003296 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003297 ;}
3298 break;
3299
Reid Spencer3ed469c2006-11-02 20:25:50 +00003300 case 91:
3301#line 1315 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003302 { // Packed array type?
3303 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3304 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003305 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00003306 if (!ElemTy->isPrimitiveType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003307 GEN_ERROR("Elemental type of a PackedType must be primitive");
Reid Spencer21be8652006-10-22 07:03:43 +00003308 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003309 GEN_ERROR("Vector length should be a power of 2!");
Reid Spencer21be8652006-10-22 07:03:43 +00003310 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3311 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003312 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003313 ;}
3314 break;
3315
Reid Spencer3ed469c2006-11-02 20:25:50 +00003316 case 92:
3317#line 1327 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003318 { // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003319 std::vector<const Type*> Elements;
Reid Spencer21be8652006-10-22 07:03:43 +00003320 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3321 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003322 Elements.push_back(*I);
3323
Reid Spencer21be8652006-10-22 07:03:43 +00003324 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3325 delete (yyvsp[-1].TypeList);
Reid Spencer61c83e02006-08-18 08:43:06 +00003326 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003327 ;}
3328 break;
3329
Reid Spencer3ed469c2006-11-02 20:25:50 +00003330 case 93:
3331#line 1337 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003332 { // Empty structure type?
3333 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer61c83e02006-08-18 08:43:06 +00003334 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003335 ;}
3336 break;
3337
Reid Spencer3ed469c2006-11-02 20:25:50 +00003338 case 94:
3339#line 1341 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003340 { // Pointer type?
3341 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Chris Lattner59c85e92006-10-15 23:27:25 +00003342 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencer21be8652006-10-22 07:03:43 +00003343 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3344 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003345 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003346 ;}
3347 break;
3348
Reid Spencer3ed469c2006-11-02 20:25:50 +00003349 case 95:
3350#line 1352 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003351 {
3352 (yyval.TypeList) = new std::list<PATypeHolder>();
3353 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003354 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003355 ;}
3356 break;
3357
Reid Spencer3ed469c2006-11-02 20:25:50 +00003358 case 96:
3359#line 1357 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003360 {
3361 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003362 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003363 ;}
3364 break;
3365
Reid Spencer3ed469c2006-11-02 20:25:50 +00003366 case 98:
3367#line 1364 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003368 {
3369 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy);
Reid Spencer61c83e02006-08-18 08:43:06 +00003370 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003371 ;}
3372 break;
3373
Reid Spencer3ed469c2006-11-02 20:25:50 +00003374 case 99:
3375#line 1368 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003376 {
3377 ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Reid Spencer61c83e02006-08-18 08:43:06 +00003378 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003379 ;}
3380 break;
3381
Reid Spencer3ed469c2006-11-02 20:25:50 +00003382 case 100:
3383#line 1372 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003384 {
3385 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer61c83e02006-08-18 08:43:06 +00003386 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003387 ;}
3388 break;
3389
Reid Spencer3ed469c2006-11-02 20:25:50 +00003390 case 101:
3391#line 1383 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003392 { // Nonempty unsized arr
3393 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003394 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003395 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003396 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003397 const Type *ETy = ATy->getElementType();
3398 int NumElements = ATy->getNumElements();
3399
3400 // Verify that we have the correct size...
Reid Spencer21be8652006-10-22 07:03:43 +00003401 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00003402 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer21be8652006-10-22 07:03:43 +00003403 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003404 itostr(NumElements) + "!");
3405
3406 // Verify all elements are correct type!
Reid Spencer21be8652006-10-22 07:03:43 +00003407 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3408 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003409 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003410 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer21be8652006-10-22 07:03:43 +00003411 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003412 }
3413
Reid Spencer21be8652006-10-22 07:03:43 +00003414 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3415 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003416 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003417 ;}
3418 break;
3419
Reid Spencer3ed469c2006-11-02 20:25:50 +00003420 case 102:
3421#line 1409 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003422 {
3423 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003424 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003425 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003426 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003427
3428 int NumElements = ATy->getNumElements();
3429 if (NumElements != -1 && NumElements != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003430 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003431 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencer21be8652006-10-22 07:03:43 +00003432 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3433 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003434 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003435 ;}
3436 break;
3437
Reid Spencer3ed469c2006-11-02 20:25:50 +00003438 case 103:
3439#line 1423 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003440 {
3441 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003442 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003443 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003444 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003445
3446 int NumElements = ATy->getNumElements();
3447 const Type *ETy = ATy->getElementType();
Reid Spencer21be8652006-10-22 07:03:43 +00003448 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3449 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003450 GEN_ERROR("Can't build string constant of size " +
Reid Spencer21be8652006-10-22 07:03:43 +00003451 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003452 " when array has size " + itostr(NumElements) + "!");
3453 std::vector<Constant*> Vals;
3454 if (ETy == Type::SByteTy) {
Reid Spencer21be8652006-10-22 07:03:43 +00003455 for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00003456 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003457 } else if (ETy == Type::UByteTy) {
Reid Spencer21be8652006-10-22 07:03:43 +00003458 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003459 C != (unsigned char*)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00003460 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003461 } else {
Reid Spencer21be8652006-10-22 07:03:43 +00003462 free((yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003463 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003464 }
Reid Spencer21be8652006-10-22 07:03:43 +00003465 free((yyvsp[0].StrVal));
3466 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3467 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003468 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003469 ;}
3470 break;
3471
Reid Spencer3ed469c2006-11-02 20:25:50 +00003472 case 104:
3473#line 1453 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003474 { // Nonempty unsized arr
3475 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003476 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003477 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003478 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003479 const Type *ETy = PTy->getElementType();
3480 int NumElements = PTy->getNumElements();
3481
3482 // Verify that we have the correct size...
Reid Spencer21be8652006-10-22 07:03:43 +00003483 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00003484 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer21be8652006-10-22 07:03:43 +00003485 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003486 itostr(NumElements) + "!");
3487
3488 // Verify all elements are correct type!
Reid Spencer21be8652006-10-22 07:03:43 +00003489 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3490 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003491 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003492 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer21be8652006-10-22 07:03:43 +00003493 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003494 }
3495
Reid Spencer21be8652006-10-22 07:03:43 +00003496 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3497 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003498 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003499 ;}
3500 break;
3501
Reid Spencer3ed469c2006-11-02 20:25:50 +00003502 case 105:
3503#line 1479 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003504 {
3505 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer61c83e02006-08-18 08:43:06 +00003506 if (STy == 0)
3507 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003508 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003509
Reid Spencer21be8652006-10-22 07:03:43 +00003510 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer61c83e02006-08-18 08:43:06 +00003511 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003512
3513 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer21be8652006-10-22 07:03:43 +00003514 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3515 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer61c83e02006-08-18 08:43:06 +00003516 GEN_ERROR("Expected type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003517 STy->getElementType(i)->getDescription() +
3518 "' for element #" + utostr(i) +
3519 " of structure initializer!");
3520
Reid Spencer21be8652006-10-22 07:03:43 +00003521 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3522 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003523 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003524 ;}
3525 break;
3526
Reid Spencer3ed469c2006-11-02 20:25:50 +00003527 case 106:
3528#line 1500 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003529 {
3530 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003531 if (STy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003532 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003533 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003534
3535 if (STy->getNumContainedTypes() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003536 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003537
Reid Spencer21be8652006-10-22 07:03:43 +00003538 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3539 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003540 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003541 ;}
3542 break;
3543
Reid Spencer3ed469c2006-11-02 20:25:50 +00003544 case 107:
3545#line 1513 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003546 {
3547 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003548 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003549 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003550 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003551
Reid Spencer21be8652006-10-22 07:03:43 +00003552 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3553 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003554 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003555 ;}
3556 break;
3557
Reid Spencer3ed469c2006-11-02 20:25:50 +00003558 case 108:
3559#line 1523 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003560 {
3561 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3562 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003563 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003564 ;}
3565 break;
3566
Reid Spencer3ed469c2006-11-02 20:25:50 +00003567 case 109:
3568#line 1528 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003569 {
3570 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003571 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003572 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003573
3574 // ConstExprs can exist in the body of a function, thus creating
3575 // GlobalValues whenever they refer to a variable. Because we are in
3576 // the context of a function, getValNonImprovising will search the functions
3577 // symbol table instead of the module symbol table for the global symbol,
3578 // which throws things all off. To get around this, we just tell
3579 // getValNonImprovising that we are at global scope here.
3580 //
3581 Function *SavedCurFn = CurFun.CurrentFunction;
3582 CurFun.CurrentFunction = 0;
3583
Reid Spencer21be8652006-10-22 07:03:43 +00003584 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003585 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003586
3587 CurFun.CurrentFunction = SavedCurFn;
3588
3589 // If this is an initializer for a constant pointer, which is referencing a
3590 // (currently) undefined variable, create a stub now that shall be replaced
3591 // in the future with the right type of variable.
3592 //
3593 if (V == 0) {
3594 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3595 const PointerType *PT = cast<PointerType>(Ty);
3596
3597 // First check to see if the forward references value is already created!
3598 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer21be8652006-10-22 07:03:43 +00003599 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003600
3601 if (I != CurModule.GlobalRefs.end()) {
3602 V = I->second; // Placeholder already exists, use it...
Reid Spencer21be8652006-10-22 07:03:43 +00003603 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003604 } else {
3605 std::string Name;
Reid Spencer21be8652006-10-22 07:03:43 +00003606 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003607
3608 // Create the forward referenced global.
3609 GlobalValue *GV;
3610 if (const FunctionType *FTy =
3611 dyn_cast<FunctionType>(PT->getElementType())) {
3612 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3613 CurModule.CurrentModule);
3614 } else {
3615 GV = new GlobalVariable(PT->getElementType(), false,
3616 GlobalValue::ExternalLinkage, 0,
3617 Name, CurModule.CurrentModule);
3618 }
3619
3620 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer21be8652006-10-22 07:03:43 +00003621 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003622 V = GV;
3623 }
3624 }
3625
Reid Spencer21be8652006-10-22 07:03:43 +00003626 (yyval.ConstVal) = cast<GlobalValue>(V);
3627 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003628 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003629 ;}
3630 break;
3631
Reid Spencer3ed469c2006-11-02 20:25:50 +00003632 case 110:
3633#line 1589 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003634 {
3635 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003636 GEN_ERROR("Mismatched types for constant expression!");
Reid Spencer21be8652006-10-22 07:03:43 +00003637 (yyval.ConstVal) = (yyvsp[0].ConstVal);
3638 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003639 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003640 ;}
3641 break;
3642
Reid Spencer3ed469c2006-11-02 20:25:50 +00003643 case 111:
3644#line 1596 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003645 {
3646 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003647 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +00003648 GEN_ERROR("Cannot create a null initialized value of this type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003649 (yyval.ConstVal) = Constant::getNullValue(Ty);
3650 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003651 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003652 ;}
3653 break;
3654
Reid Spencer3ed469c2006-11-02 20:25:50 +00003655 case 112:
3656#line 1605 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003657 { // integral constants
3658 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003659 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003660 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003661 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003662 ;}
3663 break;
3664
Reid Spencer3ed469c2006-11-02 20:25:50 +00003665 case 113:
3666#line 1611 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003667 { // integral constants
3668 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003669 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003670 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003671 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003672 ;}
3673 break;
3674
Reid Spencer3ed469c2006-11-02 20:25:50 +00003675 case 114:
3676#line 1617 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003677 { // Boolean constants
3678 (yyval.ConstVal) = ConstantBool::getTrue();
Reid Spencer61c83e02006-08-18 08:43:06 +00003679 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003680 ;}
3681 break;
3682
Reid Spencer3ed469c2006-11-02 20:25:50 +00003683 case 115:
3684#line 1621 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003685 { // Boolean constants
3686 (yyval.ConstVal) = ConstantBool::getFalse();
Reid Spencer61c83e02006-08-18 08:43:06 +00003687 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003688 ;}
3689 break;
3690
Reid Spencer3ed469c2006-11-02 20:25:50 +00003691 case 116:
3692#line 1625 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003693 { // Float & Double constants
3694 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003695 GEN_ERROR("Floating point constant invalid for type!!");
Reid Spencer21be8652006-10-22 07:03:43 +00003696 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003697 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003698 ;}
3699 break;
3700
Reid Spencer3ed469c2006-11-02 20:25:50 +00003701 case 117:
3702#line 1633 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003703 {
3704 if (!(yyvsp[-3].ConstVal)->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003705 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003706 (yyvsp[-3].ConstVal)->getType()->getDescription() + "'!");
3707 if (!(yyvsp[-1].TypeVal)->get()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003708 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003709 (yyvsp[-1].TypeVal)->get()->getDescription() + "'!");
3710 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get());
3711 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003712 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003713 ;}
3714 break;
3715
Reid Spencer3ed469c2006-11-02 20:25:50 +00003716 case 118:
3717#line 1644 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003718 {
3719 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00003720 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003721
3722 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3723 // indices to uint struct indices for compatibility.
3724 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer21be8652006-10-22 07:03:43 +00003725 GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()),
3726 GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end());
3727 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003728 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer21be8652006-10-22 07:03:43 +00003729 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003730 if (CUI->getType() == Type::UByteTy)
Reid Spencer21be8652006-10-22 07:03:43 +00003731 (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003732
3733 const Type *IdxTy =
Reid Spencer21be8652006-10-22 07:03:43 +00003734 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003735 if (!IdxTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003736 GEN_ERROR("Index list invalid for constant getelementptr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003737
3738 std::vector<Constant*> IdxVec;
Reid Spencer21be8652006-10-22 07:03:43 +00003739 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
3740 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003741 IdxVec.push_back(C);
3742 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003743 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003744
Reid Spencer21be8652006-10-22 07:03:43 +00003745 delete (yyvsp[-1].ValueList);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003746
Reid Spencer21be8652006-10-22 07:03:43 +00003747 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
Reid Spencer61c83e02006-08-18 08:43:06 +00003748 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003749 ;}
3750 break;
3751
Reid Spencer3ed469c2006-11-02 20:25:50 +00003752 case 119:
3753#line 1676 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003754 {
3755 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003756 GEN_ERROR("Select condition must be of boolean type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003757 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003758 GEN_ERROR("Select operand types must match!");
Reid Spencer21be8652006-10-22 07:03:43 +00003759 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003760 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003761 ;}
3762 break;
3763
Reid Spencer3ed469c2006-11-02 20:25:50 +00003764 case 120:
3765#line 1684 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003766 {
3767 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003768 GEN_ERROR("Binary operator types must match!");
Reid Spencer1628cec2006-10-26 06:15:43 +00003769 // First, make sure we're dealing with the right opcode by upgrading from
3770 // obsolete versions.
3771 sanitizeOpCode((yyvsp[-5].BinaryOpVal),(yyvsp[-3].ConstVal)->getType());
3772 CHECK_FOR_ERROR;
3773
Reid Spencer68a24bd2005-08-27 18:50:39 +00003774 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3775 // To retain backward compatibility with these early compilers, we emit a
3776 // cast to the appropriate integer type automatically if we are in the
3777 // broken case. See PR424 for more information.
Reid Spencer21be8652006-10-22 07:03:43 +00003778 if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) {
Reid Spencer1628cec2006-10-26 06:15:43 +00003779 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003780 } else {
3781 const Type *IntPtrTy = 0;
3782 switch (CurModule.CurrentModule->getPointerSize()) {
3783 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3784 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer61c83e02006-08-18 08:43:06 +00003785 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003786 }
Reid Spencer1628cec2006-10-26 06:15:43 +00003787 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy),
Reid Spencer21be8652006-10-22 07:03:43 +00003788 ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy));
3789 (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003790 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003791 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003792 ;}
3793 break;
3794
Reid Spencer3ed469c2006-11-02 20:25:50 +00003795 case 121:
3796#line 1711 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003797 {
3798 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003799 GEN_ERROR("Logical operator types must match!");
Reid Spencer21be8652006-10-22 07:03:43 +00003800 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
3801 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
3802 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00003803 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00003804 }
Reid Spencer1628cec2006-10-26 06:15:43 +00003805 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003806 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003807 ;}
3808 break;
3809
Reid Spencer3ed469c2006-11-02 20:25:50 +00003810 case 122:
3811#line 1722 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1628cec2006-10-26 06:15:43 +00003812 {
3813 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3814 GEN_ERROR("setcc operand types must match!");
3815 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3816 CHECK_FOR_ERROR
3817 ;}
3818 break;
3819
Reid Spencer3ed469c2006-11-02 20:25:50 +00003820 case 123:
3821#line 1728 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1628cec2006-10-26 06:15:43 +00003822 {
3823 if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy)
3824 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
3825 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
3826 GEN_ERROR("Shift constant expression requires integer operand!");
3827 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3828 CHECK_FOR_ERROR
3829 ;}
3830 break;
3831
Reid Spencer3ed469c2006-11-02 20:25:50 +00003832 case 124:
3833#line 1736 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003834 {
3835 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003836 GEN_ERROR("Invalid extractelement operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00003837 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003838 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003839 ;}
3840 break;
3841
Reid Spencer3ed469c2006-11-02 20:25:50 +00003842 case 125:
3843#line 1742 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003844 {
3845 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003846 GEN_ERROR("Invalid insertelement operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00003847 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003848 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003849 ;}
3850 break;
3851
Reid Spencer3ed469c2006-11-02 20:25:50 +00003852 case 126:
3853#line 1748 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003854 {
3855 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003856 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00003857 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003858 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003859 ;}
3860 break;
3861
Reid Spencer3ed469c2006-11-02 20:25:50 +00003862 case 127:
3863#line 1757 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003864 {
3865 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003866 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003867 ;}
3868 break;
3869
Reid Spencer3ed469c2006-11-02 20:25:50 +00003870 case 128:
3871#line 1761 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003872 {
3873 (yyval.ConstVector) = new std::vector<Constant*>();
3874 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003875 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003876 ;}
3877 break;
3878
Reid Spencer3ed469c2006-11-02 20:25:50 +00003879 case 129:
3880#line 1769 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003881 { (yyval.BoolVal) = false; ;}
3882 break;
3883
Reid Spencer3ed469c2006-11-02 20:25:50 +00003884 case 130:
3885#line 1769 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003886 { (yyval.BoolVal) = true; ;}
3887 break;
3888
Reid Spencer3ed469c2006-11-02 20:25:50 +00003889 case 131:
3890#line 1779 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003891 {
3892 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003893 CurModule.ModuleDone();
Reid Spencerf63697d2006-10-09 17:36:59 +00003894 CHECK_FOR_ERROR;
Reid Spencer21be8652006-10-22 07:03:43 +00003895;}
3896 break;
3897
Reid Spencer3ed469c2006-11-02 20:25:50 +00003898 case 132:
3899#line 1787 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003900 {
3901 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003902 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003903 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003904 ;}
3905 break;
3906
Reid Spencer1628cec2006-10-26 06:15:43 +00003907 case 133:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003908#line 1792 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1628cec2006-10-26 06:15:43 +00003909 {
3910 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
3911 CHECK_FOR_ERROR
3912 ;}
3913 break;
3914
3915 case 134:
Reid Spencer3ed469c2006-11-02 20:25:50 +00003916#line 1796 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3917 {
3918 (yyval.ModuleVal) = (yyvsp[-3].ModuleVal);
3919 CHECK_FOR_ERROR
3920 ;}
3921 break;
3922
3923 case 135:
3924#line 1800 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
3925 {
3926 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
3927 CHECK_FOR_ERROR
3928 ;}
3929 break;
3930
3931 case 136:
3932#line 1804 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003933 {
3934 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003935 // Emit an error if there are any unresolved types left.
3936 if (!CurModule.LateResolveTypes.empty()) {
3937 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00003938 if (DID.Type == ValID::NameVal) {
3939 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3940 } else {
3941 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3942 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003943 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003944 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003945 ;}
3946 break;
3947
Reid Spencer3ed469c2006-11-02 20:25:50 +00003948 case 137:
3949#line 1819 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003950 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003951 // Eagerly resolve types. This is not an optimization, this is a
3952 // requirement that is due to the fact that we could have this:
3953 //
3954 // %list = type { %list * }
3955 // %list = type { %list * } ; repeated type decl
3956 //
3957 // If types are not resolved eagerly, then the two types will not be
3958 // determined to be the same type!
3959 //
Reid Spencer21be8652006-10-22 07:03:43 +00003960 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003961
Reid Spencer21be8652006-10-22 07:03:43 +00003962 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003963 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003964 // If this is a named type that is not a redefinition, add it to the slot
3965 // table.
Reid Spencer21be8652006-10-22 07:03:43 +00003966 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003967 }
3968
Reid Spencer21be8652006-10-22 07:03:43 +00003969 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003970 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003971 ;}
3972 break;
3973
Reid Spencer3ed469c2006-11-02 20:25:50 +00003974 case 138:
3975#line 1841 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003976 { // Function prototypes can be in const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00003977 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003978 ;}
3979 break;
3980
Reid Spencer3ed469c2006-11-02 20:25:50 +00003981 case 139:
3982#line 1844 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003983 { // Asm blocks can be in the const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00003984 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003985 ;}
3986 break;
3987
Reid Spencer3ed469c2006-11-02 20:25:50 +00003988 case 140:
3989#line 1847 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003990 {
3991 if ((yyvsp[0].ConstVal) == 0)
Reid Spencer5b7e7532006-09-28 19:28:24 +00003992 GEN_ERROR("Global value initializer is not a constant!");
Reid Spencer21be8652006-10-22 07:03:43 +00003993 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 +00003994 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003995 ;}
3996 break;
3997
Reid Spencer3ed469c2006-11-02 20:25:50 +00003998 case 141:
3999#line 1852 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004000 {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004001 CurGV = 0;
Reid Spencer21be8652006-10-22 07:03:43 +00004002 ;}
4003 break;
4004
Reid Spencer3ed469c2006-11-02 20:25:50 +00004005 case 142:
4006#line 1855 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004007 {
4008 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004009 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004010 delete (yyvsp[0].TypeVal);
4011 ;}
4012 break;
4013
Reid Spencer1628cec2006-10-26 06:15:43 +00004014 case 143:
Reid Spencer3ed469c2006-11-02 20:25:50 +00004015#line 1859 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer1628cec2006-10-26 06:15:43 +00004016 {
4017 CurGV = 0;
4018 CHECK_FOR_ERROR
4019 ;}
4020 break;
4021
4022 case 144:
Reid Spencer3ed469c2006-11-02 20:25:50 +00004023#line 1863 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4024 {
4025 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
4026 CHECK_FOR_ERROR
4027 delete (yyvsp[0].TypeVal);
4028 ;}
4029 break;
4030
4031 case 145:
4032#line 1867 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4033 {
4034 CurGV = 0;
4035 CHECK_FOR_ERROR
4036 ;}
4037 break;
4038
4039 case 146:
4040#line 1871 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004041 {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004042 CurGV =
Reid Spencer21be8652006-10-22 07:03:43 +00004043 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004044 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004045 delete (yyvsp[0].TypeVal);
4046 ;}
4047 break;
4048
Reid Spencer3ed469c2006-11-02 20:25:50 +00004049 case 147:
4050#line 1876 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004051 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004052 CurGV = 0;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004053 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004054 ;}
4055 break;
4056
Reid Spencer3ed469c2006-11-02 20:25:50 +00004057 case 148:
4058#line 1880 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004059 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004060 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004061 ;}
4062 break;
4063
Reid Spencer3ed469c2006-11-02 20:25:50 +00004064 case 149:
4065#line 1883 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004066 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004067 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004068 ;}
4069 break;
4070
Reid Spencer3ed469c2006-11-02 20:25:50 +00004071 case 150:
4072#line 1886 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004073 {
4074 ;}
4075 break;
4076
Reid Spencer3ed469c2006-11-02 20:25:50 +00004077 case 151:
4078#line 1890 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004079 {
Chris Lattner66316012006-01-24 04:14:29 +00004080 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer21be8652006-10-22 07:03:43 +00004081 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4082 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4083 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004084
4085 if (AsmSoFar.empty())
4086 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4087 else
4088 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004089 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004090;}
4091 break;
4092
Reid Spencer3ed469c2006-11-02 20:25:50 +00004093 case 152:
4094#line 1903 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004095 { (yyval.Endianness) = Module::BigEndian; ;}
4096 break;
4097
Reid Spencer3ed469c2006-11-02 20:25:50 +00004098 case 153:
4099#line 1904 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004100 { (yyval.Endianness) = Module::LittleEndian; ;}
4101 break;
4102
Reid Spencer3ed469c2006-11-02 20:25:50 +00004103 case 154:
4104#line 1906 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004105 {
4106 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
Reid Spencer61c83e02006-08-18 08:43:06 +00004107 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004108 ;}
4109 break;
4110
Reid Spencer3ed469c2006-11-02 20:25:50 +00004111 case 155:
4112#line 1910 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004113 {
4114 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004115 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Reid Spencer21be8652006-10-22 07:03:43 +00004116 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004117 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4118 else
Reid Spencer21be8652006-10-22 07:03:43 +00004119 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00004120 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004121 ;}
4122 break;
4123
Reid Spencer3ed469c2006-11-02 20:25:50 +00004124 case 156:
4125#line 1919 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004126 {
4127 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4128 free((yyvsp[0].StrVal));
4129 ;}
4130 break;
4131
Reid Spencer3ed469c2006-11-02 20:25:50 +00004132 case 157:
4133#line 1923 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004134 {
4135 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4136 free((yyvsp[0].StrVal));
4137 ;}
4138 break;
4139
Reid Spencer1628cec2006-10-26 06:15:43 +00004140 case 159:
Reid Spencer3ed469c2006-11-02 20:25:50 +00004141#line 1930 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4142 {
4143 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4144 free((yyvsp[0].StrVal));
4145 CHECK_FOR_ERROR
4146 ;}
4147 break;
4148
4149 case 160:
4150#line 1935 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4151 {
4152 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4153 free((yyvsp[0].StrVal));
4154 CHECK_FOR_ERROR
4155 ;}
4156 break;
4157
4158 case 161:
4159#line 1940 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004160 {
Reid Spencer61c83e02006-08-18 08:43:06 +00004161 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004162 ;}
4163 break;
4164
Reid Spencer3ed469c2006-11-02 20:25:50 +00004165 case 165:
4166#line 1950 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004167 { (yyval.StrVal) = 0; ;}
4168 break;
4169
Reid Spencer3ed469c2006-11-02 20:25:50 +00004170 case 166:
4171#line 1952 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004172 {
4173 if (*(yyvsp[-1].TypeVal) == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004174 GEN_ERROR("void typed arguments are invalid!");
Reid Spencer21be8652006-10-22 07:03:43 +00004175 (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004176 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004177;}
4178 break;
4179
Reid Spencer3ed469c2006-11-02 20:25:50 +00004180 case 167:
4181#line 1959 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004182 {
4183 (yyval.ArgList) = (yyvsp[-2].ArgList);
4184 (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal));
4185 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004186 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004187 ;}
4188 break;
4189
Reid Spencer3ed469c2006-11-02 20:25:50 +00004190 case 168:
4191#line 1965 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004192 {
4193 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4194 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4195 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004196 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004197 ;}
4198 break;
4199
Reid Spencer3ed469c2006-11-02 20:25:50 +00004200 case 169:
4201#line 1972 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004202 {
4203 (yyval.ArgList) = (yyvsp[0].ArgList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004204 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004205 ;}
4206 break;
4207
Reid Spencer3ed469c2006-11-02 20:25:50 +00004208 case 170:
4209#line 1976 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004210 {
4211 (yyval.ArgList) = (yyvsp[-2].ArgList);
4212 (yyval.ArgList)->push_back(std::pair<PATypeHolder*,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004213 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004214 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004215 ;}
4216 break;
4217
Reid Spencer3ed469c2006-11-02 20:25:50 +00004218 case 171:
4219#line 1982 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004220 {
4221 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4222 (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004223 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004224 ;}
4225 break;
4226
Reid Spencer3ed469c2006-11-02 20:25:50 +00004227 case 172:
4228#line 1987 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004229 {
4230 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004231 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004232 ;}
4233 break;
4234
Reid Spencer3ed469c2006-11-02 20:25:50 +00004235 case 173:
4236#line 1993 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004237 {
4238 UnEscapeLexed((yyvsp[-5].StrVal));
4239 std::string FunctionName((yyvsp[-5].StrVal));
4240 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004241
Reid Spencer21be8652006-10-22 07:03:43 +00004242 if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004243 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004244
4245 std::vector<const Type*> ParamTypeList;
Reid Spencer21be8652006-10-22 07:03:43 +00004246 if ((yyvsp[-3].ArgList)) { // If there are arguments...
4247 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4248 I != (yyvsp[-3].ArgList)->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004249 ParamTypeList.push_back(I->first->get());
4250 }
4251
4252 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4253 if (isVarArg) ParamTypeList.pop_back();
4254
Reid Spencer21be8652006-10-22 07:03:43 +00004255 const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004256 const PointerType *PFT = PointerType::get(FT);
Reid Spencer21be8652006-10-22 07:03:43 +00004257 delete (yyvsp[-6].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004258
4259 ValID ID;
4260 if (!FunctionName.empty()) {
4261 ID = ValID::create((char*)FunctionName.c_str());
4262 } else {
4263 ID = ValID::create((int)CurModule.Values[PFT].size());
4264 }
4265
4266 Function *Fn = 0;
4267 // See if this function was forward referenced. If so, recycle the object.
4268 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4269 // Move the function to the end of the list, from whereever it was
4270 // previously inserted.
4271 Fn = cast<Function>(FWRef);
4272 CurModule.CurrentModule->getFunctionList().remove(Fn);
4273 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4274 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4275 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4276 // If this is the case, either we need to be a forward decl, or it needs
4277 // to be.
4278 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004279 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004280
4281 // Make sure to strip off any argument names so we can't get conflicts.
4282 if (Fn->isExternal())
4283 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4284 AI != AE; ++AI)
4285 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004286 } else { // Not already defined?
4287 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4288 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004289
Reid Spencer68a24bd2005-08-27 18:50:39 +00004290 InsertValue(Fn, CurModule.Values);
4291 }
4292
4293 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004294
4295 if (CurFun.isDeclare) {
4296 // If we have declaration, always overwrite linkage. This will allow us to
4297 // correctly handle cases, when pointer to function is passed as argument to
4298 // another function.
4299 Fn->setLinkage(CurFun.Linkage);
4300 }
Reid Spencer21be8652006-10-22 07:03:43 +00004301 Fn->setCallingConv((yyvsp[-7].UIntVal));
4302 Fn->setAlignment((yyvsp[0].UIntVal));
4303 if ((yyvsp[-1].StrVal)) {
4304 Fn->setSection((yyvsp[-1].StrVal));
4305 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004306 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004307
4308 // Add all of the arguments we parsed to the function...
Reid Spencer21be8652006-10-22 07:03:43 +00004309 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004310 if (isVarArg) { // Nuke the last entry
Reid Spencer21be8652006-10-22 07:03:43 +00004311 assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00004312 "Not a varargs marker!");
Reid Spencer21be8652006-10-22 07:03:43 +00004313 delete (yyvsp[-3].ArgList)->back().first;
4314 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004315 }
4316 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer21be8652006-10-22 07:03:43 +00004317 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4318 I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004319 delete I->first; // Delete the typeholder...
4320
4321 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004322 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004323 InsertValue(ArgIt);
4324 }
4325
Reid Spencer21be8652006-10-22 07:03:43 +00004326 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004327 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004328 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004329;}
4330 break;
4331
Reid Spencer3ed469c2006-11-02 20:25:50 +00004332 case 176:
4333#line 2089 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004334 {
4335 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004336
4337 // Make sure that we keep track of the linkage type even if there was a
4338 // previous "declare".
Reid Spencer21be8652006-10-22 07:03:43 +00004339 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
4340;}
4341 break;
4342
Reid Spencer3ed469c2006-11-02 20:25:50 +00004343 case 179:
4344#line 2099 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004345 {
4346 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004347 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004348;}
4349 break;
4350
Reid Spencer1628cec2006-10-26 06:15:43 +00004351 case 181:
Reid Spencer3ed469c2006-11-02 20:25:50 +00004352#line 2105 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4353 { CurFun.Linkage = GlobalValue::DLLImportLinkage ;}
Reid Spencer1628cec2006-10-26 06:15:43 +00004354 break;
4355
4356 case 182:
Reid Spencer3ed469c2006-11-02 20:25:50 +00004357#line 2106 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4358 { CurFun.Linkage = GlobalValue::DLLImportLinkage ;}
4359 break;
4360
4361 case 183:
4362#line 2108 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
4363 { CurFun.isDeclare = true; ;}
4364 break;
4365
4366 case 184:
4367#line 2108 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004368 {
4369 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004370 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004371 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004372 ;}
4373 break;
4374
Reid Spencer3ed469c2006-11-02 20:25:50 +00004375 case 185:
4376#line 2118 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004377 {
4378 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004379 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004380 ;}
4381 break;
4382
Reid Spencer3ed469c2006-11-02 20:25:50 +00004383 case 186:
4384#line 2122 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004385 {
4386 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004387 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004388 ;}
4389 break;
4390
Reid Spencer3ed469c2006-11-02 20:25:50 +00004391 case 187:
4392#line 2127 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004393 { // A reference to a direct constant
4394 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00004395 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004396 ;}
4397 break;
4398
Reid Spencer3ed469c2006-11-02 20:25:50 +00004399 case 188:
4400#line 2131 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004401 {
4402 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00004403 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004404 ;}
4405 break;
4406
Reid Spencer3ed469c2006-11-02 20:25:50 +00004407 case 189:
4408#line 2135 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004409 { // Perhaps it's an FP constant?
4410 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004411 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004412 ;}
4413 break;
4414
Reid Spencer3ed469c2006-11-02 20:25:50 +00004415 case 190:
4416#line 2139 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004417 {
4418 (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue());
Reid Spencer61c83e02006-08-18 08:43:06 +00004419 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004420 ;}
4421 break;
4422
Reid Spencer3ed469c2006-11-02 20:25:50 +00004423 case 191:
4424#line 2143 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004425 {
4426 (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse());
Reid Spencer61c83e02006-08-18 08:43:06 +00004427 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004428 ;}
4429 break;
4430
Reid Spencer3ed469c2006-11-02 20:25:50 +00004431 case 192:
4432#line 2147 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004433 {
4434 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004435 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004436 ;}
4437 break;
4438
Reid Spencer3ed469c2006-11-02 20:25:50 +00004439 case 193:
4440#line 2151 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004441 {
4442 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004443 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004444 ;}
4445 break;
4446
Reid Spencer3ed469c2006-11-02 20:25:50 +00004447 case 194:
4448#line 2155 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004449 { // A vector zero constant.
4450 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004451 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004452 ;}
4453 break;
4454
Reid Spencer3ed469c2006-11-02 20:25:50 +00004455 case 195:
4456#line 2159 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004457 { // Nonempty unsized packed vector
4458 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4459 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004460
4461 PackedType* pt = PackedType::get(ETy, NumElements);
4462 PATypeHolder* PTy = new PATypeHolder(
4463 HandleUpRefs(
4464 PackedType::get(
4465 ETy,
4466 NumElements)
4467 )
4468 );
4469
4470 // Verify all elements are correct type!
Reid Spencer21be8652006-10-22 07:03:43 +00004471 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4472 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004473 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004474 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer21be8652006-10-22 07:03:43 +00004475 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004476 }
4477
Reid Spencer21be8652006-10-22 07:03:43 +00004478 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4479 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00004480 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004481 ;}
4482 break;
Reid Spencerb83eb642006-10-20 07:07:24 +00004483
Reid Spencer3ed469c2006-11-02 20:25:50 +00004484 case 196:
4485#line 2184 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004486 {
4487 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Reid Spencerb83eb642006-10-20 07:07:24 +00004488 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004489 ;}
4490 break;
4491
Reid Spencer3ed469c2006-11-02 20:25:50 +00004492 case 197:
4493#line 2188 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004494 {
4495 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4496 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4497 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4498 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4499 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4500 free((yyvsp[-2].StrVal));
4501 free((yyvsp[0].StrVal));
Reid Spencerb83eb642006-10-20 07:07:24 +00004502 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004503 ;}
4504 break;
4505
Reid Spencer3ed469c2006-11-02 20:25:50 +00004506 case 198:
4507#line 2202 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004508 { // Is it an integer reference...?
4509 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4510 CHECK_FOR_ERROR
4511 ;}
4512 break;
4513
Reid Spencer3ed469c2006-11-02 20:25:50 +00004514 case 199:
4515#line 2206 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004516 { // Is it a named reference...?
4517 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4518 CHECK_FOR_ERROR
4519 ;}
4520 break;
4521
Reid Spencer3ed469c2006-11-02 20:25:50 +00004522 case 202:
4523#line 2218 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004524 {
4525 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal);
4526 CHECK_FOR_ERROR
4527 ;}
4528 break;
4529
Reid Spencer3ed469c2006-11-02 20:25:50 +00004530 case 203:
4531#line 2223 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004532 {
4533 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4534 CHECK_FOR_ERROR
4535 ;}
4536 break;
4537
Reid Spencer3ed469c2006-11-02 20:25:50 +00004538 case 204:
4539#line 2227 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004540 { // Do not allow functions with 0 basic blocks
4541 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4542 CHECK_FOR_ERROR
4543 ;}
4544 break;
4545
Reid Spencer3ed469c2006-11-02 20:25:50 +00004546 case 205:
4547#line 2236 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004548 {
4549 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4550 CHECK_FOR_ERROR
4551 InsertValue((yyvsp[0].TermInstVal));
4552
4553 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4554 InsertValue((yyvsp[-2].BasicBlockVal));
4555 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
4556 CHECK_FOR_ERROR
4557 ;}
4558 break;
4559
Reid Spencer3ed469c2006-11-02 20:25:50 +00004560 case 206:
4561#line 2247 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004562 {
4563 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4564 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
4565 CHECK_FOR_ERROR
4566 ;}
4567 break;
4568
Reid Spencer3ed469c2006-11-02 20:25:50 +00004569 case 207:
4570#line 2252 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004571 {
4572 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004573 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004574
4575 // Make sure to move the basic block to the correct location in the
4576 // function, instead of leaving it inserted wherever it was first
4577 // referenced.
4578 Function::BasicBlockListType &BBL =
4579 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer21be8652006-10-22 07:03:43 +00004580 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004581 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004582 ;}
4583 break;
4584
Reid Spencer3ed469c2006-11-02 20:25:50 +00004585 case 208:
4586#line 2264 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004587 {
4588 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004589 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004590
4591 // Make sure to move the basic block to the correct location in the
4592 // function, instead of leaving it inserted wherever it was first
4593 // referenced.
4594 Function::BasicBlockListType &BBL =
4595 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer21be8652006-10-22 07:03:43 +00004596 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004597 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004598 ;}
4599 break;
Reid Spencer61c83e02006-08-18 08:43:06 +00004600
Reid Spencer3ed469c2006-11-02 20:25:50 +00004601 case 209:
4602#line 2277 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004603 { // Return with a result...
4604 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4605 CHECK_FOR_ERROR
4606 ;}
4607 break;
4608
Reid Spencer3ed469c2006-11-02 20:25:50 +00004609 case 210:
4610#line 2281 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004611 { // Return with no result...
4612 (yyval.TermInstVal) = new ReturnInst();
4613 CHECK_FOR_ERROR
4614 ;}
4615 break;
4616
Reid Spencer3ed469c2006-11-02 20:25:50 +00004617 case 211:
4618#line 2285 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004619 { // Unconditional Branch...
4620 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
4621 CHECK_FOR_ERROR
4622 (yyval.TermInstVal) = new BranchInst(tmpBB);
4623 ;}
4624 break;
4625
Reid Spencer3ed469c2006-11-02 20:25:50 +00004626 case 212:
4627#line 2290 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004628 {
4629 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
4630 CHECK_FOR_ERROR
4631 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
4632 CHECK_FOR_ERROR
4633 Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal));
4634 CHECK_FOR_ERROR
4635 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4636 ;}
4637 break;
4638
Reid Spencer3ed469c2006-11-02 20:25:50 +00004639 case 213:
4640#line 2299 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004641 {
4642 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
4643 CHECK_FOR_ERROR
4644 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
4645 CHECK_FOR_ERROR
4646 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
4647 (yyval.TermInstVal) = S;
4648
4649 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4650 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004651 for (; I != E; ++I) {
4652 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4653 S->addCase(CI, I->second);
4654 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004655 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004656 }
Reid Spencer21be8652006-10-22 07:03:43 +00004657 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00004658 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004659 ;}
4660 break;
4661
Reid Spencer3ed469c2006-11-02 20:25:50 +00004662 case 214:
4663#line 2318 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004664 {
4665 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004666 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004667 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004668 CHECK_FOR_ERROR
4669 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer21be8652006-10-22 07:03:43 +00004670 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004671 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004672 ;}
4673 break;
4674
Reid Spencer3ed469c2006-11-02 20:25:50 +00004675 case 215:
4676#line 2328 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004677 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004678 const PointerType *PFTy;
4679 const FunctionType *Ty;
4680
Reid Spencer21be8652006-10-22 07:03:43 +00004681 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004682 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4683 // Pull out the types of all of the arguments...
4684 std::vector<const Type*> ParamTypes;
Reid Spencer21be8652006-10-22 07:03:43 +00004685 if ((yyvsp[-7].ValueList)) {
4686 for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004687 I != E; ++I)
4688 ParamTypes.push_back((*I)->getType());
4689 }
4690
4691 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4692 if (isVarArg) ParamTypes.pop_back();
4693
Reid Spencer21be8652006-10-22 07:03:43 +00004694 Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004695 PFTy = PointerType::get(Ty);
4696 }
4697
Reid Spencer21be8652006-10-22 07:03:43 +00004698 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004699 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004700 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004701 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004702 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004703 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004704
4705 // Create the call node...
Reid Spencer21be8652006-10-22 07:03:43 +00004706 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
4707 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004708 } else { // Has arguments?
4709 // Loop through FunctionType's arguments and ensure they are specified
4710 // correctly!
4711 //
4712 FunctionType::param_iterator I = Ty->param_begin();
4713 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer21be8652006-10-22 07:03:43 +00004714 std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004715
4716 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4717 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00004718 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004719 (*I)->getDescription() + "'!");
4720
4721 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004722 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004723
Reid Spencer21be8652006-10-22 07:03:43 +00004724 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004725 }
Reid Spencer21be8652006-10-22 07:03:43 +00004726 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004727
Reid Spencer21be8652006-10-22 07:03:43 +00004728 delete (yyvsp[-10].TypeVal);
4729 delete (yyvsp[-7].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004730 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004731 ;}
4732 break;
4733
Reid Spencer3ed469c2006-11-02 20:25:50 +00004734 case 216:
4735#line 2383 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004736 {
4737 (yyval.TermInstVal) = new UnwindInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00004738 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004739 ;}
4740 break;
4741
Reid Spencer3ed469c2006-11-02 20:25:50 +00004742 case 217:
4743#line 2387 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004744 {
4745 (yyval.TermInstVal) = new UnreachableInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00004746 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004747 ;}
4748 break;
4749
Reid Spencer3ed469c2006-11-02 20:25:50 +00004750 case 218:
4751#line 2394 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004752 {
4753 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
4754 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004755 CHECK_FOR_ERROR
Reid Spencer61c83e02006-08-18 08:43:06 +00004756 if (V == 0)
4757 GEN_ERROR("May only switch on a constant pool value!");
4758
Reid Spencer21be8652006-10-22 07:03:43 +00004759 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004760 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004761 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
4762 ;}
4763 break;
4764
Reid Spencer3ed469c2006-11-02 20:25:50 +00004765 case 219:
4766#line 2405 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004767 {
4768 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
4769 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004770 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004771
4772 if (V == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004773 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004774
Reid Spencer21be8652006-10-22 07:03:43 +00004775 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004776 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004777 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
4778 ;}
4779 break;
4780
Reid Spencer3ed469c2006-11-02 20:25:50 +00004781 case 220:
4782#line 2418 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004783 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004784 // Is this definition named?? if so, assign the name...
Reid Spencer21be8652006-10-22 07:03:43 +00004785 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004786 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004787 InsertValue((yyvsp[0].InstVal));
4788 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004789 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004790;}
4791 break;
4792
Reid Spencer3ed469c2006-11-02 20:25:50 +00004793 case 221:
4794#line 2427 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004795 { // Used for PHI nodes
4796 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
4797 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004798 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004799 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004800 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004801 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4802 delete (yyvsp[-5].TypeVal);
4803 ;}
4804 break;
4805
Reid Spencer3ed469c2006-11-02 20:25:50 +00004806 case 222:
4807#line 2436 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004808 {
4809 (yyval.PHIList) = (yyvsp[-6].PHIList);
4810 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004811 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004812 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004813 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004814 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4815 ;}
4816 break;
4817
Reid Spencer3ed469c2006-11-02 20:25:50 +00004818 case 223:
4819#line 2446 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004820 { // Used for call statements, and memory insts...
4821 (yyval.ValueList) = new std::vector<Value*>();
4822 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
4823 ;}
4824 break;
4825
Reid Spencer3ed469c2006-11-02 20:25:50 +00004826 case 224:
4827#line 2450 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004828 {
4829 (yyval.ValueList) = (yyvsp[-2].ValueList);
4830 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004831 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004832 ;}
4833 break;
4834
Reid Spencer3ed469c2006-11-02 20:25:50 +00004835 case 226:
4836#line 2457 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004837 { (yyval.ValueList) = 0; ;}
4838 break;
4839
Reid Spencer3ed469c2006-11-02 20:25:50 +00004840 case 227:
4841#line 2459 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004842 {
4843 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004844 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004845 ;}
4846 break;
4847
Reid Spencer3ed469c2006-11-02 20:25:50 +00004848 case 228:
4849#line 2463 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004850 {
4851 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004852 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004853 ;}
4854 break;
4855
Reid Spencer3ed469c2006-11-02 20:25:50 +00004856 case 229:
4857#line 2468 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004858 {
4859 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
4860 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004861 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004862 "Arithmetic operator requires integer, FP, or packed operands!");
Reid Spencer3ed469c2006-11-02 20:25:50 +00004863 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) &&
4864 ((yyvsp[-4].BinaryOpVal).opcode == Instruction::URem ||
4865 (yyvsp[-4].BinaryOpVal).opcode == Instruction::SRem ||
4866 (yyvsp[-4].BinaryOpVal).opcode == Instruction::FRem))
4867 GEN_ERROR("U/S/FRem not supported on packed types!");
Reid Spencer1628cec2006-10-26 06:15:43 +00004868 // Upgrade the opcode from obsolete versions before we do anything with it.
4869 sanitizeOpCode((yyvsp[-4].BinaryOpVal),*(yyvsp[-3].TypeVal));
4870 CHECK_FOR_ERROR;
Reid Spencer21be8652006-10-22 07:03:43 +00004871 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004872 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004873 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004874 CHECK_FOR_ERROR
Reid Spencer1628cec2006-10-26 06:15:43 +00004875 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, val1, val2);
Reid Spencer21be8652006-10-22 07:03:43 +00004876 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004877 GEN_ERROR("binary operator returned null!");
Reid Spencer21be8652006-10-22 07:03:43 +00004878 delete (yyvsp[-3].TypeVal);
4879 ;}
4880 break;
4881
Reid Spencer3ed469c2006-11-02 20:25:50 +00004882 case 230:
4883#line 2490 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004884 {
4885 if (!(*(yyvsp[-3].TypeVal))->isIntegral()) {
4886 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
4887 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00004888 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00004889 }
Reid Spencer21be8652006-10-22 07:03:43 +00004890 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004891 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004892 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004893 CHECK_FOR_ERROR
Reid Spencer1628cec2006-10-26 06:15:43 +00004894 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2);
Reid Spencer21be8652006-10-22 07:03:43 +00004895 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004896 GEN_ERROR("binary operator returned null!");
Reid Spencer21be8652006-10-22 07:03:43 +00004897 delete (yyvsp[-3].TypeVal);
4898 ;}
4899 break;
4900
Reid Spencer3ed469c2006-11-02 20:25:50 +00004901 case 231:
4902#line 2505 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004903 {
4904 if(isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) {
Reid Spencer61c83e02006-08-18 08:43:06 +00004905 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004906 "PackedTypes currently not supported in setcc instructions!");
4907 }
Reid Spencer21be8652006-10-22 07:03:43 +00004908 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004909 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004910 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004911 CHECK_FOR_ERROR
Reid Spencer1628cec2006-10-26 06:15:43 +00004912 (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2);
Reid Spencer21be8652006-10-22 07:03:43 +00004913 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004914 GEN_ERROR("binary operator returned null!");
Reid Spencer21be8652006-10-22 07:03:43 +00004915 delete (yyvsp[-3].TypeVal);
4916 ;}
4917 break;
4918
Reid Spencer3ed469c2006-11-02 20:25:50 +00004919 case 232:
4920#line 2519 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004921 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004922 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4923 << " Replacing with 'xor'.\n";
4924
Reid Spencer21be8652006-10-22 07:03:43 +00004925 Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004926 if (Ones == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004927 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004928
Reid Spencer21be8652006-10-22 07:03:43 +00004929 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
4930 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004931 GEN_ERROR("Could not create a xor instruction!");
4932 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004933 ;}
4934 break;
4935
Reid Spencer3ed469c2006-11-02 20:25:50 +00004936 case 233:
4937#line 2532 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004938 {
4939 if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004940 GEN_ERROR("Shift amount must be ubyte!");
Reid Spencer21be8652006-10-22 07:03:43 +00004941 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
Reid Spencer61c83e02006-08-18 08:43:06 +00004942 GEN_ERROR("Shift constant expression requires integer operand!");
Reid Spencer1628cec2006-10-26 06:15:43 +00004943 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal).opcode, (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004944 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004945 ;}
4946 break;
4947
Reid Spencer3ed469c2006-11-02 20:25:50 +00004948 case 234:
4949#line 2540 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004950 {
4951 if (!(yyvsp[0].TypeVal)->get()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004952 GEN_ERROR("cast instruction to a non-primitive type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00004953 (yyvsp[0].TypeVal)->get()->getDescription() + "'!");
4954 (yyval.InstVal) = new CastInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
4955 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004956 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004957 ;}
4958 break;
4959
Reid Spencer3ed469c2006-11-02 20:25:50 +00004960 case 235:
4961#line 2548 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004962 {
4963 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004964 GEN_ERROR("select condition must be boolean!");
Reid Spencer21be8652006-10-22 07:03:43 +00004965 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004966 GEN_ERROR("select value types should match!");
Reid Spencer21be8652006-10-22 07:03:43 +00004967 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004968 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004969 ;}
4970 break;
4971
Reid Spencer3ed469c2006-11-02 20:25:50 +00004972 case 236:
4973#line 2556 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004974 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004975 NewVarArgs = true;
Reid Spencer21be8652006-10-22 07:03:43 +00004976 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
4977 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004978 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004979 ;}
4980 break;
4981
Reid Spencer3ed469c2006-11-02 20:25:50 +00004982 case 237:
4983#line 2562 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004984 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004985 ObsoleteVarArgs = true;
Reid Spencer21be8652006-10-22 07:03:43 +00004986 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004987 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004988 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004989
4990 //b = vaarg a, t ->
4991 //foo = alloca 1 of t
4992 //bar = vacopy a
4993 //store bar -> foo
4994 //b = vaarg foo, t
4995 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4996 CurBB->getInstList().push_back(foo);
Reid Spencer21be8652006-10-22 07:03:43 +00004997 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004998 CurBB->getInstList().push_back(bar);
4999 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer21be8652006-10-22 07:03:43 +00005000 (yyval.InstVal) = new VAArgInst(foo, *(yyvsp[0].TypeVal));
5001 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005002 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005003 ;}
5004 break;
5005
Reid Spencer3ed469c2006-11-02 20:25:50 +00005006 case 238:
5007#line 2582 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005008 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005009 ObsoleteVarArgs = true;
Reid Spencer21be8652006-10-22 07:03:43 +00005010 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005011 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00005012 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005013
5014 //b = vanext a, t ->
5015 //foo = alloca 1 of t
5016 //bar = vacopy a
5017 //store bar -> foo
5018 //tmp = vaarg foo, t
5019 //b = load foo
5020 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
5021 CurBB->getInstList().push_back(foo);
Reid Spencer21be8652006-10-22 07:03:43 +00005022 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005023 CurBB->getInstList().push_back(bar);
5024 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer21be8652006-10-22 07:03:43 +00005025 Instruction* tmp = new VAArgInst(foo, *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005026 CurBB->getInstList().push_back(tmp);
Reid Spencer21be8652006-10-22 07:03:43 +00005027 (yyval.InstVal) = new LoadInst(foo);
5028 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005029 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005030 ;}
5031 break;
5032
Reid Spencer3ed469c2006-11-02 20:25:50 +00005033 case 239:
5034#line 2605 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005035 {
5036 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005037 GEN_ERROR("Invalid extractelement operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00005038 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005039 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005040 ;}
5041 break;
5042
Reid Spencer3ed469c2006-11-02 20:25:50 +00005043 case 240:
5044#line 2611 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005045 {
5046 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005047 GEN_ERROR("Invalid insertelement operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00005048 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005049 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005050 ;}
5051 break;
5052
Reid Spencer3ed469c2006-11-02 20:25:50 +00005053 case 241:
5054#line 2617 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005055 {
5056 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005057 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00005058 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005059 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005060 ;}
5061 break;
5062
Reid Spencer3ed469c2006-11-02 20:25:50 +00005063 case 242:
5064#line 2623 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005065 {
5066 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005067 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005068 GEN_ERROR("PHI node operands must be of first class type!");
Reid Spencer21be8652006-10-22 07:03:43 +00005069 (yyval.InstVal) = new PHINode(Ty);
5070 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5071 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5072 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencer61c83e02006-08-18 08:43:06 +00005073 GEN_ERROR("All elements of a PHI node must be of the same type!");
Reid Spencer21be8652006-10-22 07:03:43 +00005074 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5075 (yyvsp[0].PHIList)->pop_front();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005076 }
Reid Spencer21be8652006-10-22 07:03:43 +00005077 delete (yyvsp[0].PHIList); // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005078 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005079 ;}
5080 break;
5081
Reid Spencer3ed469c2006-11-02 20:25:50 +00005082 case 243:
5083#line 2638 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005084 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005085 const PointerType *PFTy;
5086 const FunctionType *Ty;
5087
Reid Spencer21be8652006-10-22 07:03:43 +00005088 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005089 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5090 // Pull out the types of all of the arguments...
5091 std::vector<const Type*> ParamTypes;
Reid Spencer21be8652006-10-22 07:03:43 +00005092 if ((yyvsp[-1].ValueList)) {
5093 for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005094 I != E; ++I)
5095 ParamTypes.push_back((*I)->getType());
5096 }
5097
5098 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5099 if (isVarArg) ParamTypes.pop_back();
5100
Reid Spencer21be8652006-10-22 07:03:43 +00005101 if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005102 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005103
Reid Spencer21be8652006-10-22 07:03:43 +00005104 Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005105 PFTy = PointerType::get(Ty);
5106 }
5107
Reid Spencer21be8652006-10-22 07:03:43 +00005108 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005109 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005110
5111 // Create the call node...
Reid Spencer21be8652006-10-22 07:03:43 +00005112 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer68a24bd2005-08-27 18:50:39 +00005113 // Make sure no arguments is a good thing!
5114 if (Ty->getNumParams() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005115 GEN_ERROR("No arguments passed to a function that "
Reid Spencer68a24bd2005-08-27 18:50:39 +00005116 "expects arguments!");
5117
Reid Spencer21be8652006-10-22 07:03:43 +00005118 (yyval.InstVal) = new CallInst(V, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005119 } else { // Has arguments?
5120 // Loop through FunctionType's arguments and ensure they are specified
5121 // correctly!
5122 //
5123 FunctionType::param_iterator I = Ty->param_begin();
5124 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer21be8652006-10-22 07:03:43 +00005125 std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005126
5127 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5128 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00005129 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005130 (*I)->getDescription() + "'!");
5131
5132 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005133 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005134
Reid Spencer21be8652006-10-22 07:03:43 +00005135 (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005136 }
Reid Spencer21be8652006-10-22 07:03:43 +00005137 cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal));
5138 cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal));
5139 delete (yyvsp[-4].TypeVal);
5140 delete (yyvsp[-1].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00005141 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005142 ;}
5143 break;
5144
Reid Spencer3ed469c2006-11-02 20:25:50 +00005145 case 244:
5146#line 2697 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005147 {
5148 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005149 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005150 ;}
5151 break;
5152
Reid Spencer3ed469c2006-11-02 20:25:50 +00005153 case 245:
5154#line 2704 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005155 {
5156 (yyval.ValueList) = (yyvsp[0].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00005157 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005158 ;}
5159 break;
5160
Reid Spencer3ed469c2006-11-02 20:25:50 +00005161 case 246:
5162#line 2707 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005163 {
5164 (yyval.ValueList) = new std::vector<Value*>();
Reid Spencer61c83e02006-08-18 08:43:06 +00005165 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005166 ;}
5167 break;
5168
Reid Spencer3ed469c2006-11-02 20:25:50 +00005169 case 247:
5170#line 2712 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005171 {
5172 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00005173 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005174 ;}
5175 break;
5176
Reid Spencer3ed469c2006-11-02 20:25:50 +00005177 case 248:
5178#line 2716 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005179 {
5180 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005181 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005182 ;}
5183 break;
5184
Reid Spencer3ed469c2006-11-02 20:25:50 +00005185 case 249:
5186#line 2723 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005187 {
5188 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5189 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005190 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005191 ;}
5192 break;
5193
Reid Spencer3ed469c2006-11-02 20:25:50 +00005194 case 250:
5195#line 2728 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005196 {
5197 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005198 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005199 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5200 delete (yyvsp[-4].TypeVal);
5201 ;}
5202 break;
5203
Reid Spencer3ed469c2006-11-02 20:25:50 +00005204 case 251:
5205#line 2734 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005206 {
5207 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5208 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005209 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005210 ;}
5211 break;
5212
Reid Spencer3ed469c2006-11-02 20:25:50 +00005213 case 252:
5214#line 2739 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005215 {
5216 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005217 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005218 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5219 delete (yyvsp[-4].TypeVal);
5220 ;}
5221 break;
5222
Reid Spencer3ed469c2006-11-02 20:25:50 +00005223 case 253:
5224#line 2745 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005225 {
5226 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005227 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer21be8652006-10-22 07:03:43 +00005228 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
5229 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005230 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005231 ;}
5232 break;
5233
Reid Spencer3ed469c2006-11-02 20:25:50 +00005234 case 254:
5235#line 2753 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005236 {
5237 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005238 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer21be8652006-10-22 07:03:43 +00005239 (*(yyvsp[-1].TypeVal))->getDescription());
5240 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005241 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer21be8652006-10-22 07:03:43 +00005242 (*(yyvsp[-1].TypeVal))->getDescription());
5243 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005244 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005245 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5246 delete (yyvsp[-1].TypeVal);
5247 ;}
5248 break;
5249
Reid Spencer3ed469c2006-11-02 20:25:50 +00005250 case 255:
5251#line 2765 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005252 {
5253 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005254 if (!PT)
Reid Spencer61c83e02006-08-18 08:43:06 +00005255 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer21be8652006-10-22 07:03:43 +00005256 (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005257 const Type *ElTy = PT->getElementType();
Reid Spencer21be8652006-10-22 07:03:43 +00005258 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5259 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005260 "' into space of type '" + ElTy->getDescription() + "'!");
5261
Reid Spencer21be8652006-10-22 07:03:43 +00005262 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005263 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005264 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5265 delete (yyvsp[-1].TypeVal);
5266 ;}
5267 break;
5268
Reid Spencer3ed469c2006-11-02 20:25:50 +00005269 case 256:
5270#line 2780 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005271 {
5272 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005273 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005274
5275 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
5276 // indices to uint struct indices for compatibility.
5277 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer21be8652006-10-22 07:03:43 +00005278 GTI = gep_type_begin((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()),
5279 GTE = gep_type_end((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end());
5280 for (unsigned i = 0, e = (yyvsp[0].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005281 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer21be8652006-10-22 07:03:43 +00005282 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[0].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00005283 if (CUI->getType() == Type::UByteTy)
Reid Spencer21be8652006-10-22 07:03:43 +00005284 (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005285
Reid Spencer21be8652006-10-22 07:03:43 +00005286 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005287 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer21be8652006-10-22 07:03:43 +00005288 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
5289 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005290 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005291 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
5292 delete (yyvsp[-2].TypeVal);
5293 delete (yyvsp[0].ValueList);
5294 ;}
5295 break;
5296
5297
5298 default: break;
5299 }
5300
5301/* Line 1126 of yacc.c. */
Reid Spencer3ed469c2006-11-02 20:25:50 +00005302#line 5303 "llvmAsmParser.tab.c"
Reid Spencer5b7e7532006-09-28 19:28:24 +00005303
5304 yyvsp -= yylen;
5305 yyssp -= yylen;
5306
Reid Spencer21be8652006-10-22 07:03:43 +00005307
5308 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005309
5310 *++yyvsp = yyval;
5311
5312
Reid Spencer21be8652006-10-22 07:03:43 +00005313 /* Now `shift' the result of the reduction. Determine what state
5314 that goes to, based on the state we popped back to and the rule
5315 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005316
5317 yyn = yyr1[yyn];
5318
Reid Spencer21be8652006-10-22 07:03:43 +00005319 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5320 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005321 yystate = yytable[yystate];
5322 else
Reid Spencer21be8652006-10-22 07:03:43 +00005323 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005324
5325 goto yynewstate;
5326
5327
Reid Spencer21be8652006-10-22 07:03:43 +00005328/*------------------------------------.
5329| yyerrlab -- here on detecting error |
5330`------------------------------------*/
5331yyerrlab:
5332 /* If not already recovering from an error, report this error. */
5333 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005334 {
5335 ++yynerrs;
Reid Spencer21be8652006-10-22 07:03:43 +00005336#if YYERROR_VERBOSE
Reid Spencer5b7e7532006-09-28 19:28:24 +00005337 yyn = yypact[yystate];
Chris Lattner224f84f2006-08-18 17:34:45 +00005338
Reid Spencer21be8652006-10-22 07:03:43 +00005339 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencer5b7e7532006-09-28 19:28:24 +00005340 {
Reid Spencer21be8652006-10-22 07:03:43 +00005341 int yytype = YYTRANSLATE (yychar);
5342 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5343 YYSIZE_T yysize = yysize0;
5344 YYSIZE_T yysize1;
5345 int yysize_overflow = 0;
5346 char *yymsg = 0;
5347# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5348 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5349 int yyx;
Reid Spencer5b7e7532006-09-28 19:28:24 +00005350
Reid Spencer21be8652006-10-22 07:03:43 +00005351#if 0
5352 /* This is so xgettext sees the translatable formats that are
5353 constructed on the fly. */
5354 YY_("syntax error, unexpected %s");
5355 YY_("syntax error, unexpected %s, expecting %s");
5356 YY_("syntax error, unexpected %s, expecting %s or %s");
5357 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5358 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5359#endif
5360 char *yyfmt;
5361 char const *yyf;
5362 static char const yyunexpected[] = "syntax error, unexpected %s";
5363 static char const yyexpecting[] = ", expecting %s";
5364 static char const yyor[] = " or %s";
5365 char yyformat[sizeof yyunexpected
5366 + sizeof yyexpecting - 1
5367 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5368 * (sizeof yyor - 1))];
5369 char const *yyprefix = yyexpecting;
5370
5371 /* Start YYX at -YYN if negative to avoid negative indexes in
5372 YYCHECK. */
5373 int yyxbegin = yyn < 0 ? -yyn : 0;
5374
5375 /* Stay within bounds of both yycheck and yytname. */
5376 int yychecklim = YYLAST - yyn;
5377 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5378 int yycount = 1;
5379
5380 yyarg[0] = yytname[yytype];
5381 yyfmt = yystpcpy (yyformat, yyunexpected);
5382
5383 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5384 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5385 {
5386 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5387 {
5388 yycount = 1;
5389 yysize = yysize0;
5390 yyformat[sizeof yyunexpected - 1] = '\0';
5391 break;
5392 }
5393 yyarg[yycount++] = yytname[yyx];
5394 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5395 yysize_overflow |= yysize1 < yysize;
5396 yysize = yysize1;
5397 yyfmt = yystpcpy (yyfmt, yyprefix);
5398 yyprefix = yyor;
5399 }
5400
5401 yyf = YY_(yyformat);
5402 yysize1 = yysize + yystrlen (yyf);
5403 yysize_overflow |= yysize1 < yysize;
5404 yysize = yysize1;
5405
5406 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5407 yymsg = (char *) YYSTACK_ALLOC (yysize);
5408 if (yymsg)
Reid Spencer5b7e7532006-09-28 19:28:24 +00005409 {
Reid Spencer21be8652006-10-22 07:03:43 +00005410 /* Avoid sprintf, as that infringes on the user's name space.
5411 Don't have undefined behavior even if the translation
5412 produced a string with the wrong number of "%s"s. */
5413 char *yyp = yymsg;
5414 int yyi = 0;
5415 while ((*yyp = *yyf))
Reid Spencer5b7e7532006-09-28 19:28:24 +00005416 {
Reid Spencer21be8652006-10-22 07:03:43 +00005417 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5418 {
5419 yyp += yytnamerr (yyp, yyarg[yyi++]);
5420 yyf += 2;
5421 }
5422 else
5423 {
5424 yyp++;
5425 yyf++;
5426 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00005427 }
Reid Spencer21be8652006-10-22 07:03:43 +00005428 yyerror (yymsg);
5429 YYSTACK_FREE (yymsg);
Reid Spencer5b7e7532006-09-28 19:28:24 +00005430 }
5431 else
Reid Spencer21be8652006-10-22 07:03:43 +00005432 {
5433 yyerror (YY_("syntax error"));
5434 goto yyexhaustedlab;
5435 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00005436 }
5437 else
5438#endif /* YYERROR_VERBOSE */
Reid Spencer21be8652006-10-22 07:03:43 +00005439 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005440 }
5441
Reid Spencer21be8652006-10-22 07:03:43 +00005442
Reid Spencer68a24bd2005-08-27 18:50:39 +00005443
5444 if (yyerrstatus == 3)
5445 {
Reid Spencer21be8652006-10-22 07:03:43 +00005446 /* If just tried and failed to reuse look-ahead token after an
5447 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005448
Reid Spencer21be8652006-10-22 07:03:43 +00005449 if (yychar <= YYEOF)
5450 {
5451 /* Return failure if at end of input. */
5452 if (yychar == YYEOF)
5453 YYABORT;
5454 }
5455 else
5456 {
5457 yydestruct ("Error: discarding", yytoken, &yylval);
5458 yychar = YYEMPTY;
5459 }
5460 }
5461
5462 /* Else will try to reuse look-ahead token after shifting the error
5463 token. */
5464 goto yyerrlab1;
5465
5466
5467/*---------------------------------------------------.
5468| yyerrorlab -- error raised explicitly by YYERROR. |
5469`---------------------------------------------------*/
5470yyerrorlab:
5471
5472 /* Pacify compilers like GCC when the user code never invokes
5473 YYERROR and the label yyerrorlab therefore never appears in user
5474 code. */
5475 if (0)
5476 goto yyerrorlab;
5477
5478yyvsp -= yylen;
5479 yyssp -= yylen;
5480 yystate = *yyssp;
5481 goto yyerrlab1;
5482
5483
5484/*-------------------------------------------------------------.
5485| yyerrlab1 -- common code for both syntax error and YYERROR. |
5486`-------------------------------------------------------------*/
5487yyerrlab1:
5488 yyerrstatus = 3; /* Each real token shifted decrements this. */
5489
5490 for (;;)
5491 {
5492 yyn = yypact[yystate];
5493 if (yyn != YYPACT_NINF)
5494 {
5495 yyn += YYTERROR;
5496 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5497 {
5498 yyn = yytable[yyn];
5499 if (0 < yyn)
5500 break;
5501 }
5502 }
5503
5504 /* Pop the current state because it cannot handle the error token. */
5505 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005506 YYABORT;
5507
Chris Lattner8335e842006-01-23 23:05:42 +00005508
Reid Spencer21be8652006-10-22 07:03:43 +00005509 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5510 YYPOPSTACK;
5511 yystate = *yyssp;
5512 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005513 }
5514
5515 if (yyn == YYFINAL)
5516 YYACCEPT;
5517
Reid Spencer68a24bd2005-08-27 18:50:39 +00005518 *++yyvsp = yylval;
Reid Spencer21be8652006-10-22 07:03:43 +00005519
5520
5521 /* Shift the error token. */
5522 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005523
5524 yystate = yyn;
5525 goto yynewstate;
5526
Chris Lattner1ae022f2006-10-22 06:08:13 +00005527
Reid Spencer21be8652006-10-22 07:03:43 +00005528/*-------------------------------------.
5529| yyacceptlab -- YYACCEPT comes here. |
5530`-------------------------------------*/
5531yyacceptlab:
5532 yyresult = 0;
5533 goto yyreturn;
5534
5535/*-----------------------------------.
5536| yyabortlab -- YYABORT comes here. |
5537`-----------------------------------*/
5538yyabortlab:
5539 yyresult = 1;
5540 goto yyreturn;
5541
5542#ifndef yyoverflow
5543/*-------------------------------------------------.
5544| yyexhaustedlab -- memory exhaustion comes here. |
5545`-------------------------------------------------*/
5546yyexhaustedlab:
5547 yyerror (YY_("memory exhausted"));
5548 yyresult = 2;
5549 /* Fall through. */
Chris Lattner1ae022f2006-10-22 06:08:13 +00005550#endif
Reid Spencer21be8652006-10-22 07:03:43 +00005551
5552yyreturn:
5553 if (yychar != YYEOF && yychar != YYEMPTY)
5554 yydestruct ("Cleanup: discarding lookahead",
5555 yytoken, &yylval);
5556 while (yyssp != yyss)
5557 {
5558 yydestruct ("Cleanup: popping",
5559 yystos[*yyssp], yyvsp);
5560 YYPOPSTACK;
Chris Lattner1ae022f2006-10-22 06:08:13 +00005561 }
Reid Spencer21be8652006-10-22 07:03:43 +00005562#ifndef yyoverflow
5563 if (yyss != yyssa)
5564 YYSTACK_FREE (yyss);
5565#endif
5566 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005567}
Reid Spencer21be8652006-10-22 07:03:43 +00005568
5569
Reid Spencer3ed469c2006-11-02 20:25:50 +00005570#line 2806 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005571
5572
5573void llvm::GenerateError(const std::string &message, int LineNo) {
5574 if (LineNo == -1) LineNo = llvmAsmlineno;
5575 // TODO: column number in exception
5576 if (TheParseError)
5577 TheParseError->setError(CurFilename, message, LineNo);
5578 TriggerError = 1;
5579}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005580
5581int yyerror(const char *ErrorMsg) {
5582 std::string where
5583 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5584 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5585 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5586 if (yychar == YYEMPTY || yychar == 0)
5587 errMsg += "end-of-file.";
5588 else
5589 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005590 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005591 return 0;
5592}
Reid Spencer21be8652006-10-22 07:03:43 +00005593