blob: 6837528d6c7de43f4f211cc845014f194c91b048 [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,
148 REM = 339,
149 AND = 340,
150 OR = 341,
151 XOR = 342,
152 SETLE = 343,
153 SETGE = 344,
154 SETLT = 345,
155 SETGT = 346,
156 SETEQ = 347,
157 SETNE = 348,
158 MALLOC = 349,
159 ALLOCA = 350,
160 FREE = 351,
161 LOAD = 352,
162 STORE = 353,
163 GETELEMENTPTR = 354,
164 PHI_TOK = 355,
165 CAST = 356,
166 SELECT = 357,
167 SHL = 358,
168 SHR = 359,
169 VAARG = 360,
170 EXTRACTELEMENT = 361,
171 INSERTELEMENT = 362,
172 SHUFFLEVECTOR = 363,
173 VAARG_old = 364,
174 VANEXT_old = 365
Reid Spencer21be8652006-10-22 07:03:43 +0000175 };
176#endif
177/* Tokens. */
178#define ESINT64VAL 258
179#define EUINT64VAL 259
180#define SINTVAL 260
181#define UINTVAL 261
182#define FPVAL 262
183#define VOID 263
184#define BOOL 264
185#define SBYTE 265
186#define UBYTE 266
187#define SHORT 267
188#define USHORT 268
189#define INT 269
190#define UINT 270
191#define LONG 271
192#define ULONG 272
193#define FLOAT 273
194#define DOUBLE 274
195#define TYPE 275
196#define LABEL 276
197#define VAR_ID 277
198#define LABELSTR 278
199#define STRINGCONSTANT 279
200#define IMPLEMENTATION 280
201#define ZEROINITIALIZER 281
202#define TRUETOK 282
203#define FALSETOK 283
204#define BEGINTOK 284
205#define ENDTOK 285
206#define DECLARE 286
207#define GLOBAL 287
208#define CONSTANT 288
209#define SECTION 289
210#define VOLATILE 290
211#define TO 291
212#define DOTDOTDOT 292
213#define NULL_TOK 293
214#define UNDEF 294
215#define CONST 295
216#define INTERNAL 296
217#define LINKONCE 297
218#define WEAK 298
219#define APPENDING 299
220#define DLLIMPORT 300
221#define DLLEXPORT 301
222#define EXTERN_WEAK 302
223#define OPAQUE 303
224#define NOT 304
225#define EXTERNAL 305
226#define TARGET 306
227#define TRIPLE 307
228#define ENDIAN 308
229#define POINTERSIZE 309
230#define LITTLE 310
231#define BIG 311
232#define ALIGN 312
233#define DEPLIBS 313
234#define CALL 314
235#define TAIL 315
236#define ASM_TOK 316
237#define MODULE 317
238#define SIDEEFFECT 318
239#define CC_TOK 319
240#define CCC_TOK 320
241#define CSRETCC_TOK 321
242#define FASTCC_TOK 322
243#define COLDCC_TOK 323
244#define X86_STDCALLCC_TOK 324
245#define X86_FASTCALLCC_TOK 325
246#define DATALAYOUT 326
247#define RET 327
248#define BR 328
249#define SWITCH 329
250#define INVOKE 330
251#define UNWIND 331
252#define UNREACHABLE 332
253#define ADD 333
254#define SUB 334
255#define MUL 335
Reid Spencer1628cec2006-10-26 06:15:43 +0000256#define UDIV 336
257#define SDIV 337
258#define FDIV 338
259#define REM 339
260#define AND 340
261#define OR 341
262#define XOR 342
263#define SETLE 343
264#define SETGE 344
265#define SETLT 345
266#define SETGT 346
267#define SETEQ 347
268#define SETNE 348
269#define MALLOC 349
270#define ALLOCA 350
271#define FREE 351
272#define LOAD 352
273#define STORE 353
274#define GETELEMENTPTR 354
275#define PHI_TOK 355
276#define CAST 356
277#define SELECT 357
278#define SHL 358
279#define SHR 359
280#define VAARG 360
281#define EXTRACTELEMENT 361
282#define INSERTELEMENT 362
283#define SHUFFLEVECTOR 363
284#define VAARG_old 364
285#define VANEXT_old 365
Reid Spencer21be8652006-10-22 07:03:43 +0000286
287
288
289
290/* Copy the first part of user declarations. */
Reid Spencer1628cec2006-10-26 06:15:43 +0000291#line 14 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000292
293#include "ParserInternals.h"
294#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000295#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000296#include "llvm/Instructions.h"
297#include "llvm/Module.h"
298#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000299#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000300#include "llvm/Support/GetElementPtrTypeIterator.h"
301#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000302#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000303#include <algorithm>
304#include <iostream>
305#include <list>
306#include <utility>
307
Reid Spencere4f47592006-08-18 17:32:55 +0000308// The following is a gross hack. In order to rid the libAsmParser library of
309// exceptions, we have to have a way of getting the yyparse function to go into
310// an error situation. So, whenever we want an error to occur, the GenerateError
311// function (see bottom of file) sets TriggerError. Then, at the end of each
312// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
313// (a goto) to put YACC in error state. Furthermore, several calls to
314// GenerateError are made from inside productions and they must simulate the
315// previous exception behavior by exiting the production immediately. We have
316// replaced these with the GEN_ERROR macro which calls GeneratError and then
317// immediately invokes YYERROR. This would be so much cleaner if it was a
318// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000319static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000320#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000321#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
322
Reid Spencer68a24bd2005-08-27 18:50:39 +0000323int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
324int yylex(); // declaration" of xxx warnings.
325int yyparse();
326
327namespace llvm {
328 std::string CurFilename;
329}
330using namespace llvm;
331
332static Module *ParserResult;
333
334// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
335// relating to upreferences in the input stream.
336//
337//#define DEBUG_UPREFS 1
338#ifdef DEBUG_UPREFS
339#define UR_OUT(X) std::cerr << X
340#else
341#define UR_OUT(X)
342#endif
343
344#define YYERROR_VERBOSE 1
345
346static bool ObsoleteVarArgs;
347static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000348static BasicBlock *CurBB;
349static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000350
351
352// This contains info used when building the body of a function. It is
353// destroyed when the function is completed.
354//
355typedef std::vector<Value *> ValueList; // Numbered defs
356static void
357ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
358 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
359
360static struct PerModuleInfo {
361 Module *CurrentModule;
362 std::map<const Type *, ValueList> Values; // Module level numbered definitions
363 std::map<const Type *,ValueList> LateResolveValues;
364 std::vector<PATypeHolder> Types;
365 std::map<ValID, PATypeHolder> LateResolveTypes;
366
367 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000368 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000369 /// that we can resolve them later and print error messages as appropriate.
370 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
371
372 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
373 // references to global values. Global values may be referenced before they
374 // are defined, and if so, the temporary object that they represent is held
375 // here. This is used for forward references of GlobalValues.
376 //
377 typedef std::map<std::pair<const PointerType *,
378 ValID>, GlobalValue*> GlobalRefsType;
379 GlobalRefsType GlobalRefs;
380
381 void ModuleDone() {
382 // If we could not resolve some functions at function compilation time
383 // (calls to functions before they are defined), resolve them now... Types
384 // are resolved when the constant pool has been completely parsed.
385 //
386 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000387 if (TriggerError)
388 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000389
390 // Check to make sure that all global value forward references have been
391 // resolved!
392 //
393 if (!GlobalRefs.empty()) {
394 std::string UndefinedReferences = "Unresolved global references exist:\n";
395
396 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
397 I != E; ++I) {
398 UndefinedReferences += " " + I->first.first->getDescription() + " " +
399 I->first.second.getName() + "\n";
400 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000401 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000402 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000403 }
404
Reid Spencere812fb22006-01-19 01:21:04 +0000405 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattnerd5efe842006-04-08 01:18:56 +0000406 for (Module::iterator FI = CurrentModule->begin(),
407 FE = CurrentModule->end(); FI != FE; )
Chris Lattnerc2c60382006-03-04 07:53:41 +0000408 UpgradeCallsToIntrinsic(FI++);
Reid Spencer0b118202006-01-16 21:12:35 +0000409
Reid Spencer68a24bd2005-08-27 18:50:39 +0000410 Values.clear(); // Clear out function local definitions
411 Types.clear();
412 CurrentModule = 0;
413 }
414
Reid Spencer68a24bd2005-08-27 18:50:39 +0000415 // GetForwardRefForGlobal - Check to see if there is a forward reference
416 // for this global. If so, remove it from the GlobalRefs map and return it.
417 // If not, just return null.
418 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
419 // Check to see if there is a forward reference to this global variable...
420 // if there is, eliminate it and patch the reference to use the new def'n.
421 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
422 GlobalValue *Ret = 0;
423 if (I != GlobalRefs.end()) {
424 Ret = I->second;
425 GlobalRefs.erase(I);
426 }
427 return Ret;
428 }
429} CurModule;
430
431static struct PerFunctionInfo {
432 Function *CurrentFunction; // Pointer to current function being created
433
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000434 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000435 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000436 bool isDeclare; // Is this function a forward declararation?
437 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000438
439 /// BBForwardRefs - When we see forward references to basic blocks, keep
440 /// track of them here.
441 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
442 std::vector<BasicBlock*> NumberedBlocks;
443 unsigned NextBBNum;
444
445 inline PerFunctionInfo() {
446 CurrentFunction = 0;
447 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000448 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000449 }
450
451 inline void FunctionStart(Function *M) {
452 CurrentFunction = M;
453 NextBBNum = 0;
454 }
455
456 void FunctionDone() {
457 NumberedBlocks.clear();
458
459 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000460 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000461 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000462 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000463 return;
464 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000465
466 // Resolve all forward references now.
467 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
468
469 Values.clear(); // Clear out function local definitions
470 CurrentFunction = 0;
471 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000472 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000473 }
474} CurFun; // Info for the current function...
475
476static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
477
478
479//===----------------------------------------------------------------------===//
480// Code to handle definitions of all the types
481//===----------------------------------------------------------------------===//
482
483static int InsertValue(Value *V,
484 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
485 if (V->hasName()) return -1; // Is this a numbered definition?
486
487 // Yes, insert the value into the value table...
488 ValueList &List = ValueTab[V->getType()];
489 List.push_back(V);
490 return List.size()-1;
491}
492
493static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
494 switch (D.Type) {
495 case ValID::NumberVal: // Is it a numbered definition?
496 // Module constants occupy the lowest numbered slots...
497 if ((unsigned)D.Num < CurModule.Types.size())
498 return CurModule.Types[(unsigned)D.Num];
499 break;
500 case ValID::NameVal: // Is it a named definition?
501 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
502 D.destroy(); // Free old strdup'd memory...
503 return N;
504 }
505 break;
506 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000507 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000508 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000509 }
510
511 // If we reached here, we referenced either a symbol that we don't know about
512 // or an id number that hasn't been read yet. We may be referencing something
513 // forward, so just create an entry to be resolved later and get to it...
514 //
515 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
516
517
518 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000519 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000520 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000521 return 0;
522 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000523 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000524 return 0;
525 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000526 }
527
528 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
529 if (I != CurModule.LateResolveTypes.end())
530 return I->second;
531
532 Type *Typ = OpaqueType::get();
533 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
534 return Typ;
535 }
536
537static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
538 SymbolTable &SymTab =
539 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
540 CurModule.CurrentModule->getSymbolTable();
541 return SymTab.lookup(Ty, Name);
542}
543
544// getValNonImprovising - Look up the value specified by the provided type and
545// the provided ValID. If the value exists and has already been defined, return
546// it. Otherwise return null.
547//
548static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000549 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000550 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000551 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000552 return 0;
553 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000554
555 switch (D.Type) {
556 case ValID::NumberVal: { // Is it a numbered definition?
557 unsigned Num = (unsigned)D.Num;
558
559 // Module constants occupy the lowest numbered slots...
560 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
561 if (VI != CurModule.Values.end()) {
562 if (Num < VI->second.size())
563 return VI->second[Num];
564 Num -= VI->second.size();
565 }
566
567 // Make sure that our type is within bounds
568 VI = CurFun.Values.find(Ty);
569 if (VI == CurFun.Values.end()) return 0;
570
571 // Check that the number is within bounds...
572 if (VI->second.size() <= Num) return 0;
573
574 return VI->second[Num];
575 }
576
577 case ValID::NameVal: { // Is it a named definition?
578 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
579 if (N == 0) return 0;
580
581 D.destroy(); // Free old strdup'd memory...
582 return N;
583 }
584
585 // Check to make sure that "Ty" is an integral type, and that our
586 // value will fit into the specified type...
587 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000588 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000589 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000590 itostr(D.ConstPool64) + "' is invalid for type '" +
591 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000592 return 0;
593 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000594 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000595
596 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000597 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
598 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000599 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000600 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000601 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000602 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000603 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000604 }
605 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000606 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000607 }
608
609 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000610 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000611 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000612 return 0;
613 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000614 return ConstantFP::get(Ty, D.ConstPoolFP);
615
616 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000617 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000618 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000619 return 0;
620 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000621 return ConstantPointerNull::get(cast<PointerType>(Ty));
622
623 case ValID::ConstUndefVal: // Is it an undef value?
624 return UndefValue::get(Ty);
625
Chris Lattner7aa61892005-12-21 17:53:23 +0000626 case ValID::ConstZeroVal: // Is it a zero value?
627 return Constant::getNullValue(Ty);
628
Reid Spencer68a24bd2005-08-27 18:50:39 +0000629 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000630 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000631 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000632 return 0;
633 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000634 return D.ConstantValue;
635
Chris Lattner0e9c3762006-01-25 22:27:16 +0000636 case ValID::InlineAsmVal: { // Inline asm expression
637 const PointerType *PTy = dyn_cast<PointerType>(Ty);
638 const FunctionType *FTy =
639 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000640 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000641 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000642 return 0;
643 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000644 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
645 D.IAD->HasSideEffects);
646 D.destroy(); // Free InlineAsmDescriptor.
647 return IA;
648 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000649 default:
650 assert(0 && "Unhandled case!");
651 return 0;
652 } // End of switch
653
654 assert(0 && "Unhandled case!");
655 return 0;
656}
657
658// getVal - This function is identical to getValNonImprovising, except that if a
659// value is not already defined, it "improvises" by creating a placeholder var
660// that looks and acts just like the requested variable. When the value is
661// defined later, all uses of the placeholder variable are replaced with the
662// real thing.
663//
664static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000665 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000666 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000667 return 0;
668 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000669
670 // See if the value has already been defined.
671 Value *V = getValNonImprovising(Ty, ID);
672 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000673 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000674
Reid Spencer5b7e7532006-09-28 19:28:24 +0000675 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000676 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000677 return 0;
678 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000679
680 // If we reached here, we referenced either a symbol that we don't know about
681 // or an id number that hasn't been read yet. We may be referencing something
682 // forward, so just create an entry to be resolved later and get to it...
683 //
684 V = new Argument(Ty);
685
686 // Remember where this forward reference came from. FIXME, shouldn't we try
687 // to recycle these things??
688 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
689 llvmAsmlineno)));
690
691 if (inFunctionScope())
692 InsertValue(V, CurFun.LateResolveValues);
693 else
694 InsertValue(V, CurModule.LateResolveValues);
695 return V;
696}
697
698/// getBBVal - This is used for two purposes:
699/// * If isDefinition is true, a new basic block with the specified ID is being
700/// defined.
701/// * If isDefinition is true, this is a reference to a basic block, which may
702/// or may not be a forward reference.
703///
704static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
705 assert(inFunctionScope() && "Can't get basic block at global scope!");
706
707 std::string Name;
708 BasicBlock *BB = 0;
709 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000710 default:
711 GenerateError("Illegal label reference " + ID.getName());
712 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000713 case ValID::NumberVal: // Is it a numbered definition?
714 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
715 CurFun.NumberedBlocks.resize(ID.Num+1);
716 BB = CurFun.NumberedBlocks[ID.Num];
717 break;
718 case ValID::NameVal: // Is it a named definition?
719 Name = ID.Name;
720 if (Value *N = CurFun.CurrentFunction->
721 getSymbolTable().lookup(Type::LabelTy, Name))
722 BB = cast<BasicBlock>(N);
723 break;
724 }
725
726 // See if the block has already been defined.
727 if (BB) {
728 // If this is the definition of the block, make sure the existing value was
729 // just a forward reference. If it was a forward reference, there will be
730 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000731 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000732 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000733 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000734 return 0;
735 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000736
737 ID.destroy(); // Free strdup'd memory.
738 return BB;
739 }
740
741 // Otherwise this block has not been seen before.
742 BB = new BasicBlock("", CurFun.CurrentFunction);
743 if (ID.Type == ValID::NameVal) {
744 BB->setName(ID.Name);
745 } else {
746 CurFun.NumberedBlocks[ID.Num] = BB;
747 }
748
749 // If this is not a definition, keep track of it so we can use it as a forward
750 // reference.
751 if (!isDefinition) {
752 // Remember where this forward reference came from.
753 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
754 } else {
755 // The forward declaration could have been inserted anywhere in the
756 // function: insert it into the correct place now.
757 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
758 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
759 }
760 ID.destroy();
761 return BB;
762}
763
764
765//===----------------------------------------------------------------------===//
766// Code to handle forward references in instructions
767//===----------------------------------------------------------------------===//
768//
769// This code handles the late binding needed with statements that reference
770// values not defined yet... for example, a forward branch, or the PHI node for
771// a loop body.
772//
773// This keeps a table (CurFun.LateResolveValues) of all such forward references
774// and back patchs after we are done.
775//
776
777// ResolveDefinitions - If we could not resolve some defs at parsing
778// time (forward branches, phi functions for loops, etc...) resolve the
779// defs now...
780//
781static void
782ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
783 std::map<const Type*,ValueList> *FutureLateResolvers) {
784 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
785 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
786 E = LateResolvers.end(); LRI != E; ++LRI) {
787 ValueList &List = LRI->second;
788 while (!List.empty()) {
789 Value *V = List.back();
790 List.pop_back();
791
792 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
793 CurModule.PlaceHolderInfo.find(V);
794 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
795
796 ValID &DID = PHI->second.first;
797
798 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000799 if (TriggerError)
800 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000801 if (TheRealValue) {
802 V->replaceAllUsesWith(TheRealValue);
803 delete V;
804 CurModule.PlaceHolderInfo.erase(PHI);
805 } else if (FutureLateResolvers) {
806 // Functions have their unresolved items forwarded to the module late
807 // resolver table
808 InsertValue(V, *FutureLateResolvers);
809 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000810 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000811 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000812 "' of type '" + V->getType()->getDescription() + "'",
813 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000814 return;
815 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000816 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000817 itostr(DID.Num) + " of type '" +
818 V->getType()->getDescription() + "'",
819 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000820 return;
821 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000822 }
823 }
824 }
825
826 LateResolvers.clear();
827}
828
829// ResolveTypeTo - A brand new type was just declared. This means that (if
830// name is not null) things referencing Name can be resolved. Otherwise, things
831// refering to the number can be resolved. Do this now.
832//
833static void ResolveTypeTo(char *Name, const Type *ToTy) {
834 ValID D;
835 if (Name) D = ValID::create(Name);
836 else D = ValID::create((int)CurModule.Types.size());
837
838 std::map<ValID, PATypeHolder>::iterator I =
839 CurModule.LateResolveTypes.find(D);
840 if (I != CurModule.LateResolveTypes.end()) {
841 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
842 CurModule.LateResolveTypes.erase(I);
843 }
844}
845
846// setValueName - Set the specified value to the name given. The name may be
847// null potentially, in which case this is a noop. The string passed in is
848// assumed to be a malloc'd string buffer, and is free'd by this function.
849//
850static void setValueName(Value *V, char *NameStr) {
851 if (NameStr) {
852 std::string Name(NameStr); // Copy string
853 free(NameStr); // Free old string
854
Reid Spencer5b7e7532006-09-28 19:28:24 +0000855 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000856 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000857 return;
858 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000859
860 assert(inFunctionScope() && "Must be in function scope!");
861 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000862 if (ST.lookup(V->getType(), Name)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000863 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000864 V->getType()->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000865 return;
866 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000867
868 // Set the name.
869 V->setName(Name);
870 }
871}
872
873/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
874/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000875static GlobalVariable *
876ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
877 bool isConstantGlobal, const Type *Ty,
878 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000879 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000880 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000881 return 0;
882 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000883
884 const PointerType *PTy = PointerType::get(Ty);
885
886 std::string Name;
887 if (NameStr) {
888 Name = NameStr; // Copy string
889 free(NameStr); // Free old string
890 }
891
892 // See if this global value was forward referenced. If so, recycle the
893 // object.
894 ValID ID;
895 if (!Name.empty()) {
896 ID = ValID::create((char*)Name.c_str());
897 } else {
898 ID = ValID::create((int)CurModule.Values[PTy].size());
899 }
900
901 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
902 // Move the global to the end of the list, from whereever it was
903 // previously inserted.
904 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
905 CurModule.CurrentModule->getGlobalList().remove(GV);
906 CurModule.CurrentModule->getGlobalList().push_back(GV);
907 GV->setInitializer(Initializer);
908 GV->setLinkage(Linkage);
909 GV->setConstant(isConstantGlobal);
910 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000911 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000912 }
913
914 // If this global has a name, check to see if there is already a definition
915 // of this global in the module. If so, merge as appropriate. Note that
916 // this is really just a hack around problems in the CFE. :(
917 if (!Name.empty()) {
918 // We are a simple redefinition of a value, check to see if it is defined
919 // the same as the old one.
920 if (GlobalVariable *EGV =
921 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
922 // We are allowed to redefine a global variable in two circumstances:
923 // 1. If at least one of the globals is uninitialized or
924 // 2. If both initializers have the same value.
925 //
926 if (!EGV->hasInitializer() || !Initializer ||
927 EGV->getInitializer() == Initializer) {
928
929 // Make sure the existing global version gets the initializer! Make
930 // sure that it also gets marked const if the new version is.
931 if (Initializer && !EGV->hasInitializer())
932 EGV->setInitializer(Initializer);
933 if (isConstantGlobal)
934 EGV->setConstant(true);
935 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000936 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000937 }
938
Reid Spencer61c83e02006-08-18 08:43:06 +0000939 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000940 "' in the '" + Ty->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000941 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000942 }
943 }
944
945 // Otherwise there is no existing GV to use, create one now.
946 GlobalVariable *GV =
947 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
948 CurModule.CurrentModule);
949 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000950 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000951}
952
953// setTypeName - Set the specified type to the name given. The name may be
954// null potentially, in which case this is a noop. The string passed in is
955// assumed to be a malloc'd string buffer, and is freed by this function.
956//
957// This function returns true if the type has already been defined, but is
958// allowed to be redefined in the specified context. If the name is a new name
959// for the type plane, it is inserted and false is returned.
960static bool setTypeName(const Type *T, char *NameStr) {
961 assert(!inFunctionScope() && "Can't give types function-local names!");
962 if (NameStr == 0) return false;
963
964 std::string Name(NameStr); // Copy string
965 free(NameStr); // Free old string
966
967 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000968 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000969 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000970 return false;
971 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000972
973 // Set the type name, checking for conflicts as we do so.
974 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
975
976 if (AlreadyExists) { // Inserting a name that is already defined???
977 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
978 assert(Existing && "Conflict but no matching type?");
979
980 // There is only one case where this is allowed: when we are refining an
981 // opaque type. In this case, Existing will be an opaque type.
982 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
983 // We ARE replacing an opaque type!
984 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
985 return true;
986 }
987
988 // Otherwise, this is an attempt to redefine a type. That's okay if
989 // the redefinition is identical to the original. This will be so if
990 // Existing and T point to the same Type object. In this one case we
991 // allow the equivalent redefinition.
992 if (Existing == T) return true; // Yes, it's equal.
993
994 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer61c83e02006-08-18 08:43:06 +0000995 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000996 T->getDescription() + "' type plane!");
997 }
998
999 return false;
1000}
1001
1002//===----------------------------------------------------------------------===//
1003// Code for handling upreferences in type names...
1004//
1005
1006// TypeContains - Returns true if Ty directly contains E in it.
1007//
1008static bool TypeContains(const Type *Ty, const Type *E) {
1009 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
1010 E) != Ty->subtype_end();
1011}
1012
1013namespace {
1014 struct UpRefRecord {
1015 // NestingLevel - The number of nesting levels that need to be popped before
1016 // this type is resolved.
1017 unsigned NestingLevel;
1018
1019 // LastContainedTy - This is the type at the current binding level for the
1020 // type. Every time we reduce the nesting level, this gets updated.
1021 const Type *LastContainedTy;
1022
1023 // UpRefTy - This is the actual opaque type that the upreference is
1024 // represented with.
1025 OpaqueType *UpRefTy;
1026
1027 UpRefRecord(unsigned NL, OpaqueType *URTy)
1028 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1029 };
1030}
1031
1032// UpRefs - A list of the outstanding upreferences that need to be resolved.
1033static std::vector<UpRefRecord> UpRefs;
1034
1035/// HandleUpRefs - Every time we finish a new layer of types, this function is
1036/// called. It loops through the UpRefs vector, which is a list of the
1037/// currently active types. For each type, if the up reference is contained in
1038/// the newly completed type, we decrement the level count. When the level
1039/// count reaches zero, the upreferenced type is the type that is passed in:
1040/// thus we can complete the cycle.
1041///
1042static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +00001043 // If Ty isn't abstract, or if there are no up-references in it, then there is
1044 // nothing to resolve here.
1045 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1046
Reid Spencer68a24bd2005-08-27 18:50:39 +00001047 PATypeHolder Ty(ty);
1048 UR_OUT("Type '" << Ty->getDescription() <<
1049 "' newly formed. Resolving upreferences.\n" <<
1050 UpRefs.size() << " upreferences active!\n");
1051
1052 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1053 // to zero), we resolve them all together before we resolve them to Ty. At
1054 // the end of the loop, if there is anything to resolve to Ty, it will be in
1055 // this variable.
1056 OpaqueType *TypeToResolve = 0;
1057
1058 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1059 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1060 << UpRefs[i].second->getDescription() << ") = "
1061 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1062 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1063 // Decrement level of upreference
1064 unsigned Level = --UpRefs[i].NestingLevel;
1065 UpRefs[i].LastContainedTy = Ty;
1066 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1067 if (Level == 0) { // Upreference should be resolved!
1068 if (!TypeToResolve) {
1069 TypeToResolve = UpRefs[i].UpRefTy;
1070 } else {
1071 UR_OUT(" * Resolving upreference for "
1072 << UpRefs[i].second->getDescription() << "\n";
1073 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1074 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1075 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1076 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1077 }
1078 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1079 --i; // Do not skip the next element...
1080 }
1081 }
1082 }
1083
1084 if (TypeToResolve) {
1085 UR_OUT(" * Resolving upreference for "
1086 << UpRefs[i].second->getDescription() << "\n";
1087 std::string OldName = TypeToResolve->getDescription());
1088 TypeToResolve->refineAbstractTypeTo(Ty);
1089 }
1090
1091 return Ty;
1092}
1093
Reid Spencer1628cec2006-10-26 06:15:43 +00001094/// This function is used to obtain the correct opcode for an instruction when
1095/// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both
1096/// an opcode and an "obsolete" flag. These are generated by the lexer and
1097/// the "obsolete" member will be true when the lexer encounters the token for
1098/// an obsolete opcode. For example, "div" was replaced by [usf]div but we need
1099/// to maintain backwards compatibility for asm files that still have the "div"
1100/// instruction. This function handles converting div -> [usf]div appropriately.
1101/// @brief Convert obsolete opcodes to new values
1102static void
1103sanitizeOpCode(OpcodeInfo<Instruction::BinaryOps> &OI, const PATypeHolder& PATy)
1104{
1105 // If its not obsolete, don't do anything
1106 if (!OI.obsolete)
1107 return;
1108
1109 // If its a packed type we want to use the element type
1110 const Type* Ty = PATy;
1111 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
1112 Ty = PTy->getElementType();
1113
1114 // Depending on the opcode ..
1115 switch (OI.opcode) {
1116 default:
1117 GenerateError("Invalid Obsolete OpCode");
1118 break;
1119 case Instruction::UDiv:
1120 // Handle cases where the opcode needs to change
1121 if (Ty->isFloatingPoint())
1122 OI.opcode = Instruction::FDiv;
1123 else if (Ty->isSigned())
1124 OI.opcode = Instruction::SDiv;
1125 break;
1126 }
1127 // Its not obsolete any more, we fixed it.
1128 OI.obsolete = false;
1129}
1130
Reid Spencer68a24bd2005-08-27 18:50:39 +00001131
1132// common code from the two 'RunVMAsmParser' functions
Reid Spencer5b7e7532006-09-28 19:28:24 +00001133static Module* RunParser(Module * M) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001134
1135 llvmAsmlineno = 1; // Reset the current line number...
1136 ObsoleteVarArgs = false;
1137 NewVarArgs = false;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001138 CurModule.CurrentModule = M;
Reid Spencerf63697d2006-10-09 17:36:59 +00001139
1140 // Check to make sure the parser succeeded
1141 if (yyparse()) {
1142 if (ParserResult)
1143 delete ParserResult;
1144 return 0;
1145 }
1146
1147 // Check to make sure that parsing produced a result
Reid Spencer61c83e02006-08-18 08:43:06 +00001148 if (!ParserResult)
1149 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +00001150
Reid Spencerf63697d2006-10-09 17:36:59 +00001151 // Reset ParserResult variable while saving its value for the result.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001152 Module *Result = ParserResult;
1153 ParserResult = 0;
1154
1155 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
1156 {
1157 Function* F;
1158 if ((F = Result->getNamedFunction("llvm.va_start"))
1159 && F->getFunctionType()->getNumParams() == 0)
1160 ObsoleteVarArgs = true;
1161 if((F = Result->getNamedFunction("llvm.va_copy"))
1162 && F->getFunctionType()->getNumParams() == 1)
1163 ObsoleteVarArgs = true;
1164 }
1165
Reid Spencer5b7e7532006-09-28 19:28:24 +00001166 if (ObsoleteVarArgs && NewVarArgs) {
1167 GenerateError(
1168 "This file is corrupt: it uses both new and old style varargs");
1169 return 0;
1170 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001171
1172 if(ObsoleteVarArgs) {
1173 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001174 if (F->arg_size() != 0) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001175 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001176 return 0;
1177 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001178
1179 //foo = va_start()
1180 // ->
1181 //bar = alloca typeof(foo)
1182 //va_start(bar)
1183 //foo = load bar
1184
1185 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1186 const Type* ArgTy = F->getFunctionType()->getReturnType();
1187 const Type* ArgTyPtr = PointerType::get(ArgTy);
1188 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001189 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001190
1191 while (!F->use_empty()) {
1192 CallInst* CI = cast<CallInst>(F->use_back());
1193 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1194 new CallInst(NF, bar, "", CI);
1195 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1196 CI->replaceAllUsesWith(foo);
1197 CI->getParent()->getInstList().erase(CI);
1198 }
1199 Result->getFunctionList().erase(F);
1200 }
1201
1202 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001203 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001204 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001205 return 0;
1206 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001207
1208 //vaend foo
1209 // ->
1210 //bar = alloca 1 of typeof(foo)
1211 //vaend bar
1212 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1213 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1214 const Type* ArgTyPtr = PointerType::get(ArgTy);
1215 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001216 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001217
1218 while (!F->use_empty()) {
1219 CallInst* CI = cast<CallInst>(F->use_back());
1220 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1221 new StoreInst(CI->getOperand(1), bar, CI);
1222 new CallInst(NF, bar, "", CI);
1223 CI->getParent()->getInstList().erase(CI);
1224 }
1225 Result->getFunctionList().erase(F);
1226 }
1227
1228 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001229 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001230 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001231 return 0;
1232 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001233 //foo = vacopy(bar)
1234 // ->
1235 //a = alloca 1 of typeof(foo)
1236 //b = alloca 1 of typeof(foo)
1237 //store bar -> b
1238 //vacopy(a, b)
1239 //foo = load a
1240
1241 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1242 const Type* ArgTy = F->getFunctionType()->getReturnType();
1243 const Type* ArgTyPtr = PointerType::get(ArgTy);
1244 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001245 RetTy, ArgTyPtr, ArgTyPtr,
1246 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001247
1248 while (!F->use_empty()) {
1249 CallInst* CI = cast<CallInst>(F->use_back());
1250 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1251 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1252 new StoreInst(CI->getOperand(1), b, CI);
1253 new CallInst(NF, a, b, "", CI);
1254 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1255 CI->replaceAllUsesWith(foo);
1256 CI->getParent()->getInstList().erase(CI);
1257 }
1258 Result->getFunctionList().erase(F);
1259 }
1260 }
1261
1262 return Result;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001263}
Reid Spencer68a24bd2005-08-27 18:50:39 +00001264
1265//===----------------------------------------------------------------------===//
1266// RunVMAsmParser - Define an interface to this parser
1267//===----------------------------------------------------------------------===//
1268//
1269Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1270 set_scan_file(F);
1271
1272 CurFilename = Filename;
1273 return RunParser(new Module(CurFilename));
1274}
1275
1276Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1277 set_scan_string(AsmString);
1278
1279 CurFilename = "from_memory";
1280 if (M == NULL) {
1281 return RunParser(new Module (CurFilename));
1282 } else {
1283 return RunParser(M);
1284 }
1285}
1286
1287
Reid Spencer21be8652006-10-22 07:03:43 +00001288
1289/* Enabling traces. */
1290#ifndef YYDEBUG
1291# define YYDEBUG 0
1292#endif
1293
1294/* Enabling verbose error messages. */
1295#ifdef YYERROR_VERBOSE
1296# undef YYERROR_VERBOSE
1297# define YYERROR_VERBOSE 1
1298#else
1299# define YYERROR_VERBOSE 0
1300#endif
1301
1302/* Enabling the token table. */
1303#ifndef YYTOKEN_TABLE
1304# define YYTOKEN_TABLE 0
1305#endif
1306
1307#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
Reid Spencer1628cec2006-10-26 06:15:43 +00001308#line 1011 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00001309typedef union YYSTYPE {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001310 llvm::Module *ModuleVal;
1311 llvm::Function *FunctionVal;
1312 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1313 llvm::BasicBlock *BasicBlockVal;
1314 llvm::TerminatorInst *TermInstVal;
1315 llvm::Instruction *InstVal;
1316 llvm::Constant *ConstVal;
1317
1318 const llvm::Type *PrimType;
1319 llvm::PATypeHolder *TypeVal;
1320 llvm::Value *ValueVal;
1321
1322 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1323 std::vector<llvm::Value*> *ValueList;
1324 std::list<llvm::PATypeHolder> *TypeList;
1325 // Represent the RHS of PHI node
1326 std::list<std::pair<llvm::Value*,
1327 llvm::BasicBlock*> > *PHIList;
1328 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1329 std::vector<llvm::Constant*> *ConstVector;
1330
1331 llvm::GlobalValue::LinkageTypes Linkage;
1332 int64_t SInt64Val;
1333 uint64_t UInt64Val;
1334 int SIntVal;
1335 unsigned UIntVal;
1336 double FPVal;
1337 bool BoolVal;
1338
1339 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001340 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001341
Reid Spencer1628cec2006-10-26 06:15:43 +00001342 BinaryOpInfo BinaryOpVal;
1343 TermOpInfo TermOpVal;
1344 MemOpInfo MemOpVal;
1345 OtherOpInfo OtherOpVal;
1346 llvm::Module::Endianness Endianness;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001347} YYSTYPE;
Reid Spencer21be8652006-10-22 07:03:43 +00001348/* Line 196 of yacc.c. */
Reid Spencer1628cec2006-10-26 06:15:43 +00001349#line 1350 "llvmAsmParser.tab.c"
Reid Spencer21be8652006-10-22 07:03:43 +00001350# define yystype YYSTYPE /* obsolescent; will be withdrawn */
1351# define YYSTYPE_IS_DECLARED 1
1352# define YYSTYPE_IS_TRIVIAL 1
Reid Spencer68a24bd2005-08-27 18:50:39 +00001353#endif
1354
1355
1356
Reid Spencer21be8652006-10-22 07:03:43 +00001357/* Copy the second part of user declarations. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001358
1359
Reid Spencer21be8652006-10-22 07:03:43 +00001360/* Line 219 of yacc.c. */
Reid Spencer1628cec2006-10-26 06:15:43 +00001361#line 1362 "llvmAsmParser.tab.c"
Reid Spencer68a24bd2005-08-27 18:50:39 +00001362
Reid Spencer21be8652006-10-22 07:03:43 +00001363#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1364# define YYSIZE_T __SIZE_TYPE__
1365#endif
1366#if ! defined (YYSIZE_T) && defined (size_t)
1367# define YYSIZE_T size_t
1368#endif
1369#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
1370# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1371# define YYSIZE_T size_t
1372#endif
1373#if ! defined (YYSIZE_T)
1374# define YYSIZE_T unsigned int
1375#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001376
Reid Spencer21be8652006-10-22 07:03:43 +00001377#ifndef YY_
1378# if YYENABLE_NLS
1379# if ENABLE_NLS
1380# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1381# define YY_(msgid) dgettext ("bison-runtime", msgid)
1382# endif
1383# endif
1384# ifndef YY_
1385# define YY_(msgid) msgid
1386# endif
1387#endif
1388
1389#if ! defined (yyoverflow) || YYERROR_VERBOSE
1390
1391/* The parser invokes alloca or malloc; define the necessary symbols. */
1392
1393# ifdef YYSTACK_USE_ALLOCA
1394# if YYSTACK_USE_ALLOCA
1395# ifdef __GNUC__
1396# define YYSTACK_ALLOC __builtin_alloca
1397# else
1398# define YYSTACK_ALLOC alloca
1399# if defined (__STDC__) || defined (__cplusplus)
1400# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1401# define YYINCLUDED_STDLIB_H
1402# endif
1403# endif
1404# endif
1405# endif
1406
1407# ifdef YYSTACK_ALLOC
1408 /* Pacify GCC's `empty if-body' warning. */
1409# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
1410# ifndef YYSTACK_ALLOC_MAXIMUM
1411 /* The OS might guarantee only one guard page at the bottom of the stack,
1412 and a page size can be as small as 4096 bytes. So we cannot safely
1413 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1414 to allow for a few compiler-allocated temporary stack slots. */
1415# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
1416# endif
1417# else
1418# define YYSTACK_ALLOC YYMALLOC
1419# define YYSTACK_FREE YYFREE
1420# ifndef YYSTACK_ALLOC_MAXIMUM
1421# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
1422# endif
1423# ifdef __cplusplus
1424extern "C" {
1425# endif
1426# ifndef YYMALLOC
1427# define YYMALLOC malloc
1428# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
1429 && (defined (__STDC__) || defined (__cplusplus)))
1430void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1431# endif
1432# endif
1433# ifndef YYFREE
1434# define YYFREE free
1435# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
1436 && (defined (__STDC__) || defined (__cplusplus)))
1437void free (void *); /* INFRINGES ON USER NAME SPACE */
1438# endif
1439# endif
1440# ifdef __cplusplus
1441}
1442# endif
1443# endif
1444#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
1445
1446
1447#if (! defined (yyoverflow) \
1448 && (! defined (__cplusplus) \
1449 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
1450
1451/* A type that is properly aligned for any stack member. */
1452union yyalloc
1453{
1454 short int yyss;
1455 YYSTYPE yyvs;
1456 };
1457
1458/* The size of the maximum gap between one aligned stack and the next. */
1459# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1460
1461/* The size of an array large to enough to hold all stacks, each with
1462 N elements. */
1463# define YYSTACK_BYTES(N) \
1464 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
1465 + YYSTACK_GAP_MAXIMUM)
1466
1467/* Copy COUNT objects from FROM to TO. The source and destination do
1468 not overlap. */
1469# ifndef YYCOPY
1470# if defined (__GNUC__) && 1 < __GNUC__
1471# define YYCOPY(To, From, Count) \
1472 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1473# else
1474# define YYCOPY(To, From, Count) \
1475 do \
1476 { \
1477 YYSIZE_T yyi; \
1478 for (yyi = 0; yyi < (Count); yyi++) \
1479 (To)[yyi] = (From)[yyi]; \
1480 } \
1481 while (0)
1482# endif
1483# endif
1484
1485/* Relocate STACK from its old location to the new one. The
1486 local variables YYSIZE and YYSTACKSIZE give the old and new number of
1487 elements in the stack, and YYPTR gives the new location of the
1488 stack. Advance YYPTR to a properly aligned location for the next
1489 stack. */
1490# define YYSTACK_RELOCATE(Stack) \
1491 do \
1492 { \
1493 YYSIZE_T yynewbytes; \
1494 YYCOPY (&yyptr->Stack, Stack, yysize); \
1495 Stack = &yyptr->Stack; \
1496 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1497 yyptr += yynewbytes / sizeof (*yyptr); \
1498 } \
1499 while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001500
1501#endif
1502
Reid Spencer21be8652006-10-22 07:03:43 +00001503#if defined (__STDC__) || defined (__cplusplus)
1504 typedef signed char yysigned_char;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001505#else
Reid Spencer21be8652006-10-22 07:03:43 +00001506 typedef short int yysigned_char;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001507#endif
1508
Reid Spencer21be8652006-10-22 07:03:43 +00001509/* YYFINAL -- State number of the termination state. */
1510#define YYFINAL 4
1511/* YYLAST -- Last index in YYTABLE. */
Reid Spencer1628cec2006-10-26 06:15:43 +00001512#define YYLAST 1288
Reid Spencer21be8652006-10-22 07:03:43 +00001513
1514/* YYNTOKENS -- Number of terminals. */
Reid Spencer1628cec2006-10-26 06:15:43 +00001515#define YYNTOKENS 125
Reid Spencer21be8652006-10-22 07:03:43 +00001516/* YYNNTS -- Number of nonterminals. */
1517#define YYNNTS 75
1518/* YYNRULES -- Number of rules. */
Reid Spencer1628cec2006-10-26 06:15:43 +00001519#define YYNRULES 254
Reid Spencer21be8652006-10-22 07:03:43 +00001520/* YYNRULES -- Number of states. */
Reid Spencer1628cec2006-10-26 06:15:43 +00001521#define YYNSTATES 519
Reid Spencer21be8652006-10-22 07:03:43 +00001522
1523/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1524#define YYUNDEFTOK 2
Reid Spencer1628cec2006-10-26 06:15:43 +00001525#define YYMAXUTOK 365
Reid Spencer21be8652006-10-22 07:03:43 +00001526
1527#define YYTRANSLATE(YYX) \
1528 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1529
1530/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1531static const unsigned char yytranslate[] =
1532{
1533 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer1628cec2006-10-26 06:15:43 +00001537 114, 115, 123, 2, 112, 2, 2, 2, 2, 2,
Reid Spencer21be8652006-10-22 07:03:43 +00001538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer1628cec2006-10-26 06:15:43 +00001539 119, 111, 120, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer21be8652006-10-22 07:03:43 +00001540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer1628cec2006-10-26 06:15:43 +00001542 2, 116, 113, 118, 2, 2, 2, 2, 2, 124,
Reid Spencer21be8652006-10-22 07:03:43 +00001543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Reid Spencer1628cec2006-10-26 06:15:43 +00001545 117, 2, 2, 121, 2, 122, 2, 2, 2, 2,
Reid Spencer21be8652006-10-22 07:03:43 +00001546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1555 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, 1, 2, 3, 4,
1559 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1560 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1561 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1562 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1563 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1564 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1565 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1566 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1567 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1568 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
Reid Spencer1628cec2006-10-26 06:15:43 +00001569 105, 106, 107, 108, 109, 110
Reid Spencer21be8652006-10-22 07:03:43 +00001570};
1571
1572#if YYDEBUG
1573/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1574 YYRHS. */
1575static const unsigned short int yyprhs[] =
1576{
1577 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
1578 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
1579 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
Reid Spencer1628cec2006-10-26 06:15:43 +00001580 59, 61, 63, 65, 67, 69, 71, 74, 75, 77,
1581 79, 81, 83, 85, 87, 89, 90, 91, 93, 95,
1582 97, 99, 101, 103, 106, 107, 110, 111, 115, 118,
1583 119, 121, 122, 126, 128, 131, 133, 135, 137, 139,
Reid Spencer21be8652006-10-22 07:03:43 +00001584 141, 143, 145, 147, 149, 151, 153, 155, 157, 159,
Reid Spencer1628cec2006-10-26 06:15:43 +00001585 161, 163, 165, 167, 169, 171, 173, 176, 181, 187,
1586 193, 197, 200, 203, 205, 209, 211, 215, 217, 218,
1587 223, 227, 231, 236, 241, 245, 248, 251, 254, 257,
1588 260, 263, 266, 269, 272, 275, 282, 288, 297, 304,
1589 311, 318, 325, 332, 341, 350, 354, 356, 358, 360,
1590 362, 365, 368, 373, 376, 378, 383, 386, 391, 392,
1591 400, 401, 409, 410, 418, 419, 427, 431, 436, 437,
1592 439, 441, 443, 447, 451, 455, 459, 463, 467, 469,
1593 470, 472, 474, 476, 477, 480, 484, 486, 488, 492,
1594 494, 495, 504, 506, 508, 512, 514, 516, 519, 520,
1595 522, 524, 525, 530, 531, 533, 535, 537, 539, 541,
1596 543, 545, 547, 549, 553, 555, 561, 563, 565, 567,
1597 569, 572, 575, 578, 582, 585, 586, 588, 591, 594,
1598 598, 608, 618, 627, 641, 643, 645, 652, 658, 661,
1599 668, 676, 678, 682, 684, 685, 688, 690, 696, 702,
1600 708, 711, 716, 721, 728, 733, 738, 743, 748, 755,
1601 762, 765, 773, 775, 778, 779, 781, 782, 786, 793,
1602 797, 804, 807, 812, 819
Reid Spencer21be8652006-10-22 07:03:43 +00001603};
1604
1605/* YYRHS -- A `-1'-separated list of the rules' RHS. */
1606static const short int yyrhs[] =
1607{
Reid Spencer1628cec2006-10-26 06:15:43 +00001608 156, 0, -1, 5, -1, 6, -1, 3, -1, 4,
Reid Spencer21be8652006-10-22 07:03:43 +00001609 -1, 78, -1, 79, -1, 80, -1, 81, -1, 82,
1610 -1, 83, -1, 84, -1, 85, -1, 86, -1, 87,
Reid Spencer1628cec2006-10-26 06:15:43 +00001611 -1, 88, -1, 89, -1, 90, -1, 91, -1, 92,
1612 -1, 93, -1, 103, -1, 104, -1, 16, -1, 14,
1613 -1, 12, -1, 10, -1, 17, -1, 15, -1, 13,
1614 -1, 11, -1, 132, -1, 133, -1, 18, -1, 19,
1615 -1, 168, 111, -1, -1, 41, -1, 42, -1, 43,
1616 -1, 44, -1, 45, -1, 46, -1, 47, -1, -1,
1617 -1, 65, -1, 66, -1, 67, -1, 68, -1, 69,
1618 -1, 70, -1, 64, 4, -1, -1, 57, 4, -1,
1619 -1, 112, 57, 4, -1, 34, 24, -1, -1, 141,
1620 -1, -1, 112, 144, 143, -1, 141, -1, 57, 4,
1621 -1, 147, -1, 8, -1, 149, -1, 8, -1, 149,
1622 -1, 9, -1, 10, -1, 11, -1, 12, -1, 13,
1623 -1, 14, -1, 15, -1, 16, -1, 17, -1, 18,
1624 -1, 19, -1, 20, -1, 21, -1, 48, -1, 148,
1625 -1, 183, -1, 113, 4, -1, 146, 114, 151, 115,
1626 -1, 116, 4, 117, 149, 118, -1, 119, 4, 117,
1627 149, 120, -1, 121, 150, 122, -1, 121, 122, -1,
1628 149, 123, -1, 149, -1, 150, 112, 149, -1, 150,
1629 -1, 150, 112, 37, -1, 37, -1, -1, 147, 116,
1630 154, 118, -1, 147, 116, 118, -1, 147, 124, 24,
1631 -1, 147, 119, 154, 120, -1, 147, 121, 154, 122,
1632 -1, 147, 121, 122, -1, 147, 38, -1, 147, 39,
1633 -1, 147, 183, -1, 147, 153, -1, 147, 26, -1,
1634 132, 127, -1, 133, 4, -1, 9, 27, -1, 9,
1635 28, -1, 135, 7, -1, 101, 114, 152, 36, 147,
1636 115, -1, 99, 114, 152, 197, 115, -1, 102, 114,
1637 152, 112, 152, 112, 152, 115, -1, 128, 114, 152,
1638 112, 152, 115, -1, 129, 114, 152, 112, 152, 115,
1639 -1, 130, 114, 152, 112, 152, 115, -1, 131, 114,
1640 152, 112, 152, 115, -1, 106, 114, 152, 112, 152,
1641 115, -1, 107, 114, 152, 112, 152, 112, 152, 115,
1642 -1, 108, 114, 152, 112, 152, 112, 152, 115, -1,
1643 154, 112, 152, -1, 152, -1, 32, -1, 33, -1,
1644 157, -1, 157, 177, -1, 157, 179, -1, 157, 62,
1645 61, 163, -1, 157, 25, -1, 158, -1, 158, 136,
1646 20, 145, -1, 158, 179, -1, 158, 62, 61, 163,
1647 -1, -1, 158, 136, 137, 155, 152, 159, 143, -1,
1648 -1, 158, 136, 50, 155, 147, 160, 143, -1, -1,
1649 158, 136, 45, 155, 147, 161, 143, -1, -1, 158,
1650 136, 47, 155, 147, 162, 143, -1, 158, 51, 165,
1651 -1, 158, 58, 111, 166, -1, -1, 24, -1, 56,
1652 -1, 55, -1, 53, 111, 164, -1, 54, 111, 4,
1653 -1, 52, 111, 24, -1, 71, 111, 24, -1, 116,
1654 167, 118, -1, 167, 112, 24, -1, 24, -1, -1,
1655 22, -1, 24, -1, 168, -1, -1, 147, 169, -1,
1656 171, 112, 170, -1, 170, -1, 171, -1, 171, 112,
1657 37, -1, 37, -1, -1, 138, 145, 168, 114, 172,
1658 115, 142, 139, -1, 29, -1, 121, -1, 137, 173,
1659 174, -1, 30, -1, 122, -1, 186, 176, -1, -1,
1660 45, -1, 47, -1, -1, 31, 180, 178, 173, -1,
1661 -1, 63, -1, 3, -1, 4, -1, 7, -1, 27,
1662 -1, 28, -1, 38, -1, 39, -1, 26, -1, 119,
1663 154, 120, -1, 153, -1, 61, 181, 24, 112, 24,
1664 -1, 126, -1, 168, -1, 183, -1, 182, -1, 147,
1665 184, -1, 186, 187, -1, 175, 187, -1, 188, 136,
1666 189, -1, 188, 191, -1, -1, 23, -1, 72, 185,
1667 -1, 72, 8, -1, 73, 21, 184, -1, 73, 9,
1668 184, 112, 21, 184, 112, 21, 184, -1, 74, 134,
1669 184, 112, 21, 184, 116, 190, 118, -1, 74, 134,
1670 184, 112, 21, 184, 116, 118, -1, 75, 138, 145,
1671 184, 114, 194, 115, 36, 21, 184, 76, 21, 184,
1672 -1, 76, -1, 77, -1, 190, 134, 182, 112, 21,
1673 184, -1, 134, 182, 112, 21, 184, -1, 136, 196,
1674 -1, 147, 116, 184, 112, 184, 118, -1, 192, 112,
1675 116, 184, 112, 184, 118, -1, 185, -1, 193, 112,
1676 185, -1, 193, -1, -1, 60, 59, -1, 59, -1,
1677 128, 147, 184, 112, 184, -1, 129, 147, 184, 112,
1678 184, -1, 130, 147, 184, 112, 184, -1, 49, 185,
1679 -1, 131, 185, 112, 185, -1, 101, 185, 36, 147,
1680 -1, 102, 185, 112, 185, 112, 185, -1, 105, 185,
1681 112, 147, -1, 109, 185, 112, 147, -1, 110, 185,
1682 112, 147, -1, 106, 185, 112, 185, -1, 107, 185,
1683 112, 185, 112, 185, -1, 108, 185, 112, 185, 112,
1684 185, -1, 100, 192, -1, 195, 138, 145, 184, 114,
1685 194, 115, -1, 199, -1, 112, 193, -1, -1, 35,
1686 -1, -1, 94, 147, 140, -1, 94, 147, 112, 15,
1687 184, 140, -1, 95, 147, 140, -1, 95, 147, 112,
1688 15, 184, 140, -1, 96, 185, -1, 198, 97, 147,
1689 184, -1, 198, 98, 185, 112, 147, 184, -1, 99,
1690 147, 184, 197, -1
Reid Spencer21be8652006-10-22 07:03:43 +00001691};
1692
1693/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1694static const unsigned short int yyrline[] =
1695{
Reid Spencer1628cec2006-10-26 06:15:43 +00001696 0, 1134, 1134, 1135, 1143, 1144, 1154, 1154, 1154, 1154,
1697 1154, 1154, 1154, 1155, 1155, 1155, 1156, 1156, 1156, 1156,
1698 1156, 1156, 1158, 1158, 1162, 1162, 1162, 1162, 1163, 1163,
1699 1163, 1163, 1164, 1164, 1165, 1165, 1168, 1172, 1177, 1178,
1700 1179, 1180, 1181, 1182, 1183, 1184, 1186, 1187, 1188, 1189,
1701 1190, 1191, 1192, 1193, 1202, 1203, 1209, 1210, 1218, 1226,
1702 1227, 1232, 1233, 1234, 1239, 1253, 1253, 1254, 1254, 1256,
1703 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1267, 1267, 1267,
1704 1267, 1267, 1267, 1268, 1272, 1276, 1284, 1292, 1305, 1310,
1705 1322, 1332, 1336, 1347, 1352, 1358, 1359, 1363, 1367, 1378,
1706 1404, 1418, 1448, 1474, 1495, 1508, 1518, 1523, 1584, 1591,
1707 1600, 1606, 1612, 1616, 1620, 1628, 1639, 1671, 1679, 1706,
1708 1717, 1723, 1731, 1737, 1743, 1752, 1756, 1764, 1764, 1774,
1709 1782, 1787, 1791, 1795, 1799, 1814, 1836, 1839, 1842, 1842,
1710 1850, 1850, 1858, 1858, 1866, 1866, 1875, 1878, 1881, 1885,
1711 1898, 1899, 1901, 1905, 1914, 1918, 1923, 1925, 1930, 1935,
1712 1944, 1944, 1945, 1945, 1947, 1954, 1960, 1967, 1971, 1977,
1713 1982, 1987, 2082, 2082, 2084, 2092, 2092, 2094, 2099, 2100,
1714 2101, 2103, 2103, 2113, 2117, 2122, 2126, 2130, 2134, 2138,
1715 2142, 2146, 2150, 2154, 2179, 2183, 2197, 2201, 2207, 2207,
1716 2213, 2218, 2222, 2231, 2242, 2247, 2259, 2272, 2276, 2280,
1717 2285, 2294, 2313, 2322, 2378, 2382, 2389, 2400, 2413, 2422,
1718 2431, 2441, 2445, 2452, 2452, 2454, 2458, 2463, 2482, 2497,
1719 2511, 2524, 2532, 2540, 2548, 2554, 2574, 2597, 2603, 2609,
1720 2615, 2630, 2689, 2696, 2699, 2704, 2708, 2715, 2720, 2726,
1721 2731, 2737, 2745, 2757, 2772
Reid Spencer21be8652006-10-22 07:03:43 +00001722};
1723#endif
1724
1725#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1726/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1727 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1728static const char *const yytname[] =
1729{
1730 "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL",
1731 "UINTVAL", "FPVAL", "VOID", "BOOL", "SBYTE", "UBYTE", "SHORT", "USHORT",
1732 "INT", "UINT", "LONG", "ULONG", "FLOAT", "DOUBLE", "TYPE", "LABEL",
1733 "VAR_ID", "LABELSTR", "STRINGCONSTANT", "IMPLEMENTATION",
1734 "ZEROINITIALIZER", "TRUETOK", "FALSETOK", "BEGINTOK", "ENDTOK",
1735 "DECLARE", "GLOBAL", "CONSTANT", "SECTION", "VOLATILE", "TO",
1736 "DOTDOTDOT", "NULL_TOK", "UNDEF", "CONST", "INTERNAL", "LINKONCE",
1737 "WEAK", "APPENDING", "DLLIMPORT", "DLLEXPORT", "EXTERN_WEAK", "OPAQUE",
1738 "NOT", "EXTERNAL", "TARGET", "TRIPLE", "ENDIAN", "POINTERSIZE", "LITTLE",
1739 "BIG", "ALIGN", "DEPLIBS", "CALL", "TAIL", "ASM_TOK", "MODULE",
1740 "SIDEEFFECT", "CC_TOK", "CCC_TOK", "CSRETCC_TOK", "FASTCC_TOK",
1741 "COLDCC_TOK", "X86_STDCALLCC_TOK", "X86_FASTCALLCC_TOK", "DATALAYOUT",
1742 "RET", "BR", "SWITCH", "INVOKE", "UNWIND", "UNREACHABLE", "ADD", "SUB",
Reid Spencer1628cec2006-10-26 06:15:43 +00001743 "MUL", "UDIV", "SDIV", "FDIV", "REM", "AND", "OR", "XOR", "SETLE",
1744 "SETGE", "SETLT", "SETGT", "SETEQ", "SETNE", "MALLOC", "ALLOCA", "FREE",
1745 "LOAD", "STORE", "GETELEMENTPTR", "PHI_TOK", "CAST", "SELECT", "SHL",
1746 "SHR", "VAARG", "EXTRACTELEMENT", "INSERTELEMENT", "SHUFFLEVECTOR",
1747 "VAARG_old", "VANEXT_old", "'='", "','", "'\\\\'", "'('", "')'", "'['",
1748 "'x'", "']'", "'<'", "'>'", "'{'", "'}'", "'*'", "'c'", "$accept",
1749 "INTVAL", "EINT64VAL", "ArithmeticOps", "LogicalOps", "SetCondOps",
1750 "ShiftOps", "SIntType", "UIntType", "IntType", "FPType", "OptAssign",
1751 "OptLinkage", "OptCallingConv", "OptAlign", "OptCAlign", "SectionString",
1752 "OptSection", "GlobalVarAttributes", "GlobalVarAttribute", "TypesV",
1753 "UpRTypesV", "Types", "PrimType", "UpRTypes", "TypeListI",
1754 "ArgTypeListI", "ConstVal", "ConstExpr", "ConstVector", "GlobalType",
1755 "Module", "FunctionList", "ConstPool", "@1", "@2", "@3", "@4",
1756 "AsmBlock", "BigOrLittle", "TargetDefinition", "LibrariesDefinition",
1757 "LibList", "Name", "OptName", "ArgVal", "ArgListH", "ArgList",
1758 "FunctionHeaderH", "BEGIN", "FunctionHeader", "END", "Function",
1759 "FnDeclareLinkage", "FunctionProto", "@5", "OptSideEffect",
1760 "ConstValueRef", "SymbolicValueRef", "ValueRef", "ResolvedVal",
1761 "BasicBlockList", "BasicBlock", "InstructionList", "BBTerminatorInst",
1762 "JumpTable", "Inst", "PHIList", "ValueRefList", "ValueRefListE",
1763 "OptTailCall", "InstVal", "IndexList", "OptVolatile", "MemoryInst", 0
Reid Spencer21be8652006-10-22 07:03:43 +00001764};
1765#endif
1766
1767# ifdef YYPRINT
1768/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1769 token YYLEX-NUM. */
1770static const unsigned short int yytoknum[] =
1771{
1772 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1773 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1774 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1775 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1776 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1777 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1778 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1779 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1780 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1781 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
Reid Spencer1628cec2006-10-26 06:15:43 +00001782 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1783 365, 61, 44, 92, 40, 41, 91, 120, 93, 60,
1784 62, 123, 125, 42, 99
Reid Spencer21be8652006-10-22 07:03:43 +00001785};
1786# endif
1787
1788/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1789static const unsigned char yyr1[] =
1790{
Reid Spencer1628cec2006-10-26 06:15:43 +00001791 0, 125, 126, 126, 127, 127, 128, 128, 128, 128,
1792 128, 128, 128, 129, 129, 129, 130, 130, 130, 130,
1793 130, 130, 131, 131, 132, 132, 132, 132, 133, 133,
1794 133, 133, 134, 134, 135, 135, 136, 136, 137, 137,
1795 137, 137, 137, 137, 137, 137, 138, 138, 138, 138,
1796 138, 138, 138, 138, 139, 139, 140, 140, 141, 142,
1797 142, 143, 143, 144, 144, 145, 145, 146, 146, 147,
1798 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
1799 148, 148, 148, 149, 149, 149, 149, 149, 149, 149,
1800 149, 149, 149, 150, 150, 151, 151, 151, 151, 152,
1801 152, 152, 152, 152, 152, 152, 152, 152, 152, 152,
1802 152, 152, 152, 152, 152, 153, 153, 153, 153, 153,
1803 153, 153, 153, 153, 153, 154, 154, 155, 155, 156,
1804 157, 157, 157, 157, 157, 158, 158, 158, 159, 158,
1805 160, 158, 161, 158, 162, 158, 158, 158, 158, 163,
1806 164, 164, 165, 165, 165, 165, 166, 167, 167, 167,
1807 168, 168, 169, 169, 170, 171, 171, 172, 172, 172,
1808 172, 173, 174, 174, 175, 176, 176, 177, 178, 178,
1809 178, 180, 179, 181, 181, 182, 182, 182, 182, 182,
1810 182, 182, 182, 182, 182, 182, 183, 183, 184, 184,
1811 185, 186, 186, 187, 188, 188, 188, 189, 189, 189,
1812 189, 189, 189, 189, 189, 189, 190, 190, 191, 192,
1813 192, 193, 193, 194, 194, 195, 195, 196, 196, 196,
1814 196, 196, 196, 196, 196, 196, 196, 196, 196, 196,
1815 196, 196, 196, 197, 197, 198, 198, 199, 199, 199,
1816 199, 199, 199, 199, 199
Reid Spencer21be8652006-10-22 07:03:43 +00001817};
1818
1819/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1820static const unsigned char yyr2[] =
1821{
1822 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1823 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1824 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer1628cec2006-10-26 06:15:43 +00001825 1, 1, 1, 1, 1, 1, 2, 0, 1, 1,
1826 1, 1, 1, 1, 1, 0, 0, 1, 1, 1,
1827 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
1828 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
Reid Spencer21be8652006-10-22 07:03:43 +00001829 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Reid Spencer1628cec2006-10-26 06:15:43 +00001830 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1831 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1832 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1833 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
1834 6, 6, 6, 8, 8, 3, 1, 1, 1, 1,
1835 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
1836 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
1837 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
1838 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
1839 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
1840 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
1841 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
1842 2, 2, 2, 3, 2, 0, 1, 2, 2, 3,
1843 9, 9, 8, 13, 1, 1, 6, 5, 2, 6,
1844 7, 1, 3, 1, 0, 2, 1, 5, 5, 5,
1845 2, 4, 4, 6, 4, 4, 4, 4, 6, 6,
1846 2, 7, 1, 2, 0, 1, 0, 3, 6, 3,
1847 6, 2, 4, 6, 4
Reid Spencer21be8652006-10-22 07:03:43 +00001848};
1849
1850/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
1851 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
1852 means the default is an error. */
1853static const unsigned char yydefact[] =
1854{
Reid Spencer1628cec2006-10-26 06:15:43 +00001855 148, 0, 45, 134, 1, 133, 181, 38, 39, 40,
1856 41, 42, 43, 44, 0, 46, 205, 130, 131, 205,
1857 160, 161, 0, 0, 0, 45, 0, 136, 178, 0,
1858 0, 47, 48, 49, 50, 51, 52, 0, 0, 206,
1859 202, 37, 175, 176, 177, 201, 0, 0, 0, 0,
1860 146, 0, 0, 0, 0, 0, 0, 0, 36, 179,
1861 180, 46, 149, 132, 53, 2, 3, 66, 70, 71,
1862 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1863 82, 83, 0, 0, 0, 0, 196, 0, 0, 65,
1864 84, 69, 197, 85, 172, 173, 174, 246, 204, 0,
1865 0, 0, 0, 159, 147, 137, 135, 127, 128, 0,
1866 0, 0, 0, 182, 86, 0, 0, 68, 91, 93,
1867 0, 0, 98, 92, 245, 0, 226, 0, 0, 0,
1868 0, 46, 214, 215, 6, 7, 8, 9, 10, 11,
1869 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1870 0, 0, 0, 0, 0, 0, 0, 22, 23, 0,
1871 0, 0, 0, 0, 0, 0, 0, 0, 0, 203,
1872 46, 218, 0, 242, 154, 151, 150, 152, 153, 155,
1873 158, 0, 142, 144, 140, 70, 71, 72, 73, 74,
1874 75, 76, 77, 78, 79, 80, 0, 0, 0, 0,
1875 138, 0, 0, 0, 90, 170, 97, 95, 0, 0,
1876 230, 225, 208, 207, 0, 0, 27, 31, 26, 30,
1877 25, 29, 24, 28, 32, 33, 0, 0, 56, 56,
1878 251, 0, 0, 240, 0, 0, 0, 0, 0, 0,
1879 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1880 156, 61, 61, 61, 112, 113, 4, 5, 110, 111,
1881 114, 109, 105, 106, 0, 0, 0, 0, 0, 0,
1882 0, 0, 0, 0, 0, 0, 0, 0, 108, 107,
1883 61, 67, 67, 94, 169, 163, 166, 167, 0, 0,
1884 87, 185, 186, 187, 192, 188, 189, 190, 191, 183,
1885 0, 194, 199, 198, 200, 0, 209, 0, 0, 0,
1886 247, 0, 249, 244, 0, 0, 0, 0, 0, 0,
1887 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1888 0, 157, 0, 143, 145, 141, 0, 0, 0, 0,
1889 0, 0, 100, 126, 0, 0, 104, 0, 101, 0,
1890 0, 0, 0, 139, 88, 89, 162, 164, 0, 59,
1891 96, 184, 0, 0, 0, 0, 0, 0, 0, 0,
1892 0, 254, 0, 0, 232, 0, 234, 237, 0, 0,
1893 235, 236, 0, 0, 0, 231, 0, 252, 0, 0,
1894 0, 63, 61, 244, 0, 0, 0, 0, 0, 0,
1895 99, 102, 103, 0, 0, 0, 0, 168, 165, 60,
1896 54, 0, 193, 0, 0, 224, 56, 57, 56, 221,
1897 243, 0, 0, 0, 0, 0, 227, 228, 229, 224,
1898 0, 58, 64, 62, 0, 0, 0, 0, 0, 0,
1899 125, 0, 0, 0, 0, 0, 171, 0, 0, 0,
1900 223, 0, 0, 248, 250, 0, 0, 0, 233, 238,
1901 239, 0, 253, 116, 0, 0, 0, 0, 0, 0,
1902 0, 0, 0, 55, 195, 0, 0, 0, 222, 219,
1903 0, 241, 115, 0, 122, 0, 0, 118, 119, 120,
1904 121, 0, 212, 0, 0, 0, 220, 0, 0, 0,
1905 210, 0, 211, 0, 0, 117, 123, 124, 0, 0,
1906 0, 0, 0, 0, 217, 0, 0, 216, 213
Reid Spencer21be8652006-10-22 07:03:43 +00001907};
1908
1909/* YYDEFGOTO[NTERM-NUM]. */
1910static const short int yydefgoto[] =
1911{
Reid Spencer1628cec2006-10-26 06:15:43 +00001912 -1, 86, 258, 274, 275, 276, 277, 196, 197, 226,
1913 198, 25, 15, 37, 446, 310, 391, 410, 333, 392,
1914 87, 88, 199, 90, 91, 120, 208, 343, 301, 344,
1915 109, 1, 2, 3, 280, 253, 251, 252, 63, 177,
1916 50, 104, 181, 92, 357, 286, 287, 288, 38, 96,
1917 16, 44, 17, 61, 18, 28, 362, 302, 93, 304,
1918 419, 19, 40, 41, 169, 494, 98, 233, 450, 451,
1919 170, 171, 371, 172, 173
Reid Spencer21be8652006-10-22 07:03:43 +00001920};
1921
1922/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
1923 STATE-NUM. */
Reid Spencer1628cec2006-10-26 06:15:43 +00001924#define YYPACT_NINF -463
Reid Spencer21be8652006-10-22 07:03:43 +00001925static const short int yypact[] =
1926{
Reid Spencer1628cec2006-10-26 06:15:43 +00001927 -463, 42, 182, 621, -463, -463, -463, -463, -463, -463,
1928 -463, -463, -463, -463, -15, 347, 64, -463, -463, -12,
1929 -463, -463, 15, 1, 33, 360, 10, -463, 89, 114,
1930 140, -463, -463, -463, -463, -463, -463, 1005, -1, -463,
1931 -463, 115, -463, -463, -463, -463, 40, 56, 67, 68,
1932 -463, 59, 114, 1005, 51, 51, 51, 51, -463, -463,
1933 -463, 347, -463, -463, -463, -463, -463, 66, -463, -463,
1934 -463, -463, -463, -463, -463, -463, -463, -463, -463, -463,
1935 -463, -463, 172, 177, 180, 489, -463, 115, 74, -463,
1936 -463, -97, -463, -463, -463, -463, -463, 1178, -463, 165,
1937 -17, 188, 170, 171, -463, -463, -463, -463, -463, 1046,
1938 1046, 1046, 1087, -463, -463, 80, 81, -463, -463, -97,
1939 -91, 85, 838, -463, -463, 1046, -463, 142, 1128, 6,
1940 248, 347, -463, -463, -463, -463, -463, -463, -463, -463,
1941 -463, -463, -463, -463, -463, -463, -463, -463, -463, -463,
1942 1046, 1046, 1046, 1046, 1046, 1046, 1046, -463, -463, 1046,
1943 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, -463,
1944 347, -463, 35, -463, -463, -463, -463, -463, -463, -463,
1945 -463, -48, -463, -463, -463, 113, 146, 198, 150, 200,
1946 152, 213, 167, 214, 212, 223, 169, 216, 224, 443,
1947 -463, 1046, 1046, 1046, -463, 879, -463, 109, 117, 620,
1948 -463, -463, 66, -463, 620, 620, -463, -463, -463, -463,
1949 -463, -463, -463, -463, -463, -463, 620, 1005, 128, 129,
1950 -463, 620, 126, 131, 209, 134, 141, 143, 144, 154,
1951 156, 157, 620, 620, 620, 158, 1005, 1046, 1046, 228,
1952 -463, 161, 161, 161, -463, -463, -463, -463, -463, -463,
1953 -463, -463, -463, -463, 160, 164, 175, 178, 181, 184,
1954 87, 1087, 574, 230, 185, 186, 187, 189, -463, -463,
1955 161, -33, -101, -97, -463, 115, -463, 163, 176, 923,
1956 -463, -463, -463, -463, -463, -463, -463, -463, -463, 231,
1957 1087, -463, -463, -463, -463, 190, -463, 195, 620, -9,
1958 -463, -8, -463, 196, 620, 193, 1046, 1046, 1046, 1046,
1959 1046, 1046, 1046, 1046, 199, 201, 202, 1046, 620, 620,
1960 203, -463, -22, -463, -463, -463, 1087, 1087, 1087, 1087,
1961 1087, 1087, -463, -463, -47, -79, -463, -82, -463, 1087,
1962 1087, 1087, 1087, -463, -463, -463, -463, -463, 964, 262,
1963 -463, -463, 293, -75, 301, 302, 210, 620, 324, 620,
1964 1046, -463, 217, 620, -463, 218, -463, -463, 219, 220,
1965 -463, -463, 620, 620, 620, -463, 229, -463, 1046, 314,
1966 340, -463, 161, 196, 309, 234, 237, 240, 241, 1087,
1967 -463, -463, -463, 242, 243, 246, 247, -463, -463, -463,
1968 303, 249, -463, 620, 620, 1046, 250, -463, 250, -463,
1969 251, 620, 255, 1046, 1046, 1046, -463, -463, -463, 1046,
1970 620, -463, -463, -463, 253, 1046, 1087, 1087, 1087, 1087,
1971 -463, 1087, 1087, 1087, 1087, 365, -463, 348, 259, 258,
1972 251, 260, 320, -463, -463, 1046, 261, 620, -463, -463,
1973 -463, 267, -463, -463, 270, 277, 278, 282, 283, 281,
1974 284, 294, 304, -463, -463, 376, 65, 372, -463, -463,
1975 305, -463, -463, 1087, -463, 1087, 1087, -463, -463, -463,
1976 -463, 620, -463, 726, 149, 399, -463, 306, 307, 310,
1977 -463, 312, -463, 726, 620, -463, -463, -463, 405, 315,
1978 352, 620, 409, 411, -463, 620, 620, -463, -463
Reid Spencer21be8652006-10-22 07:03:43 +00001979};
1980
1981/* YYPGOTO[NTERM-NUM]. */
1982static const short int yypgoto[] =
1983{
Reid Spencer1628cec2006-10-26 06:15:43 +00001984 -463, -463, -463, 336, 339, 341, 342, -129, -128, -462,
1985 -463, 396, 415, -118, -463, -225, 82, -463, -244, -463,
1986 -50, -463, -37, -463, -56, 321, -463, -102, 252, -247,
1987 5, -463, -463, -463, -463, -463, -463, -463, 390, -463,
1988 -463, -463, -463, 2, -463, 92, -463, -463, 391, -463,
1989 -463, -463, -463, -463, 450, -463, -463, -459, -57, 62,
1990 -105, -463, 436, -463, -463, -463, -463, -463, 86, 28,
1991 -463, -463, 69, -463, -463
Reid Spencer21be8652006-10-22 07:03:43 +00001992};
1993
1994/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
1995 positive, shift that token. If negative, reduce the rule which
1996 number is the opposite. If zero, do what YYDEFACT says.
1997 If YYTABLE_NINF, syntax error. */
Reid Spencer1628cec2006-10-26 06:15:43 +00001998#define YYTABLE_NINF -130
Reid Spencer21be8652006-10-22 07:03:43 +00001999static const short int yytable[] =
2000{
Reid Spencer1628cec2006-10-26 06:15:43 +00002001 89, 224, 225, 106, 312, 26, 367, 369, 334, 335,
2002 200, 39, 389, 227, 493, 214, 89, -67, 42, 355,
2003 210, 203, 123, 213, 345, 347, 123, 215, 94, 119,
2004 399, 204, 503, 399, 501, 390, 353, 399, 175, 176,
2005 402, 401, 4, 26, 509, 412, 29, 230, 368, 368,
2006 234, 235, 246, 363, 236, 237, 238, 239, 240, 241,
2007 110, 111, 112, 245, 249, 399, 119, 46, 47, 48,
2008 250, 400, 182, 183, 184, 216, 217, 218, 219, 220,
2009 221, 222, 223, 107, 108, 354, 49, 39, 209, 121,
2010 123, 209, 65, 66, 52, 117, 185, 186, 187, 188,
2011 189, 190, 191, 192, 193, 194, 195, 79, 80, 20,
2012 43, 21, 51, 228, 229, 209, 231, 232, 209, 209,
2013 95, 58, 209, 209, 209, 209, 209, 209, 242, 243,
2014 244, 209, 247, 248, 59, 81, 60, 20, 62, 21,
2015 254, 255, 279, 330, 64, 281, 282, 283, 433, -27,
2016 -27, 99, 303, -26, -26, -25, -25, 303, 303, 216,
2017 217, 218, 219, 220, 221, 222, 223, 100, 285, 303,
2018 -24, -24, 256, 257, 303, 103, 114, 308, 101, 102,
2019 -68, 115, -129, 492, 116, 303, 303, 303, 122, 174,
2020 89, 453, 178, 454, 179, 180, 328, 201, 202, 205,
2021 82, 211, -31, 83, -30, 342, 84, 5, 85, 89,
2022 329, 209, 375, 6, 377, 378, 379, -29, -28, -34,
2023 259, 289, 385, 7, 8, 9, 10, 11, 12, 13,
2024 -35, 260, 290, 283, 393, 394, 395, 396, 397, 398,
2025 309, 311, 314, 315, 14, 316, 317, 403, 404, 405,
2026 406, 303, 331, 318, 348, 319, 320, 303, 216, 217,
2027 218, 219, 220, 221, 222, 223, 321, 502, 322, 323,
2028 327, 303, 303, 332, 336, 358, 305, 306, 337, 374,
2029 209, 376, 209, 209, 209, 380, 381, 356, 307, 338,
2030 209, 359, 339, 313, 361, 340, 389, 440, 341, 349,
2031 350, 351, 364, 352, 324, 325, 326, 365, 370, 373,
2032 303, 382, 303, 383, 384, 388, 303, 411, 458, 459,
2033 460, 285, 413, 414, 415, 303, 303, 303, 417, 421,
2034 423, 424, 425, 209, 465, 466, 467, 468, 431, 469,
2035 470, 471, 472, 429, 432, 435, 436, 224, 225, 437,
2036 478, 430, 438, 439, 441, 442, 303, 303, 443, 444,
2037 445, 447, 452, 455, 303, 224, 225, 457, 463, 473,
2038 366, 475, 474, 303, 476, 477, 372, 368, 209, 479,
2039 53, 497, 481, 498, 499, 482, 209, 209, 209, 483,
2040 386, 387, 209, 484, 485, 486, 487, 491, 464, 488,
2041 303, 7, 8, 9, 10, 54, 12, 55, 495, 489,
2042 56, 30, 31, 32, 33, 34, 35, 36, 209, 490,
2043 504, 505, 506, 496, 508, 507, 511, 512, 513, 416,
2044 515, 418, 516, 165, 303, 422, 166, 97, 167, 168,
2045 57, 409, 105, 207, 426, 427, 428, 303, 65, 66,
2046 408, 278, 113, 27, 303, 45, 420, 461, 303, 303,
2047 0, 0, 434, 0, 0, 20, 0, 21, 0, 261,
2048 0, 0, 0, 0, 0, 448, 449, 0, 0, 0,
2049 0, 262, 263, 456, 0, 0, 0, 0, 0, 0,
2050 0, 0, 462, 0, 65, 66, 0, 117, 68, 69,
2051 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
2052 80, 20, 0, 21, 0, 0, 0, 0, 0, 480,
2053 0, 134, 135, 136, 137, 138, 139, 140, 141, 142,
2054 143, 144, 145, 146, 147, 148, 149, 81, 0, 0,
2055 0, 0, 264, 0, 265, 266, 157, 158, 0, 267,
2056 268, 269, 0, 500, 0, 0, 0, 0, 0, 270,
2057 0, 0, 271, 0, 272, 0, 510, 273, 0, 0,
2058 0, 0, 0, 514, 0, 0, 0, 517, 518, 65,
2059 66, 0, 117, 185, 186, 187, 188, 189, 190, 191,
2060 192, 193, 194, 195, 79, 80, 20, 0, 21, 0,
2061 0, 0, 82, 0, 0, 83, 0, 0, 84, 0,
2062 85, 118, 0, 0, 0, 0, 0, 0, 0, 0,
2063 0, 0, 81, 291, 292, 65, 66, 293, 0, 0,
Reid Spencer21be8652006-10-22 07:03:43 +00002064 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer1628cec2006-10-26 06:15:43 +00002065 0, -37, 20, 20, 21, 21, 294, 295, 296, 0,
2066 0, 0, 6, -37, -37, 0, 0, 0, 297, 298,
2067 0, 0, -37, -37, -37, -37, -37, -37, -37, 0,
2068 0, -37, 22, 0, 0, 0, 0, 0, 0, 23,
2069 0, 299, 0, 24, 0, 0, 0, 82, 0, 0,
2070 83, 0, 0, 84, 0, 85, 346, 0, 134, 135,
2071 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
2072 146, 147, 148, 149, 0, 0, 0, 0, 0, 264,
2073 0, 265, 266, 157, 158, 0, 267, 268, 269, 291,
2074 292, 0, 0, 293, 0, 0, 0, 0, 0, 300,
Reid Spencer21be8652006-10-22 07:03:43 +00002075 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer1628cec2006-10-26 06:15:43 +00002076 0, 0, 294, 295, 296, 0, 0, 0, 0, 0,
2077 0, 0, 0, 0, 297, 298, 0, 0, 0, 0,
Reid Spencer21be8652006-10-22 07:03:43 +00002078 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer1628cec2006-10-26 06:15:43 +00002079 0, 0, 0, 0, 0, 0, 0, 299, 0, 0,
2080 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2081 0, 0, 0, 0, 134, 135, 136, 137, 138, 139,
2082 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
2083 0, 0, 0, 0, 0, 264, 0, 265, 266, 157,
2084 158, 0, 267, 268, 269, 0, 0, 0, 0, 0,
2085 0, 0, 0, 65, 66, 300, 117, 68, 69, 70,
Reid Spencer21be8652006-10-22 07:03:43 +00002086 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
Reid Spencer1628cec2006-10-26 06:15:43 +00002087 20, 0, 21, 0, 0, 0, 0, 0, 0, 0,
2088 0, 0, 0, 0, 0, 206, 0, 0, 0, 0,
Reid Spencer21be8652006-10-22 07:03:43 +00002089 0, 0, 0, 0, 65, 66, 81, 117, 68, 69,
2090 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
Reid Spencer1628cec2006-10-26 06:15:43 +00002091 80, 20, 0, 21, 0, 0, 0, 0, 0, 0,
2092 0, 0, 0, 0, 0, 0, 284, 0, 0, 0,
2093 0, 0, 0, 0, 0, 0, 0, 81, 65, 66,
2094 0, 117, 68, 69, 70, 71, 72, 73, 74, 75,
Reid Spencer21be8652006-10-22 07:03:43 +00002095 76, 77, 78, 79, 80, 20, 0, 21, 0, 0,
Reid Spencer1628cec2006-10-26 06:15:43 +00002096 0, 82, 0, 0, 83, 0, 0, 84, 0, 85,
2097 360, 0, 0, 0, 0, 0, 0, 0, 0, 65,
2098 66, 81, 117, 68, 69, 70, 71, 72, 73, 74,
2099 75, 76, 77, 78, 79, 80, 20, 0, 21, 0,
Reid Spencer21be8652006-10-22 07:03:43 +00002100 0, 0, 82, 0, 0, 83, 0, 0, 84, 0,
Reid Spencer1628cec2006-10-26 06:15:43 +00002101 85, 407, 0, 0, 0, 0, 0, 0, 0, 0,
2102 65, 66, 81, 67, 68, 69, 70, 71, 72, 73,
2103 74, 75, 76, 77, 78, 79, 80, 20, 0, 21,
2104 0, 0, 0, 0, 0, 0, 82, 0, 0, 83,
2105 0, 0, 84, 0, 85, 0, 0, 0, 0, 0,
2106 0, 65, 66, 81, 117, 68, 69, 70, 71, 72,
2107 73, 74, 75, 76, 77, 78, 79, 80, 20, 0,
2108 21, 0, 0, 0, 0, 0, 0, 82, 0, 0,
2109 83, 0, 0, 84, 0, 85, 0, 0, 0, 0,
2110 0, 0, 65, 66, 81, 117, 185, 186, 187, 188,
2111 189, 190, 191, 192, 193, 194, 195, 79, 80, 20,
2112 0, 21, 0, 0, 0, 0, 0, 0, 82, 0,
2113 0, 83, 0, 0, 84, 0, 85, 0, 0, 0,
2114 0, 0, 0, 65, 66, 81, 212, 68, 69, 70,
2115 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2116 20, 0, 21, 0, 0, 0, 0, 0, 0, 82,
2117 0, 0, 83, 0, 0, 84, 0, 85, 0, 0,
2118 0, 0, 0, 0, 0, 0, 81, 0, 0, 0,
Reid Spencer21be8652006-10-22 07:03:43 +00002119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer21be8652006-10-22 07:03:43 +00002120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Reid Spencer1628cec2006-10-26 06:15:43 +00002121 82, 0, 0, 83, 0, 0, 84, 0, 85, 0,
2122 0, 0, 0, 124, 0, 0, 0, 0, 0, 0,
2123 0, 0, 0, 0, 0, 0, 0, 125, 0, 0,
2124 0, 0, 0, 0, 0, 0, 0, 126, 127, 0,
2125 0, 82, 0, 0, 83, 0, 0, 84, 0, 85,
2126 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
2127 138, 139, 140, 141, 142, 143, 144, 145, 146, 147,
2128 148, 149, 150, 151, 152, 0, 0, 153, 154, 155,
2129 156, 157, 158, 159, 160, 161, 162, 163, 164
Reid Spencer21be8652006-10-22 07:03:43 +00002130};
2131
2132static const short int yycheck[] =
2133{
Reid Spencer1628cec2006-10-26 06:15:43 +00002134 37, 130, 130, 53, 229, 3, 15, 15, 252, 253,
2135 112, 23, 34, 131, 476, 9, 53, 114, 30, 120,
2136 125, 112, 123, 128, 271, 272, 123, 21, 29, 85,
2137 112, 122, 494, 112, 493, 57, 280, 112, 55, 56,
2138 122, 120, 0, 41, 503, 120, 61, 152, 57, 57,
2139 155, 156, 170, 300, 159, 160, 161, 162, 163, 164,
2140 55, 56, 57, 168, 112, 112, 122, 52, 53, 54,
2141 118, 118, 109, 110, 111, 10, 11, 12, 13, 14,
2142 15, 16, 17, 32, 33, 118, 71, 23, 125, 87,
2143 123, 128, 5, 6, 61, 8, 9, 10, 11, 12,
2144 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
2145 122, 24, 111, 150, 151, 152, 153, 154, 155, 156,
2146 121, 111, 159, 160, 161, 162, 163, 164, 165, 166,
2147 167, 168, 97, 98, 45, 48, 47, 22, 24, 24,
2148 27, 28, 199, 248, 4, 201, 202, 203, 392, 3,
2149 4, 111, 209, 3, 4, 3, 4, 214, 215, 10,
2150 11, 12, 13, 14, 15, 16, 17, 111, 205, 226,
2151 3, 4, 3, 4, 231, 116, 4, 227, 111, 111,
2152 114, 4, 0, 118, 4, 242, 243, 244, 114, 24,
2153 227, 416, 4, 418, 24, 24, 246, 117, 117, 114,
2154 113, 59, 4, 116, 4, 118, 119, 25, 121, 246,
2155 247, 248, 317, 31, 319, 320, 321, 4, 4, 7,
2156 4, 112, 327, 41, 42, 43, 44, 45, 46, 47,
2157 7, 7, 115, 289, 336, 337, 338, 339, 340, 341,
2158 112, 112, 116, 112, 62, 36, 112, 349, 350, 351,
2159 352, 308, 24, 112, 24, 112, 112, 314, 10, 11,
2160 12, 13, 14, 15, 16, 17, 112, 118, 112, 112,
2161 112, 328, 329, 112, 114, 112, 214, 215, 114, 316,
2162 317, 318, 319, 320, 321, 322, 323, 285, 226, 114,
2163 327, 115, 114, 231, 63, 114, 34, 399, 114, 114,
2164 114, 114, 112, 114, 242, 243, 244, 112, 112, 116,
2165 367, 112, 369, 112, 112, 112, 373, 24, 423, 424,
2166 425, 358, 21, 21, 114, 382, 383, 384, 4, 112,
2167 112, 112, 112, 370, 436, 437, 438, 439, 24, 441,
2168 442, 443, 444, 114, 4, 36, 112, 476, 476, 112,
2169 455, 388, 112, 112, 112, 112, 413, 414, 112, 112,
2170 57, 112, 112, 112, 421, 494, 494, 112, 115, 4,
2171 308, 112, 24, 430, 116, 115, 314, 57, 415, 118,
2172 20, 483, 115, 485, 486, 115, 423, 424, 425, 112,
2173 328, 329, 429, 115, 112, 112, 115, 21, 435, 115,
2174 457, 41, 42, 43, 44, 45, 46, 47, 36, 115,
2175 50, 64, 65, 66, 67, 68, 69, 70, 455, 115,
2176 21, 115, 115, 118, 112, 115, 21, 112, 76, 367,
2177 21, 369, 21, 97, 491, 373, 97, 41, 97, 97,
2178 25, 359, 52, 122, 382, 383, 384, 504, 5, 6,
2179 358, 199, 61, 3, 511, 19, 370, 429, 515, 516,
2180 -1, -1, 393, -1, -1, 22, -1, 24, -1, 26,
2181 -1, -1, -1, -1, -1, 413, 414, -1, -1, -1,
2182 -1, 38, 39, 421, -1, -1, -1, -1, -1, -1,
2183 -1, -1, 430, -1, 5, 6, -1, 8, 9, 10,
2184 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2185 21, 22, -1, 24, -1, -1, -1, -1, -1, 457,
2186 -1, 78, 79, 80, 81, 82, 83, 84, 85, 86,
2187 87, 88, 89, 90, 91, 92, 93, 48, -1, -1,
2188 -1, -1, 99, -1, 101, 102, 103, 104, -1, 106,
2189 107, 108, -1, 491, -1, -1, -1, -1, -1, 116,
2190 -1, -1, 119, -1, 121, -1, 504, 124, -1, -1,
2191 -1, -1, -1, 511, -1, -1, -1, 515, 516, 5,
2192 6, -1, 8, 9, 10, 11, 12, 13, 14, 15,
2193 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
2194 -1, -1, 113, -1, -1, 116, -1, -1, 119, -1,
2195 121, 122, -1, -1, -1, -1, -1, -1, -1, -1,
2196 -1, -1, 48, 3, 4, 5, 6, 7, -1, -1,
Reid Spencer21be8652006-10-22 07:03:43 +00002197 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer1628cec2006-10-26 06:15:43 +00002198 -1, 20, 22, 22, 24, 24, 26, 27, 28, -1,
2199 -1, -1, 31, 32, 33, -1, -1, -1, 38, 39,
2200 -1, -1, 41, 42, 43, 44, 45, 46, 47, -1,
2201 -1, 50, 51, -1, -1, -1, -1, -1, -1, 58,
2202 -1, 61, -1, 62, -1, -1, -1, 113, -1, -1,
2203 116, -1, -1, 119, -1, 121, 122, -1, 78, 79,
2204 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
2205 90, 91, 92, 93, -1, -1, -1, -1, -1, 99,
2206 -1, 101, 102, 103, 104, -1, 106, 107, 108, 3,
2207 4, -1, -1, 7, -1, -1, -1, -1, -1, 119,
Reid Spencer21be8652006-10-22 07:03:43 +00002208 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer1628cec2006-10-26 06:15:43 +00002209 -1, -1, 26, 27, 28, -1, -1, -1, -1, -1,
2210 -1, -1, -1, -1, 38, 39, -1, -1, -1, -1,
2211 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2212 -1, -1, -1, -1, -1, -1, -1, 61, -1, -1,
2213 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2214 -1, -1, -1, -1, 78, 79, 80, 81, 82, 83,
2215 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
2216 -1, -1, -1, -1, -1, 99, -1, 101, 102, 103,
2217 104, -1, 106, 107, 108, -1, -1, -1, -1, -1,
2218 -1, -1, -1, 5, 6, 119, 8, 9, 10, 11,
2219 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
2220 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
2221 -1, -1, -1, -1, -1, 37, -1, -1, -1, -1,
2222 -1, -1, -1, -1, 5, 6, 48, 8, 9, 10,
2223 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
2224 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
2225 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1,
2226 -1, -1, -1, -1, -1, -1, -1, 48, 5, 6,
2227 -1, 8, 9, 10, 11, 12, 13, 14, 15, 16,
Reid Spencer21be8652006-10-22 07:03:43 +00002228 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
Reid Spencer1628cec2006-10-26 06:15:43 +00002229 -1, 113, -1, -1, 116, -1, -1, 119, -1, 121,
Reid Spencer21be8652006-10-22 07:03:43 +00002230 37, -1, -1, -1, -1, -1, -1, -1, -1, 5,
2231 6, 48, 8, 9, 10, 11, 12, 13, 14, 15,
2232 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
Reid Spencer1628cec2006-10-26 06:15:43 +00002233 -1, -1, 113, -1, -1, 116, -1, -1, 119, -1,
2234 121, 37, -1, -1, -1, -1, -1, -1, -1, -1,
2235 5, 6, 48, 8, 9, 10, 11, 12, 13, 14,
2236 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
2237 -1, -1, -1, -1, -1, -1, 113, -1, -1, 116,
2238 -1, -1, 119, -1, 121, -1, -1, -1, -1, -1,
2239 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
2240 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
2241 24, -1, -1, -1, -1, -1, -1, 113, -1, -1,
2242 116, -1, -1, 119, -1, 121, -1, -1, -1, -1,
2243 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
2244 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
2245 -1, 24, -1, -1, -1, -1, -1, -1, 113, -1,
2246 -1, 116, -1, -1, 119, -1, 121, -1, -1, -1,
2247 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
Reid Spencer21be8652006-10-22 07:03:43 +00002248 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
Reid Spencer1628cec2006-10-26 06:15:43 +00002249 22, -1, 24, -1, -1, -1, -1, -1, -1, 113,
2250 -1, -1, 116, -1, -1, 119, -1, 121, -1, -1,
2251 -1, -1, -1, -1, -1, -1, 48, -1, -1, -1,
Reid Spencer21be8652006-10-22 07:03:43 +00002252 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer21be8652006-10-22 07:03:43 +00002253 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
Reid Spencer1628cec2006-10-26 06:15:43 +00002254 113, -1, -1, 116, -1, -1, 119, -1, 121, -1,
2255 -1, -1, -1, 35, -1, -1, -1, -1, -1, -1,
2256 -1, -1, -1, -1, -1, -1, -1, 49, -1, -1,
2257 -1, -1, -1, -1, -1, -1, -1, 59, 60, -1,
2258 -1, 113, -1, -1, 116, -1, -1, 119, -1, 121,
2259 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
2260 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
2261 92, 93, 94, 95, 96, -1, -1, 99, 100, 101,
2262 102, 103, 104, 105, 106, 107, 108, 109, 110
Reid Spencer21be8652006-10-22 07:03:43 +00002263};
2264
2265/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2266 symbol of state STATE-NUM. */
2267static const unsigned char yystos[] =
2268{
Reid Spencer1628cec2006-10-26 06:15:43 +00002269 0, 156, 157, 158, 0, 25, 31, 41, 42, 43,
2270 44, 45, 46, 47, 62, 137, 175, 177, 179, 186,
2271 22, 24, 51, 58, 62, 136, 168, 179, 180, 61,
2272 64, 65, 66, 67, 68, 69, 70, 138, 173, 23,
2273 187, 188, 30, 122, 176, 187, 52, 53, 54, 71,
2274 165, 111, 61, 20, 45, 47, 50, 137, 111, 45,
2275 47, 178, 24, 163, 4, 5, 6, 8, 9, 10,
Reid Spencer21be8652006-10-22 07:03:43 +00002276 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
Reid Spencer1628cec2006-10-26 06:15:43 +00002277 21, 48, 113, 116, 119, 121, 126, 145, 146, 147,
2278 148, 149, 168, 183, 29, 121, 174, 136, 191, 111,
2279 111, 111, 111, 116, 166, 163, 145, 32, 33, 155,
2280 155, 155, 155, 173, 4, 4, 4, 8, 122, 149,
2281 150, 168, 114, 123, 35, 49, 59, 60, 72, 73,
Reid Spencer21be8652006-10-22 07:03:43 +00002282 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
2283 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
Reid Spencer1628cec2006-10-26 06:15:43 +00002284 94, 95, 96, 99, 100, 101, 102, 103, 104, 105,
2285 106, 107, 108, 109, 110, 128, 129, 130, 131, 189,
2286 195, 196, 198, 199, 24, 55, 56, 164, 4, 24,
2287 24, 167, 147, 147, 147, 9, 10, 11, 12, 13,
2288 14, 15, 16, 17, 18, 19, 132, 133, 135, 147,
2289 152, 117, 117, 112, 122, 114, 37, 150, 151, 147,
2290 185, 59, 8, 185, 9, 21, 10, 11, 12, 13,
2291 14, 15, 16, 17, 132, 133, 134, 138, 147, 147,
2292 185, 147, 147, 192, 185, 185, 185, 185, 185, 185,
2293 185, 185, 147, 147, 147, 185, 138, 97, 98, 112,
2294 118, 161, 162, 160, 27, 28, 3, 4, 127, 4,
2295 7, 26, 38, 39, 99, 101, 102, 106, 107, 108,
2296 116, 119, 121, 124, 128, 129, 130, 131, 153, 183,
2297 159, 149, 149, 149, 37, 147, 170, 171, 172, 112,
2298 115, 3, 4, 7, 26, 27, 28, 38, 39, 61,
2299 119, 153, 182, 183, 184, 184, 184, 184, 145, 112,
2300 140, 112, 140, 184, 116, 112, 36, 112, 112, 112,
2301 112, 112, 112, 112, 184, 184, 184, 112, 145, 147,
2302 185, 24, 112, 143, 143, 143, 114, 114, 114, 114,
2303 114, 114, 118, 152, 154, 154, 122, 154, 24, 114,
2304 114, 114, 114, 143, 118, 120, 168, 169, 112, 115,
2305 37, 63, 181, 154, 112, 112, 184, 15, 57, 15,
2306 112, 197, 184, 116, 147, 185, 147, 185, 185, 185,
2307 147, 147, 112, 112, 112, 185, 184, 184, 112, 34,
2308 57, 141, 144, 152, 152, 152, 152, 152, 152, 112,
2309 118, 120, 122, 152, 152, 152, 152, 37, 170, 141,
2310 142, 24, 120, 21, 21, 114, 184, 4, 184, 185,
2311 193, 112, 184, 112, 112, 112, 184, 184, 184, 114,
2312 147, 24, 4, 143, 197, 36, 112, 112, 112, 112,
2313 152, 112, 112, 112, 112, 57, 139, 112, 184, 184,
2314 193, 194, 112, 140, 140, 112, 184, 112, 185, 185,
2315 185, 194, 184, 115, 147, 152, 152, 152, 152, 152,
2316 152, 152, 152, 4, 24, 112, 116, 115, 185, 118,
2317 184, 115, 115, 112, 115, 112, 112, 115, 115, 115,
2318 115, 21, 118, 134, 190, 36, 118, 152, 152, 152,
2319 184, 182, 118, 134, 21, 115, 115, 115, 112, 182,
2320 184, 21, 112, 76, 184, 21, 21, 184, 184
Reid Spencer21be8652006-10-22 07:03:43 +00002321};
Reid Spencer68a24bd2005-08-27 18:50:39 +00002322
2323#define yyerrok (yyerrstatus = 0)
2324#define yyclearin (yychar = YYEMPTY)
Reid Spencer21be8652006-10-22 07:03:43 +00002325#define YYEMPTY (-2)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002326#define YYEOF 0
Reid Spencer21be8652006-10-22 07:03:43 +00002327
Reid Spencer68a24bd2005-08-27 18:50:39 +00002328#define YYACCEPT goto yyacceptlab
Reid Spencer21be8652006-10-22 07:03:43 +00002329#define YYABORT goto yyabortlab
2330#define YYERROR goto yyerrorlab
2331
2332
2333/* Like YYERROR except do call yyerror. This remains here temporarily
2334 to ease the transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00002335 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer21be8652006-10-22 07:03:43 +00002336
Reid Spencer68a24bd2005-08-27 18:50:39 +00002337#define YYFAIL goto yyerrlab
Reid Spencer21be8652006-10-22 07:03:43 +00002338
Reid Spencer68a24bd2005-08-27 18:50:39 +00002339#define YYRECOVERING() (!!yyerrstatus)
Reid Spencer21be8652006-10-22 07:03:43 +00002340
2341#define YYBACKUP(Token, Value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002342do \
2343 if (yychar == YYEMPTY && yylen == 1) \
Reid Spencer21be8652006-10-22 07:03:43 +00002344 { \
2345 yychar = (Token); \
2346 yylval = (Value); \
2347 yytoken = YYTRANSLATE (yychar); \
Reid Spencer5b7e7532006-09-28 19:28:24 +00002348 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00002349 goto yybackup; \
2350 } \
2351 else \
Reid Spencer21be8652006-10-22 07:03:43 +00002352 { \
2353 yyerror (YY_("syntax error: cannot back up")); \
2354 YYERROR; \
2355 } \
Reid Spencer5b7e7532006-09-28 19:28:24 +00002356while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002357
Reid Spencer21be8652006-10-22 07:03:43 +00002358
Reid Spencer68a24bd2005-08-27 18:50:39 +00002359#define YYTERROR 1
2360#define YYERRCODE 256
2361
Reid Spencer21be8652006-10-22 07:03:43 +00002362
2363/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2364 If N is 0, then set CURRENT to the empty location which ends
2365 the previous symbol: RHS[0] (always defined). */
2366
2367#define YYRHSLOC(Rhs, K) ((Rhs)[K])
2368#ifndef YYLLOC_DEFAULT
2369# define YYLLOC_DEFAULT(Current, Rhs, N) \
2370 do \
2371 if (N) \
2372 { \
2373 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2374 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2375 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2376 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2377 } \
2378 else \
2379 { \
2380 (Current).first_line = (Current).last_line = \
2381 YYRHSLOC (Rhs, 0).last_line; \
2382 (Current).first_column = (Current).last_column = \
2383 YYRHSLOC (Rhs, 0).last_column; \
2384 } \
2385 while (0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002386#endif
2387
Reid Spencer21be8652006-10-22 07:03:43 +00002388
2389/* YY_LOCATION_PRINT -- Print the location on the stream.
2390 This macro was not mandated originally: define only if we know
2391 we won't break user code: when these are the locations we know. */
2392
2393#ifndef YY_LOCATION_PRINT
2394# if YYLTYPE_IS_TRIVIAL
2395# define YY_LOCATION_PRINT(File, Loc) \
2396 fprintf (File, "%d.%d-%d.%d", \
2397 (Loc).first_line, (Loc).first_column, \
2398 (Loc).last_line, (Loc).last_column)
2399# else
2400# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2401# endif
2402#endif
2403
2404
2405/* YYLEX -- calling `yylex' with the right arguments. */
2406
Reid Spencer68a24bd2005-08-27 18:50:39 +00002407#ifdef YYLEX_PARAM
Reid Spencer21be8652006-10-22 07:03:43 +00002408# define YYLEX yylex (YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002409#else
Reid Spencer21be8652006-10-22 07:03:43 +00002410# define YYLEX yylex ()
Chris Lattner1ae022f2006-10-22 06:08:13 +00002411#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002412
2413/* Enable debugging if requested. */
2414#if YYDEBUG
2415
2416# ifndef YYFPRINTF
2417# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2418# define YYFPRINTF fprintf
2419# endif
2420
2421# define YYDPRINTF(Args) \
2422do { \
2423 if (yydebug) \
2424 YYFPRINTF Args; \
2425} while (0)
2426
2427# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2428do { \
2429 if (yydebug) \
2430 { \
2431 YYFPRINTF (stderr, "%s ", Title); \
2432 yysymprint (stderr, \
2433 Type, Value); \
2434 YYFPRINTF (stderr, "\n"); \
2435 } \
2436} while (0)
2437
2438/*------------------------------------------------------------------.
2439| yy_stack_print -- Print the state stack from its BOTTOM up to its |
2440| TOP (included). |
2441`------------------------------------------------------------------*/
2442
2443#if defined (__STDC__) || defined (__cplusplus)
2444static void
2445yy_stack_print (short int *bottom, short int *top)
Chris Lattner1ae022f2006-10-22 06:08:13 +00002446#else
Reid Spencer21be8652006-10-22 07:03:43 +00002447static void
2448yy_stack_print (bottom, top)
2449 short int *bottom;
2450 short int *top;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002451#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002452{
2453 YYFPRINTF (stderr, "Stack now");
2454 for (/* Nothing. */; bottom <= top; ++bottom)
2455 YYFPRINTF (stderr, " %d", *bottom);
2456 YYFPRINTF (stderr, "\n");
2457}
2458
2459# define YY_STACK_PRINT(Bottom, Top) \
2460do { \
2461 if (yydebug) \
2462 yy_stack_print ((Bottom), (Top)); \
2463} while (0)
2464
2465
2466/*------------------------------------------------.
2467| Report that the YYRULE is going to be reduced. |
2468`------------------------------------------------*/
2469
2470#if defined (__STDC__) || defined (__cplusplus)
2471static void
2472yy_reduce_print (int yyrule)
2473#else
2474static void
2475yy_reduce_print (yyrule)
2476 int yyrule;
Chris Lattner59c85e92006-10-15 23:27:25 +00002477#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002478{
2479 int yyi;
2480 unsigned long int yylno = yyrline[yyrule];
2481 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
2482 yyrule - 1, yylno);
2483 /* Print the symbols being reduced, and their result. */
2484 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
2485 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
2486 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
2487}
Reid Spencerb83eb642006-10-20 07:07:24 +00002488
Reid Spencer21be8652006-10-22 07:03:43 +00002489# define YY_REDUCE_PRINT(Rule) \
2490do { \
2491 if (yydebug) \
2492 yy_reduce_print (Rule); \
2493} while (0)
Reid Spencerb83eb642006-10-20 07:07:24 +00002494
Reid Spencer21be8652006-10-22 07:03:43 +00002495/* Nonzero means print parse trace. It is left uninitialized so that
2496 multiple parsers can coexist. */
2497int yydebug;
2498#else /* !YYDEBUG */
2499# define YYDPRINTF(Args)
2500# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
2501# define YY_STACK_PRINT(Bottom, Top)
2502# define YY_REDUCE_PRINT(Rule)
2503#endif /* !YYDEBUG */
Reid Spencerb83eb642006-10-20 07:07:24 +00002504
Reid Spencerb83eb642006-10-20 07:07:24 +00002505
Reid Spencer21be8652006-10-22 07:03:43 +00002506/* YYINITDEPTH -- initial size of the parser's stacks. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002507#ifndef YYINITDEPTH
Reid Spencer21be8652006-10-22 07:03:43 +00002508# define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002509#endif
2510
Reid Spencer21be8652006-10-22 07:03:43 +00002511/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2512 if the built-in stack extension method is used).
Reid Spencer68a24bd2005-08-27 18:50:39 +00002513
Reid Spencer21be8652006-10-22 07:03:43 +00002514 Do not make this value too large; the results are undefined if
2515 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
2516 evaluated with infinite-precision integer arithmetic. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002517
2518#ifndef YYMAXDEPTH
Reid Spencer21be8652006-10-22 07:03:43 +00002519# define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002520#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002521
Reid Spencer68a24bd2005-08-27 18:50:39 +00002522
2523
Reid Spencer21be8652006-10-22 07:03:43 +00002524#if YYERROR_VERBOSE
Reid Spencer68a24bd2005-08-27 18:50:39 +00002525
Reid Spencer21be8652006-10-22 07:03:43 +00002526# ifndef yystrlen
2527# if defined (__GLIBC__) && defined (_STRING_H)
2528# define yystrlen strlen
2529# else
2530/* Return the length of YYSTR. */
2531static YYSIZE_T
2532# if defined (__STDC__) || defined (__cplusplus)
2533yystrlen (const char *yystr)
2534# else
2535yystrlen (yystr)
2536 const char *yystr;
2537# endif
Chris Lattner1ae022f2006-10-22 06:08:13 +00002538{
Reid Spencer21be8652006-10-22 07:03:43 +00002539 const char *yys = yystr;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002540
Reid Spencer21be8652006-10-22 07:03:43 +00002541 while (*yys++ != '\0')
2542 continue;
2543
2544 return yys - yystr - 1;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002545}
Reid Spencer21be8652006-10-22 07:03:43 +00002546# endif
2547# endif
Chris Lattner1ae022f2006-10-22 06:08:13 +00002548
Reid Spencer21be8652006-10-22 07:03:43 +00002549# ifndef yystpcpy
2550# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2551# define yystpcpy stpcpy
2552# else
2553/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2554 YYDEST. */
2555static char *
2556# if defined (__STDC__) || defined (__cplusplus)
2557yystpcpy (char *yydest, const char *yysrc)
2558# else
2559yystpcpy (yydest, yysrc)
2560 char *yydest;
2561 const char *yysrc;
2562# endif
Chris Lattner1ae022f2006-10-22 06:08:13 +00002563{
Reid Spencer21be8652006-10-22 07:03:43 +00002564 char *yyd = yydest;
2565 const char *yys = yysrc;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002566
Reid Spencer21be8652006-10-22 07:03:43 +00002567 while ((*yyd++ = *yys++) != '\0')
2568 continue;
2569
2570 return yyd - 1;
Chris Lattner1ae022f2006-10-22 06:08:13 +00002571}
Reid Spencer21be8652006-10-22 07:03:43 +00002572# endif
2573# endif
Chris Lattner1ae022f2006-10-22 06:08:13 +00002574
Reid Spencer21be8652006-10-22 07:03:43 +00002575# ifndef yytnamerr
2576/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
2577 quotes and backslashes, so that it's suitable for yyerror. The
2578 heuristic is that double-quoting is unnecessary unless the string
2579 contains an apostrophe, a comma, or backslash (other than
2580 backslash-backslash). YYSTR is taken from yytname. If YYRES is
2581 null, do not copy; instead, return the length of what the result
2582 would have been. */
2583static YYSIZE_T
2584yytnamerr (char *yyres, const char *yystr)
2585{
2586 if (*yystr == '"')
2587 {
2588 size_t yyn = 0;
2589 char const *yyp = yystr;
2590
2591 for (;;)
2592 switch (*++yyp)
2593 {
2594 case '\'':
2595 case ',':
2596 goto do_not_strip_quotes;
2597
2598 case '\\':
2599 if (*++yyp != '\\')
2600 goto do_not_strip_quotes;
2601 /* Fall through. */
2602 default:
2603 if (yyres)
2604 yyres[yyn] = *yyp;
2605 yyn++;
2606 break;
2607
2608 case '"':
2609 if (yyres)
2610 yyres[yyn] = '\0';
2611 return yyn;
2612 }
2613 do_not_strip_quotes: ;
2614 }
2615
2616 if (! yyres)
2617 return yystrlen (yystr);
2618
2619 return yystpcpy (yyres, yystr) - yyres;
2620}
2621# endif
2622
2623#endif /* YYERROR_VERBOSE */
2624
Reid Spencerb83eb642006-10-20 07:07:24 +00002625
2626
Reid Spencer21be8652006-10-22 07:03:43 +00002627#if YYDEBUG
2628/*--------------------------------.
2629| Print this symbol on YYOUTPUT. |
2630`--------------------------------*/
Reid Spencerb83eb642006-10-20 07:07:24 +00002631
Reid Spencer21be8652006-10-22 07:03:43 +00002632#if defined (__STDC__) || defined (__cplusplus)
2633static void
2634yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
Chris Lattner1ae022f2006-10-22 06:08:13 +00002635#else
Reid Spencer21be8652006-10-22 07:03:43 +00002636static void
2637yysymprint (yyoutput, yytype, yyvaluep)
2638 FILE *yyoutput;
2639 int yytype;
2640 YYSTYPE *yyvaluep;
2641#endif
2642{
2643 /* Pacify ``unused variable'' warnings. */
2644 (void) yyvaluep;
2645
2646 if (yytype < YYNTOKENS)
2647 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
2648 else
2649 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
2650
2651
2652# ifdef YYPRINT
2653 if (yytype < YYNTOKENS)
2654 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
2655# endif
2656 switch (yytype)
2657 {
2658 default:
2659 break;
2660 }
2661 YYFPRINTF (yyoutput, ")");
2662}
2663
2664#endif /* ! YYDEBUG */
2665/*-----------------------------------------------.
2666| Release the memory associated to this symbol. |
2667`-----------------------------------------------*/
2668
2669#if defined (__STDC__) || defined (__cplusplus)
2670static void
2671yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
2672#else
2673static void
2674yydestruct (yymsg, yytype, yyvaluep)
2675 const char *yymsg;
2676 int yytype;
2677 YYSTYPE *yyvaluep;
2678#endif
2679{
2680 /* Pacify ``unused variable'' warnings. */
2681 (void) yyvaluep;
2682
2683 if (!yymsg)
2684 yymsg = "Deleting";
2685 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
2686
2687 switch (yytype)
2688 {
2689
2690 default:
2691 break;
2692 }
2693}
2694
2695
2696/* Prevent warnings from -Wmissing-prototypes. */
2697
2698#ifdef YYPARSE_PARAM
2699# if defined (__STDC__) || defined (__cplusplus)
2700int yyparse (void *YYPARSE_PARAM);
2701# else
2702int yyparse ();
2703# endif
2704#else /* ! YYPARSE_PARAM */
2705#if defined (__STDC__) || defined (__cplusplus)
Reid Spencere812fb22006-01-19 01:21:04 +00002706int yyparse (void);
Chris Lattner1ae022f2006-10-22 06:08:13 +00002707#else
Reid Spencer21be8652006-10-22 07:03:43 +00002708int yyparse ();
2709#endif
2710#endif /* ! YYPARSE_PARAM */
2711
2712
2713
2714/* The look-ahead symbol. */
2715int yychar;
2716
2717/* The semantic value of the look-ahead symbol. */
2718YYSTYPE yylval;
2719
2720/* Number of syntax errors so far. */
2721int yynerrs;
2722
2723
2724
2725/*----------.
2726| yyparse. |
2727`----------*/
2728
2729#ifdef YYPARSE_PARAM
2730# if defined (__STDC__) || defined (__cplusplus)
2731int yyparse (void *YYPARSE_PARAM)
2732# else
2733int yyparse (YYPARSE_PARAM)
2734 void *YYPARSE_PARAM;
2735# endif
2736#else /* ! YYPARSE_PARAM */
2737#if defined (__STDC__) || defined (__cplusplus)
2738int
2739yyparse (void)
2740#else
2741int
2742yyparse ()
2743
2744#endif
2745#endif
2746{
2747
2748 int yystate;
2749 int yyn;
2750 int yyresult;
2751 /* Number of tokens to shift before error messages enabled. */
2752 int yyerrstatus;
2753 /* Look-ahead token as an internal (translated) token number. */
2754 int yytoken = 0;
2755
2756 /* Three stacks and their tools:
2757 `yyss': related to states,
2758 `yyvs': related to semantic values,
2759 `yyls': related to locations.
2760
2761 Refer to the stacks thru separate pointers, to allow yyoverflow
2762 to reallocate them elsewhere. */
2763
2764 /* The state stack. */
2765 short int yyssa[YYINITDEPTH];
2766 short int *yyss = yyssa;
2767 short int *yyssp;
2768
2769 /* The semantic value stack. */
2770 YYSTYPE yyvsa[YYINITDEPTH];
2771 YYSTYPE *yyvs = yyvsa;
2772 YYSTYPE *yyvsp;
2773
2774
2775
Reid Spencer5b7e7532006-09-28 19:28:24 +00002776#define YYPOPSTACK (yyvsp--, yyssp--)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002777
Reid Spencer21be8652006-10-22 07:03:43 +00002778 YYSIZE_T yystacksize = YYINITDEPTH;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002779
Reid Spencer21be8652006-10-22 07:03:43 +00002780 /* The variables used to return semantic value and location from the
2781 action routines. */
2782 YYSTYPE yyval;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002783
2784
Reid Spencer21be8652006-10-22 07:03:43 +00002785 /* When reducing, the number of symbols on the RHS of the reduced
2786 rule. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002787 int yylen;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002788
Reid Spencer21be8652006-10-22 07:03:43 +00002789 YYDPRINTF ((stderr, "Starting parse\n"));
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002790
Reid Spencer68a24bd2005-08-27 18:50:39 +00002791 yystate = 0;
2792 yyerrstatus = 0;
2793 yynerrs = 0;
2794 yychar = YYEMPTY; /* Cause a token to be read. */
2795
2796 /* Initialize stack pointers.
2797 Waste one element of value and location stack
2798 so that they stay on the same level as the state stack.
2799 The wasted elements are never initialized. */
2800
Reid Spencer21be8652006-10-22 07:03:43 +00002801 yyssp = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002802 yyvsp = yyvs;
2803
Reid Spencer21be8652006-10-22 07:03:43 +00002804 goto yysetstate;
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002805
Reid Spencer21be8652006-10-22 07:03:43 +00002806/*------------------------------------------------------------.
2807| yynewstate -- Push a new state, which is found in yystate. |
2808`------------------------------------------------------------*/
2809 yynewstate:
2810 /* In all cases, when you get here, the value and location stacks
2811 have just been pushed. so pushing a state here evens the stacks.
2812 */
2813 yyssp++;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002814
Reid Spencer21be8652006-10-22 07:03:43 +00002815 yysetstate:
2816 *yyssp = yystate;
2817
2818 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002819 {
2820 /* Get the current used size of the three stacks, in elements. */
Reid Spencer21be8652006-10-22 07:03:43 +00002821 YYSIZE_T yysize = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002822
2823#ifdef yyoverflow
Reid Spencer21be8652006-10-22 07:03:43 +00002824 {
2825 /* Give user a chance to reallocate the stack. Use copies of
2826 these so that the &'s don't force the real ones into
2827 memory. */
2828 YYSTYPE *yyvs1 = yyvs;
2829 short int *yyss1 = yyss;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002830
Reid Spencer21be8652006-10-22 07:03:43 +00002831
2832 /* Each stack pointer address is followed by the size of the
2833 data in use in that stack, in bytes. This used to be a
2834 conditional around just the two extra args, but that might
2835 be undefined if yyoverflow is a macro. */
2836 yyoverflow (YY_("memory exhausted"),
2837 &yyss1, yysize * sizeof (*yyssp),
2838 &yyvs1, yysize * sizeof (*yyvsp),
2839
2840 &yystacksize);
2841
2842 yyss = yyss1;
2843 yyvs = yyvs1;
2844 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002845#else /* no yyoverflow */
Reid Spencer21be8652006-10-22 07:03:43 +00002846# ifndef YYSTACK_RELOCATE
2847 goto yyexhaustedlab;
2848# else
Reid Spencer68a24bd2005-08-27 18:50:39 +00002849 /* Extend the stack our own way. */
Reid Spencer21be8652006-10-22 07:03:43 +00002850 if (YYMAXDEPTH <= yystacksize)
2851 goto yyexhaustedlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002852 yystacksize *= 2;
Reid Spencer21be8652006-10-22 07:03:43 +00002853 if (YYMAXDEPTH < yystacksize)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002854 yystacksize = YYMAXDEPTH;
Reid Spencer21be8652006-10-22 07:03:43 +00002855
2856 {
2857 short int *yyss1 = yyss;
2858 union yyalloc *yyptr =
2859 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2860 if (! yyptr)
2861 goto yyexhaustedlab;
2862 YYSTACK_RELOCATE (yyss);
2863 YYSTACK_RELOCATE (yyvs);
2864
2865# undef YYSTACK_RELOCATE
2866 if (yyss1 != yyssa)
2867 YYSTACK_FREE (yyss1);
2868 }
2869# endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002870#endif /* no yyoverflow */
2871
Reid Spencer21be8652006-10-22 07:03:43 +00002872 yyssp = yyss + yysize - 1;
2873 yyvsp = yyvs + yysize - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002874
2875
Reid Spencer21be8652006-10-22 07:03:43 +00002876 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2877 (unsigned long int) yystacksize));
2878
2879 if (yyss + yystacksize - 1 <= yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002880 YYABORT;
2881 }
2882
Reid Spencer21be8652006-10-22 07:03:43 +00002883 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002884
2885 goto yybackup;
Reid Spencer21be8652006-10-22 07:03:43 +00002886
2887/*-----------.
2888| yybackup. |
2889`-----------*/
2890yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002891
Reid Spencer5b7e7532006-09-28 19:28:24 +00002892/* Do appropriate processing given the current state. */
Reid Spencer21be8652006-10-22 07:03:43 +00002893/* Read a look-ahead token if we need one and don't already have one. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002894/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002895
Reid Spencer21be8652006-10-22 07:03:43 +00002896 /* First try to decide what to do without reference to look-ahead token. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002897
Reid Spencer68a24bd2005-08-27 18:50:39 +00002898 yyn = yypact[yystate];
Reid Spencer21be8652006-10-22 07:03:43 +00002899 if (yyn == YYPACT_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002900 goto yydefault;
2901
Reid Spencer21be8652006-10-22 07:03:43 +00002902 /* Not known => get a look-ahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002903
Reid Spencer21be8652006-10-22 07:03:43 +00002904 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002905 if (yychar == YYEMPTY)
2906 {
Reid Spencer21be8652006-10-22 07:03:43 +00002907 YYDPRINTF ((stderr, "Reading a token: "));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002908 yychar = YYLEX;
2909 }
2910
Reid Spencer21be8652006-10-22 07:03:43 +00002911 if (yychar <= YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002912 {
Reid Spencer21be8652006-10-22 07:03:43 +00002913 yychar = yytoken = YYEOF;
2914 YYDPRINTF ((stderr, "Now at end of input.\n"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002915 }
2916 else
2917 {
Reid Spencer21be8652006-10-22 07:03:43 +00002918 yytoken = YYTRANSLATE (yychar);
2919 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002920 }
2921
Reid Spencer21be8652006-10-22 07:03:43 +00002922 /* If the proper action on seeing token YYTOKEN is to reduce or to
2923 detect an error, take that action. */
2924 yyn += yytoken;
2925 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002926 goto yydefault;
2927 yyn = yytable[yyn];
Reid Spencer21be8652006-10-22 07:03:43 +00002928 if (yyn <= 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002929 {
Reid Spencer21be8652006-10-22 07:03:43 +00002930 if (yyn == 0 || yyn == YYTABLE_NINF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002931 goto yyerrlab;
2932 yyn = -yyn;
2933 goto yyreduce;
2934 }
2935
2936 if (yyn == YYFINAL)
2937 YYACCEPT;
2938
Reid Spencer21be8652006-10-22 07:03:43 +00002939 /* Shift the look-ahead token. */
2940 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Reid Spencer5b7e7532006-09-28 19:28:24 +00002941
2942 /* Discard the token being shifted unless it is eof. */
2943 if (yychar != YYEOF)
2944 yychar = YYEMPTY;
2945
2946 *++yyvsp = yylval;
2947
Reid Spencer21be8652006-10-22 07:03:43 +00002948
2949 /* Count tokens shifted since error; after three, turn off error
2950 status. */
2951 if (yyerrstatus)
2952 yyerrstatus--;
Chris Lattner224f84f2006-08-18 17:34:45 +00002953
Reid Spencer68a24bd2005-08-27 18:50:39 +00002954 yystate = yyn;
2955 goto yynewstate;
2956
Chris Lattner1ae022f2006-10-22 06:08:13 +00002957
Reid Spencer21be8652006-10-22 07:03:43 +00002958/*-----------------------------------------------------------.
2959| yydefault -- do the default action for the current state. |
2960`-----------------------------------------------------------*/
2961yydefault:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002962 yyn = yydefact[yystate];
2963 if (yyn == 0)
2964 goto yyerrlab;
Reid Spencer21be8652006-10-22 07:03:43 +00002965 goto yyreduce;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002966
Reid Spencer21be8652006-10-22 07:03:43 +00002967
2968/*-----------------------------.
2969| yyreduce -- Do a reduction. |
2970`-----------------------------*/
Reid Spencer68a24bd2005-08-27 18:50:39 +00002971yyreduce:
Reid Spencer21be8652006-10-22 07:03:43 +00002972 /* yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002973 yylen = yyr2[yyn];
2974
Reid Spencer21be8652006-10-22 07:03:43 +00002975 /* If YYLEN is nonzero, implement the default value of the action:
2976 `$$ = $1'.
2977
2978 Otherwise, the following line sets YYVAL to garbage.
2979 This behavior is undocumented and Bison
2980 users should not rely upon it. Assigning to YYVAL
2981 unconditionally makes the parser a bit smaller, and it avoids a
2982 GCC warning that YYVAL may be used uninitialized. */
2983 yyval = yyvsp[1-yylen];
2984
2985
2986 YY_REDUCE_PRINT (yyn);
2987 switch (yyn)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002988 {
Reid Spencer21be8652006-10-22 07:03:43 +00002989 case 3:
Reid Spencer1628cec2006-10-26 06:15:43 +00002990#line 1135 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00002991 {
2992 if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00002993 GEN_ERROR("Value too large for type!");
Reid Spencer21be8652006-10-22 07:03:43 +00002994 (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00002995 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00002996;}
2997 break;
2998
2999 case 5:
Reid Spencer1628cec2006-10-26 06:15:43 +00003000#line 1144 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003001 {
3002 if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00003003 GEN_ERROR("Value too large for type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003004 (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003005 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003006;}
3007 break;
3008
Reid Spencer1628cec2006-10-26 06:15:43 +00003009 case 36:
3010#line 1168 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003011 {
3012 (yyval.StrVal) = (yyvsp[-1].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003013 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003014 ;}
3015 break;
3016
Reid Spencer1628cec2006-10-26 06:15:43 +00003017 case 37:
3018#line 1172 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003019 {
3020 (yyval.StrVal) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003021 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003022 ;}
3023 break;
3024
Reid Spencer1628cec2006-10-26 06:15:43 +00003025 case 38:
3026#line 1177 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003027 { (yyval.Linkage) = GlobalValue::InternalLinkage; ;}
3028 break;
3029
Reid Spencer1628cec2006-10-26 06:15:43 +00003030 case 39:
3031#line 1178 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003032 { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;}
3033 break;
3034
Reid Spencer1628cec2006-10-26 06:15:43 +00003035 case 40:
3036#line 1179 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003037 { (yyval.Linkage) = GlobalValue::WeakLinkage; ;}
3038 break;
3039
Reid Spencer1628cec2006-10-26 06:15:43 +00003040 case 41:
3041#line 1180 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003042 { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;}
3043 break;
3044
Reid Spencer1628cec2006-10-26 06:15:43 +00003045 case 42:
3046#line 1181 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003047 { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;}
3048 break;
3049
Reid Spencer1628cec2006-10-26 06:15:43 +00003050 case 43:
3051#line 1182 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003052 { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;}
3053 break;
3054
Reid Spencer1628cec2006-10-26 06:15:43 +00003055 case 44:
3056#line 1183 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003057 { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;}
3058 break;
3059
Reid Spencer1628cec2006-10-26 06:15:43 +00003060 case 45:
3061#line 1184 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003062 { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;}
3063 break;
3064
Reid Spencer21be8652006-10-22 07:03:43 +00003065 case 46:
Reid Spencer1628cec2006-10-26 06:15:43 +00003066#line 1186 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3067 { (yyval.UIntVal) = CallingConv::C; ;}
Reid Spencer21be8652006-10-22 07:03:43 +00003068 break;
3069
3070 case 47:
Reid Spencer1628cec2006-10-26 06:15:43 +00003071#line 1187 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3072 { (yyval.UIntVal) = CallingConv::C; ;}
Reid Spencer21be8652006-10-22 07:03:43 +00003073 break;
3074
3075 case 48:
Reid Spencer1628cec2006-10-26 06:15:43 +00003076#line 1188 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3077 { (yyval.UIntVal) = CallingConv::CSRet; ;}
Reid Spencer21be8652006-10-22 07:03:43 +00003078 break;
3079
3080 case 49:
Reid Spencer1628cec2006-10-26 06:15:43 +00003081#line 1189 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3082 { (yyval.UIntVal) = CallingConv::Fast; ;}
Reid Spencer21be8652006-10-22 07:03:43 +00003083 break;
3084
3085 case 50:
Reid Spencer1628cec2006-10-26 06:15:43 +00003086#line 1190 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3087 { (yyval.UIntVal) = CallingConv::Cold; ;}
Reid Spencer21be8652006-10-22 07:03:43 +00003088 break;
3089
3090 case 51:
Reid Spencer1628cec2006-10-26 06:15:43 +00003091#line 1191 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3092 { (yyval.UIntVal) = CallingConv::X86_StdCall; ;}
3093 break;
3094
3095 case 52:
3096#line 1192 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3097 { (yyval.UIntVal) = CallingConv::X86_FastCall; ;}
3098 break;
3099
3100 case 53:
3101#line 1193 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003102 {
3103 if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003104 GEN_ERROR("Calling conv too large!");
Reid Spencer21be8652006-10-22 07:03:43 +00003105 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003106 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003107 ;}
3108 break;
3109
Reid Spencer21be8652006-10-22 07:03:43 +00003110 case 54:
Reid Spencer1628cec2006-10-26 06:15:43 +00003111#line 1202 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003112 { (yyval.UIntVal) = 0; ;}
3113 break;
3114
3115 case 55:
Reid Spencer1628cec2006-10-26 06:15:43 +00003116#line 1203 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003117 {
3118 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3119 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003120 GEN_ERROR("Alignment must be a power of two!");
3121 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003122;}
3123 break;
3124
3125 case 56:
Reid Spencer1628cec2006-10-26 06:15:43 +00003126#line 1209 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3127 { (yyval.UIntVal) = 0; ;}
3128 break;
3129
3130 case 57:
3131#line 1210 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3132 {
3133 (yyval.UIntVal) = (yyvsp[0].UInt64Val);
3134 if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal)))
3135 GEN_ERROR("Alignment must be a power of two!");
3136 CHECK_FOR_ERROR
3137;}
3138 break;
3139
3140 case 58:
3141#line 1218 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003142 {
3143 for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i)
3144 if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\')
Reid Spencer61c83e02006-08-18 08:43:06 +00003145 GEN_ERROR("Invalid character in section name!");
Reid Spencer21be8652006-10-22 07:03:43 +00003146 (yyval.StrVal) = (yyvsp[0].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003147 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003148;}
3149 break;
3150
Reid Spencer1628cec2006-10-26 06:15:43 +00003151 case 59:
3152#line 1226 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003153 { (yyval.StrVal) = 0; ;}
3154 break;
3155
Reid Spencer1628cec2006-10-26 06:15:43 +00003156 case 60:
3157#line 1227 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003158 { (yyval.StrVal) = (yyvsp[0].StrVal); ;}
3159 break;
3160
Reid Spencer21be8652006-10-22 07:03:43 +00003161 case 61:
Reid Spencer1628cec2006-10-26 06:15:43 +00003162#line 1232 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3163 {;}
3164 break;
3165
3166 case 62:
3167#line 1233 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3168 {;}
3169 break;
3170
3171 case 63:
3172#line 1234 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003173 {
3174 CurGV->setSection((yyvsp[0].StrVal));
3175 free((yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003176 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003177 ;}
3178 break;
3179
Reid Spencer1628cec2006-10-26 06:15:43 +00003180 case 64:
3181#line 1239 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003182 {
3183 if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003184 GEN_ERROR("Alignment must be a power of two!");
Reid Spencer21be8652006-10-22 07:03:43 +00003185 CurGV->setAlignment((yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003186 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003187 ;}
3188 break;
3189
Reid Spencer21be8652006-10-22 07:03:43 +00003190 case 66:
Reid Spencer1628cec2006-10-26 06:15:43 +00003191#line 1253 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003192 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
3193 break;
3194
Reid Spencer1628cec2006-10-26 06:15:43 +00003195 case 68:
3196#line 1254 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3197 { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;}
3198 break;
3199
3200 case 69:
3201#line 1256 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003202 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003203 if (!UpRefs.empty())
Reid Spencer21be8652006-10-22 07:03:43 +00003204 GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription());
3205 (yyval.TypeVal) = (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003206 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003207 ;}
3208 break;
3209
Reid Spencer1628cec2006-10-26 06:15:43 +00003210 case 83:
3211#line 1268 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003212 {
3213 (yyval.TypeVal) = new PATypeHolder(OpaqueType::get());
Reid Spencer61c83e02006-08-18 08:43:06 +00003214 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003215 ;}
3216 break;
3217
Reid Spencer1628cec2006-10-26 06:15:43 +00003218 case 84:
3219#line 1272 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003220 {
3221 (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType));
Reid Spencer61c83e02006-08-18 08:43:06 +00003222 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003223 ;}
3224 break;
3225
Reid Spencer1628cec2006-10-26 06:15:43 +00003226 case 85:
3227#line 1276 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003228 { // Named types are also simple types...
3229 const Type* tmp = getTypeVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003230 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003231 (yyval.TypeVal) = new PATypeHolder(tmp);
3232;}
3233 break;
3234
Reid Spencer1628cec2006-10-26 06:15:43 +00003235 case 86:
3236#line 1284 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003237 { // Type UpReference
3238 if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003239 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Reid Spencer21be8652006-10-22 07:03:43 +00003240 UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector...
3241 (yyval.TypeVal) = new PATypeHolder(OT);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003242 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00003243 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003244 ;}
3245 break;
3246
Reid Spencer1628cec2006-10-26 06:15:43 +00003247 case 87:
3248#line 1292 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003249 { // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003250 std::vector<const Type*> Params;
Reid Spencer21be8652006-10-22 07:03:43 +00003251 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3252 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003253 Params.push_back(*I);
3254 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
3255 if (isVarArg) Params.pop_back();
3256
Reid Spencer21be8652006-10-22 07:03:43 +00003257 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg)));
3258 delete (yyvsp[-1].TypeList); // Delete the argument list
3259 delete (yyvsp[-3].TypeVal); // Delete the return type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003260 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003261 ;}
3262 break;
3263
Reid Spencer1628cec2006-10-26 06:15:43 +00003264 case 88:
3265#line 1305 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003266 { // Sized array type?
3267 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3268 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003269 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003270 ;}
3271 break;
3272
Reid Spencer1628cec2006-10-26 06:15:43 +00003273 case 89:
3274#line 1310 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003275 { // Packed array type?
3276 const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get();
3277 if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003278 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00003279 if (!ElemTy->isPrimitiveType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003280 GEN_ERROR("Elemental type of a PackedType must be primitive");
Reid Spencer21be8652006-10-22 07:03:43 +00003281 if (!isPowerOf2_32((yyvsp[-3].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003282 GEN_ERROR("Vector length should be a power of 2!");
Reid Spencer21be8652006-10-22 07:03:43 +00003283 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val))));
3284 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003285 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003286 ;}
3287 break;
3288
Reid Spencer1628cec2006-10-26 06:15:43 +00003289 case 90:
3290#line 1322 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003291 { // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00003292 std::vector<const Type*> Elements;
Reid Spencer21be8652006-10-22 07:03:43 +00003293 for (std::list<llvm::PATypeHolder>::iterator I = (yyvsp[-1].TypeList)->begin(),
3294 E = (yyvsp[-1].TypeList)->end(); I != E; ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003295 Elements.push_back(*I);
3296
Reid Spencer21be8652006-10-22 07:03:43 +00003297 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
3298 delete (yyvsp[-1].TypeList);
Reid Spencer61c83e02006-08-18 08:43:06 +00003299 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003300 ;}
3301 break;
3302
Reid Spencer1628cec2006-10-26 06:15:43 +00003303 case 91:
3304#line 1332 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003305 { // Empty structure type?
3306 (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer61c83e02006-08-18 08:43:06 +00003307 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003308 ;}
3309 break;
3310
Reid Spencer1628cec2006-10-26 06:15:43 +00003311 case 92:
3312#line 1336 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003313 { // Pointer type?
3314 if (*(yyvsp[-1].TypeVal) == Type::LabelTy)
Chris Lattner59c85e92006-10-15 23:27:25 +00003315 GEN_ERROR("Cannot form a pointer to a basic block");
Reid Spencer21be8652006-10-22 07:03:43 +00003316 (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal))));
3317 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003318 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003319 ;}
3320 break;
3321
Reid Spencer1628cec2006-10-26 06:15:43 +00003322 case 93:
3323#line 1347 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003324 {
3325 (yyval.TypeList) = new std::list<PATypeHolder>();
3326 (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003327 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003328 ;}
3329 break;
3330
Reid Spencer1628cec2006-10-26 06:15:43 +00003331 case 94:
3332#line 1352 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003333 {
3334 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003335 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003336 ;}
3337 break;
3338
Reid Spencer1628cec2006-10-26 06:15:43 +00003339 case 96:
3340#line 1359 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003341 {
3342 ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy);
Reid Spencer61c83e02006-08-18 08:43:06 +00003343 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003344 ;}
3345 break;
3346
Reid Spencer1628cec2006-10-26 06:15:43 +00003347 case 97:
3348#line 1363 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003349 {
3350 ((yyval.TypeList) = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Reid Spencer61c83e02006-08-18 08:43:06 +00003351 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003352 ;}
3353 break;
3354
Reid Spencer1628cec2006-10-26 06:15:43 +00003355 case 98:
3356#line 1367 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003357 {
3358 (yyval.TypeList) = new std::list<PATypeHolder>();
Reid Spencer61c83e02006-08-18 08:43:06 +00003359 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003360 ;}
3361 break;
3362
Reid Spencer1628cec2006-10-26 06:15:43 +00003363 case 99:
3364#line 1378 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003365 { // Nonempty unsized arr
3366 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003367 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003368 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003369 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003370 const Type *ETy = ATy->getElementType();
3371 int NumElements = ATy->getNumElements();
3372
3373 // Verify that we have the correct size...
Reid Spencer21be8652006-10-22 07:03:43 +00003374 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00003375 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Reid Spencer21be8652006-10-22 07:03:43 +00003376 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003377 itostr(NumElements) + "!");
3378
3379 // Verify all elements are correct type!
Reid Spencer21be8652006-10-22 07:03:43 +00003380 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3381 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003382 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003383 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer21be8652006-10-22 07:03:43 +00003384 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003385 }
3386
Reid Spencer21be8652006-10-22 07:03:43 +00003387 (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector));
3388 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003389 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003390 ;}
3391 break;
3392
Reid Spencer1628cec2006-10-26 06:15:43 +00003393 case 100:
3394#line 1404 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003395 {
3396 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003397 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003398 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003399 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003400
3401 int NumElements = ATy->getNumElements();
3402 if (NumElements != -1 && NumElements != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003403 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencer68a24bd2005-08-27 18:50:39 +00003404 " arguments, but has size of " + itostr(NumElements) +"!");
Reid Spencer21be8652006-10-22 07:03:43 +00003405 (yyval.ConstVal) = ConstantArray::get(ATy, std::vector<Constant*>());
3406 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003407 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003408 ;}
3409 break;
3410
Reid Spencer1628cec2006-10-26 06:15:43 +00003411 case 101:
3412#line 1418 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003413 {
3414 const ArrayType *ATy = dyn_cast<ArrayType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003415 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003416 GEN_ERROR("Cannot make array constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003417 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003418
3419 int NumElements = ATy->getNumElements();
3420 const Type *ETy = ATy->getElementType();
Reid Spencer21be8652006-10-22 07:03:43 +00003421 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
3422 if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003423 GEN_ERROR("Can't build string constant of size " +
Reid Spencer21be8652006-10-22 07:03:43 +00003424 itostr((int)(EndStr-(yyvsp[0].StrVal))) +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003425 " when array has size " + itostr(NumElements) + "!");
3426 std::vector<Constant*> Vals;
3427 if (ETy == Type::SByteTy) {
Reid Spencer21be8652006-10-22 07:03:43 +00003428 for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00003429 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003430 } else if (ETy == Type::UByteTy) {
Reid Spencer21be8652006-10-22 07:03:43 +00003431 for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003432 C != (unsigned char*)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00003433 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003434 } else {
Reid Spencer21be8652006-10-22 07:03:43 +00003435 free((yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003436 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003437 }
Reid Spencer21be8652006-10-22 07:03:43 +00003438 free((yyvsp[0].StrVal));
3439 (yyval.ConstVal) = ConstantArray::get(ATy, Vals);
3440 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003441 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003442 ;}
3443 break;
3444
Reid Spencer1628cec2006-10-26 06:15:43 +00003445 case 102:
3446#line 1448 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003447 { // Nonempty unsized arr
3448 const PackedType *PTy = dyn_cast<PackedType>((yyvsp[-3].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003449 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003450 GEN_ERROR("Cannot make packed constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003451 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003452 const Type *ETy = PTy->getElementType();
3453 int NumElements = PTy->getNumElements();
3454
3455 // Verify that we have the correct size...
Reid Spencer21be8652006-10-22 07:03:43 +00003456 if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00003457 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Reid Spencer21be8652006-10-22 07:03:43 +00003458 utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003459 itostr(NumElements) + "!");
3460
3461 // Verify all elements are correct type!
Reid Spencer21be8652006-10-22 07:03:43 +00003462 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
3463 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003464 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003465 ETy->getDescription() +"' as required!\nIt is of type '"+
Reid Spencer21be8652006-10-22 07:03:43 +00003466 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003467 }
3468
Reid Spencer21be8652006-10-22 07:03:43 +00003469 (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector));
3470 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003471 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003472 ;}
3473 break;
3474
Reid Spencer1628cec2006-10-26 06:15:43 +00003475 case 103:
3476#line 1474 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003477 {
3478 const StructType *STy = dyn_cast<StructType>((yyvsp[-3].TypeVal)->get());
Reid Spencer61c83e02006-08-18 08:43:06 +00003479 if (STy == 0)
3480 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003481 (*(yyvsp[-3].TypeVal))->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003482
Reid Spencer21be8652006-10-22 07:03:43 +00003483 if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes())
Reid Spencer61c83e02006-08-18 08:43:06 +00003484 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003485
3486 // Check to ensure that constants are compatible with the type initializer!
Reid Spencer21be8652006-10-22 07:03:43 +00003487 for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i)
3488 if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i))
Reid Spencer61c83e02006-08-18 08:43:06 +00003489 GEN_ERROR("Expected type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003490 STy->getElementType(i)->getDescription() +
3491 "' for element #" + utostr(i) +
3492 " of structure initializer!");
3493
Reid Spencer21be8652006-10-22 07:03:43 +00003494 (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector));
3495 delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00003496 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003497 ;}
3498 break;
3499
Reid Spencer1628cec2006-10-26 06:15:43 +00003500 case 104:
3501#line 1495 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003502 {
3503 const StructType *STy = dyn_cast<StructType>((yyvsp[-2].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003504 if (STy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003505 GEN_ERROR("Cannot make struct constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003506 (*(yyvsp[-2].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003507
3508 if (STy->getNumContainedTypes() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003509 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003510
Reid Spencer21be8652006-10-22 07:03:43 +00003511 (yyval.ConstVal) = ConstantStruct::get(STy, std::vector<Constant*>());
3512 delete (yyvsp[-2].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003513 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003514 ;}
3515 break;
3516
Reid Spencer1628cec2006-10-26 06:15:43 +00003517 case 105:
3518#line 1508 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003519 {
3520 const PointerType *PTy = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003521 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003522 GEN_ERROR("Cannot make null pointer constant with type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003523 (*(yyvsp[-1].TypeVal))->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003524
Reid Spencer21be8652006-10-22 07:03:43 +00003525 (yyval.ConstVal) = ConstantPointerNull::get(PTy);
3526 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003527 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003528 ;}
3529 break;
3530
Reid Spencer1628cec2006-10-26 06:15:43 +00003531 case 106:
3532#line 1518 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003533 {
3534 (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get());
3535 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003536 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003537 ;}
3538 break;
3539
Reid Spencer1628cec2006-10-26 06:15:43 +00003540 case 107:
3541#line 1523 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003542 {
3543 const PointerType *Ty = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003544 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00003545 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003546
3547 // ConstExprs can exist in the body of a function, thus creating
3548 // GlobalValues whenever they refer to a variable. Because we are in
3549 // the context of a function, getValNonImprovising will search the functions
3550 // symbol table instead of the module symbol table for the global symbol,
3551 // which throws things all off. To get around this, we just tell
3552 // getValNonImprovising that we are at global scope here.
3553 //
3554 Function *SavedCurFn = CurFun.CurrentFunction;
3555 CurFun.CurrentFunction = 0;
3556
Reid Spencer21be8652006-10-22 07:03:43 +00003557 Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00003558 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003559
3560 CurFun.CurrentFunction = SavedCurFn;
3561
3562 // If this is an initializer for a constant pointer, which is referencing a
3563 // (currently) undefined variable, create a stub now that shall be replaced
3564 // in the future with the right type of variable.
3565 //
3566 if (V == 0) {
3567 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3568 const PointerType *PT = cast<PointerType>(Ty);
3569
3570 // First check to see if the forward references value is already created!
3571 PerModuleInfo::GlobalRefsType::iterator I =
Reid Spencer21be8652006-10-22 07:03:43 +00003572 CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal)));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003573
3574 if (I != CurModule.GlobalRefs.end()) {
3575 V = I->second; // Placeholder already exists, use it...
Reid Spencer21be8652006-10-22 07:03:43 +00003576 (yyvsp[0].ValIDVal).destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003577 } else {
3578 std::string Name;
Reid Spencer21be8652006-10-22 07:03:43 +00003579 if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003580
3581 // Create the forward referenced global.
3582 GlobalValue *GV;
3583 if (const FunctionType *FTy =
3584 dyn_cast<FunctionType>(PT->getElementType())) {
3585 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
3586 CurModule.CurrentModule);
3587 } else {
3588 GV = new GlobalVariable(PT->getElementType(), false,
3589 GlobalValue::ExternalLinkage, 0,
3590 Name, CurModule.CurrentModule);
3591 }
3592
3593 // Keep track of the fact that we have a forward ref to recycle it
Reid Spencer21be8652006-10-22 07:03:43 +00003594 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003595 V = GV;
3596 }
3597 }
3598
Reid Spencer21be8652006-10-22 07:03:43 +00003599 (yyval.ConstVal) = cast<GlobalValue>(V);
3600 delete (yyvsp[-1].TypeVal); // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00003601 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003602 ;}
3603 break;
3604
Reid Spencer1628cec2006-10-26 06:15:43 +00003605 case 108:
3606#line 1584 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003607 {
3608 if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003609 GEN_ERROR("Mismatched types for constant expression!");
Reid Spencer21be8652006-10-22 07:03:43 +00003610 (yyval.ConstVal) = (yyvsp[0].ConstVal);
3611 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003612 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003613 ;}
3614 break;
3615
Reid Spencer1628cec2006-10-26 06:15:43 +00003616 case 109:
3617#line 1591 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003618 {
3619 const Type *Ty = (yyvsp[-1].TypeVal)->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003620 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +00003621 GEN_ERROR("Cannot create a null initialized value of this type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003622 (yyval.ConstVal) = Constant::getNullValue(Ty);
3623 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003624 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003625 ;}
3626 break;
3627
Reid Spencer1628cec2006-10-26 06:15:43 +00003628 case 110:
3629#line 1600 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003630 { // integral constants
3631 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003632 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003633 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003634 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003635 ;}
3636 break;
3637
Reid Spencer1628cec2006-10-26 06:15:43 +00003638 case 111:
3639#line 1606 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003640 { // integral constants
3641 if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003642 GEN_ERROR("Constant value doesn't fit in type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003643 (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00003644 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003645 ;}
3646 break;
3647
Reid Spencer1628cec2006-10-26 06:15:43 +00003648 case 112:
3649#line 1612 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003650 { // Boolean constants
3651 (yyval.ConstVal) = ConstantBool::getTrue();
Reid Spencer61c83e02006-08-18 08:43:06 +00003652 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003653 ;}
3654 break;
3655
Reid Spencer1628cec2006-10-26 06:15:43 +00003656 case 113:
3657#line 1616 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003658 { // Boolean constants
3659 (yyval.ConstVal) = ConstantBool::getFalse();
Reid Spencer61c83e02006-08-18 08:43:06 +00003660 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003661 ;}
3662 break;
3663
Reid Spencer1628cec2006-10-26 06:15:43 +00003664 case 114:
3665#line 1620 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003666 { // Float & Double constants
3667 if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003668 GEN_ERROR("Floating point constant invalid for type!!");
Reid Spencer21be8652006-10-22 07:03:43 +00003669 (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003670 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003671 ;}
3672 break;
3673
Reid Spencer1628cec2006-10-26 06:15:43 +00003674 case 115:
3675#line 1628 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003676 {
3677 if (!(yyvsp[-3].ConstVal)->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003678 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003679 (yyvsp[-3].ConstVal)->getType()->getDescription() + "'!");
3680 if (!(yyvsp[-1].TypeVal)->get()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003681 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00003682 (yyvsp[-1].TypeVal)->get()->getDescription() + "'!");
3683 (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get());
3684 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003685 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003686 ;}
3687 break;
3688
Reid Spencer1628cec2006-10-26 06:15:43 +00003689 case 116:
3690#line 1639 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003691 {
3692 if (!isa<PointerType>((yyvsp[-2].ConstVal)->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00003693 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003694
3695 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3696 // indices to uint struct indices for compatibility.
3697 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer21be8652006-10-22 07:03:43 +00003698 GTI = gep_type_begin((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end()),
3699 GTE = gep_type_end((yyvsp[-2].ConstVal)->getType(), (yyvsp[-1].ValueList)->begin(), (yyvsp[-1].ValueList)->end());
3700 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003701 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer21be8652006-10-22 07:03:43 +00003702 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003703 if (CUI->getType() == Type::UByteTy)
Reid Spencer21be8652006-10-22 07:03:43 +00003704 (*(yyvsp[-1].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003705
3706 const Type *IdxTy =
Reid Spencer21be8652006-10-22 07:03:43 +00003707 GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003708 if (!IdxTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003709 GEN_ERROR("Index list invalid for constant getelementptr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003710
3711 std::vector<Constant*> IdxVec;
Reid Spencer21be8652006-10-22 07:03:43 +00003712 for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i)
3713 if (Constant *C = dyn_cast<Constant>((*(yyvsp[-1].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003714 IdxVec.push_back(C);
3715 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003716 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003717
Reid Spencer21be8652006-10-22 07:03:43 +00003718 delete (yyvsp[-1].ValueList);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003719
Reid Spencer21be8652006-10-22 07:03:43 +00003720 (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec);
Reid Spencer61c83e02006-08-18 08:43:06 +00003721 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003722 ;}
3723 break;
3724
Reid Spencer1628cec2006-10-26 06:15:43 +00003725 case 117:
3726#line 1671 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003727 {
3728 if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003729 GEN_ERROR("Select condition must be of boolean type!");
Reid Spencer21be8652006-10-22 07:03:43 +00003730 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003731 GEN_ERROR("Select operand types must match!");
Reid Spencer21be8652006-10-22 07:03:43 +00003732 (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003733 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003734 ;}
3735 break;
3736
Reid Spencer1628cec2006-10-26 06:15:43 +00003737 case 118:
3738#line 1679 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003739 {
3740 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003741 GEN_ERROR("Binary operator types must match!");
Reid Spencer1628cec2006-10-26 06:15:43 +00003742 // First, make sure we're dealing with the right opcode by upgrading from
3743 // obsolete versions.
3744 sanitizeOpCode((yyvsp[-5].BinaryOpVal),(yyvsp[-3].ConstVal)->getType());
3745 CHECK_FOR_ERROR;
3746
Reid Spencer68a24bd2005-08-27 18:50:39 +00003747 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3748 // To retain backward compatibility with these early compilers, we emit a
3749 // cast to the appropriate integer type automatically if we are in the
3750 // broken case. See PR424 for more information.
Reid Spencer21be8652006-10-22 07:03:43 +00003751 if (!isa<PointerType>((yyvsp[-3].ConstVal)->getType())) {
Reid Spencer1628cec2006-10-26 06:15:43 +00003752 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003753 } else {
3754 const Type *IntPtrTy = 0;
3755 switch (CurModule.CurrentModule->getPointerSize()) {
3756 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3757 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer61c83e02006-08-18 08:43:06 +00003758 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003759 }
Reid Spencer1628cec2006-10-26 06:15:43 +00003760 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, ConstantExpr::getCast((yyvsp[-3].ConstVal), IntPtrTy),
Reid Spencer21be8652006-10-22 07:03:43 +00003761 ConstantExpr::getCast((yyvsp[-1].ConstVal), IntPtrTy));
3762 (yyval.ConstVal) = ConstantExpr::getCast((yyval.ConstVal), (yyvsp[-3].ConstVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003763 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003764 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003765 ;}
3766 break;
3767
Reid Spencer1628cec2006-10-26 06:15:43 +00003768 case 119:
3769#line 1706 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003770 {
3771 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003772 GEN_ERROR("Logical operator types must match!");
Reid Spencer21be8652006-10-22 07:03:43 +00003773 if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) {
3774 if (!isa<PackedType>((yyvsp[-3].ConstVal)->getType()) ||
3775 !cast<PackedType>((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00003776 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00003777 }
Reid Spencer1628cec2006-10-26 06:15:43 +00003778 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003779 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003780 ;}
3781 break;
3782
3783 case 120:
Reid Spencer1628cec2006-10-26 06:15:43 +00003784#line 1717 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3785 {
3786 if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType())
3787 GEN_ERROR("setcc operand types must match!");
3788 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3789 CHECK_FOR_ERROR
3790 ;}
3791 break;
3792
3793 case 121:
3794#line 1723 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3795 {
3796 if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy)
3797 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
3798 if (!(yyvsp[-3].ConstVal)->getType()->isInteger())
3799 GEN_ERROR("Shift constant expression requires integer operand!");
3800 (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal).opcode, (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
3801 CHECK_FOR_ERROR
3802 ;}
3803 break;
3804
3805 case 122:
3806#line 1731 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003807 {
3808 if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003809 GEN_ERROR("Invalid extractelement operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00003810 (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003811 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003812 ;}
3813 break;
3814
Reid Spencer1628cec2006-10-26 06:15:43 +00003815 case 123:
3816#line 1737 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003817 {
3818 if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003819 GEN_ERROR("Invalid insertelement operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00003820 (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003821 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003822 ;}
3823 break;
3824
Reid Spencer1628cec2006-10-26 06:15:43 +00003825 case 124:
3826#line 1743 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003827 {
3828 if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00003829 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00003830 (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003831 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003832 ;}
3833 break;
3834
Reid Spencer1628cec2006-10-26 06:15:43 +00003835 case 125:
3836#line 1752 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003837 {
3838 ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003839 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003840 ;}
3841 break;
3842
Reid Spencer1628cec2006-10-26 06:15:43 +00003843 case 126:
3844#line 1756 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003845 {
3846 (yyval.ConstVector) = new std::vector<Constant*>();
3847 (yyval.ConstVector)->push_back((yyvsp[0].ConstVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00003848 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003849 ;}
3850 break;
3851
Reid Spencer1628cec2006-10-26 06:15:43 +00003852 case 127:
3853#line 1764 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003854 { (yyval.BoolVal) = false; ;}
3855 break;
3856
Reid Spencer1628cec2006-10-26 06:15:43 +00003857 case 128:
3858#line 1764 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003859 { (yyval.BoolVal) = true; ;}
3860 break;
3861
Reid Spencer1628cec2006-10-26 06:15:43 +00003862 case 129:
3863#line 1774 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003864 {
3865 (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003866 CurModule.ModuleDone();
Reid Spencerf63697d2006-10-09 17:36:59 +00003867 CHECK_FOR_ERROR;
Reid Spencer21be8652006-10-22 07:03:43 +00003868;}
3869 break;
3870
Reid Spencer1628cec2006-10-26 06:15:43 +00003871 case 130:
3872#line 1782 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003873 {
3874 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003875 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003876 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003877 ;}
3878 break;
3879
Reid Spencer21be8652006-10-22 07:03:43 +00003880 case 131:
Reid Spencer1628cec2006-10-26 06:15:43 +00003881#line 1787 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003882 {
3883 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00003884 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003885 ;}
3886 break;
3887
3888 case 132:
Reid Spencer1628cec2006-10-26 06:15:43 +00003889#line 1791 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3890 {
3891 (yyval.ModuleVal) = (yyvsp[-3].ModuleVal);
3892 CHECK_FOR_ERROR
3893 ;}
3894 break;
3895
3896 case 133:
3897#line 1795 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3898 {
3899 (yyval.ModuleVal) = (yyvsp[-1].ModuleVal);
3900 CHECK_FOR_ERROR
3901 ;}
3902 break;
3903
3904 case 134:
3905#line 1799 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003906 {
3907 (yyval.ModuleVal) = CurModule.CurrentModule;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003908 // Emit an error if there are any unresolved types left.
3909 if (!CurModule.LateResolveTypes.empty()) {
3910 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00003911 if (DID.Type == ValID::NameVal) {
3912 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3913 } else {
3914 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3915 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003916 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003917 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003918 ;}
3919 break;
3920
Reid Spencer1628cec2006-10-26 06:15:43 +00003921 case 135:
3922#line 1814 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003923 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003924 // Eagerly resolve types. This is not an optimization, this is a
3925 // requirement that is due to the fact that we could have this:
3926 //
3927 // %list = type { %list * }
3928 // %list = type { %list * } ; repeated type decl
3929 //
3930 // If types are not resolved eagerly, then the two types will not be
3931 // determined to be the same type!
3932 //
Reid Spencer21be8652006-10-22 07:03:43 +00003933 ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003934
Reid Spencer21be8652006-10-22 07:03:43 +00003935 if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003936 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003937 // If this is a named type that is not a redefinition, add it to the slot
3938 // table.
Reid Spencer21be8652006-10-22 07:03:43 +00003939 CurModule.Types.push_back(*(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00003940 }
3941
Reid Spencer21be8652006-10-22 07:03:43 +00003942 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003943 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003944 ;}
3945 break;
3946
Reid Spencer1628cec2006-10-26 06:15:43 +00003947 case 136:
3948#line 1836 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003949 { // Function prototypes can be in const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00003950 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003951 ;}
3952 break;
3953
Reid Spencer1628cec2006-10-26 06:15:43 +00003954 case 137:
3955#line 1839 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003956 { // Asm blocks can be in the const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00003957 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003958 ;}
3959 break;
3960
Reid Spencer1628cec2006-10-26 06:15:43 +00003961 case 138:
3962#line 1842 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003963 {
3964 if ((yyvsp[0].ConstVal) == 0)
Reid Spencer5b7e7532006-09-28 19:28:24 +00003965 GEN_ERROR("Global value initializer is not a constant!");
Reid Spencer21be8652006-10-22 07:03:43 +00003966 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 +00003967 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003968 ;}
3969 break;
3970
Reid Spencer1628cec2006-10-26 06:15:43 +00003971 case 139:
3972#line 1847 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003973 {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003974 CurGV = 0;
Reid Spencer21be8652006-10-22 07:03:43 +00003975 ;}
3976 break;
3977
Reid Spencer1628cec2006-10-26 06:15:43 +00003978 case 140:
3979#line 1850 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003980 {
3981 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003982 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003983 delete (yyvsp[0].TypeVal);
3984 ;}
3985 break;
3986
Reid Spencer21be8652006-10-22 07:03:43 +00003987 case 141:
Reid Spencer1628cec2006-10-26 06:15:43 +00003988#line 1854 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00003989 {
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00003990 CurGV = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003991 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00003992 ;}
3993 break;
3994
3995 case 142:
Reid Spencer1628cec2006-10-26 06:15:43 +00003996#line 1858 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
3997 {
3998 CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
3999 CHECK_FOR_ERROR
4000 delete (yyvsp[0].TypeVal);
4001 ;}
4002 break;
4003
4004 case 143:
4005#line 1862 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4006 {
4007 CurGV = 0;
4008 CHECK_FOR_ERROR
4009 ;}
4010 break;
4011
4012 case 144:
4013#line 1866 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004014 {
Reid Spencer5b7e7532006-09-28 19:28:24 +00004015 CurGV =
Reid Spencer21be8652006-10-22 07:03:43 +00004016 ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004017 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004018 delete (yyvsp[0].TypeVal);
4019 ;}
4020 break;
4021
Reid Spencer1628cec2006-10-26 06:15:43 +00004022 case 145:
4023#line 1871 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004024 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004025 CurGV = 0;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004026 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004027 ;}
4028 break;
4029
Reid Spencer1628cec2006-10-26 06:15:43 +00004030 case 146:
4031#line 1875 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004032 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004033 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004034 ;}
4035 break;
4036
Reid Spencer1628cec2006-10-26 06:15:43 +00004037 case 147:
4038#line 1878 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004039 {
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00004040 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004041 ;}
4042 break;
4043
Reid Spencer1628cec2006-10-26 06:15:43 +00004044 case 148:
4045#line 1881 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004046 {
4047 ;}
4048 break;
4049
Reid Spencer1628cec2006-10-26 06:15:43 +00004050 case 149:
4051#line 1885 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004052 {
Chris Lattner66316012006-01-24 04:14:29 +00004053 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Reid Spencer21be8652006-10-22 07:03:43 +00004054 char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true);
4055 std::string NewAsm((yyvsp[0].StrVal), EndStr);
4056 free((yyvsp[0].StrVal));
Chris Lattner66316012006-01-24 04:14:29 +00004057
4058 if (AsmSoFar.empty())
4059 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
4060 else
4061 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00004062 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004063;}
4064 break;
4065
Reid Spencer1628cec2006-10-26 06:15:43 +00004066 case 150:
4067#line 1898 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004068 { (yyval.Endianness) = Module::BigEndian; ;}
4069 break;
4070
Reid Spencer1628cec2006-10-26 06:15:43 +00004071 case 151:
4072#line 1899 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004073 { (yyval.Endianness) = Module::LittleEndian; ;}
4074 break;
4075
Reid Spencer1628cec2006-10-26 06:15:43 +00004076 case 152:
4077#line 1901 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004078 {
4079 CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness));
Reid Spencer61c83e02006-08-18 08:43:06 +00004080 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004081 ;}
4082 break;
4083
Reid Spencer1628cec2006-10-26 06:15:43 +00004084 case 153:
4085#line 1905 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004086 {
4087 if ((yyvsp[0].UInt64Val) == 32)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004088 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Reid Spencer21be8652006-10-22 07:03:43 +00004089 else if ((yyvsp[0].UInt64Val) == 64)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004090 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
4091 else
Reid Spencer21be8652006-10-22 07:03:43 +00004092 GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00004093 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004094 ;}
4095 break;
4096
Reid Spencer1628cec2006-10-26 06:15:43 +00004097 case 154:
4098#line 1914 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004099 {
4100 CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal));
4101 free((yyvsp[0].StrVal));
4102 ;}
4103 break;
4104
Reid Spencer1628cec2006-10-26 06:15:43 +00004105 case 155:
4106#line 1918 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004107 {
4108 CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal));
4109 free((yyvsp[0].StrVal));
4110 ;}
4111 break;
4112
Reid Spencer21be8652006-10-22 07:03:43 +00004113 case 157:
Reid Spencer1628cec2006-10-26 06:15:43 +00004114#line 1925 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4115 {
4116 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4117 free((yyvsp[0].StrVal));
4118 CHECK_FOR_ERROR
4119 ;}
4120 break;
4121
4122 case 158:
4123#line 1930 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4124 {
4125 CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal));
4126 free((yyvsp[0].StrVal));
4127 CHECK_FOR_ERROR
4128 ;}
4129 break;
4130
4131 case 159:
4132#line 1935 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004133 {
Reid Spencer61c83e02006-08-18 08:43:06 +00004134 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004135 ;}
4136 break;
4137
Reid Spencer1628cec2006-10-26 06:15:43 +00004138 case 163:
4139#line 1945 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004140 { (yyval.StrVal) = 0; ;}
4141 break;
4142
Reid Spencer1628cec2006-10-26 06:15:43 +00004143 case 164:
4144#line 1947 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004145 {
4146 if (*(yyvsp[-1].TypeVal) == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004147 GEN_ERROR("void typed arguments are invalid!");
Reid Spencer21be8652006-10-22 07:03:43 +00004148 (yyval.ArgVal) = new std::pair<PATypeHolder*, char*>((yyvsp[-1].TypeVal), (yyvsp[0].StrVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004149 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004150;}
4151 break;
4152
Reid Spencer1628cec2006-10-26 06:15:43 +00004153 case 165:
4154#line 1954 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004155 {
4156 (yyval.ArgList) = (yyvsp[-2].ArgList);
4157 (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal));
4158 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004159 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004160 ;}
4161 break;
4162
Reid Spencer1628cec2006-10-26 06:15:43 +00004163 case 166:
4164#line 1960 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004165 {
4166 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4167 (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal));
4168 delete (yyvsp[0].ArgVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004169 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004170 ;}
4171 break;
4172
Reid Spencer1628cec2006-10-26 06:15:43 +00004173 case 167:
4174#line 1967 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004175 {
4176 (yyval.ArgList) = (yyvsp[0].ArgList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004177 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004178 ;}
4179 break;
4180
Reid Spencer1628cec2006-10-26 06:15:43 +00004181 case 168:
4182#line 1971 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004183 {
4184 (yyval.ArgList) = (yyvsp[-2].ArgList);
4185 (yyval.ArgList)->push_back(std::pair<PATypeHolder*,
Reid Spencer68a24bd2005-08-27 18:50:39 +00004186 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004187 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004188 ;}
4189 break;
4190
Reid Spencer1628cec2006-10-26 06:15:43 +00004191 case 169:
4192#line 1977 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004193 {
4194 (yyval.ArgList) = new std::vector<std::pair<PATypeHolder*,char*> >();
4195 (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Reid Spencer61c83e02006-08-18 08:43:06 +00004196 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004197 ;}
4198 break;
4199
Reid Spencer1628cec2006-10-26 06:15:43 +00004200 case 170:
4201#line 1982 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004202 {
4203 (yyval.ArgList) = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00004204 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004205 ;}
4206 break;
4207
Reid Spencer1628cec2006-10-26 06:15:43 +00004208 case 171:
4209#line 1988 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004210 {
4211 UnEscapeLexed((yyvsp[-5].StrVal));
4212 std::string FunctionName((yyvsp[-5].StrVal));
4213 free((yyvsp[-5].StrVal)); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00004214
Reid Spencer21be8652006-10-22 07:03:43 +00004215 if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004216 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004217
4218 std::vector<const Type*> ParamTypeList;
Reid Spencer21be8652006-10-22 07:03:43 +00004219 if ((yyvsp[-3].ArgList)) { // If there are arguments...
4220 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4221 I != (yyvsp[-3].ArgList)->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004222 ParamTypeList.push_back(I->first->get());
4223 }
4224
4225 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
4226 if (isVarArg) ParamTypeList.pop_back();
4227
Reid Spencer21be8652006-10-22 07:03:43 +00004228 const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004229 const PointerType *PFT = PointerType::get(FT);
Reid Spencer21be8652006-10-22 07:03:43 +00004230 delete (yyvsp[-6].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004231
4232 ValID ID;
4233 if (!FunctionName.empty()) {
4234 ID = ValID::create((char*)FunctionName.c_str());
4235 } else {
4236 ID = ValID::create((int)CurModule.Values[PFT].size());
4237 }
4238
4239 Function *Fn = 0;
4240 // See if this function was forward referenced. If so, recycle the object.
4241 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4242 // Move the function to the end of the list, from whereever it was
4243 // previously inserted.
4244 Fn = cast<Function>(FWRef);
4245 CurModule.CurrentModule->getFunctionList().remove(Fn);
4246 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4247 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4248 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
4249 // If this is the case, either we need to be a forward decl, or it needs
4250 // to be.
4251 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00004252 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004253
4254 // Make sure to strip off any argument names so we can't get conflicts.
4255 if (Fn->isExternal())
4256 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4257 AI != AE; ++AI)
4258 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004259 } else { // Not already defined?
4260 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
4261 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004262
Reid Spencer68a24bd2005-08-27 18:50:39 +00004263 InsertValue(Fn, CurModule.Values);
4264 }
4265
4266 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00004267
4268 if (CurFun.isDeclare) {
4269 // If we have declaration, always overwrite linkage. This will allow us to
4270 // correctly handle cases, when pointer to function is passed as argument to
4271 // another function.
4272 Fn->setLinkage(CurFun.Linkage);
4273 }
Reid Spencer21be8652006-10-22 07:03:43 +00004274 Fn->setCallingConv((yyvsp[-7].UIntVal));
4275 Fn->setAlignment((yyvsp[0].UIntVal));
4276 if ((yyvsp[-1].StrVal)) {
4277 Fn->setSection((yyvsp[-1].StrVal));
4278 free((yyvsp[-1].StrVal));
Chris Lattnere869eef2005-11-12 00:11:49 +00004279 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00004280
4281 // Add all of the arguments we parsed to the function...
Reid Spencer21be8652006-10-22 07:03:43 +00004282 if ((yyvsp[-3].ArgList)) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00004283 if (isVarArg) { // Nuke the last entry
Reid Spencer21be8652006-10-22 07:03:43 +00004284 assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00004285 "Not a varargs marker!");
Reid Spencer21be8652006-10-22 07:03:43 +00004286 delete (yyvsp[-3].ArgList)->back().first;
4287 (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00004288 }
4289 Function::arg_iterator ArgIt = Fn->arg_begin();
Reid Spencer21be8652006-10-22 07:03:43 +00004290 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = (yyvsp[-3].ArgList)->begin();
4291 I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004292 delete I->first; // Delete the typeholder...
4293
4294 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004295 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004296 InsertValue(ArgIt);
4297 }
4298
Reid Spencer21be8652006-10-22 07:03:43 +00004299 delete (yyvsp[-3].ArgList); // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00004300 }
Reid Spencer61c83e02006-08-18 08:43:06 +00004301 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004302;}
4303 break;
4304
Reid Spencer1628cec2006-10-26 06:15:43 +00004305 case 174:
4306#line 2084 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004307 {
4308 (yyval.FunctionVal) = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004309
4310 // Make sure that we keep track of the linkage type even if there was a
4311 // previous "declare".
Reid Spencer21be8652006-10-22 07:03:43 +00004312 (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage));
4313;}
4314 break;
4315
Reid Spencer1628cec2006-10-26 06:15:43 +00004316 case 177:
4317#line 2094 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004318 {
4319 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004320 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004321;}
4322 break;
4323
Reid Spencer21be8652006-10-22 07:03:43 +00004324 case 179:
Reid Spencer1628cec2006-10-26 06:15:43 +00004325#line 2100 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4326 { CurFun.Linkage = GlobalValue::DLLImportLinkage ;}
Reid Spencer21be8652006-10-22 07:03:43 +00004327 break;
4328
4329 case 180:
Reid Spencer1628cec2006-10-26 06:15:43 +00004330#line 2101 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4331 { CurFun.Linkage = GlobalValue::DLLImportLinkage ;}
4332 break;
4333
4334 case 181:
4335#line 2103 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
4336 { CurFun.isDeclare = true; ;}
4337 break;
4338
4339 case 182:
4340#line 2103 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004341 {
4342 (yyval.FunctionVal) = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004343 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00004344 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004345 ;}
4346 break;
4347
Reid Spencer1628cec2006-10-26 06:15:43 +00004348 case 183:
4349#line 2113 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004350 {
4351 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004352 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004353 ;}
4354 break;
4355
Reid Spencer1628cec2006-10-26 06:15:43 +00004356 case 184:
4357#line 2117 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004358 {
4359 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004360 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004361 ;}
4362 break;
4363
Reid Spencer1628cec2006-10-26 06:15:43 +00004364 case 185:
4365#line 2122 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004366 { // A reference to a direct constant
4367 (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00004368 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004369 ;}
4370 break;
4371
Reid Spencer1628cec2006-10-26 06:15:43 +00004372 case 186:
4373#line 2126 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004374 {
4375 (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val));
Reid Spencer61c83e02006-08-18 08:43:06 +00004376 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004377 ;}
4378 break;
4379
Reid Spencer1628cec2006-10-26 06:15:43 +00004380 case 187:
4381#line 2130 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004382 { // Perhaps it's an FP constant?
4383 (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004384 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004385 ;}
4386 break;
4387
Reid Spencer1628cec2006-10-26 06:15:43 +00004388 case 188:
4389#line 2134 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004390 {
4391 (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue());
Reid Spencer61c83e02006-08-18 08:43:06 +00004392 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004393 ;}
4394 break;
4395
Reid Spencer1628cec2006-10-26 06:15:43 +00004396 case 189:
4397#line 2138 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004398 {
4399 (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse());
Reid Spencer61c83e02006-08-18 08:43:06 +00004400 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004401 ;}
4402 break;
4403
Reid Spencer1628cec2006-10-26 06:15:43 +00004404 case 190:
4405#line 2142 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004406 {
4407 (yyval.ValIDVal) = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00004408 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004409 ;}
4410 break;
4411
Reid Spencer1628cec2006-10-26 06:15:43 +00004412 case 191:
4413#line 2146 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004414 {
4415 (yyval.ValIDVal) = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00004416 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004417 ;}
4418 break;
4419
Reid Spencer1628cec2006-10-26 06:15:43 +00004420 case 192:
4421#line 2150 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004422 { // A vector zero constant.
4423 (yyval.ValIDVal) = ValID::createZeroInit();
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00004424 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004425 ;}
4426 break;
4427
Reid Spencer1628cec2006-10-26 06:15:43 +00004428 case 193:
4429#line 2154 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004430 { // Nonempty unsized packed vector
4431 const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType();
4432 int NumElements = (yyvsp[-1].ConstVector)->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004433
4434 PackedType* pt = PackedType::get(ETy, NumElements);
4435 PATypeHolder* PTy = new PATypeHolder(
4436 HandleUpRefs(
4437 PackedType::get(
4438 ETy,
4439 NumElements)
4440 )
4441 );
4442
4443 // Verify all elements are correct type!
Reid Spencer21be8652006-10-22 07:03:43 +00004444 for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) {
4445 if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004446 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004447 ETy->getDescription() +"' as required!\nIt is of type '" +
Reid Spencer21be8652006-10-22 07:03:43 +00004448 (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004449 }
4450
Reid Spencer21be8652006-10-22 07:03:43 +00004451 (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector)));
4452 delete PTy; delete (yyvsp[-1].ConstVector);
Reid Spencer61c83e02006-08-18 08:43:06 +00004453 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004454 ;}
4455 break;
Reid Spencerb83eb642006-10-20 07:07:24 +00004456
Reid Spencer1628cec2006-10-26 06:15:43 +00004457 case 194:
4458#line 2179 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004459 {
4460 (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal));
Reid Spencerb83eb642006-10-20 07:07:24 +00004461 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004462 ;}
4463 break;
4464
Reid Spencer1628cec2006-10-26 06:15:43 +00004465 case 195:
4466#line 2183 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004467 {
4468 char *End = UnEscapeLexed((yyvsp[-2].StrVal), true);
4469 std::string AsmStr = std::string((yyvsp[-2].StrVal), End);
4470 End = UnEscapeLexed((yyvsp[0].StrVal), true);
4471 std::string Constraints = std::string((yyvsp[0].StrVal), End);
4472 (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal));
4473 free((yyvsp[-2].StrVal));
4474 free((yyvsp[0].StrVal));
Reid Spencerb83eb642006-10-20 07:07:24 +00004475 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004476 ;}
4477 break;
4478
Reid Spencer1628cec2006-10-26 06:15:43 +00004479 case 196:
4480#line 2197 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004481 { // Is it an integer reference...?
4482 (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal));
4483 CHECK_FOR_ERROR
4484 ;}
4485 break;
4486
Reid Spencer1628cec2006-10-26 06:15:43 +00004487 case 197:
4488#line 2201 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004489 { // Is it a named reference...?
4490 (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal));
4491 CHECK_FOR_ERROR
4492 ;}
4493 break;
4494
Reid Spencer1628cec2006-10-26 06:15:43 +00004495 case 200:
4496#line 2213 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004497 {
4498 (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal);
4499 CHECK_FOR_ERROR
4500 ;}
4501 break;
4502
Reid Spencer1628cec2006-10-26 06:15:43 +00004503 case 201:
4504#line 2218 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004505 {
4506 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4507 CHECK_FOR_ERROR
4508 ;}
4509 break;
4510
Reid Spencer1628cec2006-10-26 06:15:43 +00004511 case 202:
4512#line 2222 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004513 { // Do not allow functions with 0 basic blocks
4514 (yyval.FunctionVal) = (yyvsp[-1].FunctionVal);
4515 CHECK_FOR_ERROR
4516 ;}
4517 break;
4518
Reid Spencer1628cec2006-10-26 06:15:43 +00004519 case 203:
4520#line 2231 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004521 {
4522 setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal));
4523 CHECK_FOR_ERROR
4524 InsertValue((yyvsp[0].TermInstVal));
4525
4526 (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal));
4527 InsertValue((yyvsp[-2].BasicBlockVal));
4528 (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal);
4529 CHECK_FOR_ERROR
4530 ;}
4531 break;
4532
Reid Spencer1628cec2006-10-26 06:15:43 +00004533 case 204:
4534#line 2242 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004535 {
4536 (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal));
4537 (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal);
4538 CHECK_FOR_ERROR
4539 ;}
4540 break;
4541
Reid Spencer1628cec2006-10-26 06:15:43 +00004542 case 205:
4543#line 2247 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004544 {
4545 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004546 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004547
4548 // Make sure to move the basic block to the correct location in the
4549 // function, instead of leaving it inserted wherever it was first
4550 // referenced.
4551 Function::BasicBlockListType &BBL =
4552 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer21be8652006-10-22 07:03:43 +00004553 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004554 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004555 ;}
4556 break;
4557
Reid Spencer1628cec2006-10-26 06:15:43 +00004558 case 206:
4559#line 2259 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004560 {
4561 (yyval.BasicBlockVal) = CurBB = getBBVal(ValID::create((yyvsp[0].StrVal)), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004562 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004563
4564 // Make sure to move the basic block to the correct location in the
4565 // function, instead of leaving it inserted wherever it was first
4566 // referenced.
4567 Function::BasicBlockListType &BBL =
4568 CurFun.CurrentFunction->getBasicBlockList();
Reid Spencer21be8652006-10-22 07:03:43 +00004569 BBL.splice(BBL.end(), BBL, (yyval.BasicBlockVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004570 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004571 ;}
4572 break;
Reid Spencer61c83e02006-08-18 08:43:06 +00004573
Reid Spencer1628cec2006-10-26 06:15:43 +00004574 case 207:
4575#line 2272 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004576 { // Return with a result...
4577 (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal));
4578 CHECK_FOR_ERROR
4579 ;}
4580 break;
4581
Reid Spencer1628cec2006-10-26 06:15:43 +00004582 case 208:
4583#line 2276 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004584 { // Return with no result...
4585 (yyval.TermInstVal) = new ReturnInst();
4586 CHECK_FOR_ERROR
4587 ;}
4588 break;
4589
Reid Spencer1628cec2006-10-26 06:15:43 +00004590 case 209:
4591#line 2280 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004592 { // Unconditional Branch...
4593 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
4594 CHECK_FOR_ERROR
4595 (yyval.TermInstVal) = new BranchInst(tmpBB);
4596 ;}
4597 break;
4598
Reid Spencer1628cec2006-10-26 06:15:43 +00004599 case 210:
4600#line 2285 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004601 {
4602 BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal));
4603 CHECK_FOR_ERROR
4604 BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal));
4605 CHECK_FOR_ERROR
4606 Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal));
4607 CHECK_FOR_ERROR
4608 (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4609 ;}
4610 break;
4611
Reid Spencer1628cec2006-10-26 06:15:43 +00004612 case 211:
4613#line 2294 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004614 {
4615 Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal));
4616 CHECK_FOR_ERROR
4617 BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal));
4618 CHECK_FOR_ERROR
4619 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size());
4620 (yyval.TermInstVal) = S;
4621
4622 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = (yyvsp[-1].JumpTable)->begin(),
4623 E = (yyvsp[-1].JumpTable)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004624 for (; I != E; ++I) {
4625 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4626 S->addCase(CI, I->second);
4627 else
Reid Spencer61c83e02006-08-18 08:43:06 +00004628 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004629 }
Reid Spencer21be8652006-10-22 07:03:43 +00004630 delete (yyvsp[-1].JumpTable);
Reid Spencer61c83e02006-08-18 08:43:06 +00004631 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004632 ;}
4633 break;
4634
Reid Spencer1628cec2006-10-26 06:15:43 +00004635 case 212:
4636#line 2313 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004637 {
4638 Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004639 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004640 BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004641 CHECK_FOR_ERROR
4642 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Reid Spencer21be8652006-10-22 07:03:43 +00004643 (yyval.TermInstVal) = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00004644 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004645 ;}
4646 break;
4647
Reid Spencer1628cec2006-10-26 06:15:43 +00004648 case 213:
4649#line 2323 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004650 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004651 const PointerType *PFTy;
4652 const FunctionType *Ty;
4653
Reid Spencer21be8652006-10-22 07:03:43 +00004654 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-10].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004655 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4656 // Pull out the types of all of the arguments...
4657 std::vector<const Type*> ParamTypes;
Reid Spencer21be8652006-10-22 07:03:43 +00004658 if ((yyvsp[-7].ValueList)) {
4659 for (std::vector<Value*>::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004660 I != E; ++I)
4661 ParamTypes.push_back((*I)->getType());
4662 }
4663
4664 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4665 if (isVarArg) ParamTypes.pop_back();
4666
Reid Spencer21be8652006-10-22 07:03:43 +00004667 Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004668 PFTy = PointerType::get(Ty);
4669 }
4670
Reid Spencer21be8652006-10-22 07:03:43 +00004671 Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004672 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004673 BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004674 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004675 BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004676 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004677
4678 // Create the call node...
Reid Spencer21be8652006-10-22 07:03:43 +00004679 if (!(yyvsp[-7].ValueList)) { // Has no arguments?
4680 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004681 } else { // Has arguments?
4682 // Loop through FunctionType's arguments and ensure they are specified
4683 // correctly!
4684 //
4685 FunctionType::param_iterator I = Ty->param_begin();
4686 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer21be8652006-10-22 07:03:43 +00004687 std::vector<Value*>::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004688
4689 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4690 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00004691 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004692 (*I)->getDescription() + "'!");
4693
4694 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004695 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004696
Reid Spencer21be8652006-10-22 07:03:43 +00004697 (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004698 }
Reid Spencer21be8652006-10-22 07:03:43 +00004699 cast<InvokeInst>((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004700
Reid Spencer21be8652006-10-22 07:03:43 +00004701 delete (yyvsp[-10].TypeVal);
4702 delete (yyvsp[-7].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00004703 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004704 ;}
4705 break;
4706
Reid Spencer1628cec2006-10-26 06:15:43 +00004707 case 214:
4708#line 2378 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004709 {
4710 (yyval.TermInstVal) = new UnwindInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00004711 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004712 ;}
4713 break;
4714
Reid Spencer1628cec2006-10-26 06:15:43 +00004715 case 215:
4716#line 2382 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004717 {
4718 (yyval.TermInstVal) = new UnreachableInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00004719 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004720 ;}
4721 break;
4722
Reid Spencer1628cec2006-10-26 06:15:43 +00004723 case 216:
4724#line 2389 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004725 {
4726 (yyval.JumpTable) = (yyvsp[-5].JumpTable);
4727 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004728 CHECK_FOR_ERROR
Reid Spencer61c83e02006-08-18 08:43:06 +00004729 if (V == 0)
4730 GEN_ERROR("May only switch on a constant pool value!");
4731
Reid Spencer21be8652006-10-22 07:03:43 +00004732 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004733 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004734 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
4735 ;}
4736 break;
4737
Reid Spencer1628cec2006-10-26 06:15:43 +00004738 case 217:
4739#line 2400 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004740 {
4741 (yyval.JumpTable) = new std::vector<std::pair<Constant*, BasicBlock*> >();
4742 Constant *V = cast<Constant>(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal)));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004743 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004744
4745 if (V == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004746 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004747
Reid Spencer21be8652006-10-22 07:03:43 +00004748 BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004749 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004750 (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB));
4751 ;}
4752 break;
4753
Reid Spencer1628cec2006-10-26 06:15:43 +00004754 case 218:
4755#line 2413 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004756 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004757 // Is this definition named?? if so, assign the name...
Reid Spencer21be8652006-10-22 07:03:43 +00004758 setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004759 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004760 InsertValue((yyvsp[0].InstVal));
4761 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004762 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004763;}
4764 break;
4765
Reid Spencer1628cec2006-10-26 06:15:43 +00004766 case 219:
4767#line 2422 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004768 { // Used for PHI nodes
4769 (yyval.PHIList) = new std::list<std::pair<Value*, BasicBlock*> >();
4770 Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004771 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004772 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004773 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004774 (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4775 delete (yyvsp[-5].TypeVal);
4776 ;}
4777 break;
4778
Reid Spencer1628cec2006-10-26 06:15:43 +00004779 case 220:
4780#line 2431 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004781 {
4782 (yyval.PHIList) = (yyvsp[-6].PHIList);
4783 Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004784 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004785 BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004786 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004787 (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB));
4788 ;}
4789 break;
4790
Reid Spencer1628cec2006-10-26 06:15:43 +00004791 case 221:
4792#line 2441 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004793 { // Used for call statements, and memory insts...
4794 (yyval.ValueList) = new std::vector<Value*>();
4795 (yyval.ValueList)->push_back((yyvsp[0].ValueVal));
4796 ;}
4797 break;
4798
Reid Spencer1628cec2006-10-26 06:15:43 +00004799 case 222:
4800#line 2445 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004801 {
4802 (yyval.ValueList) = (yyvsp[-2].ValueList);
4803 (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004804 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004805 ;}
4806 break;
4807
Reid Spencer1628cec2006-10-26 06:15:43 +00004808 case 224:
4809#line 2452 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004810 { (yyval.ValueList) = 0; ;}
4811 break;
4812
Reid Spencer1628cec2006-10-26 06:15:43 +00004813 case 225:
4814#line 2454 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004815 {
4816 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004817 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004818 ;}
4819 break;
4820
Reid Spencer1628cec2006-10-26 06:15:43 +00004821 case 226:
4822#line 2458 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004823 {
4824 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004825 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004826 ;}
4827 break;
4828
Reid Spencer1628cec2006-10-26 06:15:43 +00004829 case 227:
4830#line 2463 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004831 {
4832 if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() &&
4833 !isa<PackedType>((*(yyvsp[-3].TypeVal)).get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004834 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004835 "Arithmetic operator requires integer, FP, or packed operands!");
Reid Spencer1628cec2006-10-26 06:15:43 +00004836 if (isa<PackedType>((*(yyvsp[-3].TypeVal)).get()) && (yyvsp[-4].BinaryOpVal).opcode == Instruction::Rem)
Reid Spencer61c83e02006-08-18 08:43:06 +00004837 GEN_ERROR("Rem not supported on packed types!");
Reid Spencer1628cec2006-10-26 06:15:43 +00004838 // Upgrade the opcode from obsolete versions before we do anything with it.
4839 sanitizeOpCode((yyvsp[-4].BinaryOpVal),*(yyvsp[-3].TypeVal));
4840 CHECK_FOR_ERROR;
Reid Spencer21be8652006-10-22 07:03:43 +00004841 Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004842 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004843 Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004844 CHECK_FOR_ERROR
Reid Spencer1628cec2006-10-26 06:15:43 +00004845 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, val1, val2);
Reid Spencer21be8652006-10-22 07:03:43 +00004846 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004847 GEN_ERROR("binary operator returned null!");
Reid Spencer21be8652006-10-22 07:03:43 +00004848 delete (yyvsp[-3].TypeVal);
4849 ;}
4850 break;
4851
Reid Spencer1628cec2006-10-26 06:15:43 +00004852 case 228:
4853#line 2482 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004854 {
4855 if (!(*(yyvsp[-3].TypeVal))->isIntegral()) {
4856 if (!isa<PackedType>((yyvsp[-3].TypeVal)->get()) ||
4857 !cast<PackedType>((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00004858 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00004859 }
Reid Spencer21be8652006-10-22 07:03:43 +00004860 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004861 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004862 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004863 CHECK_FOR_ERROR
Reid Spencer1628cec2006-10-26 06:15:43 +00004864 (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2);
Reid Spencer21be8652006-10-22 07:03:43 +00004865 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004866 GEN_ERROR("binary operator returned null!");
Reid Spencer21be8652006-10-22 07:03:43 +00004867 delete (yyvsp[-3].TypeVal);
4868 ;}
4869 break;
4870
Reid Spencer1628cec2006-10-26 06:15:43 +00004871 case 229:
4872#line 2497 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004873 {
4874 if(isa<PackedType>((*(yyvsp[-3].TypeVal)).get())) {
Reid Spencer61c83e02006-08-18 08:43:06 +00004875 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004876 "PackedTypes currently not supported in setcc instructions!");
4877 }
Reid Spencer21be8652006-10-22 07:03:43 +00004878 Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004879 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004880 Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004881 CHECK_FOR_ERROR
Reid Spencer1628cec2006-10-26 06:15:43 +00004882 (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal).opcode, tmpVal1, tmpVal2);
Reid Spencer21be8652006-10-22 07:03:43 +00004883 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004884 GEN_ERROR("binary operator returned null!");
Reid Spencer21be8652006-10-22 07:03:43 +00004885 delete (yyvsp[-3].TypeVal);
4886 ;}
4887 break;
4888
Reid Spencer1628cec2006-10-26 06:15:43 +00004889 case 230:
4890#line 2511 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004891 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004892 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4893 << " Replacing with 'xor'.\n";
4894
Reid Spencer21be8652006-10-22 07:03:43 +00004895 Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004896 if (Ones == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004897 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004898
Reid Spencer21be8652006-10-22 07:03:43 +00004899 (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones);
4900 if ((yyval.InstVal) == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004901 GEN_ERROR("Could not create a xor instruction!");
4902 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004903 ;}
4904 break;
4905
Reid Spencer1628cec2006-10-26 06:15:43 +00004906 case 231:
4907#line 2524 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004908 {
4909 if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004910 GEN_ERROR("Shift amount must be ubyte!");
Reid Spencer21be8652006-10-22 07:03:43 +00004911 if (!(yyvsp[-2].ValueVal)->getType()->isInteger())
Reid Spencer61c83e02006-08-18 08:43:06 +00004912 GEN_ERROR("Shift constant expression requires integer operand!");
Reid Spencer1628cec2006-10-26 06:15:43 +00004913 (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal).opcode, (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004914 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004915 ;}
4916 break;
4917
Reid Spencer1628cec2006-10-26 06:15:43 +00004918 case 232:
4919#line 2532 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004920 {
4921 if (!(yyvsp[0].TypeVal)->get()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004922 GEN_ERROR("cast instruction to a non-primitive type: '" +
Reid Spencer21be8652006-10-22 07:03:43 +00004923 (yyvsp[0].TypeVal)->get()->getDescription() + "'!");
4924 (yyval.InstVal) = new CastInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
4925 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004926 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004927 ;}
4928 break;
4929
Reid Spencer1628cec2006-10-26 06:15:43 +00004930 case 233:
4931#line 2540 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004932 {
4933 if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004934 GEN_ERROR("select condition must be boolean!");
Reid Spencer21be8652006-10-22 07:03:43 +00004935 if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004936 GEN_ERROR("select value types should match!");
Reid Spencer21be8652006-10-22 07:03:43 +00004937 (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00004938 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004939 ;}
4940 break;
4941
Reid Spencer1628cec2006-10-26 06:15:43 +00004942 case 234:
4943#line 2548 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004944 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004945 NewVarArgs = true;
Reid Spencer21be8652006-10-22 07:03:43 +00004946 (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal));
4947 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004948 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004949 ;}
4950 break;
4951
Reid Spencer1628cec2006-10-26 06:15:43 +00004952 case 235:
4953#line 2554 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004954 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004955 ObsoleteVarArgs = true;
Reid Spencer21be8652006-10-22 07:03:43 +00004956 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004957 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004958 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004959
4960 //b = vaarg a, t ->
4961 //foo = alloca 1 of t
4962 //bar = vacopy a
4963 //store bar -> foo
4964 //b = vaarg foo, t
4965 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4966 CurBB->getInstList().push_back(foo);
Reid Spencer21be8652006-10-22 07:03:43 +00004967 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004968 CurBB->getInstList().push_back(bar);
4969 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer21be8652006-10-22 07:03:43 +00004970 (yyval.InstVal) = new VAArgInst(foo, *(yyvsp[0].TypeVal));
4971 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004972 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00004973 ;}
4974 break;
4975
Reid Spencer1628cec2006-10-26 06:15:43 +00004976 case 236:
4977#line 2574 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00004978 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00004979 ObsoleteVarArgs = true;
Reid Spencer21be8652006-10-22 07:03:43 +00004980 const Type* ArgTy = (yyvsp[-2].ValueVal)->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004981 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004982 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004983
4984 //b = vanext a, t ->
4985 //foo = alloca 1 of t
4986 //bar = vacopy a
4987 //store bar -> foo
4988 //tmp = vaarg foo, t
4989 //b = load foo
4990 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4991 CurBB->getInstList().push_back(foo);
Reid Spencer21be8652006-10-22 07:03:43 +00004992 CallInst* bar = new CallInst(NF, (yyvsp[-2].ValueVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004993 CurBB->getInstList().push_back(bar);
4994 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Reid Spencer21be8652006-10-22 07:03:43 +00004995 Instruction* tmp = new VAArgInst(foo, *(yyvsp[0].TypeVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00004996 CurBB->getInstList().push_back(tmp);
Reid Spencer21be8652006-10-22 07:03:43 +00004997 (yyval.InstVal) = new LoadInst(foo);
4998 delete (yyvsp[0].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004999 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005000 ;}
5001 break;
5002
Reid Spencer1628cec2006-10-26 06:15:43 +00005003 case 237:
5004#line 2597 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005005 {
5006 if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005007 GEN_ERROR("Invalid extractelement operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00005008 (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005009 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005010 ;}
5011 break;
5012
Reid Spencer1628cec2006-10-26 06:15:43 +00005013 case 238:
5014#line 2603 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005015 {
5016 if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005017 GEN_ERROR("Invalid insertelement operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00005018 (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005019 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005020 ;}
5021 break;
5022
Reid Spencer1628cec2006-10-26 06:15:43 +00005023 case 239:
5024#line 2609 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005025 {
5026 if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)))
Reid Spencer61c83e02006-08-18 08:43:06 +00005027 GEN_ERROR("Invalid shufflevector operands!");
Reid Spencer21be8652006-10-22 07:03:43 +00005028 (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005029 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005030 ;}
5031 break;
5032
Reid Spencer1628cec2006-10-26 06:15:43 +00005033 case 240:
5034#line 2615 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005035 {
5036 const Type *Ty = (yyvsp[0].PHIList)->front().first->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005037 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005038 GEN_ERROR("PHI node operands must be of first class type!");
Reid Spencer21be8652006-10-22 07:03:43 +00005039 (yyval.InstVal) = new PHINode(Ty);
5040 ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size());
5041 while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) {
5042 if ((yyvsp[0].PHIList)->front().first->getType() != Ty)
Reid Spencer61c83e02006-08-18 08:43:06 +00005043 GEN_ERROR("All elements of a PHI node must be of the same type!");
Reid Spencer21be8652006-10-22 07:03:43 +00005044 cast<PHINode>((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second);
5045 (yyvsp[0].PHIList)->pop_front();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005046 }
Reid Spencer21be8652006-10-22 07:03:43 +00005047 delete (yyvsp[0].PHIList); // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00005048 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005049 ;}
5050 break;
5051
Reid Spencer1628cec2006-10-26 06:15:43 +00005052 case 241:
5053#line 2630 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005054 {
Reid Spencer68a24bd2005-08-27 18:50:39 +00005055 const PointerType *PFTy;
5056 const FunctionType *Ty;
5057
Reid Spencer21be8652006-10-22 07:03:43 +00005058 if (!(PFTy = dyn_cast<PointerType>((yyvsp[-4].TypeVal)->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00005059 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
5060 // Pull out the types of all of the arguments...
5061 std::vector<const Type*> ParamTypes;
Reid Spencer21be8652006-10-22 07:03:43 +00005062 if ((yyvsp[-1].ValueList)) {
5063 for (std::vector<Value*>::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005064 I != E; ++I)
5065 ParamTypes.push_back((*I)->getType());
5066 }
5067
5068 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
5069 if (isVarArg) ParamTypes.pop_back();
5070
Reid Spencer21be8652006-10-22 07:03:43 +00005071 if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00005072 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005073
Reid Spencer21be8652006-10-22 07:03:43 +00005074 Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005075 PFTy = PointerType::get(Ty);
5076 }
5077
Reid Spencer21be8652006-10-22 07:03:43 +00005078 Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00005079 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00005080
5081 // Create the call node...
Reid Spencer21be8652006-10-22 07:03:43 +00005082 if (!(yyvsp[-1].ValueList)) { // Has no arguments?
Reid Spencer68a24bd2005-08-27 18:50:39 +00005083 // Make sure no arguments is a good thing!
5084 if (Ty->getNumParams() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00005085 GEN_ERROR("No arguments passed to a function that "
Reid Spencer68a24bd2005-08-27 18:50:39 +00005086 "expects arguments!");
5087
Reid Spencer21be8652006-10-22 07:03:43 +00005088 (yyval.InstVal) = new CallInst(V, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005089 } else { // Has arguments?
5090 // Loop through FunctionType's arguments and ensure they are specified
5091 // correctly!
5092 //
5093 FunctionType::param_iterator I = Ty->param_begin();
5094 FunctionType::param_iterator E = Ty->param_end();
Reid Spencer21be8652006-10-22 07:03:43 +00005095 std::vector<Value*>::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00005096
5097 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
5098 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00005099 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005100 (*I)->getDescription() + "'!");
5101
5102 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005103 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005104
Reid Spencer21be8652006-10-22 07:03:43 +00005105 (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005106 }
Reid Spencer21be8652006-10-22 07:03:43 +00005107 cast<CallInst>((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal));
5108 cast<CallInst>((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal));
5109 delete (yyvsp[-4].TypeVal);
5110 delete (yyvsp[-1].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00005111 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005112 ;}
5113 break;
5114
Reid Spencer1628cec2006-10-26 06:15:43 +00005115 case 242:
5116#line 2689 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005117 {
5118 (yyval.InstVal) = (yyvsp[0].InstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005119 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005120 ;}
5121 break;
5122
Reid Spencer1628cec2006-10-26 06:15:43 +00005123 case 243:
5124#line 2696 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005125 {
5126 (yyval.ValueList) = (yyvsp[0].ValueList);
Reid Spencer61c83e02006-08-18 08:43:06 +00005127 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005128 ;}
5129 break;
5130
Reid Spencer1628cec2006-10-26 06:15:43 +00005131 case 244:
5132#line 2699 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005133 {
5134 (yyval.ValueList) = new std::vector<Value*>();
Reid Spencer61c83e02006-08-18 08:43:06 +00005135 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005136 ;}
5137 break;
5138
Reid Spencer1628cec2006-10-26 06:15:43 +00005139 case 245:
5140#line 2704 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005141 {
5142 (yyval.BoolVal) = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00005143 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005144 ;}
5145 break;
5146
Reid Spencer1628cec2006-10-26 06:15:43 +00005147 case 246:
5148#line 2708 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005149 {
5150 (yyval.BoolVal) = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00005151 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005152 ;}
5153 break;
5154
Reid Spencer1628cec2006-10-26 06:15:43 +00005155 case 247:
5156#line 2715 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005157 {
5158 (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5159 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005160 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005161 ;}
5162 break;
5163
Reid Spencer1628cec2006-10-26 06:15:43 +00005164 case 248:
5165#line 2720 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005166 {
5167 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005168 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005169 (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5170 delete (yyvsp[-4].TypeVal);
5171 ;}
5172 break;
5173
Reid Spencer1628cec2006-10-26 06:15:43 +00005174 case 249:
5175#line 2726 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005176 {
5177 (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal));
5178 delete (yyvsp[-1].TypeVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00005179 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005180 ;}
5181 break;
5182
Reid Spencer1628cec2006-10-26 06:15:43 +00005183 case 250:
5184#line 2731 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005185 {
5186 Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005187 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005188 (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal));
5189 delete (yyvsp[-4].TypeVal);
5190 ;}
5191 break;
5192
Reid Spencer1628cec2006-10-26 06:15:43 +00005193 case 251:
5194#line 2737 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005195 {
5196 if (!isa<PointerType>((yyvsp[0].ValueVal)->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005197 GEN_ERROR("Trying to free nonpointer type " +
Reid Spencer21be8652006-10-22 07:03:43 +00005198 (yyvsp[0].ValueVal)->getType()->getDescription() + "!");
5199 (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005200 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005201 ;}
5202 break;
5203
Reid Spencer1628cec2006-10-26 06:15:43 +00005204 case 252:
5205#line 2745 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005206 {
5207 if (!isa<PointerType>((yyvsp[-1].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005208 GEN_ERROR("Can't load from nonpointer type: " +
Reid Spencer21be8652006-10-22 07:03:43 +00005209 (*(yyvsp[-1].TypeVal))->getDescription());
5210 if (!cast<PointerType>((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00005211 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Reid Spencer21be8652006-10-22 07:03:43 +00005212 (*(yyvsp[-1].TypeVal))->getDescription());
5213 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005214 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005215 (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal));
5216 delete (yyvsp[-1].TypeVal);
5217 ;}
5218 break;
5219
Reid Spencer1628cec2006-10-26 06:15:43 +00005220 case 253:
5221#line 2757 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005222 {
5223 const PointerType *PT = dyn_cast<PointerType>((yyvsp[-1].TypeVal)->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005224 if (!PT)
Reid Spencer61c83e02006-08-18 08:43:06 +00005225 GEN_ERROR("Can't store to a nonpointer type: " +
Reid Spencer21be8652006-10-22 07:03:43 +00005226 (*(yyvsp[-1].TypeVal))->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00005227 const Type *ElTy = PT->getElementType();
Reid Spencer21be8652006-10-22 07:03:43 +00005228 if (ElTy != (yyvsp[-3].ValueVal)->getType())
5229 GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() +
Reid Spencer68a24bd2005-08-27 18:50:39 +00005230 "' into space of type '" + ElTy->getDescription() + "'!");
5231
Reid Spencer21be8652006-10-22 07:03:43 +00005232 Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005233 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005234 (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal));
5235 delete (yyvsp[-1].TypeVal);
5236 ;}
5237 break;
5238
Reid Spencer1628cec2006-10-26 06:15:43 +00005239 case 254:
5240#line 2772 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer21be8652006-10-22 07:03:43 +00005241 {
5242 if (!isa<PointerType>((yyvsp[-2].TypeVal)->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00005243 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00005244
5245 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
5246 // indices to uint struct indices for compatibility.
5247 generic_gep_type_iterator<std::vector<Value*>::iterator>
Reid Spencer21be8652006-10-22 07:03:43 +00005248 GTI = gep_type_begin((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end()),
5249 GTE = gep_type_end((yyvsp[-2].TypeVal)->get(), (yyvsp[0].ValueList)->begin(), (yyvsp[0].ValueList)->end());
5250 for (unsigned i = 0, e = (yyvsp[0].ValueList)->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005251 if (isa<StructType>(*GTI)) // Only change struct indices
Reid Spencer21be8652006-10-22 07:03:43 +00005252 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*(yyvsp[0].ValueList))[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00005253 if (CUI->getType() == Type::UByteTy)
Reid Spencer21be8652006-10-22 07:03:43 +00005254 (*(yyvsp[0].ValueList))[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005255
Reid Spencer21be8652006-10-22 07:03:43 +00005256 if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true))
Reid Spencer61c83e02006-08-18 08:43:06 +00005257 GEN_ERROR("Invalid getelementptr indices for type '" +
Reid Spencer21be8652006-10-22 07:03:43 +00005258 (*(yyvsp[-2].TypeVal))->getDescription()+ "'!");
5259 Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal));
Reid Spencer61c83e02006-08-18 08:43:06 +00005260 CHECK_FOR_ERROR
Reid Spencer21be8652006-10-22 07:03:43 +00005261 (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList));
5262 delete (yyvsp[-2].TypeVal);
5263 delete (yyvsp[0].ValueList);
5264 ;}
5265 break;
5266
5267
5268 default: break;
5269 }
5270
5271/* Line 1126 of yacc.c. */
Reid Spencer1628cec2006-10-26 06:15:43 +00005272#line 5273 "llvmAsmParser.tab.c"
Reid Spencer5b7e7532006-09-28 19:28:24 +00005273
5274 yyvsp -= yylen;
5275 yyssp -= yylen;
5276
Reid Spencer21be8652006-10-22 07:03:43 +00005277
5278 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005279
5280 *++yyvsp = yyval;
5281
5282
Reid Spencer21be8652006-10-22 07:03:43 +00005283 /* Now `shift' the result of the reduction. Determine what state
5284 that goes to, based on the state we popped back to and the rule
5285 number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005286
5287 yyn = yyr1[yyn];
5288
Reid Spencer21be8652006-10-22 07:03:43 +00005289 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
5290 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005291 yystate = yytable[yystate];
5292 else
Reid Spencer21be8652006-10-22 07:03:43 +00005293 yystate = yydefgoto[yyn - YYNTOKENS];
Reid Spencer68a24bd2005-08-27 18:50:39 +00005294
5295 goto yynewstate;
5296
5297
Reid Spencer21be8652006-10-22 07:03:43 +00005298/*------------------------------------.
5299| yyerrlab -- here on detecting error |
5300`------------------------------------*/
5301yyerrlab:
5302 /* If not already recovering from an error, report this error. */
5303 if (!yyerrstatus)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005304 {
5305 ++yynerrs;
Reid Spencer21be8652006-10-22 07:03:43 +00005306#if YYERROR_VERBOSE
Reid Spencer5b7e7532006-09-28 19:28:24 +00005307 yyn = yypact[yystate];
Chris Lattner224f84f2006-08-18 17:34:45 +00005308
Reid Spencer21be8652006-10-22 07:03:43 +00005309 if (YYPACT_NINF < yyn && yyn < YYLAST)
Reid Spencer5b7e7532006-09-28 19:28:24 +00005310 {
Reid Spencer21be8652006-10-22 07:03:43 +00005311 int yytype = YYTRANSLATE (yychar);
5312 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
5313 YYSIZE_T yysize = yysize0;
5314 YYSIZE_T yysize1;
5315 int yysize_overflow = 0;
5316 char *yymsg = 0;
5317# define YYERROR_VERBOSE_ARGS_MAXIMUM 5
5318 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
5319 int yyx;
Reid Spencer5b7e7532006-09-28 19:28:24 +00005320
Reid Spencer21be8652006-10-22 07:03:43 +00005321#if 0
5322 /* This is so xgettext sees the translatable formats that are
5323 constructed on the fly. */
5324 YY_("syntax error, unexpected %s");
5325 YY_("syntax error, unexpected %s, expecting %s");
5326 YY_("syntax error, unexpected %s, expecting %s or %s");
5327 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
5328 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
5329#endif
5330 char *yyfmt;
5331 char const *yyf;
5332 static char const yyunexpected[] = "syntax error, unexpected %s";
5333 static char const yyexpecting[] = ", expecting %s";
5334 static char const yyor[] = " or %s";
5335 char yyformat[sizeof yyunexpected
5336 + sizeof yyexpecting - 1
5337 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
5338 * (sizeof yyor - 1))];
5339 char const *yyprefix = yyexpecting;
5340
5341 /* Start YYX at -YYN if negative to avoid negative indexes in
5342 YYCHECK. */
5343 int yyxbegin = yyn < 0 ? -yyn : 0;
5344
5345 /* Stay within bounds of both yycheck and yytname. */
5346 int yychecklim = YYLAST - yyn;
5347 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
5348 int yycount = 1;
5349
5350 yyarg[0] = yytname[yytype];
5351 yyfmt = yystpcpy (yyformat, yyunexpected);
5352
5353 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
5354 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
5355 {
5356 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
5357 {
5358 yycount = 1;
5359 yysize = yysize0;
5360 yyformat[sizeof yyunexpected - 1] = '\0';
5361 break;
5362 }
5363 yyarg[yycount++] = yytname[yyx];
5364 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
5365 yysize_overflow |= yysize1 < yysize;
5366 yysize = yysize1;
5367 yyfmt = yystpcpy (yyfmt, yyprefix);
5368 yyprefix = yyor;
5369 }
5370
5371 yyf = YY_(yyformat);
5372 yysize1 = yysize + yystrlen (yyf);
5373 yysize_overflow |= yysize1 < yysize;
5374 yysize = yysize1;
5375
5376 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
5377 yymsg = (char *) YYSTACK_ALLOC (yysize);
5378 if (yymsg)
Reid Spencer5b7e7532006-09-28 19:28:24 +00005379 {
Reid Spencer21be8652006-10-22 07:03:43 +00005380 /* Avoid sprintf, as that infringes on the user's name space.
5381 Don't have undefined behavior even if the translation
5382 produced a string with the wrong number of "%s"s. */
5383 char *yyp = yymsg;
5384 int yyi = 0;
5385 while ((*yyp = *yyf))
Reid Spencer5b7e7532006-09-28 19:28:24 +00005386 {
Reid Spencer21be8652006-10-22 07:03:43 +00005387 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
5388 {
5389 yyp += yytnamerr (yyp, yyarg[yyi++]);
5390 yyf += 2;
5391 }
5392 else
5393 {
5394 yyp++;
5395 yyf++;
5396 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00005397 }
Reid Spencer21be8652006-10-22 07:03:43 +00005398 yyerror (yymsg);
5399 YYSTACK_FREE (yymsg);
Reid Spencer5b7e7532006-09-28 19:28:24 +00005400 }
5401 else
Reid Spencer21be8652006-10-22 07:03:43 +00005402 {
5403 yyerror (YY_("syntax error"));
5404 goto yyexhaustedlab;
5405 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00005406 }
5407 else
5408#endif /* YYERROR_VERBOSE */
Reid Spencer21be8652006-10-22 07:03:43 +00005409 yyerror (YY_("syntax error"));
Reid Spencer68a24bd2005-08-27 18:50:39 +00005410 }
5411
Reid Spencer21be8652006-10-22 07:03:43 +00005412
Reid Spencer68a24bd2005-08-27 18:50:39 +00005413
5414 if (yyerrstatus == 3)
5415 {
Reid Spencer21be8652006-10-22 07:03:43 +00005416 /* If just tried and failed to reuse look-ahead token after an
5417 error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00005418
Reid Spencer21be8652006-10-22 07:03:43 +00005419 if (yychar <= YYEOF)
5420 {
5421 /* Return failure if at end of input. */
5422 if (yychar == YYEOF)
5423 YYABORT;
5424 }
5425 else
5426 {
5427 yydestruct ("Error: discarding", yytoken, &yylval);
5428 yychar = YYEMPTY;
5429 }
5430 }
5431
5432 /* Else will try to reuse look-ahead token after shifting the error
5433 token. */
5434 goto yyerrlab1;
5435
5436
5437/*---------------------------------------------------.
5438| yyerrorlab -- error raised explicitly by YYERROR. |
5439`---------------------------------------------------*/
5440yyerrorlab:
5441
5442 /* Pacify compilers like GCC when the user code never invokes
5443 YYERROR and the label yyerrorlab therefore never appears in user
5444 code. */
5445 if (0)
5446 goto yyerrorlab;
5447
5448yyvsp -= yylen;
5449 yyssp -= yylen;
5450 yystate = *yyssp;
5451 goto yyerrlab1;
5452
5453
5454/*-------------------------------------------------------------.
5455| yyerrlab1 -- common code for both syntax error and YYERROR. |
5456`-------------------------------------------------------------*/
5457yyerrlab1:
5458 yyerrstatus = 3; /* Each real token shifted decrements this. */
5459
5460 for (;;)
5461 {
5462 yyn = yypact[yystate];
5463 if (yyn != YYPACT_NINF)
5464 {
5465 yyn += YYTERROR;
5466 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
5467 {
5468 yyn = yytable[yyn];
5469 if (0 < yyn)
5470 break;
5471 }
5472 }
5473
5474 /* Pop the current state because it cannot handle the error token. */
5475 if (yyssp == yyss)
Reid Spencer68a24bd2005-08-27 18:50:39 +00005476 YYABORT;
5477
Chris Lattner8335e842006-01-23 23:05:42 +00005478
Reid Spencer21be8652006-10-22 07:03:43 +00005479 yydestruct ("Error: popping", yystos[yystate], yyvsp);
5480 YYPOPSTACK;
5481 yystate = *yyssp;
5482 YY_STACK_PRINT (yyss, yyssp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005483 }
5484
5485 if (yyn == YYFINAL)
5486 YYACCEPT;
5487
Reid Spencer68a24bd2005-08-27 18:50:39 +00005488 *++yyvsp = yylval;
Reid Spencer21be8652006-10-22 07:03:43 +00005489
5490
5491 /* Shift the error token. */
5492 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005493
5494 yystate = yyn;
5495 goto yynewstate;
5496
Chris Lattner1ae022f2006-10-22 06:08:13 +00005497
Reid Spencer21be8652006-10-22 07:03:43 +00005498/*-------------------------------------.
5499| yyacceptlab -- YYACCEPT comes here. |
5500`-------------------------------------*/
5501yyacceptlab:
5502 yyresult = 0;
5503 goto yyreturn;
5504
5505/*-----------------------------------.
5506| yyabortlab -- YYABORT comes here. |
5507`-----------------------------------*/
5508yyabortlab:
5509 yyresult = 1;
5510 goto yyreturn;
5511
5512#ifndef yyoverflow
5513/*-------------------------------------------------.
5514| yyexhaustedlab -- memory exhaustion comes here. |
5515`-------------------------------------------------*/
5516yyexhaustedlab:
5517 yyerror (YY_("memory exhausted"));
5518 yyresult = 2;
5519 /* Fall through. */
Chris Lattner1ae022f2006-10-22 06:08:13 +00005520#endif
Reid Spencer21be8652006-10-22 07:03:43 +00005521
5522yyreturn:
5523 if (yychar != YYEOF && yychar != YYEMPTY)
5524 yydestruct ("Cleanup: discarding lookahead",
5525 yytoken, &yylval);
5526 while (yyssp != yyss)
5527 {
5528 yydestruct ("Cleanup: popping",
5529 yystos[*yyssp], yyvsp);
5530 YYPOPSTACK;
Chris Lattner1ae022f2006-10-22 06:08:13 +00005531 }
Reid Spencer21be8652006-10-22 07:03:43 +00005532#ifndef yyoverflow
5533 if (yyss != yyssa)
5534 YYSTACK_FREE (yyss);
5535#endif
5536 return yyresult;
Reid Spencer68a24bd2005-08-27 18:50:39 +00005537}
Reid Spencer21be8652006-10-22 07:03:43 +00005538
5539
Reid Spencer1628cec2006-10-26 06:15:43 +00005540#line 2798 "/proj/llvm/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00005541
5542
5543void llvm::GenerateError(const std::string &message, int LineNo) {
5544 if (LineNo == -1) LineNo = llvmAsmlineno;
5545 // TODO: column number in exception
5546 if (TheParseError)
5547 TheParseError->setError(CurFilename, message, LineNo);
5548 TriggerError = 1;
5549}
Reid Spencer68a24bd2005-08-27 18:50:39 +00005550
5551int yyerror(const char *ErrorMsg) {
5552 std::string where
5553 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5554 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5555 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
5556 if (yychar == YYEMPTY || yychar == 0)
5557 errMsg += "end-of-file.";
5558 else
5559 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00005560 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00005561 return 0;
5562}
Reid Spencer21be8652006-10-22 07:03:43 +00005563