blob: 9057dad68707f32d0b7a3dfb1561ffec89938069 [file] [log] [blame]
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001
Chris Lattner6ab03f62006-09-28 23:35:22 +00002/* A Bison parser, made from /Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004
Chris Lattner6ab03f62006-09-28 23:35:22 +00005#define YYBISON 1 /* Identify Bison output. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00006
Reid Spencerdfb3fb42005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Chris Lattner6ab03f62006-09-28 23:35:22 +00008#define yylex llvmAsmlex
Reid Spencerdfb3fb42005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattner6ab03f62006-09-28 23:35:22 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencerdfb3fb42005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattner6ab03f62006-09-28 23:35:22 +000014#define ESINT64VAL 257
15#define EUINT64VAL 258
16#define SINTVAL 259
17#define UINTVAL 260
18#define FPVAL 261
19#define VOID 262
20#define BOOL 263
21#define SBYTE 264
22#define UBYTE 265
23#define SHORT 266
24#define USHORT 267
25#define INT 268
26#define UINT 269
27#define LONG 270
28#define ULONG 271
29#define FLOAT 272
30#define DOUBLE 273
31#define TYPE 274
32#define LABEL 275
33#define VAR_ID 276
34#define LABELSTR 277
35#define STRINGCONSTANT 278
36#define IMPLEMENTATION 279
37#define ZEROINITIALIZER 280
38#define TRUETOK 281
39#define FALSETOK 282
40#define BEGINTOK 283
41#define ENDTOK 284
42#define DECLARE 285
43#define GLOBAL 286
44#define CONSTANT 287
45#define SECTION 288
46#define VOLATILE 289
47#define TO 290
48#define DOTDOTDOT 291
49#define NULL_TOK 292
50#define UNDEF 293
51#define CONST 294
52#define INTERNAL 295
53#define LINKONCE 296
54#define WEAK 297
55#define APPENDING 298
56#define DLLIMPORT 299
57#define DLLEXPORT 300
58#define EXTERN_WEAK 301
59#define OPAQUE 302
60#define NOT 303
61#define EXTERNAL 304
62#define TARGET 305
63#define TRIPLE 306
64#define ENDIAN 307
65#define POINTERSIZE 308
66#define LITTLE 309
67#define BIG 310
68#define ALIGN 311
69#define DEPLIBS 312
70#define CALL 313
71#define TAIL 314
72#define ASM_TOK 315
73#define MODULE 316
74#define SIDEEFFECT 317
75#define CC_TOK 318
76#define CCC_TOK 319
77#define CSRETCC_TOK 320
78#define FASTCC_TOK 321
79#define COLDCC_TOK 322
80#define X86_STDCALLCC_TOK 323
81#define X86_FASTCALLCC_TOK 324
82#define RET 325
83#define BR 326
84#define SWITCH 327
85#define INVOKE 328
86#define UNWIND 329
87#define UNREACHABLE 330
88#define ADD 331
89#define SUB 332
90#define MUL 333
91#define DIV 334
92#define REM 335
93#define AND 336
94#define OR 337
95#define XOR 338
96#define SETLE 339
97#define SETGE 340
98#define SETLT 341
99#define SETGT 342
100#define SETEQ 343
101#define SETNE 344
102#define MALLOC 345
103#define ALLOCA 346
104#define FREE 347
105#define LOAD 348
106#define STORE 349
107#define GETELEMENTPTR 350
108#define PHI_TOK 351
109#define CAST 352
110#define SELECT 353
111#define SHL 354
112#define SHR 355
113#define VAARG 356
114#define EXTRACTELEMENT 357
115#define INSERTELEMENT 358
116#define SHUFFLEVECTOR 359
117#define VAARG_old 360
118#define VANEXT_old 361
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000119
Chris Lattner6ab03f62006-09-28 23:35:22 +0000120#line 14 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000121
122#include "ParserInternals.h"
123#include "llvm/CallingConv.h"
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000124#include "llvm/InlineAsm.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000125#include "llvm/Instructions.h"
126#include "llvm/Module.h"
127#include "llvm/SymbolTable.h"
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000128#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000129#include "llvm/Support/GetElementPtrTypeIterator.h"
130#include "llvm/ADT/STLExtras.h"
Chris Lattner840f7892005-11-06 06:46:53 +0000131#include "llvm/Support/MathExtras.h"
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000132#include <algorithm>
133#include <iostream>
134#include <list>
135#include <utility>
136
Reid Spencerb50974a2006-08-18 17:32:55 +0000137// The following is a gross hack. In order to rid the libAsmParser library of
138// exceptions, we have to have a way of getting the yyparse function to go into
139// an error situation. So, whenever we want an error to occur, the GenerateError
140// function (see bottom of file) sets TriggerError. Then, at the end of each
141// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
142// (a goto) to put YACC in error state. Furthermore, several calls to
143// GenerateError are made from inside productions and they must simulate the
144// previous exception behavior by exiting the production immediately. We have
145// replaced these with the GEN_ERROR macro which calls GeneratError and then
146// immediately invokes YYERROR. This would be so much cleaner if it was a
147// recursive descent parser.
Reid Spencer713eedc2006-08-18 08:43:06 +0000148static bool TriggerError = false;
149#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYERROR; } }
Reid Spencer713eedc2006-08-18 08:43:06 +0000150#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
151
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000152int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
153int yylex(); // declaration" of xxx warnings.
154int yyparse();
155
156namespace llvm {
157 std::string CurFilename;
158}
159using namespace llvm;
160
161static Module *ParserResult;
162
163// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
164// relating to upreferences in the input stream.
165//
166//#define DEBUG_UPREFS 1
167#ifdef DEBUG_UPREFS
168#define UR_OUT(X) std::cerr << X
169#else
170#define UR_OUT(X)
171#endif
172
173#define YYERROR_VERBOSE 1
174
175static bool ObsoleteVarArgs;
176static bool NewVarArgs;
Chris Lattner11ca4d62005-11-12 18:22:38 +0000177static BasicBlock *CurBB;
178static GlobalVariable *CurGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000179
180
181// This contains info used when building the body of a function. It is
182// destroyed when the function is completed.
183//
184typedef std::vector<Value *> ValueList; // Numbered defs
185static void
186ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
187 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
188
189static struct PerModuleInfo {
190 Module *CurrentModule;
191 std::map<const Type *, ValueList> Values; // Module level numbered definitions
192 std::map<const Type *,ValueList> LateResolveValues;
193 std::vector<PATypeHolder> Types;
194 std::map<ValID, PATypeHolder> LateResolveTypes;
195
196 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner7aa45902006-06-21 16:53:00 +0000197 /// how they were referenced and on which line of the input they came from so
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000198 /// that we can resolve them later and print error messages as appropriate.
199 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
200
201 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
202 // references to global values. Global values may be referenced before they
203 // are defined, and if so, the temporary object that they represent is held
204 // here. This is used for forward references of GlobalValues.
205 //
206 typedef std::map<std::pair<const PointerType *,
207 ValID>, GlobalValue*> GlobalRefsType;
208 GlobalRefsType GlobalRefs;
209
210 void ModuleDone() {
211 // If we could not resolve some functions at function compilation time
212 // (calls to functions before they are defined), resolve them now... Types
213 // are resolved when the constant pool has been completely parsed.
214 //
215 ResolveDefinitions(LateResolveValues);
Reid Spencer309080a2006-09-28 19:28:24 +0000216 if (TriggerError)
217 return;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000218
219 // Check to make sure that all global value forward references have been
220 // resolved!
221 //
222 if (!GlobalRefs.empty()) {
223 std::string UndefinedReferences = "Unresolved global references exist:\n";
224
225 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
226 I != E; ++I) {
227 UndefinedReferences += " " + I->first.first->getDescription() + " " +
228 I->first.second.getName() + "\n";
229 }
Reid Spencer713eedc2006-08-18 08:43:06 +0000230 GenerateError(UndefinedReferences);
Reid Spencer309080a2006-09-28 19:28:24 +0000231 return;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000232 }
233
Reid Spencerc8a9faf2006-01-19 01:21:04 +0000234 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattner9ff96a72006-04-08 01:18:56 +0000235 for (Module::iterator FI = CurrentModule->begin(),
236 FE = CurrentModule->end(); FI != FE; )
Chris Lattneradf5ec62006-03-04 07:53:41 +0000237 UpgradeCallsToIntrinsic(FI++);
Reid Spencerb4f9a6f2006-01-16 21:12:35 +0000238
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000239 Values.clear(); // Clear out function local definitions
240 Types.clear();
241 CurrentModule = 0;
242 }
243
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000244 // GetForwardRefForGlobal - Check to see if there is a forward reference
245 // for this global. If so, remove it from the GlobalRefs map and return it.
246 // If not, just return null.
247 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
248 // Check to see if there is a forward reference to this global variable...
249 // if there is, eliminate it and patch the reference to use the new def'n.
250 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
251 GlobalValue *Ret = 0;
252 if (I != GlobalRefs.end()) {
253 Ret = I->second;
254 GlobalRefs.erase(I);
255 }
256 return Ret;
257 }
258} CurModule;
259
260static struct PerFunctionInfo {
261 Function *CurrentFunction; // Pointer to current function being created
262
Anton Korobeynikov73441cd2006-09-14 18:25:26 +0000263 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000264 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +0000265 bool isDeclare; // Is this function a forward declararation?
266 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000267
268 /// BBForwardRefs - When we see forward references to basic blocks, keep
269 /// track of them here.
270 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
271 std::vector<BasicBlock*> NumberedBlocks;
272 unsigned NextBBNum;
273
274 inline PerFunctionInfo() {
275 CurrentFunction = 0;
276 isDeclare = false;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +0000277 Linkage = GlobalValue::ExternalLinkage;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000278 }
279
280 inline void FunctionStart(Function *M) {
281 CurrentFunction = M;
282 NextBBNum = 0;
283 }
284
285 void FunctionDone() {
286 NumberedBlocks.clear();
287
288 // Any forward referenced blocks left?
Reid Spencer309080a2006-09-28 19:28:24 +0000289 if (!BBForwardRefs.empty()) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000290 GenerateError("Undefined reference to label " +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000291 BBForwardRefs.begin()->first->getName());
Reid Spencer309080a2006-09-28 19:28:24 +0000292 return;
293 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000294
295 // Resolve all forward references now.
296 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
297
298 Values.clear(); // Clear out function local definitions
299 CurrentFunction = 0;
300 isDeclare = false;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +0000301 Linkage = GlobalValue::ExternalLinkage;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000302 }
303} CurFun; // Info for the current function...
304
305static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
306
307
308//===----------------------------------------------------------------------===//
309// Code to handle definitions of all the types
310//===----------------------------------------------------------------------===//
311
312static int InsertValue(Value *V,
313 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
314 if (V->hasName()) return -1; // Is this a numbered definition?
315
316 // Yes, insert the value into the value table...
317 ValueList &List = ValueTab[V->getType()];
318 List.push_back(V);
319 return List.size()-1;
320}
321
322static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
323 switch (D.Type) {
324 case ValID::NumberVal: // Is it a numbered definition?
325 // Module constants occupy the lowest numbered slots...
326 if ((unsigned)D.Num < CurModule.Types.size())
327 return CurModule.Types[(unsigned)D.Num];
328 break;
329 case ValID::NameVal: // Is it a named definition?
330 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
331 D.destroy(); // Free old strdup'd memory...
332 return N;
333 }
334 break;
335 default:
Reid Spencer713eedc2006-08-18 08:43:06 +0000336 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer309080a2006-09-28 19:28:24 +0000337 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000338 }
339
340 // If we reached here, we referenced either a symbol that we don't know about
341 // or an id number that hasn't been read yet. We may be referencing something
342 // forward, so just create an entry to be resolved later and get to it...
343 //
344 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
345
346
347 if (inFunctionScope()) {
Reid Spencer309080a2006-09-28 19:28:24 +0000348 if (D.Type == ValID::NameVal) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000349 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer309080a2006-09-28 19:28:24 +0000350 return 0;
351 } else {
Reid Spencer713eedc2006-08-18 08:43:06 +0000352 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer309080a2006-09-28 19:28:24 +0000353 return 0;
354 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000355 }
356
357 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
358 if (I != CurModule.LateResolveTypes.end())
359 return I->second;
360
361 Type *Typ = OpaqueType::get();
362 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
363 return Typ;
364 }
365
366static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
367 SymbolTable &SymTab =
368 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
369 CurModule.CurrentModule->getSymbolTable();
370 return SymTab.lookup(Ty, Name);
371}
372
373// getValNonImprovising - Look up the value specified by the provided type and
374// the provided ValID. If the value exists and has already been defined, return
375// it. Otherwise return null.
376//
377static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer309080a2006-09-28 19:28:24 +0000378 if (isa<FunctionType>(Ty)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000379 GenerateError("Functions are not values and "
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000380 "must be referenced as pointers");
Reid Spencer309080a2006-09-28 19:28:24 +0000381 return 0;
382 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000383
384 switch (D.Type) {
385 case ValID::NumberVal: { // Is it a numbered definition?
386 unsigned Num = (unsigned)D.Num;
387
388 // Module constants occupy the lowest numbered slots...
389 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
390 if (VI != CurModule.Values.end()) {
391 if (Num < VI->second.size())
392 return VI->second[Num];
393 Num -= VI->second.size();
394 }
395
396 // Make sure that our type is within bounds
397 VI = CurFun.Values.find(Ty);
398 if (VI == CurFun.Values.end()) return 0;
399
400 // Check that the number is within bounds...
401 if (VI->second.size() <= Num) return 0;
402
403 return VI->second[Num];
404 }
405
406 case ValID::NameVal: { // Is it a named definition?
407 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
408 if (N == 0) return 0;
409
410 D.destroy(); // Free old strdup'd memory...
411 return N;
412 }
413
414 // Check to make sure that "Ty" is an integral type, and that our
415 // value will fit into the specified type...
416 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencer309080a2006-09-28 19:28:24 +0000417 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000418 GenerateError("Signed integral constant '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000419 itostr(D.ConstPool64) + "' is invalid for type '" +
420 Ty->getDescription() + "'!");
Reid Spencer309080a2006-09-28 19:28:24 +0000421 return 0;
422 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000423 return ConstantSInt::get(Ty, D.ConstPool64);
424
425 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
426 if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
427 if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000428 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000429 "' is invalid or out of range!");
Reid Spencer309080a2006-09-28 19:28:24 +0000430 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000431 } else { // This is really a signed reference. Transmogrify.
432 return ConstantSInt::get(Ty, D.ConstPool64);
433 }
434 } else {
435 return ConstantUInt::get(Ty, D.UConstPool64);
436 }
437
438 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer309080a2006-09-28 19:28:24 +0000439 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000440 GenerateError("FP constant invalid for type!!");
Reid Spencer309080a2006-09-28 19:28:24 +0000441 return 0;
442 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000443 return ConstantFP::get(Ty, D.ConstPoolFP);
444
445 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer309080a2006-09-28 19:28:24 +0000446 if (!isa<PointerType>(Ty)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000447 GenerateError("Cannot create a a non pointer null!");
Reid Spencer309080a2006-09-28 19:28:24 +0000448 return 0;
449 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000450 return ConstantPointerNull::get(cast<PointerType>(Ty));
451
452 case ValID::ConstUndefVal: // Is it an undef value?
453 return UndefValue::get(Ty);
454
Chris Lattnera054d122005-12-21 17:53:23 +0000455 case ValID::ConstZeroVal: // Is it a zero value?
456 return Constant::getNullValue(Ty);
457
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000458 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer309080a2006-09-28 19:28:24 +0000459 if (D.ConstantValue->getType() != Ty) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000460 GenerateError("Constant expression type different from required type!");
Reid Spencer309080a2006-09-28 19:28:24 +0000461 return 0;
462 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000463 return D.ConstantValue;
464
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000465 case ValID::InlineAsmVal: { // Inline asm expression
466 const PointerType *PTy = dyn_cast<PointerType>(Ty);
467 const FunctionType *FTy =
468 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer309080a2006-09-28 19:28:24 +0000469 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000470 GenerateError("Invalid type for asm constraint string!");
Reid Spencer309080a2006-09-28 19:28:24 +0000471 return 0;
472 }
Chris Lattnere0a4ee92006-01-25 22:27:16 +0000473 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
474 D.IAD->HasSideEffects);
475 D.destroy(); // Free InlineAsmDescriptor.
476 return IA;
477 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000478 default:
479 assert(0 && "Unhandled case!");
480 return 0;
481 } // End of switch
482
483 assert(0 && "Unhandled case!");
484 return 0;
485}
486
487// getVal - This function is identical to getValNonImprovising, except that if a
488// value is not already defined, it "improvises" by creating a placeholder var
489// that looks and acts just like the requested variable. When the value is
490// defined later, all uses of the placeholder variable are replaced with the
491// real thing.
492//
493static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer309080a2006-09-28 19:28:24 +0000494 if (Ty == Type::LabelTy) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000495 GenerateError("Cannot use a basic block here");
Reid Spencer309080a2006-09-28 19:28:24 +0000496 return 0;
497 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000498
499 // See if the value has already been defined.
500 Value *V = getValNonImprovising(Ty, ID);
501 if (V) return V;
Reid Spencer309080a2006-09-28 19:28:24 +0000502 if (TriggerError) return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000503
Reid Spencer309080a2006-09-28 19:28:24 +0000504 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000505 GenerateError("Invalid use of a composite type!");
Reid Spencer309080a2006-09-28 19:28:24 +0000506 return 0;
507 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000508
509 // If we reached here, we referenced either a symbol that we don't know about
510 // or an id number that hasn't been read yet. We may be referencing something
511 // forward, so just create an entry to be resolved later and get to it...
512 //
513 V = new Argument(Ty);
514
515 // Remember where this forward reference came from. FIXME, shouldn't we try
516 // to recycle these things??
517 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
518 llvmAsmlineno)));
519
520 if (inFunctionScope())
521 InsertValue(V, CurFun.LateResolveValues);
522 else
523 InsertValue(V, CurModule.LateResolveValues);
524 return V;
525}
526
527/// getBBVal - This is used for two purposes:
528/// * If isDefinition is true, a new basic block with the specified ID is being
529/// defined.
530/// * If isDefinition is true, this is a reference to a basic block, which may
531/// or may not be a forward reference.
532///
533static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
534 assert(inFunctionScope() && "Can't get basic block at global scope!");
535
536 std::string Name;
537 BasicBlock *BB = 0;
538 switch (ID.Type) {
Reid Spencer309080a2006-09-28 19:28:24 +0000539 default:
540 GenerateError("Illegal label reference " + ID.getName());
541 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000542 case ValID::NumberVal: // Is it a numbered definition?
543 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
544 CurFun.NumberedBlocks.resize(ID.Num+1);
545 BB = CurFun.NumberedBlocks[ID.Num];
546 break;
547 case ValID::NameVal: // Is it a named definition?
548 Name = ID.Name;
549 if (Value *N = CurFun.CurrentFunction->
550 getSymbolTable().lookup(Type::LabelTy, Name))
551 BB = cast<BasicBlock>(N);
552 break;
553 }
554
555 // See if the block has already been defined.
556 if (BB) {
557 // If this is the definition of the block, make sure the existing value was
558 // just a forward reference. If it was a forward reference, there will be
559 // an entry for it in the PlaceHolderInfo map.
Reid Spencer309080a2006-09-28 19:28:24 +0000560 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000561 // The existing value was a definition, not a forward reference.
Reid Spencer713eedc2006-08-18 08:43:06 +0000562 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer309080a2006-09-28 19:28:24 +0000563 return 0;
564 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000565
566 ID.destroy(); // Free strdup'd memory.
567 return BB;
568 }
569
570 // Otherwise this block has not been seen before.
571 BB = new BasicBlock("", CurFun.CurrentFunction);
572 if (ID.Type == ValID::NameVal) {
573 BB->setName(ID.Name);
574 } else {
575 CurFun.NumberedBlocks[ID.Num] = BB;
576 }
577
578 // If this is not a definition, keep track of it so we can use it as a forward
579 // reference.
580 if (!isDefinition) {
581 // Remember where this forward reference came from.
582 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
583 } else {
584 // The forward declaration could have been inserted anywhere in the
585 // function: insert it into the correct place now.
586 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
587 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
588 }
589 ID.destroy();
590 return BB;
591}
592
593
594//===----------------------------------------------------------------------===//
595// Code to handle forward references in instructions
596//===----------------------------------------------------------------------===//
597//
598// This code handles the late binding needed with statements that reference
599// values not defined yet... for example, a forward branch, or the PHI node for
600// a loop body.
601//
602// This keeps a table (CurFun.LateResolveValues) of all such forward references
603// and back patchs after we are done.
604//
605
606// ResolveDefinitions - If we could not resolve some defs at parsing
607// time (forward branches, phi functions for loops, etc...) resolve the
608// defs now...
609//
610static void
611ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
612 std::map<const Type*,ValueList> *FutureLateResolvers) {
613 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
614 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
615 E = LateResolvers.end(); LRI != E; ++LRI) {
616 ValueList &List = LRI->second;
617 while (!List.empty()) {
618 Value *V = List.back();
619 List.pop_back();
620
621 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
622 CurModule.PlaceHolderInfo.find(V);
623 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
624
625 ValID &DID = PHI->second.first;
626
627 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer309080a2006-09-28 19:28:24 +0000628 if (TriggerError)
629 return;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000630 if (TheRealValue) {
631 V->replaceAllUsesWith(TheRealValue);
632 delete V;
633 CurModule.PlaceHolderInfo.erase(PHI);
634 } else if (FutureLateResolvers) {
635 // Functions have their unresolved items forwarded to the module late
636 // resolver table
637 InsertValue(V, *FutureLateResolvers);
638 } else {
Reid Spencer309080a2006-09-28 19:28:24 +0000639 if (DID.Type == ValID::NameVal) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000640 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000641 "' of type '" + V->getType()->getDescription() + "'",
642 PHI->second.second);
Reid Spencer309080a2006-09-28 19:28:24 +0000643 return;
644 } else {
Reid Spencer713eedc2006-08-18 08:43:06 +0000645 GenerateError("Reference to an invalid definition: #" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000646 itostr(DID.Num) + " of type '" +
647 V->getType()->getDescription() + "'",
648 PHI->second.second);
Reid Spencer309080a2006-09-28 19:28:24 +0000649 return;
650 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000651 }
652 }
653 }
654
655 LateResolvers.clear();
656}
657
658// ResolveTypeTo - A brand new type was just declared. This means that (if
659// name is not null) things referencing Name can be resolved. Otherwise, things
660// refering to the number can be resolved. Do this now.
661//
662static void ResolveTypeTo(char *Name, const Type *ToTy) {
663 ValID D;
664 if (Name) D = ValID::create(Name);
665 else D = ValID::create((int)CurModule.Types.size());
666
667 std::map<ValID, PATypeHolder>::iterator I =
668 CurModule.LateResolveTypes.find(D);
669 if (I != CurModule.LateResolveTypes.end()) {
670 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
671 CurModule.LateResolveTypes.erase(I);
672 }
673}
674
675// setValueName - Set the specified value to the name given. The name may be
676// null potentially, in which case this is a noop. The string passed in is
677// assumed to be a malloc'd string buffer, and is free'd by this function.
678//
679static void setValueName(Value *V, char *NameStr) {
680 if (NameStr) {
681 std::string Name(NameStr); // Copy string
682 free(NameStr); // Free old string
683
Reid Spencer309080a2006-09-28 19:28:24 +0000684 if (V->getType() == Type::VoidTy) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000685 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer309080a2006-09-28 19:28:24 +0000686 return;
687 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000688
689 assert(inFunctionScope() && "Must be in function scope!");
690 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
Reid Spencer309080a2006-09-28 19:28:24 +0000691 if (ST.lookup(V->getType(), Name)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000692 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000693 V->getType()->getDescription() + "' type plane!");
Reid Spencer309080a2006-09-28 19:28:24 +0000694 return;
695 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000696
697 // Set the name.
698 V->setName(Name);
699 }
700}
701
702/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
703/// this is a declaration, otherwise it is a definition.
Chris Lattner11ca4d62005-11-12 18:22:38 +0000704static GlobalVariable *
705ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
706 bool isConstantGlobal, const Type *Ty,
707 Constant *Initializer) {
Reid Spencer309080a2006-09-28 19:28:24 +0000708 if (isa<FunctionType>(Ty)) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000709 GenerateError("Cannot declare global vars of function type!");
Reid Spencer309080a2006-09-28 19:28:24 +0000710 return 0;
711 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000712
713 const PointerType *PTy = PointerType::get(Ty);
714
715 std::string Name;
716 if (NameStr) {
717 Name = NameStr; // Copy string
718 free(NameStr); // Free old string
719 }
720
721 // See if this global value was forward referenced. If so, recycle the
722 // object.
723 ValID ID;
724 if (!Name.empty()) {
725 ID = ValID::create((char*)Name.c_str());
726 } else {
727 ID = ValID::create((int)CurModule.Values[PTy].size());
728 }
729
730 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
731 // Move the global to the end of the list, from whereever it was
732 // previously inserted.
733 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
734 CurModule.CurrentModule->getGlobalList().remove(GV);
735 CurModule.CurrentModule->getGlobalList().push_back(GV);
736 GV->setInitializer(Initializer);
737 GV->setLinkage(Linkage);
738 GV->setConstant(isConstantGlobal);
739 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000740 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000741 }
742
743 // If this global has a name, check to see if there is already a definition
744 // of this global in the module. If so, merge as appropriate. Note that
745 // this is really just a hack around problems in the CFE. :(
746 if (!Name.empty()) {
747 // We are a simple redefinition of a value, check to see if it is defined
748 // the same as the old one.
749 if (GlobalVariable *EGV =
750 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
751 // We are allowed to redefine a global variable in two circumstances:
752 // 1. If at least one of the globals is uninitialized or
753 // 2. If both initializers have the same value.
754 //
755 if (!EGV->hasInitializer() || !Initializer ||
756 EGV->getInitializer() == Initializer) {
757
758 // Make sure the existing global version gets the initializer! Make
759 // sure that it also gets marked const if the new version is.
760 if (Initializer && !EGV->hasInitializer())
761 EGV->setInitializer(Initializer);
762 if (isConstantGlobal)
763 EGV->setConstant(true);
764 EGV->setLinkage(Linkage);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000765 return EGV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000766 }
767
Reid Spencer713eedc2006-08-18 08:43:06 +0000768 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000769 "' in the '" + Ty->getDescription() + "' type plane!");
Reid Spencer309080a2006-09-28 19:28:24 +0000770 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000771 }
772 }
773
774 // Otherwise there is no existing GV to use, create one now.
775 GlobalVariable *GV =
776 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
777 CurModule.CurrentModule);
778 InsertValue(GV, CurModule.Values);
Chris Lattner11ca4d62005-11-12 18:22:38 +0000779 return GV;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000780}
781
782// setTypeName - Set the specified type to the name given. The name may be
783// null potentially, in which case this is a noop. The string passed in is
784// assumed to be a malloc'd string buffer, and is freed by this function.
785//
786// This function returns true if the type has already been defined, but is
787// allowed to be redefined in the specified context. If the name is a new name
788// for the type plane, it is inserted and false is returned.
789static bool setTypeName(const Type *T, char *NameStr) {
790 assert(!inFunctionScope() && "Can't give types function-local names!");
791 if (NameStr == 0) return false;
792
793 std::string Name(NameStr); // Copy string
794 free(NameStr); // Free old string
795
796 // We don't allow assigning names to void type
Reid Spencer309080a2006-09-28 19:28:24 +0000797 if (T == Type::VoidTy) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000798 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer309080a2006-09-28 19:28:24 +0000799 return false;
800 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000801
802 // Set the type name, checking for conflicts as we do so.
803 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
804
805 if (AlreadyExists) { // Inserting a name that is already defined???
806 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
807 assert(Existing && "Conflict but no matching type?");
808
809 // There is only one case where this is allowed: when we are refining an
810 // opaque type. In this case, Existing will be an opaque type.
811 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
812 // We ARE replacing an opaque type!
813 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
814 return true;
815 }
816
817 // Otherwise, this is an attempt to redefine a type. That's okay if
818 // the redefinition is identical to the original. This will be so if
819 // Existing and T point to the same Type object. In this one case we
820 // allow the equivalent redefinition.
821 if (Existing == T) return true; // Yes, it's equal.
822
823 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer713eedc2006-08-18 08:43:06 +0000824 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000825 T->getDescription() + "' type plane!");
826 }
827
828 return false;
829}
830
831//===----------------------------------------------------------------------===//
832// Code for handling upreferences in type names...
833//
834
835// TypeContains - Returns true if Ty directly contains E in it.
836//
837static bool TypeContains(const Type *Ty, const Type *E) {
838 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
839 E) != Ty->subtype_end();
840}
841
842namespace {
843 struct UpRefRecord {
844 // NestingLevel - The number of nesting levels that need to be popped before
845 // this type is resolved.
846 unsigned NestingLevel;
847
848 // LastContainedTy - This is the type at the current binding level for the
849 // type. Every time we reduce the nesting level, this gets updated.
850 const Type *LastContainedTy;
851
852 // UpRefTy - This is the actual opaque type that the upreference is
853 // represented with.
854 OpaqueType *UpRefTy;
855
856 UpRefRecord(unsigned NL, OpaqueType *URTy)
857 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
858 };
859}
860
861// UpRefs - A list of the outstanding upreferences that need to be resolved.
862static std::vector<UpRefRecord> UpRefs;
863
864/// HandleUpRefs - Every time we finish a new layer of types, this function is
865/// called. It loops through the UpRefs vector, which is a list of the
866/// currently active types. For each type, if the up reference is contained in
867/// the newly completed type, we decrement the level count. When the level
868/// count reaches zero, the upreferenced type is the type that is passed in:
869/// thus we can complete the cycle.
870///
871static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner680aab62006-08-18 17:34:45 +0000872 // If Ty isn't abstract, or if there are no up-references in it, then there is
873 // nothing to resolve here.
874 if (!ty->isAbstract() || UpRefs.empty()) return ty;
875
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000876 PATypeHolder Ty(ty);
877 UR_OUT("Type '" << Ty->getDescription() <<
878 "' newly formed. Resolving upreferences.\n" <<
879 UpRefs.size() << " upreferences active!\n");
880
881 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
882 // to zero), we resolve them all together before we resolve them to Ty. At
883 // the end of the loop, if there is anything to resolve to Ty, it will be in
884 // this variable.
885 OpaqueType *TypeToResolve = 0;
886
887 for (unsigned i = 0; i != UpRefs.size(); ++i) {
888 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
889 << UpRefs[i].second->getDescription() << ") = "
890 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
891 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
892 // Decrement level of upreference
893 unsigned Level = --UpRefs[i].NestingLevel;
894 UpRefs[i].LastContainedTy = Ty;
895 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
896 if (Level == 0) { // Upreference should be resolved!
897 if (!TypeToResolve) {
898 TypeToResolve = UpRefs[i].UpRefTy;
899 } else {
900 UR_OUT(" * Resolving upreference for "
901 << UpRefs[i].second->getDescription() << "\n";
902 std::string OldName = UpRefs[i].UpRefTy->getDescription());
903 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
904 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
905 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
906 }
907 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
908 --i; // Do not skip the next element...
909 }
910 }
911 }
912
913 if (TypeToResolve) {
914 UR_OUT(" * Resolving upreference for "
915 << UpRefs[i].second->getDescription() << "\n";
916 std::string OldName = TypeToResolve->getDescription());
917 TypeToResolve->refineAbstractTypeTo(Ty);
918 }
919
920 return Ty;
921}
922
923
924// common code from the two 'RunVMAsmParser' functions
Reid Spencer309080a2006-09-28 19:28:24 +0000925static Module* RunParser(Module * M) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000926
927 llvmAsmlineno = 1; // Reset the current line number...
928 ObsoleteVarArgs = false;
929 NewVarArgs = false;
930
931 CurModule.CurrentModule = M;
932 yyparse(); // Parse the file, potentially throwing exception
Reid Spencer713eedc2006-08-18 08:43:06 +0000933 if (!ParserResult)
934 return 0;
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000935
936 Module *Result = ParserResult;
937 ParserResult = 0;
938
939 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
940 {
941 Function* F;
942 if ((F = Result->getNamedFunction("llvm.va_start"))
943 && F->getFunctionType()->getNumParams() == 0)
944 ObsoleteVarArgs = true;
945 if((F = Result->getNamedFunction("llvm.va_copy"))
946 && F->getFunctionType()->getNumParams() == 1)
947 ObsoleteVarArgs = true;
948 }
949
Reid Spencer309080a2006-09-28 19:28:24 +0000950 if (ObsoleteVarArgs && NewVarArgs) {
951 GenerateError(
952 "This file is corrupt: it uses both new and old style varargs");
953 return 0;
954 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000955
956 if(ObsoleteVarArgs) {
957 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
Reid Spencer309080a2006-09-28 19:28:24 +0000958 if (F->arg_size() != 0) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000959 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencer309080a2006-09-28 19:28:24 +0000960 return 0;
961 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000962
963 //foo = va_start()
964 // ->
965 //bar = alloca typeof(foo)
966 //va_start(bar)
967 //foo = load bar
968
969 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
970 const Type* ArgTy = F->getFunctionType()->getReturnType();
971 const Type* ArgTyPtr = PointerType::get(ArgTy);
972 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen11e26b52005-10-23 04:37:20 +0000973 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000974
975 while (!F->use_empty()) {
976 CallInst* CI = cast<CallInst>(F->use_back());
977 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
978 new CallInst(NF, bar, "", CI);
979 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
980 CI->replaceAllUsesWith(foo);
981 CI->getParent()->getInstList().erase(CI);
982 }
983 Result->getFunctionList().erase(F);
984 }
985
986 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
Reid Spencer309080a2006-09-28 19:28:24 +0000987 if(F->arg_size() != 1) {
Reid Spencer713eedc2006-08-18 08:43:06 +0000988 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencer309080a2006-09-28 19:28:24 +0000989 return 0;
990 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +0000991
992 //vaend foo
993 // ->
994 //bar = alloca 1 of typeof(foo)
995 //vaend bar
996 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
997 const Type* ArgTy = F->getFunctionType()->getParamType(0);
998 const Type* ArgTyPtr = PointerType::get(ArgTy);
999 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen11e26b52005-10-23 04:37:20 +00001000 RetTy, ArgTyPtr, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001001
1002 while (!F->use_empty()) {
1003 CallInst* CI = cast<CallInst>(F->use_back());
1004 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1005 new StoreInst(CI->getOperand(1), bar, CI);
1006 new CallInst(NF, bar, "", CI);
1007 CI->getParent()->getInstList().erase(CI);
1008 }
1009 Result->getFunctionList().erase(F);
1010 }
1011
1012 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
Reid Spencer309080a2006-09-28 19:28:24 +00001013 if(F->arg_size() != 1) {
Reid Spencer713eedc2006-08-18 08:43:06 +00001014 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencer309080a2006-09-28 19:28:24 +00001015 return 0;
1016 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001017 //foo = vacopy(bar)
1018 // ->
1019 //a = alloca 1 of typeof(foo)
1020 //b = alloca 1 of typeof(foo)
1021 //store bar -> b
1022 //vacopy(a, b)
1023 //foo = load a
1024
1025 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1026 const Type* ArgTy = F->getFunctionType()->getReturnType();
1027 const Type* ArgTyPtr = PointerType::get(ArgTy);
1028 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen11e26b52005-10-23 04:37:20 +00001029 RetTy, ArgTyPtr, ArgTyPtr,
1030 (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001031
1032 while (!F->use_empty()) {
1033 CallInst* CI = cast<CallInst>(F->use_back());
1034 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1035 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1036 new StoreInst(CI->getOperand(1), b, CI);
1037 new CallInst(NF, a, b, "", CI);
1038 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1039 CI->replaceAllUsesWith(foo);
1040 CI->getParent()->getInstList().erase(CI);
1041 }
1042 Result->getFunctionList().erase(F);
1043 }
1044 }
1045
1046 return Result;
Reid Spencer309080a2006-09-28 19:28:24 +00001047}
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001048
1049//===----------------------------------------------------------------------===//
1050// RunVMAsmParser - Define an interface to this parser
1051//===----------------------------------------------------------------------===//
1052//
1053Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1054 set_scan_file(F);
1055
1056 CurFilename = Filename;
1057 return RunParser(new Module(CurFilename));
1058}
1059
1060Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1061 set_scan_string(AsmString);
1062
1063 CurFilename = "from_memory";
1064 if (M == NULL) {
1065 return RunParser(new Module (CurFilename));
1066 } else {
1067 return RunParser(M);
1068 }
1069}
1070
1071
Chris Lattner6ab03f62006-09-28 23:35:22 +00001072#line 966 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1073typedef union {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001074 llvm::Module *ModuleVal;
1075 llvm::Function *FunctionVal;
1076 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1077 llvm::BasicBlock *BasicBlockVal;
1078 llvm::TerminatorInst *TermInstVal;
1079 llvm::Instruction *InstVal;
1080 llvm::Constant *ConstVal;
1081
1082 const llvm::Type *PrimType;
1083 llvm::PATypeHolder *TypeVal;
1084 llvm::Value *ValueVal;
1085
1086 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1087 std::vector<llvm::Value*> *ValueList;
1088 std::list<llvm::PATypeHolder> *TypeList;
1089 // Represent the RHS of PHI node
1090 std::list<std::pair<llvm::Value*,
1091 llvm::BasicBlock*> > *PHIList;
1092 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1093 std::vector<llvm::Constant*> *ConstVector;
1094
1095 llvm::GlobalValue::LinkageTypes Linkage;
1096 int64_t SInt64Val;
1097 uint64_t UInt64Val;
1098 int SIntVal;
1099 unsigned UIntVal;
1100 double FPVal;
1101 bool BoolVal;
1102
1103 char *StrVal; // This memory is strdup'd!
1104 llvm::ValID ValIDVal; // strdup'd memory maybe!
1105
1106 llvm::Instruction::BinaryOps BinaryOpVal;
1107 llvm::Instruction::TermOps TermOpVal;
1108 llvm::Instruction::MemoryOps MemOpVal;
1109 llvm::Instruction::OtherOps OtherOpVal;
1110 llvm::Module::Endianness Endianness;
Reid Spencer309080a2006-09-28 19:28:24 +00001111} YYSTYPE;
Chris Lattner6ab03f62006-09-28 23:35:22 +00001112#include <stdio.h>
1113
1114#ifndef __cplusplus
1115#ifndef __STDC__
1116#define const
1117#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001118#endif
1119
1120
1121
Chris Lattner6ab03f62006-09-28 23:35:22 +00001122#define YYFINAL 514
1123#define YYFLAG -32768
1124#define YYNTBASE 122
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001125
Chris Lattner6ab03f62006-09-28 23:35:22 +00001126#define YYTRANSLATE(x) ((unsigned)(x) <= 361 ? yytranslate[x] : 196)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001127
Chris Lattner6ab03f62006-09-28 23:35:22 +00001128static const char yytranslate[] = { 0,
1129 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1130 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1131 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1132 2, 2, 2, 2, 2, 2, 2, 2, 2, 111,
1133 112, 120, 2, 109, 2, 2, 2, 2, 2, 2,
1134 2, 2, 2, 2, 2, 2, 2, 2, 2, 116,
1135 108, 117, 2, 2, 2, 2, 2, 2, 2, 2,
1136 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1137 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1138 113, 110, 115, 2, 2, 2, 2, 2, 121, 2,
1139 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1140 2, 2, 2, 2, 2, 2, 2, 2, 2, 114,
1141 2, 2, 118, 2, 119, 2, 2, 2, 2, 2,
1142 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1143 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1144 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1145 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1146 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1147 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1148 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1149 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1150 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1151 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1152 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1153 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1154 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1155 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1156 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1157 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1158 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1159 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1160 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1161 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1162 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1163 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1164 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1165 107
1166};
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001167
Chris Lattner6ab03f62006-09-28 23:35:22 +00001168#if YYDEBUG != 0
1169static const short yyprhs[] = { 0,
1170 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1171 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1172 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1173 60, 62, 64, 67, 68, 70, 72, 74, 76, 78,
1174 80, 82, 83, 84, 86, 88, 90, 92, 94, 96,
1175 99, 100, 103, 104, 108, 111, 112, 114, 115, 119,
1176 121, 124, 126, 128, 130, 132, 134, 136, 138, 140,
1177 142, 144, 146, 148, 150, 152, 154, 156, 158, 160,
1178 162, 164, 166, 169, 174, 180, 186, 190, 193, 196,
1179 198, 202, 204, 208, 210, 211, 216, 220, 224, 229,
1180 234, 238, 241, 244, 247, 250, 253, 256, 259, 262,
1181 265, 268, 275, 281, 290, 297, 304, 311, 318, 325,
1182 334, 343, 347, 349, 351, 353, 355, 358, 361, 366,
1183 369, 371, 376, 379, 384, 385, 393, 394, 402, 403,
1184 411, 412, 420, 424, 429, 430, 432, 434, 436, 440,
1185 444, 448, 452, 456, 458, 459, 461, 463, 465, 466,
1186 469, 473, 475, 477, 481, 483, 484, 493, 495, 497,
1187 501, 503, 505, 508, 509, 511, 513, 514, 519, 520,
1188 522, 524, 526, 528, 530, 532, 534, 536, 538, 542,
1189 544, 550, 552, 554, 556, 558, 561, 564, 567, 571,
1190 574, 575, 577, 580, 583, 587, 597, 607, 616, 630,
1191 632, 634, 641, 647, 650, 657, 665, 667, 671, 673,
1192 674, 677, 679, 685, 691, 697, 700, 705, 710, 717,
1193 722, 727, 732, 737, 744, 751, 754, 762, 764, 767,
1194 768, 770, 771, 775, 782, 786, 793, 796, 801, 808
1195};
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001196
Chris Lattner6ab03f62006-09-28 23:35:22 +00001197static const short yyrhs[] = { 5,
1198 0, 6, 0, 3, 0, 4, 0, 77, 0, 78,
1199 0, 79, 0, 80, 0, 81, 0, 82, 0, 83,
1200 0, 84, 0, 85, 0, 86, 0, 87, 0, 88,
1201 0, 89, 0, 90, 0, 100, 0, 101, 0, 16,
1202 0, 14, 0, 12, 0, 10, 0, 17, 0, 15,
1203 0, 13, 0, 11, 0, 128, 0, 129, 0, 18,
1204 0, 19, 0, 164, 108, 0, 0, 41, 0, 42,
1205 0, 43, 0, 44, 0, 45, 0, 46, 0, 47,
1206 0, 0, 0, 65, 0, 66, 0, 67, 0, 68,
1207 0, 69, 0, 70, 0, 64, 4, 0, 0, 57,
1208 4, 0, 0, 109, 57, 4, 0, 34, 24, 0,
1209 0, 137, 0, 0, 109, 140, 139, 0, 137, 0,
1210 57, 4, 0, 143, 0, 8, 0, 145, 0, 8,
1211 0, 145, 0, 9, 0, 10, 0, 11, 0, 12,
1212 0, 13, 0, 14, 0, 15, 0, 16, 0, 17,
1213 0, 18, 0, 19, 0, 20, 0, 21, 0, 48,
1214 0, 144, 0, 179, 0, 110, 4, 0, 142, 111,
1215 147, 112, 0, 113, 4, 114, 145, 115, 0, 116,
1216 4, 114, 145, 117, 0, 118, 146, 119, 0, 118,
1217 119, 0, 145, 120, 0, 145, 0, 146, 109, 145,
1218 0, 146, 0, 146, 109, 37, 0, 37, 0, 0,
1219 143, 113, 150, 115, 0, 143, 113, 115, 0, 143,
1220 121, 24, 0, 143, 116, 150, 117, 0, 143, 118,
1221 150, 119, 0, 143, 118, 119, 0, 143, 38, 0,
1222 143, 39, 0, 143, 179, 0, 143, 149, 0, 143,
1223 26, 0, 128, 123, 0, 129, 4, 0, 9, 27,
1224 0, 9, 28, 0, 131, 7, 0, 98, 111, 148,
1225 36, 143, 112, 0, 96, 111, 148, 193, 112, 0,
1226 99, 111, 148, 109, 148, 109, 148, 112, 0, 124,
1227 111, 148, 109, 148, 112, 0, 125, 111, 148, 109,
1228 148, 112, 0, 126, 111, 148, 109, 148, 112, 0,
1229 127, 111, 148, 109, 148, 112, 0, 103, 111, 148,
1230 109, 148, 112, 0, 104, 111, 148, 109, 148, 109,
1231 148, 112, 0, 105, 111, 148, 109, 148, 109, 148,
1232 112, 0, 150, 109, 148, 0, 148, 0, 32, 0,
1233 33, 0, 153, 0, 153, 173, 0, 153, 175, 0,
1234 153, 62, 61, 159, 0, 153, 25, 0, 154, 0,
1235 154, 132, 20, 141, 0, 154, 175, 0, 154, 62,
1236 61, 159, 0, 0, 154, 132, 133, 151, 148, 155,
1237 139, 0, 0, 154, 132, 50, 151, 143, 156, 139,
1238 0, 0, 154, 132, 45, 151, 143, 157, 139, 0,
1239 0, 154, 132, 47, 151, 143, 158, 139, 0, 154,
1240 51, 161, 0, 154, 58, 108, 162, 0, 0, 24,
1241 0, 56, 0, 55, 0, 53, 108, 160, 0, 54,
1242 108, 4, 0, 52, 108, 24, 0, 113, 163, 115,
1243 0, 163, 109, 24, 0, 24, 0, 0, 22, 0,
1244 24, 0, 164, 0, 0, 143, 165, 0, 167, 109,
1245 166, 0, 166, 0, 167, 0, 167, 109, 37, 0,
1246 37, 0, 0, 134, 141, 164, 111, 168, 112, 138,
1247 135, 0, 29, 0, 118, 0, 133, 169, 170, 0,
1248 30, 0, 119, 0, 182, 172, 0, 0, 45, 0,
1249 47, 0, 0, 31, 176, 174, 169, 0, 0, 63,
1250 0, 3, 0, 4, 0, 7, 0, 27, 0, 28,
1251 0, 38, 0, 39, 0, 26, 0, 116, 150, 117,
1252 0, 149, 0, 61, 177, 24, 109, 24, 0, 122,
1253 0, 164, 0, 179, 0, 178, 0, 143, 180, 0,
1254 182, 183, 0, 171, 183, 0, 184, 132, 185, 0,
1255 184, 187, 0, 0, 23, 0, 71, 181, 0, 71,
1256 8, 0, 72, 21, 180, 0, 72, 9, 180, 109,
1257 21, 180, 109, 21, 180, 0, 73, 130, 180, 109,
1258 21, 180, 113, 186, 115, 0, 73, 130, 180, 109,
1259 21, 180, 113, 115, 0, 74, 134, 141, 180, 111,
1260 190, 112, 36, 21, 180, 75, 21, 180, 0, 75,
1261 0, 76, 0, 186, 130, 178, 109, 21, 180, 0,
1262 130, 178, 109, 21, 180, 0, 132, 192, 0, 143,
1263 113, 180, 109, 180, 115, 0, 188, 109, 113, 180,
1264 109, 180, 115, 0, 181, 0, 189, 109, 181, 0,
1265 189, 0, 0, 60, 59, 0, 59, 0, 124, 143,
1266 180, 109, 180, 0, 125, 143, 180, 109, 180, 0,
1267 126, 143, 180, 109, 180, 0, 49, 181, 0, 127,
1268 181, 109, 181, 0, 98, 181, 36, 143, 0, 99,
1269 181, 109, 181, 109, 181, 0, 102, 181, 109, 143,
1270 0, 106, 181, 109, 143, 0, 107, 181, 109, 143,
1271 0, 103, 181, 109, 181, 0, 104, 181, 109, 181,
1272 109, 181, 0, 105, 181, 109, 181, 109, 181, 0,
1273 97, 188, 0, 191, 134, 141, 180, 111, 190, 112,
1274 0, 195, 0, 109, 189, 0, 0, 35, 0, 0,
1275 91, 143, 136, 0, 91, 143, 109, 15, 180, 136,
1276 0, 92, 143, 136, 0, 92, 143, 109, 15, 180,
1277 136, 0, 93, 181, 0, 194, 94, 143, 180, 0,
1278 194, 95, 181, 109, 143, 180, 0, 96, 143, 180,
1279 193, 0
1280};
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001281
1282#endif
1283
Chris Lattner6ab03f62006-09-28 23:35:22 +00001284#if YYDEBUG != 0
1285static const short yyrline[] = { 0,
1286 1088, 1089, 1097, 1098, 1108, 1108, 1108, 1108, 1108, 1109,
1287 1109, 1109, 1110, 1110, 1110, 1110, 1110, 1110, 1112, 1112,
1288 1116, 1116, 1116, 1116, 1117, 1117, 1117, 1117, 1118, 1118,
1289 1119, 1119, 1122, 1126, 1131, 1131, 1132, 1133, 1134, 1135,
1290 1136, 1137, 1140, 1140, 1141, 1142, 1143, 1144, 1145, 1146,
1291 1156, 1156, 1163, 1163, 1172, 1180, 1180, 1186, 1186, 1188,
1292 1193, 1207, 1207, 1208, 1208, 1210, 1220, 1220, 1220, 1220,
1293 1220, 1220, 1220, 1221, 1221, 1221, 1221, 1221, 1221, 1222,
1294 1226, 1230, 1238, 1246, 1259, 1264, 1276, 1286, 1290, 1299,
1295 1304, 1310, 1311, 1315, 1319, 1330, 1356, 1370, 1400, 1426,
1296 1447, 1460, 1470, 1475, 1536, 1543, 1552, 1558, 1564, 1568,
1297 1572, 1580, 1591, 1623, 1631, 1653, 1664, 1670, 1678, 1684,
1298 1690, 1699, 1703, 1711, 1711, 1721, 1729, 1734, 1738, 1742,
1299 1746, 1761, 1783, 1786, 1789, 1794, 1797, 1801, 1805, 1809,
1300 1813, 1818, 1822, 1825, 1828, 1832, 1845, 1846, 1848, 1852,
1301 1861, 1867, 1869, 1874, 1879, 1888, 1888, 1889, 1889, 1891,
1302 1898, 1904, 1911, 1915, 1921, 1926, 1931, 2026, 2026, 2028,
1303 2036, 2036, 2038, 2043, 2043, 2044, 2047, 2047, 2057, 2061,
1304 2066, 2070, 2074, 2078, 2082, 2086, 2090, 2094, 2098, 2123,
1305 2127, 2141, 2145, 2151, 2151, 2157, 2162, 2166, 2175, 2186,
1306 2191, 2203, 2216, 2220, 2224, 2229, 2238, 2257, 2266, 2322,
1307 2326, 2333, 2344, 2357, 2366, 2375, 2385, 2389, 2396, 2396,
1308 2398, 2402, 2407, 2423, 2438, 2452, 2465, 2473, 2481, 2489,
1309 2495, 2515, 2538, 2544, 2550, 2556, 2571, 2630, 2637, 2640,
1310 2645, 2649, 2656, 2661, 2667, 2672, 2678, 2686, 2698, 2713
1311};
1312#endif
1313
1314
1315#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1316
1317static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1318"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1319"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1320"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1321"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1322"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1323"DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE",
1324"ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK",
1325"MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK",
1326"X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","RET","BR","SWITCH","INVOKE","UNWIND",
1327"UNREACHABLE","ADD","SUB","MUL","DIV","REM","AND","OR","XOR","SETLE","SETGE",
1328"SETLT","SETGT","SETEQ","SETNE","MALLOC","ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR",
1329"PHI_TOK","CAST","SELECT","SHL","SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT",
1330"SHUFFLEVECTOR","VAARG_old","VANEXT_old","'='","','","'\\\\'","'('","')'","'['",
1331"'x'","']'","'<'","'>'","'{'","'}'","'*'","'c'","INTVAL","EINT64VAL","ArithmeticOps",
1332"LogicalOps","SetCondOps","ShiftOps","SIntType","UIntType","IntType","FPType",
1333"OptAssign","OptLinkage","OptCallingConv","OptAlign","OptCAlign","SectionString",
1334"OptSection","GlobalVarAttributes","GlobalVarAttribute","TypesV","UpRTypesV",
1335"Types","PrimType","UpRTypes","TypeListI","ArgTypeListI","ConstVal","ConstExpr",
1336"ConstVector","GlobalType","Module","FunctionList","ConstPool","@1","@2","@3",
1337"@4","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition","LibList",
1338"Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader",
1339"END","Function","FnDeclareLinkage","FunctionProto","@5","OptSideEffect","ConstValueRef",
1340"SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList",
1341"BBTerminatorInst","JumpTable","Inst","PHIList","ValueRefList","ValueRefListE",
1342"OptTailCall","InstVal","IndexList","OptVolatile","MemoryInst", NULL
1343};
1344#endif
1345
1346static const short yyr1[] = { 0,
1347 122, 122, 123, 123, 124, 124, 124, 124, 124, 125,
1348 125, 125, 126, 126, 126, 126, 126, 126, 127, 127,
1349 128, 128, 128, 128, 129, 129, 129, 129, 130, 130,
1350 131, 131, 132, 132, 133, 133, 133, 133, 133, 133,
1351 133, 133, 134, 134, 134, 134, 134, 134, 134, 134,
1352 135, 135, 136, 136, 137, 138, 138, 139, 139, 140,
1353 140, 141, 141, 142, 142, 143, 144, 144, 144, 144,
1354 144, 144, 144, 144, 144, 144, 144, 144, 144, 145,
1355 145, 145, 145, 145, 145, 145, 145, 145, 145, 146,
1356 146, 147, 147, 147, 147, 148, 148, 148, 148, 148,
1357 148, 148, 148, 148, 148, 148, 148, 148, 148, 148,
1358 148, 149, 149, 149, 149, 149, 149, 149, 149, 149,
1359 149, 150, 150, 151, 151, 152, 153, 153, 153, 153,
1360 153, 154, 154, 154, 155, 154, 156, 154, 157, 154,
1361 158, 154, 154, 154, 154, 159, 160, 160, 161, 161,
1362 161, 162, 163, 163, 163, 164, 164, 165, 165, 166,
1363 167, 167, 168, 168, 168, 168, 169, 170, 170, 171,
1364 172, 172, 173, 174, 174, 174, 176, 175, 177, 177,
1365 178, 178, 178, 178, 178, 178, 178, 178, 178, 178,
1366 178, 179, 179, 180, 180, 181, 182, 182, 183, 184,
1367 184, 184, 185, 185, 185, 185, 185, 185, 185, 185,
1368 185, 186, 186, 187, 188, 188, 189, 189, 190, 190,
1369 191, 191, 192, 192, 192, 192, 192, 192, 192, 192,
1370 192, 192, 192, 192, 192, 192, 192, 192, 193, 193,
1371 194, 194, 195, 195, 195, 195, 195, 195, 195, 195
1372};
1373
1374static const short yyr2[] = { 0,
1375 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1376 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1377 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1378 1, 1, 2, 0, 1, 1, 1, 1, 1, 1,
1379 1, 0, 0, 1, 1, 1, 1, 1, 1, 2,
1380 0, 2, 0, 3, 2, 0, 1, 0, 3, 1,
1381 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1382 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1383 1, 1, 2, 4, 5, 5, 3, 2, 2, 1,
1384 3, 1, 3, 1, 0, 4, 3, 3, 4, 4,
1385 3, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1386 2, 6, 5, 8, 6, 6, 6, 6, 6, 8,
1387 8, 3, 1, 1, 1, 1, 2, 2, 4, 2,
1388 1, 4, 2, 4, 0, 7, 0, 7, 0, 7,
1389 0, 7, 3, 4, 0, 1, 1, 1, 3, 3,
1390 3, 3, 3, 1, 0, 1, 1, 1, 0, 2,
1391 3, 1, 1, 3, 1, 0, 8, 1, 1, 3,
1392 1, 1, 2, 0, 1, 1, 0, 4, 0, 1,
1393 1, 1, 1, 1, 1, 1, 1, 1, 3, 1,
1394 5, 1, 1, 1, 1, 2, 2, 2, 3, 2,
1395 0, 1, 2, 2, 3, 9, 9, 8, 13, 1,
1396 1, 6, 5, 2, 6, 7, 1, 3, 1, 0,
1397 2, 1, 5, 5, 5, 2, 4, 4, 6, 4,
1398 4, 4, 4, 6, 6, 2, 7, 1, 2, 0,
1399 1, 0, 3, 6, 3, 6, 2, 4, 6, 4
1400};
1401
1402static const short yydefact[] = { 145,
1403 42, 131, 130, 177, 35, 36, 37, 38, 39, 40,
1404 41, 0, 43, 201, 127, 128, 201, 156, 157, 0,
1405 0, 0, 42, 0, 133, 174, 0, 0, 44, 45,
1406 46, 47, 48, 49, 0, 0, 202, 198, 34, 171,
1407 172, 173, 197, 0, 0, 0, 143, 0, 0, 0,
1408 0, 0, 0, 0, 33, 175, 176, 43, 146, 129,
1409 50, 1, 2, 63, 67, 68, 69, 70, 71, 72,
1410 73, 74, 75, 76, 77, 78, 79, 80, 0, 0,
1411 0, 0, 192, 0, 0, 62, 81, 66, 193, 82,
1412 168, 169, 170, 242, 200, 0, 0, 0, 155, 144,
1413 134, 132, 124, 125, 0, 0, 0, 0, 178, 83,
1414 0, 0, 65, 88, 90, 0, 0, 95, 89, 241,
1415 0, 222, 0, 0, 0, 0, 43, 210, 211, 5,
1416 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
1417 16, 17, 18, 0, 0, 0, 0, 0, 0, 0,
1418 19, 20, 0, 0, 0, 0, 0, 0, 0, 0,
1419 0, 0, 199, 43, 214, 0, 238, 151, 148, 147,
1420 149, 150, 154, 0, 139, 141, 137, 67, 68, 69,
1421 70, 71, 72, 73, 74, 75, 76, 77, 0, 0,
1422 0, 0, 135, 0, 0, 0, 87, 166, 94, 92,
1423 0, 0, 226, 221, 204, 203, 0, 0, 24, 28,
1424 23, 27, 22, 26, 21, 25, 29, 30, 0, 0,
1425 53, 53, 247, 0, 0, 236, 0, 0, 0, 0,
1426 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1427 0, 0, 152, 58, 58, 58, 109, 110, 3, 4,
1428 107, 108, 111, 106, 102, 103, 0, 0, 0, 0,
1429 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1430 105, 104, 58, 64, 64, 91, 165, 159, 162, 163,
1431 0, 0, 84, 181, 182, 183, 188, 184, 185, 186,
1432 187, 179, 0, 190, 195, 194, 196, 0, 205, 0,
1433 0, 0, 243, 0, 245, 240, 0, 0, 0, 0,
1434 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1435 0, 0, 0, 153, 0, 140, 142, 138, 0, 0,
1436 0, 0, 0, 0, 97, 123, 0, 0, 101, 0,
1437 98, 0, 0, 0, 0, 136, 85, 86, 158, 160,
1438 0, 56, 93, 180, 0, 0, 0, 0, 0, 0,
1439 0, 0, 0, 250, 0, 0, 228, 0, 230, 233,
1440 0, 0, 231, 232, 0, 0, 0, 227, 0, 248,
1441 0, 0, 0, 60, 58, 240, 0, 0, 0, 0,
1442 0, 0, 96, 99, 100, 0, 0, 0, 0, 164,
1443 161, 57, 51, 0, 189, 0, 0, 220, 53, 54,
1444 53, 217, 239, 0, 0, 0, 0, 0, 223, 224,
1445 225, 220, 0, 55, 61, 59, 0, 0, 0, 0,
1446 0, 0, 122, 0, 0, 0, 0, 0, 167, 0,
1447 0, 0, 219, 0, 0, 244, 246, 0, 0, 0,
1448 229, 234, 235, 0, 249, 113, 0, 0, 0, 0,
1449 0, 0, 0, 0, 0, 52, 191, 0, 0, 0,
1450 218, 215, 0, 237, 112, 0, 119, 0, 0, 115,
1451 116, 117, 118, 0, 208, 0, 0, 0, 216, 0,
1452 0, 0, 206, 0, 207, 0, 0, 114, 120, 121,
1453 0, 0, 0, 0, 0, 0, 213, 0, 0, 212,
1454 209, 0, 0, 0
1455};
1456
1457static const short yydefgoto[] = { 83,
1458 251, 267, 268, 269, 270, 189, 190, 219, 191, 23,
1459 13, 35, 439, 303, 384, 403, 326, 385, 84, 85,
1460 192, 87, 88, 116, 201, 336, 294, 337, 105, 512,
1461 1, 2, 273, 246, 244, 245, 60, 171, 47, 100,
1462 174, 89, 350, 279, 280, 281, 36, 93, 14, 42,
1463 15, 58, 16, 26, 355, 295, 90, 297, 412, 17,
1464 38, 39, 163, 487, 95, 226, 443, 444, 164, 165,
1465 364, 166, 167
1466};
1467
1468static const short yypact[] = {-32768,
1469 194, 602,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1470-32768, -20, 38, 59,-32768,-32768, -18,-32768,-32768, 13,
1471 -8, 75, 115, 58,-32768, 40, 124, 163,-32768,-32768,
1472-32768,-32768,-32768,-32768, 1052, -22,-32768,-32768, -3,-32768,
1473-32768,-32768,-32768, 60, 65, 67,-32768, 57, 124, 1052,
1474 62, 62, 62, 62,-32768,-32768,-32768, 38,-32768,-32768,
1475-32768,-32768,-32768, 61,-32768,-32768,-32768,-32768,-32768,-32768,
1476-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 167, 172,
1477 173, 569,-32768, -3, 68,-32768,-32768, -30,-32768,-32768,
1478-32768,-32768,-32768, 1223,-32768, 159, 42, 180, 162,-32768,
1479-32768,-32768,-32768,-32768, 1093, 1093, 1093, 1134,-32768,-32768,
1480 73, 74,-32768,-32768, -30, -75, 78, 847,-32768,-32768,
1481 1093,-32768, 132, 1175, 14, 185, 38,-32768,-32768,-32768,
1482-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1483-32768,-32768,-32768, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
1484-32768,-32768, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
1485 1093, 1093,-32768, 38,-32768, 22,-32768,-32768,-32768,-32768,
1486-32768,-32768,-32768, -47,-32768,-32768,-32768, 111, 137, 199,
1487 140, 203, 142, 204, 147, 205, 210, 211, 151, 206,
1488 213, 412,-32768, 1093, 1093, 1093,-32768, 888,-32768, 103,
1489 110, 635,-32768,-32768, 61,-32768, 635, 635,-32768,-32768,
1490-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 635, 1052,
1491 114, 117,-32768, 635, 134, 118, 188, 119, 139, 141,
1492 144, 145, 146, 148, 635, 635, 635, 149, 1052, 1093,
1493 1093, 225,-32768, 150, 150, 150,-32768,-32768,-32768,-32768,
1494-32768,-32768,-32768,-32768,-32768,-32768, 152, 153, 154, 157,
1495 158, 175, 929, 1134, 589, 227, 176, 178, 179, 182,
1496-32768,-32768, 150, -51, -72, -30,-32768, -3,-32768, 161,
1497 183, 970,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1498-32768, 197, 1134,-32768,-32768,-32768,-32768, 164,-32768, 187,
1499 635, -4,-32768, 3,-32768, 189, 635, 171, 1093, 1093,
1500 1093, 1093, 1093, 1093, 1093, 1093, 193, 195, 200, 1093,
1501 635, 635, 201,-32768, -17,-32768,-32768,-32768, 1134, 1134,
1502 1134, 1134, 1134, 1134,-32768,-32768, -16, -26,-32768, -73,
1503-32768, 1134, 1134, 1134, 1134,-32768,-32768,-32768,-32768,-32768,
1504 1011, 228,-32768,-32768, 237, -25, 270, 273, 186, 635,
1505 299, 635, 1093,-32768, 214, 635,-32768, 215,-32768,-32768,
1506 216, 217,-32768,-32768, 635, 635, 635,-32768, 202,-32768,
1507 1093, 282, 304,-32768, 150, 189, 276, 218, 224, 229,
1508 230, 1134,-32768,-32768,-32768, 231, 232, 233, 234,-32768,
1509-32768,-32768, 257, 238,-32768, 635, 635, 1093, 239,-32768,
1510 239,-32768, 241, 635, 244, 1093, 1093, 1093,-32768,-32768,
1511-32768, 1093, 635,-32768,-32768,-32768, 242, 1093, 1134, 1134,
1512 1134, 1134,-32768, 1134, 1134, 1134, 1134, 311,-32768, 331,
1513 247, 245, 241, 248, 300,-32768,-32768, 1093, 246, 635,
1514-32768,-32768,-32768, 252,-32768,-32768, 254, 258, 260, 261,
1515 265, 263, 268, 272, 277,-32768,-32768, 348, 16, 341,
1516-32768,-32768, 275,-32768,-32768, 1134,-32768, 1134, 1134,-32768,
1517-32768,-32768,-32768, 635,-32768, 738, 63, 367,-32768, 279,
1518 280, 284,-32768, 285,-32768, 738, 635,-32768,-32768,-32768,
1519 376, 289, 324, 635, 379, 380,-32768, 635, 635,-32768,
1520-32768, 402, 403,-32768
1521};
1522
1523static const short yypgoto[] = {-32768,
1524-32768, 310, 312, 313, 314, -125, -124, -449,-32768, 366,
1525 386, -103,-32768, -219, 69,-32768, -236,-32768, -46,-32768,
1526 -35,-32768, -66, 292,-32768, -100, 219, -251, 80,-32768,
1527-32768,-32768,-32768,-32768,-32768,-32768, 363,-32768,-32768,-32768,
1528-32768, 4,-32768, 71,-32768,-32768, 356,-32768,-32768,-32768,
1529-32768,-32768, 413,-32768,-32768, -447, -55, 64, -99,-32768,
1530 399,-32768,-32768,-32768,-32768,-32768, 56, -2,-32768,-32768,
1531 37,-32768,-32768
1532};
1533
1534
1535#define YYLAST 1330
1536
1537
1538static const short yytable[] = { 86,
1539 217, 218, 305, 102, 37, 24, 91, 193, 327, 328,
1540 360, 40, 338, 340, 86, 115, 382, 362, 18, 486,
1541 19, 203, 207, 220, 206, 209, 210, 211, 212, 213,
1542 214, 215, 216, 196, 208, 392, 346, 496, 494, 383,
1543 27, 356, 24, 197, 348, 395, 223, 119, 502, 227,
1544 228, 115, 361, 229, 230, 231, 232, 233, 234, 361,
1545 239, 242, 238, 347, 44, 45, 46, 243, 119, 175,
1546 176, 177, 209, 210, 211, 212, 213, 214, 215, 216,
1547 -64, 37, 392, 392, 56, 202, 57, 117, 202, 119,
1548 394, 405, 392, 103, 104, 92, 169, 170, 393, 48,
1549 41, 28, 29, 30, 31, 32, 33, 34, 221, 222,
1550 202, 224, 225, 202, 202, 240, 241, 202, 202, 202,
1551 202, 202, 202, 235, 236, 237, 202, 274, 275, 276,
1552 485, 106, 107, 108, 50, 49, 272, 247, 248, -24,
1553 -24, 323, -23, -23, -22, -22, 296, 59, 426, -21,
1554 -21, 296, 296, 249, 250, 5, 6, 7, 8, 51,
1555 10, 52, 278, 296, 53, 55, 61, 96, 296, 99,
1556 110, -65, 97, 301, 98, 111, 112, 495, 118, 296,
1557 296, 296, 168, 172, 86, 173, 194, 195, 198, 446,
1558 204, 447, 321, -126, 209, 210, 211, 212, 213, 214,
1559 215, 216, -28, 86, 322, 202, -27, -26, -25, 252,
1560 368, 282, 370, 371, 372, 276, -31, -32, 3, 253,
1561 378, 283, 302, 309, 4, 304, 308, 310, 386, 387,
1562 388, 389, 390, 391, 5, 6, 7, 8, 9, 10,
1563 11, 396, 397, 398, 399, 296, 307, 311, 324, 312,
1564 341, 296, 313, 314, 315, 12, 316, 320, 325, 354,
1565 404, 382, 329, 330, 331, 296, 296, 332, 333, 351,
1566 298, 299, 357, 367, 202, 369, 202, 202, 202, 373,
1567 374, 349, 300, 366, 202, 334, 342, 306, 343, 344,
1568 406, 433, 345, 407, 352, 358, 408, 363, 317, 318,
1569 319, 375, 410, 376, 296, 424, 296, 425, 377, 381,
1570 296, 428, 422, 438, 466, 278, 451, 452, 453, 296,
1571 296, 296, 414, 416, 417, 418, 429, 202, 458, 459,
1572 460, 461, 430, 462, 463, 464, 465, 431, 432, 434,
1573 435, 436, 437, 217, 218, 423, 440, 445, 471, 448,
1574 296, 296, 450, 456, 467, 468, 361, 469, 296, 470,
1575 472, 217, 218, 474, 359, 475, 476, 296, 484, 478,
1576 365, 477, 202, 479, 480, 490, 488, 491, 492, 481,
1577 202, 202, 202, 482, 379, 380, 202, 497, 483, 489,
1578 498, 499, 457, 501, 296, 500, 504, 505, 506, 508,
1579 509, 513, 514, 159, 94, 160, 161, 162, 54, 200,
1580 271, 101, 202, 109, 25, 43, 62, 63, 413, 454,
1581 402, 401, 427, 409, 0, 411, 0, 0, 296, 415,
1582 0, 0, 0, 18, 0, 19, 0, 254, 419, 420,
1583 421, 296, 0, 0, 0, 0, 0, 0, 296, 255,
1584 256, 0, 296, 296, 0, 0, 0, 0, 0, 0,
1585 0, 0, 0, 0, 0, 0, 0, 0, 0, 441,
1586 442, 0, 0, 0, 0, 0, 0, 449, 0, 0,
1587 0, 0, 0, 0, 0, 0, 455, 0, 130, 131,
1588 132, 133, 134, 135, 136, 137, 138, 139, 140, 141,
1589 142, 143, 0, 0, 0, 0, 0, 257, 0, 258,
1590 259, 151, 152, 473, 260, 261, 262, 0, 0, 0,
1591 0, 0, 0, 0, 263, 0, 0, 264, 0, 265,
1592 0, 0, 266, 0, 0, 0, 0, 0, 0, 0,
1593 0, 0, 0, 0, 0, 0, 0, 493, 0, 0,
1594 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1595 503, 0, 0, 0, 0, 0, 0, 507, 0, 0,
1596 0, 510, 511, 62, 63, 0, 113, 65, 66, 67,
1597 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1598 18, 0, 19, 62, 63, 0, 113, 178, 179, 180,
1599 181, 182, 183, 184, 185, 186, 187, 188, 76, 77,
1600 18, 0, 19, 0, 0, 0, 78, 0, 0, 0,
1601 0, -34, 0, 18, 0, 19, 0, 0, 0, 0,
1602 0, 0, 4, -34, -34, 0, 78, 284, 285, 62,
1603 63, 286, -34, -34, -34, -34, -34, -34, -34, 0,
1604 0, -34, 20, 0, 0, 0, 18, 0, 19, 21,
1605 287, 288, 289, 22, 0, 0, 0, 0, 0, 0,
1606 0, 0, 290, 291, 0, 0, 0, 0, 79, 0,
1607 0, 80, 0, 0, 81, 0, 82, 114, 0, 0,
1608 0, 0, 0, 0, 0, 292, 0, 0, 79, 0,
1609 0, 80, 0, 0, 81, 0, 82, 339, 0, 0,
1610 0, 130, 131, 132, 133, 134, 135, 136, 137, 138,
1611 139, 140, 141, 142, 143, 0, 0, 0, 0, 0,
1612 257, 0, 258, 259, 151, 152, 0, 260, 261, 262,
1613 284, 285, 0, 0, 286, 0, 0, 0, 0, 0,
1614 293, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1615 0, 0, 0, 287, 288, 289, 0, 0, 0, 0,
1616 0, 0, 0, 0, 0, 290, 291, 0, 0, 0,
1617 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1618 0, 0, 0, 0, 0, 0, 0, 0, 292, 0,
1619 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1620 0, 0, 0, 0, 130, 131, 132, 133, 134, 135,
1621 136, 137, 138, 139, 140, 141, 142, 143, 0, 0,
1622 0, 0, 0, 257, 0, 258, 259, 151, 152, 0,
1623 260, 261, 262, 0, 0, 0, 0, 0, 0, 0,
1624 0, 62, 63, 293, 113, 65, 66, 67, 68, 69,
1625 70, 71, 72, 73, 74, 75, 76, 77, 18, 0,
1626 19, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1627 0, 0, 0, 199, 0, 0, 0, 0, 0, 0,
1628 0, 0, 62, 63, 78, 113, 65, 66, 67, 68,
1629 69, 70, 71, 72, 73, 74, 75, 76, 77, 18,
1630 0, 19, 0, 0, 0, 0, 0, 0, 0, 0,
1631 0, 0, 0, 0, 277, 0, 0, 0, 0, 0,
1632 0, 0, 0, 62, 63, 78, 113, 178, 179, 180,
1633 181, 182, 183, 184, 185, 186, 187, 188, 76, 77,
1634 18, 0, 19, 0, 0, 0, 79, 0, 0, 80,
1635 0, 0, 81, 0, 82, 0, 0, 0, 0, 0,
1636 0, 0, 0, 0, 62, 63, 78, 113, 65, 66,
1637 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1638 77, 18, 0, 19, 0, 0, 0, 79, 0, 0,
1639 80, 0, 0, 81, 0, 82, 353, 0, 0, 0,
1640 0, 0, 0, 0, 0, 62, 63, 78, 113, 65,
1641 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
1642 76, 77, 18, 0, 19, 0, 0, 0, 79, 0,
1643 0, 80, 0, 335, 81, 0, 82, 400, 0, 0,
1644 0, 0, 0, 0, 0, 0, 62, 63, 78, 64,
1645 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1646 75, 76, 77, 18, 0, 19, 0, 0, 0, 79,
1647 0, 0, 80, 0, 0, 81, 0, 82, 0, 0,
1648 0, 0, 0, 0, 0, 0, 0, 62, 63, 78,
1649 113, 65, 66, 67, 68, 69, 70, 71, 72, 73,
1650 74, 75, 76, 77, 18, 0, 19, 0, 0, 0,
1651 79, 0, 0, 80, 0, 0, 81, 0, 82, 0,
1652 0, 0, 0, 0, 0, 0, 0, 0, 62, 63,
1653 78, 113, 178, 179, 180, 181, 182, 183, 184, 185,
1654 186, 187, 188, 76, 77, 18, 0, 19, 0, 0,
1655 0, 79, 0, 0, 80, 0, 0, 81, 0, 82,
1656 0, 0, 0, 0, 0, 0, 0, 0, 0, 62,
1657 63, 78, 205, 65, 66, 67, 68, 69, 70, 71,
1658 72, 73, 74, 75, 76, 77, 18, 0, 19, 0,
1659 0, 0, 79, 0, 0, 80, 0, 0, 81, 0,
1660 82, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1661 0, 0, 78, 0, 0, 0, 0, 0, 0, 0,
1662 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1663 0, 0, 0, 79, 0, 0, 80, 0, 0, 81,
1664 0, 82, 0, 0, 0, 0, 0, 120, 0, 0,
1665 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1666 0, 121, 0, 0, 0, 0, 0, 0, 0, 0,
1667 0, 122, 123, 0, 79, 0, 0, 80, 0, 0,
1668 81, 0, 82, 124, 125, 126, 127, 128, 129, 130,
1669 131, 132, 133, 134, 135, 136, 137, 138, 139, 140,
1670 141, 142, 143, 144, 145, 146, 0, 0, 147, 148,
1671 149, 150, 151, 152, 153, 154, 155, 156, 157, 158
1672};
1673
1674static const short yycheck[] = { 35,
1675 126, 126, 222, 50, 23, 2, 29, 108, 245, 246,
1676 15, 30, 264, 265, 50, 82, 34, 15, 22, 469,
1677 24, 121, 9, 127, 124, 10, 11, 12, 13, 14,
1678 15, 16, 17, 109, 21, 109, 273, 487, 486, 57,
1679 61, 293, 39, 119, 117, 119, 146, 120, 496, 149,
1680 150, 118, 57, 153, 154, 155, 156, 157, 158, 57,
1681 164, 109, 162, 115, 52, 53, 54, 115, 120, 105,
1682 106, 107, 10, 11, 12, 13, 14, 15, 16, 17,
1683 111, 23, 109, 109, 45, 121, 47, 84, 124, 120,
1684 117, 117, 109, 32, 33, 118, 55, 56, 115, 108,
1685 119, 64, 65, 66, 67, 68, 69, 70, 144, 145,
1686 146, 147, 148, 149, 150, 94, 95, 153, 154, 155,
1687 156, 157, 158, 159, 160, 161, 162, 194, 195, 196,
1688 115, 52, 53, 54, 20, 61, 192, 27, 28, 3,
1689 4, 241, 3, 4, 3, 4, 202, 24, 385, 3,
1690 4, 207, 208, 3, 4, 41, 42, 43, 44, 45,
1691 46, 47, 198, 219, 50, 108, 4, 108, 224, 113,
1692 4, 111, 108, 220, 108, 4, 4, 115, 111, 235,
1693 236, 237, 24, 4, 220, 24, 114, 114, 111, 409,
1694 59, 411, 239, 0, 10, 11, 12, 13, 14, 15,
1695 16, 17, 4, 239, 240, 241, 4, 4, 4, 4,
1696 310, 109, 312, 313, 314, 282, 7, 7, 25, 7,
1697 320, 112, 109, 36, 31, 109, 109, 109, 329, 330,
1698 331, 332, 333, 334, 41, 42, 43, 44, 45, 46,
1699 47, 342, 343, 344, 345, 301, 113, 109, 24, 109,
1700 24, 307, 109, 109, 109, 62, 109, 109, 109, 63,
1701 24, 34, 111, 111, 111, 321, 322, 111, 111, 109,
1702 207, 208, 109, 309, 310, 311, 312, 313, 314, 315,
1703 316, 278, 219, 113, 320, 111, 111, 224, 111, 111,
1704 21, 392, 111, 21, 112, 109, 111, 109, 235, 236,
1705 237, 109, 4, 109, 360, 24, 362, 4, 109, 109,
1706 366, 36, 111, 57, 4, 351, 416, 417, 418, 375,
1707 376, 377, 109, 109, 109, 109, 109, 363, 429, 430,
1708 431, 432, 109, 434, 435, 436, 437, 109, 109, 109,
1709 109, 109, 109, 469, 469, 381, 109, 109, 448, 109,
1710 406, 407, 109, 112, 24, 109, 57, 113, 414, 112,
1711 115, 487, 487, 112, 301, 112, 109, 423, 21, 109,
1712 307, 112, 408, 109, 112, 476, 36, 478, 479, 112,
1713 416, 417, 418, 112, 321, 322, 422, 21, 112, 115,
1714 112, 112, 428, 109, 450, 112, 21, 109, 75, 21,
1715 21, 0, 0, 94, 39, 94, 94, 94, 23, 118,
1716 192, 49, 448, 58, 2, 17, 5, 6, 363, 422,
1717 352, 351, 386, 360, -1, 362, -1, -1, 484, 366,
1718 -1, -1, -1, 22, -1, 24, -1, 26, 375, 376,
1719 377, 497, -1, -1, -1, -1, -1, -1, 504, 38,
1720 39, -1, 508, 509, -1, -1, -1, -1, -1, -1,
1721 -1, -1, -1, -1, -1, -1, -1, -1, -1, 406,
1722 407, -1, -1, -1, -1, -1, -1, 414, -1, -1,
1723 -1, -1, -1, -1, -1, -1, 423, -1, 77, 78,
1724 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
1725 89, 90, -1, -1, -1, -1, -1, 96, -1, 98,
1726 99, 100, 101, 450, 103, 104, 105, -1, -1, -1,
1727 -1, -1, -1, -1, 113, -1, -1, 116, -1, 118,
1728 -1, -1, 121, -1, -1, -1, -1, -1, -1, -1,
1729 -1, -1, -1, -1, -1, -1, -1, 484, -1, -1,
1730 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1731 497, -1, -1, -1, -1, -1, -1, 504, -1, -1,
1732 -1, 508, 509, 5, 6, -1, 8, 9, 10, 11,
1733 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1734 22, -1, 24, 5, 6, -1, 8, 9, 10, 11,
1735 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1736 22, -1, 24, -1, -1, -1, 48, -1, -1, -1,
1737 -1, 20, -1, 22, -1, 24, -1, -1, -1, -1,
1738 -1, -1, 31, 32, 33, -1, 48, 3, 4, 5,
1739 6, 7, 41, 42, 43, 44, 45, 46, 47, -1,
1740 -1, 50, 51, -1, -1, -1, 22, -1, 24, 58,
1741 26, 27, 28, 62, -1, -1, -1, -1, -1, -1,
1742 -1, -1, 38, 39, -1, -1, -1, -1, 110, -1,
1743 -1, 113, -1, -1, 116, -1, 118, 119, -1, -1,
1744 -1, -1, -1, -1, -1, 61, -1, -1, 110, -1,
1745 -1, 113, -1, -1, 116, -1, 118, 119, -1, -1,
1746 -1, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1747 86, 87, 88, 89, 90, -1, -1, -1, -1, -1,
1748 96, -1, 98, 99, 100, 101, -1, 103, 104, 105,
1749 3, 4, -1, -1, 7, -1, -1, -1, -1, -1,
1750 116, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1751 -1, -1, -1, 26, 27, 28, -1, -1, -1, -1,
1752 -1, -1, -1, -1, -1, 38, 39, -1, -1, -1,
1753 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1754 -1, -1, -1, -1, -1, -1, -1, -1, 61, -1,
1755 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1756 -1, -1, -1, -1, 77, 78, 79, 80, 81, 82,
1757 83, 84, 85, 86, 87, 88, 89, 90, -1, -1,
1758 -1, -1, -1, 96, -1, 98, 99, 100, 101, -1,
1759 103, 104, 105, -1, -1, -1, -1, -1, -1, -1,
1760 -1, 5, 6, 116, 8, 9, 10, 11, 12, 13,
1761 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1762 24, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1763 -1, -1, -1, 37, -1, -1, -1, -1, -1, -1,
1764 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
1765 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1766 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
1767 -1, -1, -1, -1, 37, -1, -1, -1, -1, -1,
1768 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
1769 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1770 22, -1, 24, -1, -1, -1, 110, -1, -1, 113,
1771 -1, -1, 116, -1, 118, -1, -1, -1, -1, -1,
1772 -1, -1, -1, -1, 5, 6, 48, 8, 9, 10,
1773 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1774 21, 22, -1, 24, -1, -1, -1, 110, -1, -1,
1775 113, -1, -1, 116, -1, 118, 37, -1, -1, -1,
1776 -1, -1, -1, -1, -1, 5, 6, 48, 8, 9,
1777 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1778 20, 21, 22, -1, 24, -1, -1, -1, 110, -1,
1779 -1, 113, -1, 115, 116, -1, 118, 37, -1, -1,
1780 -1, -1, -1, -1, -1, -1, 5, 6, 48, 8,
1781 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1782 19, 20, 21, 22, -1, 24, -1, -1, -1, 110,
1783 -1, -1, 113, -1, -1, 116, -1, 118, -1, -1,
1784 -1, -1, -1, -1, -1, -1, -1, 5, 6, 48,
1785 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1786 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1787 110, -1, -1, 113, -1, -1, 116, -1, 118, -1,
1788 -1, -1, -1, -1, -1, -1, -1, -1, 5, 6,
1789 48, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1790 17, 18, 19, 20, 21, 22, -1, 24, -1, -1,
1791 -1, 110, -1, -1, 113, -1, -1, 116, -1, 118,
1792 -1, -1, -1, -1, -1, -1, -1, -1, -1, 5,
1793 6, 48, 8, 9, 10, 11, 12, 13, 14, 15,
1794 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1795 -1, -1, 110, -1, -1, 113, -1, -1, 116, -1,
1796 118, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1797 -1, -1, 48, -1, -1, -1, -1, -1, -1, -1,
1798 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1799 -1, -1, -1, 110, -1, -1, 113, -1, -1, 116,
1800 -1, 118, -1, -1, -1, -1, -1, 35, -1, -1,
1801 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1802 -1, 49, -1, -1, -1, -1, -1, -1, -1, -1,
1803 -1, 59, 60, -1, 110, -1, -1, 113, -1, -1,
1804 116, -1, 118, 71, 72, 73, 74, 75, 76, 77,
1805 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
1806 88, 89, 90, 91, 92, 93, -1, -1, 96, 97,
1807 98, 99, 100, 101, 102, 103, 104, 105, 106, 107
1808};
1809/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1810#line 3 "/usr/share/bison.simple"
1811/* This file comes from bison-1.28. */
1812
1813/* Skeleton output parser for bison,
1814 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1815
1816 This program is free software; you can redistribute it and/or modify
1817 it under the terms of the GNU General Public License as published by
1818 the Free Software Foundation; either version 2, or (at your option)
1819 any later version.
1820
1821 This program is distributed in the hope that it will be useful,
1822 but WITHOUT ANY WARRANTY; without even the implied warranty of
1823 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1824 GNU General Public License for more details.
1825
1826 You should have received a copy of the GNU General Public License
1827 along with this program; if not, write to the Free Software
1828 Foundation, Inc., 59 Temple Place - Suite 330,
1829 Boston, MA 02111-1307, USA. */
1830
1831/* As a special exception, when this file is copied by Bison into a
1832 Bison output file, you may use that output file without restriction.
1833 This special exception was added by the Free Software Foundation
1834 in version 1.24 of Bison. */
1835
1836/* This is the parser code that is written into each bison parser
1837 when the %semantic_parser declaration is not specified in the grammar.
1838 It was written by Richard Stallman by simplifying the hairy parser
1839 used when %semantic_parser is specified. */
1840
1841#ifndef YYSTACK_USE_ALLOCA
1842#ifdef alloca
1843#define YYSTACK_USE_ALLOCA
1844#else /* alloca not defined */
1845#ifdef __GNUC__
1846#define YYSTACK_USE_ALLOCA
1847#define alloca __builtin_alloca
1848#else /* not GNU C. */
1849#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1850#define YYSTACK_USE_ALLOCA
1851#include <alloca.h>
1852#else /* not sparc */
1853/* We think this test detects Watcom and Microsoft C. */
1854/* This used to test MSDOS, but that is a bad idea
1855 since that symbol is in the user namespace. */
1856#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1857#if 0 /* No need for malloc.h, which pollutes the namespace;
1858 instead, just don't use alloca. */
1859#include <malloc.h>
1860#endif
1861#else /* not MSDOS, or __TURBOC__ */
1862#if defined(_AIX)
1863/* I don't know what this was needed for, but it pollutes the namespace.
1864 So I turned it off. rms, 2 May 1997. */
1865/* #include <malloc.h> */
1866 #pragma alloca
1867#define YYSTACK_USE_ALLOCA
1868#else /* not MSDOS, or __TURBOC__, or _AIX */
1869#if 0
1870#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1871 and on HPUX 10. Eventually we can turn this on. */
1872#define YYSTACK_USE_ALLOCA
1873#define alloca __builtin_alloca
1874#endif /* __hpux */
1875#endif
1876#endif /* not _AIX */
1877#endif /* not MSDOS, or __TURBOC__ */
1878#endif /* not sparc */
1879#endif /* not GNU C */
1880#endif /* alloca not defined */
1881#endif /* YYSTACK_USE_ALLOCA not defined */
1882
1883#ifdef YYSTACK_USE_ALLOCA
1884#define YYSTACK_ALLOC alloca
Reid Spencer309080a2006-09-28 19:28:24 +00001885#else
Chris Lattner6ab03f62006-09-28 23:35:22 +00001886#define YYSTACK_ALLOC malloc
Reid Spencer309080a2006-09-28 19:28:24 +00001887#endif
1888
Chris Lattner6ab03f62006-09-28 23:35:22 +00001889/* Note: there must be only one dollar sign in this file.
1890 It is replaced by the list of actions, each action
1891 as one case of the switch. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001892
1893#define yyerrok (yyerrstatus = 0)
1894#define yyclearin (yychar = YYEMPTY)
Chris Lattner6ab03f62006-09-28 23:35:22 +00001895#define YYEMPTY -2
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001896#define YYEOF 0
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001897#define YYACCEPT goto yyacceptlab
Chris Lattner6ab03f62006-09-28 23:35:22 +00001898#define YYABORT goto yyabortlab
1899#define YYERROR goto yyerrlab1
1900/* Like YYERROR except do call yyerror.
1901 This remains here temporarily to ease the
1902 transition to the new meaning of YYERROR, for GCC.
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001903 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001904#define YYFAIL goto yyerrlab
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001905#define YYRECOVERING() (!!yyerrstatus)
Chris Lattner6ab03f62006-09-28 23:35:22 +00001906#define YYBACKUP(token, value) \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001907do \
1908 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattner6ab03f62006-09-28 23:35:22 +00001909 { yychar = (token), yylval = (value); \
1910 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer309080a2006-09-28 19:28:24 +00001911 YYPOPSTACK; \
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001912 goto yybackup; \
1913 } \
1914 else \
Chris Lattner6ab03f62006-09-28 23:35:22 +00001915 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer309080a2006-09-28 19:28:24 +00001916while (0)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001917
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001918#define YYTERROR 1
1919#define YYERRCODE 256
1920
Chris Lattner6ab03f62006-09-28 23:35:22 +00001921#ifndef YYPURE
1922#define YYLEX yylex()
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001923#endif
1924
Chris Lattner6ab03f62006-09-28 23:35:22 +00001925#ifdef YYPURE
1926#ifdef YYLSP_NEEDED
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001927#ifdef YYLEX_PARAM
Chris Lattner6ab03f62006-09-28 23:35:22 +00001928#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001929#else
Chris Lattner6ab03f62006-09-28 23:35:22 +00001930#define YYLEX yylex(&yylval, &yylloc)
1931#endif
1932#else /* not YYLSP_NEEDED */
1933#ifdef YYLEX_PARAM
1934#define YYLEX yylex(&yylval, YYLEX_PARAM)
1935#else
1936#define YYLEX yylex(&yylval)
1937#endif
1938#endif /* not YYLSP_NEEDED */
Chris Lattner680aab62006-08-18 17:34:45 +00001939#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001940
Chris Lattner6ab03f62006-09-28 23:35:22 +00001941/* If nonreentrant, generate the variables here */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001942
Chris Lattner6ab03f62006-09-28 23:35:22 +00001943#ifndef YYPURE
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001944
Chris Lattner6ab03f62006-09-28 23:35:22 +00001945int yychar; /* the lookahead symbol */
1946YYSTYPE yylval; /* the semantic value of the */
1947 /* lookahead symbol */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00001948
Chris Lattner6ab03f62006-09-28 23:35:22 +00001949#ifdef YYLSP_NEEDED
1950YYLTYPE yylloc; /* location data for the lookahead */
1951 /* symbol */
Chris Lattneredd9b032006-01-23 23:05:42 +00001952#endif
Reid Spencer713eedc2006-08-18 08:43:06 +00001953
Chris Lattner6ab03f62006-09-28 23:35:22 +00001954int yynerrs; /* number of parse errors so far */
1955#endif /* not YYPURE */
Reid Spencer713eedc2006-08-18 08:43:06 +00001956
Chris Lattner6ab03f62006-09-28 23:35:22 +00001957#if YYDEBUG != 0
1958int yydebug; /* nonzero means print parse trace */
1959/* Since this is uninitialized, it does not stop multiple parsers
1960 from coexisting. */
Robert Bocchinofdf9e412006-01-17 20:06:25 +00001961#endif
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001962
Chris Lattner6ab03f62006-09-28 23:35:22 +00001963/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencerc8a9faf2006-01-19 01:21:04 +00001964
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001965#ifndef YYINITDEPTH
Chris Lattner6ab03f62006-09-28 23:35:22 +00001966#define YYINITDEPTH 200
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001967#endif
1968
Chris Lattner6ab03f62006-09-28 23:35:22 +00001969/* YYMAXDEPTH is the maximum size the stacks can grow to
1970 (effective only if the built-in stack extension method is used). */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001971
Chris Lattner6ab03f62006-09-28 23:35:22 +00001972#if YYMAXDEPTH == 0
1973#undef YYMAXDEPTH
1974#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001975
1976#ifndef YYMAXDEPTH
Chris Lattner6ab03f62006-09-28 23:35:22 +00001977#define YYMAXDEPTH 10000
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001978#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001979
Chris Lattner6ab03f62006-09-28 23:35:22 +00001980/* Define __yy_memcpy. Note that the size argument
1981 should be passed with type unsigned int, because that is what the non-GCC
1982 definitions require. With GCC, __builtin_memcpy takes an arg
1983 of type size_t, but it can handle unsigned int. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001984
Chris Lattner6ab03f62006-09-28 23:35:22 +00001985#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
1986#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
1987#else /* not GNU C or C++ */
1988#ifndef __cplusplus
Reid Spencerdfb3fb42005-08-27 18:50:39 +00001989
Chris Lattner6ab03f62006-09-28 23:35:22 +00001990/* This is the most reliable way to avoid incompatibilities
1991 in available built-in functions on various systems. */
Reid Spencer309080a2006-09-28 19:28:24 +00001992static void
Chris Lattner6ab03f62006-09-28 23:35:22 +00001993__yy_memcpy (to, from, count)
1994 char *to;
1995 char *from;
1996 unsigned int count;
1997{
1998 register char *f = from;
1999 register char *t = to;
2000 register int i = count;
2001
2002 while (i-- > 0)
2003 *t++ = *f++;
2004}
2005
2006#else /* __cplusplus */
2007
2008/* This is the most reliable way to avoid incompatibilities
2009 in available built-in functions on various systems. */
Reid Spencer309080a2006-09-28 19:28:24 +00002010static void
Chris Lattner6ab03f62006-09-28 23:35:22 +00002011__yy_memcpy (char *to, char *from, unsigned int count)
2012{
2013 register char *t = to;
2014 register char *f = from;
2015 register int i = count;
2016
2017 while (i-- > 0)
2018 *t++ = *f++;
2019}
2020
Reid Spencer309080a2006-09-28 19:28:24 +00002021#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002022#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002023
Chris Lattner6ab03f62006-09-28 23:35:22 +00002024#line 217 "/usr/share/bison.simple"
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002025
Chris Lattner6ab03f62006-09-28 23:35:22 +00002026/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2027 into yyparse. The argument should have type void *.
2028 It should actually point to an object.
2029 Grammar actions can access the variable by casting it
2030 to the proper pointer type. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002031
2032#ifdef YYPARSE_PARAM
Chris Lattner6ab03f62006-09-28 23:35:22 +00002033#ifdef __cplusplus
2034#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2035#define YYPARSE_PARAM_DECL
2036#else /* not __cplusplus */
2037#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2038#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2039#endif /* not __cplusplus */
2040#else /* not YYPARSE_PARAM */
2041#define YYPARSE_PARAM_ARG
2042#define YYPARSE_PARAM_DECL
2043#endif /* not YYPARSE_PARAM */
2044
2045/* Prevent warning if -Wstrict-prototypes. */
2046#ifdef __GNUC__
2047#ifdef YYPARSE_PARAM
2048int yyparse (void *);
2049#else
Reid Spencerc8a9faf2006-01-19 01:21:04 +00002050int yyparse (void);
Chris Lattner680aab62006-08-18 17:34:45 +00002051#endif
Chris Lattner6ab03f62006-09-28 23:35:22 +00002052#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002053
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002054int
Chris Lattner6ab03f62006-09-28 23:35:22 +00002055yyparse(YYPARSE_PARAM_ARG)
2056 YYPARSE_PARAM_DECL
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002057{
Chris Lattner6ab03f62006-09-28 23:35:22 +00002058 register int yystate;
2059 register int yyn;
2060 register short *yyssp;
2061 register YYSTYPE *yyvsp;
2062 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2063 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002064
Chris Lattner6ab03f62006-09-28 23:35:22 +00002065 short yyssa[YYINITDEPTH]; /* the state stack */
2066 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002067
Chris Lattner6ab03f62006-09-28 23:35:22 +00002068 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2069 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002070
Chris Lattner6ab03f62006-09-28 23:35:22 +00002071#ifdef YYLSP_NEEDED
2072 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2073 YYLTYPE *yyls = yylsa;
2074 YYLTYPE *yylsp;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002075
Chris Lattner6ab03f62006-09-28 23:35:22 +00002076#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2077#else
Reid Spencer309080a2006-09-28 19:28:24 +00002078#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattner6ab03f62006-09-28 23:35:22 +00002079#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002080
Chris Lattner6ab03f62006-09-28 23:35:22 +00002081 int yystacksize = YYINITDEPTH;
2082 int yyfree_stacks = 0;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002083
Chris Lattner6ab03f62006-09-28 23:35:22 +00002084#ifdef YYPURE
2085 int yychar;
2086 YYSTYPE yylval;
2087 int yynerrs;
2088#ifdef YYLSP_NEEDED
2089 YYLTYPE yylloc;
2090#endif
2091#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002092
Chris Lattner6ab03f62006-09-28 23:35:22 +00002093 YYSTYPE yyval; /* the variable used to return */
2094 /* semantic values from the action */
2095 /* routines */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002096
Reid Spencer309080a2006-09-28 19:28:24 +00002097 int yylen;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002098
Chris Lattner6ab03f62006-09-28 23:35:22 +00002099#if YYDEBUG != 0
2100 if (yydebug)
2101 fprintf(stderr, "Starting parse\n");
2102#endif
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002103
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002104 yystate = 0;
2105 yyerrstatus = 0;
2106 yynerrs = 0;
2107 yychar = YYEMPTY; /* Cause a token to be read. */
2108
2109 /* Initialize stack pointers.
2110 Waste one element of value and location stack
2111 so that they stay on the same level as the state stack.
2112 The wasted elements are never initialized. */
2113
Chris Lattner6ab03f62006-09-28 23:35:22 +00002114 yyssp = yyss - 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002115 yyvsp = yyvs;
Chris Lattner6ab03f62006-09-28 23:35:22 +00002116#ifdef YYLSP_NEEDED
2117 yylsp = yyls;
2118#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002119
Chris Lattner6ab03f62006-09-28 23:35:22 +00002120/* Push a new state, which is found in yystate . */
2121/* In all cases, when you get here, the value and location stacks
2122 have just been pushed. so pushing a state here evens the stacks. */
2123yynewstate:
Jeff Cohen11e26b52005-10-23 04:37:20 +00002124
Chris Lattner6ab03f62006-09-28 23:35:22 +00002125 *++yyssp = yystate;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002126
Chris Lattner6ab03f62006-09-28 23:35:22 +00002127 if (yyssp >= yyss + yystacksize - 1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002128 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00002129 /* Give user a chance to reallocate the stack */
2130 /* Use copies of these so that the &'s don't force the real ones into memory. */
2131 YYSTYPE *yyvs1 = yyvs;
2132 short *yyss1 = yyss;
2133#ifdef YYLSP_NEEDED
2134 YYLTYPE *yyls1 = yyls;
2135#endif
2136
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002137 /* Get the current used size of the three stacks, in elements. */
Chris Lattner6ab03f62006-09-28 23:35:22 +00002138 int size = yyssp - yyss + 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002139
2140#ifdef yyoverflow
Chris Lattner6ab03f62006-09-28 23:35:22 +00002141 /* Each stack pointer address is followed by the size of
2142 the data in use in that stack, in bytes. */
2143#ifdef YYLSP_NEEDED
2144 /* This used to be a conditional around just the two extra args,
2145 but that might be undefined if yyoverflow is a macro. */
2146 yyoverflow("parser stack overflow",
2147 &yyss1, size * sizeof (*yyssp),
2148 &yyvs1, size * sizeof (*yyvsp),
2149 &yyls1, size * sizeof (*yylsp),
2150 &yystacksize);
2151#else
2152 yyoverflow("parser stack overflow",
2153 &yyss1, size * sizeof (*yyssp),
2154 &yyvs1, size * sizeof (*yyvsp),
2155 &yystacksize);
2156#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002157
Chris Lattner6ab03f62006-09-28 23:35:22 +00002158 yyss = yyss1; yyvs = yyvs1;
2159#ifdef YYLSP_NEEDED
2160 yyls = yyls1;
2161#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002162#else /* no yyoverflow */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002163 /* Extend the stack our own way. */
Chris Lattner6ab03f62006-09-28 23:35:22 +00002164 if (yystacksize >= YYMAXDEPTH)
2165 {
2166 yyerror("parser stack overflow");
2167 if (yyfree_stacks)
2168 {
2169 free (yyss);
2170 free (yyvs);
2171#ifdef YYLSP_NEEDED
2172 free (yyls);
2173#endif
2174 }
2175 return 2;
2176 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002177 yystacksize *= 2;
Chris Lattner6ab03f62006-09-28 23:35:22 +00002178 if (yystacksize > YYMAXDEPTH)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002179 yystacksize = YYMAXDEPTH;
Chris Lattner6ab03f62006-09-28 23:35:22 +00002180#ifndef YYSTACK_USE_ALLOCA
2181 yyfree_stacks = 1;
2182#endif
2183 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2184 __yy_memcpy ((char *)yyss, (char *)yyss1,
2185 size * (unsigned int) sizeof (*yyssp));
2186 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2187 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2188 size * (unsigned int) sizeof (*yyvsp));
2189#ifdef YYLSP_NEEDED
2190 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2191 __yy_memcpy ((char *)yyls, (char *)yyls1,
2192 size * (unsigned int) sizeof (*yylsp));
2193#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002194#endif /* no yyoverflow */
2195
Chris Lattner6ab03f62006-09-28 23:35:22 +00002196 yyssp = yyss + size - 1;
2197 yyvsp = yyvs + size - 1;
2198#ifdef YYLSP_NEEDED
2199 yylsp = yyls + size - 1;
2200#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002201
Chris Lattner6ab03f62006-09-28 23:35:22 +00002202#if YYDEBUG != 0
2203 if (yydebug)
2204 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2205#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002206
Chris Lattner6ab03f62006-09-28 23:35:22 +00002207 if (yyssp >= yyss + yystacksize - 1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002208 YYABORT;
2209 }
2210
Chris Lattner6ab03f62006-09-28 23:35:22 +00002211#if YYDEBUG != 0
2212 if (yydebug)
2213 fprintf(stderr, "Entering state %d\n", yystate);
2214#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002215
2216 goto yybackup;
Chris Lattner6ab03f62006-09-28 23:35:22 +00002217 yybackup:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002218
Reid Spencer309080a2006-09-28 19:28:24 +00002219/* Do appropriate processing given the current state. */
Chris Lattner6ab03f62006-09-28 23:35:22 +00002220/* Read a lookahead token if we need one and don't already have one. */
Reid Spencer309080a2006-09-28 19:28:24 +00002221/* yyresume: */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002222
Chris Lattner6ab03f62006-09-28 23:35:22 +00002223 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer309080a2006-09-28 19:28:24 +00002224
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002225 yyn = yypact[yystate];
Chris Lattner6ab03f62006-09-28 23:35:22 +00002226 if (yyn == YYFLAG)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002227 goto yydefault;
2228
Chris Lattner6ab03f62006-09-28 23:35:22 +00002229 /* Not known => get a lookahead token if don't already have one. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002230
Chris Lattner6ab03f62006-09-28 23:35:22 +00002231 /* yychar is either YYEMPTY or YYEOF
2232 or a valid token in external form. */
2233
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002234 if (yychar == YYEMPTY)
2235 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00002236#if YYDEBUG != 0
2237 if (yydebug)
2238 fprintf(stderr, "Reading a token: ");
2239#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002240 yychar = YYLEX;
2241 }
2242
Chris Lattner6ab03f62006-09-28 23:35:22 +00002243 /* Convert token to internal form (in yychar1) for indexing tables with */
2244
2245 if (yychar <= 0) /* This means end of input. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002246 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00002247 yychar1 = 0;
2248 yychar = YYEOF; /* Don't call YYLEX any more */
2249
2250#if YYDEBUG != 0
2251 if (yydebug)
2252 fprintf(stderr, "Now at end of input.\n");
2253#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002254 }
2255 else
2256 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00002257 yychar1 = YYTRANSLATE(yychar);
2258
2259#if YYDEBUG != 0
2260 if (yydebug)
2261 {
2262 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2263 /* Give the individual parser a way to print the precise meaning
2264 of a token, for further debugging info. */
2265#ifdef YYPRINT
2266 YYPRINT (stderr, yychar, yylval);
2267#endif
2268 fprintf (stderr, ")\n");
2269 }
2270#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002271 }
2272
Chris Lattner6ab03f62006-09-28 23:35:22 +00002273 yyn += yychar1;
2274 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002275 goto yydefault;
Chris Lattner6ab03f62006-09-28 23:35:22 +00002276
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002277 yyn = yytable[yyn];
Chris Lattner6ab03f62006-09-28 23:35:22 +00002278
2279 /* yyn is what to do for this token type in this state.
2280 Negative => reduce, -yyn is rule number.
2281 Positive => shift, yyn is new state.
2282 New state is final state => don't bother to shift,
2283 just return success.
2284 0, or most negative number => error. */
2285
2286 if (yyn < 0)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002287 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00002288 if (yyn == YYFLAG)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002289 goto yyerrlab;
2290 yyn = -yyn;
2291 goto yyreduce;
2292 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00002293 else if (yyn == 0)
2294 goto yyerrlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002295
2296 if (yyn == YYFINAL)
2297 YYACCEPT;
2298
Chris Lattner6ab03f62006-09-28 23:35:22 +00002299 /* Shift the lookahead token. */
2300
2301#if YYDEBUG != 0
2302 if (yydebug)
2303 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2304#endif
Reid Spencer309080a2006-09-28 19:28:24 +00002305
2306 /* Discard the token being shifted unless it is eof. */
2307 if (yychar != YYEOF)
2308 yychar = YYEMPTY;
2309
2310 *++yyvsp = yylval;
Chris Lattner6ab03f62006-09-28 23:35:22 +00002311#ifdef YYLSP_NEEDED
2312 *++yylsp = yylloc;
2313#endif
Reid Spencer309080a2006-09-28 19:28:24 +00002314
Chris Lattner6ab03f62006-09-28 23:35:22 +00002315 /* count tokens shifted since error; after three, turn off error status. */
2316 if (yyerrstatus) yyerrstatus--;
Chris Lattner680aab62006-08-18 17:34:45 +00002317
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002318 yystate = yyn;
2319 goto yynewstate;
2320
Chris Lattner6ab03f62006-09-28 23:35:22 +00002321/* Do the default action for the current state. */
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00002322yydefault:
Chris Lattner6ab03f62006-09-28 23:35:22 +00002323
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002324 yyn = yydefact[yystate];
2325 if (yyn == 0)
2326 goto yyerrlab;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002327
Chris Lattner6ab03f62006-09-28 23:35:22 +00002328/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002329yyreduce:
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002330 yylen = yyr2[yyn];
Chris Lattner6ab03f62006-09-28 23:35:22 +00002331 if (yylen > 0)
2332 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002333
Chris Lattner6ab03f62006-09-28 23:35:22 +00002334#if YYDEBUG != 0
2335 if (yydebug)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002336 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00002337 int i;
2338
2339 fprintf (stderr, "Reducing via rule %d (line %d), ",
2340 yyn, yyrline[yyn]);
2341
2342 /* Print the symbols being reduced, and their result. */
2343 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2344 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2345 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2346 }
2347#endif
2348
2349
2350 switch (yyn) {
2351
2352case 2:
2353#line 1089 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2354{
2355 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer713eedc2006-08-18 08:43:06 +00002356 GEN_ERROR("Value too large for type!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002357 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002358 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002359;
2360 break;}
2361case 4:
2362#line 1098 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2363{
2364 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer713eedc2006-08-18 08:43:06 +00002365 GEN_ERROR("Value too large for type!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002366 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Reid Spencer713eedc2006-08-18 08:43:06 +00002367 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002368;
2369 break;}
2370case 33:
2371#line 1122 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2372{
2373 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002374 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002375 ;
2376 break;}
2377case 34:
2378#line 1126 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2379{
2380 yyval.StrVal = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00002381 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002382 ;
2383 break;}
2384case 35:
2385#line 1131 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2386{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2387 break;}
2388case 36:
2389#line 1132 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2390{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2391 break;}
2392case 37:
2393#line 1133 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2394{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2395 break;}
2396case 38:
2397#line 1134 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2398{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2399 break;}
2400case 39:
2401#line 1135 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2402{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2403 break;}
2404case 40:
2405#line 1136 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2406{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2407 break;}
2408case 41:
2409#line 1137 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2410{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2411 break;}
2412case 42:
2413#line 1138 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2414{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2415 break;}
2416case 43:
2417#line 1140 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2418{ yyval.UIntVal = CallingConv::C; ;
2419 break;}
2420case 44:
2421#line 1141 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2422{ yyval.UIntVal = CallingConv::C; ;
2423 break;}
2424case 45:
2425#line 1142 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2426{ yyval.UIntVal = CallingConv::CSRet; ;
2427 break;}
2428case 46:
2429#line 1143 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2430{ yyval.UIntVal = CallingConv::Fast; ;
2431 break;}
2432case 47:
2433#line 1144 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2434{ yyval.UIntVal = CallingConv::Cold; ;
2435 break;}
2436case 48:
2437#line 1145 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2438{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2439 break;}
2440case 49:
2441#line 1146 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2442{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2443 break;}
2444case 50:
2445#line 1147 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2446{
2447 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Reid Spencer713eedc2006-08-18 08:43:06 +00002448 GEN_ERROR("Calling conv too large!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002449 yyval.UIntVal = yyvsp[0].UInt64Val;
Reid Spencer713eedc2006-08-18 08:43:06 +00002450 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002451 ;
2452 break;}
2453case 51:
2454#line 1156 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2455{ yyval.UIntVal = 0; ;
2456 break;}
2457case 52:
2458#line 1157 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2459{
2460 yyval.UIntVal = yyvsp[0].UInt64Val;
2461 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00002462 GEN_ERROR("Alignment must be a power of two!");
2463 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002464;
2465 break;}
2466case 53:
2467#line 1163 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2468{ yyval.UIntVal = 0; ;
2469 break;}
2470case 54:
2471#line 1164 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2472{
2473 yyval.UIntVal = yyvsp[0].UInt64Val;
2474 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00002475 GEN_ERROR("Alignment must be a power of two!");
2476 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002477;
2478 break;}
2479case 55:
2480#line 1172 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2481{
2482 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2483 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
Reid Spencer713eedc2006-08-18 08:43:06 +00002484 GEN_ERROR("Invalid character in section name!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002485 yyval.StrVal = yyvsp[0].StrVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002486 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002487;
2488 break;}
2489case 56:
2490#line 1180 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2491{ yyval.StrVal = 0; ;
2492 break;}
2493case 57:
2494#line 1181 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2495{ yyval.StrVal = yyvsp[0].StrVal; ;
2496 break;}
2497case 58:
2498#line 1186 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2499{;
2500 break;}
2501case 59:
2502#line 1187 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2503{;
2504 break;}
2505case 60:
2506#line 1188 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2507{
2508 CurGV->setSection(yyvsp[0].StrVal);
2509 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002510 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002511 ;
2512 break;}
2513case 61:
2514#line 1193 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2515{
2516 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Reid Spencer713eedc2006-08-18 08:43:06 +00002517 GEN_ERROR("Alignment must be a power of two!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002518 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00002519 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002520 ;
2521 break;}
2522case 63:
2523#line 1207 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2524{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2525 break;}
2526case 65:
2527#line 1208 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2528{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2529 break;}
2530case 66:
2531#line 1210 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2532{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002533 if (!UpRefs.empty())
Chris Lattner6ab03f62006-09-28 23:35:22 +00002534 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2535 yyval.TypeVal = yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002536 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002537 ;
2538 break;}
2539case 80:
2540#line 1222 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2541{
2542 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer713eedc2006-08-18 08:43:06 +00002543 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002544 ;
2545 break;}
2546case 81:
2547#line 1226 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2548{
2549 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Reid Spencer713eedc2006-08-18 08:43:06 +00002550 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002551 ;
2552 break;}
2553case 82:
2554#line 1230 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2555{ // Named types are also simple types...
2556 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002557 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002558 yyval.TypeVal = new PATypeHolder(tmp);
2559;
2560 break;}
2561case 83:
2562#line 1238 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2563{ // Type UpReference
2564 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002565 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattner6ab03f62006-09-28 23:35:22 +00002566 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2567 yyval.TypeVal = new PATypeHolder(OT);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002568 UR_OUT("New Upreference!\n");
Reid Spencer713eedc2006-08-18 08:43:06 +00002569 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002570 ;
2571 break;}
2572case 84:
2573#line 1246 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2574{ // Function derived type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002575 std::vector<const Type*> Params;
Chris Lattner6ab03f62006-09-28 23:35:22 +00002576 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2577 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002578 Params.push_back(*I);
2579 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2580 if (isVarArg) Params.pop_back();
2581
Chris Lattner6ab03f62006-09-28 23:35:22 +00002582 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2583 delete yyvsp[-1].TypeList; // Delete the argument list
2584 delete yyvsp[-3].TypeVal; // Delete the return type handle
Reid Spencer713eedc2006-08-18 08:43:06 +00002585 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002586 ;
2587 break;}
2588case 85:
2589#line 1259 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2590{ // Sized array type?
2591 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2592 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002593 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002594 ;
2595 break;}
2596case 86:
2597#line 1264 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2598{ // Packed array type?
2599 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2600 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencer713eedc2006-08-18 08:43:06 +00002601 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner625b9c82005-11-10 01:42:43 +00002602 if (!ElemTy->isPrimitiveType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002603 GEN_ERROR("Elemental type of a PackedType must be primitive");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002604 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Reid Spencer713eedc2006-08-18 08:43:06 +00002605 GEN_ERROR("Vector length should be a power of 2!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002606 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2607 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002608 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002609 ;
2610 break;}
2611case 87:
2612#line 1276 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2613{ // Structure type?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002614 std::vector<const Type*> Elements;
Chris Lattner6ab03f62006-09-28 23:35:22 +00002615 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2616 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002617 Elements.push_back(*I);
2618
Chris Lattner6ab03f62006-09-28 23:35:22 +00002619 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2620 delete yyvsp[-1].TypeList;
Reid Spencer713eedc2006-08-18 08:43:06 +00002621 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002622 ;
2623 break;}
2624case 88:
2625#line 1286 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2626{ // Empty structure type?
2627 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer713eedc2006-08-18 08:43:06 +00002628 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002629 ;
2630 break;}
2631case 89:
2632#line 1290 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2633{ // Pointer type?
2634 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2635 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002636 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002637 ;
2638 break;}
2639case 90:
2640#line 1299 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2641{
2642 yyval.TypeList = new std::list<PATypeHolder>();
2643 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002644 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002645 ;
2646 break;}
2647case 91:
2648#line 1304 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2649{
2650 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002651 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002652 ;
2653 break;}
2654case 93:
2655#line 1311 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2656{
2657 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Reid Spencer713eedc2006-08-18 08:43:06 +00002658 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002659 ;
2660 break;}
2661case 94:
2662#line 1315 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2663{
2664 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Reid Spencer713eedc2006-08-18 08:43:06 +00002665 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002666 ;
2667 break;}
2668case 95:
2669#line 1319 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2670{
2671 yyval.TypeList = new std::list<PATypeHolder>();
Reid Spencer713eedc2006-08-18 08:43:06 +00002672 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002673 ;
2674 break;}
2675case 96:
2676#line 1330 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2677{ // Nonempty unsized arr
2678 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002679 if (ATy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002680 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002681 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002682 const Type *ETy = ATy->getElementType();
2683 int NumElements = ATy->getNumElements();
2684
2685 // Verify that we have the correct size...
Chris Lattner6ab03f62006-09-28 23:35:22 +00002686 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencer713eedc2006-08-18 08:43:06 +00002687 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002688 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002689 itostr(NumElements) + "!");
2690
2691 // Verify all elements are correct type!
Chris Lattner6ab03f62006-09-28 23:35:22 +00002692 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2693 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002694 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002695 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner6ab03f62006-09-28 23:35:22 +00002696 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002697 }
2698
Chris Lattner6ab03f62006-09-28 23:35:22 +00002699 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2700 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer713eedc2006-08-18 08:43:06 +00002701 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002702 ;
2703 break;}
2704case 97:
2705#line 1356 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2706{
2707 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002708 if (ATy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002709 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002710 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002711
2712 int NumElements = ATy->getNumElements();
2713 if (NumElements != -1 && NumElements != 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002714 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002715 " arguments, but has size of " + itostr(NumElements) +"!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002716 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2717 delete yyvsp[-2].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002718 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002719 ;
2720 break;}
2721case 98:
2722#line 1370 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2723{
2724 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002725 if (ATy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002726 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002727 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002728
2729 int NumElements = ATy->getNumElements();
2730 const Type *ETy = ATy->getElementType();
Chris Lattner6ab03f62006-09-28 23:35:22 +00002731 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2732 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00002733 GEN_ERROR("Can't build string constant of size " +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002734 itostr((int)(EndStr-yyvsp[0].StrVal)) +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002735 " when array has size " + itostr(NumElements) + "!");
2736 std::vector<Constant*> Vals;
2737 if (ETy == Type::SByteTy) {
Chris Lattner6ab03f62006-09-28 23:35:22 +00002738 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002739 Vals.push_back(ConstantSInt::get(ETy, *C));
2740 } else if (ETy == Type::UByteTy) {
Chris Lattner6ab03f62006-09-28 23:35:22 +00002741 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
Chris Lattner8ebd2162006-01-24 04:14:29 +00002742 C != (unsigned char*)EndStr; ++C)
2743 Vals.push_back(ConstantUInt::get(ETy, *C));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002744 } else {
Chris Lattner6ab03f62006-09-28 23:35:22 +00002745 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002746 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002747 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00002748 free(yyvsp[0].StrVal);
2749 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2750 delete yyvsp[-2].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002751 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002752 ;
2753 break;}
2754case 99:
2755#line 1400 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2756{ // Nonempty unsized arr
2757 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002758 if (PTy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002759 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002760 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002761 const Type *ETy = PTy->getElementType();
2762 int NumElements = PTy->getNumElements();
2763
2764 // Verify that we have the correct size...
Chris Lattner6ab03f62006-09-28 23:35:22 +00002765 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencer713eedc2006-08-18 08:43:06 +00002766 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002767 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002768 itostr(NumElements) + "!");
2769
2770 // Verify all elements are correct type!
Chris Lattner6ab03f62006-09-28 23:35:22 +00002771 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2772 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002773 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002774 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattner6ab03f62006-09-28 23:35:22 +00002775 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002776 }
2777
Chris Lattner6ab03f62006-09-28 23:35:22 +00002778 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2779 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer713eedc2006-08-18 08:43:06 +00002780 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002781 ;
2782 break;}
2783case 100:
2784#line 1426 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2785{
2786 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Reid Spencer713eedc2006-08-18 08:43:06 +00002787 if (STy == 0)
2788 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002789 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer713eedc2006-08-18 08:43:06 +00002790
Chris Lattner6ab03f62006-09-28 23:35:22 +00002791 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencer713eedc2006-08-18 08:43:06 +00002792 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002793
2794 // Check to ensure that constants are compatible with the type initializer!
Chris Lattner6ab03f62006-09-28 23:35:22 +00002795 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2796 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer713eedc2006-08-18 08:43:06 +00002797 GEN_ERROR("Expected type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002798 STy->getElementType(i)->getDescription() +
2799 "' for element #" + utostr(i) +
2800 " of structure initializer!");
2801
Chris Lattner6ab03f62006-09-28 23:35:22 +00002802 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2803 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer713eedc2006-08-18 08:43:06 +00002804 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002805 ;
2806 break;}
2807case 101:
2808#line 1447 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2809{
2810 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002811 if (STy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002812 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002813 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002814
2815 if (STy->getNumContainedTypes() != 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002816 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002817
Chris Lattner6ab03f62006-09-28 23:35:22 +00002818 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2819 delete yyvsp[-2].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002820 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002821 ;
2822 break;}
2823case 102:
2824#line 1460 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2825{
2826 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002827 if (PTy == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002828 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002829 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002830
Chris Lattner6ab03f62006-09-28 23:35:22 +00002831 yyval.ConstVal = ConstantPointerNull::get(PTy);
2832 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002833 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002834 ;
2835 break;}
2836case 103:
2837#line 1470 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2838{
2839 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2840 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002841 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002842 ;
2843 break;}
2844case 104:
2845#line 1475 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2846{
2847 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002848 if (Ty == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00002849 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002850
2851 // ConstExprs can exist in the body of a function, thus creating
2852 // GlobalValues whenever they refer to a variable. Because we are in
2853 // the context of a function, getValNonImprovising will search the functions
2854 // symbol table instead of the module symbol table for the global symbol,
2855 // which throws things all off. To get around this, we just tell
2856 // getValNonImprovising that we are at global scope here.
2857 //
2858 Function *SavedCurFn = CurFun.CurrentFunction;
2859 CurFun.CurrentFunction = 0;
2860
Chris Lattner6ab03f62006-09-28 23:35:22 +00002861 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00002862 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002863
2864 CurFun.CurrentFunction = SavedCurFn;
2865
2866 // If this is an initializer for a constant pointer, which is referencing a
2867 // (currently) undefined variable, create a stub now that shall be replaced
2868 // in the future with the right type of variable.
2869 //
2870 if (V == 0) {
2871 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2872 const PointerType *PT = cast<PointerType>(Ty);
2873
2874 // First check to see if the forward references value is already created!
2875 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattner6ab03f62006-09-28 23:35:22 +00002876 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002877
2878 if (I != CurModule.GlobalRefs.end()) {
2879 V = I->second; // Placeholder already exists, use it...
Chris Lattner6ab03f62006-09-28 23:35:22 +00002880 yyvsp[0].ValIDVal.destroy();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002881 } else {
2882 std::string Name;
Chris Lattner6ab03f62006-09-28 23:35:22 +00002883 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002884
2885 // Create the forward referenced global.
2886 GlobalValue *GV;
2887 if (const FunctionType *FTy =
2888 dyn_cast<FunctionType>(PT->getElementType())) {
2889 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2890 CurModule.CurrentModule);
2891 } else {
2892 GV = new GlobalVariable(PT->getElementType(), false,
2893 GlobalValue::ExternalLinkage, 0,
2894 Name, CurModule.CurrentModule);
2895 }
2896
2897 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattner6ab03f62006-09-28 23:35:22 +00002898 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002899 V = GV;
2900 }
2901 }
2902
Chris Lattner6ab03f62006-09-28 23:35:22 +00002903 yyval.ConstVal = cast<GlobalValue>(V);
2904 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer713eedc2006-08-18 08:43:06 +00002905 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002906 ;
2907 break;}
2908case 105:
2909#line 1536 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2910{
2911 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002912 GEN_ERROR("Mismatched types for constant expression!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002913 yyval.ConstVal = yyvsp[0].ConstVal;
2914 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002915 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002916 ;
2917 break;}
2918case 106:
2919#line 1543 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2920{
2921 const Type *Ty = yyvsp[-1].TypeVal->get();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002922 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer713eedc2006-08-18 08:43:06 +00002923 GEN_ERROR("Cannot create a null initialized value of this type!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002924 yyval.ConstVal = Constant::getNullValue(Ty);
2925 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002926 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002927 ;
2928 break;}
2929case 107:
2930#line 1552 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2931{ // integral constants
2932 if (!ConstantSInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Reid Spencer713eedc2006-08-18 08:43:06 +00002933 GEN_ERROR("Constant value doesn't fit in type!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002934 yyval.ConstVal = ConstantSInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00002935 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002936 ;
2937 break;}
2938case 108:
2939#line 1558 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2940{ // integral constants
2941 if (!ConstantUInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Reid Spencer713eedc2006-08-18 08:43:06 +00002942 GEN_ERROR("Constant value doesn't fit in type!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002943 yyval.ConstVal = ConstantUInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00002944 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002945 ;
2946 break;}
2947case 109:
2948#line 1564 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2949{ // Boolean constants
2950 yyval.ConstVal = ConstantBool::getTrue();
Reid Spencer713eedc2006-08-18 08:43:06 +00002951 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002952 ;
2953 break;}
2954case 110:
2955#line 1568 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2956{ // Boolean constants
2957 yyval.ConstVal = ConstantBool::getFalse();
Reid Spencer713eedc2006-08-18 08:43:06 +00002958 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002959 ;
2960 break;}
2961case 111:
2962#line 1572 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2963{ // Float & Double constants
2964 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00002965 GEN_ERROR("Floating point constant invalid for type!!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00002966 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00002967 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002968 ;
2969 break;}
2970case 112:
2971#line 1580 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2972{
2973 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002974 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002975 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
2976 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00002977 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00002978 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
2979 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
2980 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00002981 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00002982 ;
2983 break;}
2984case 113:
2985#line 1591 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2986{
2987 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencer713eedc2006-08-18 08:43:06 +00002988 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002989
2990 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
2991 // indices to uint struct indices for compatibility.
2992 generic_gep_type_iterator<std::vector<Value*>::iterator>
Chris Lattner6ab03f62006-09-28 23:35:22 +00002993 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
2994 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
2995 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002996 if (isa<StructType>(*GTI)) // Only change struct indices
Chris Lattner6ab03f62006-09-28 23:35:22 +00002997 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[-1].ValueList)[i]))
Reid Spencerdfb3fb42005-08-27 18:50:39 +00002998 if (CUI->getType() == Type::UByteTy)
Chris Lattner6ab03f62006-09-28 23:35:22 +00002999 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003000
3001 const Type *IdxTy =
Chris Lattner6ab03f62006-09-28 23:35:22 +00003002 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003003 if (!IdxTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003004 GEN_ERROR("Index list invalid for constant getelementptr!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003005
3006 std::vector<Constant*> IdxVec;
Chris Lattner6ab03f62006-09-28 23:35:22 +00003007 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3008 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003009 IdxVec.push_back(C);
3010 else
Reid Spencer713eedc2006-08-18 08:43:06 +00003011 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003012
Chris Lattner6ab03f62006-09-28 23:35:22 +00003013 delete yyvsp[-1].ValueList;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003014
Chris Lattner6ab03f62006-09-28 23:35:22 +00003015 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Reid Spencer713eedc2006-08-18 08:43:06 +00003016 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003017 ;
3018 break;}
3019case 114:
3020#line 1623 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3021{
3022 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003023 GEN_ERROR("Select condition must be of boolean type!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003024 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003025 GEN_ERROR("Select operand types must match!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003026 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003027 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003028 ;
3029 break;}
3030case 115:
3031#line 1631 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3032{
3033 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003034 GEN_ERROR("Binary operator types must match!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003035 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3036 // To retain backward compatibility with these early compilers, we emit a
3037 // cast to the appropriate integer type automatically if we are in the
3038 // broken case. See PR424 for more information.
Chris Lattner6ab03f62006-09-28 23:35:22 +00003039 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
3040 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003041 } else {
3042 const Type *IntPtrTy = 0;
3043 switch (CurModule.CurrentModule->getPointerSize()) {
3044 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3045 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer713eedc2006-08-18 08:43:06 +00003046 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003047 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00003048 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
3049 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
3050 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003051 }
Reid Spencer713eedc2006-08-18 08:43:06 +00003052 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003053 ;
3054 break;}
3055case 116:
3056#line 1653 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3057{
3058 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003059 GEN_ERROR("Logical operator types must match!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003060 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
3061 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
3062 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
Reid Spencer713eedc2006-08-18 08:43:06 +00003063 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner15f5a182005-12-21 18:31:50 +00003064 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00003065 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003066 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003067 ;
3068 break;}
3069case 117:
3070#line 1664 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3071{
3072 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003073 GEN_ERROR("setcc operand types must match!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003074 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003075 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003076 ;
3077 break;}
3078case 118:
3079#line 1670 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3080{
3081 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003082 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003083 if (!yyvsp[-3].ConstVal->getType()->isInteger())
Reid Spencer713eedc2006-08-18 08:43:06 +00003084 GEN_ERROR("Shift constant expression requires integer operand!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003085 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003086 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003087 ;
3088 break;}
3089case 119:
3090#line 1678 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3091{
3092 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00003093 GEN_ERROR("Invalid extractelement operands!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003094 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003095 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003096 ;
3097 break;}
3098case 120:
3099#line 1684 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3100{
3101 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00003102 GEN_ERROR("Invalid insertelement operands!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003103 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003104 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003105 ;
3106 break;}
3107case 121:
3108#line 1690 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3109{
3110 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00003111 GEN_ERROR("Invalid shufflevector operands!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003112 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003113 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003114 ;
3115 break;}
3116case 122:
3117#line 1699 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3118{
3119 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003120 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003121 ;
3122 break;}
3123case 123:
3124#line 1703 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3125{
3126 yyval.ConstVector = new std::vector<Constant*>();
3127 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003128 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003129 ;
3130 break;}
3131case 124:
3132#line 1711 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3133{ yyval.BoolVal = false; ;
3134 break;}
3135case 125:
3136#line 1711 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3137{ yyval.BoolVal = true; ;
3138 break;}
3139case 126:
3140#line 1721 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3141{
3142 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003143 CurModule.ModuleDone();
Reid Spencer713eedc2006-08-18 08:43:06 +00003144 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003145;
3146 break;}
3147case 127:
3148#line 1729 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3149{
3150 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003151 CurFun.FunctionDone();
Reid Spencer713eedc2006-08-18 08:43:06 +00003152 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003153 ;
3154 break;}
3155case 128:
3156#line 1734 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3157{
3158 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003159 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003160 ;
3161 break;}
3162case 129:
3163#line 1738 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3164{
3165 yyval.ModuleVal = yyvsp[-3].ModuleVal;
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003166 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003167 ;
3168 break;}
3169case 130:
3170#line 1742 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3171{
3172 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003173 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003174 ;
3175 break;}
3176case 131:
3177#line 1746 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3178{
3179 yyval.ModuleVal = CurModule.CurrentModule;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003180 // Emit an error if there are any unresolved types left.
3181 if (!CurModule.LateResolveTypes.empty()) {
3182 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer713eedc2006-08-18 08:43:06 +00003183 if (DID.Type == ValID::NameVal) {
3184 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3185 } else {
3186 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3187 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003188 }
Reid Spencer713eedc2006-08-18 08:43:06 +00003189 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003190 ;
3191 break;}
3192case 132:
3193#line 1761 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3194{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003195 // Eagerly resolve types. This is not an optimization, this is a
3196 // requirement that is due to the fact that we could have this:
3197 //
3198 // %list = type { %list * }
3199 // %list = type { %list * } ; repeated type decl
3200 //
3201 // If types are not resolved eagerly, then the two types will not be
3202 // determined to be the same type!
3203 //
Chris Lattner6ab03f62006-09-28 23:35:22 +00003204 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003205
Chris Lattner6ab03f62006-09-28 23:35:22 +00003206 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer309080a2006-09-28 19:28:24 +00003207 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003208 // If this is a named type that is not a redefinition, add it to the slot
3209 // table.
Chris Lattner6ab03f62006-09-28 23:35:22 +00003210 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003211 }
3212
Chris Lattner6ab03f62006-09-28 23:35:22 +00003213 delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003214 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003215 ;
3216 break;}
3217case 133:
3218#line 1783 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3219{ // Function prototypes can be in const pool
Reid Spencer713eedc2006-08-18 08:43:06 +00003220 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003221 ;
3222 break;}
3223case 134:
3224#line 1786 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3225{ // Asm blocks can be in the const pool
Reid Spencer713eedc2006-08-18 08:43:06 +00003226 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003227 ;
3228 break;}
3229case 135:
3230#line 1789 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3231{
3232 if (yyvsp[0].ConstVal == 0)
Reid Spencer309080a2006-09-28 19:28:24 +00003233 GEN_ERROR("Global value initializer is not a constant!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003234 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003235 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003236 ;
3237 break;}
3238case 136:
3239#line 1794 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3240{
Reid Spencer309080a2006-09-28 19:28:24 +00003241 CurGV = 0;
Chris Lattner6ab03f62006-09-28 23:35:22 +00003242 ;
3243 break;}
3244case 137:
3245#line 1797 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3246{
3247 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
Reid Spencer309080a2006-09-28 19:28:24 +00003248 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003249 delete yyvsp[0].TypeVal;
3250 ;
3251 break;}
3252case 138:
3253#line 1801 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3254{
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003255 CurGV = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00003256 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003257 ;
3258 break;}
3259case 139:
3260#line 1805 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3261{
3262 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
Reid Spencer309080a2006-09-28 19:28:24 +00003263 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003264 delete yyvsp[0].TypeVal;
3265 ;
3266 break;}
3267case 140:
3268#line 1809 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3269{
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003270 CurGV = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00003271 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003272 ;
3273 break;}
3274case 141:
3275#line 1813 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3276{
Reid Spencer309080a2006-09-28 19:28:24 +00003277 CurGV =
Chris Lattner6ab03f62006-09-28 23:35:22 +00003278 ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
Reid Spencer309080a2006-09-28 19:28:24 +00003279 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003280 delete yyvsp[0].TypeVal;
3281 ;
3282 break;}
3283case 142:
3284#line 1818 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3285{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003286 CurGV = 0;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003287 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003288 ;
3289 break;}
3290case 143:
3291#line 1822 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3292{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003293 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003294 ;
3295 break;}
3296case 144:
3297#line 1825 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3298{
Anton Korobeynikov6f7072c2006-09-17 20:25:45 +00003299 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003300 ;
3301 break;}
3302case 145:
3303#line 1828 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3304{
3305 ;
3306 break;}
3307case 146:
3308#line 1832 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3309{
Chris Lattner8ebd2162006-01-24 04:14:29 +00003310 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattner6ab03f62006-09-28 23:35:22 +00003311 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3312 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3313 free(yyvsp[0].StrVal);
Chris Lattner8ebd2162006-01-24 04:14:29 +00003314
3315 if (AsmSoFar.empty())
3316 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3317 else
3318 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer713eedc2006-08-18 08:43:06 +00003319 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003320;
3321 break;}
3322case 147:
3323#line 1845 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3324{ yyval.Endianness = Module::BigEndian; ;
3325 break;}
3326case 148:
3327#line 1846 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3328{ yyval.Endianness = Module::LittleEndian; ;
3329 break;}
3330case 149:
3331#line 1848 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3332{
3333 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Reid Spencer713eedc2006-08-18 08:43:06 +00003334 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003335 ;
3336 break;}
3337case 150:
3338#line 1852 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3339{
3340 if (yyvsp[0].UInt64Val == 32)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003341 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Chris Lattner6ab03f62006-09-28 23:35:22 +00003342 else if (yyvsp[0].UInt64Val == 64)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003343 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3344 else
Chris Lattner6ab03f62006-09-28 23:35:22 +00003345 GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Reid Spencer713eedc2006-08-18 08:43:06 +00003346 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003347 ;
3348 break;}
3349case 151:
3350#line 1861 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3351{
3352 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3353 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003354 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003355 ;
3356 break;}
3357case 153:
3358#line 1869 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3359{
3360 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3361 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003362 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003363 ;
3364 break;}
3365case 154:
3366#line 1874 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3367{
3368 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3369 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003370 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003371 ;
3372 break;}
3373case 155:
3374#line 1879 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3375{
Reid Spencer713eedc2006-08-18 08:43:06 +00003376 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003377 ;
3378 break;}
3379case 159:
3380#line 1889 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3381{ yyval.StrVal = 0; ;
3382 break;}
3383case 160:
3384#line 1891 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3385{
3386 if (*yyvsp[-1].TypeVal == Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003387 GEN_ERROR("void typed arguments are invalid!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003388 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003389 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003390;
3391 break;}
3392case 161:
3393#line 1898 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3394{
3395 yyval.ArgList = yyvsp[-2].ArgList;
3396 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3397 delete yyvsp[0].ArgVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003398 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003399 ;
3400 break;}
3401case 162:
3402#line 1904 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3403{
3404 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3405 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3406 delete yyvsp[0].ArgVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003407 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003408 ;
3409 break;}
3410case 163:
3411#line 1911 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3412{
3413 yyval.ArgList = yyvsp[0].ArgList;
Reid Spencer713eedc2006-08-18 08:43:06 +00003414 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003415 ;
3416 break;}
3417case 164:
3418#line 1915 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3419{
3420 yyval.ArgList = yyvsp[-2].ArgList;
3421 yyval.ArgList->push_back(std::pair<PATypeHolder*,
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003422 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer713eedc2006-08-18 08:43:06 +00003423 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003424 ;
3425 break;}
3426case 165:
3427#line 1921 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3428{
3429 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3430 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Reid Spencer713eedc2006-08-18 08:43:06 +00003431 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003432 ;
3433 break;}
3434case 166:
3435#line 1926 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3436{
3437 yyval.ArgList = 0;
Reid Spencer713eedc2006-08-18 08:43:06 +00003438 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003439 ;
3440 break;}
3441case 167:
3442#line 1932 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3443{
3444 UnEscapeLexed(yyvsp[-5].StrVal);
3445 std::string FunctionName(yyvsp[-5].StrVal);
3446 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003447
Chris Lattner6ab03f62006-09-28 23:35:22 +00003448 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00003449 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003450
3451 std::vector<const Type*> ParamTypeList;
Chris Lattner6ab03f62006-09-28 23:35:22 +00003452 if (yyvsp[-3].ArgList) { // If there are arguments...
3453 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3454 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003455 ParamTypeList.push_back(I->first->get());
3456 }
3457
3458 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3459 if (isVarArg) ParamTypeList.pop_back();
3460
Chris Lattner6ab03f62006-09-28 23:35:22 +00003461 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003462 const PointerType *PFT = PointerType::get(FT);
Chris Lattner6ab03f62006-09-28 23:35:22 +00003463 delete yyvsp[-6].TypeVal;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003464
3465 ValID ID;
3466 if (!FunctionName.empty()) {
3467 ID = ValID::create((char*)FunctionName.c_str());
3468 } else {
3469 ID = ValID::create((int)CurModule.Values[PFT].size());
3470 }
3471
3472 Function *Fn = 0;
3473 // See if this function was forward referenced. If so, recycle the object.
3474 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3475 // Move the function to the end of the list, from whereever it was
3476 // previously inserted.
3477 Fn = cast<Function>(FWRef);
3478 CurModule.CurrentModule->getFunctionList().remove(Fn);
3479 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3480 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3481 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3482 // If this is the case, either we need to be a forward decl, or it needs
3483 // to be.
3484 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer713eedc2006-08-18 08:43:06 +00003485 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003486
3487 // Make sure to strip off any argument names so we can't get conflicts.
3488 if (Fn->isExternal())
3489 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3490 AI != AE; ++AI)
3491 AI->setName("");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003492 } else { // Not already defined?
3493 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3494 CurModule.CurrentModule);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003495
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003496 InsertValue(Fn, CurModule.Values);
3497 }
3498
3499 CurFun.FunctionStart(Fn);
Anton Korobeynikov0ab01ff2006-09-17 13:06:18 +00003500
3501 if (CurFun.isDeclare) {
3502 // If we have declaration, always overwrite linkage. This will allow us to
3503 // correctly handle cases, when pointer to function is passed as argument to
3504 // another function.
3505 Fn->setLinkage(CurFun.Linkage);
3506 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00003507 Fn->setCallingConv(yyvsp[-7].UIntVal);
3508 Fn->setAlignment(yyvsp[0].UIntVal);
3509 if (yyvsp[-1].StrVal) {
3510 Fn->setSection(yyvsp[-1].StrVal);
3511 free(yyvsp[-1].StrVal);
Chris Lattnera0c20b42005-11-12 00:11:49 +00003512 }
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003513
3514 // Add all of the arguments we parsed to the function...
Chris Lattner6ab03f62006-09-28 23:35:22 +00003515 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003516 if (isVarArg) { // Nuke the last entry
Chris Lattner6ab03f62006-09-28 23:35:22 +00003517 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003518 "Not a varargs marker!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00003519 delete yyvsp[-3].ArgList->back().first;
3520 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003521 }
3522 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattner6ab03f62006-09-28 23:35:22 +00003523 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3524 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003525 delete I->first; // Delete the typeholder...
3526
3527 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer309080a2006-09-28 19:28:24 +00003528 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003529 InsertValue(ArgIt);
3530 }
3531
Chris Lattner6ab03f62006-09-28 23:35:22 +00003532 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003533 }
Reid Spencer713eedc2006-08-18 08:43:06 +00003534 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003535;
3536 break;}
3537case 170:
3538#line 2028 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3539{
3540 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003541
3542 // Make sure that we keep track of the linkage type even if there was a
3543 // previous "declare".
Chris Lattner6ab03f62006-09-28 23:35:22 +00003544 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3545;
3546 break;}
3547case 173:
3548#line 2038 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3549{
3550 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003551 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003552;
3553 break;}
3554case 175:
3555#line 2044 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3556{ CurFun.Linkage = GlobalValue::DLLImportLinkage ;
3557 break;}
3558case 176:
3559#line 2045 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3560{ CurFun.Linkage = GlobalValue::DLLImportLinkage ;
3561 break;}
3562case 177:
3563#line 2047 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3564{ CurFun.isDeclare = true; ;
3565 break;}
3566case 178:
3567#line 2047 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3568{
3569 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003570 CurFun.FunctionDone();
Reid Spencer713eedc2006-08-18 08:43:06 +00003571 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003572 ;
3573 break;}
3574case 179:
3575#line 2057 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3576{
3577 yyval.BoolVal = false;
Reid Spencer713eedc2006-08-18 08:43:06 +00003578 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003579 ;
3580 break;}
3581case 180:
3582#line 2061 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3583{
3584 yyval.BoolVal = true;
Reid Spencer713eedc2006-08-18 08:43:06 +00003585 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003586 ;
3587 break;}
3588case 181:
3589#line 2066 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3590{ // A reference to a direct constant
3591 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00003592 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003593 ;
3594 break;}
3595case 182:
3596#line 2070 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3597{
3598 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Reid Spencer713eedc2006-08-18 08:43:06 +00003599 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003600 ;
3601 break;}
3602case 183:
3603#line 2074 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3604{ // Perhaps it's an FP constant?
3605 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003606 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003607 ;
3608 break;}
3609case 184:
3610#line 2078 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3611{
3612 yyval.ValIDVal = ValID::create(ConstantBool::getTrue());
Reid Spencer713eedc2006-08-18 08:43:06 +00003613 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003614 ;
3615 break;}
3616case 185:
3617#line 2082 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3618{
3619 yyval.ValIDVal = ValID::create(ConstantBool::getFalse());
Reid Spencer713eedc2006-08-18 08:43:06 +00003620 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003621 ;
3622 break;}
3623case 186:
3624#line 2086 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3625{
3626 yyval.ValIDVal = ValID::createNull();
Reid Spencer713eedc2006-08-18 08:43:06 +00003627 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003628 ;
3629 break;}
3630case 187:
3631#line 2090 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3632{
3633 yyval.ValIDVal = ValID::createUndef();
Reid Spencer713eedc2006-08-18 08:43:06 +00003634 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003635 ;
3636 break;}
3637case 188:
3638#line 2094 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3639{ // A vector zero constant.
3640 yyval.ValIDVal = ValID::createZeroInit();
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003641 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003642 ;
3643 break;}
3644case 189:
3645#line 2098 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3646{ // Nonempty unsized packed vector
3647 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3648 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003649
3650 PackedType* pt = PackedType::get(ETy, NumElements);
3651 PATypeHolder* PTy = new PATypeHolder(
3652 HandleUpRefs(
3653 PackedType::get(
3654 ETy,
3655 NumElements)
3656 )
3657 );
3658
3659 // Verify all elements are correct type!
Chris Lattner6ab03f62006-09-28 23:35:22 +00003660 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3661 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00003662 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003663 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00003664 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003665 }
3666
Chris Lattner6ab03f62006-09-28 23:35:22 +00003667 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3668 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer713eedc2006-08-18 08:43:06 +00003669 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003670 ;
3671 break;}
3672case 190:
3673#line 2123 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3674{
3675 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003676 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003677 ;
3678 break;}
3679case 191:
3680#line 2127 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3681{
3682 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3683 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3684 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3685 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3686 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3687 free(yyvsp[-2].StrVal);
3688 free(yyvsp[0].StrVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003689 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003690 ;
3691 break;}
3692case 192:
3693#line 2141 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3694{ // Is it an integer reference...?
3695 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003696 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003697 ;
3698 break;}
3699case 193:
3700#line 2145 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3701{ // Is it a named reference...?
3702 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003703 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003704 ;
3705 break;}
3706case 196:
3707#line 2157 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3708{
3709 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003710 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003711 ;
3712 break;}
3713case 197:
3714#line 2162 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3715{
3716 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003717 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003718 ;
3719 break;}
3720case 198:
3721#line 2166 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3722{ // Do not allow functions with 0 basic blocks
3723 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003724 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003725 ;
3726 break;}
3727case 199:
3728#line 2175 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3729{
3730 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Reid Spencer309080a2006-09-28 19:28:24 +00003731 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003732 InsertValue(yyvsp[0].TermInstVal);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003733
Chris Lattner6ab03f62006-09-28 23:35:22 +00003734 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3735 InsertValue(yyvsp[-2].BasicBlockVal);
3736 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003737 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003738 ;
3739 break;}
3740case 200:
3741#line 2186 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3742{
3743 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3744 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00003745 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003746 ;
3747 break;}
3748case 201:
3749#line 2191 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3750{
3751 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer309080a2006-09-28 19:28:24 +00003752 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003753
3754 // Make sure to move the basic block to the correct location in the
3755 // function, instead of leaving it inserted wherever it was first
3756 // referenced.
3757 Function::BasicBlockListType &BBL =
3758 CurFun.CurrentFunction->getBasicBlockList();
Chris Lattner6ab03f62006-09-28 23:35:22 +00003759 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003760 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003761 ;
3762 break;}
3763case 202:
3764#line 2203 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3765{
3766 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
Reid Spencer309080a2006-09-28 19:28:24 +00003767 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003768
3769 // Make sure to move the basic block to the correct location in the
3770 // function, instead of leaving it inserted wherever it was first
3771 // referenced.
3772 Function::BasicBlockListType &BBL =
3773 CurFun.CurrentFunction->getBasicBlockList();
Chris Lattner6ab03f62006-09-28 23:35:22 +00003774 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003775 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003776 ;
3777 break;}
3778case 203:
3779#line 2216 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3780{ // Return with a result...
3781 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3782 CHECK_FOR_ERROR
3783 ;
3784 break;}
3785case 204:
3786#line 2220 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3787{ // Return with no result...
3788 yyval.TermInstVal = new ReturnInst();
3789 CHECK_FOR_ERROR
3790 ;
3791 break;}
3792case 205:
3793#line 2224 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3794{ // Unconditional Branch...
3795 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
3796 CHECK_FOR_ERROR
3797 yyval.TermInstVal = new BranchInst(tmpBB);
3798 ;
3799 break;}
3800case 206:
3801#line 2229 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3802{
3803 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
3804 CHECK_FOR_ERROR
3805 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
3806 CHECK_FOR_ERROR
3807 Value* tmpVal = getVal(Type::BoolTy, yyvsp[-6].ValIDVal);
3808 CHECK_FOR_ERROR
3809 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
3810 ;
3811 break;}
3812case 207:
3813#line 2238 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3814{
3815 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
3816 CHECK_FOR_ERROR
3817 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
3818 CHECK_FOR_ERROR
3819 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
3820 yyval.TermInstVal = S;
Reid Spencer713eedc2006-08-18 08:43:06 +00003821
Chris Lattner6ab03f62006-09-28 23:35:22 +00003822 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3823 E = yyvsp[-1].JumpTable->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003824 for (; I != E; ++I) {
3825 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3826 S->addCase(CI, I->second);
3827 else
Reid Spencer713eedc2006-08-18 08:43:06 +00003828 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003829 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00003830 delete yyvsp[-1].JumpTable;
Reid Spencer713eedc2006-08-18 08:43:06 +00003831 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003832 ;
3833 break;}
3834case 208:
3835#line 2257 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3836{
3837 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00003838 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003839 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00003840 CHECK_FOR_ERROR
3841 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattner6ab03f62006-09-28 23:35:22 +00003842 yyval.TermInstVal = S;
Reid Spencer713eedc2006-08-18 08:43:06 +00003843 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003844 ;
3845 break;}
3846case 209:
3847#line 2267 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3848{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003849 const PointerType *PFTy;
3850 const FunctionType *Ty;
3851
Chris Lattner6ab03f62006-09-28 23:35:22 +00003852 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003853 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3854 // Pull out the types of all of the arguments...
3855 std::vector<const Type*> ParamTypes;
Chris Lattner6ab03f62006-09-28 23:35:22 +00003856 if (yyvsp[-7].ValueList) {
3857 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003858 I != E; ++I)
3859 ParamTypes.push_back((*I)->getType());
3860 }
3861
3862 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3863 if (isVarArg) ParamTypes.pop_back();
3864
Chris Lattner6ab03f62006-09-28 23:35:22 +00003865 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003866 PFTy = PointerType::get(Ty);
3867 }
3868
Chris Lattner6ab03f62006-09-28 23:35:22 +00003869 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
Reid Spencer309080a2006-09-28 19:28:24 +00003870 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003871 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00003872 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003873 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00003874 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003875
3876 // Create the call node...
Chris Lattner6ab03f62006-09-28 23:35:22 +00003877 if (!yyvsp[-7].ValueList) { // Has no arguments?
3878 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003879 } else { // Has arguments?
3880 // Loop through FunctionType's arguments and ensure they are specified
3881 // correctly!
3882 //
3883 FunctionType::param_iterator I = Ty->param_begin();
3884 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner6ab03f62006-09-28 23:35:22 +00003885 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003886
3887 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3888 if ((*ArgI)->getType() != *I)
Reid Spencer713eedc2006-08-18 08:43:06 +00003889 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003890 (*I)->getDescription() + "'!");
3891
3892 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer713eedc2006-08-18 08:43:06 +00003893 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003894
Chris Lattner6ab03f62006-09-28 23:35:22 +00003895 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003896 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00003897 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003898
Chris Lattner6ab03f62006-09-28 23:35:22 +00003899 delete yyvsp[-10].TypeVal;
3900 delete yyvsp[-7].ValueList;
Reid Spencer713eedc2006-08-18 08:43:06 +00003901 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003902 ;
3903 break;}
3904case 210:
3905#line 2322 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3906{
3907 yyval.TermInstVal = new UnwindInst();
Reid Spencer713eedc2006-08-18 08:43:06 +00003908 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003909 ;
3910 break;}
3911case 211:
3912#line 2326 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3913{
3914 yyval.TermInstVal = new UnreachableInst();
Reid Spencer713eedc2006-08-18 08:43:06 +00003915 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003916 ;
3917 break;}
3918case 212:
3919#line 2333 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3920{
3921 yyval.JumpTable = yyvsp[-5].JumpTable;
3922 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Reid Spencer309080a2006-09-28 19:28:24 +00003923 CHECK_FOR_ERROR
Reid Spencer713eedc2006-08-18 08:43:06 +00003924 if (V == 0)
3925 GEN_ERROR("May only switch on a constant pool value!");
3926
Chris Lattner6ab03f62006-09-28 23:35:22 +00003927 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003928 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003929 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
3930 ;
3931 break;}
3932case 213:
3933#line 2344 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3934{
3935 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
3936 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Reid Spencer309080a2006-09-28 19:28:24 +00003937 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003938
3939 if (V == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00003940 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003941
Chris Lattner6ab03f62006-09-28 23:35:22 +00003942 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003943 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003944 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
3945 ;
3946 break;}
3947case 214:
3948#line 2357 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3949{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00003950 // Is this definition named?? if so, assign the name...
Chris Lattner6ab03f62006-09-28 23:35:22 +00003951 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Reid Spencer309080a2006-09-28 19:28:24 +00003952 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003953 InsertValue(yyvsp[0].InstVal);
3954 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00003955 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003956;
3957 break;}
3958case 215:
3959#line 2366 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3960{ // Used for PHI nodes
3961 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
3962 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003963 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003964 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00003965 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003966 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
3967 delete yyvsp[-5].TypeVal;
3968 ;
3969 break;}
3970case 216:
3971#line 2375 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3972{
3973 yyval.PHIList = yyvsp[-6].PHIList;
3974 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003975 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003976 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00003977 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003978 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
3979 ;
3980 break;}
3981case 217:
3982#line 2385 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3983{ // Used for call statements, and memory insts...
3984 yyval.ValueList = new std::vector<Value*>();
3985 yyval.ValueList->push_back(yyvsp[0].ValueVal);
3986 ;
3987 break;}
3988case 218:
3989#line 2389 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3990{
3991 yyval.ValueList = yyvsp[-2].ValueList;
3992 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00003993 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00003994 ;
3995 break;}
3996case 220:
3997#line 2396 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3998{ yyval.ValueList = 0; ;
3999 break;}
4000case 221:
4001#line 2398 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4002{
4003 yyval.BoolVal = true;
Reid Spencer713eedc2006-08-18 08:43:06 +00004004 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004005 ;
4006 break;}
4007case 222:
4008#line 2402 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4009{
4010 yyval.BoolVal = false;
Reid Spencer713eedc2006-08-18 08:43:06 +00004011 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004012 ;
4013 break;}
4014case 223:
4015#line 2407 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4016{
4017 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4018 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004019 GEN_ERROR(
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004020 "Arithmetic operator requires integer, FP, or packed operands!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004021 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) && yyvsp[-4].BinaryOpVal == Instruction::Rem)
Reid Spencer713eedc2006-08-18 08:43:06 +00004022 GEN_ERROR("Rem not supported on packed types!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004023 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00004024 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004025 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00004026 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004027 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4028 if (yyval.InstVal == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004029 GEN_ERROR("binary operator returned null!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004030 delete yyvsp[-3].TypeVal;
4031 ;
4032 break;}
4033case 224:
4034#line 2423 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4035{
4036 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
4037 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
4038 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
Reid Spencer713eedc2006-08-18 08:43:06 +00004039 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner15f5a182005-12-21 18:31:50 +00004040 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00004041 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00004042 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004043 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00004044 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004045 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4046 if (yyval.InstVal == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004047 GEN_ERROR("binary operator returned null!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004048 delete yyvsp[-3].TypeVal;
4049 ;
4050 break;}
4051case 225:
4052#line 2438 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4053{
4054 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
Reid Spencer713eedc2006-08-18 08:43:06 +00004055 GEN_ERROR(
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004056 "PackedTypes currently not supported in setcc instructions!");
4057 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00004058 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00004059 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004060 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer309080a2006-09-28 19:28:24 +00004061 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004062 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4063 if (yyval.InstVal == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004064 GEN_ERROR("binary operator returned null!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004065 delete yyvsp[-3].TypeVal;
4066 ;
4067 break;}
4068case 226:
4069#line 2452 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4070{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004071 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4072 << " Replacing with 'xor'.\n";
4073
Chris Lattner6ab03f62006-09-28 23:35:22 +00004074 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004075 if (Ones == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004076 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004077
Chris Lattner6ab03f62006-09-28 23:35:22 +00004078 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
4079 if (yyval.InstVal == 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004080 GEN_ERROR("Could not create a xor instruction!");
4081 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004082 ;
4083 break;}
4084case 227:
4085#line 2465 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4086{
4087 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00004088 GEN_ERROR("Shift amount must be ubyte!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004089 if (!yyvsp[-2].ValueVal->getType()->isInteger())
Reid Spencer713eedc2006-08-18 08:43:06 +00004090 GEN_ERROR("Shift constant expression requires integer operand!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004091 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004092 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004093 ;
4094 break;}
4095case 228:
4096#line 2473 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4097{
4098 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00004099 GEN_ERROR("cast instruction to a non-primitive type: '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00004100 yyvsp[0].TypeVal->get()->getDescription() + "'!");
4101 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4102 delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004103 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004104 ;
4105 break;}
4106case 229:
4107#line 2481 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4108{
4109 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00004110 GEN_ERROR("select condition must be boolean!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004111 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Reid Spencer713eedc2006-08-18 08:43:06 +00004112 GEN_ERROR("select value types should match!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004113 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004114 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004115 ;
4116 break;}
4117case 230:
4118#line 2489 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4119{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004120 NewVarArgs = true;
Chris Lattner6ab03f62006-09-28 23:35:22 +00004121 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4122 delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004123 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004124 ;
4125 break;}
4126case 231:
4127#line 2495 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4128{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004129 ObsoleteVarArgs = true;
Chris Lattner6ab03f62006-09-28 23:35:22 +00004130 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004131 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00004132 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004133
4134 //b = vaarg a, t ->
4135 //foo = alloca 1 of t
4136 //bar = vacopy a
4137 //store bar -> foo
4138 //b = vaarg foo, t
4139 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4140 CurBB->getInstList().push_back(foo);
Chris Lattner6ab03f62006-09-28 23:35:22 +00004141 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004142 CurBB->getInstList().push_back(bar);
4143 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Chris Lattner6ab03f62006-09-28 23:35:22 +00004144 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
4145 delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004146 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004147 ;
4148 break;}
4149case 232:
4150#line 2515 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4151{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004152 ObsoleteVarArgs = true;
Chris Lattner6ab03f62006-09-28 23:35:22 +00004153 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004154 Function* NF = CurModule.CurrentModule->
Jeff Cohen11e26b52005-10-23 04:37:20 +00004155 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004156
4157 //b = vanext a, t ->
4158 //foo = alloca 1 of t
4159 //bar = vacopy a
4160 //store bar -> foo
4161 //tmp = vaarg foo, t
4162 //b = load foo
4163 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4164 CurBB->getInstList().push_back(foo);
Chris Lattner6ab03f62006-09-28 23:35:22 +00004165 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004166 CurBB->getInstList().push_back(bar);
4167 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Chris Lattner6ab03f62006-09-28 23:35:22 +00004168 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004169 CurBB->getInstList().push_back(tmp);
Chris Lattner6ab03f62006-09-28 23:35:22 +00004170 yyval.InstVal = new LoadInst(foo);
4171 delete yyvsp[0].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004172 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004173 ;
4174 break;}
4175case 233:
4176#line 2538 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4177{
4178 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00004179 GEN_ERROR("Invalid extractelement operands!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004180 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004181 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004182 ;
4183 break;}
4184case 234:
4185#line 2544 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4186{
4187 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00004188 GEN_ERROR("Invalid insertelement operands!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004189 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004190 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004191 ;
4192 break;}
4193case 235:
4194#line 2550 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4195{
4196 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer713eedc2006-08-18 08:43:06 +00004197 GEN_ERROR("Invalid shufflevector operands!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004198 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004199 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004200 ;
4201 break;}
4202case 236:
4203#line 2556 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4204{
4205 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004206 if (!Ty->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00004207 GEN_ERROR("PHI node operands must be of first class type!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004208 yyval.InstVal = new PHINode(Ty);
4209 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4210 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4211 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Reid Spencer713eedc2006-08-18 08:43:06 +00004212 GEN_ERROR("All elements of a PHI node must be of the same type!");
Chris Lattner6ab03f62006-09-28 23:35:22 +00004213 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4214 yyvsp[0].PHIList->pop_front();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004215 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00004216 delete yyvsp[0].PHIList; // Free the list...
Reid Spencer713eedc2006-08-18 08:43:06 +00004217 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004218 ;
4219 break;}
4220case 237:
4221#line 2571 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4222{
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004223 const PointerType *PFTy;
4224 const FunctionType *Ty;
4225
Chris Lattner6ab03f62006-09-28 23:35:22 +00004226 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004227 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4228 // Pull out the types of all of the arguments...
4229 std::vector<const Type*> ParamTypes;
Chris Lattner6ab03f62006-09-28 23:35:22 +00004230 if (yyvsp[-1].ValueList) {
4231 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004232 I != E; ++I)
4233 ParamTypes.push_back((*I)->getType());
4234 }
4235
4236 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4237 if (isVarArg) ParamTypes.pop_back();
4238
Chris Lattner6ab03f62006-09-28 23:35:22 +00004239 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
Reid Spencer713eedc2006-08-18 08:43:06 +00004240 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004241
Chris Lattner6ab03f62006-09-28 23:35:22 +00004242 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004243 PFTy = PointerType::get(Ty);
4244 }
4245
Chris Lattner6ab03f62006-09-28 23:35:22 +00004246 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
Reid Spencer309080a2006-09-28 19:28:24 +00004247 CHECK_FOR_ERROR
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004248
4249 // Create the call node...
Chris Lattner6ab03f62006-09-28 23:35:22 +00004250 if (!yyvsp[-1].ValueList) { // Has no arguments?
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004251 // Make sure no arguments is a good thing!
4252 if (Ty->getNumParams() != 0)
Reid Spencer713eedc2006-08-18 08:43:06 +00004253 GEN_ERROR("No arguments passed to a function that "
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004254 "expects arguments!");
4255
Chris Lattner6ab03f62006-09-28 23:35:22 +00004256 yyval.InstVal = new CallInst(V, std::vector<Value*>());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004257 } else { // Has arguments?
4258 // Loop through FunctionType's arguments and ensure they are specified
4259 // correctly!
4260 //
4261 FunctionType::param_iterator I = Ty->param_begin();
4262 FunctionType::param_iterator E = Ty->param_end();
Chris Lattner6ab03f62006-09-28 23:35:22 +00004263 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004264
4265 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4266 if ((*ArgI)->getType() != *I)
Reid Spencer713eedc2006-08-18 08:43:06 +00004267 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004268 (*I)->getDescription() + "'!");
4269
4270 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004271 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004272
Chris Lattner6ab03f62006-09-28 23:35:22 +00004273 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004274 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00004275 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
4276 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
4277 delete yyvsp[-4].TypeVal;
4278 delete yyvsp[-1].ValueList;
Reid Spencer713eedc2006-08-18 08:43:06 +00004279 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004280 ;
4281 break;}
4282case 238:
4283#line 2630 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4284{
4285 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004286 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004287 ;
4288 break;}
4289case 239:
4290#line 2637 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4291{
4292 yyval.ValueList = yyvsp[0].ValueList;
Reid Spencer713eedc2006-08-18 08:43:06 +00004293 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004294 ;
4295 break;}
4296case 240:
4297#line 2640 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4298{
4299 yyval.ValueList = new std::vector<Value*>();
Reid Spencer713eedc2006-08-18 08:43:06 +00004300 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004301 ;
4302 break;}
4303case 241:
4304#line 2645 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4305{
4306 yyval.BoolVal = true;
Reid Spencer713eedc2006-08-18 08:43:06 +00004307 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004308 ;
4309 break;}
4310case 242:
4311#line 2649 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4312{
4313 yyval.BoolVal = false;
Reid Spencer713eedc2006-08-18 08:43:06 +00004314 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004315 ;
4316 break;}
4317case 243:
4318#line 2656 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4319{
4320 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4321 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004322 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004323 ;
4324 break;}
4325case 244:
4326#line 2661 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4327{
4328 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004329 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004330 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4331 delete yyvsp[-4].TypeVal;
4332 ;
4333 break;}
4334case 245:
4335#line 2667 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4336{
4337 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4338 delete yyvsp[-1].TypeVal;
Reid Spencer713eedc2006-08-18 08:43:06 +00004339 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004340 ;
4341 break;}
4342case 246:
4343#line 2672 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4344{
4345 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004346 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004347 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4348 delete yyvsp[-4].TypeVal;
4349 ;
4350 break;}
4351case 247:
4352#line 2678 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4353{
4354 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004355 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattner6ab03f62006-09-28 23:35:22 +00004356 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4357 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004358 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004359 ;
4360 break;}
4361case 248:
4362#line 2686 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4363{
4364 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004365 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattner6ab03f62006-09-28 23:35:22 +00004366 (*yyvsp[-1].TypeVal)->getDescription());
4367 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
Reid Spencer713eedc2006-08-18 08:43:06 +00004368 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattner6ab03f62006-09-28 23:35:22 +00004369 (*yyvsp[-1].TypeVal)->getDescription());
4370 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004371 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004372 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal);
4373 delete yyvsp[-1].TypeVal;
4374 ;
4375 break;}
4376case 249:
4377#line 2698 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4378{
4379 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004380 if (!PT)
Reid Spencer713eedc2006-08-18 08:43:06 +00004381 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattner6ab03f62006-09-28 23:35:22 +00004382 (*yyvsp[-1].TypeVal)->getDescription());
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004383 const Type *ElTy = PT->getElementType();
Chris Lattner6ab03f62006-09-28 23:35:22 +00004384 if (ElTy != yyvsp[-3].ValueVal->getType())
4385 GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004386 "' into space of type '" + ElTy->getDescription() + "'!");
4387
Chris Lattner6ab03f62006-09-28 23:35:22 +00004388 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004389 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004390 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal);
4391 delete yyvsp[-1].TypeVal;
4392 ;
4393 break;}
4394case 250:
4395#line 2713 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4396{
4397 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencer713eedc2006-08-18 08:43:06 +00004398 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004399
4400 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4401 // indices to uint struct indices for compatibility.
4402 generic_gep_type_iterator<std::vector<Value*>::iterator>
Chris Lattner6ab03f62006-09-28 23:35:22 +00004403 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4404 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4405 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004406 if (isa<StructType>(*GTI)) // Only change struct indices
Chris Lattner6ab03f62006-09-28 23:35:22 +00004407 if (ConstantUInt *CUI = dyn_cast<ConstantUInt>((*yyvsp[0].ValueList)[i]))
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004408 if (CUI->getType() == Type::UByteTy)
Chris Lattner6ab03f62006-09-28 23:35:22 +00004409 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004410
Chris Lattner6ab03f62006-09-28 23:35:22 +00004411 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
Reid Spencer713eedc2006-08-18 08:43:06 +00004412 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattner6ab03f62006-09-28 23:35:22 +00004413 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4414 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer713eedc2006-08-18 08:43:06 +00004415 CHECK_FOR_ERROR
Chris Lattner6ab03f62006-09-28 23:35:22 +00004416 yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList);
4417 delete yyvsp[-2].TypeVal;
4418 delete yyvsp[0].ValueList;
4419 ;
4420 break;}
4421}
4422 /* the action file gets copied in in place of this dollarsign */
4423#line 543 "/usr/share/bison.simple"
Reid Spencer309080a2006-09-28 19:28:24 +00004424
4425 yyvsp -= yylen;
4426 yyssp -= yylen;
Chris Lattner6ab03f62006-09-28 23:35:22 +00004427#ifdef YYLSP_NEEDED
4428 yylsp -= yylen;
4429#endif
Reid Spencer309080a2006-09-28 19:28:24 +00004430
Chris Lattner6ab03f62006-09-28 23:35:22 +00004431#if YYDEBUG != 0
4432 if (yydebug)
4433 {
4434 short *ssp1 = yyss - 1;
4435 fprintf (stderr, "state stack now");
4436 while (ssp1 != yyssp)
4437 fprintf (stderr, " %d", *++ssp1);
4438 fprintf (stderr, "\n");
4439 }
4440#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004441
4442 *++yyvsp = yyval;
4443
Chris Lattner6ab03f62006-09-28 23:35:22 +00004444#ifdef YYLSP_NEEDED
4445 yylsp++;
4446 if (yylen == 0)
4447 {
4448 yylsp->first_line = yylloc.first_line;
4449 yylsp->first_column = yylloc.first_column;
4450 yylsp->last_line = (yylsp-1)->last_line;
4451 yylsp->last_column = (yylsp-1)->last_column;
4452 yylsp->text = 0;
4453 }
4454 else
4455 {
4456 yylsp->last_line = (yylsp+yylen-1)->last_line;
4457 yylsp->last_column = (yylsp+yylen-1)->last_column;
4458 }
4459#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004460
Chris Lattner6ab03f62006-09-28 23:35:22 +00004461 /* Now "shift" the result of the reduction.
4462 Determine what state that goes to,
4463 based on the state we popped back to
4464 and the rule number reduced by. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004465
4466 yyn = yyr1[yyn];
4467
Chris Lattner6ab03f62006-09-28 23:35:22 +00004468 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4469 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004470 yystate = yytable[yystate];
4471 else
Chris Lattner6ab03f62006-09-28 23:35:22 +00004472 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004473
4474 goto yynewstate;
4475
Chris Lattner6ab03f62006-09-28 23:35:22 +00004476yyerrlab: /* here on detecting error */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004477
Chris Lattner6ab03f62006-09-28 23:35:22 +00004478 if (! yyerrstatus)
4479 /* If not already recovering from an error, report this error. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004480 {
4481 ++yynerrs;
Chris Lattner6ab03f62006-09-28 23:35:22 +00004482
4483#ifdef YYERROR_VERBOSE
Reid Spencer309080a2006-09-28 19:28:24 +00004484 yyn = yypact[yystate];
Chris Lattner680aab62006-08-18 17:34:45 +00004485
Chris Lattner6ab03f62006-09-28 23:35:22 +00004486 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer309080a2006-09-28 19:28:24 +00004487 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00004488 int size = 0;
4489 char *msg;
4490 int x, count;
Reid Spencer309080a2006-09-28 19:28:24 +00004491
Chris Lattner6ab03f62006-09-28 23:35:22 +00004492 count = 0;
4493 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4494 for (x = (yyn < 0 ? -yyn : 0);
4495 x < (sizeof(yytname) / sizeof(char *)); x++)
4496 if (yycheck[x + yyn] == x)
4497 size += strlen(yytname[x]) + 15, count++;
4498 msg = (char *) malloc(size + 15);
4499 if (msg != 0)
Reid Spencer309080a2006-09-28 19:28:24 +00004500 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00004501 strcpy(msg, "parse error");
4502
4503 if (count < 5)
Reid Spencer309080a2006-09-28 19:28:24 +00004504 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00004505 count = 0;
4506 for (x = (yyn < 0 ? -yyn : 0);
4507 x < (sizeof(yytname) / sizeof(char *)); x++)
4508 if (yycheck[x + yyn] == x)
4509 {
4510 strcat(msg, count == 0 ? ", expecting `" : " or `");
4511 strcat(msg, yytname[x]);
4512 strcat(msg, "'");
4513 count++;
4514 }
Reid Spencer309080a2006-09-28 19:28:24 +00004515 }
Chris Lattner6ab03f62006-09-28 23:35:22 +00004516 yyerror(msg);
4517 free(msg);
Reid Spencer309080a2006-09-28 19:28:24 +00004518 }
4519 else
Chris Lattner6ab03f62006-09-28 23:35:22 +00004520 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer309080a2006-09-28 19:28:24 +00004521 }
4522 else
4523#endif /* YYERROR_VERBOSE */
Chris Lattner6ab03f62006-09-28 23:35:22 +00004524 yyerror("parse error");
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004525 }
4526
Chris Lattner6ab03f62006-09-28 23:35:22 +00004527 goto yyerrlab1;
4528yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004529
4530 if (yyerrstatus == 3)
4531 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00004532 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004533
Chris Lattner6ab03f62006-09-28 23:35:22 +00004534 /* return failure if at end of input */
4535 if (yychar == YYEOF)
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004536 YYABORT;
4537
Chris Lattner6ab03f62006-09-28 23:35:22 +00004538#if YYDEBUG != 0
4539 if (yydebug)
4540 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4541#endif
Chris Lattneredd9b032006-01-23 23:05:42 +00004542
Chris Lattner6ab03f62006-09-28 23:35:22 +00004543 yychar = YYEMPTY;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004544 }
4545
Chris Lattner6ab03f62006-09-28 23:35:22 +00004546 /* Else will try to reuse lookahead token
4547 after shifting the error token. */
4548
4549 yyerrstatus = 3; /* Each real token shifted decrements this */
4550
4551 goto yyerrhandle;
4552
4553yyerrdefault: /* current state does not do anything special for the error token. */
4554
4555#if 0
4556 /* This is wrong; only states that explicitly want error tokens
4557 should shift them. */
4558 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4559 if (yyn) goto yydefault;
4560#endif
4561
4562yyerrpop: /* pop the current state because it cannot handle the error token */
4563
4564 if (yyssp == yyss) YYABORT;
4565 yyvsp--;
4566 yystate = *--yyssp;
4567#ifdef YYLSP_NEEDED
4568 yylsp--;
4569#endif
4570
4571#if YYDEBUG != 0
4572 if (yydebug)
4573 {
4574 short *ssp1 = yyss - 1;
4575 fprintf (stderr, "Error: state stack now");
4576 while (ssp1 != yyssp)
4577 fprintf (stderr, " %d", *++ssp1);
4578 fprintf (stderr, "\n");
4579 }
4580#endif
4581
4582yyerrhandle:
4583
4584 yyn = yypact[yystate];
4585 if (yyn == YYFLAG)
4586 goto yyerrdefault;
4587
4588 yyn += YYTERROR;
4589 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4590 goto yyerrdefault;
4591
4592 yyn = yytable[yyn];
4593 if (yyn < 0)
4594 {
4595 if (yyn == YYFLAG)
4596 goto yyerrpop;
4597 yyn = -yyn;
4598 goto yyreduce;
4599 }
4600 else if (yyn == 0)
4601 goto yyerrpop;
4602
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004603 if (yyn == YYFINAL)
4604 YYACCEPT;
4605
Chris Lattner6ab03f62006-09-28 23:35:22 +00004606#if YYDEBUG != 0
4607 if (yydebug)
4608 fprintf(stderr, "Shifting error token, ");
4609#endif
4610
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004611 *++yyvsp = yylval;
Chris Lattner6ab03f62006-09-28 23:35:22 +00004612#ifdef YYLSP_NEEDED
4613 *++yylsp = yylloc;
4614#endif
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004615
4616 yystate = yyn;
4617 goto yynewstate;
4618
Chris Lattner6ab03f62006-09-28 23:35:22 +00004619 yyacceptlab:
4620 /* YYACCEPT comes here. */
4621 if (yyfree_stacks)
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004622 {
Chris Lattner6ab03f62006-09-28 23:35:22 +00004623 free (yyss);
4624 free (yyvs);
4625#ifdef YYLSP_NEEDED
4626 free (yyls);
Anton Korobeynikov73441cd2006-09-14 18:25:26 +00004627#endif
Chris Lattner6ab03f62006-09-28 23:35:22 +00004628 }
4629 return 0;
4630
4631 yyabortlab:
4632 /* YYABORT comes here. */
4633 if (yyfree_stacks)
4634 {
4635 free (yyss);
4636 free (yyvs);
4637#ifdef YYLSP_NEEDED
4638 free (yyls);
4639#endif
4640 }
4641 return 1;
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004642}
Chris Lattner6ab03f62006-09-28 23:35:22 +00004643#line 2739 "/Volumes/ProjectsDisk/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer713eedc2006-08-18 08:43:06 +00004644
4645
4646void llvm::GenerateError(const std::string &message, int LineNo) {
4647 if (LineNo == -1) LineNo = llvmAsmlineno;
4648 // TODO: column number in exception
4649 if (TheParseError)
4650 TheParseError->setError(CurFilename, message, LineNo);
4651 TriggerError = 1;
4652}
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004653
4654int yyerror(const char *ErrorMsg) {
4655 std::string where
4656 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4657 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4658 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4659 if (yychar == YYEMPTY || yychar == 0)
4660 errMsg += "end-of-file.";
4661 else
4662 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer713eedc2006-08-18 08:43:06 +00004663 GenerateError(errMsg);
Reid Spencerdfb3fb42005-08-27 18:50:39 +00004664 return 0;
4665}