blob: 21a722f05f45170e5c4687eb610930c092de4808 [file] [log] [blame]
Reid Spencer68a24bd2005-08-27 18:50:39 +00001
Chris Lattnerf49c1762006-11-08 05:58:47 +00002/* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004
Chris Lattnerf49c1762006-11-08 05:58:47 +00005#define YYBISON 1 /* Identify Bison output. */
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00006
Reid Spencer68a24bd2005-08-27 18:50:39 +00007#define yyparse llvmAsmparse
Chris Lattnerf49c1762006-11-08 05:58:47 +00008#define yylex llvmAsmlex
Reid Spencer68a24bd2005-08-27 18:50:39 +00009#define yyerror llvmAsmerror
Chris Lattnerf49c1762006-11-08 05:58:47 +000010#define yylval llvmAsmlval
11#define yychar llvmAsmchar
Reid Spencer68a24bd2005-08-27 18:50:39 +000012#define yydebug llvmAsmdebug
13#define yynerrs llvmAsmnerrs
Chris Lattnerf49c1762006-11-08 05:58:47 +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 DATALAYOUT 325
83#define RET 326
84#define BR 327
85#define SWITCH 328
86#define INVOKE 329
87#define UNWIND 330
88#define UNREACHABLE 331
89#define ADD 332
90#define SUB 333
91#define MUL 334
92#define UDIV 335
93#define SDIV 336
94#define FDIV 337
95#define UREM 338
96#define SREM 339
97#define FREM 340
98#define AND 341
99#define OR 342
100#define XOR 343
101#define SETLE 344
102#define SETGE 345
103#define SETLT 346
104#define SETGT 347
105#define SETEQ 348
106#define SETNE 349
107#define MALLOC 350
108#define ALLOCA 351
109#define FREE 352
110#define LOAD 353
111#define STORE 354
112#define GETELEMENTPTR 355
113#define PHI_TOK 356
114#define CAST 357
115#define SELECT 358
116#define SHL 359
117#define SHR 360
118#define VAARG 361
119#define EXTRACTELEMENT 362
120#define INSERTELEMENT 363
121#define SHUFFLEVECTOR 364
122#define VAARG_old 365
123#define VANEXT_old 366
Reid Spencer68a24bd2005-08-27 18:50:39 +0000124
Chris Lattnerf49c1762006-11-08 05:58:47 +0000125#line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000126
127#include "ParserInternals.h"
128#include "llvm/CallingConv.h"
Chris Lattner0e9c3762006-01-25 22:27:16 +0000129#include "llvm/InlineAsm.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000130#include "llvm/Instructions.h"
131#include "llvm/Module.h"
132#include "llvm/SymbolTable.h"
Reid Spencer0b118202006-01-16 21:12:35 +0000133#include "llvm/Assembly/AutoUpgrade.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000134#include "llvm/Support/GetElementPtrTypeIterator.h"
135#include "llvm/ADT/STLExtras.h"
Chris Lattner0019bbe2005-11-06 06:46:53 +0000136#include "llvm/Support/MathExtras.h"
Reid Spencer68a24bd2005-08-27 18:50:39 +0000137#include <algorithm>
138#include <iostream>
139#include <list>
140#include <utility>
141
Reid Spencere4f47592006-08-18 17:32:55 +0000142// The following is a gross hack. In order to rid the libAsmParser library of
143// exceptions, we have to have a way of getting the yyparse function to go into
144// an error situation. So, whenever we want an error to occur, the GenerateError
145// function (see bottom of file) sets TriggerError. Then, at the end of each
146// production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
147// (a goto) to put YACC in error state. Furthermore, several calls to
148// GenerateError are made from inside productions and they must simulate the
149// previous exception behavior by exiting the production immediately. We have
150// replaced these with the GEN_ERROR macro which calls GeneratError and then
151// immediately invokes YYERROR. This would be so much cleaner if it was a
152// recursive descent parser.
Reid Spencer61c83e02006-08-18 08:43:06 +0000153static bool TriggerError = false;
Reid Spencerf63697d2006-10-09 17:36:59 +0000154#define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
Reid Spencer61c83e02006-08-18 08:43:06 +0000155#define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
156
Reid Spencer68a24bd2005-08-27 18:50:39 +0000157int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
158int yylex(); // declaration" of xxx warnings.
159int yyparse();
160
161namespace llvm {
162 std::string CurFilename;
163}
164using namespace llvm;
165
166static Module *ParserResult;
167
168// DEBUG_UPREFS - Define this symbol if you want to enable debugging output
169// relating to upreferences in the input stream.
170//
171//#define DEBUG_UPREFS 1
172#ifdef DEBUG_UPREFS
173#define UR_OUT(X) std::cerr << X
174#else
175#define UR_OUT(X)
176#endif
177
178#define YYERROR_VERBOSE 1
179
180static bool ObsoleteVarArgs;
181static bool NewVarArgs;
Chris Lattnerb475c422005-11-12 18:22:38 +0000182static BasicBlock *CurBB;
183static GlobalVariable *CurGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000184
185
186// This contains info used when building the body of a function. It is
187// destroyed when the function is completed.
188//
189typedef std::vector<Value *> ValueList; // Numbered defs
190static void
191ResolveDefinitions(std::map<const Type *,ValueList> &LateResolvers,
192 std::map<const Type *,ValueList> *FutureLateResolvers = 0);
193
194static struct PerModuleInfo {
195 Module *CurrentModule;
196 std::map<const Type *, ValueList> Values; // Module level numbered definitions
197 std::map<const Type *,ValueList> LateResolveValues;
198 std::vector<PATypeHolder> Types;
199 std::map<ValID, PATypeHolder> LateResolveTypes;
200
201 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
Chris Lattner0ad19702006-06-21 16:53:00 +0000202 /// how they were referenced and on which line of the input they came from so
Reid Spencer68a24bd2005-08-27 18:50:39 +0000203 /// that we can resolve them later and print error messages as appropriate.
204 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
205
206 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
207 // references to global values. Global values may be referenced before they
208 // are defined, and if so, the temporary object that they represent is held
209 // here. This is used for forward references of GlobalValues.
210 //
211 typedef std::map<std::pair<const PointerType *,
212 ValID>, GlobalValue*> GlobalRefsType;
213 GlobalRefsType GlobalRefs;
214
215 void ModuleDone() {
216 // If we could not resolve some functions at function compilation time
217 // (calls to functions before they are defined), resolve them now... Types
218 // are resolved when the constant pool has been completely parsed.
219 //
220 ResolveDefinitions(LateResolveValues);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000221 if (TriggerError)
222 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000223
224 // Check to make sure that all global value forward references have been
225 // resolved!
226 //
227 if (!GlobalRefs.empty()) {
228 std::string UndefinedReferences = "Unresolved global references exist:\n";
229
230 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
231 I != E; ++I) {
232 UndefinedReferences += " " + I->first.first->getDescription() + " " +
233 I->first.second.getName() + "\n";
234 }
Reid Spencer61c83e02006-08-18 08:43:06 +0000235 GenerateError(UndefinedReferences);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000236 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000237 }
238
Reid Spencere812fb22006-01-19 01:21:04 +0000239 // Look for intrinsic functions and CallInst that need to be upgraded
Chris Lattnerd5efe842006-04-08 01:18:56 +0000240 for (Module::iterator FI = CurrentModule->begin(),
241 FE = CurrentModule->end(); FI != FE; )
Chris Lattnerc2c60382006-03-04 07:53:41 +0000242 UpgradeCallsToIntrinsic(FI++);
Reid Spencer0b118202006-01-16 21:12:35 +0000243
Reid Spencer68a24bd2005-08-27 18:50:39 +0000244 Values.clear(); // Clear out function local definitions
245 Types.clear();
246 CurrentModule = 0;
247 }
248
Reid Spencer68a24bd2005-08-27 18:50:39 +0000249 // GetForwardRefForGlobal - Check to see if there is a forward reference
250 // for this global. If so, remove it from the GlobalRefs map and return it.
251 // If not, just return null.
252 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
253 // Check to see if there is a forward reference to this global variable...
254 // if there is, eliminate it and patch the reference to use the new def'n.
255 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
256 GlobalValue *Ret = 0;
257 if (I != GlobalRefs.end()) {
258 Ret = I->second;
259 GlobalRefs.erase(I);
260 }
261 return Ret;
262 }
263} CurModule;
264
265static struct PerFunctionInfo {
266 Function *CurrentFunction; // Pointer to current function being created
267
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000268 std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
Reid Spencer68a24bd2005-08-27 18:50:39 +0000269 std::map<const Type*, ValueList> LateResolveValues;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000270 bool isDeclare; // Is this function a forward declararation?
271 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000272
273 /// BBForwardRefs - When we see forward references to basic blocks, keep
274 /// track of them here.
275 std::map<BasicBlock*, std::pair<ValID, int> > BBForwardRefs;
276 std::vector<BasicBlock*> NumberedBlocks;
277 unsigned NextBBNum;
278
279 inline PerFunctionInfo() {
280 CurrentFunction = 0;
281 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000282 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000283 }
284
285 inline void FunctionStart(Function *M) {
286 CurrentFunction = M;
287 NextBBNum = 0;
288 }
289
290 void FunctionDone() {
291 NumberedBlocks.clear();
292
293 // Any forward referenced blocks left?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000294 if (!BBForwardRefs.empty()) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000295 GenerateError("Undefined reference to label " +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000296 BBForwardRefs.begin()->first->getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000297 return;
298 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000299
300 // Resolve all forward references now.
301 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
302
303 Values.clear(); // Clear out function local definitions
304 CurrentFunction = 0;
305 isDeclare = false;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +0000306 Linkage = GlobalValue::ExternalLinkage;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000307 }
308} CurFun; // Info for the current function...
309
310static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
311
312
313//===----------------------------------------------------------------------===//
314// Code to handle definitions of all the types
315//===----------------------------------------------------------------------===//
316
317static int InsertValue(Value *V,
318 std::map<const Type*,ValueList> &ValueTab = CurFun.Values) {
319 if (V->hasName()) return -1; // Is this a numbered definition?
320
321 // Yes, insert the value into the value table...
322 ValueList &List = ValueTab[V->getType()];
323 List.push_back(V);
324 return List.size()-1;
325}
326
327static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
328 switch (D.Type) {
329 case ValID::NumberVal: // Is it a numbered definition?
330 // Module constants occupy the lowest numbered slots...
331 if ((unsigned)D.Num < CurModule.Types.size())
332 return CurModule.Types[(unsigned)D.Num];
333 break;
334 case ValID::NameVal: // Is it a named definition?
335 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
336 D.destroy(); // Free old strdup'd memory...
337 return N;
338 }
339 break;
340 default:
Reid Spencer61c83e02006-08-18 08:43:06 +0000341 GenerateError("Internal parser error: Invalid symbol type reference!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000342 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000343 }
344
345 // If we reached here, we referenced either a symbol that we don't know about
346 // or an id number that hasn't been read yet. We may be referencing something
347 // forward, so just create an entry to be resolved later and get to it...
348 //
349 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
350
351
352 if (inFunctionScope()) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000353 if (D.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000354 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000355 return 0;
356 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000357 GenerateError("Reference to an undefined type: #" + itostr(D.Num));
Reid Spencer5b7e7532006-09-28 19:28:24 +0000358 return 0;
359 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000360 }
361
362 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
363 if (I != CurModule.LateResolveTypes.end())
364 return I->second;
365
366 Type *Typ = OpaqueType::get();
367 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
368 return Typ;
369 }
370
371static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) {
372 SymbolTable &SymTab =
373 inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() :
374 CurModule.CurrentModule->getSymbolTable();
375 return SymTab.lookup(Ty, Name);
376}
377
378// getValNonImprovising - Look up the value specified by the provided type and
379// the provided ValID. If the value exists and has already been defined, return
380// it. Otherwise return null.
381//
382static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000383 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000384 GenerateError("Functions are not values and "
Reid Spencer68a24bd2005-08-27 18:50:39 +0000385 "must be referenced as pointers");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000386 return 0;
387 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000388
389 switch (D.Type) {
390 case ValID::NumberVal: { // Is it a numbered definition?
391 unsigned Num = (unsigned)D.Num;
392
393 // Module constants occupy the lowest numbered slots...
394 std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
395 if (VI != CurModule.Values.end()) {
396 if (Num < VI->second.size())
397 return VI->second[Num];
398 Num -= VI->second.size();
399 }
400
401 // Make sure that our type is within bounds
402 VI = CurFun.Values.find(Ty);
403 if (VI == CurFun.Values.end()) return 0;
404
405 // Check that the number is within bounds...
406 if (VI->second.size() <= Num) return 0;
407
408 return VI->second[Num];
409 }
410
411 case ValID::NameVal: { // Is it a named definition?
412 Value *N = lookupInSymbolTable(Ty, std::string(D.Name));
413 if (N == 0) return 0;
414
415 D.destroy(); // Free old strdup'd memory...
416 return N;
417 }
418
419 // Check to make sure that "Ty" is an integral type, and that our
420 // value will fit into the specified type...
421 case ValID::ConstSIntVal: // Is it a constant pool reference??
Reid Spencerb83eb642006-10-20 07:07:24 +0000422 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000423 GenerateError("Signed integral constant '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000424 itostr(D.ConstPool64) + "' is invalid for type '" +
425 Ty->getDescription() + "'!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000426 return 0;
427 }
Reid Spencerb83eb642006-10-20 07:07:24 +0000428 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000429
430 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
Reid Spencerb83eb642006-10-20 07:07:24 +0000431 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
432 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000433 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000434 "' is invalid or out of range!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000435 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000436 } else { // This is really a signed reference. Transmogrify.
Reid Spencerb83eb642006-10-20 07:07:24 +0000437 return ConstantInt::get(Ty, D.ConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000438 }
439 } else {
Reid Spencerb83eb642006-10-20 07:07:24 +0000440 return ConstantInt::get(Ty, D.UConstPool64);
Reid Spencer68a24bd2005-08-27 18:50:39 +0000441 }
442
443 case ValID::ConstFPVal: // Is it a floating point const pool reference?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000444 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000445 GenerateError("FP constant invalid for type!!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000446 return 0;
447 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000448 return ConstantFP::get(Ty, D.ConstPoolFP);
449
450 case ValID::ConstNullVal: // Is it a null value?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000451 if (!isa<PointerType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000452 GenerateError("Cannot create a a non pointer null!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000453 return 0;
454 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000455 return ConstantPointerNull::get(cast<PointerType>(Ty));
456
457 case ValID::ConstUndefVal: // Is it an undef value?
458 return UndefValue::get(Ty);
459
Chris Lattner7aa61892005-12-21 17:53:23 +0000460 case ValID::ConstZeroVal: // Is it a zero value?
461 return Constant::getNullValue(Ty);
462
Reid Spencer68a24bd2005-08-27 18:50:39 +0000463 case ValID::ConstantVal: // Fully resolved constant?
Reid Spencer5b7e7532006-09-28 19:28:24 +0000464 if (D.ConstantValue->getType() != Ty) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000465 GenerateError("Constant expression type different from required type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000466 return 0;
467 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000468 return D.ConstantValue;
469
Chris Lattner0e9c3762006-01-25 22:27:16 +0000470 case ValID::InlineAsmVal: { // Inline asm expression
471 const PointerType *PTy = dyn_cast<PointerType>(Ty);
472 const FunctionType *FTy =
473 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000474 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000475 GenerateError("Invalid type for asm constraint string!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000476 return 0;
477 }
Chris Lattner0e9c3762006-01-25 22:27:16 +0000478 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
479 D.IAD->HasSideEffects);
480 D.destroy(); // Free InlineAsmDescriptor.
481 return IA;
482 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000483 default:
484 assert(0 && "Unhandled case!");
485 return 0;
486 } // End of switch
487
488 assert(0 && "Unhandled case!");
489 return 0;
490}
491
492// getVal - This function is identical to getValNonImprovising, except that if a
493// value is not already defined, it "improvises" by creating a placeholder var
494// that looks and acts just like the requested variable. When the value is
495// defined later, all uses of the placeholder variable are replaced with the
496// real thing.
497//
498static Value *getVal(const Type *Ty, const ValID &ID) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000499 if (Ty == Type::LabelTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000500 GenerateError("Cannot use a basic block here");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000501 return 0;
502 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000503
504 // See if the value has already been defined.
505 Value *V = getValNonImprovising(Ty, ID);
506 if (V) return V;
Reid Spencer5b7e7532006-09-28 19:28:24 +0000507 if (TriggerError) return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000508
Reid Spencer5b7e7532006-09-28 19:28:24 +0000509 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000510 GenerateError("Invalid use of a composite type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000511 return 0;
512 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000513
514 // If we reached here, we referenced either a symbol that we don't know about
515 // or an id number that hasn't been read yet. We may be referencing something
516 // forward, so just create an entry to be resolved later and get to it...
517 //
518 V = new Argument(Ty);
519
520 // Remember where this forward reference came from. FIXME, shouldn't we try
521 // to recycle these things??
522 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
523 llvmAsmlineno)));
524
525 if (inFunctionScope())
526 InsertValue(V, CurFun.LateResolveValues);
527 else
528 InsertValue(V, CurModule.LateResolveValues);
529 return V;
530}
531
532/// getBBVal - This is used for two purposes:
533/// * If isDefinition is true, a new basic block with the specified ID is being
534/// defined.
535/// * If isDefinition is true, this is a reference to a basic block, which may
536/// or may not be a forward reference.
537///
538static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
539 assert(inFunctionScope() && "Can't get basic block at global scope!");
540
541 std::string Name;
542 BasicBlock *BB = 0;
543 switch (ID.Type) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000544 default:
545 GenerateError("Illegal label reference " + ID.getName());
546 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000547 case ValID::NumberVal: // Is it a numbered definition?
548 if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size())
549 CurFun.NumberedBlocks.resize(ID.Num+1);
550 BB = CurFun.NumberedBlocks[ID.Num];
551 break;
552 case ValID::NameVal: // Is it a named definition?
553 Name = ID.Name;
554 if (Value *N = CurFun.CurrentFunction->
555 getSymbolTable().lookup(Type::LabelTy, Name))
556 BB = cast<BasicBlock>(N);
557 break;
558 }
559
560 // See if the block has already been defined.
561 if (BB) {
562 // If this is the definition of the block, make sure the existing value was
563 // just a forward reference. If it was a forward reference, there will be
564 // an entry for it in the PlaceHolderInfo map.
Reid Spencer5b7e7532006-09-28 19:28:24 +0000565 if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000566 // The existing value was a definition, not a forward reference.
Reid Spencer61c83e02006-08-18 08:43:06 +0000567 GenerateError("Redefinition of label " + ID.getName());
Reid Spencer5b7e7532006-09-28 19:28:24 +0000568 return 0;
569 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000570
571 ID.destroy(); // Free strdup'd memory.
572 return BB;
573 }
574
575 // Otherwise this block has not been seen before.
576 BB = new BasicBlock("", CurFun.CurrentFunction);
577 if (ID.Type == ValID::NameVal) {
578 BB->setName(ID.Name);
579 } else {
580 CurFun.NumberedBlocks[ID.Num] = BB;
581 }
582
583 // If this is not a definition, keep track of it so we can use it as a forward
584 // reference.
585 if (!isDefinition) {
586 // Remember where this forward reference came from.
587 CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno);
588 } else {
589 // The forward declaration could have been inserted anywhere in the
590 // function: insert it into the correct place now.
591 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
592 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
593 }
594 ID.destroy();
595 return BB;
596}
597
598
599//===----------------------------------------------------------------------===//
600// Code to handle forward references in instructions
601//===----------------------------------------------------------------------===//
602//
603// This code handles the late binding needed with statements that reference
604// values not defined yet... for example, a forward branch, or the PHI node for
605// a loop body.
606//
607// This keeps a table (CurFun.LateResolveValues) of all such forward references
608// and back patchs after we are done.
609//
610
611// ResolveDefinitions - If we could not resolve some defs at parsing
612// time (forward branches, phi functions for loops, etc...) resolve the
613// defs now...
614//
615static void
616ResolveDefinitions(std::map<const Type*,ValueList> &LateResolvers,
617 std::map<const Type*,ValueList> *FutureLateResolvers) {
618 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
619 for (std::map<const Type*,ValueList>::iterator LRI = LateResolvers.begin(),
620 E = LateResolvers.end(); LRI != E; ++LRI) {
621 ValueList &List = LRI->second;
622 while (!List.empty()) {
623 Value *V = List.back();
624 List.pop_back();
625
626 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
627 CurModule.PlaceHolderInfo.find(V);
628 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
629
630 ValID &DID = PHI->second.first;
631
632 Value *TheRealValue = getValNonImprovising(LRI->first, DID);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000633 if (TriggerError)
634 return;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000635 if (TheRealValue) {
636 V->replaceAllUsesWith(TheRealValue);
637 delete V;
638 CurModule.PlaceHolderInfo.erase(PHI);
639 } else if (FutureLateResolvers) {
640 // Functions have their unresolved items forwarded to the module late
641 // resolver table
642 InsertValue(V, *FutureLateResolvers);
643 } else {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000644 if (DID.Type == ValID::NameVal) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000645 GenerateError("Reference to an invalid definition: '" +DID.getName()+
Reid Spencer68a24bd2005-08-27 18:50:39 +0000646 "' of type '" + V->getType()->getDescription() + "'",
647 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000648 return;
649 } else {
Reid Spencer61c83e02006-08-18 08:43:06 +0000650 GenerateError("Reference to an invalid definition: #" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000651 itostr(DID.Num) + " of type '" +
652 V->getType()->getDescription() + "'",
653 PHI->second.second);
Reid Spencer5b7e7532006-09-28 19:28:24 +0000654 return;
655 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000656 }
657 }
658 }
659
660 LateResolvers.clear();
661}
662
663// ResolveTypeTo - A brand new type was just declared. This means that (if
664// name is not null) things referencing Name can be resolved. Otherwise, things
665// refering to the number can be resolved. Do this now.
666//
667static void ResolveTypeTo(char *Name, const Type *ToTy) {
668 ValID D;
669 if (Name) D = ValID::create(Name);
670 else D = ValID::create((int)CurModule.Types.size());
671
672 std::map<ValID, PATypeHolder>::iterator I =
673 CurModule.LateResolveTypes.find(D);
674 if (I != CurModule.LateResolveTypes.end()) {
675 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
676 CurModule.LateResolveTypes.erase(I);
677 }
678}
679
680// setValueName - Set the specified value to the name given. The name may be
681// null potentially, in which case this is a noop. The string passed in is
682// assumed to be a malloc'd string buffer, and is free'd by this function.
683//
684static void setValueName(Value *V, char *NameStr) {
685 if (NameStr) {
686 std::string Name(NameStr); // Copy string
687 free(NameStr); // Free old string
688
Reid Spencer5b7e7532006-09-28 19:28:24 +0000689 if (V->getType() == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000690 GenerateError("Can't assign name '" + Name+"' to value with void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000691 return;
692 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000693
694 assert(inFunctionScope() && "Must be in function scope!");
695 SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable();
Reid Spencer5b7e7532006-09-28 19:28:24 +0000696 if (ST.lookup(V->getType(), Name)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000697 GenerateError("Redefinition of value named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000698 V->getType()->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000699 return;
700 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000701
702 // Set the name.
703 V->setName(Name);
704 }
705}
706
707/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
708/// this is a declaration, otherwise it is a definition.
Chris Lattnerb475c422005-11-12 18:22:38 +0000709static GlobalVariable *
710ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage,
711 bool isConstantGlobal, const Type *Ty,
712 Constant *Initializer) {
Reid Spencer5b7e7532006-09-28 19:28:24 +0000713 if (isa<FunctionType>(Ty)) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000714 GenerateError("Cannot declare global vars of function type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000715 return 0;
716 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000717
718 const PointerType *PTy = PointerType::get(Ty);
719
720 std::string Name;
721 if (NameStr) {
722 Name = NameStr; // Copy string
723 free(NameStr); // Free old string
724 }
725
726 // See if this global value was forward referenced. If so, recycle the
727 // object.
728 ValID ID;
729 if (!Name.empty()) {
730 ID = ValID::create((char*)Name.c_str());
731 } else {
732 ID = ValID::create((int)CurModule.Values[PTy].size());
733 }
734
735 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
736 // Move the global to the end of the list, from whereever it was
737 // previously inserted.
738 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
739 CurModule.CurrentModule->getGlobalList().remove(GV);
740 CurModule.CurrentModule->getGlobalList().push_back(GV);
741 GV->setInitializer(Initializer);
742 GV->setLinkage(Linkage);
743 GV->setConstant(isConstantGlobal);
744 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000745 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000746 }
747
748 // If this global has a name, check to see if there is already a definition
749 // of this global in the module. If so, merge as appropriate. Note that
750 // this is really just a hack around problems in the CFE. :(
751 if (!Name.empty()) {
752 // We are a simple redefinition of a value, check to see if it is defined
753 // the same as the old one.
754 if (GlobalVariable *EGV =
755 CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
756 // We are allowed to redefine a global variable in two circumstances:
757 // 1. If at least one of the globals is uninitialized or
758 // 2. If both initializers have the same value.
759 //
760 if (!EGV->hasInitializer() || !Initializer ||
761 EGV->getInitializer() == Initializer) {
762
763 // Make sure the existing global version gets the initializer! Make
764 // sure that it also gets marked const if the new version is.
765 if (Initializer && !EGV->hasInitializer())
766 EGV->setInitializer(Initializer);
767 if (isConstantGlobal)
768 EGV->setConstant(true);
769 EGV->setLinkage(Linkage);
Chris Lattnerb475c422005-11-12 18:22:38 +0000770 return EGV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000771 }
772
Reid Spencer61c83e02006-08-18 08:43:06 +0000773 GenerateError("Redefinition of global variable named '" + Name +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000774 "' in the '" + Ty->getDescription() + "' type plane!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000775 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000776 }
777 }
778
779 // Otherwise there is no existing GV to use, create one now.
780 GlobalVariable *GV =
781 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
782 CurModule.CurrentModule);
783 InsertValue(GV, CurModule.Values);
Chris Lattnerb475c422005-11-12 18:22:38 +0000784 return GV;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000785}
786
787// setTypeName - Set the specified type to the name given. The name may be
788// null potentially, in which case this is a noop. The string passed in is
789// assumed to be a malloc'd string buffer, and is freed by this function.
790//
791// This function returns true if the type has already been defined, but is
792// allowed to be redefined in the specified context. If the name is a new name
793// for the type plane, it is inserted and false is returned.
794static bool setTypeName(const Type *T, char *NameStr) {
795 assert(!inFunctionScope() && "Can't give types function-local names!");
796 if (NameStr == 0) return false;
797
798 std::string Name(NameStr); // Copy string
799 free(NameStr); // Free old string
800
801 // We don't allow assigning names to void type
Reid Spencer5b7e7532006-09-28 19:28:24 +0000802 if (T == Type::VoidTy) {
Reid Spencer61c83e02006-08-18 08:43:06 +0000803 GenerateError("Can't assign name '" + Name + "' to the void type!");
Reid Spencer5b7e7532006-09-28 19:28:24 +0000804 return false;
805 }
Reid Spencer68a24bd2005-08-27 18:50:39 +0000806
807 // Set the type name, checking for conflicts as we do so.
808 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
809
810 if (AlreadyExists) { // Inserting a name that is already defined???
811 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
812 assert(Existing && "Conflict but no matching type?");
813
814 // There is only one case where this is allowed: when we are refining an
815 // opaque type. In this case, Existing will be an opaque type.
816 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
817 // We ARE replacing an opaque type!
818 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
819 return true;
820 }
821
822 // Otherwise, this is an attempt to redefine a type. That's okay if
823 // the redefinition is identical to the original. This will be so if
824 // Existing and T point to the same Type object. In this one case we
825 // allow the equivalent redefinition.
826 if (Existing == T) return true; // Yes, it's equal.
827
828 // Any other kind of (non-equivalent) redefinition is an error.
Reid Spencer61c83e02006-08-18 08:43:06 +0000829 GenerateError("Redefinition of type named '" + Name + "' in the '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +0000830 T->getDescription() + "' type plane!");
831 }
832
833 return false;
834}
835
836//===----------------------------------------------------------------------===//
837// Code for handling upreferences in type names...
838//
839
840// TypeContains - Returns true if Ty directly contains E in it.
841//
842static bool TypeContains(const Type *Ty, const Type *E) {
843 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
844 E) != Ty->subtype_end();
845}
846
847namespace {
848 struct UpRefRecord {
849 // NestingLevel - The number of nesting levels that need to be popped before
850 // this type is resolved.
851 unsigned NestingLevel;
852
853 // LastContainedTy - This is the type at the current binding level for the
854 // type. Every time we reduce the nesting level, this gets updated.
855 const Type *LastContainedTy;
856
857 // UpRefTy - This is the actual opaque type that the upreference is
858 // represented with.
859 OpaqueType *UpRefTy;
860
861 UpRefRecord(unsigned NL, OpaqueType *URTy)
862 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
863 };
864}
865
866// UpRefs - A list of the outstanding upreferences that need to be resolved.
867static std::vector<UpRefRecord> UpRefs;
868
869/// HandleUpRefs - Every time we finish a new layer of types, this function is
870/// called. It loops through the UpRefs vector, which is a list of the
871/// currently active types. For each type, if the up reference is contained in
872/// the newly completed type, we decrement the level count. When the level
873/// count reaches zero, the upreferenced type is the type that is passed in:
874/// thus we can complete the cycle.
875///
876static PATypeHolder HandleUpRefs(const Type *ty) {
Chris Lattner224f84f2006-08-18 17:34:45 +0000877 // If Ty isn't abstract, or if there are no up-references in it, then there is
878 // nothing to resolve here.
879 if (!ty->isAbstract() || UpRefs.empty()) return ty;
880
Reid Spencer68a24bd2005-08-27 18:50:39 +0000881 PATypeHolder Ty(ty);
882 UR_OUT("Type '" << Ty->getDescription() <<
883 "' newly formed. Resolving upreferences.\n" <<
884 UpRefs.size() << " upreferences active!\n");
885
886 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
887 // to zero), we resolve them all together before we resolve them to Ty. At
888 // the end of the loop, if there is anything to resolve to Ty, it will be in
889 // this variable.
890 OpaqueType *TypeToResolve = 0;
891
892 for (unsigned i = 0; i != UpRefs.size(); ++i) {
893 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
894 << UpRefs[i].second->getDescription() << ") = "
895 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
896 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
897 // Decrement level of upreference
898 unsigned Level = --UpRefs[i].NestingLevel;
899 UpRefs[i].LastContainedTy = Ty;
900 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
901 if (Level == 0) { // Upreference should be resolved!
902 if (!TypeToResolve) {
903 TypeToResolve = UpRefs[i].UpRefTy;
904 } else {
905 UR_OUT(" * Resolving upreference for "
906 << UpRefs[i].second->getDescription() << "\n";
907 std::string OldName = UpRefs[i].UpRefTy->getDescription());
908 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
909 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
910 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
911 }
912 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
913 --i; // Do not skip the next element...
914 }
915 }
916 }
917
918 if (TypeToResolve) {
919 UR_OUT(" * Resolving upreference for "
920 << UpRefs[i].second->getDescription() << "\n";
921 std::string OldName = TypeToResolve->getDescription());
922 TypeToResolve->refineAbstractTypeTo(Ty);
923 }
924
925 return Ty;
926}
927
Reid Spencer1628cec2006-10-26 06:15:43 +0000928/// This function is used to obtain the correct opcode for an instruction when
929/// an obsolete opcode is encountered. The OI parameter (OpcodeInfo) has both
930/// an opcode and an "obsolete" flag. These are generated by the lexer and
931/// the "obsolete" member will be true when the lexer encounters the token for
932/// an obsolete opcode. For example, "div" was replaced by [usf]div but we need
933/// to maintain backwards compatibility for asm files that still have the "div"
934/// instruction. This function handles converting div -> [usf]div appropriately.
935/// @brief Convert obsolete opcodes to new values
936static void
937sanitizeOpCode(OpcodeInfo<Instruction::BinaryOps> &OI, const PATypeHolder& PATy)
938{
939 // If its not obsolete, don't do anything
940 if (!OI.obsolete)
941 return;
942
943 // If its a packed type we want to use the element type
944 const Type* Ty = PATy;
945 if (const PackedType* PTy = dyn_cast<PackedType>(Ty))
946 Ty = PTy->getElementType();
947
948 // Depending on the opcode ..
949 switch (OI.opcode) {
950 default:
Reid Spencer3ed469c2006-11-02 20:25:50 +0000951 GenerateError("Invalid obsolete opCode (check Lexer.l)");
Reid Spencer1628cec2006-10-26 06:15:43 +0000952 break;
953 case Instruction::UDiv:
954 // Handle cases where the opcode needs to change
955 if (Ty->isFloatingPoint())
956 OI.opcode = Instruction::FDiv;
957 else if (Ty->isSigned())
958 OI.opcode = Instruction::SDiv;
959 break;
Reid Spencer3ed469c2006-11-02 20:25:50 +0000960 case Instruction::URem:
961 if (Ty->isFloatingPoint())
962 OI.opcode = Instruction::FRem;
963 else if (Ty->isSigned())
964 OI.opcode = Instruction::SRem;
965 break;
Reid Spencer1628cec2006-10-26 06:15:43 +0000966 }
967 // Its not obsolete any more, we fixed it.
968 OI.obsolete = false;
969}
Reid Spencer3ed469c2006-11-02 20:25:50 +0000970
Reid Spencer68a24bd2005-08-27 18:50:39 +0000971// common code from the two 'RunVMAsmParser' functions
Reid Spencer5b7e7532006-09-28 19:28:24 +0000972static Module* RunParser(Module * M) {
Reid Spencer68a24bd2005-08-27 18:50:39 +0000973
974 llvmAsmlineno = 1; // Reset the current line number...
975 ObsoleteVarArgs = false;
976 NewVarArgs = false;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000977 CurModule.CurrentModule = M;
Reid Spencerf63697d2006-10-09 17:36:59 +0000978
979 // Check to make sure the parser succeeded
980 if (yyparse()) {
981 if (ParserResult)
982 delete ParserResult;
983 return 0;
984 }
985
986 // Check to make sure that parsing produced a result
Reid Spencer61c83e02006-08-18 08:43:06 +0000987 if (!ParserResult)
988 return 0;
Reid Spencer68a24bd2005-08-27 18:50:39 +0000989
Reid Spencerf63697d2006-10-09 17:36:59 +0000990 // Reset ParserResult variable while saving its value for the result.
Reid Spencer68a24bd2005-08-27 18:50:39 +0000991 Module *Result = ParserResult;
992 ParserResult = 0;
993
994 //Not all functions use vaarg, so make a second check for ObsoleteVarArgs
995 {
996 Function* F;
997 if ((F = Result->getNamedFunction("llvm.va_start"))
998 && F->getFunctionType()->getNumParams() == 0)
999 ObsoleteVarArgs = true;
1000 if((F = Result->getNamedFunction("llvm.va_copy"))
1001 && F->getFunctionType()->getNumParams() == 1)
1002 ObsoleteVarArgs = true;
1003 }
1004
Reid Spencer5b7e7532006-09-28 19:28:24 +00001005 if (ObsoleteVarArgs && NewVarArgs) {
1006 GenerateError(
1007 "This file is corrupt: it uses both new and old style varargs");
1008 return 0;
1009 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001010
1011 if(ObsoleteVarArgs) {
1012 if(Function* F = Result->getNamedFunction("llvm.va_start")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001013 if (F->arg_size() != 0) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001014 GenerateError("Obsolete va_start takes 0 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001015 return 0;
1016 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001017
1018 //foo = va_start()
1019 // ->
1020 //bar = alloca typeof(foo)
1021 //va_start(bar)
1022 //foo = load bar
1023
1024 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1025 const Type* ArgTy = F->getFunctionType()->getReturnType();
1026 const Type* ArgTyPtr = PointerType::get(ArgTy);
1027 Function* NF = Result->getOrInsertFunction("llvm.va_start",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001028 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001029
1030 while (!F->use_empty()) {
1031 CallInst* CI = cast<CallInst>(F->use_back());
1032 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI);
1033 new CallInst(NF, bar, "", CI);
1034 Value* foo = new LoadInst(bar, "vastart.fix.2", CI);
1035 CI->replaceAllUsesWith(foo);
1036 CI->getParent()->getInstList().erase(CI);
1037 }
1038 Result->getFunctionList().erase(F);
1039 }
1040
1041 if(Function* F = Result->getNamedFunction("llvm.va_end")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001042 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001043 GenerateError("Obsolete va_end takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001044 return 0;
1045 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001046
1047 //vaend foo
1048 // ->
1049 //bar = alloca 1 of typeof(foo)
1050 //vaend bar
1051 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1052 const Type* ArgTy = F->getFunctionType()->getParamType(0);
1053 const Type* ArgTyPtr = PointerType::get(ArgTy);
1054 Function* NF = Result->getOrInsertFunction("llvm.va_end",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001055 RetTy, ArgTyPtr, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001056
1057 while (!F->use_empty()) {
1058 CallInst* CI = cast<CallInst>(F->use_back());
1059 AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI);
1060 new StoreInst(CI->getOperand(1), bar, CI);
1061 new CallInst(NF, bar, "", CI);
1062 CI->getParent()->getInstList().erase(CI);
1063 }
1064 Result->getFunctionList().erase(F);
1065 }
1066
1067 if(Function* F = Result->getNamedFunction("llvm.va_copy")) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00001068 if(F->arg_size() != 1) {
Reid Spencer61c83e02006-08-18 08:43:06 +00001069 GenerateError("Obsolete va_copy takes 1 argument!");
Reid Spencer5b7e7532006-09-28 19:28:24 +00001070 return 0;
1071 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00001072 //foo = vacopy(bar)
1073 // ->
1074 //a = alloca 1 of typeof(foo)
1075 //b = alloca 1 of typeof(foo)
1076 //store bar -> b
1077 //vacopy(a, b)
1078 //foo = load a
1079
1080 const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID);
1081 const Type* ArgTy = F->getFunctionType()->getReturnType();
1082 const Type* ArgTyPtr = PointerType::get(ArgTy);
1083 Function* NF = Result->getOrInsertFunction("llvm.va_copy",
Jeff Cohen66c5fd62005-10-23 04:37:20 +00001084 RetTy, ArgTyPtr, ArgTyPtr,
1085 (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00001086
1087 while (!F->use_empty()) {
1088 CallInst* CI = cast<CallInst>(F->use_back());
1089 AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI);
1090 AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI);
1091 new StoreInst(CI->getOperand(1), b, CI);
1092 new CallInst(NF, a, b, "", CI);
1093 Value* foo = new LoadInst(a, "vacopy.fix.3", CI);
1094 CI->replaceAllUsesWith(foo);
1095 CI->getParent()->getInstList().erase(CI);
1096 }
1097 Result->getFunctionList().erase(F);
1098 }
1099 }
1100
1101 return Result;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001102}
Reid Spencer68a24bd2005-08-27 18:50:39 +00001103
1104//===----------------------------------------------------------------------===//
1105// RunVMAsmParser - Define an interface to this parser
1106//===----------------------------------------------------------------------===//
1107//
1108Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1109 set_scan_file(F);
1110
1111 CurFilename = Filename;
1112 return RunParser(new Module(CurFilename));
1113}
1114
1115Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1116 set_scan_string(AsmString);
1117
1118 CurFilename = "from_memory";
1119 if (M == NULL) {
1120 return RunParser(new Module (CurFilename));
1121 } else {
1122 return RunParser(M);
1123 }
1124}
1125
1126
Chris Lattnerf49c1762006-11-08 05:58:47 +00001127#line 1016 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1128typedef union {
Reid Spencer68a24bd2005-08-27 18:50:39 +00001129 llvm::Module *ModuleVal;
1130 llvm::Function *FunctionVal;
1131 std::pair<llvm::PATypeHolder*, char*> *ArgVal;
1132 llvm::BasicBlock *BasicBlockVal;
1133 llvm::TerminatorInst *TermInstVal;
1134 llvm::Instruction *InstVal;
1135 llvm::Constant *ConstVal;
1136
1137 const llvm::Type *PrimType;
1138 llvm::PATypeHolder *TypeVal;
1139 llvm::Value *ValueVal;
1140
1141 std::vector<std::pair<llvm::PATypeHolder*,char*> > *ArgList;
1142 std::vector<llvm::Value*> *ValueList;
1143 std::list<llvm::PATypeHolder> *TypeList;
1144 // Represent the RHS of PHI node
1145 std::list<std::pair<llvm::Value*,
1146 llvm::BasicBlock*> > *PHIList;
1147 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1148 std::vector<llvm::Constant*> *ConstVector;
1149
1150 llvm::GlobalValue::LinkageTypes Linkage;
1151 int64_t SInt64Val;
1152 uint64_t UInt64Val;
1153 int SIntVal;
1154 unsigned UIntVal;
1155 double FPVal;
1156 bool BoolVal;
1157
1158 char *StrVal; // This memory is strdup'd!
Reid Spencer1628cec2006-10-26 06:15:43 +00001159 llvm::ValID ValIDVal; // strdup'd memory maybe!
Reid Spencer68a24bd2005-08-27 18:50:39 +00001160
Reid Spencer1628cec2006-10-26 06:15:43 +00001161 BinaryOpInfo BinaryOpVal;
1162 TermOpInfo TermOpVal;
1163 MemOpInfo MemOpVal;
1164 OtherOpInfo OtherOpVal;
1165 llvm::Module::Endianness Endianness;
Reid Spencer5b7e7532006-09-28 19:28:24 +00001166} YYSTYPE;
Chris Lattnerf49c1762006-11-08 05:58:47 +00001167#include <stdio.h>
1168
1169#ifndef __cplusplus
1170#ifndef __STDC__
1171#define const
1172#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00001173#endif
1174
1175
1176
Chris Lattnerf49c1762006-11-08 05:58:47 +00001177#define YYFINAL 521
1178#define YYFLAG -32768
1179#define YYNTBASE 127
Reid Spencer68a24bd2005-08-27 18:50:39 +00001180
Chris Lattnerf49c1762006-11-08 05:58:47 +00001181#define YYTRANSLATE(x) ((unsigned)(x) <= 366 ? yytranslate[x] : 201)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001182
Chris Lattnerf49c1762006-11-08 05:58:47 +00001183static const short yytranslate[] = { 0,
1184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1187 2, 2, 2, 2, 2, 2, 2, 2, 2, 116,
1188 117, 125, 2, 114, 2, 2, 2, 2, 2, 2,
1189 2, 2, 2, 2, 2, 2, 2, 2, 2, 121,
1190 113, 122, 2, 2, 2, 2, 2, 2, 2, 2,
1191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1193 118, 115, 120, 2, 2, 2, 2, 2, 126, 2,
1194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1195 2, 2, 2, 2, 2, 2, 2, 2, 2, 119,
1196 2, 2, 123, 2, 124, 2, 2, 2, 2, 2,
1197 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1198 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1199 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1200 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1201 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1202 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1203 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1204 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1205 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1206 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1207 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1208 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1209 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1210 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1211 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1212 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1213 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1214 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1215 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1216 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1217 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1218 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1219 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1220 107, 108, 109, 110, 111, 112
1221};
Reid Spencer68a24bd2005-08-27 18:50:39 +00001222
Chris Lattnerf49c1762006-11-08 05:58:47 +00001223#if YYDEBUG != 0
1224static const short yyprhs[] = { 0,
1225 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1226 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1227 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1228 60, 62, 64, 66, 68, 70, 72, 75, 76, 78,
1229 80, 82, 84, 86, 88, 90, 91, 92, 94, 96,
1230 98, 100, 102, 104, 107, 108, 111, 112, 116, 119,
1231 120, 122, 123, 127, 129, 132, 134, 136, 138, 140,
1232 142, 144, 146, 148, 150, 152, 154, 156, 158, 160,
1233 162, 164, 166, 168, 170, 172, 174, 177, 182, 188,
1234 194, 198, 201, 204, 206, 210, 212, 216, 218, 219,
1235 224, 228, 232, 237, 242, 246, 249, 252, 255, 258,
1236 261, 264, 267, 270, 273, 276, 283, 289, 298, 305,
1237 312, 319, 326, 333, 342, 351, 355, 357, 359, 361,
1238 363, 366, 369, 374, 377, 379, 384, 387, 392, 393,
1239 401, 402, 410, 411, 419, 420, 428, 432, 437, 438,
1240 440, 442, 444, 448, 452, 456, 460, 464, 468, 470,
1241 471, 473, 475, 477, 478, 481, 485, 487, 489, 493,
1242 495, 496, 505, 507, 509, 513, 515, 517, 520, 521,
1243 523, 525, 526, 531, 532, 534, 536, 538, 540, 542,
1244 544, 546, 548, 550, 554, 556, 562, 564, 566, 568,
1245 570, 573, 576, 579, 583, 586, 587, 589, 592, 595,
1246 599, 609, 619, 628, 642, 644, 646, 653, 659, 662,
1247 669, 677, 679, 683, 685, 686, 689, 691, 697, 703,
1248 709, 712, 717, 722, 729, 734, 739, 744, 749, 756,
1249 763, 766, 774, 776, 779, 780, 782, 783, 787, 794,
1250 798, 805, 808, 813, 820
1251};
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001252
Chris Lattnerf49c1762006-11-08 05:58:47 +00001253static const short yyrhs[] = { 5,
1254 0, 6, 0, 3, 0, 4, 0, 78, 0, 79,
1255 0, 80, 0, 81, 0, 82, 0, 83, 0, 84,
1256 0, 85, 0, 86, 0, 87, 0, 88, 0, 89,
1257 0, 90, 0, 91, 0, 92, 0, 93, 0, 94,
1258 0, 95, 0, 105, 0, 106, 0, 16, 0, 14,
1259 0, 12, 0, 10, 0, 17, 0, 15, 0, 13,
1260 0, 11, 0, 133, 0, 134, 0, 18, 0, 19,
1261 0, 169, 113, 0, 0, 41, 0, 42, 0, 43,
1262 0, 44, 0, 45, 0, 46, 0, 47, 0, 0,
1263 0, 65, 0, 66, 0, 67, 0, 68, 0, 69,
1264 0, 70, 0, 64, 4, 0, 0, 57, 4, 0,
1265 0, 114, 57, 4, 0, 34, 24, 0, 0, 142,
1266 0, 0, 114, 145, 144, 0, 142, 0, 57, 4,
1267 0, 148, 0, 8, 0, 150, 0, 8, 0, 150,
1268 0, 9, 0, 10, 0, 11, 0, 12, 0, 13,
1269 0, 14, 0, 15, 0, 16, 0, 17, 0, 18,
1270 0, 19, 0, 20, 0, 21, 0, 48, 0, 149,
1271 0, 184, 0, 115, 4, 0, 147, 116, 152, 117,
1272 0, 118, 4, 119, 150, 120, 0, 121, 4, 119,
1273 150, 122, 0, 123, 151, 124, 0, 123, 124, 0,
1274 150, 125, 0, 150, 0, 151, 114, 150, 0, 151,
1275 0, 151, 114, 37, 0, 37, 0, 0, 148, 118,
1276 155, 120, 0, 148, 118, 120, 0, 148, 126, 24,
1277 0, 148, 121, 155, 122, 0, 148, 123, 155, 124,
1278 0, 148, 123, 124, 0, 148, 38, 0, 148, 39,
1279 0, 148, 184, 0, 148, 154, 0, 148, 26, 0,
1280 133, 128, 0, 134, 4, 0, 9, 27, 0, 9,
1281 28, 0, 136, 7, 0, 103, 116, 153, 36, 148,
1282 117, 0, 101, 116, 153, 198, 117, 0, 104, 116,
1283 153, 114, 153, 114, 153, 117, 0, 129, 116, 153,
1284 114, 153, 117, 0, 130, 116, 153, 114, 153, 117,
1285 0, 131, 116, 153, 114, 153, 117, 0, 132, 116,
1286 153, 114, 153, 117, 0, 108, 116, 153, 114, 153,
1287 117, 0, 109, 116, 153, 114, 153, 114, 153, 117,
1288 0, 110, 116, 153, 114, 153, 114, 153, 117, 0,
1289 155, 114, 153, 0, 153, 0, 32, 0, 33, 0,
1290 158, 0, 158, 178, 0, 158, 180, 0, 158, 62,
1291 61, 164, 0, 158, 25, 0, 159, 0, 159, 137,
1292 20, 146, 0, 159, 180, 0, 159, 62, 61, 164,
1293 0, 0, 159, 137, 138, 156, 153, 160, 144, 0,
1294 0, 159, 137, 50, 156, 148, 161, 144, 0, 0,
1295 159, 137, 45, 156, 148, 162, 144, 0, 0, 159,
1296 137, 47, 156, 148, 163, 144, 0, 159, 51, 166,
1297 0, 159, 58, 113, 167, 0, 0, 24, 0, 56,
1298 0, 55, 0, 53, 113, 165, 0, 54, 113, 4,
1299 0, 52, 113, 24, 0, 71, 113, 24, 0, 118,
1300 168, 120, 0, 168, 114, 24, 0, 24, 0, 0,
1301 22, 0, 24, 0, 169, 0, 0, 148, 170, 0,
1302 172, 114, 171, 0, 171, 0, 172, 0, 172, 114,
1303 37, 0, 37, 0, 0, 139, 146, 169, 116, 173,
1304 117, 143, 140, 0, 29, 0, 123, 0, 138, 174,
1305 175, 0, 30, 0, 124, 0, 187, 177, 0, 0,
1306 45, 0, 47, 0, 0, 31, 181, 179, 174, 0,
1307 0, 63, 0, 3, 0, 4, 0, 7, 0, 27,
1308 0, 28, 0, 38, 0, 39, 0, 26, 0, 121,
1309 155, 122, 0, 154, 0, 61, 182, 24, 114, 24,
1310 0, 127, 0, 169, 0, 184, 0, 183, 0, 148,
1311 185, 0, 187, 188, 0, 176, 188, 0, 189, 137,
1312 190, 0, 189, 192, 0, 0, 23, 0, 72, 186,
1313 0, 72, 8, 0, 73, 21, 185, 0, 73, 9,
1314 185, 114, 21, 185, 114, 21, 185, 0, 74, 135,
1315 185, 114, 21, 185, 118, 191, 120, 0, 74, 135,
1316 185, 114, 21, 185, 118, 120, 0, 75, 139, 146,
1317 185, 116, 195, 117, 36, 21, 185, 76, 21, 185,
1318 0, 76, 0, 77, 0, 191, 135, 183, 114, 21,
1319 185, 0, 135, 183, 114, 21, 185, 0, 137, 197,
1320 0, 148, 118, 185, 114, 185, 120, 0, 193, 114,
1321 118, 185, 114, 185, 120, 0, 186, 0, 194, 114,
1322 186, 0, 194, 0, 0, 60, 59, 0, 59, 0,
1323 129, 148, 185, 114, 185, 0, 130, 148, 185, 114,
1324 185, 0, 131, 148, 185, 114, 185, 0, 49, 186,
1325 0, 132, 186, 114, 186, 0, 103, 186, 36, 148,
1326 0, 104, 186, 114, 186, 114, 186, 0, 107, 186,
1327 114, 148, 0, 111, 186, 114, 148, 0, 112, 186,
1328 114, 148, 0, 108, 186, 114, 186, 0, 109, 186,
1329 114, 186, 114, 186, 0, 110, 186, 114, 186, 114,
1330 186, 0, 102, 193, 0, 196, 139, 146, 185, 116,
1331 195, 117, 0, 200, 0, 114, 194, 0, 0, 35,
1332 0, 0, 96, 148, 141, 0, 96, 148, 114, 15,
1333 185, 141, 0, 97, 148, 141, 0, 97, 148, 114,
1334 15, 185, 141, 0, 98, 186, 0, 199, 99, 148,
1335 185, 0, 199, 100, 186, 114, 148, 185, 0, 101,
1336 148, 185, 198, 0
1337};
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001338
1339#endif
1340
Chris Lattnerf49c1762006-11-08 05:58:47 +00001341#if YYDEBUG != 0
1342static const short yyrline[] = { 0,
1343 1139, 1140, 1148, 1149, 1159, 1159, 1159, 1159, 1159, 1159,
1344 1159, 1159, 1159, 1160, 1160, 1160, 1161, 1161, 1161, 1161,
1345 1161, 1161, 1163, 1163, 1167, 1167, 1167, 1167, 1168, 1168,
1346 1168, 1168, 1169, 1169, 1170, 1170, 1173, 1177, 1182, 1182,
1347 1183, 1184, 1185, 1186, 1187, 1188, 1191, 1191, 1192, 1193,
1348 1194, 1195, 1196, 1197, 1207, 1207, 1214, 1214, 1223, 1231,
1349 1231, 1237, 1237, 1239, 1244, 1258, 1258, 1259, 1259, 1261,
1350 1271, 1271, 1271, 1271, 1271, 1271, 1271, 1272, 1272, 1272,
1351 1272, 1272, 1272, 1273, 1277, 1281, 1289, 1297, 1310, 1315,
1352 1327, 1337, 1341, 1352, 1357, 1363, 1364, 1368, 1372, 1383,
1353 1409, 1423, 1453, 1479, 1500, 1513, 1523, 1528, 1589, 1596,
1354 1605, 1611, 1617, 1621, 1625, 1633, 1644, 1676, 1684, 1711,
1355 1722, 1728, 1736, 1742, 1748, 1757, 1761, 1769, 1769, 1779,
1356 1787, 1792, 1796, 1800, 1804, 1819, 1841, 1844, 1847, 1852,
1357 1855, 1859, 1863, 1867, 1871, 1876, 1880, 1883, 1886, 1890,
1358 1903, 1904, 1906, 1910, 1919, 1923, 1928, 1930, 1935, 1940,
1359 1949, 1949, 1950, 1950, 1952, 1959, 1965, 1972, 1976, 1982,
1360 1987, 1992, 2087, 2087, 2089, 2097, 2097, 2099, 2104, 2104,
1361 2105, 2108, 2108, 2118, 2122, 2127, 2131, 2135, 2139, 2143,
1362 2147, 2151, 2155, 2159, 2184, 2188, 2202, 2206, 2212, 2212,
1363 2218, 2223, 2227, 2236, 2247, 2252, 2264, 2277, 2281, 2285,
1364 2290, 2299, 2318, 2327, 2383, 2387, 2394, 2405, 2418, 2427,
1365 2436, 2446, 2450, 2457, 2457, 2459, 2463, 2468, 2490, 2505,
1366 2519, 2532, 2540, 2548, 2556, 2562, 2582, 2605, 2611, 2617,
1367 2623, 2638, 2697, 2704, 2707, 2712, 2716, 2723, 2728, 2734,
1368 2739, 2745, 2753, 2765, 2780
1369};
1370#endif
1371
1372
1373#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1374
1375static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1376"EUINT64VAL","SINTVAL","UINTVAL","FPVAL","VOID","BOOL","SBYTE","UBYTE","SHORT",
1377"USHORT","INT","UINT","LONG","ULONG","FLOAT","DOUBLE","TYPE","LABEL","VAR_ID",
1378"LABELSTR","STRINGCONSTANT","IMPLEMENTATION","ZEROINITIALIZER","TRUETOK","FALSETOK",
1379"BEGINTOK","ENDTOK","DECLARE","GLOBAL","CONSTANT","SECTION","VOLATILE","TO",
1380"DOTDOTDOT","NULL_TOK","UNDEF","CONST","INTERNAL","LINKONCE","WEAK","APPENDING",
1381"DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","NOT","EXTERNAL","TARGET","TRIPLE",
1382"ENDIAN","POINTERSIZE","LITTLE","BIG","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK",
1383"MODULE","SIDEEFFECT","CC_TOK","CCC_TOK","CSRETCC_TOK","FASTCC_TOK","COLDCC_TOK",
1384"X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK","DATALAYOUT","RET","BR","SWITCH","INVOKE",
1385"UNWIND","UNREACHABLE","ADD","SUB","MUL","UDIV","SDIV","FDIV","UREM","SREM",
1386"FREM","AND","OR","XOR","SETLE","SETGE","SETLT","SETGT","SETEQ","SETNE","MALLOC",
1387"ALLOCA","FREE","LOAD","STORE","GETELEMENTPTR","PHI_TOK","CAST","SELECT","SHL",
1388"SHR","VAARG","EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR","VAARG_old","VANEXT_old",
1389"'='","','","'\\\\'","'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'*'",
1390"'c'","INTVAL","EINT64VAL","ArithmeticOps","LogicalOps","SetCondOps","ShiftOps",
1391"SIntType","UIntType","IntType","FPType","OptAssign","OptLinkage","OptCallingConv",
1392"OptAlign","OptCAlign","SectionString","OptSection","GlobalVarAttributes","GlobalVarAttribute",
1393"TypesV","UpRTypesV","Types","PrimType","UpRTypes","TypeListI","ArgTypeListI",
1394"ConstVal","ConstExpr","ConstVector","GlobalType","Module","FunctionList","ConstPool",
1395"@1","@2","@3","@4","AsmBlock","BigOrLittle","TargetDefinition","LibrariesDefinition",
1396"LibList","Name","OptName","ArgVal","ArgListH","ArgList","FunctionHeaderH","BEGIN",
1397"FunctionHeader","END","Function","FnDeclareLinkage","FunctionProto","@5","OptSideEffect",
1398"ConstValueRef","SymbolicValueRef","ValueRef","ResolvedVal","BasicBlockList",
1399"BasicBlock","InstructionList","BBTerminatorInst","JumpTable","Inst","PHIList",
1400"ValueRefList","ValueRefListE","OptTailCall","InstVal","IndexList","OptVolatile",
1401"MemoryInst", NULL
1402};
1403#endif
1404
1405static const short yyr1[] = { 0,
1406 127, 127, 128, 128, 129, 129, 129, 129, 129, 129,
1407 129, 129, 129, 130, 130, 130, 131, 131, 131, 131,
1408 131, 131, 132, 132, 133, 133, 133, 133, 134, 134,
1409 134, 134, 135, 135, 136, 136, 137, 137, 138, 138,
1410 138, 138, 138, 138, 138, 138, 139, 139, 139, 139,
1411 139, 139, 139, 139, 140, 140, 141, 141, 142, 143,
1412 143, 144, 144, 145, 145, 146, 146, 147, 147, 148,
1413 149, 149, 149, 149, 149, 149, 149, 149, 149, 149,
1414 149, 149, 149, 150, 150, 150, 150, 150, 150, 150,
1415 150, 150, 150, 151, 151, 152, 152, 152, 152, 153,
1416 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
1417 153, 153, 153, 153, 153, 154, 154, 154, 154, 154,
1418 154, 154, 154, 154, 154, 155, 155, 156, 156, 157,
1419 158, 158, 158, 158, 158, 159, 159, 159, 160, 159,
1420 161, 159, 162, 159, 163, 159, 159, 159, 159, 164,
1421 165, 165, 166, 166, 166, 166, 167, 168, 168, 168,
1422 169, 169, 170, 170, 171, 172, 172, 173, 173, 173,
1423 173, 174, 175, 175, 176, 177, 177, 178, 179, 179,
1424 179, 181, 180, 182, 182, 183, 183, 183, 183, 183,
1425 183, 183, 183, 183, 183, 183, 184, 184, 185, 185,
1426 186, 187, 187, 188, 189, 189, 189, 190, 190, 190,
1427 190, 190, 190, 190, 190, 190, 191, 191, 192, 193,
1428 193, 194, 194, 195, 195, 196, 196, 197, 197, 197,
1429 197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
1430 197, 197, 197, 198, 198, 199, 199, 200, 200, 200,
1431 200, 200, 200, 200, 200
1432};
1433
1434static const short yyr2[] = { 0,
1435 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1436 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1437 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1438 1, 1, 1, 1, 1, 1, 2, 0, 1, 1,
1439 1, 1, 1, 1, 1, 0, 0, 1, 1, 1,
1440 1, 1, 1, 2, 0, 2, 0, 3, 2, 0,
1441 1, 0, 3, 1, 2, 1, 1, 1, 1, 1,
1442 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1443 1, 1, 1, 1, 1, 1, 2, 4, 5, 5,
1444 3, 2, 2, 1, 3, 1, 3, 1, 0, 4,
1445 3, 3, 4, 4, 3, 2, 2, 2, 2, 2,
1446 2, 2, 2, 2, 2, 6, 5, 8, 6, 6,
1447 6, 6, 6, 8, 8, 3, 1, 1, 1, 1,
1448 2, 2, 4, 2, 1, 4, 2, 4, 0, 7,
1449 0, 7, 0, 7, 0, 7, 3, 4, 0, 1,
1450 1, 1, 3, 3, 3, 3, 3, 3, 1, 0,
1451 1, 1, 1, 0, 2, 3, 1, 1, 3, 1,
1452 0, 8, 1, 1, 3, 1, 1, 2, 0, 1,
1453 1, 0, 4, 0, 1, 1, 1, 1, 1, 1,
1454 1, 1, 1, 3, 1, 5, 1, 1, 1, 1,
1455 2, 2, 2, 3, 2, 0, 1, 2, 2, 3,
1456 9, 9, 8, 13, 1, 1, 6, 5, 2, 6,
1457 7, 1, 3, 1, 0, 2, 1, 5, 5, 5,
1458 2, 4, 4, 6, 4, 4, 4, 4, 6, 6,
1459 2, 7, 1, 2, 0, 1, 0, 3, 6, 3,
1460 6, 2, 4, 6, 4
1461};
1462
1463static const short yydefact[] = { 149,
1464 46, 135, 134, 182, 39, 40, 41, 42, 43, 44,
1465 45, 0, 47, 206, 131, 132, 206, 161, 162, 0,
1466 0, 0, 46, 0, 137, 179, 0, 0, 48, 49,
1467 50, 51, 52, 53, 0, 0, 207, 203, 38, 176,
1468 177, 178, 202, 0, 0, 0, 0, 147, 0, 0,
1469 0, 0, 0, 0, 0, 37, 180, 181, 47, 150,
1470 133, 54, 1, 2, 67, 71, 72, 73, 74, 75,
1471 76, 77, 78, 79, 80, 81, 82, 83, 84, 0,
1472 0, 0, 0, 197, 0, 0, 66, 85, 70, 198,
1473 86, 173, 174, 175, 247, 205, 0, 0, 0, 0,
1474 160, 148, 138, 136, 128, 129, 0, 0, 0, 0,
1475 183, 87, 0, 0, 69, 92, 94, 0, 0, 99,
1476 93, 246, 0, 227, 0, 0, 0, 0, 47, 215,
1477 216, 5, 6, 7, 8, 9, 10, 11, 12, 13,
1478 14, 15, 16, 17, 18, 19, 20, 21, 22, 0,
1479 0, 0, 0, 0, 0, 0, 23, 24, 0, 0,
1480 0, 0, 0, 0, 0, 0, 0, 0, 204, 47,
1481 219, 0, 243, 155, 152, 151, 153, 154, 156, 159,
1482 0, 143, 145, 141, 71, 72, 73, 74, 75, 76,
1483 77, 78, 79, 80, 81, 0, 0, 0, 0, 139,
1484 0, 0, 0, 91, 171, 98, 96, 0, 0, 231,
1485 226, 209, 208, 0, 0, 28, 32, 27, 31, 26,
1486 30, 25, 29, 33, 34, 0, 0, 57, 57, 252,
1487 0, 0, 241, 0, 0, 0, 0, 0, 0, 0,
1488 0, 0, 0, 0, 0, 0, 0, 0, 0, 157,
1489 62, 62, 62, 113, 114, 3, 4, 111, 112, 115,
1490 110, 106, 107, 0, 0, 0, 0, 0, 0, 0,
1491 0, 0, 0, 0, 0, 0, 0, 109, 108, 62,
1492 68, 68, 95, 170, 164, 167, 168, 0, 0, 88,
1493 186, 187, 188, 193, 189, 190, 191, 192, 184, 0,
1494 195, 200, 199, 201, 0, 210, 0, 0, 0, 248,
1495 0, 250, 245, 0, 0, 0, 0, 0, 0, 0,
1496 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1497 158, 0, 144, 146, 142, 0, 0, 0, 0, 0,
1498 0, 101, 127, 0, 0, 105, 0, 102, 0, 0,
1499 0, 0, 140, 89, 90, 163, 165, 0, 60, 97,
1500 185, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1501 255, 0, 0, 233, 0, 235, 238, 0, 0, 236,
1502 237, 0, 0, 0, 232, 0, 253, 0, 0, 0,
1503 64, 62, 245, 0, 0, 0, 0, 0, 0, 100,
1504 103, 104, 0, 0, 0, 0, 169, 166, 61, 55,
1505 0, 194, 0, 0, 225, 57, 58, 57, 222, 244,
1506 0, 0, 0, 0, 0, 228, 229, 230, 225, 0,
1507 59, 65, 63, 0, 0, 0, 0, 0, 0, 126,
1508 0, 0, 0, 0, 0, 172, 0, 0, 0, 224,
1509 0, 0, 249, 251, 0, 0, 0, 234, 239, 240,
1510 0, 254, 117, 0, 0, 0, 0, 0, 0, 0,
1511 0, 0, 56, 196, 0, 0, 0, 223, 220, 0,
1512 242, 116, 0, 123, 0, 0, 119, 120, 121, 122,
1513 0, 213, 0, 0, 0, 221, 0, 0, 0, 211,
1514 0, 212, 0, 0, 118, 124, 125, 0, 0, 0,
1515 0, 0, 0, 218, 0, 0, 217, 214, 0, 0,
1516 0
1517};
1518
1519static const short yydefgoto[] = { 84,
1520 258, 274, 275, 276, 277, 196, 197, 226, 198, 23,
1521 13, 35, 446, 310, 391, 410, 333, 392, 85, 86,
1522 199, 88, 89, 118, 208, 343, 301, 344, 107, 519,
1523 1, 2, 280, 253, 251, 252, 61, 177, 48, 102,
1524 181, 90, 357, 286, 287, 288, 36, 94, 14, 42,
1525 15, 59, 16, 26, 362, 302, 91, 304, 419, 17,
1526 38, 39, 169, 494, 96, 233, 450, 451, 170, 171,
1527 371, 172, 173
1528};
1529
1530static const short yypact[] = {-32768,
1531 184, 610,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1532-32768, -46, 135, -1,-32768,-32768, -18,-32768,-32768, 15,
1533 -72, -24, 51, -62,-32768, 19, 61, 98,-32768,-32768,
1534-32768,-32768,-32768,-32768, 1070, -20,-32768,-32768, 85,-32768,
1535-32768,-32768,-32768, 33, 56, 60, 62,-32768, 54, 61,
1536 1070, 90, 90, 90, 90,-32768,-32768,-32768, 135,-32768,
1537-32768,-32768,-32768,-32768, 58,-32768,-32768,-32768,-32768,-32768,
1538-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 173,
1539 174, 176, 576,-32768, 85, 66,-32768,-32768, -26,-32768,
1540-32768,-32768,-32768,-32768, 1245,-32768, 157, 83, 179, 162,
1541 166,-32768,-32768,-32768,-32768,-32768, 1111, 1111, 1111, 1152,
1542-32768,-32768, 75, 76,-32768,-32768, -26, -78, 80, 865,
1543-32768,-32768, 1111,-32768, 138, 1193, 24, 151, 135,-32768,
1544-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1545-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1111,
1546 1111, 1111, 1111, 1111, 1111, 1111,-32768,-32768, 1111, 1111,
1547 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111,-32768, 135,
1548-32768, 41,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1549 -10,-32768,-32768,-32768, 115, 145, 202, 147, 203, 149,
1550 204, 152, 206, 212, 213, 154, 217, 215, 419,-32768,
1551 1111, 1111, 1111,-32768, 906,-32768, 118, 116, 643,-32768,
1552-32768, 58,-32768, 643, 643,-32768,-32768,-32768,-32768,-32768,
1553-32768,-32768,-32768,-32768,-32768, 643, 1070, 120, 121,-32768,
1554 643, 124, 129, 208, 131, 133, 134, 140, 141, 142,
1555 143, 643, 643, 643, 144, 1070, 1111, 1111, 236,-32768,
1556 148, 148, 148,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1557-32768,-32768,-32768, 150, 153, 155, 156, 159, 160, 947,
1558 1152, 596, 237, 161, 164, 175, 177,-32768,-32768, 148,
1559 -81, -38, -26,-32768, 85,-32768, 180, 146, 988,-32768,
1560-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 201, 1152,
1561-32768,-32768,-32768,-32768, 182,-32768, 183, 643, -2,-32768,
1562 6,-32768, 186, 643, 185, 1111, 1111, 1111, 1111, 1111,
1563 1111, 1111, 1111, 187, 188, 190, 1111, 643, 643, 191,
1564-32768, -23,-32768,-32768,-32768, 1152, 1152, 1152, 1152, 1152,
1565 1152,-32768,-32768, -9, -52,-32768, -76,-32768, 1152, 1152,
1566 1152, 1152,-32768,-32768,-32768,-32768,-32768, 1029, 231,-32768,
1567-32768, 243, -14, 247, 249, 193, 643, 294, 643, 1111,
1568-32768, 196, 643,-32768, 197,-32768,-32768, 199, 205,-32768,
1569-32768, 643, 643, 643,-32768, 200,-32768, 1111, 291, 313,
1570-32768, 148, 186, 288, 211, 216, 218, 219, 1152,-32768,
1571-32768,-32768, 220, 226, 232, 233,-32768,-32768,-32768, 269,
1572 234,-32768, 643, 643, 1111, 240,-32768, 240,-32768, 241,
1573 643, 242, 1111, 1111, 1111,-32768,-32768,-32768, 1111, 643,
1574-32768,-32768,-32768, 214, 1111, 1152, 1152, 1152, 1152,-32768,
1575 1152, 1152, 1152, 1152, 341,-32768, 327, 246, 239, 241,
1576 244, 305,-32768,-32768, 1111, 245, 643,-32768,-32768,-32768,
1577 252,-32768,-32768, 253, 250, 254, 259, 260, 262, 264,
1578 265, 267,-32768,-32768, 342, 14, 340,-32768,-32768, 257,
1579-32768,-32768, 1152,-32768, 1152, 1152,-32768,-32768,-32768,-32768,
1580 643,-32768, 751, 65, 366,-32768, 274, 278, 279,-32768,
1581 283,-32768, 751, 643,-32768,-32768,-32768, 377, 285, 325,
1582 643, 382, 383,-32768, 643, 643,-32768,-32768, 405, 406,
1583-32768
1584};
1585
1586static const short yypgoto[] = {-32768,
1587-32768, 312, 314, 315, 316, -127, -126, -462,-32768, 369,
1588 389, -87,-32768, -225, 55,-32768, -245,-32768, -48,-32768,
1589 -35,-32768, -66, 293,-32768, -100, 222, -253, 59,-32768,
1590-32768,-32768,-32768,-32768,-32768,-32768, 365,-32768,-32768,-32768,
1591-32768, 4,-32768, 68,-32768,-32768, 357,-32768,-32768,-32768,
1592-32768,-32768, 415,-32768,-32768, -453, -55, 64, -103,-32768,
1593 401,-32768,-32768,-32768,-32768,-32768, 49, -7,-32768,-32768,
1594 30,-32768,-32768
1595};
1596
1597
1598#define YYLAST 1357
1599
1600
1601static const short yytable[] = { 87,
1602 224, 225, 104, 312, 37, 24, 334, 335, 92, 200,
1603 389, 40, 367, 493, 27, 87, 117, 345, 347, 210,
1604 369, 37, 213, 216, 217, 218, 219, 220, 221, 222,
1605 223, 503, 214, 390, 353, 203, 50, 399, 354, 501,
1606 49, 227, 24, 121, 215, 204, 363, 402, 230, 509,
1607 56, 234, 235, 117, 368, 236, 237, 238, 239, 240,
1608 241, 399, 368, 57, 245, 58, 44, 45, 46, 401,
1609 51, 182, 183, 184, 216, 217, 218, 219, 220, 221,
1610 222, 223, 246, 355, 60, 47, 121, 209, 119, -68,
1611 209, 5, 6, 7, 8, 52, 10, 53, 121, 399,
1612 54, 62, 93, 249, 399, 41, 18, 412, 19, 250,
1613 400, 108, 109, 110, 228, 229, 209, 231, 232, 209,
1614 209, 105, 106, 209, 209, 209, 209, 209, 209, 242,
1615 243, 244, 209, 492, 281, 282, 283, 175, 176, 247,
1616 248, 254, 255, 279, 330, 97, 433, -28, -28, -27,
1617 -27, -26, -26, 303, -25, -25, 256, 257, 303, 303,
1618 216, 217, 218, 219, 220, 221, 222, 223, 98, 285,
1619 303, 101, 99, -69, 100, 303, 112, 113, 308, 114,
1620 174, 120, 178, -130, 502, 179, 303, 303, 303, 180,
1621 453, 87, 454, 201, 202, 205, 211, 328, 28, 29,
1622 30, 31, 32, 33, 34, -32, -31, -30, 3, -29,
1623 87, 329, 209, 375, 4, 377, 378, 379, -35, -36,
1624 259, 260, 283, 385, 5, 6, 7, 8, 9, 10,
1625 11, 289, 290, 309, 311, 393, 394, 395, 396, 397,
1626 398, 314, 315, 316, 317, 12, 318, 319, 403, 404,
1627 405, 406, 303, 320, 321, 322, 323, 327, 303, 331,
1628 348, 332, 359, 361, 389, 336, 411, 413, 337, 414,
1629 338, 339, 303, 303, 340, 341, 349, 305, 306, 350,
1630 374, 209, 376, 209, 209, 209, 380, 381, 356, 307,
1631 351, 209, 352, 358, 313, 364, 365, 417, 440, 370,
1632 382, 383, 373, 384, 388, 324, 325, 326, 415, 421,
1633 423, 303, 424, 303, 431, 429, 432, 303, 425, 458,
1634 459, 460, 285, 435, 436, 445, 303, 303, 303, 437,
1635 463, 438, 439, 441, 209, 465, 466, 467, 468, 442,
1636 469, 470, 471, 472, 473, 443, 444, 447, 224, 225,
1637 474, 478, 430, 452, 455, 457, 476, 303, 303, 475,
1638 477, 368, 491, 483, 479, 303, 224, 225, 481, 482,
1639 484, 366, 485, 486, 303, 495, 496, 372, 487, 209,
1640 488, 489, 497, 490, 498, 499, 504, 209, 209, 209,
1641 505, 386, 387, 209, 506, 507, 508, 511, 512, 464,
1642 513, 303, 515, 516, 520, 521, 165, 95, 166, 167,
1643 168, 55, 207, 409, 103, 111, 25, 43, 420, 209,
1644 278, 461, 434, 63, 64, 408, 0, 0, 0, 0,
1645 416, 0, 418, 0, 0, 303, 422, 0, 0, 0,
1646 18, 0, 19, 0, 261, 426, 427, 428, 303, 0,
1647 0, 0, 0, 0, 0, 303, 262, 263, 0, 303,
1648 303, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1649 0, 0, 0, 0, 0, 0, 448, 449, 0, 0,
1650 0, 0, 0, 0, 456, 0, 0, 0, 0, 0,
1651 0, 0, 0, 462, 0, 0, 132, 133, 134, 135,
1652 136, 137, 138, 139, 140, 141, 142, 143, 144, 145,
1653 146, 147, 148, 149, 0, 0, 0, 0, 0, 264,
1654 480, 265, 266, 157, 158, 0, 267, 268, 269, 0,
1655 0, 0, 0, 0, 0, 0, 270, 0, 0, 271,
1656 0, 272, 0, 0, 273, 0, 0, 0, 0, 0,
1657 0, 0, 0, 0, 500, 0, 0, 0, 0, 0,
1658 0, 0, 0, 0, 0, 0, 0, 510, 0, 0,
1659 0, 0, 0, 0, 514, 0, 0, 0, 517, 518,
1660 63, 64, 0, 115, 66, 67, 68, 69, 70, 71,
1661 72, 73, 74, 75, 76, 77, 78, 18, 0, 19,
1662 63, 64, 0, 115, 185, 186, 187, 188, 189, 190,
1663 191, 192, 193, 194, 195, 77, 78, 18, 0, 19,
1664 0, 0, 0, 79, 0, 0, 0, 0, 0, -38,
1665 0, 18, 0, 19, 0, 0, 0, 0, 0, 0,
1666 4, -38, -38, 79, 0, 291, 292, 63, 64, 293,
1667 -38, -38, -38, -38, -38, -38, -38, 0, 0, -38,
1668 20, 0, 0, 0, 18, 0, 19, 21, 294, 295,
1669 296, 22, 0, 0, 0, 0, 0, 0, 0, 0,
1670 297, 298, 0, 0, 0, 0, 0, 0, 0, 0,
1671 80, 0, 0, 81, 0, 0, 82, 0, 83, 116,
1672 0, 0, 0, 299, 0, 0, 0, 0, 0, 0,
1673 80, 0, 0, 81, 0, 0, 82, 0, 83, 346,
1674 132, 133, 134, 135, 136, 137, 138, 139, 140, 141,
1675 142, 143, 144, 145, 146, 147, 148, 149, 0, 0,
1676 0, 0, 0, 264, 0, 265, 266, 157, 158, 0,
1677 267, 268, 269, 291, 292, 0, 0, 293, 0, 0,
1678 0, 0, 0, 300, 0, 0, 0, 0, 0, 0,
1679 0, 0, 0, 0, 0, 0, 294, 295, 296, 0,
1680 0, 0, 0, 0, 0, 0, 0, 0, 297, 298,
1681 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1682 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1683 0, 299, 0, 0, 0, 0, 0, 0, 0, 0,
1684 0, 0, 0, 0, 0, 0, 0, 0, 132, 133,
1685 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
1686 144, 145, 146, 147, 148, 149, 0, 0, 0, 0,
1687 0, 264, 0, 265, 266, 157, 158, 0, 267, 268,
1688 269, 0, 0, 0, 0, 0, 0, 0, 0, 63,
1689 64, 300, 115, 66, 67, 68, 69, 70, 71, 72,
1690 73, 74, 75, 76, 77, 78, 18, 0, 19, 0,
1691 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1692 0, 206, 0, 0, 0, 0, 0, 0, 0, 0,
1693 63, 64, 79, 115, 66, 67, 68, 69, 70, 71,
1694 72, 73, 74, 75, 76, 77, 78, 18, 0, 19,
1695 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1696 0, 0, 284, 0, 0, 0, 0, 0, 0, 0,
1697 0, 63, 64, 79, 115, 185, 186, 187, 188, 189,
1698 190, 191, 192, 193, 194, 195, 77, 78, 18, 0,
1699 19, 0, 0, 0, 0, 0, 0, 0, 0, 80,
1700 0, 0, 81, 0, 0, 82, 0, 83, 0, 0,
1701 0, 0, 63, 64, 79, 115, 66, 67, 68, 69,
1702 70, 71, 72, 73, 74, 75, 76, 77, 78, 18,
1703 0, 19, 0, 0, 0, 0, 0, 0, 0, 0,
1704 80, 0, 0, 81, 360, 0, 82, 0, 83, 0,
1705 0, 0, 0, 63, 64, 79, 115, 66, 67, 68,
1706 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1707 18, 0, 19, 0, 0, 0, 0, 0, 0, 0,
1708 0, 80, 0, 0, 81, 407, 342, 82, 0, 83,
1709 0, 0, 0, 0, 63, 64, 79, 65, 66, 67,
1710 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1711 78, 18, 0, 19, 0, 0, 0, 0, 0, 0,
1712 0, 0, 80, 0, 0, 81, 0, 0, 82, 0,
1713 83, 0, 0, 0, 0, 63, 64, 79, 115, 66,
1714 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1715 77, 78, 18, 0, 19, 0, 0, 0, 0, 0,
1716 0, 0, 0, 80, 0, 0, 81, 0, 0, 82,
1717 0, 83, 0, 0, 0, 0, 63, 64, 79, 115,
1718 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
1719 195, 77, 78, 18, 0, 19, 0, 0, 0, 0,
1720 0, 0, 0, 0, 80, 0, 0, 81, 0, 0,
1721 82, 0, 83, 0, 0, 0, 0, 63, 64, 79,
1722 212, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1723 75, 76, 77, 78, 18, 0, 19, 0, 0, 0,
1724 0, 0, 0, 0, 0, 80, 0, 0, 81, 0,
1725 0, 82, 0, 83, 0, 0, 0, 0, 0, 0,
1726 79, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1727 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1728 0, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1729 0, 0, 82, 0, 83, 0, 0, 0, 0, 122,
1730 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1731 0, 0, 0, 123, 0, 0, 0, 0, 0, 0,
1732 0, 0, 0, 124, 125, 0, 0, 80, 0, 0,
1733 81, 0, 0, 82, 0, 83, 126, 127, 128, 129,
1734 130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
1735 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
1736 150, 151, 152, 0, 0, 153, 154, 155, 156, 157,
1737 158, 159, 160, 161, 162, 163, 164
1738};
1739
1740static const short yycheck[] = { 35,
1741 128, 128, 51, 229, 23, 2, 252, 253, 29, 110,
1742 34, 30, 15, 476, 61, 51, 83, 271, 272, 123,
1743 15, 23, 126, 10, 11, 12, 13, 14, 15, 16,
1744 17, 494, 9, 57, 280, 114, 61, 114, 120, 493,
1745 113, 129, 39, 125, 21, 124, 300, 124, 152, 503,
1746 113, 155, 156, 120, 57, 159, 160, 161, 162, 163,
1747 164, 114, 57, 45, 168, 47, 52, 53, 54, 122,
1748 20, 107, 108, 109, 10, 11, 12, 13, 14, 15,
1749 16, 17, 170, 122, 24, 71, 125, 123, 85, 116,
1750 126, 41, 42, 43, 44, 45, 46, 47, 125, 114,
1751 50, 4, 123, 114, 114, 124, 22, 122, 24, 120,
1752 120, 53, 54, 55, 150, 151, 152, 153, 154, 155,
1753 156, 32, 33, 159, 160, 161, 162, 163, 164, 165,
1754 166, 167, 168, 120, 201, 202, 203, 55, 56, 99,
1755 100, 27, 28, 199, 248, 113, 392, 3, 4, 3,
1756 4, 3, 4, 209, 3, 4, 3, 4, 214, 215,
1757 10, 11, 12, 13, 14, 15, 16, 17, 113, 205,
1758 226, 118, 113, 116, 113, 231, 4, 4, 227, 4,
1759 24, 116, 4, 0, 120, 24, 242, 243, 244, 24,
1760 416, 227, 418, 119, 119, 116, 59, 246, 64, 65,
1761 66, 67, 68, 69, 70, 4, 4, 4, 25, 4,
1762 246, 247, 248, 317, 31, 319, 320, 321, 7, 7,
1763 4, 7, 289, 327, 41, 42, 43, 44, 45, 46,
1764 47, 114, 117, 114, 114, 336, 337, 338, 339, 340,
1765 341, 118, 114, 36, 114, 62, 114, 114, 349, 350,
1766 351, 352, 308, 114, 114, 114, 114, 114, 314, 24,
1767 24, 114, 117, 63, 34, 116, 24, 21, 116, 21,
1768 116, 116, 328, 329, 116, 116, 116, 214, 215, 116,
1769 316, 317, 318, 319, 320, 321, 322, 323, 285, 226,
1770 116, 327, 116, 114, 231, 114, 114, 4, 399, 114,
1771 114, 114, 118, 114, 114, 242, 243, 244, 116, 114,
1772 114, 367, 114, 369, 24, 116, 4, 373, 114, 423,
1773 424, 425, 358, 36, 114, 57, 382, 383, 384, 114,
1774 117, 114, 114, 114, 370, 436, 437, 438, 439, 114,
1775 441, 442, 443, 444, 4, 114, 114, 114, 476, 476,
1776 24, 455, 388, 114, 114, 114, 118, 413, 414, 114,
1777 117, 57, 21, 114, 120, 421, 494, 494, 117, 117,
1778 117, 308, 114, 114, 430, 36, 120, 314, 117, 415,
1779 117, 117, 483, 117, 485, 486, 21, 423, 424, 425,
1780 117, 328, 329, 429, 117, 117, 114, 21, 114, 435,
1781 76, 457, 21, 21, 0, 0, 95, 39, 95, 95,
1782 95, 23, 120, 359, 50, 59, 2, 17, 370, 455,
1783 199, 429, 393, 5, 6, 358, -1, -1, -1, -1,
1784 367, -1, 369, -1, -1, 491, 373, -1, -1, -1,
1785 22, -1, 24, -1, 26, 382, 383, 384, 504, -1,
1786 -1, -1, -1, -1, -1, 511, 38, 39, -1, 515,
1787 516, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1788 -1, -1, -1, -1, -1, -1, 413, 414, -1, -1,
1789 -1, -1, -1, -1, 421, -1, -1, -1, -1, -1,
1790 -1, -1, -1, 430, -1, -1, 78, 79, 80, 81,
1791 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
1792 92, 93, 94, 95, -1, -1, -1, -1, -1, 101,
1793 457, 103, 104, 105, 106, -1, 108, 109, 110, -1,
1794 -1, -1, -1, -1, -1, -1, 118, -1, -1, 121,
1795 -1, 123, -1, -1, 126, -1, -1, -1, -1, -1,
1796 -1, -1, -1, -1, 491, -1, -1, -1, -1, -1,
1797 -1, -1, -1, -1, -1, -1, -1, 504, -1, -1,
1798 -1, -1, -1, -1, 511, -1, -1, -1, 515, 516,
1799 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1800 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1801 5, 6, -1, 8, 9, 10, 11, 12, 13, 14,
1802 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1803 -1, -1, -1, 48, -1, -1, -1, -1, -1, 20,
1804 -1, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1805 31, 32, 33, 48, -1, 3, 4, 5, 6, 7,
1806 41, 42, 43, 44, 45, 46, 47, -1, -1, 50,
1807 51, -1, -1, -1, 22, -1, 24, 58, 26, 27,
1808 28, 62, -1, -1, -1, -1, -1, -1, -1, -1,
1809 38, 39, -1, -1, -1, -1, -1, -1, -1, -1,
1810 115, -1, -1, 118, -1, -1, 121, -1, 123, 124,
1811 -1, -1, -1, 61, -1, -1, -1, -1, -1, -1,
1812 115, -1, -1, 118, -1, -1, 121, -1, 123, 124,
1813 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
1814 88, 89, 90, 91, 92, 93, 94, 95, -1, -1,
1815 -1, -1, -1, 101, -1, 103, 104, 105, 106, -1,
1816 108, 109, 110, 3, 4, -1, -1, 7, -1, -1,
1817 -1, -1, -1, 121, -1, -1, -1, -1, -1, -1,
1818 -1, -1, -1, -1, -1, -1, 26, 27, 28, -1,
1819 -1, -1, -1, -1, -1, -1, -1, -1, 38, 39,
1820 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1821 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1822 -1, 61, -1, -1, -1, -1, -1, -1, -1, -1,
1823 -1, -1, -1, -1, -1, -1, -1, -1, 78, 79,
1824 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
1825 90, 91, 92, 93, 94, 95, -1, -1, -1, -1,
1826 -1, 101, -1, 103, 104, 105, 106, -1, 108, 109,
1827 110, -1, -1, -1, -1, -1, -1, -1, -1, 5,
1828 6, 121, 8, 9, 10, 11, 12, 13, 14, 15,
1829 16, 17, 18, 19, 20, 21, 22, -1, 24, -1,
1830 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1831 -1, 37, -1, -1, -1, -1, -1, -1, -1, -1,
1832 5, 6, 48, 8, 9, 10, 11, 12, 13, 14,
1833 15, 16, 17, 18, 19, 20, 21, 22, -1, 24,
1834 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1835 -1, -1, 37, -1, -1, -1, -1, -1, -1, -1,
1836 -1, 5, 6, 48, 8, 9, 10, 11, 12, 13,
1837 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
1838 24, -1, -1, -1, -1, -1, -1, -1, -1, 115,
1839 -1, -1, 118, -1, -1, 121, -1, 123, -1, -1,
1840 -1, -1, 5, 6, 48, 8, 9, 10, 11, 12,
1841 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
1842 -1, 24, -1, -1, -1, -1, -1, -1, -1, -1,
1843 115, -1, -1, 118, 37, -1, 121, -1, 123, -1,
1844 -1, -1, -1, 5, 6, 48, 8, 9, 10, 11,
1845 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
1846 22, -1, 24, -1, -1, -1, -1, -1, -1, -1,
1847 -1, 115, -1, -1, 118, 37, 120, 121, -1, 123,
1848 -1, -1, -1, -1, 5, 6, 48, 8, 9, 10,
1849 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1850 21, 22, -1, 24, -1, -1, -1, -1, -1, -1,
1851 -1, -1, 115, -1, -1, 118, -1, -1, 121, -1,
1852 123, -1, -1, -1, -1, 5, 6, 48, 8, 9,
1853 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1854 20, 21, 22, -1, 24, -1, -1, -1, -1, -1,
1855 -1, -1, -1, 115, -1, -1, 118, -1, -1, 121,
1856 -1, 123, -1, -1, -1, -1, 5, 6, 48, 8,
1857 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
1858 19, 20, 21, 22, -1, 24, -1, -1, -1, -1,
1859 -1, -1, -1, -1, 115, -1, -1, 118, -1, -1,
1860 121, -1, 123, -1, -1, -1, -1, 5, 6, 48,
1861 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
1862 18, 19, 20, 21, 22, -1, 24, -1, -1, -1,
1863 -1, -1, -1, -1, -1, 115, -1, -1, 118, -1,
1864 -1, 121, -1, 123, -1, -1, -1, -1, -1, -1,
1865 48, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1866 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1867 -1, -1, -1, -1, -1, -1, 115, -1, -1, 118,
1868 -1, -1, 121, -1, 123, -1, -1, -1, -1, 35,
1869 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1870 -1, -1, -1, 49, -1, -1, -1, -1, -1, -1,
1871 -1, -1, -1, 59, 60, -1, -1, 115, -1, -1,
1872 118, -1, -1, 121, -1, 123, 72, 73, 74, 75,
1873 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
1874 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
1875 96, 97, 98, -1, -1, 101, 102, 103, 104, 105,
1876 106, 107, 108, 109, 110, 111, 112
1877};
1878/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1879#line 3 "/usr/share/bison.simple"
1880/* This file comes from bison-1.28. */
1881
1882/* Skeleton output parser for bison,
1883 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1884
1885 This program is free software; you can redistribute it and/or modify
1886 it under the terms of the GNU General Public License as published by
1887 the Free Software Foundation; either version 2, or (at your option)
1888 any later version.
1889
1890 This program is distributed in the hope that it will be useful,
1891 but WITHOUT ANY WARRANTY; without even the implied warranty of
1892 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1893 GNU General Public License for more details.
1894
1895 You should have received a copy of the GNU General Public License
1896 along with this program; if not, write to the Free Software
1897 Foundation, Inc., 59 Temple Place - Suite 330,
1898 Boston, MA 02111-1307, USA. */
1899
1900/* As a special exception, when this file is copied by Bison into a
1901 Bison output file, you may use that output file without restriction.
1902 This special exception was added by the Free Software Foundation
1903 in version 1.24 of Bison. */
1904
1905/* This is the parser code that is written into each bison parser
1906 when the %semantic_parser declaration is not specified in the grammar.
1907 It was written by Richard Stallman by simplifying the hairy parser
1908 used when %semantic_parser is specified. */
1909
1910#ifndef YYSTACK_USE_ALLOCA
1911#ifdef alloca
1912#define YYSTACK_USE_ALLOCA
1913#else /* alloca not defined */
1914#ifdef __GNUC__
1915#define YYSTACK_USE_ALLOCA
1916#define alloca __builtin_alloca
1917#else /* not GNU C. */
1918#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1919#define YYSTACK_USE_ALLOCA
1920#include <alloca.h>
1921#else /* not sparc */
1922/* We think this test detects Watcom and Microsoft C. */
1923/* This used to test MSDOS, but that is a bad idea
1924 since that symbol is in the user namespace. */
1925#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1926#if 0 /* No need for malloc.h, which pollutes the namespace;
1927 instead, just don't use alloca. */
1928#include <malloc.h>
1929#endif
1930#else /* not MSDOS, or __TURBOC__ */
1931#if defined(_AIX)
1932/* I don't know what this was needed for, but it pollutes the namespace.
1933 So I turned it off. rms, 2 May 1997. */
1934/* #include <malloc.h> */
1935 #pragma alloca
1936#define YYSTACK_USE_ALLOCA
1937#else /* not MSDOS, or __TURBOC__, or _AIX */
1938#if 0
1939#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1940 and on HPUX 10. Eventually we can turn this on. */
1941#define YYSTACK_USE_ALLOCA
1942#define alloca __builtin_alloca
1943#endif /* __hpux */
1944#endif
1945#endif /* not _AIX */
1946#endif /* not MSDOS, or __TURBOC__ */
1947#endif /* not sparc */
1948#endif /* not GNU C */
1949#endif /* alloca not defined */
1950#endif /* YYSTACK_USE_ALLOCA not defined */
1951
1952#ifdef YYSTACK_USE_ALLOCA
1953#define YYSTACK_ALLOC alloca
Reid Spencer5b7e7532006-09-28 19:28:24 +00001954#else
Chris Lattnerf49c1762006-11-08 05:58:47 +00001955#define YYSTACK_ALLOC malloc
Reid Spencer5b7e7532006-09-28 19:28:24 +00001956#endif
1957
Chris Lattnerf49c1762006-11-08 05:58:47 +00001958/* Note: there must be only one dollar sign in this file.
1959 It is replaced by the list of actions, each action
1960 as one case of the switch. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001961
1962#define yyerrok (yyerrstatus = 0)
1963#define yyclearin (yychar = YYEMPTY)
Chris Lattnerf49c1762006-11-08 05:58:47 +00001964#define YYEMPTY -2
Reid Spencer68a24bd2005-08-27 18:50:39 +00001965#define YYEOF 0
Reid Spencer68a24bd2005-08-27 18:50:39 +00001966#define YYACCEPT goto yyacceptlab
Chris Lattnerf49c1762006-11-08 05:58:47 +00001967#define YYABORT goto yyabortlab
1968#define YYERROR goto yyerrlab1
1969/* Like YYERROR except do call yyerror.
1970 This remains here temporarily to ease the
1971 transition to the new meaning of YYERROR, for GCC.
Reid Spencer68a24bd2005-08-27 18:50:39 +00001972 Once GCC version 2 has supplanted version 1, this can go. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00001973#define YYFAIL goto yyerrlab
Reid Spencer68a24bd2005-08-27 18:50:39 +00001974#define YYRECOVERING() (!!yyerrstatus)
Chris Lattnerf49c1762006-11-08 05:58:47 +00001975#define YYBACKUP(token, value) \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001976do \
1977 if (yychar == YYEMPTY && yylen == 1) \
Chris Lattnerf49c1762006-11-08 05:58:47 +00001978 { yychar = (token), yylval = (value); \
1979 yychar1 = YYTRANSLATE (yychar); \
Reid Spencer5b7e7532006-09-28 19:28:24 +00001980 YYPOPSTACK; \
Reid Spencer68a24bd2005-08-27 18:50:39 +00001981 goto yybackup; \
1982 } \
1983 else \
Chris Lattnerf49c1762006-11-08 05:58:47 +00001984 { yyerror ("syntax error: cannot back up"); YYERROR; } \
Reid Spencer5b7e7532006-09-28 19:28:24 +00001985while (0)
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00001986
Reid Spencer68a24bd2005-08-27 18:50:39 +00001987#define YYTERROR 1
1988#define YYERRCODE 256
1989
Chris Lattnerf49c1762006-11-08 05:58:47 +00001990#ifndef YYPURE
1991#define YYLEX yylex()
Reid Spencer68a24bd2005-08-27 18:50:39 +00001992#endif
1993
Chris Lattnerf49c1762006-11-08 05:58:47 +00001994#ifdef YYPURE
1995#ifdef YYLSP_NEEDED
Reid Spencer68a24bd2005-08-27 18:50:39 +00001996#ifdef YYLEX_PARAM
Chris Lattnerf49c1762006-11-08 05:58:47 +00001997#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
Reid Spencer68a24bd2005-08-27 18:50:39 +00001998#else
Chris Lattnerf49c1762006-11-08 05:58:47 +00001999#define YYLEX yylex(&yylval, &yylloc)
2000#endif
2001#else /* not YYLSP_NEEDED */
2002#ifdef YYLEX_PARAM
2003#define YYLEX yylex(&yylval, YYLEX_PARAM)
2004#else
2005#define YYLEX yylex(&yylval)
2006#endif
2007#endif /* not YYLSP_NEEDED */
Chris Lattner1ae022f2006-10-22 06:08:13 +00002008#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002009
Chris Lattnerf49c1762006-11-08 05:58:47 +00002010/* If nonreentrant, generate the variables here */
Reid Spencer21be8652006-10-22 07:03:43 +00002011
Chris Lattnerf49c1762006-11-08 05:58:47 +00002012#ifndef YYPURE
Reid Spencer21be8652006-10-22 07:03:43 +00002013
Chris Lattnerf49c1762006-11-08 05:58:47 +00002014int yychar; /* the lookahead symbol */
2015YYSTYPE yylval; /* the semantic value of the */
2016 /* lookahead symbol */
Reid Spencer21be8652006-10-22 07:03:43 +00002017
Chris Lattnerf49c1762006-11-08 05:58:47 +00002018#ifdef YYLSP_NEEDED
2019YYLTYPE yylloc; /* location data for the lookahead */
2020 /* symbol */
Chris Lattner1ae022f2006-10-22 06:08:13 +00002021#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002022
Chris Lattnerf49c1762006-11-08 05:58:47 +00002023int yynerrs; /* number of parse errors so far */
2024#endif /* not YYPURE */
Reid Spencer21be8652006-10-22 07:03:43 +00002025
Chris Lattnerf49c1762006-11-08 05:58:47 +00002026#if YYDEBUG != 0
2027int yydebug; /* nonzero means print parse trace */
2028/* Since this is uninitialized, it does not stop multiple parsers
2029 from coexisting. */
Chris Lattner59c85e92006-10-15 23:27:25 +00002030#endif
Reid Spencerb83eb642006-10-20 07:07:24 +00002031
Chris Lattnerf49c1762006-11-08 05:58:47 +00002032/* YYINITDEPTH indicates the initial size of the parser's stacks */
Reid Spencerb83eb642006-10-20 07:07:24 +00002033
Reid Spencer68a24bd2005-08-27 18:50:39 +00002034#ifndef YYINITDEPTH
Chris Lattnerf49c1762006-11-08 05:58:47 +00002035#define YYINITDEPTH 200
Reid Spencer68a24bd2005-08-27 18:50:39 +00002036#endif
2037
Chris Lattnerf49c1762006-11-08 05:58:47 +00002038/* YYMAXDEPTH is the maximum size the stacks can grow to
2039 (effective only if the built-in stack extension method is used). */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002040
Chris Lattnerf49c1762006-11-08 05:58:47 +00002041#if YYMAXDEPTH == 0
2042#undef YYMAXDEPTH
2043#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002044
2045#ifndef YYMAXDEPTH
Chris Lattnerf49c1762006-11-08 05:58:47 +00002046#define YYMAXDEPTH 10000
Reid Spencer68a24bd2005-08-27 18:50:39 +00002047#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002048
Chris Lattnerf49c1762006-11-08 05:58:47 +00002049/* Define __yy_memcpy. Note that the size argument
2050 should be passed with type unsigned int, because that is what the non-GCC
2051 definitions require. With GCC, __builtin_memcpy takes an arg
2052 of type size_t, but it can handle unsigned int. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002053
Chris Lattnerf49c1762006-11-08 05:58:47 +00002054#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2055#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2056#else /* not GNU C or C++ */
2057#ifndef __cplusplus
Reid Spencer68a24bd2005-08-27 18:50:39 +00002058
Chris Lattnerf49c1762006-11-08 05:58:47 +00002059/* This is the most reliable way to avoid incompatibilities
2060 in available built-in functions on various systems. */
Reid Spencer21be8652006-10-22 07:03:43 +00002061static void
Chris Lattnerf49c1762006-11-08 05:58:47 +00002062__yy_memcpy (to, from, count)
2063 char *to;
2064 char *from;
2065 unsigned int count;
2066{
2067 register char *f = from;
2068 register char *t = to;
2069 register int i = count;
2070
2071 while (i-- > 0)
2072 *t++ = *f++;
2073}
2074
2075#else /* __cplusplus */
2076
2077/* This is the most reliable way to avoid incompatibilities
2078 in available built-in functions on various systems. */
Reid Spencer21be8652006-10-22 07:03:43 +00002079static void
Chris Lattnerf49c1762006-11-08 05:58:47 +00002080__yy_memcpy (char *to, char *from, unsigned int count)
2081{
2082 register char *t = to;
2083 register char *f = from;
2084 register int i = count;
2085
2086 while (i-- > 0)
2087 *t++ = *f++;
2088}
2089
Reid Spencer21be8652006-10-22 07:03:43 +00002090#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002091#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002092
Chris Lattnerf49c1762006-11-08 05:58:47 +00002093#line 217 "/usr/share/bison.simple"
Reid Spencer21be8652006-10-22 07:03:43 +00002094
Chris Lattnerf49c1762006-11-08 05:58:47 +00002095/* The user can define YYPARSE_PARAM as the name of an argument to be passed
2096 into yyparse. The argument should have type void *.
2097 It should actually point to an object.
2098 Grammar actions can access the variable by casting it
2099 to the proper pointer type. */
Reid Spencer21be8652006-10-22 07:03:43 +00002100
2101#ifdef YYPARSE_PARAM
Chris Lattnerf49c1762006-11-08 05:58:47 +00002102#ifdef __cplusplus
2103#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2104#define YYPARSE_PARAM_DECL
2105#else /* not __cplusplus */
2106#define YYPARSE_PARAM_ARG YYPARSE_PARAM
2107#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2108#endif /* not __cplusplus */
2109#else /* not YYPARSE_PARAM */
2110#define YYPARSE_PARAM_ARG
2111#define YYPARSE_PARAM_DECL
2112#endif /* not YYPARSE_PARAM */
2113
2114/* Prevent warning if -Wstrict-prototypes. */
2115#ifdef __GNUC__
2116#ifdef YYPARSE_PARAM
2117int yyparse (void *);
2118#else
Reid Spencere812fb22006-01-19 01:21:04 +00002119int yyparse (void);
Reid Spencer21be8652006-10-22 07:03:43 +00002120#endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00002121#endif
Reid Spencer21be8652006-10-22 07:03:43 +00002122
Reid Spencer21be8652006-10-22 07:03:43 +00002123int
Chris Lattnerf49c1762006-11-08 05:58:47 +00002124yyparse(YYPARSE_PARAM_ARG)
2125 YYPARSE_PARAM_DECL
Reid Spencer21be8652006-10-22 07:03:43 +00002126{
Chris Lattnerf49c1762006-11-08 05:58:47 +00002127 register int yystate;
2128 register int yyn;
2129 register short *yyssp;
2130 register YYSTYPE *yyvsp;
2131 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2132 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
Reid Spencer21be8652006-10-22 07:03:43 +00002133
Chris Lattnerf49c1762006-11-08 05:58:47 +00002134 short yyssa[YYINITDEPTH]; /* the state stack */
2135 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
Reid Spencer21be8652006-10-22 07:03:43 +00002136
Chris Lattnerf49c1762006-11-08 05:58:47 +00002137 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2138 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
Reid Spencer21be8652006-10-22 07:03:43 +00002139
Chris Lattnerf49c1762006-11-08 05:58:47 +00002140#ifdef YYLSP_NEEDED
2141 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2142 YYLTYPE *yyls = yylsa;
2143 YYLTYPE *yylsp;
Reid Spencer21be8652006-10-22 07:03:43 +00002144
Chris Lattnerf49c1762006-11-08 05:58:47 +00002145#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2146#else
Reid Spencer5b7e7532006-09-28 19:28:24 +00002147#define YYPOPSTACK (yyvsp--, yyssp--)
Chris Lattnerf49c1762006-11-08 05:58:47 +00002148#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002149
Chris Lattnerf49c1762006-11-08 05:58:47 +00002150 int yystacksize = YYINITDEPTH;
2151 int yyfree_stacks = 0;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002152
Chris Lattnerf49c1762006-11-08 05:58:47 +00002153#ifdef YYPURE
2154 int yychar;
2155 YYSTYPE yylval;
2156 int yynerrs;
2157#ifdef YYLSP_NEEDED
2158 YYLTYPE yylloc;
2159#endif
2160#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002161
Chris Lattnerf49c1762006-11-08 05:58:47 +00002162 YYSTYPE yyval; /* the variable used to return */
2163 /* semantic values from the action */
2164 /* routines */
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002165
Reid Spencer5b7e7532006-09-28 19:28:24 +00002166 int yylen;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002167
Chris Lattnerf49c1762006-11-08 05:58:47 +00002168#if YYDEBUG != 0
2169 if (yydebug)
2170 fprintf(stderr, "Starting parse\n");
2171#endif
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00002172
Reid Spencer68a24bd2005-08-27 18:50:39 +00002173 yystate = 0;
2174 yyerrstatus = 0;
2175 yynerrs = 0;
2176 yychar = YYEMPTY; /* Cause a token to be read. */
2177
2178 /* Initialize stack pointers.
2179 Waste one element of value and location stack
2180 so that they stay on the same level as the state stack.
2181 The wasted elements are never initialized. */
2182
Chris Lattnerf49c1762006-11-08 05:58:47 +00002183 yyssp = yyss - 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002184 yyvsp = yyvs;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002185#ifdef YYLSP_NEEDED
2186 yylsp = yyls;
2187#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002188
Chris Lattnerf49c1762006-11-08 05:58:47 +00002189/* Push a new state, which is found in yystate . */
2190/* In all cases, when you get here, the value and location stacks
2191 have just been pushed. so pushing a state here evens the stacks. */
2192yynewstate:
Jeff Cohen66c5fd62005-10-23 04:37:20 +00002193
Chris Lattnerf49c1762006-11-08 05:58:47 +00002194 *++yyssp = yystate;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002195
Chris Lattnerf49c1762006-11-08 05:58:47 +00002196 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002197 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00002198 /* Give user a chance to reallocate the stack */
2199 /* Use copies of these so that the &'s don't force the real ones into memory. */
2200 YYSTYPE *yyvs1 = yyvs;
2201 short *yyss1 = yyss;
2202#ifdef YYLSP_NEEDED
2203 YYLTYPE *yyls1 = yyls;
2204#endif
2205
Reid Spencer68a24bd2005-08-27 18:50:39 +00002206 /* Get the current used size of the three stacks, in elements. */
Chris Lattnerf49c1762006-11-08 05:58:47 +00002207 int size = yyssp - yyss + 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002208
2209#ifdef yyoverflow
Chris Lattnerf49c1762006-11-08 05:58:47 +00002210 /* Each stack pointer address is followed by the size of
2211 the data in use in that stack, in bytes. */
2212#ifdef YYLSP_NEEDED
2213 /* This used to be a conditional around just the two extra args,
2214 but that might be undefined if yyoverflow is a macro. */
2215 yyoverflow("parser stack overflow",
2216 &yyss1, size * sizeof (*yyssp),
2217 &yyvs1, size * sizeof (*yyvsp),
2218 &yyls1, size * sizeof (*yylsp),
2219 &yystacksize);
2220#else
2221 yyoverflow("parser stack overflow",
2222 &yyss1, size * sizeof (*yyssp),
2223 &yyvs1, size * sizeof (*yyvsp),
2224 &yystacksize);
2225#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002226
Chris Lattnerf49c1762006-11-08 05:58:47 +00002227 yyss = yyss1; yyvs = yyvs1;
2228#ifdef YYLSP_NEEDED
2229 yyls = yyls1;
2230#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002231#else /* no yyoverflow */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002232 /* Extend the stack our own way. */
Chris Lattnerf49c1762006-11-08 05:58:47 +00002233 if (yystacksize >= YYMAXDEPTH)
2234 {
2235 yyerror("parser stack overflow");
2236 if (yyfree_stacks)
2237 {
2238 free (yyss);
2239 free (yyvs);
2240#ifdef YYLSP_NEEDED
2241 free (yyls);
2242#endif
2243 }
2244 return 2;
2245 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00002246 yystacksize *= 2;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002247 if (yystacksize > YYMAXDEPTH)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002248 yystacksize = YYMAXDEPTH;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002249#ifndef YYSTACK_USE_ALLOCA
2250 yyfree_stacks = 1;
2251#endif
2252 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2253 __yy_memcpy ((char *)yyss, (char *)yyss1,
2254 size * (unsigned int) sizeof (*yyssp));
2255 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2256 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2257 size * (unsigned int) sizeof (*yyvsp));
2258#ifdef YYLSP_NEEDED
2259 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2260 __yy_memcpy ((char *)yyls, (char *)yyls1,
2261 size * (unsigned int) sizeof (*yylsp));
2262#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002263#endif /* no yyoverflow */
2264
Chris Lattnerf49c1762006-11-08 05:58:47 +00002265 yyssp = yyss + size - 1;
2266 yyvsp = yyvs + size - 1;
2267#ifdef YYLSP_NEEDED
2268 yylsp = yyls + size - 1;
2269#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002270
Chris Lattnerf49c1762006-11-08 05:58:47 +00002271#if YYDEBUG != 0
2272 if (yydebug)
2273 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2274#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002275
Chris Lattnerf49c1762006-11-08 05:58:47 +00002276 if (yyssp >= yyss + yystacksize - 1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002277 YYABORT;
2278 }
2279
Chris Lattnerf49c1762006-11-08 05:58:47 +00002280#if YYDEBUG != 0
2281 if (yydebug)
2282 fprintf(stderr, "Entering state %d\n", yystate);
2283#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002284
2285 goto yybackup;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002286 yybackup:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002287
Reid Spencer5b7e7532006-09-28 19:28:24 +00002288/* Do appropriate processing given the current state. */
Chris Lattnerf49c1762006-11-08 05:58:47 +00002289/* Read a lookahead token if we need one and don't already have one. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002290/* yyresume: */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002291
Chris Lattnerf49c1762006-11-08 05:58:47 +00002292 /* First try to decide what to do without reference to lookahead token. */
Reid Spencer5b7e7532006-09-28 19:28:24 +00002293
Reid Spencer68a24bd2005-08-27 18:50:39 +00002294 yyn = yypact[yystate];
Chris Lattnerf49c1762006-11-08 05:58:47 +00002295 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002296 goto yydefault;
2297
Chris Lattnerf49c1762006-11-08 05:58:47 +00002298 /* Not known => get a lookahead token if don't already have one. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002299
Chris Lattnerf49c1762006-11-08 05:58:47 +00002300 /* yychar is either YYEMPTY or YYEOF
2301 or a valid token in external form. */
2302
Reid Spencer68a24bd2005-08-27 18:50:39 +00002303 if (yychar == YYEMPTY)
2304 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00002305#if YYDEBUG != 0
2306 if (yydebug)
2307 fprintf(stderr, "Reading a token: ");
2308#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002309 yychar = YYLEX;
2310 }
2311
Chris Lattnerf49c1762006-11-08 05:58:47 +00002312 /* Convert token to internal form (in yychar1) for indexing tables with */
2313
2314 if (yychar <= 0) /* This means end of input. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002315 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00002316 yychar1 = 0;
2317 yychar = YYEOF; /* Don't call YYLEX any more */
2318
2319#if YYDEBUG != 0
2320 if (yydebug)
2321 fprintf(stderr, "Now at end of input.\n");
2322#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002323 }
2324 else
2325 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00002326 yychar1 = YYTRANSLATE(yychar);
2327
2328#if YYDEBUG != 0
2329 if (yydebug)
2330 {
2331 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2332 /* Give the individual parser a way to print the precise meaning
2333 of a token, for further debugging info. */
2334#ifdef YYPRINT
2335 YYPRINT (stderr, yychar, yylval);
2336#endif
2337 fprintf (stderr, ")\n");
2338 }
2339#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00002340 }
2341
Chris Lattnerf49c1762006-11-08 05:58:47 +00002342 yyn += yychar1;
2343 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002344 goto yydefault;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002345
Reid Spencer68a24bd2005-08-27 18:50:39 +00002346 yyn = yytable[yyn];
Chris Lattnerf49c1762006-11-08 05:58:47 +00002347
2348 /* yyn is what to do for this token type in this state.
2349 Negative => reduce, -yyn is rule number.
2350 Positive => shift, yyn is new state.
2351 New state is final state => don't bother to shift,
2352 just return success.
2353 0, or most negative number => error. */
2354
2355 if (yyn < 0)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002356 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00002357 if (yyn == YYFLAG)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002358 goto yyerrlab;
2359 yyn = -yyn;
2360 goto yyreduce;
2361 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00002362 else if (yyn == 0)
2363 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002364
2365 if (yyn == YYFINAL)
2366 YYACCEPT;
2367
Chris Lattnerf49c1762006-11-08 05:58:47 +00002368 /* Shift the lookahead token. */
2369
2370#if YYDEBUG != 0
2371 if (yydebug)
2372 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2373#endif
Reid Spencer5b7e7532006-09-28 19:28:24 +00002374
2375 /* Discard the token being shifted unless it is eof. */
2376 if (yychar != YYEOF)
2377 yychar = YYEMPTY;
2378
2379 *++yyvsp = yylval;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002380#ifdef YYLSP_NEEDED
2381 *++yylsp = yylloc;
2382#endif
Reid Spencer5b7e7532006-09-28 19:28:24 +00002383
Chris Lattnerf49c1762006-11-08 05:58:47 +00002384 /* count tokens shifted since error; after three, turn off error status. */
2385 if (yyerrstatus) yyerrstatus--;
Chris Lattner224f84f2006-08-18 17:34:45 +00002386
Reid Spencer68a24bd2005-08-27 18:50:39 +00002387 yystate = yyn;
2388 goto yynewstate;
2389
Chris Lattnerf49c1762006-11-08 05:58:47 +00002390/* Do the default action for the current state. */
Reid Spencer21be8652006-10-22 07:03:43 +00002391yydefault:
Chris Lattnerf49c1762006-11-08 05:58:47 +00002392
Reid Spencer68a24bd2005-08-27 18:50:39 +00002393 yyn = yydefact[yystate];
2394 if (yyn == 0)
2395 goto yyerrlab;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002396
Chris Lattnerf49c1762006-11-08 05:58:47 +00002397/* Do a reduction. yyn is the number of a rule to reduce with. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002398yyreduce:
Reid Spencer68a24bd2005-08-27 18:50:39 +00002399 yylen = yyr2[yyn];
Chris Lattnerf49c1762006-11-08 05:58:47 +00002400 if (yylen > 0)
2401 yyval = yyvsp[1-yylen]; /* implement default value of the action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00002402
Chris Lattnerf49c1762006-11-08 05:58:47 +00002403#if YYDEBUG != 0
2404 if (yydebug)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002405 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00002406 int i;
2407
2408 fprintf (stderr, "Reducing via rule %d (line %d), ",
2409 yyn, yyrline[yyn]);
2410
2411 /* Print the symbols being reduced, and their result. */
2412 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2413 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2414 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2415 }
2416#endif
2417
2418
2419 switch (yyn) {
2420
2421case 2:
2422#line 1140 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2423{
2424 if (yyvsp[0].UIntVal > (uint32_t)INT32_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00002425 GEN_ERROR("Value too large for type!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002426 yyval.SIntVal = (int32_t)yyvsp[0].UIntVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002427 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002428;
2429 break;}
2430case 4:
2431#line 1149 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2432{
2433 if (yyvsp[0].UInt64Val > (uint64_t)INT64_MAX) // Outside of my range!
Reid Spencer61c83e02006-08-18 08:43:06 +00002434 GEN_ERROR("Value too large for type!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002435 yyval.SInt64Val = (int64_t)yyvsp[0].UInt64Val;
Reid Spencer61c83e02006-08-18 08:43:06 +00002436 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002437;
2438 break;}
2439case 37:
2440#line 1173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2441{
2442 yyval.StrVal = yyvsp[-1].StrVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002443 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002444 ;
2445 break;}
2446case 38:
2447#line 1177 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2448{
2449 yyval.StrVal = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00002450 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002451 ;
2452 break;}
2453case 39:
2454#line 1182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2455{ yyval.Linkage = GlobalValue::InternalLinkage; ;
2456 break;}
2457case 40:
2458#line 1183 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2459{ yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2460 break;}
2461case 41:
2462#line 1184 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2463{ yyval.Linkage = GlobalValue::WeakLinkage; ;
2464 break;}
2465case 42:
2466#line 1185 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2467{ yyval.Linkage = GlobalValue::AppendingLinkage; ;
2468 break;}
2469case 43:
2470#line 1186 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2471{ yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2472 break;}
2473case 44:
2474#line 1187 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2475{ yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2476 break;}
2477case 45:
2478#line 1188 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2479{ yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2480 break;}
2481case 46:
2482#line 1189 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2483{ yyval.Linkage = GlobalValue::ExternalLinkage; ;
2484 break;}
2485case 47:
2486#line 1191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2487{ yyval.UIntVal = CallingConv::C; ;
2488 break;}
2489case 48:
2490#line 1192 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2491{ yyval.UIntVal = CallingConv::C; ;
2492 break;}
2493case 49:
2494#line 1193 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2495{ yyval.UIntVal = CallingConv::CSRet; ;
2496 break;}
2497case 50:
2498#line 1194 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2499{ yyval.UIntVal = CallingConv::Fast; ;
2500 break;}
2501case 51:
2502#line 1195 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2503{ yyval.UIntVal = CallingConv::Cold; ;
2504 break;}
2505case 52:
2506#line 1196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2507{ yyval.UIntVal = CallingConv::X86_StdCall; ;
2508 break;}
2509case 53:
2510#line 1197 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2511{ yyval.UIntVal = CallingConv::X86_FastCall; ;
2512 break;}
2513case 54:
2514#line 1198 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2515{
2516 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
Reid Spencer61c83e02006-08-18 08:43:06 +00002517 GEN_ERROR("Calling conv too large!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002518 yyval.UIntVal = yyvsp[0].UInt64Val;
Reid Spencer61c83e02006-08-18 08:43:06 +00002519 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002520 ;
2521 break;}
2522case 55:
2523#line 1207 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2524{ yyval.UIntVal = 0; ;
2525 break;}
2526case 56:
2527#line 1208 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2528{
2529 yyval.UIntVal = yyvsp[0].UInt64Val;
2530 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencer1628cec2006-10-26 06:15:43 +00002531 GEN_ERROR("Alignment must be a power of two!");
2532 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002533;
2534 break;}
2535case 57:
2536#line 1214 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2537{ yyval.UIntVal = 0; ;
2538 break;}
2539case 58:
2540#line 1215 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2541{
2542 yyval.UIntVal = yyvsp[0].UInt64Val;
2543 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
Reid Spencer3ed469c2006-11-02 20:25:50 +00002544 GEN_ERROR("Alignment must be a power of two!");
2545 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002546;
2547 break;}
2548case 59:
2549#line 1223 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2550{
2551 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2552 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
Reid Spencer61c83e02006-08-18 08:43:06 +00002553 GEN_ERROR("Invalid character in section name!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002554 yyval.StrVal = yyvsp[0].StrVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002555 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002556;
2557 break;}
2558case 60:
2559#line 1231 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2560{ yyval.StrVal = 0; ;
2561 break;}
2562case 61:
2563#line 1232 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2564{ yyval.StrVal = yyvsp[0].StrVal; ;
2565 break;}
2566case 62:
2567#line 1237 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2568{;
2569 break;}
2570case 63:
2571#line 1238 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2572{;
2573 break;}
2574case 64:
2575#line 1239 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2576{
2577 CurGV->setSection(yyvsp[0].StrVal);
2578 free(yyvsp[0].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00002579 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002580 ;
2581 break;}
2582case 65:
2583#line 1244 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2584{
2585 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00002586 GEN_ERROR("Alignment must be a power of two!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002587 CurGV->setAlignment(yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00002588 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002589 ;
2590 break;}
2591case 67:
2592#line 1258 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2593{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2594 break;}
2595case 69:
2596#line 1259 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2597{ yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType); ;
2598 break;}
2599case 70:
2600#line 1261 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2601{
Reid Spencer68a24bd2005-08-27 18:50:39 +00002602 if (!UpRefs.empty())
Chris Lattnerf49c1762006-11-08 05:58:47 +00002603 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
2604 yyval.TypeVal = yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002605 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002606 ;
2607 break;}
2608case 84:
2609#line 1273 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2610{
2611 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
Reid Spencer61c83e02006-08-18 08:43:06 +00002612 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002613 ;
2614 break;}
2615case 85:
2616#line 1277 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2617{
2618 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
Reid Spencer61c83e02006-08-18 08:43:06 +00002619 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002620 ;
2621 break;}
2622case 86:
2623#line 1281 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2624{ // Named types are also simple types...
2625 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00002626 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002627 yyval.TypeVal = new PATypeHolder(tmp);
2628;
2629 break;}
2630case 87:
2631#line 1289 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2632{ // Type UpReference
2633 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002634 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
Chris Lattnerf49c1762006-11-08 05:58:47 +00002635 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2636 yyval.TypeVal = new PATypeHolder(OT);
Reid Spencer68a24bd2005-08-27 18:50:39 +00002637 UR_OUT("New Upreference!\n");
Reid Spencer61c83e02006-08-18 08:43:06 +00002638 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002639 ;
2640 break;}
2641case 88:
2642#line 1297 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2643{ // Function derived type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002644 std::vector<const Type*> Params;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002645 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2646 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002647 Params.push_back(*I);
2648 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2649 if (isVarArg) Params.pop_back();
2650
Chris Lattnerf49c1762006-11-08 05:58:47 +00002651 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FunctionType::get(*yyvsp[-3].TypeVal,Params,isVarArg)));
2652 delete yyvsp[-1].TypeList; // Delete the argument list
2653 delete yyvsp[-3].TypeVal; // Delete the return type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00002654 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002655 ;
2656 break;}
2657case 89:
2658#line 1310 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2659{ // Sized array type?
2660 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2661 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002662 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002663 ;
2664 break;}
2665case 90:
2666#line 1315 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2667{ // Packed array type?
2668 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2669 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
Reid Spencer61c83e02006-08-18 08:43:06 +00002670 GEN_ERROR("Unsigned result not equal to signed result");
Chris Lattner9547d7f2005-11-10 01:42:43 +00002671 if (!ElemTy->isPrimitiveType())
Reid Spencer61c83e02006-08-18 08:43:06 +00002672 GEN_ERROR("Elemental type of a PackedType must be primitive");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002673 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00002674 GEN_ERROR("Vector length should be a power of 2!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002675 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PackedType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2676 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002677 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002678 ;
2679 break;}
2680case 91:
2681#line 1327 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2682{ // Structure type?
Reid Spencer68a24bd2005-08-27 18:50:39 +00002683 std::vector<const Type*> Elements;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002684 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2685 E = yyvsp[-1].TypeList->end(); I != E; ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00002686 Elements.push_back(*I);
2687
Chris Lattnerf49c1762006-11-08 05:58:47 +00002688 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2689 delete yyvsp[-1].TypeList;
Reid Spencer61c83e02006-08-18 08:43:06 +00002690 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002691 ;
2692 break;}
2693case 92:
2694#line 1337 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2695{ // Empty structure type?
2696 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
Reid Spencer61c83e02006-08-18 08:43:06 +00002697 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002698 ;
2699 break;}
2700case 93:
2701#line 1341 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2702{ // Pointer type?
2703 if (*yyvsp[-1].TypeVal == Type::LabelTy)
Chris Lattner59c85e92006-10-15 23:27:25 +00002704 GEN_ERROR("Cannot form a pointer to a basic block");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002705 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2706 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002707 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002708 ;
2709 break;}
2710case 94:
2711#line 1352 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2712{
2713 yyval.TypeList = new std::list<PATypeHolder>();
2714 yyval.TypeList->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002715 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002716 ;
2717 break;}
2718case 95:
2719#line 1357 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2720{
2721 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal); delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002722 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002723 ;
2724 break;}
2725case 97:
2726#line 1364 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2727{
2728 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(Type::VoidTy);
Reid Spencer61c83e02006-08-18 08:43:06 +00002729 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002730 ;
2731 break;}
2732case 98:
2733#line 1368 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2734{
2735 (yyval.TypeList = new std::list<PATypeHolder>())->push_back(Type::VoidTy);
Reid Spencer61c83e02006-08-18 08:43:06 +00002736 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002737 ;
2738 break;}
2739case 99:
2740#line 1372 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2741{
2742 yyval.TypeList = new std::list<PATypeHolder>();
Reid Spencer61c83e02006-08-18 08:43:06 +00002743 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002744 ;
2745 break;}
2746case 100:
2747#line 1383 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2748{ // Nonempty unsized arr
2749 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00002750 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002751 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00002752 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002753 const Type *ETy = ATy->getElementType();
2754 int NumElements = ATy->getNumElements();
2755
2756 // Verify that we have the correct size...
Chris Lattnerf49c1762006-11-08 05:58:47 +00002757 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00002758 GEN_ERROR("Type mismatch: constant sized array initialized with " +
Chris Lattnerf49c1762006-11-08 05:58:47 +00002759 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00002760 itostr(NumElements) + "!");
2761
2762 // Verify all elements are correct type!
Chris Lattnerf49c1762006-11-08 05:58:47 +00002763 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2764 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00002765 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00002766 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattnerf49c1762006-11-08 05:58:47 +00002767 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002768 }
2769
Chris Lattnerf49c1762006-11-08 05:58:47 +00002770 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
2771 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer61c83e02006-08-18 08:43:06 +00002772 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002773 ;
2774 break;}
2775case 101:
2776#line 1409 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2777{
2778 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00002779 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002780 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00002781 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002782
2783 int NumElements = ATy->getNumElements();
2784 if (NumElements != -1 && NumElements != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002785 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
Reid Spencer68a24bd2005-08-27 18:50:39 +00002786 " arguments, but has size of " + itostr(NumElements) +"!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002787 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
2788 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002789 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002790 ;
2791 break;}
2792case 102:
2793#line 1423 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2794{
2795 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00002796 if (ATy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002797 GEN_ERROR("Cannot make array constant with type: '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00002798 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002799
2800 int NumElements = ATy->getNumElements();
2801 const Type *ETy = ATy->getElementType();
Chris Lattnerf49c1762006-11-08 05:58:47 +00002802 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
2803 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
Reid Spencer61c83e02006-08-18 08:43:06 +00002804 GEN_ERROR("Can't build string constant of size " +
Chris Lattnerf49c1762006-11-08 05:58:47 +00002805 itostr((int)(EndStr-yyvsp[0].StrVal)) +
Reid Spencer68a24bd2005-08-27 18:50:39 +00002806 " when array has size " + itostr(NumElements) + "!");
2807 std::vector<Constant*> Vals;
2808 if (ETy == Type::SByteTy) {
Chris Lattnerf49c1762006-11-08 05:58:47 +00002809 for (signed char *C = (signed char *)yyvsp[0].StrVal; C != (signed char *)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00002810 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002811 } else if (ETy == Type::UByteTy) {
Chris Lattnerf49c1762006-11-08 05:58:47 +00002812 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
Chris Lattner66316012006-01-24 04:14:29 +00002813 C != (unsigned char*)EndStr; ++C)
Reid Spencerb83eb642006-10-20 07:07:24 +00002814 Vals.push_back(ConstantInt::get(ETy, *C));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002815 } else {
Chris Lattnerf49c1762006-11-08 05:58:47 +00002816 free(yyvsp[0].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00002817 GEN_ERROR("Cannot build string arrays of non byte sized elements!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002818 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00002819 free(yyvsp[0].StrVal);
2820 yyval.ConstVal = ConstantArray::get(ATy, Vals);
2821 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002822 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002823 ;
2824 break;}
2825case 103:
2826#line 1453 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2827{ // Nonempty unsized arr
2828 const PackedType *PTy = dyn_cast<PackedType>(yyvsp[-3].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00002829 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002830 GEN_ERROR("Cannot make packed constant with type: '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00002831 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002832 const Type *ETy = PTy->getElementType();
2833 int NumElements = PTy->getNumElements();
2834
2835 // Verify that we have the correct size...
Chris Lattnerf49c1762006-11-08 05:58:47 +00002836 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
Reid Spencer61c83e02006-08-18 08:43:06 +00002837 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
Chris Lattnerf49c1762006-11-08 05:58:47 +00002838 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
Reid Spencer68a24bd2005-08-27 18:50:39 +00002839 itostr(NumElements) + "!");
2840
2841 // Verify all elements are correct type!
Chris Lattnerf49c1762006-11-08 05:58:47 +00002842 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
2843 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00002844 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00002845 ETy->getDescription() +"' as required!\nIt is of type '"+
Chris Lattnerf49c1762006-11-08 05:58:47 +00002846 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002847 }
2848
Chris Lattnerf49c1762006-11-08 05:58:47 +00002849 yyval.ConstVal = ConstantPacked::get(PTy, *yyvsp[-1].ConstVector);
2850 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer61c83e02006-08-18 08:43:06 +00002851 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002852 ;
2853 break;}
2854case 104:
2855#line 1479 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2856{
2857 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
Reid Spencer61c83e02006-08-18 08:43:06 +00002858 if (STy == 0)
2859 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00002860 (*yyvsp[-3].TypeVal)->getDescription() + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00002861
Chris Lattnerf49c1762006-11-08 05:58:47 +00002862 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
Reid Spencer61c83e02006-08-18 08:43:06 +00002863 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002864
2865 // Check to ensure that constants are compatible with the type initializer!
Chris Lattnerf49c1762006-11-08 05:58:47 +00002866 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
2867 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
Reid Spencer61c83e02006-08-18 08:43:06 +00002868 GEN_ERROR("Expected type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00002869 STy->getElementType(i)->getDescription() +
2870 "' for element #" + utostr(i) +
2871 " of structure initializer!");
2872
Chris Lattnerf49c1762006-11-08 05:58:47 +00002873 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
2874 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
Reid Spencer61c83e02006-08-18 08:43:06 +00002875 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002876 ;
2877 break;}
2878case 105:
2879#line 1500 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2880{
2881 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00002882 if (STy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002883 GEN_ERROR("Cannot make struct constant with type: '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00002884 (*yyvsp[-2].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002885
2886 if (STy->getNumContainedTypes() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002887 GEN_ERROR("Illegal number of initializers for structure type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002888
Chris Lattnerf49c1762006-11-08 05:58:47 +00002889 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
2890 delete yyvsp[-2].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002891 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002892 ;
2893 break;}
2894case 106:
2895#line 1513 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2896{
2897 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00002898 if (PTy == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002899 GEN_ERROR("Cannot make null pointer constant with type: '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00002900 (*yyvsp[-1].TypeVal)->getDescription() + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002901
Chris Lattnerf49c1762006-11-08 05:58:47 +00002902 yyval.ConstVal = ConstantPointerNull::get(PTy);
2903 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002904 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002905 ;
2906 break;}
2907case 107:
2908#line 1523 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2909{
2910 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
2911 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002912 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002913 ;
2914 break;}
2915case 108:
2916#line 1528 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2917{
2918 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00002919 if (Ty == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00002920 GEN_ERROR("Global const reference must be a pointer type!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00002921
2922 // ConstExprs can exist in the body of a function, thus creating
2923 // GlobalValues whenever they refer to a variable. Because we are in
2924 // the context of a function, getValNonImprovising will search the functions
2925 // symbol table instead of the module symbol table for the global symbol,
2926 // which throws things all off. To get around this, we just tell
2927 // getValNonImprovising that we are at global scope here.
2928 //
2929 Function *SavedCurFn = CurFun.CurrentFunction;
2930 CurFun.CurrentFunction = 0;
2931
Chris Lattnerf49c1762006-11-08 05:58:47 +00002932 Value *V = getValNonImprovising(Ty, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00002933 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00002934
2935 CurFun.CurrentFunction = SavedCurFn;
2936
2937 // If this is an initializer for a constant pointer, which is referencing a
2938 // (currently) undefined variable, create a stub now that shall be replaced
2939 // in the future with the right type of variable.
2940 //
2941 if (V == 0) {
2942 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
2943 const PointerType *PT = cast<PointerType>(Ty);
2944
2945 // First check to see if the forward references value is already created!
2946 PerModuleInfo::GlobalRefsType::iterator I =
Chris Lattnerf49c1762006-11-08 05:58:47 +00002947 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002948
2949 if (I != CurModule.GlobalRefs.end()) {
2950 V = I->second; // Placeholder already exists, use it...
Chris Lattnerf49c1762006-11-08 05:58:47 +00002951 yyvsp[0].ValIDVal.destroy();
Reid Spencer68a24bd2005-08-27 18:50:39 +00002952 } else {
2953 std::string Name;
Chris Lattnerf49c1762006-11-08 05:58:47 +00002954 if (yyvsp[0].ValIDVal.Type == ValID::NameVal) Name = yyvsp[0].ValIDVal.Name;
Reid Spencer68a24bd2005-08-27 18:50:39 +00002955
2956 // Create the forward referenced global.
2957 GlobalValue *GV;
2958 if (const FunctionType *FTy =
2959 dyn_cast<FunctionType>(PT->getElementType())) {
2960 GV = new Function(FTy, GlobalValue::ExternalLinkage, Name,
2961 CurModule.CurrentModule);
2962 } else {
2963 GV = new GlobalVariable(PT->getElementType(), false,
2964 GlobalValue::ExternalLinkage, 0,
2965 Name, CurModule.CurrentModule);
2966 }
2967
2968 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattnerf49c1762006-11-08 05:58:47 +00002969 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
Reid Spencer68a24bd2005-08-27 18:50:39 +00002970 V = GV;
2971 }
2972 }
2973
Chris Lattnerf49c1762006-11-08 05:58:47 +00002974 yyval.ConstVal = cast<GlobalValue>(V);
2975 delete yyvsp[-1].TypeVal; // Free the type handle
Reid Spencer61c83e02006-08-18 08:43:06 +00002976 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002977 ;
2978 break;}
2979case 109:
2980#line 1589 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2981{
2982 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00002983 GEN_ERROR("Mismatched types for constant expression!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002984 yyval.ConstVal = yyvsp[0].ConstVal;
2985 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002986 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002987 ;
2988 break;}
2989case 110:
2990#line 1596 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2991{
2992 const Type *Ty = yyvsp[-1].TypeVal->get();
Reid Spencer68a24bd2005-08-27 18:50:39 +00002993 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
Reid Spencer61c83e02006-08-18 08:43:06 +00002994 GEN_ERROR("Cannot create a null initialized value of this type!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00002995 yyval.ConstVal = Constant::getNullValue(Ty);
2996 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00002997 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00002998 ;
2999 break;}
3000case 111:
3001#line 1605 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3002{ // integral constants
3003 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003004 GEN_ERROR("Constant value doesn't fit in type!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003005 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003006 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003007 ;
3008 break;}
3009case 112:
3010#line 1611 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3011{ // integral constants
3012 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
Reid Spencer61c83e02006-08-18 08:43:06 +00003013 GEN_ERROR("Constant value doesn't fit in type!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003014 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003015 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003016 ;
3017 break;}
3018case 113:
3019#line 1617 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3020{ // Boolean constants
3021 yyval.ConstVal = ConstantBool::getTrue();
Reid Spencer61c83e02006-08-18 08:43:06 +00003022 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003023 ;
3024 break;}
3025case 114:
3026#line 1621 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3027{ // Boolean constants
3028 yyval.ConstVal = ConstantBool::getFalse();
Reid Spencer61c83e02006-08-18 08:43:06 +00003029 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003030 ;
3031 break;}
3032case 115:
3033#line 1625 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3034{ // Float & Double constants
3035 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
Reid Spencer61c83e02006-08-18 08:43:06 +00003036 GEN_ERROR("Floating point constant invalid for type!!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003037 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003038 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003039 ;
3040 break;}
3041case 116:
3042#line 1633 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3043{
3044 if (!yyvsp[-3].ConstVal->getType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003045 GEN_ERROR("cast constant expression from a non-primitive type: '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00003046 yyvsp[-3].ConstVal->getType()->getDescription() + "'!");
3047 if (!yyvsp[-1].TypeVal->get()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003048 GEN_ERROR("cast constant expression to a non-primitive type: '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00003049 yyvsp[-1].TypeVal->get()->getDescription() + "'!");
3050 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-3].ConstVal, yyvsp[-1].TypeVal->get());
3051 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003052 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003053 ;
3054 break;}
3055case 117:
3056#line 1644 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3057{
3058 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00003059 GEN_ERROR("GetElementPtr requires a pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003060
3061 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
3062 // indices to uint struct indices for compatibility.
3063 generic_gep_type_iterator<std::vector<Value*>::iterator>
Chris Lattnerf49c1762006-11-08 05:58:47 +00003064 GTI = gep_type_begin(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end()),
3065 GTE = gep_type_end(yyvsp[-2].ConstVal->getType(), yyvsp[-1].ValueList->begin(), yyvsp[-1].ValueList->end());
3066 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003067 if (isa<StructType>(*GTI)) // Only change struct indices
Chris Lattnerf49c1762006-11-08 05:58:47 +00003068 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*yyvsp[-1].ValueList)[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003069 if (CUI->getType() == Type::UByteTy)
Chris Lattnerf49c1762006-11-08 05:58:47 +00003070 (*yyvsp[-1].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003071
3072 const Type *IdxTy =
Chris Lattnerf49c1762006-11-08 05:58:47 +00003073 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), *yyvsp[-1].ValueList, true);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003074 if (!IdxTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003075 GEN_ERROR("Index list invalid for constant getelementptr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003076
3077 std::vector<Constant*> IdxVec;
Chris Lattnerf49c1762006-11-08 05:58:47 +00003078 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3079 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00003080 IdxVec.push_back(C);
3081 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003082 GEN_ERROR("Indices to constant getelementptr must be constants!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003083
Chris Lattnerf49c1762006-11-08 05:58:47 +00003084 delete yyvsp[-1].ValueList;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003085
Chris Lattnerf49c1762006-11-08 05:58:47 +00003086 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, IdxVec);
Reid Spencer61c83e02006-08-18 08:43:06 +00003087 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003088 ;
3089 break;}
3090case 118:
3091#line 1676 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3092{
3093 if (yyvsp[-5].ConstVal->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003094 GEN_ERROR("Select condition must be of boolean type!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003095 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003096 GEN_ERROR("Select operand types must match!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003097 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003098 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003099 ;
3100 break;}
3101case 119:
3102#line 1684 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3103{
3104 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003105 GEN_ERROR("Binary operator types must match!");
Reid Spencer1628cec2006-10-26 06:15:43 +00003106 // First, make sure we're dealing with the right opcode by upgrading from
3107 // obsolete versions.
Chris Lattnerf49c1762006-11-08 05:58:47 +00003108 sanitizeOpCode(yyvsp[-5].BinaryOpVal,yyvsp[-3].ConstVal->getType());
Reid Spencer1628cec2006-10-26 06:15:43 +00003109 CHECK_FOR_ERROR;
3110
Reid Spencer68a24bd2005-08-27 18:50:39 +00003111 // HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs.
3112 // To retain backward compatibility with these early compilers, we emit a
3113 // cast to the appropriate integer type automatically if we are in the
3114 // broken case. See PR424 for more information.
Chris Lattnerf49c1762006-11-08 05:58:47 +00003115 if (!isa<PointerType>(yyvsp[-3].ConstVal->getType())) {
3116 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal.opcode, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003117 } else {
3118 const Type *IntPtrTy = 0;
3119 switch (CurModule.CurrentModule->getPointerSize()) {
3120 case Module::Pointer32: IntPtrTy = Type::IntTy; break;
3121 case Module::Pointer64: IntPtrTy = Type::LongTy; break;
Reid Spencer61c83e02006-08-18 08:43:06 +00003122 default: GEN_ERROR("invalid pointer binary constant expr!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003123 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00003124 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal.opcode, ConstantExpr::getCast(yyvsp[-3].ConstVal, IntPtrTy),
3125 ConstantExpr::getCast(yyvsp[-1].ConstVal, IntPtrTy));
3126 yyval.ConstVal = ConstantExpr::getCast(yyval.ConstVal, yyvsp[-3].ConstVal->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003127 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003128 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003129 ;
3130 break;}
3131case 120:
3132#line 1711 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3133{
3134 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003135 GEN_ERROR("Logical operator types must match!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003136 if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
3137 if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
3138 !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00003139 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00003140 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00003141 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal.opcode, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003142 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003143 ;
3144 break;}
3145case 121:
3146#line 1722 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3147{
3148 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
Reid Spencer1628cec2006-10-26 06:15:43 +00003149 GEN_ERROR("setcc operand types must match!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003150 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal.opcode, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer1628cec2006-10-26 06:15:43 +00003151 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003152 ;
3153 break;}
3154case 122:
3155#line 1728 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3156{
3157 if (yyvsp[-1].ConstVal->getType() != Type::UByteTy)
Reid Spencer1628cec2006-10-26 06:15:43 +00003158 GEN_ERROR("Shift count for shift constant must be unsigned byte!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003159 if (!yyvsp[-3].ConstVal->getType()->isInteger())
Reid Spencer1628cec2006-10-26 06:15:43 +00003160 GEN_ERROR("Shift constant expression requires integer operand!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003161 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal.opcode, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer1628cec2006-10-26 06:15:43 +00003162 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003163 ;
3164 break;}
3165case 123:
3166#line 1736 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3167{
3168 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer61c83e02006-08-18 08:43:06 +00003169 GEN_ERROR("Invalid extractelement operands!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003170 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003171 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003172 ;
3173 break;}
3174case 124:
3175#line 1742 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3176{
3177 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer61c83e02006-08-18 08:43:06 +00003178 GEN_ERROR("Invalid insertelement operands!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003179 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003180 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003181 ;
3182 break;}
3183case 125:
3184#line 1748 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3185{
3186 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
Reid Spencer61c83e02006-08-18 08:43:06 +00003187 GEN_ERROR("Invalid shufflevector operands!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003188 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003189 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003190 ;
3191 break;}
3192case 126:
3193#line 1757 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3194{
3195 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003196 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003197 ;
3198 break;}
3199case 127:
3200#line 1761 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3201{
3202 yyval.ConstVector = new std::vector<Constant*>();
3203 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003204 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003205 ;
3206 break;}
3207case 128:
3208#line 1769 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3209{ yyval.BoolVal = false; ;
3210 break;}
3211case 129:
3212#line 1769 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3213{ yyval.BoolVal = true; ;
3214 break;}
3215case 130:
3216#line 1779 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3217{
3218 yyval.ModuleVal = ParserResult = yyvsp[0].ModuleVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003219 CurModule.ModuleDone();
Reid Spencerf63697d2006-10-09 17:36:59 +00003220 CHECK_FOR_ERROR;
Chris Lattnerf49c1762006-11-08 05:58:47 +00003221;
3222 break;}
3223case 131:
3224#line 1787 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3225{
3226 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003227 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003228 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003229 ;
3230 break;}
3231case 132:
3232#line 1792 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3233{
3234 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Reid Spencer1628cec2006-10-26 06:15:43 +00003235 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003236 ;
3237 break;}
3238case 133:
3239#line 1796 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3240{
3241 yyval.ModuleVal = yyvsp[-3].ModuleVal;
Reid Spencer3ed469c2006-11-02 20:25:50 +00003242 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003243 ;
3244 break;}
3245case 134:
3246#line 1800 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3247{
3248 yyval.ModuleVal = yyvsp[-1].ModuleVal;
Reid Spencer3ed469c2006-11-02 20:25:50 +00003249 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003250 ;
3251 break;}
3252case 135:
3253#line 1804 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3254{
3255 yyval.ModuleVal = CurModule.CurrentModule;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003256 // Emit an error if there are any unresolved types left.
3257 if (!CurModule.LateResolveTypes.empty()) {
3258 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
Reid Spencer61c83e02006-08-18 08:43:06 +00003259 if (DID.Type == ValID::NameVal) {
3260 GEN_ERROR("Reference to an undefined type: '"+DID.getName() + "'");
3261 } else {
3262 GEN_ERROR("Reference to an undefined type: #" + itostr(DID.Num));
3263 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003264 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003265 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003266 ;
3267 break;}
3268case 136:
3269#line 1819 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3270{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003271 // Eagerly resolve types. This is not an optimization, this is a
3272 // requirement that is due to the fact that we could have this:
3273 //
3274 // %list = type { %list * }
3275 // %list = type { %list * } ; repeated type decl
3276 //
3277 // If types are not resolved eagerly, then the two types will not be
3278 // determined to be the same type!
3279 //
Chris Lattnerf49c1762006-11-08 05:58:47 +00003280 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003281
Chris Lattnerf49c1762006-11-08 05:58:47 +00003282 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
Reid Spencer5b7e7532006-09-28 19:28:24 +00003283 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003284 // If this is a named type that is not a redefinition, add it to the slot
3285 // table.
Chris Lattnerf49c1762006-11-08 05:58:47 +00003286 CurModule.Types.push_back(*yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003287 }
3288
Chris Lattnerf49c1762006-11-08 05:58:47 +00003289 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003290 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003291 ;
3292 break;}
3293case 137:
3294#line 1841 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3295{ // Function prototypes can be in const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00003296 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003297 ;
3298 break;}
3299case 138:
3300#line 1844 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3301{ // Asm blocks can be in the const pool
Reid Spencer61c83e02006-08-18 08:43:06 +00003302 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003303 ;
3304 break;}
3305case 139:
3306#line 1847 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3307{
3308 if (yyvsp[0].ConstVal == 0)
Reid Spencer5b7e7532006-09-28 19:28:24 +00003309 GEN_ERROR("Global value initializer is not a constant!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003310 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, yyvsp[-2].Linkage, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003311 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003312 ;
3313 break;}
3314case 140:
3315#line 1852 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3316{
Reid Spencer5b7e7532006-09-28 19:28:24 +00003317 CurGV = 0;
Chris Lattnerf49c1762006-11-08 05:58:47 +00003318 ;
3319 break;}
3320case 141:
3321#line 1855 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3322{
3323 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003324 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003325 delete yyvsp[0].TypeVal;
3326 ;
3327 break;}
3328case 142:
3329#line 1859 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3330{
Reid Spencer1628cec2006-10-26 06:15:43 +00003331 CurGV = 0;
3332 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003333 ;
3334 break;}
3335case 143:
3336#line 1863 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3337{
3338 CurGV = ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::DLLImportLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
Reid Spencer3ed469c2006-11-02 20:25:50 +00003339 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003340 delete yyvsp[0].TypeVal;
3341 ;
3342 break;}
3343case 144:
3344#line 1867 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3345{
Reid Spencer3ed469c2006-11-02 20:25:50 +00003346 CurGV = 0;
3347 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003348 ;
3349 break;}
3350case 145:
3351#line 1871 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3352{
Reid Spencer5b7e7532006-09-28 19:28:24 +00003353 CurGV =
Chris Lattnerf49c1762006-11-08 05:58:47 +00003354 ParseGlobalVariable(yyvsp[-3].StrVal, GlobalValue::ExternalWeakLinkage, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003355 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003356 delete yyvsp[0].TypeVal;
3357 ;
3358 break;}
3359case 146:
3360#line 1876 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3361{
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00003362 CurGV = 0;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00003363 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003364 ;
3365 break;}
3366case 147:
3367#line 1880 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3368{
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00003369 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003370 ;
3371 break;}
3372case 148:
3373#line 1883 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3374{
Anton Korobeynikovbcb97702006-09-17 20:25:45 +00003375 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003376 ;
3377 break;}
3378case 149:
3379#line 1886 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3380{
3381 ;
3382 break;}
3383case 150:
3384#line 1890 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3385{
Chris Lattner66316012006-01-24 04:14:29 +00003386 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
Chris Lattnerf49c1762006-11-08 05:58:47 +00003387 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3388 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3389 free(yyvsp[0].StrVal);
Chris Lattner66316012006-01-24 04:14:29 +00003390
3391 if (AsmSoFar.empty())
3392 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3393 else
3394 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
Reid Spencer61c83e02006-08-18 08:43:06 +00003395 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003396;
3397 break;}
3398case 151:
3399#line 1903 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3400{ yyval.Endianness = Module::BigEndian; ;
3401 break;}
3402case 152:
3403#line 1904 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3404{ yyval.Endianness = Module::LittleEndian; ;
3405 break;}
3406case 153:
3407#line 1906 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3408{
3409 CurModule.CurrentModule->setEndianness(yyvsp[0].Endianness);
Reid Spencer61c83e02006-08-18 08:43:06 +00003410 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003411 ;
3412 break;}
3413case 154:
3414#line 1910 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3415{
3416 if (yyvsp[0].UInt64Val == 32)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003417 CurModule.CurrentModule->setPointerSize(Module::Pointer32);
Chris Lattnerf49c1762006-11-08 05:58:47 +00003418 else if (yyvsp[0].UInt64Val == 64)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003419 CurModule.CurrentModule->setPointerSize(Module::Pointer64);
3420 else
Chris Lattnerf49c1762006-11-08 05:58:47 +00003421 GEN_ERROR("Invalid pointer size: '" + utostr(yyvsp[0].UInt64Val) + "'!");
Reid Spencer61c83e02006-08-18 08:43:06 +00003422 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003423 ;
3424 break;}
3425case 155:
3426#line 1919 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3427{
3428 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3429 free(yyvsp[0].StrVal);
3430 ;
3431 break;}
3432case 156:
3433#line 1923 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3434{
3435 CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal);
3436 free(yyvsp[0].StrVal);
3437 ;
3438 break;}
3439case 158:
3440#line 1930 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3441{
3442 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3443 free(yyvsp[0].StrVal);
Reid Spencer3ed469c2006-11-02 20:25:50 +00003444 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003445 ;
3446 break;}
3447case 159:
3448#line 1935 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3449{
3450 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3451 free(yyvsp[0].StrVal);
Reid Spencer3ed469c2006-11-02 20:25:50 +00003452 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003453 ;
3454 break;}
3455case 160:
3456#line 1940 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3457{
Reid Spencer61c83e02006-08-18 08:43:06 +00003458 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003459 ;
3460 break;}
3461case 164:
3462#line 1950 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3463{ yyval.StrVal = 0; ;
3464 break;}
3465case 165:
3466#line 1952 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3467{
3468 if (*yyvsp[-1].TypeVal == Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003469 GEN_ERROR("void typed arguments are invalid!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003470 yyval.ArgVal = new std::pair<PATypeHolder*, char*>(yyvsp[-1].TypeVal, yyvsp[0].StrVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003471 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003472;
3473 break;}
3474case 166:
3475#line 1959 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3476{
3477 yyval.ArgList = yyvsp[-2].ArgList;
3478 yyvsp[-2].ArgList->push_back(*yyvsp[0].ArgVal);
3479 delete yyvsp[0].ArgVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003480 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003481 ;
3482 break;}
3483case 167:
3484#line 1965 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3485{
3486 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3487 yyval.ArgList->push_back(*yyvsp[0].ArgVal);
3488 delete yyvsp[0].ArgVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003489 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003490 ;
3491 break;}
3492case 168:
3493#line 1972 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3494{
3495 yyval.ArgList = yyvsp[0].ArgList;
Reid Spencer61c83e02006-08-18 08:43:06 +00003496 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003497 ;
3498 break;}
3499case 169:
3500#line 1976 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3501{
3502 yyval.ArgList = yyvsp[-2].ArgList;
3503 yyval.ArgList->push_back(std::pair<PATypeHolder*,
Reid Spencer68a24bd2005-08-27 18:50:39 +00003504 char*>(new PATypeHolder(Type::VoidTy), 0));
Reid Spencer61c83e02006-08-18 08:43:06 +00003505 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003506 ;
3507 break;}
3508case 170:
3509#line 1982 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3510{
3511 yyval.ArgList = new std::vector<std::pair<PATypeHolder*,char*> >();
3512 yyval.ArgList->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0));
Reid Spencer61c83e02006-08-18 08:43:06 +00003513 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003514 ;
3515 break;}
3516case 171:
3517#line 1987 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3518{
3519 yyval.ArgList = 0;
Reid Spencer61c83e02006-08-18 08:43:06 +00003520 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003521 ;
3522 break;}
3523case 172:
3524#line 1993 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3525{
3526 UnEscapeLexed(yyvsp[-5].StrVal);
3527 std::string FunctionName(yyvsp[-5].StrVal);
3528 free(yyvsp[-5].StrVal); // Free strdup'd memory!
Reid Spencer68a24bd2005-08-27 18:50:39 +00003529
Chris Lattnerf49c1762006-11-08 05:58:47 +00003530 if (!(*yyvsp[-6].TypeVal)->isFirstClassType() && *yyvsp[-6].TypeVal != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00003531 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003532
3533 std::vector<const Type*> ParamTypeList;
Chris Lattnerf49c1762006-11-08 05:58:47 +00003534 if (yyvsp[-3].ArgList) { // If there are arguments...
3535 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3536 I != yyvsp[-3].ArgList->end(); ++I)
Reid Spencer68a24bd2005-08-27 18:50:39 +00003537 ParamTypeList.push_back(I->first->get());
3538 }
3539
3540 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3541 if (isVarArg) ParamTypeList.pop_back();
3542
Chris Lattnerf49c1762006-11-08 05:58:47 +00003543 const FunctionType *FT = FunctionType::get(*yyvsp[-6].TypeVal, ParamTypeList, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003544 const PointerType *PFT = PointerType::get(FT);
Chris Lattnerf49c1762006-11-08 05:58:47 +00003545 delete yyvsp[-6].TypeVal;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003546
3547 ValID ID;
3548 if (!FunctionName.empty()) {
3549 ID = ValID::create((char*)FunctionName.c_str());
3550 } else {
3551 ID = ValID::create((int)CurModule.Values[PFT].size());
3552 }
3553
3554 Function *Fn = 0;
3555 // See if this function was forward referenced. If so, recycle the object.
3556 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
3557 // Move the function to the end of the list, from whereever it was
3558 // previously inserted.
3559 Fn = cast<Function>(FWRef);
3560 CurModule.CurrentModule->getFunctionList().remove(Fn);
3561 CurModule.CurrentModule->getFunctionList().push_back(Fn);
3562 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
3563 (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
3564 // If this is the case, either we need to be a forward decl, or it needs
3565 // to be.
3566 if (!CurFun.isDeclare && !Fn->isExternal())
Reid Spencer61c83e02006-08-18 08:43:06 +00003567 GEN_ERROR("Redefinition of function '" + FunctionName + "'!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003568
3569 // Make sure to strip off any argument names so we can't get conflicts.
3570 if (Fn->isExternal())
3571 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
3572 AI != AE; ++AI)
3573 AI->setName("");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003574 } else { // Not already defined?
3575 Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
3576 CurModule.CurrentModule);
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00003577
Reid Spencer68a24bd2005-08-27 18:50:39 +00003578 InsertValue(Fn, CurModule.Values);
3579 }
3580
3581 CurFun.FunctionStart(Fn);
Anton Korobeynikov93c2b372006-09-17 13:06:18 +00003582
3583 if (CurFun.isDeclare) {
3584 // If we have declaration, always overwrite linkage. This will allow us to
3585 // correctly handle cases, when pointer to function is passed as argument to
3586 // another function.
3587 Fn->setLinkage(CurFun.Linkage);
3588 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00003589 Fn->setCallingConv(yyvsp[-7].UIntVal);
3590 Fn->setAlignment(yyvsp[0].UIntVal);
3591 if (yyvsp[-1].StrVal) {
3592 Fn->setSection(yyvsp[-1].StrVal);
3593 free(yyvsp[-1].StrVal);
Chris Lattnere869eef2005-11-12 00:11:49 +00003594 }
Reid Spencer68a24bd2005-08-27 18:50:39 +00003595
3596 // Add all of the arguments we parsed to the function...
Chris Lattnerf49c1762006-11-08 05:58:47 +00003597 if (yyvsp[-3].ArgList) { // Is null if empty...
Reid Spencer68a24bd2005-08-27 18:50:39 +00003598 if (isVarArg) { // Nuke the last entry
Chris Lattnerf49c1762006-11-08 05:58:47 +00003599 assert(yyvsp[-3].ArgList->back().first->get() == Type::VoidTy && yyvsp[-3].ArgList->back().second == 0&&
Reid Spencer68a24bd2005-08-27 18:50:39 +00003600 "Not a varargs marker!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00003601 delete yyvsp[-3].ArgList->back().first;
3602 yyvsp[-3].ArgList->pop_back(); // Delete the last entry
Reid Spencer68a24bd2005-08-27 18:50:39 +00003603 }
3604 Function::arg_iterator ArgIt = Fn->arg_begin();
Chris Lattnerf49c1762006-11-08 05:58:47 +00003605 for (std::vector<std::pair<PATypeHolder*,char*> >::iterator I = yyvsp[-3].ArgList->begin();
3606 I != yyvsp[-3].ArgList->end(); ++I, ++ArgIt) {
Reid Spencer68a24bd2005-08-27 18:50:39 +00003607 delete I->first; // Delete the typeholder...
3608
3609 setValueName(ArgIt, I->second); // Insert arg into symtab...
Reid Spencer5b7e7532006-09-28 19:28:24 +00003610 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003611 InsertValue(ArgIt);
3612 }
3613
Chris Lattnerf49c1762006-11-08 05:58:47 +00003614 delete yyvsp[-3].ArgList; // We're now done with the argument list
Reid Spencer68a24bd2005-08-27 18:50:39 +00003615 }
Reid Spencer61c83e02006-08-18 08:43:06 +00003616 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003617;
3618 break;}
3619case 175:
3620#line 2089 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3621{
3622 yyval.FunctionVal = CurFun.CurrentFunction;
Reid Spencer68a24bd2005-08-27 18:50:39 +00003623
3624 // Make sure that we keep track of the linkage type even if there was a
3625 // previous "declare".
Chris Lattnerf49c1762006-11-08 05:58:47 +00003626 yyval.FunctionVal->setLinkage(yyvsp[-2].Linkage);
3627;
3628 break;}
3629case 178:
3630#line 2099 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3631{
3632 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00003633 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003634;
3635 break;}
3636case 180:
3637#line 2105 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3638{ CurFun.Linkage = GlobalValue::DLLImportLinkage; ;
3639 break;}
3640case 181:
3641#line 2106 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3642{ CurFun.Linkage = GlobalValue::DLLImportLinkage; ;
3643 break;}
3644case 182:
3645#line 2108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3646{ CurFun.isDeclare = true; ;
3647 break;}
3648case 183:
3649#line 2108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3650{
3651 yyval.FunctionVal = CurFun.CurrentFunction;
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00003652 CurFun.FunctionDone();
Reid Spencer61c83e02006-08-18 08:43:06 +00003653 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003654 ;
3655 break;}
3656case 184:
3657#line 2118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3658{
3659 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00003660 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003661 ;
3662 break;}
3663case 185:
3664#line 2122 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3665{
3666 yyval.BoolVal = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00003667 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003668 ;
3669 break;}
3670case 186:
3671#line 2127 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3672{ // A reference to a direct constant
3673 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003674 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003675 ;
3676 break;}
3677case 187:
3678#line 2131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3679{
3680 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
Reid Spencer61c83e02006-08-18 08:43:06 +00003681 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003682 ;
3683 break;}
3684case 188:
3685#line 2135 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3686{ // Perhaps it's an FP constant?
3687 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003688 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003689 ;
3690 break;}
3691case 189:
3692#line 2139 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3693{
3694 yyval.ValIDVal = ValID::create(ConstantBool::getTrue());
Reid Spencer61c83e02006-08-18 08:43:06 +00003695 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003696 ;
3697 break;}
3698case 190:
3699#line 2143 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3700{
3701 yyval.ValIDVal = ValID::create(ConstantBool::getFalse());
Reid Spencer61c83e02006-08-18 08:43:06 +00003702 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003703 ;
3704 break;}
3705case 191:
3706#line 2147 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3707{
3708 yyval.ValIDVal = ValID::createNull();
Reid Spencer61c83e02006-08-18 08:43:06 +00003709 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003710 ;
3711 break;}
3712case 192:
3713#line 2151 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3714{
3715 yyval.ValIDVal = ValID::createUndef();
Reid Spencer61c83e02006-08-18 08:43:06 +00003716 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003717 ;
3718 break;}
3719case 193:
3720#line 2155 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3721{ // A vector zero constant.
3722 yyval.ValIDVal = ValID::createZeroInit();
Anton Korobeynikov43e3aad2006-09-14 18:25:26 +00003723 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003724 ;
3725 break;}
3726case 194:
3727#line 2159 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3728{ // Nonempty unsized packed vector
3729 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
3730 int NumElements = yyvsp[-1].ConstVector->size();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003731
3732 PackedType* pt = PackedType::get(ETy, NumElements);
3733 PATypeHolder* PTy = new PATypeHolder(
3734 HandleUpRefs(
3735 PackedType::get(
3736 ETy,
3737 NumElements)
3738 )
3739 );
3740
3741 // Verify all elements are correct type!
Chris Lattnerf49c1762006-11-08 05:58:47 +00003742 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3743 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00003744 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003745 ETy->getDescription() +"' as required!\nIt is of type '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00003746 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003747 }
3748
Chris Lattnerf49c1762006-11-08 05:58:47 +00003749 yyval.ValIDVal = ValID::create(ConstantPacked::get(pt, *yyvsp[-1].ConstVector));
3750 delete PTy; delete yyvsp[-1].ConstVector;
Reid Spencer61c83e02006-08-18 08:43:06 +00003751 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003752 ;
3753 break;}
3754case 195:
3755#line 2184 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3756{
3757 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
Reid Spencerb83eb642006-10-20 07:07:24 +00003758 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003759 ;
3760 break;}
3761case 196:
3762#line 2188 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3763{
3764 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
3765 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
3766 End = UnEscapeLexed(yyvsp[0].StrVal, true);
3767 std::string Constraints = std::string(yyvsp[0].StrVal, End);
3768 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
3769 free(yyvsp[-2].StrVal);
3770 free(yyvsp[0].StrVal);
Reid Spencerb83eb642006-10-20 07:07:24 +00003771 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003772 ;
3773 break;}
3774case 197:
3775#line 2202 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3776{ // Is it an integer reference...?
3777 yyval.ValIDVal = ValID::create(yyvsp[0].SIntVal);
Reid Spencer21be8652006-10-22 07:03:43 +00003778 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003779 ;
3780 break;}
3781case 198:
3782#line 2206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3783{ // Is it a named reference...?
3784 yyval.ValIDVal = ValID::create(yyvsp[0].StrVal);
Reid Spencer21be8652006-10-22 07:03:43 +00003785 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003786 ;
3787 break;}
3788case 201:
3789#line 2218 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3790{
3791 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal); delete yyvsp[-1].TypeVal;
Reid Spencer21be8652006-10-22 07:03:43 +00003792 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003793 ;
3794 break;}
3795case 202:
3796#line 2223 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3797{
3798 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Reid Spencer21be8652006-10-22 07:03:43 +00003799 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003800 ;
3801 break;}
3802case 203:
3803#line 2227 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3804{ // Do not allow functions with 0 basic blocks
3805 yyval.FunctionVal = yyvsp[-1].FunctionVal;
Reid Spencer21be8652006-10-22 07:03:43 +00003806 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003807 ;
3808 break;}
3809case 204:
3810#line 2236 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3811{
3812 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
Reid Spencer21be8652006-10-22 07:03:43 +00003813 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003814 InsertValue(yyvsp[0].TermInstVal);
Reid Spencer21be8652006-10-22 07:03:43 +00003815
Chris Lattnerf49c1762006-11-08 05:58:47 +00003816 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
3817 InsertValue(yyvsp[-2].BasicBlockVal);
3818 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
Reid Spencer21be8652006-10-22 07:03:43 +00003819 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003820 ;
3821 break;}
3822case 205:
3823#line 2247 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3824{
3825 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
3826 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
Reid Spencer21be8652006-10-22 07:03:43 +00003827 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003828 ;
3829 break;}
3830case 206:
3831#line 2252 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3832{
3833 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003834 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003835
3836 // Make sure to move the basic block to the correct location in the
3837 // function, instead of leaving it inserted wherever it was first
3838 // referenced.
3839 Function::BasicBlockListType &BBL =
3840 CurFun.CurrentFunction->getBasicBlockList();
Chris Lattnerf49c1762006-11-08 05:58:47 +00003841 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003842 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003843 ;
3844 break;}
3845case 207:
3846#line 2264 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3847{
3848 yyval.BasicBlockVal = CurBB = getBBVal(ValID::create(yyvsp[0].StrVal), true);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003849 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003850
3851 // Make sure to move the basic block to the correct location in the
3852 // function, instead of leaving it inserted wherever it was first
3853 // referenced.
3854 Function::BasicBlockListType &BBL =
3855 CurFun.CurrentFunction->getBasicBlockList();
Chris Lattnerf49c1762006-11-08 05:58:47 +00003856 BBL.splice(BBL.end(), BBL, yyval.BasicBlockVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00003857 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003858 ;
3859 break;}
3860case 208:
3861#line 2277 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3862{ // Return with a result...
3863 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
3864 CHECK_FOR_ERROR
3865 ;
3866 break;}
3867case 209:
3868#line 2281 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3869{ // Return with no result...
3870 yyval.TermInstVal = new ReturnInst();
3871 CHECK_FOR_ERROR
3872 ;
3873 break;}
3874case 210:
3875#line 2285 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3876{ // Unconditional Branch...
3877 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
3878 CHECK_FOR_ERROR
3879 yyval.TermInstVal = new BranchInst(tmpBB);
3880 ;
3881 break;}
3882case 211:
3883#line 2290 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3884{
3885 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
3886 CHECK_FOR_ERROR
3887 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
3888 CHECK_FOR_ERROR
3889 Value* tmpVal = getVal(Type::BoolTy, yyvsp[-6].ValIDVal);
3890 CHECK_FOR_ERROR
3891 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
3892 ;
3893 break;}
3894case 212:
3895#line 2299 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3896{
3897 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
3898 CHECK_FOR_ERROR
3899 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
3900 CHECK_FOR_ERROR
3901 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
3902 yyval.TermInstVal = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00003903
Chris Lattnerf49c1762006-11-08 05:58:47 +00003904 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
3905 E = yyvsp[-1].JumpTable->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003906 for (; I != E; ++I) {
3907 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
3908 S->addCase(CI, I->second);
3909 else
Reid Spencer61c83e02006-08-18 08:43:06 +00003910 GEN_ERROR("Switch case is constant, but not a simple integer!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003911 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00003912 delete yyvsp[-1].JumpTable;
Reid Spencer61c83e02006-08-18 08:43:06 +00003913 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003914 ;
3915 break;}
3916case 213:
3917#line 2318 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3918{
3919 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003920 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003921 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003922 CHECK_FOR_ERROR
3923 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
Chris Lattnerf49c1762006-11-08 05:58:47 +00003924 yyval.TermInstVal = S;
Reid Spencer61c83e02006-08-18 08:43:06 +00003925 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003926 ;
3927 break;}
3928case 214:
3929#line 2328 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3930{
Reid Spencer68a24bd2005-08-27 18:50:39 +00003931 const PointerType *PFTy;
3932 const FunctionType *Ty;
3933
Chris Lattnerf49c1762006-11-08 05:58:47 +00003934 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-10].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00003935 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
3936 // Pull out the types of all of the arguments...
3937 std::vector<const Type*> ParamTypes;
Chris Lattnerf49c1762006-11-08 05:58:47 +00003938 if (yyvsp[-7].ValueList) {
3939 for (std::vector<Value*>::iterator I = yyvsp[-7].ValueList->begin(), E = yyvsp[-7].ValueList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003940 I != E; ++I)
3941 ParamTypes.push_back((*I)->getType());
3942 }
3943
3944 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
3945 if (isVarArg) ParamTypes.pop_back();
3946
Chris Lattnerf49c1762006-11-08 05:58:47 +00003947 Ty = FunctionType::get(yyvsp[-10].TypeVal->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003948 PFTy = PointerType::get(Ty);
3949 }
3950
Chris Lattnerf49c1762006-11-08 05:58:47 +00003951 Value *V = getVal(PFTy, yyvsp[-9].ValIDVal); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00003952 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003953 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003954 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003955 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00003956 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00003957
3958 // Create the call node...
Chris Lattnerf49c1762006-11-08 05:58:47 +00003959 if (!yyvsp[-7].ValueList) { // Has no arguments?
3960 yyval.TermInstVal = new InvokeInst(V, Normal, Except, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00003961 } else { // Has arguments?
3962 // Loop through FunctionType's arguments and ensure they are specified
3963 // correctly!
3964 //
3965 FunctionType::param_iterator I = Ty->param_begin();
3966 FunctionType::param_iterator E = Ty->param_end();
Chris Lattnerf49c1762006-11-08 05:58:47 +00003967 std::vector<Value*>::iterator ArgI = yyvsp[-7].ValueList->begin(), ArgE = yyvsp[-7].ValueList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00003968
3969 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
3970 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00003971 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00003972 (*I)->getDescription() + "'!");
3973
3974 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00003975 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00003976
Chris Lattnerf49c1762006-11-08 05:58:47 +00003977 yyval.TermInstVal = new InvokeInst(V, Normal, Except, *yyvsp[-7].ValueList);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003978 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00003979 cast<InvokeInst>(yyval.TermInstVal)->setCallingConv(yyvsp[-11].UIntVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00003980
Chris Lattnerf49c1762006-11-08 05:58:47 +00003981 delete yyvsp[-10].TypeVal;
3982 delete yyvsp[-7].ValueList;
Reid Spencer61c83e02006-08-18 08:43:06 +00003983 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003984 ;
3985 break;}
3986case 215:
3987#line 2383 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3988{
3989 yyval.TermInstVal = new UnwindInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00003990 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003991 ;
3992 break;}
3993case 216:
3994#line 2387 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3995{
3996 yyval.TermInstVal = new UnreachableInst();
Reid Spencer61c83e02006-08-18 08:43:06 +00003997 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00003998 ;
3999 break;}
4000case 217:
4001#line 2394 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4002{
4003 yyval.JumpTable = yyvsp[-5].JumpTable;
4004 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004005 CHECK_FOR_ERROR
Reid Spencer61c83e02006-08-18 08:43:06 +00004006 if (V == 0)
4007 GEN_ERROR("May only switch on a constant pool value!");
4008
Chris Lattnerf49c1762006-11-08 05:58:47 +00004009 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004010 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004011 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4012 ;
4013 break;}
4014case 218:
4015#line 2405 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4016{
4017 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4018 Constant *V = cast<Constant>(getValNonImprovising(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
Reid Spencer5b7e7532006-09-28 19:28:24 +00004019 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004020
4021 if (V == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004022 GEN_ERROR("May only switch on a constant pool value!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004023
Chris Lattnerf49c1762006-11-08 05:58:47 +00004024 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004025 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004026 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4027 ;
4028 break;}
4029case 219:
4030#line 2418 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4031{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004032 // Is this definition named?? if so, assign the name...
Chris Lattnerf49c1762006-11-08 05:58:47 +00004033 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004034 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004035 InsertValue(yyvsp[0].InstVal);
4036 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004037 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004038;
4039 break;}
4040case 220:
4041#line 2427 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4042{ // Used for PHI nodes
4043 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4044 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004045 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004046 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004047 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004048 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4049 delete yyvsp[-5].TypeVal;
4050 ;
4051 break;}
4052case 221:
4053#line 2436 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4054{
4055 yyval.PHIList = yyvsp[-6].PHIList;
4056 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004057 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004058 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004059 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004060 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4061 ;
4062 break;}
4063case 222:
4064#line 2446 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4065{ // Used for call statements, and memory insts...
4066 yyval.ValueList = new std::vector<Value*>();
4067 yyval.ValueList->push_back(yyvsp[0].ValueVal);
4068 ;
4069 break;}
4070case 223:
4071#line 2450 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4072{
4073 yyval.ValueList = yyvsp[-2].ValueList;
4074 yyvsp[-2].ValueList->push_back(yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004075 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004076 ;
4077 break;}
4078case 225:
4079#line 2457 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4080{ yyval.ValueList = 0; ;
4081 break;}
4082case 226:
4083#line 2459 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4084{
4085 yyval.BoolVal = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004086 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004087 ;
4088 break;}
4089case 227:
4090#line 2463 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4091{
4092 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004093 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004094 ;
4095 break;}
4096case 228:
4097#line 2468 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4098{
4099 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4100 !isa<PackedType>((*yyvsp[-3].TypeVal).get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004101 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004102 "Arithmetic operator requires integer, FP, or packed operands!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004103 if (isa<PackedType>((*yyvsp[-3].TypeVal).get()) &&
4104 (yyvsp[-4].BinaryOpVal.opcode == Instruction::URem ||
4105 yyvsp[-4].BinaryOpVal.opcode == Instruction::SRem ||
4106 yyvsp[-4].BinaryOpVal.opcode == Instruction::FRem))
Reid Spencer3ed469c2006-11-02 20:25:50 +00004107 GEN_ERROR("U/S/FRem not supported on packed types!");
Reid Spencer1628cec2006-10-26 06:15:43 +00004108 // Upgrade the opcode from obsolete versions before we do anything with it.
Chris Lattnerf49c1762006-11-08 05:58:47 +00004109 sanitizeOpCode(yyvsp[-4].BinaryOpVal,*yyvsp[-3].TypeVal);
Reid Spencer1628cec2006-10-26 06:15:43 +00004110 CHECK_FOR_ERROR;
Chris Lattnerf49c1762006-11-08 05:58:47 +00004111 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004112 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004113 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004114 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004115 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal.opcode, val1, val2);
4116 if (yyval.InstVal == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004117 GEN_ERROR("binary operator returned null!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004118 delete yyvsp[-3].TypeVal;
4119 ;
4120 break;}
4121case 229:
4122#line 2490 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4123{
4124 if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
4125 if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
4126 !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
Reid Spencer61c83e02006-08-18 08:43:06 +00004127 GEN_ERROR("Logical operator requires integral operands!");
Chris Lattner524a1312005-12-21 18:31:50 +00004128 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00004129 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004130 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004131 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004132 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004133 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal.opcode, tmpVal1, tmpVal2);
4134 if (yyval.InstVal == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004135 GEN_ERROR("binary operator returned null!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004136 delete yyvsp[-3].TypeVal;
4137 ;
4138 break;}
4139case 230:
4140#line 2505 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4141{
4142 if(isa<PackedType>((*yyvsp[-3].TypeVal).get())) {
Reid Spencer61c83e02006-08-18 08:43:06 +00004143 GEN_ERROR(
Reid Spencer68a24bd2005-08-27 18:50:39 +00004144 "PackedTypes currently not supported in setcc instructions!");
4145 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00004146 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004147 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004148 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004149 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004150 yyval.InstVal = new SetCondInst(yyvsp[-4].BinaryOpVal.opcode, tmpVal1, tmpVal2);
4151 if (yyval.InstVal == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004152 GEN_ERROR("binary operator returned null!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004153 delete yyvsp[-3].TypeVal;
4154 ;
4155 break;}
4156case 231:
4157#line 2519 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4158{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004159 std::cerr << "WARNING: Use of eliminated 'not' instruction:"
4160 << " Replacing with 'xor'.\n";
4161
Chris Lattnerf49c1762006-11-08 05:58:47 +00004162 Value *Ones = ConstantIntegral::getAllOnesValue(yyvsp[0].ValueVal->getType());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004163 if (Ones == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004164 GEN_ERROR("Expected integral type for not instruction!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004165
Chris Lattnerf49c1762006-11-08 05:58:47 +00004166 yyval.InstVal = BinaryOperator::create(Instruction::Xor, yyvsp[0].ValueVal, Ones);
4167 if (yyval.InstVal == 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004168 GEN_ERROR("Could not create a xor instruction!");
4169 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004170 ;
4171 break;}
4172case 232:
4173#line 2532 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4174{
4175 if (yyvsp[0].ValueVal->getType() != Type::UByteTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004176 GEN_ERROR("Shift amount must be ubyte!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004177 if (!yyvsp[-2].ValueVal->getType()->isInteger())
Reid Spencer61c83e02006-08-18 08:43:06 +00004178 GEN_ERROR("Shift constant expression requires integer operand!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004179 yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal.opcode, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004180 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004181 ;
4182 break;}
4183case 233:
4184#line 2540 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4185{
4186 if (!yyvsp[0].TypeVal->get()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004187 GEN_ERROR("cast instruction to a non-primitive type: '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00004188 yyvsp[0].TypeVal->get()->getDescription() + "'!");
4189 yyval.InstVal = new CastInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4190 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004191 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004192 ;
4193 break;}
4194case 234:
4195#line 2548 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4196{
4197 if (yyvsp[-4].ValueVal->getType() != Type::BoolTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004198 GEN_ERROR("select condition must be boolean!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004199 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004200 GEN_ERROR("select value types should match!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004201 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004202 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004203 ;
4204 break;}
4205case 235:
4206#line 2556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4207{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004208 NewVarArgs = true;
Chris Lattnerf49c1762006-11-08 05:58:47 +00004209 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4210 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004211 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004212 ;
4213 break;}
4214case 236:
4215#line 2562 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4216{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004217 ObsoleteVarArgs = true;
Chris Lattnerf49c1762006-11-08 05:58:47 +00004218 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004219 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004220 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004221
4222 //b = vaarg a, t ->
4223 //foo = alloca 1 of t
4224 //bar = vacopy a
4225 //store bar -> foo
4226 //b = vaarg foo, t
4227 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vaarg.fix");
4228 CurBB->getInstList().push_back(foo);
Chris Lattnerf49c1762006-11-08 05:58:47 +00004229 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004230 CurBB->getInstList().push_back(bar);
4231 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Chris Lattnerf49c1762006-11-08 05:58:47 +00004232 yyval.InstVal = new VAArgInst(foo, *yyvsp[0].TypeVal);
4233 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004234 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004235 ;
4236 break;}
4237case 237:
4238#line 2582 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4239{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004240 ObsoleteVarArgs = true;
Chris Lattnerf49c1762006-11-08 05:58:47 +00004241 const Type* ArgTy = yyvsp[-2].ValueVal->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004242 Function* NF = CurModule.CurrentModule->
Jeff Cohen66c5fd62005-10-23 04:37:20 +00004243 getOrInsertFunction("llvm.va_copy", ArgTy, ArgTy, (Type *)0);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004244
4245 //b = vanext a, t ->
4246 //foo = alloca 1 of t
4247 //bar = vacopy a
4248 //store bar -> foo
4249 //tmp = vaarg foo, t
4250 //b = load foo
4251 AllocaInst* foo = new AllocaInst(ArgTy, 0, "vanext.fix");
4252 CurBB->getInstList().push_back(foo);
Chris Lattnerf49c1762006-11-08 05:58:47 +00004253 CallInst* bar = new CallInst(NF, yyvsp[-2].ValueVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004254 CurBB->getInstList().push_back(bar);
4255 CurBB->getInstList().push_back(new StoreInst(bar, foo));
Chris Lattnerf49c1762006-11-08 05:58:47 +00004256 Instruction* tmp = new VAArgInst(foo, *yyvsp[0].TypeVal);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004257 CurBB->getInstList().push_back(tmp);
Chris Lattnerf49c1762006-11-08 05:58:47 +00004258 yyval.InstVal = new LoadInst(foo);
4259 delete yyvsp[0].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004260 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004261 ;
4262 break;}
4263case 238:
4264#line 2605 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4265{
4266 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer61c83e02006-08-18 08:43:06 +00004267 GEN_ERROR("Invalid extractelement operands!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004268 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004269 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004270 ;
4271 break;}
4272case 239:
4273#line 2611 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4274{
4275 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer61c83e02006-08-18 08:43:06 +00004276 GEN_ERROR("Invalid insertelement operands!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004277 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004278 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004279 ;
4280 break;}
4281case 240:
4282#line 2617 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4283{
4284 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
Reid Spencer61c83e02006-08-18 08:43:06 +00004285 GEN_ERROR("Invalid shufflevector operands!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004286 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004287 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004288 ;
4289 break;}
4290case 241:
4291#line 2623 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4292{
4293 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004294 if (!Ty->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004295 GEN_ERROR("PHI node operands must be of first class type!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004296 yyval.InstVal = new PHINode(Ty);
4297 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4298 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4299 if (yyvsp[0].PHIList->front().first->getType() != Ty)
Reid Spencer61c83e02006-08-18 08:43:06 +00004300 GEN_ERROR("All elements of a PHI node must be of the same type!");
Chris Lattnerf49c1762006-11-08 05:58:47 +00004301 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4302 yyvsp[0].PHIList->pop_front();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004303 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00004304 delete yyvsp[0].PHIList; // Free the list...
Reid Spencer61c83e02006-08-18 08:43:06 +00004305 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004306 ;
4307 break;}
4308case 242:
4309#line 2638 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4310{
Reid Spencer68a24bd2005-08-27 18:50:39 +00004311 const PointerType *PFTy;
4312 const FunctionType *Ty;
4313
Chris Lattnerf49c1762006-11-08 05:58:47 +00004314 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-4].TypeVal->get())) ||
Reid Spencer68a24bd2005-08-27 18:50:39 +00004315 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4316 // Pull out the types of all of the arguments...
4317 std::vector<const Type*> ParamTypes;
Chris Lattnerf49c1762006-11-08 05:58:47 +00004318 if (yyvsp[-1].ValueList) {
4319 for (std::vector<Value*>::iterator I = yyvsp[-1].ValueList->begin(), E = yyvsp[-1].ValueList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004320 I != E; ++I)
4321 ParamTypes.push_back((*I)->getType());
4322 }
4323
4324 bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy;
4325 if (isVarArg) ParamTypes.pop_back();
4326
Chris Lattnerf49c1762006-11-08 05:58:47 +00004327 if (!(*yyvsp[-4].TypeVal)->isFirstClassType() && *yyvsp[-4].TypeVal != Type::VoidTy)
Reid Spencer61c83e02006-08-18 08:43:06 +00004328 GEN_ERROR("LLVM functions cannot return aggregate types!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004329
Chris Lattnerf49c1762006-11-08 05:58:47 +00004330 Ty = FunctionType::get(yyvsp[-4].TypeVal->get(), ParamTypes, isVarArg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004331 PFTy = PointerType::get(Ty);
4332 }
4333
Chris Lattnerf49c1762006-11-08 05:58:47 +00004334 Value *V = getVal(PFTy, yyvsp[-3].ValIDVal); // Get the function we're calling...
Reid Spencer5b7e7532006-09-28 19:28:24 +00004335 CHECK_FOR_ERROR
Reid Spencer68a24bd2005-08-27 18:50:39 +00004336
4337 // Create the call node...
Chris Lattnerf49c1762006-11-08 05:58:47 +00004338 if (!yyvsp[-1].ValueList) { // Has no arguments?
Reid Spencer68a24bd2005-08-27 18:50:39 +00004339 // Make sure no arguments is a good thing!
4340 if (Ty->getNumParams() != 0)
Reid Spencer61c83e02006-08-18 08:43:06 +00004341 GEN_ERROR("No arguments passed to a function that "
Reid Spencer68a24bd2005-08-27 18:50:39 +00004342 "expects arguments!");
4343
Chris Lattnerf49c1762006-11-08 05:58:47 +00004344 yyval.InstVal = new CallInst(V, std::vector<Value*>());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004345 } else { // Has arguments?
4346 // Loop through FunctionType's arguments and ensure they are specified
4347 // correctly!
4348 //
4349 FunctionType::param_iterator I = Ty->param_begin();
4350 FunctionType::param_iterator E = Ty->param_end();
Chris Lattnerf49c1762006-11-08 05:58:47 +00004351 std::vector<Value*>::iterator ArgI = yyvsp[-1].ValueList->begin(), ArgE = yyvsp[-1].ValueList->end();
Reid Spencer68a24bd2005-08-27 18:50:39 +00004352
4353 for (; ArgI != ArgE && I != E; ++ArgI, ++I)
4354 if ((*ArgI)->getType() != *I)
Reid Spencer61c83e02006-08-18 08:43:06 +00004355 GEN_ERROR("Parameter " +(*ArgI)->getName()+ " is not of type '" +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004356 (*I)->getDescription() + "'!");
4357
4358 if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004359 GEN_ERROR("Invalid number of parameters detected!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004360
Chris Lattnerf49c1762006-11-08 05:58:47 +00004361 yyval.InstVal = new CallInst(V, *yyvsp[-1].ValueList);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004362 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00004363 cast<CallInst>(yyval.InstVal)->setTailCall(yyvsp[-6].BoolVal);
4364 cast<CallInst>(yyval.InstVal)->setCallingConv(yyvsp[-5].UIntVal);
4365 delete yyvsp[-4].TypeVal;
4366 delete yyvsp[-1].ValueList;
Reid Spencer61c83e02006-08-18 08:43:06 +00004367 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004368 ;
4369 break;}
4370case 243:
4371#line 2697 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4372{
4373 yyval.InstVal = yyvsp[0].InstVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004374 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004375 ;
4376 break;}
4377case 244:
4378#line 2704 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4379{
4380 yyval.ValueList = yyvsp[0].ValueList;
Reid Spencer61c83e02006-08-18 08:43:06 +00004381 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004382 ;
4383 break;}
4384case 245:
4385#line 2707 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4386{
4387 yyval.ValueList = new std::vector<Value*>();
Reid Spencer61c83e02006-08-18 08:43:06 +00004388 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004389 ;
4390 break;}
4391case 246:
4392#line 2712 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4393{
4394 yyval.BoolVal = true;
Reid Spencer61c83e02006-08-18 08:43:06 +00004395 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004396 ;
4397 break;}
4398case 247:
4399#line 2716 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4400{
4401 yyval.BoolVal = false;
Reid Spencer61c83e02006-08-18 08:43:06 +00004402 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004403 ;
4404 break;}
4405case 248:
4406#line 2723 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4407{
4408 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4409 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004410 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004411 ;
4412 break;}
4413case 249:
4414#line 2728 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4415{
4416 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004417 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004418 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4419 delete yyvsp[-4].TypeVal;
4420 ;
4421 break;}
4422case 250:
4423#line 2734 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4424{
4425 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4426 delete yyvsp[-1].TypeVal;
Reid Spencer61c83e02006-08-18 08:43:06 +00004427 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004428 ;
4429 break;}
4430case 251:
4431#line 2739 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4432{
4433 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004434 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004435 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4436 delete yyvsp[-4].TypeVal;
4437 ;
4438 break;}
4439case 252:
4440#line 2745 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4441{
4442 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004443 GEN_ERROR("Trying to free nonpointer type " +
Chris Lattnerf49c1762006-11-08 05:58:47 +00004444 yyvsp[0].ValueVal->getType()->getDescription() + "!");
4445 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004446 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004447 ;
4448 break;}
4449case 253:
4450#line 2753 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4451{
4452 if (!isa<PointerType>(yyvsp[-1].TypeVal->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004453 GEN_ERROR("Can't load from nonpointer type: " +
Chris Lattnerf49c1762006-11-08 05:58:47 +00004454 (*yyvsp[-1].TypeVal)->getDescription());
4455 if (!cast<PointerType>(yyvsp[-1].TypeVal->get())->getElementType()->isFirstClassType())
Reid Spencer61c83e02006-08-18 08:43:06 +00004456 GEN_ERROR("Can't load from pointer of non-first-class type: " +
Chris Lattnerf49c1762006-11-08 05:58:47 +00004457 (*yyvsp[-1].TypeVal)->getDescription());
4458 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004459 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004460 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-3].BoolVal);
4461 delete yyvsp[-1].TypeVal;
4462 ;
4463 break;}
4464case 254:
4465#line 2765 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4466{
4467 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004468 if (!PT)
Reid Spencer61c83e02006-08-18 08:43:06 +00004469 GEN_ERROR("Can't store to a nonpointer type: " +
Chris Lattnerf49c1762006-11-08 05:58:47 +00004470 (*yyvsp[-1].TypeVal)->getDescription());
Reid Spencer68a24bd2005-08-27 18:50:39 +00004471 const Type *ElTy = PT->getElementType();
Chris Lattnerf49c1762006-11-08 05:58:47 +00004472 if (ElTy != yyvsp[-3].ValueVal->getType())
4473 GEN_ERROR("Can't store '" + yyvsp[-3].ValueVal->getType()->getDescription() +
Reid Spencer68a24bd2005-08-27 18:50:39 +00004474 "' into space of type '" + ElTy->getDescription() + "'!");
4475
Chris Lattnerf49c1762006-11-08 05:58:47 +00004476 Value* tmpVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004477 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004478 yyval.InstVal = new StoreInst(yyvsp[-3].ValueVal, tmpVal, yyvsp[-5].BoolVal);
4479 delete yyvsp[-1].TypeVal;
4480 ;
4481 break;}
4482case 255:
4483#line 2780 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4484{
4485 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
Reid Spencer61c83e02006-08-18 08:43:06 +00004486 GEN_ERROR("getelementptr insn requires pointer operand!");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004487
4488 // LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct
4489 // indices to uint struct indices for compatibility.
4490 generic_gep_type_iterator<std::vector<Value*>::iterator>
Chris Lattnerf49c1762006-11-08 05:58:47 +00004491 GTI = gep_type_begin(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end()),
4492 GTE = gep_type_end(yyvsp[-2].TypeVal->get(), yyvsp[0].ValueList->begin(), yyvsp[0].ValueList->end());
4493 for (unsigned i = 0, e = yyvsp[0].ValueList->size(); i != e && GTI != GTE; ++i, ++GTI)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004494 if (isa<StructType>(*GTI)) // Only change struct indices
Chris Lattnerf49c1762006-11-08 05:58:47 +00004495 if (ConstantInt *CUI = dyn_cast<ConstantInt>((*yyvsp[0].ValueList)[i]))
Reid Spencer68a24bd2005-08-27 18:50:39 +00004496 if (CUI->getType() == Type::UByteTy)
Chris Lattnerf49c1762006-11-08 05:58:47 +00004497 (*yyvsp[0].ValueList)[i] = ConstantExpr::getCast(CUI, Type::UIntTy);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004498
Chris Lattnerf49c1762006-11-08 05:58:47 +00004499 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, *yyvsp[0].ValueList, true))
Reid Spencer61c83e02006-08-18 08:43:06 +00004500 GEN_ERROR("Invalid getelementptr indices for type '" +
Chris Lattnerf49c1762006-11-08 05:58:47 +00004501 (*yyvsp[-2].TypeVal)->getDescription()+ "'!");
4502 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
Reid Spencer61c83e02006-08-18 08:43:06 +00004503 CHECK_FOR_ERROR
Chris Lattnerf49c1762006-11-08 05:58:47 +00004504 yyval.InstVal = new GetElementPtrInst(tmpVal, *yyvsp[0].ValueList);
4505 delete yyvsp[-2].TypeVal;
4506 delete yyvsp[0].ValueList;
4507 ;
4508 break;}
4509}
4510 /* the action file gets copied in in place of this dollarsign */
4511#line 543 "/usr/share/bison.simple"
Reid Spencer5b7e7532006-09-28 19:28:24 +00004512
4513 yyvsp -= yylen;
4514 yyssp -= yylen;
Chris Lattnerf49c1762006-11-08 05:58:47 +00004515#ifdef YYLSP_NEEDED
4516 yylsp -= yylen;
4517#endif
Reid Spencer5b7e7532006-09-28 19:28:24 +00004518
Chris Lattnerf49c1762006-11-08 05:58:47 +00004519#if YYDEBUG != 0
4520 if (yydebug)
4521 {
4522 short *ssp1 = yyss - 1;
4523 fprintf (stderr, "state stack now");
4524 while (ssp1 != yyssp)
4525 fprintf (stderr, " %d", *++ssp1);
4526 fprintf (stderr, "\n");
4527 }
4528#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004529
4530 *++yyvsp = yyval;
4531
Chris Lattnerf49c1762006-11-08 05:58:47 +00004532#ifdef YYLSP_NEEDED
4533 yylsp++;
4534 if (yylen == 0)
4535 {
4536 yylsp->first_line = yylloc.first_line;
4537 yylsp->first_column = yylloc.first_column;
4538 yylsp->last_line = (yylsp-1)->last_line;
4539 yylsp->last_column = (yylsp-1)->last_column;
4540 yylsp->text = 0;
4541 }
4542 else
4543 {
4544 yylsp->last_line = (yylsp+yylen-1)->last_line;
4545 yylsp->last_column = (yylsp+yylen-1)->last_column;
4546 }
4547#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004548
Chris Lattnerf49c1762006-11-08 05:58:47 +00004549 /* Now "shift" the result of the reduction.
4550 Determine what state that goes to,
4551 based on the state we popped back to
4552 and the rule number reduced by. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004553
4554 yyn = yyr1[yyn];
4555
Chris Lattnerf49c1762006-11-08 05:58:47 +00004556 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4557 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004558 yystate = yytable[yystate];
4559 else
Chris Lattnerf49c1762006-11-08 05:58:47 +00004560 yystate = yydefgoto[yyn - YYNTBASE];
Reid Spencer68a24bd2005-08-27 18:50:39 +00004561
4562 goto yynewstate;
4563
Chris Lattnerf49c1762006-11-08 05:58:47 +00004564yyerrlab: /* here on detecting error */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004565
Chris Lattnerf49c1762006-11-08 05:58:47 +00004566 if (! yyerrstatus)
4567 /* If not already recovering from an error, report this error. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004568 {
4569 ++yynerrs;
Chris Lattnerf49c1762006-11-08 05:58:47 +00004570
4571#ifdef YYERROR_VERBOSE
Reid Spencer5b7e7532006-09-28 19:28:24 +00004572 yyn = yypact[yystate];
Chris Lattner224f84f2006-08-18 17:34:45 +00004573
Chris Lattnerf49c1762006-11-08 05:58:47 +00004574 if (yyn > YYFLAG && yyn < YYLAST)
Reid Spencer5b7e7532006-09-28 19:28:24 +00004575 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00004576 int size = 0;
4577 char *msg;
4578 int x, count;
Reid Spencer5b7e7532006-09-28 19:28:24 +00004579
Chris Lattnerf49c1762006-11-08 05:58:47 +00004580 count = 0;
4581 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4582 for (x = (yyn < 0 ? -yyn : 0);
4583 x < (sizeof(yytname) / sizeof(char *)); x++)
4584 if (yycheck[x + yyn] == x)
4585 size += strlen(yytname[x]) + 15, count++;
4586 msg = (char *) malloc(size + 15);
4587 if (msg != 0)
Reid Spencer5b7e7532006-09-28 19:28:24 +00004588 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00004589 strcpy(msg, "parse error");
4590
4591 if (count < 5)
Reid Spencer5b7e7532006-09-28 19:28:24 +00004592 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00004593 count = 0;
4594 for (x = (yyn < 0 ? -yyn : 0);
4595 x < (sizeof(yytname) / sizeof(char *)); x++)
4596 if (yycheck[x + yyn] == x)
4597 {
4598 strcat(msg, count == 0 ? ", expecting `" : " or `");
4599 strcat(msg, yytname[x]);
4600 strcat(msg, "'");
4601 count++;
4602 }
Reid Spencer5b7e7532006-09-28 19:28:24 +00004603 }
Chris Lattnerf49c1762006-11-08 05:58:47 +00004604 yyerror(msg);
4605 free(msg);
Reid Spencer5b7e7532006-09-28 19:28:24 +00004606 }
4607 else
Chris Lattnerf49c1762006-11-08 05:58:47 +00004608 yyerror ("parse error; also virtual memory exceeded");
Reid Spencer5b7e7532006-09-28 19:28:24 +00004609 }
4610 else
4611#endif /* YYERROR_VERBOSE */
Chris Lattnerf49c1762006-11-08 05:58:47 +00004612 yyerror("parse error");
Reid Spencer68a24bd2005-08-27 18:50:39 +00004613 }
4614
Chris Lattnerf49c1762006-11-08 05:58:47 +00004615 goto yyerrlab1;
4616yyerrlab1: /* here on error raised explicitly by an action */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004617
4618 if (yyerrstatus == 3)
4619 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00004620 /* if just tried and failed to reuse lookahead token after an error, discard it. */
Reid Spencer68a24bd2005-08-27 18:50:39 +00004621
Chris Lattnerf49c1762006-11-08 05:58:47 +00004622 /* return failure if at end of input */
4623 if (yychar == YYEOF)
Reid Spencer68a24bd2005-08-27 18:50:39 +00004624 YYABORT;
4625
Chris Lattnerf49c1762006-11-08 05:58:47 +00004626#if YYDEBUG != 0
4627 if (yydebug)
4628 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4629#endif
Chris Lattner8335e842006-01-23 23:05:42 +00004630
Chris Lattnerf49c1762006-11-08 05:58:47 +00004631 yychar = YYEMPTY;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004632 }
4633
Chris Lattnerf49c1762006-11-08 05:58:47 +00004634 /* Else will try to reuse lookahead token
4635 after shifting the error token. */
4636
4637 yyerrstatus = 3; /* Each real token shifted decrements this */
4638
4639 goto yyerrhandle;
4640
4641yyerrdefault: /* current state does not do anything special for the error token. */
4642
4643#if 0
4644 /* This is wrong; only states that explicitly want error tokens
4645 should shift them. */
4646 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4647 if (yyn) goto yydefault;
4648#endif
4649
4650yyerrpop: /* pop the current state because it cannot handle the error token */
4651
4652 if (yyssp == yyss) YYABORT;
4653 yyvsp--;
4654 yystate = *--yyssp;
4655#ifdef YYLSP_NEEDED
4656 yylsp--;
4657#endif
4658
4659#if YYDEBUG != 0
4660 if (yydebug)
4661 {
4662 short *ssp1 = yyss - 1;
4663 fprintf (stderr, "Error: state stack now");
4664 while (ssp1 != yyssp)
4665 fprintf (stderr, " %d", *++ssp1);
4666 fprintf (stderr, "\n");
4667 }
4668#endif
4669
4670yyerrhandle:
4671
4672 yyn = yypact[yystate];
4673 if (yyn == YYFLAG)
4674 goto yyerrdefault;
4675
4676 yyn += YYTERROR;
4677 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4678 goto yyerrdefault;
4679
4680 yyn = yytable[yyn];
4681 if (yyn < 0)
4682 {
4683 if (yyn == YYFLAG)
4684 goto yyerrpop;
4685 yyn = -yyn;
4686 goto yyreduce;
4687 }
4688 else if (yyn == 0)
4689 goto yyerrpop;
4690
Reid Spencer68a24bd2005-08-27 18:50:39 +00004691 if (yyn == YYFINAL)
4692 YYACCEPT;
4693
Chris Lattnerf49c1762006-11-08 05:58:47 +00004694#if YYDEBUG != 0
4695 if (yydebug)
4696 fprintf(stderr, "Shifting error token, ");
4697#endif
4698
Reid Spencer68a24bd2005-08-27 18:50:39 +00004699 *++yyvsp = yylval;
Chris Lattnerf49c1762006-11-08 05:58:47 +00004700#ifdef YYLSP_NEEDED
4701 *++yylsp = yylloc;
4702#endif
Reid Spencer68a24bd2005-08-27 18:50:39 +00004703
4704 yystate = yyn;
4705 goto yynewstate;
4706
Chris Lattnerf49c1762006-11-08 05:58:47 +00004707 yyacceptlab:
4708 /* YYACCEPT comes here. */
4709 if (yyfree_stacks)
Reid Spencer21be8652006-10-22 07:03:43 +00004710 {
Chris Lattnerf49c1762006-11-08 05:58:47 +00004711 free (yyss);
4712 free (yyvs);
4713#ifdef YYLSP_NEEDED
4714 free (yyls);
Reid Spencer21be8652006-10-22 07:03:43 +00004715#endif
Chris Lattnerf49c1762006-11-08 05:58:47 +00004716 }
4717 return 0;
4718
4719 yyabortlab:
4720 /* YYABORT comes here. */
4721 if (yyfree_stacks)
4722 {
4723 free (yyss);
4724 free (yyvs);
4725#ifdef YYLSP_NEEDED
4726 free (yyls);
4727#endif
4728 }
4729 return 1;
Reid Spencer68a24bd2005-08-27 18:50:39 +00004730}
Chris Lattnerf49c1762006-11-08 05:58:47 +00004731#line 2806 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
Reid Spencer61c83e02006-08-18 08:43:06 +00004732
4733
4734void llvm::GenerateError(const std::string &message, int LineNo) {
4735 if (LineNo == -1) LineNo = llvmAsmlineno;
4736 // TODO: column number in exception
4737 if (TheParseError)
4738 TheParseError->setError(CurFilename, message, LineNo);
4739 TriggerError = 1;
4740}
Reid Spencer68a24bd2005-08-27 18:50:39 +00004741
4742int yyerror(const char *ErrorMsg) {
4743 std::string where
4744 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
4745 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
4746 std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
4747 if (yychar == YYEMPTY || yychar == 0)
4748 errMsg += "end-of-file.";
4749 else
4750 errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
Reid Spencer61c83e02006-08-18 08:43:06 +00004751 GenerateError(errMsg);
Reid Spencer68a24bd2005-08-27 18:50:39 +00004752 return 0;
4753}