2 /* A Bison parser, made from /Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse llvmAsmparse
8 #define yylex llvmAsmlex
9 #define yyerror llvmAsmerror
10 #define yylval llvmAsmlval
11 #define yychar llvmAsmchar
12 #define yydebug llvmAsmdebug
13 #define yynerrs llvmAsmnerrs
14 #define ESINT64VAL 257
15 #define EUINT64VAL 258
16 #define ESAPINTVAL 259
17 #define EUAPINTVAL 260
18 #define LOCALVAL_ID 261
19 #define GLOBALVAL_ID 262
30 #define STRINGCONSTANT 273
31 #define ATSTRINGCONSTANT 274
32 #define ZEROINITIALIZER 275
44 #define THREAD_LOCAL 287
55 #define EXTERN_WEAK 298
66 #define SIDEEFFECT 309
69 #define FASTCC_TOK 312
70 #define COLDCC_TOK 313
71 #define X86_STDCALLCC_TOK 314
72 #define X86_FASTCALLCC_TOK 315
73 #define DATALAYOUT 316
79 #define UNREACHABLE 322
122 #define GETELEMENTPTR 365
138 #define EXTRACTELEMENT 381
139 #define INSERTELEMENT 382
140 #define SHUFFLEVECTOR 383
147 #define PROTECTED 390
149 #line 14 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
151 #include "ParserInternals.h"
152 #include "llvm/CallingConv.h"
153 #include "llvm/InlineAsm.h"
154 #include "llvm/Instructions.h"
155 #include "llvm/Module.h"
156 #include "llvm/ValueSymbolTable.h"
157 #include "llvm/Support/GetElementPtrTypeIterator.h"
158 #include "llvm/Support/CommandLine.h"
159 #include "llvm/ADT/SmallVector.h"
160 #include "llvm/ADT/STLExtras.h"
161 #include "llvm/Support/MathExtras.h"
162 #include "llvm/Support/Streams.h"
171 // The following is a gross hack. In order to rid the libAsmParser library of
172 // exceptions, we have to have a way of getting the yyparse function to go into
173 // an error situation. So, whenever we want an error to occur, the GenerateError
174 // function (see bottom of file) sets TriggerError. Then, at the end of each
175 // production in the grammer we use CHECK_FOR_ERROR which will invoke YYERROR
176 // (a goto) to put YACC in error state. Furthermore, several calls to
177 // GenerateError are made from inside productions and they must simulate the
178 // previous exception behavior by exiting the production immediately. We have
179 // replaced these with the GEN_ERROR macro which calls GeneratError and then
180 // immediately invokes YYERROR. This would be so much cleaner if it was a
181 // recursive descent parser.
182 static bool TriggerError = false;
183 #define CHECK_FOR_ERROR { if (TriggerError) { TriggerError = false; YYABORT; } }
184 #define GEN_ERROR(msg) { GenerateError(msg); YYERROR; }
186 int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit
187 int yylex(); // declaration" of xxx warnings.
191 std::string CurFilename;
194 Debug("debug-yacc", cl::desc("Print yacc debug state changes"),
195 cl::Hidden, cl::init(false));
198 using namespace llvm;
200 static Module *ParserResult;
202 // DEBUG_UPREFS - Define this symbol if you want to enable debugging output
203 // relating to upreferences in the input stream.
205 //#define DEBUG_UPREFS 1
207 #define UR_OUT(X) cerr << X
212 #define YYERROR_VERBOSE 1
214 static GlobalVariable *CurGV;
217 // This contains info used when building the body of a function. It is
218 // destroyed when the function is completed.
220 typedef std::vector<Value *> ValueList; // Numbered defs
223 ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0);
225 static struct PerModuleInfo {
226 Module *CurrentModule;
227 ValueList Values; // Module level numbered definitions
228 ValueList LateResolveValues;
229 std::vector<PATypeHolder> Types;
230 std::map<ValID, PATypeHolder> LateResolveTypes;
232 /// PlaceHolderInfo - When temporary placeholder objects are created, remember
233 /// how they were referenced and on which line of the input they came from so
234 /// that we can resolve them later and print error messages as appropriate.
235 std::map<Value*, std::pair<ValID, int> > PlaceHolderInfo;
237 // GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
238 // references to global values. Global values may be referenced before they
239 // are defined, and if so, the temporary object that they represent is held
240 // here. This is used for forward references of GlobalValues.
242 typedef std::map<std::pair<const PointerType *,
243 ValID>, GlobalValue*> GlobalRefsType;
244 GlobalRefsType GlobalRefs;
247 // If we could not resolve some functions at function compilation time
248 // (calls to functions before they are defined), resolve them now... Types
249 // are resolved when the constant pool has been completely parsed.
251 ResolveDefinitions(LateResolveValues);
255 // Check to make sure that all global value forward references have been
258 if (!GlobalRefs.empty()) {
259 std::string UndefinedReferences = "Unresolved global references exist:\n";
261 for (GlobalRefsType::iterator I = GlobalRefs.begin(), E =GlobalRefs.end();
263 UndefinedReferences += " " + I->first.first->getDescription() + " " +
264 I->first.second.getName() + "\n";
266 GenerateError(UndefinedReferences);
270 Values.clear(); // Clear out function local definitions
275 // GetForwardRefForGlobal - Check to see if there is a forward reference
276 // for this global. If so, remove it from the GlobalRefs map and return it.
277 // If not, just return null.
278 GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) {
279 // Check to see if there is a forward reference to this global variable...
280 // if there is, eliminate it and patch the reference to use the new def'n.
281 GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID));
282 GlobalValue *Ret = 0;
283 if (I != GlobalRefs.end()) {
290 bool TypeIsUnresolved(PATypeHolder* PATy) {
291 // If it isn't abstract, its resolved
292 const Type* Ty = PATy->get();
293 if (!Ty->isAbstract())
295 // Traverse the type looking for abstract types. If it isn't abstract then
296 // we don't need to traverse that leg of the type.
297 std::vector<const Type*> WorkList, SeenList;
298 WorkList.push_back(Ty);
299 while (!WorkList.empty()) {
300 const Type* Ty = WorkList.back();
301 SeenList.push_back(Ty);
303 if (const OpaqueType* OpTy = dyn_cast<OpaqueType>(Ty)) {
304 // Check to see if this is an unresolved type
305 std::map<ValID, PATypeHolder>::iterator I = LateResolveTypes.begin();
306 std::map<ValID, PATypeHolder>::iterator E = LateResolveTypes.end();
307 for ( ; I != E; ++I) {
308 if (I->second.get() == OpTy)
311 } else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(Ty)) {
312 const Type* TheTy = SeqTy->getElementType();
313 if (TheTy->isAbstract() && TheTy != Ty) {
314 std::vector<const Type*>::iterator I = SeenList.begin(),
320 WorkList.push_back(TheTy);
322 } else if (const StructType* StrTy = dyn_cast<StructType>(Ty)) {
323 for (unsigned i = 0; i < StrTy->getNumElements(); ++i) {
324 const Type* TheTy = StrTy->getElementType(i);
325 if (TheTy->isAbstract() && TheTy != Ty) {
326 std::vector<const Type*>::iterator I = SeenList.begin(),
332 WorkList.push_back(TheTy);
341 static struct PerFunctionInfo {
342 Function *CurrentFunction; // Pointer to current function being created
344 ValueList Values; // Keep track of #'d definitions
346 ValueList LateResolveValues;
347 bool isDeclare; // Is this function a forward declararation?
348 GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
349 GlobalValue::VisibilityTypes Visibility;
351 /// BBForwardRefs - When we see forward references to basic blocks, keep
352 /// track of them here.
353 std::map<ValID, BasicBlock*> BBForwardRefs;
355 inline PerFunctionInfo() {
358 Linkage = GlobalValue::ExternalLinkage;
359 Visibility = GlobalValue::DefaultVisibility;
362 inline void FunctionStart(Function *M) {
367 void FunctionDone() {
368 // Any forward referenced blocks left?
369 if (!BBForwardRefs.empty()) {
370 GenerateError("Undefined reference to label " +
371 BBForwardRefs.begin()->second->getName());
375 // Resolve all forward references now.
376 ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues);
378 Values.clear(); // Clear out function local definitions
379 BBForwardRefs.clear();
382 Linkage = GlobalValue::ExternalLinkage;
383 Visibility = GlobalValue::DefaultVisibility;
385 } CurFun; // Info for the current function...
387 static bool inFunctionScope() { return CurFun.CurrentFunction != 0; }
390 //===----------------------------------------------------------------------===//
391 // Code to handle definitions of all the types
392 //===----------------------------------------------------------------------===//
394 static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) {
395 // Things that have names or are void typed don't get slot numbers
396 if (V->hasName() || (V->getType() == Type::VoidTy))
399 // In the case of function values, we have to allow for the forward reference
400 // of basic blocks, which are included in the numbering. Consequently, we keep
401 // track of the next insertion location with NextValNum. When a BB gets
402 // inserted, it could change the size of the CurFun.Values vector.
403 if (&ValueTab == &CurFun.Values) {
404 if (ValueTab.size() <= CurFun.NextValNum)
405 ValueTab.resize(CurFun.NextValNum+1);
406 ValueTab[CurFun.NextValNum++] = V;
409 // For all other lists, its okay to just tack it on the back of the vector.
410 ValueTab.push_back(V);
413 static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) {
415 case ValID::LocalID: // Is it a numbered definition?
416 // Module constants occupy the lowest numbered slots...
417 if (D.Num < CurModule.Types.size())
418 return CurModule.Types[D.Num];
420 case ValID::LocalName: // Is it a named definition?
421 if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) {
422 D.destroy(); // Free old strdup'd memory...
427 GenerateError("Internal parser error: Invalid symbol type reference");
431 // If we reached here, we referenced either a symbol that we don't know about
432 // or an id number that hasn't been read yet. We may be referencing something
433 // forward, so just create an entry to be resolved later and get to it...
435 if (DoNotImprovise) return 0; // Do we just want a null to be returned?
438 if (inFunctionScope()) {
439 if (D.Type == ValID::LocalName) {
440 GenerateError("Reference to an undefined type: '" + D.getName() + "'");
443 GenerateError("Reference to an undefined type: #" + utostr(D.Num));
448 std::map<ValID, PATypeHolder>::iterator I =CurModule.LateResolveTypes.find(D);
449 if (I != CurModule.LateResolveTypes.end())
452 Type *Typ = OpaqueType::get();
453 CurModule.LateResolveTypes.insert(std::make_pair(D, Typ));
457 // getExistingVal - Look up the value specified by the provided type and
458 // the provided ValID. If the value exists and has already been defined, return
459 // it. Otherwise return null.
461 static Value *getExistingVal(const Type *Ty, const ValID &D) {
462 if (isa<FunctionType>(Ty)) {
463 GenerateError("Functions are not values and "
464 "must be referenced as pointers");
469 case ValID::LocalID: { // Is it a numbered definition?
470 // Check that the number is within bounds.
471 if (D.Num >= CurFun.Values.size())
473 Value *Result = CurFun.Values[D.Num];
474 if (Ty != Result->getType()) {
475 GenerateError("Numbered value (%" + utostr(D.Num) + ") of type '" +
476 Result->getType()->getDescription() + "' does not match "
477 "expected type, '" + Ty->getDescription() + "'");
482 case ValID::GlobalID: { // Is it a numbered definition?
483 if (D.Num >= CurModule.Values.size())
485 Value *Result = CurModule.Values[D.Num];
486 if (Ty != Result->getType()) {
487 GenerateError("Numbered value (@" + utostr(D.Num) + ") of type '" +
488 Result->getType()->getDescription() + "' does not match "
489 "expected type, '" + Ty->getDescription() + "'");
495 case ValID::LocalName: { // Is it a named definition?
496 if (!inFunctionScope())
498 ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
499 Value *N = SymTab.lookup(D.Name);
502 if (N->getType() != Ty)
505 D.destroy(); // Free old strdup'd memory...
508 case ValID::GlobalName: { // Is it a named definition?
509 ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
510 Value *N = SymTab.lookup(D.Name);
513 if (N->getType() != Ty)
516 D.destroy(); // Free old strdup'd memory...
520 // Check to make sure that "Ty" is an integral type, and that our
521 // value will fit into the specified type...
522 case ValID::ConstSIntVal: // Is it a constant pool reference??
523 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
524 GenerateError("Signed integral constant '" +
525 itostr(D.ConstPool64) + "' is invalid for type '" +
526 Ty->getDescription() + "'");
529 return ConstantInt::get(Ty, D.ConstPool64, true);
531 case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
532 if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
533 if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
534 GenerateError("Integral constant '" + utostr(D.UConstPool64) +
535 "' is invalid or out of range");
537 } else { // This is really a signed reference. Transmogrify.
538 return ConstantInt::get(Ty, D.ConstPool64, true);
541 return ConstantInt::get(Ty, D.UConstPool64);
544 case ValID::ConstFPVal: // Is it a floating point const pool reference?
545 if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) {
546 GenerateError("FP constant invalid for type");
549 return ConstantFP::get(Ty, D.ConstPoolFP);
551 case ValID::ConstNullVal: // Is it a null value?
552 if (!isa<PointerType>(Ty)) {
553 GenerateError("Cannot create a a non pointer null");
556 return ConstantPointerNull::get(cast<PointerType>(Ty));
558 case ValID::ConstUndefVal: // Is it an undef value?
559 return UndefValue::get(Ty);
561 case ValID::ConstZeroVal: // Is it a zero value?
562 return Constant::getNullValue(Ty);
564 case ValID::ConstantVal: // Fully resolved constant?
565 if (D.ConstantValue->getType() != Ty) {
566 GenerateError("Constant expression type different from required type");
569 return D.ConstantValue;
571 case ValID::InlineAsmVal: { // Inline asm expression
572 const PointerType *PTy = dyn_cast<PointerType>(Ty);
573 const FunctionType *FTy =
574 PTy ? dyn_cast<FunctionType>(PTy->getElementType()) : 0;
575 if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) {
576 GenerateError("Invalid type for asm constraint string");
579 InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints,
580 D.IAD->HasSideEffects);
581 D.destroy(); // Free InlineAsmDescriptor.
585 assert(0 && "Unhandled case!");
589 assert(0 && "Unhandled case!");
593 // getVal - This function is identical to getExistingVal, except that if a
594 // value is not already defined, it "improvises" by creating a placeholder var
595 // that looks and acts just like the requested variable. When the value is
596 // defined later, all uses of the placeholder variable are replaced with the
599 static Value *getVal(const Type *Ty, const ValID &ID) {
600 if (Ty == Type::LabelTy) {
601 GenerateError("Cannot use a basic block here");
605 // See if the value has already been defined.
606 Value *V = getExistingVal(Ty, ID);
608 if (TriggerError) return 0;
610 if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty)) {
611 GenerateError("Invalid use of a composite type");
615 // If we reached here, we referenced either a symbol that we don't know about
616 // or an id number that hasn't been read yet. We may be referencing something
617 // forward, so just create an entry to be resolved later and get to it...
620 case ValID::GlobalName:
621 case ValID::GlobalID: {
622 const PointerType *PTy = dyn_cast<PointerType>(Ty);
624 GenerateError("Invalid type for reference to global" );
627 const Type* ElTy = PTy->getElementType();
628 if (const FunctionType *FTy = dyn_cast<FunctionType>(ElTy))
629 V = new Function(FTy, GlobalValue::ExternalLinkage);
631 V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage);
635 V = new Argument(Ty);
638 // Remember where this forward reference came from. FIXME, shouldn't we try
639 // to recycle these things??
640 CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID,
643 if (inFunctionScope())
644 InsertValue(V, CurFun.LateResolveValues);
646 InsertValue(V, CurModule.LateResolveValues);
650 /// defineBBVal - This is a definition of a new basic block with the specified
651 /// identifier which must be the same as CurFun.NextValNum, if its numeric.
652 static BasicBlock *defineBBVal(const ValID &ID) {
653 assert(inFunctionScope() && "Can't get basic block at global scope!");
657 // First, see if this was forward referenced
659 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
660 if (BBI != CurFun.BBForwardRefs.end()) {
662 // The forward declaration could have been inserted anywhere in the
663 // function: insert it into the correct place now.
664 CurFun.CurrentFunction->getBasicBlockList().remove(BB);
665 CurFun.CurrentFunction->getBasicBlockList().push_back(BB);
667 // We're about to erase the entry, save the key so we can clean it up.
668 ValID Tmp = BBI->first;
670 // Erase the forward ref from the map as its no longer "forward"
671 CurFun.BBForwardRefs.erase(ID);
673 // The key has been removed from the map but so we don't want to leave
674 // strdup'd memory around so destroy it too.
677 // If its a numbered definition, bump the number and set the BB value.
678 if (ID.Type == ValID::LocalID) {
679 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
687 // We haven't seen this BB before and its first mention is a definition.
688 // Just create it and return it.
689 std::string Name (ID.Type == ValID::LocalName ? ID.Name : "");
690 BB = new BasicBlock(Name, CurFun.CurrentFunction);
691 if (ID.Type == ValID::LocalID) {
692 assert(ID.Num == CurFun.NextValNum && "Invalid new block number");
696 ID.destroy(); // Free strdup'd memory
700 /// getBBVal - get an existing BB value or create a forward reference for it.
702 static BasicBlock *getBBVal(const ValID &ID) {
703 assert(inFunctionScope() && "Can't get basic block at global scope!");
707 std::map<ValID, BasicBlock*>::iterator BBI = CurFun.BBForwardRefs.find(ID);
708 if (BBI != CurFun.BBForwardRefs.end()) {
710 } if (ID.Type == ValID::LocalName) {
711 std::string Name = ID.Name;
712 Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
714 if (N->getType()->getTypeID() == Type::LabelTyID)
715 BB = cast<BasicBlock>(N);
717 GenerateError("Reference to label '" + Name + "' is actually of type '"+
718 N->getType()->getDescription() + "'");
719 } else if (ID.Type == ValID::LocalID) {
720 if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
721 if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
722 BB = cast<BasicBlock>(CurFun.Values[ID.Num]);
724 GenerateError("Reference to label '%" + utostr(ID.Num) +
725 "' is actually of type '"+
726 CurFun.Values[ID.Num]->getType()->getDescription() + "'");
729 GenerateError("Illegal label reference " + ID.getName());
733 // If its already been defined, return it now.
735 ID.destroy(); // Free strdup'd memory.
739 // Otherwise, this block has not been seen before, create it.
741 if (ID.Type == ValID::LocalName)
743 BB = new BasicBlock(Name, CurFun.CurrentFunction);
745 // Insert it in the forward refs map.
746 CurFun.BBForwardRefs[ID] = BB;
752 //===----------------------------------------------------------------------===//
753 // Code to handle forward references in instructions
754 //===----------------------------------------------------------------------===//
756 // This code handles the late binding needed with statements that reference
757 // values not defined yet... for example, a forward branch, or the PHI node for
760 // This keeps a table (CurFun.LateResolveValues) of all such forward references
761 // and back patchs after we are done.
764 // ResolveDefinitions - If we could not resolve some defs at parsing
765 // time (forward branches, phi functions for loops, etc...) resolve the
769 ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers) {
770 // Loop over LateResolveDefs fixing up stuff that couldn't be resolved
771 while (!LateResolvers.empty()) {
772 Value *V = LateResolvers.back();
773 LateResolvers.pop_back();
775 std::map<Value*, std::pair<ValID, int> >::iterator PHI =
776 CurModule.PlaceHolderInfo.find(V);
777 assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!");
779 ValID &DID = PHI->second.first;
781 Value *TheRealValue = getExistingVal(V->getType(), DID);
785 V->replaceAllUsesWith(TheRealValue);
787 CurModule.PlaceHolderInfo.erase(PHI);
788 } else if (FutureLateResolvers) {
789 // Functions have their unresolved items forwarded to the module late
791 InsertValue(V, *FutureLateResolvers);
793 if (DID.Type == ValID::LocalName || DID.Type == ValID::GlobalName) {
794 GenerateError("Reference to an invalid definition: '" +DID.getName()+
795 "' of type '" + V->getType()->getDescription() + "'",
799 GenerateError("Reference to an invalid definition: #" +
800 itostr(DID.Num) + " of type '" +
801 V->getType()->getDescription() + "'",
807 LateResolvers.clear();
810 // ResolveTypeTo - A brand new type was just declared. This means that (if
811 // name is not null) things referencing Name can be resolved. Otherwise, things
812 // refering to the number can be resolved. Do this now.
814 static void ResolveTypeTo(char *Name, const Type *ToTy) {
816 if (Name) D = ValID::createLocalName(Name);
817 else D = ValID::createLocalID(CurModule.Types.size());
819 std::map<ValID, PATypeHolder>::iterator I =
820 CurModule.LateResolveTypes.find(D);
821 if (I != CurModule.LateResolveTypes.end()) {
822 ((DerivedType*)I->second.get())->refineAbstractTypeTo(ToTy);
823 CurModule.LateResolveTypes.erase(I);
827 // setValueName - Set the specified value to the name given. The name may be
828 // null potentially, in which case this is a noop. The string passed in is
829 // assumed to be a malloc'd string buffer, and is free'd by this function.
831 static void setValueName(Value *V, char *NameStr) {
832 if (!NameStr) return;
833 std::string Name(NameStr); // Copy string
834 free(NameStr); // Free old string
836 if (V->getType() == Type::VoidTy) {
837 GenerateError("Can't assign name '" + Name+"' to value with void type");
841 assert(inFunctionScope() && "Must be in function scope!");
842 ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
843 if (ST.lookup(Name)) {
844 GenerateError("Redefinition of value '" + Name + "' of type '" +
845 V->getType()->getDescription() + "'");
853 /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null,
854 /// this is a declaration, otherwise it is a definition.
855 static GlobalVariable *
856 ParseGlobalVariable(char *NameStr,
857 GlobalValue::LinkageTypes Linkage,
858 GlobalValue::VisibilityTypes Visibility,
859 bool isConstantGlobal, const Type *Ty,
860 Constant *Initializer, bool IsThreadLocal) {
861 if (isa<FunctionType>(Ty)) {
862 GenerateError("Cannot declare global vars of function type");
866 const PointerType *PTy = PointerType::get(Ty);
870 Name = NameStr; // Copy string
871 free(NameStr); // Free old string
874 // See if this global value was forward referenced. If so, recycle the
878 ID = ValID::createGlobalName((char*)Name.c_str());
880 ID = ValID::createGlobalID(CurModule.Values.size());
883 if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) {
884 // Move the global to the end of the list, from whereever it was
885 // previously inserted.
886 GlobalVariable *GV = cast<GlobalVariable>(FWGV);
887 CurModule.CurrentModule->getGlobalList().remove(GV);
888 CurModule.CurrentModule->getGlobalList().push_back(GV);
889 GV->setInitializer(Initializer);
890 GV->setLinkage(Linkage);
891 GV->setVisibility(Visibility);
892 GV->setConstant(isConstantGlobal);
893 GV->setThreadLocal(IsThreadLocal);
894 InsertValue(GV, CurModule.Values);
898 // If this global has a name
900 // if the global we're parsing has an initializer (is a definition) and
901 // has external linkage.
902 if (Initializer && Linkage != GlobalValue::InternalLinkage)
903 // If there is already a global with external linkage with this name
904 if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
905 // If we allow this GVar to get created, it will be renamed in the
906 // symbol table because it conflicts with an existing GVar. We can't
907 // allow redefinition of GVars whose linking indicates that their name
908 // must stay the same. Issue the error.
909 GenerateError("Redefinition of global variable named '" + Name +
910 "' of type '" + Ty->getDescription() + "'");
915 // Otherwise there is no existing GV to use, create one now.
917 new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name,
918 CurModule.CurrentModule, IsThreadLocal);
919 GV->setVisibility(Visibility);
920 InsertValue(GV, CurModule.Values);
924 // setTypeName - Set the specified type to the name given. The name may be
925 // null potentially, in which case this is a noop. The string passed in is
926 // assumed to be a malloc'd string buffer, and is freed by this function.
928 // This function returns true if the type has already been defined, but is
929 // allowed to be redefined in the specified context. If the name is a new name
930 // for the type plane, it is inserted and false is returned.
931 static bool setTypeName(const Type *T, char *NameStr) {
932 assert(!inFunctionScope() && "Can't give types function-local names!");
933 if (NameStr == 0) return false;
935 std::string Name(NameStr); // Copy string
936 free(NameStr); // Free old string
938 // We don't allow assigning names to void type
939 if (T == Type::VoidTy) {
940 GenerateError("Can't assign name '" + Name + "' to the void type");
944 // Set the type name, checking for conflicts as we do so.
945 bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T);
947 if (AlreadyExists) { // Inserting a name that is already defined???
948 const Type *Existing = CurModule.CurrentModule->getTypeByName(Name);
949 assert(Existing && "Conflict but no matching type?!");
951 // There is only one case where this is allowed: when we are refining an
952 // opaque type. In this case, Existing will be an opaque type.
953 if (const OpaqueType *OpTy = dyn_cast<OpaqueType>(Existing)) {
954 // We ARE replacing an opaque type!
955 const_cast<OpaqueType*>(OpTy)->refineAbstractTypeTo(T);
959 // Otherwise, this is an attempt to redefine a type. That's okay if
960 // the redefinition is identical to the original. This will be so if
961 // Existing and T point to the same Type object. In this one case we
962 // allow the equivalent redefinition.
963 if (Existing == T) return true; // Yes, it's equal.
965 // Any other kind of (non-equivalent) redefinition is an error.
966 GenerateError("Redefinition of type named '" + Name + "' of type '" +
967 T->getDescription() + "'");
973 //===----------------------------------------------------------------------===//
974 // Code for handling upreferences in type names...
977 // TypeContains - Returns true if Ty directly contains E in it.
979 static bool TypeContains(const Type *Ty, const Type *E) {
980 return std::find(Ty->subtype_begin(), Ty->subtype_end(),
981 E) != Ty->subtype_end();
986 // NestingLevel - The number of nesting levels that need to be popped before
987 // this type is resolved.
988 unsigned NestingLevel;
990 // LastContainedTy - This is the type at the current binding level for the
991 // type. Every time we reduce the nesting level, this gets updated.
992 const Type *LastContainedTy;
994 // UpRefTy - This is the actual opaque type that the upreference is
998 UpRefRecord(unsigned NL, OpaqueType *URTy)
999 : NestingLevel(NL), LastContainedTy(URTy), UpRefTy(URTy) {}
1003 // UpRefs - A list of the outstanding upreferences that need to be resolved.
1004 static std::vector<UpRefRecord> UpRefs;
1006 /// HandleUpRefs - Every time we finish a new layer of types, this function is
1007 /// called. It loops through the UpRefs vector, which is a list of the
1008 /// currently active types. For each type, if the up reference is contained in
1009 /// the newly completed type, we decrement the level count. When the level
1010 /// count reaches zero, the upreferenced type is the type that is passed in:
1011 /// thus we can complete the cycle.
1013 static PATypeHolder HandleUpRefs(const Type *ty) {
1014 // If Ty isn't abstract, or if there are no up-references in it, then there is
1015 // nothing to resolve here.
1016 if (!ty->isAbstract() || UpRefs.empty()) return ty;
1018 PATypeHolder Ty(ty);
1019 UR_OUT("Type '" << Ty->getDescription() <<
1020 "' newly formed. Resolving upreferences.\n" <<
1021 UpRefs.size() << " upreferences active!\n");
1023 // If we find any resolvable upreferences (i.e., those whose NestingLevel goes
1024 // to zero), we resolve them all together before we resolve them to Ty. At
1025 // the end of the loop, if there is anything to resolve to Ty, it will be in
1027 OpaqueType *TypeToResolve = 0;
1029 for (unsigned i = 0; i != UpRefs.size(); ++i) {
1030 UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
1031 << UpRefs[i].second->getDescription() << ") = "
1032 << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n");
1033 if (TypeContains(Ty, UpRefs[i].LastContainedTy)) {
1034 // Decrement level of upreference
1035 unsigned Level = --UpRefs[i].NestingLevel;
1036 UpRefs[i].LastContainedTy = Ty;
1037 UR_OUT(" Uplevel Ref Level = " << Level << "\n");
1038 if (Level == 0) { // Upreference should be resolved!
1039 if (!TypeToResolve) {
1040 TypeToResolve = UpRefs[i].UpRefTy;
1042 UR_OUT(" * Resolving upreference for "
1043 << UpRefs[i].second->getDescription() << "\n";
1044 std::string OldName = UpRefs[i].UpRefTy->getDescription());
1045 UpRefs[i].UpRefTy->refineAbstractTypeTo(TypeToResolve);
1046 UR_OUT(" * Type '" << OldName << "' refined upreference to: "
1047 << (const void*)Ty << ", " << Ty->getDescription() << "\n");
1049 UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list...
1050 --i; // Do not skip the next element...
1055 if (TypeToResolve) {
1056 UR_OUT(" * Resolving upreference for "
1057 << UpRefs[i].second->getDescription() << "\n";
1058 std::string OldName = TypeToResolve->getDescription());
1059 TypeToResolve->refineAbstractTypeTo(Ty);
1065 //===----------------------------------------------------------------------===//
1066 // RunVMAsmParser - Define an interface to this parser
1067 //===----------------------------------------------------------------------===//
1069 static Module* RunParser(Module * M);
1071 Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) {
1074 CurFilename = Filename;
1075 return RunParser(new Module(CurFilename));
1078 Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
1079 set_scan_string(AsmString);
1081 CurFilename = "from_memory";
1083 return RunParser(new Module (CurFilename));
1085 return RunParser(M);
1090 #line 955 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
1092 llvm::Module *ModuleVal;
1093 llvm::Function *FunctionVal;
1094 llvm::BasicBlock *BasicBlockVal;
1095 llvm::TerminatorInst *TermInstVal;
1096 llvm::Instruction *InstVal;
1097 llvm::Constant *ConstVal;
1099 const llvm::Type *PrimType;
1100 std::list<llvm::PATypeHolder> *TypeList;
1101 llvm::PATypeHolder *TypeVal;
1102 llvm::Value *ValueVal;
1103 std::vector<llvm::Value*> *ValueList;
1104 llvm::ArgListType *ArgList;
1105 llvm::TypeWithAttrs TypeWithAttrs;
1106 llvm::TypeWithAttrsList *TypeWithAttrsList;
1107 llvm::ValueRefList *ValueRefList;
1109 // Represent the RHS of PHI node
1110 std::list<std::pair<llvm::Value*,
1111 llvm::BasicBlock*> > *PHIList;
1112 std::vector<std::pair<llvm::Constant*, llvm::BasicBlock*> > *JumpTable;
1113 std::vector<llvm::Constant*> *ConstVector;
1115 llvm::GlobalValue::LinkageTypes Linkage;
1116 llvm::GlobalValue::VisibilityTypes Visibility;
1117 uint16_t ParamAttrs;
1118 llvm::APInt *APIntVal;
1126 char *StrVal; // This memory is strdup'd!
1127 llvm::ValID ValIDVal; // strdup'd memory maybe!
1129 llvm::Instruction::BinaryOps BinaryOpVal;
1130 llvm::Instruction::TermOps TermOpVal;
1131 llvm::Instruction::MemoryOps MemOpVal;
1132 llvm::Instruction::CastOps CastOpVal;
1133 llvm::Instruction::OtherOps OtherOpVal;
1134 llvm::ICmpInst::Predicate IPredicate;
1135 llvm::FCmpInst::Predicate FPredicate;
1148 #define YYFLAG -32768
1149 #define YYNTBASE 151
1151 #define YYTRANSLATE(x) ((unsigned)(x) <= 390 ? yytranslate[x] : 232)
1153 static const short yytranslate[] = { 0,
1154 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1155 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1156 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1157 2, 2, 2, 2, 2, 2, 2, 2, 2, 141,
1158 142, 139, 2, 138, 2, 2, 2, 2, 2, 2,
1159 2, 2, 2, 2, 2, 2, 2, 2, 2, 146,
1160 137, 147, 2, 2, 2, 2, 2, 2, 2, 2,
1161 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1162 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1163 143, 140, 145, 2, 2, 2, 2, 2, 150, 2,
1164 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1165 2, 2, 2, 2, 2, 2, 2, 2, 2, 144,
1166 2, 2, 148, 2, 149, 2, 2, 2, 2, 2,
1167 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1168 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1169 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1170 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1171 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1172 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1176 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1177 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1179 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
1180 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1181 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
1182 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1183 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1184 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
1185 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
1186 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1187 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
1188 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
1189 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
1190 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
1191 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
1192 127, 128, 129, 130, 131, 132, 133, 134, 135, 136
1196 static const short yyprhs[] = { 0,
1197 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
1198 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
1199 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
1200 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
1201 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
1202 100, 102, 104, 106, 108, 110, 112, 114, 116, 118,
1203 119, 122, 123, 125, 127, 129, 130, 133, 135, 137,
1204 139, 141, 143, 145, 147, 149, 150, 152, 154, 156,
1205 157, 159, 161, 162, 164, 166, 168, 170, 171, 173,
1206 175, 176, 178, 180, 182, 184, 186, 189, 191, 193,
1207 195, 197, 198, 201, 203, 205, 207, 208, 211, 212,
1208 215, 216, 220, 223, 224, 226, 227, 231, 233, 236,
1209 238, 240, 242, 244, 246, 248, 251, 253, 256, 262,
1210 268, 274, 280, 284, 287, 293, 298, 301, 303, 305,
1211 307, 311, 313, 317, 319, 320, 322, 326, 331, 335,
1212 339, 344, 349, 353, 360, 366, 369, 372, 375, 378,
1213 381, 384, 387, 390, 393, 396, 399, 402, 409, 415,
1214 424, 431, 438, 446, 454, 461, 470, 479, 483, 485,
1215 487, 489, 491, 492, 495, 502, 504, 505, 507, 510,
1216 511, 515, 516, 520, 524, 528, 532, 533, 541, 542,
1217 551, 552, 561, 567, 570, 574, 576, 580, 584, 588,
1218 592, 594, 595, 601, 605, 607, 611, 613, 614, 624,
1219 626, 628, 633, 635, 637, 640, 644, 645, 647, 649,
1220 651, 653, 655, 657, 659, 661, 663, 667, 669, 675,
1221 677, 679, 681, 683, 685, 687, 690, 693, 696, 700,
1222 703, 704, 706, 709, 712, 716, 726, 736, 745, 760,
1223 762, 764, 771, 777, 780, 787, 795, 799, 805, 806,
1224 807, 811, 814, 816, 822, 828, 835, 842, 847, 854,
1225 859, 864, 871, 878, 881, 890, 892, 894, 895, 899,
1226 906, 910, 917, 920, 926, 934
1229 static const short yyrhs[] = { 69,
1230 0, 70, 0, 71, 0, 72, 0, 73, 0, 74,
1231 0, 75, 0, 76, 0, 77, 0, 81, 0, 82,
1232 0, 83, 0, 78, 0, 79, 0, 80, 0, 112,
1233 0, 113, 0, 114, 0, 115, 0, 116, 0, 117,
1234 0, 118, 0, 119, 0, 120, 0, 121, 0, 122,
1235 0, 123, 0, 86, 0, 87, 0, 88, 0, 89,
1236 0, 90, 0, 91, 0, 92, 0, 93, 0, 94,
1237 0, 95, 0, 96, 0, 97, 0, 98, 0, 99,
1238 0, 100, 0, 101, 0, 102, 0, 103, 0, 104,
1239 0, 105, 0, 92, 0, 93, 0, 94, 0, 95,
1240 0, 22, 0, 23, 0, 11, 0, 12, 0, 13,
1241 0, 16, 0, 19, 0, 158, 0, 0, 158, 137,
1242 0, 0, 17, 0, 20, 0, 163, 0, 0, 161,
1243 137, 0, 38, 0, 40, 0, 39, 0, 41, 0,
1244 43, 0, 42, 0, 44, 0, 46, 0, 0, 134,
1245 0, 135, 0, 136, 0, 0, 42, 0, 44, 0,
1246 0, 38, 0, 39, 0, 40, 0, 43, 0, 0,
1247 40, 0, 38, 0, 0, 57, 0, 58, 0, 59,
1248 0, 60, 0, 61, 0, 56, 4, 0, 113, 0,
1249 114, 0, 131, 0, 132, 0, 0, 172, 171, 0,
1250 130, 0, 133, 0, 171, 0, 0, 174, 173, 0,
1251 0, 49, 4, 0, 0, 138, 49, 4, 0, 30,
1252 19, 0, 0, 177, 0, 0, 138, 180, 179, 0,
1253 177, 0, 49, 4, 0, 11, 0, 12, 0, 13,
1254 0, 14, 0, 45, 0, 181, 0, 182, 139, 0,
1255 216, 0, 140, 4, 0, 182, 141, 186, 142, 174,
1256 0, 10, 141, 186, 142, 174, 0, 143, 4, 144,
1257 182, 145, 0, 146, 4, 144, 182, 147, 0, 148,
1258 187, 149, 0, 148, 149, 0, 146, 148, 187, 149,
1259 147, 0, 146, 148, 149, 147, 0, 182, 172, 0,
1260 182, 0, 10, 0, 183, 0, 185, 138, 183, 0,
1261 185, 0, 185, 138, 35, 0, 35, 0, 0, 182,
1262 0, 187, 138, 182, 0, 182, 143, 190, 145, 0,
1263 182, 143, 145, 0, 182, 150, 19, 0, 182, 146,
1264 190, 147, 0, 182, 148, 190, 149, 0, 182, 148,
1265 149, 0, 182, 146, 148, 190, 149, 147, 0, 182,
1266 146, 148, 149, 147, 0, 182, 36, 0, 182, 37,
1267 0, 182, 216, 0, 182, 189, 0, 182, 21, 0,
1268 156, 3, 0, 156, 5, 0, 156, 4, 0, 156,
1269 6, 0, 11, 22, 0, 11, 23, 0, 157, 9,
1270 0, 153, 141, 188, 34, 182, 142, 0, 111, 141,
1271 188, 227, 142, 0, 125, 141, 188, 138, 188, 138,
1272 188, 142, 0, 151, 141, 188, 138, 188, 142, 0,
1273 152, 141, 188, 138, 188, 142, 0, 84, 154, 141,
1274 188, 138, 188, 142, 0, 85, 155, 141, 188, 138,
1275 188, 142, 0, 127, 141, 188, 138, 188, 142, 0,
1276 128, 141, 188, 138, 188, 138, 188, 142, 0, 129,
1277 141, 188, 138, 188, 138, 188, 142, 0, 190, 138,
1278 188, 0, 188, 0, 28, 0, 29, 0, 33, 0,
1279 0, 184, 216, 0, 117, 141, 193, 34, 182, 142,
1280 0, 195, 0, 0, 196, 0, 195, 196, 0, 0,
1281 27, 197, 212, 0, 0, 26, 198, 213, 0, 54,
1282 53, 202, 0, 160, 15, 182, 0, 160, 15, 10,
1283 0, 0, 162, 166, 192, 191, 188, 199, 179, 0,
1284 0, 162, 164, 166, 192, 191, 188, 200, 179, 0,
1285 0, 162, 165, 166, 192, 191, 182, 201, 179, 0,
1286 162, 166, 31, 169, 193, 0, 47, 203, 0, 50,
1287 137, 204, 0, 19, 0, 48, 137, 19, 0, 62,
1288 137, 19, 0, 143, 205, 145, 0, 205, 138, 19,
1289 0, 19, 0, 0, 206, 138, 182, 172, 159, 0,
1290 182, 172, 159, 0, 206, 0, 206, 138, 35, 0,
1291 35, 0, 0, 170, 184, 161, 141, 207, 142, 174,
1292 178, 175, 0, 24, 0, 148, 0, 168, 166, 208,
1293 209, 0, 25, 0, 149, 0, 219, 211, 0, 167,
1294 166, 208, 0, 0, 55, 0, 3, 0, 4, 0,
1295 9, 0, 22, 0, 23, 0, 36, 0, 37, 0,
1296 21, 0, 146, 190, 147, 0, 189, 0, 53, 214,
1297 19, 138, 19, 0, 7, 0, 8, 0, 158, 0,
1298 161, 0, 216, 0, 215, 0, 182, 217, 0, 219,
1299 220, 0, 210, 220, 0, 221, 160, 222, 0, 221,
1300 224, 0, 0, 18, 0, 63, 218, 0, 63, 10,
1301 0, 64, 14, 217, 0, 64, 11, 217, 138, 14,
1302 217, 138, 14, 217, 0, 65, 156, 217, 138, 14,
1303 217, 143, 223, 145, 0, 65, 156, 217, 138, 14,
1304 217, 143, 145, 0, 66, 170, 184, 217, 141, 226,
1305 142, 174, 34, 14, 217, 67, 14, 217, 0, 67,
1306 0, 68, 0, 223, 156, 215, 138, 14, 217, 0,
1307 156, 215, 138, 14, 217, 0, 160, 229, 0, 182,
1308 143, 217, 138, 217, 145, 0, 225, 138, 143, 217,
1309 138, 217, 145, 0, 182, 217, 172, 0, 226, 138,
1310 182, 217, 172, 0, 0, 0, 227, 138, 218, 0,
1311 52, 51, 0, 51, 0, 151, 182, 217, 138, 217,
1312 0, 152, 182, 217, 138, 217, 0, 84, 154, 182,
1313 217, 138, 217, 0, 85, 155, 182, 217, 138, 217,
1314 0, 153, 218, 34, 182, 0, 125, 218, 138, 218,
1315 138, 218, 0, 126, 218, 138, 182, 0, 127, 218,
1316 138, 218, 0, 128, 218, 138, 218, 138, 218, 0,
1317 129, 218, 138, 218, 138, 218, 0, 124, 225, 0,
1318 228, 170, 184, 217, 141, 226, 142, 174, 0, 231,
1319 0, 32, 0, 0, 106, 182, 176, 0, 106, 182,
1320 138, 11, 217, 176, 0, 107, 182, 176, 0, 107,
1321 182, 138, 11, 217, 176, 0, 108, 218, 0, 230,
1322 109, 182, 217, 176, 0, 230, 110, 218, 138, 182,
1323 217, 176, 0, 111, 182, 217, 227, 0
1329 static const short yyrline[] = { 0,
1330 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111, 1112,
1331 1112, 1112, 1112, 1112, 1112, 1113, 1113, 1113, 1113, 1113,
1332 1113, 1113, 1114, 1114, 1114, 1114, 1114, 1117, 1117, 1118,
1333 1118, 1119, 1119, 1120, 1120, 1121, 1121, 1125, 1125, 1126,
1334 1126, 1127, 1127, 1128, 1128, 1129, 1129, 1130, 1130, 1131,
1335 1131, 1132, 1133, 1138, 1139, 1139, 1141, 1141, 1142, 1142,
1336 1146, 1150, 1155, 1155, 1157, 1158, 1163, 1169, 1170, 1171,
1337 1172, 1173, 1177, 1178, 1179, 1183, 1184, 1185, 1186, 1190,
1338 1191, 1192, 1196, 1197, 1198, 1199, 1200, 1204, 1205, 1206,
1339 1209, 1209, 1210, 1211, 1212, 1213, 1214, 1222, 1223, 1224,
1340 1225, 1228, 1229, 1234, 1235, 1236, 1239, 1240, 1247, 1247,
1341 1254, 1254, 1263, 1271, 1271, 1277, 1277, 1279, 1284, 1297,
1342 1297, 1297, 1297, 1300, 1304, 1308, 1315, 1320, 1328, 1358,
1343 1389, 1394, 1406, 1416, 1420, 1430, 1437, 1444, 1451, 1456,
1344 1461, 1468, 1469, 1476, 1483, 1491, 1497, 1509, 1537, 1553,
1345 1582, 1610, 1636, 1656, 1682, 1702, 1714, 1721, 1787, 1797,
1346 1807, 1813, 1823, 1829, 1839, 1844, 1849, 1857, 1869, 1891,
1347 1899, 1905, 1916, 1921, 1926, 1932, 1938, 1947, 1951, 1959,
1348 1959, 1962, 1962, 1965, 1976, 1997, 2002, 2010, 2011, 2015,
1349 2015, 2019, 2019, 2022, 2025, 2049, 2060, 2067, 2070, 2076,
1350 2079, 2086, 2090, 2105, 2108, 2114, 2127, 2131, 2136, 2138,
1351 2143, 2148, 2157, 2167, 2178, 2182, 2191, 2200, 2205, 2327,
1352 2327, 2329, 2338, 2338, 2340, 2345, 2357, 2361, 2366, 2370,
1353 2374, 2378, 2382, 2386, 2390, 2394, 2398, 2423, 2427, 2441,
1354 2445, 2449, 2453, 2459, 2459, 2465, 2474, 2478, 2487, 2496,
1355 2505, 2509, 2514, 2518, 2522, 2527, 2537, 2556, 2565, 2645,
1356 2649, 2656, 2667, 2680, 2690, 2701, 2711, 2720, 2729, 2732,
1357 2733, 2740, 2744, 2749, 2770, 2787, 2801, 2815, 2827, 2835,
1358 2842, 2848, 2854, 2860, 2875, 2960, 2965, 2969, 2976, 2983,
1359 2991, 2998, 3006, 3014, 3028, 3045
1364 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
1366 static const char * const yytname[] = { "$","error","$undefined.","ESINT64VAL",
1367 "EUINT64VAL","ESAPINTVAL","EUAPINTVAL","LOCALVAL_ID","GLOBALVAL_ID","FPVAL",
1368 "VOID","INTTYPE","FLOAT","DOUBLE","LABEL","TYPE","LOCALVAR","GLOBALVAR","LABELSTR",
1369 "STRINGCONSTANT","ATSTRINGCONSTANT","ZEROINITIALIZER","TRUETOK","FALSETOK","BEGINTOK",
1370 "ENDTOK","DECLARE","DEFINE","GLOBAL","CONSTANT","SECTION","ALIAS","VOLATILE",
1371 "THREAD_LOCAL","TO","DOTDOTDOT","NULL_TOK","UNDEF","INTERNAL","LINKONCE","WEAK",
1372 "APPENDING","DLLIMPORT","DLLEXPORT","EXTERN_WEAK","OPAQUE","EXTERNAL","TARGET",
1373 "TRIPLE","ALIGN","DEPLIBS","CALL","TAIL","ASM_TOK","MODULE","SIDEEFFECT","CC_TOK",
1374 "CCC_TOK","FASTCC_TOK","COLDCC_TOK","X86_STDCALLCC_TOK","X86_FASTCALLCC_TOK",
1375 "DATALAYOUT","RET","BR","SWITCH","INVOKE","UNWIND","UNREACHABLE","ADD","SUB",
1376 "MUL","UDIV","SDIV","FDIV","UREM","SREM","FREM","AND","OR","XOR","SHL","LSHR",
1377 "ASHR","ICMP","FCMP","EQ","NE","SLT","SGT","SLE","SGE","ULT","UGT","ULE","UGE",
1378 "OEQ","ONE","OLT","OGT","OLE","OGE","ORD","UNO","UEQ","UNE","MALLOC","ALLOCA",
1379 "FREE","LOAD","STORE","GETELEMENTPTR","TRUNC","ZEXT","SEXT","FPTRUNC","FPEXT",
1380 "BITCAST","UITOFP","SITOFP","FPTOUI","FPTOSI","INTTOPTR","PTRTOINT","PHI_TOK",
1381 "SELECT","VAARG","EXTRACTELEMENT","INSERTELEMENT","SHUFFLEVECTOR","NORETURN",
1382 "INREG","SRET","NOUNWIND","DEFAULT","HIDDEN","PROTECTED","'='","','","'*'","'\\\\'",
1383 "'('","')'","'['","'x'","']'","'<'","'>'","'{'","'}'","'c'","ArithmeticOps",
1384 "LogicalOps","CastOps","IPredicates","FPredicates","IntType","FPType","LocalName",
1385 "OptLocalName","OptLocalAssign","GlobalName","OptGlobalAssign","GlobalAssign",
1386 "GVInternalLinkage","GVExternalLinkage","GVVisibilityStyle","FunctionDeclareLinkage",
1387 "FunctionDefineLinkage","AliasLinkage","OptCallingConv","ParamAttr","OptParamAttrs",
1388 "FuncAttr","OptFuncAttrs","OptAlign","OptCAlign","SectionString","OptSection",
1389 "GlobalVarAttributes","GlobalVarAttribute","PrimType","Types","ArgType","ResultTypes",
1390 "ArgTypeList","ArgTypeListI","TypeListI","ConstVal","ConstExpr","ConstVector",
1391 "GlobalType","ThreadLocal","AliaseeRef","Module","DefinitionList","Definition",
1392 "@1","@2","@3","@4","@5","AsmBlock","TargetDefinition","LibrariesDefinition",
1393 "LibList","ArgListH","ArgList","FunctionHeaderH","BEGIN","FunctionHeader","END",
1394 "Function","FunctionProto","OptSideEffect","ConstValueRef","SymbolicValueRef",
1395 "ValueRef","ResolvedVal","BasicBlockList","BasicBlock","InstructionList","BBTerminatorInst",
1396 "JumpTable","Inst","PHIList","ValueRefList","IndexList","OptTailCall","InstVal",
1397 "OptVolatile","MemoryInst", NULL
1401 static const short yyr1[] = { 0,
1402 151, 151, 151, 151, 151, 151, 151, 151, 151, 152,
1403 152, 152, 152, 152, 152, 153, 153, 153, 153, 153,
1404 153, 153, 153, 153, 153, 153, 153, 154, 154, 154,
1405 154, 154, 154, 154, 154, 154, 154, 155, 155, 155,
1406 155, 155, 155, 155, 155, 155, 155, 155, 155, 155,
1407 155, 155, 155, 156, 157, 157, 158, 158, 159, 159,
1408 160, 160, 161, 161, 162, 162, 163, 164, 164, 164,
1409 164, 164, 165, 165, 165, 166, 166, 166, 166, 167,
1410 167, 167, 168, 168, 168, 168, 168, 169, 169, 169,
1411 170, 170, 170, 170, 170, 170, 170, 171, 171, 171,
1412 171, 172, 172, 173, 173, 173, 174, 174, 175, 175,
1413 176, 176, 177, 178, 178, 179, 179, 180, 180, 181,
1414 181, 181, 181, 182, 182, 182, 182, 182, 182, 182,
1415 182, 182, 182, 182, 182, 182, 183, 184, 184, 185,
1416 185, 186, 186, 186, 186, 187, 187, 188, 188, 188,
1417 188, 188, 188, 188, 188, 188, 188, 188, 188, 188,
1418 188, 188, 188, 188, 188, 188, 188, 189, 189, 189,
1419 189, 189, 189, 189, 189, 189, 189, 190, 190, 191,
1420 191, 192, 192, 193, 193, 194, 194, 195, 195, 197,
1421 196, 198, 196, 196, 196, 196, 199, 196, 200, 196,
1422 201, 196, 196, 196, 196, 202, 203, 203, 204, 205,
1423 205, 205, 206, 206, 207, 207, 207, 207, 208, 209,
1424 209, 210, 211, 211, 212, 213, 214, 214, 215, 215,
1425 215, 215, 215, 215, 215, 215, 215, 215, 215, 216,
1426 216, 216, 216, 217, 217, 218, 219, 219, 220, 221,
1427 221, 221, 222, 222, 222, 222, 222, 222, 222, 222,
1428 222, 223, 223, 224, 225, 225, 226, 226, 226, 227,
1429 227, 228, 228, 229, 229, 229, 229, 229, 229, 229,
1430 229, 229, 229, 229, 229, 229, 230, 230, 231, 231,
1431 231, 231, 231, 231, 231, 231
1434 static 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, 1, 1, 1, 1,
1439 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1440 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1441 2, 0, 1, 1, 1, 0, 2, 1, 1, 1,
1442 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,
1443 1, 1, 0, 1, 1, 1, 1, 0, 1, 1,
1444 0, 1, 1, 1, 1, 1, 2, 1, 1, 1,
1445 1, 0, 2, 1, 1, 1, 0, 2, 0, 2,
1446 0, 3, 2, 0, 1, 0, 3, 1, 2, 1,
1447 1, 1, 1, 1, 1, 2, 1, 2, 5, 5,
1448 5, 5, 3, 2, 5, 4, 2, 1, 1, 1,
1449 3, 1, 3, 1, 0, 1, 3, 4, 3, 3,
1450 4, 4, 3, 6, 5, 2, 2, 2, 2, 2,
1451 2, 2, 2, 2, 2, 2, 2, 6, 5, 8,
1452 6, 6, 7, 7, 6, 8, 8, 3, 1, 1,
1453 1, 1, 0, 2, 6, 1, 0, 1, 2, 0,
1454 3, 0, 3, 3, 3, 3, 0, 7, 0, 8,
1455 0, 8, 5, 2, 3, 1, 3, 3, 3, 3,
1456 1, 0, 5, 3, 1, 3, 1, 0, 9, 1,
1457 1, 4, 1, 1, 2, 3, 0, 1, 1, 1,
1458 1, 1, 1, 1, 1, 1, 3, 1, 5, 1,
1459 1, 1, 1, 1, 1, 2, 2, 2, 3, 2,
1460 0, 1, 2, 2, 3, 9, 9, 8, 14, 1,
1461 1, 6, 5, 2, 6, 7, 3, 5, 0, 0,
1462 3, 2, 1, 5, 5, 6, 6, 4, 6, 4,
1463 4, 6, 6, 2, 8, 1, 1, 0, 3, 6,
1467 static const short yydefact[] = { 66,
1468 57, 63, 58, 64, 192, 190, 0, 0, 0, 0,
1469 0, 0, 76, 65, 66, 188, 80, 83, 0, 0,
1470 204, 0, 0, 61, 0, 67, 68, 70, 69, 71,
1471 73, 72, 74, 75, 77, 78, 79, 76, 76, 183,
1472 189, 81, 82, 76, 193, 84, 85, 86, 87, 76,
1473 251, 191, 251, 0, 0, 212, 205, 206, 194, 240,
1474 241, 196, 120, 121, 122, 123, 124, 0, 0, 0,
1475 0, 242, 243, 125, 195, 127, 183, 183, 88, 182,
1476 0, 91, 91, 252, 248, 62, 223, 224, 225, 247,
1477 207, 208, 211, 0, 145, 128, 0, 0, 0, 0,
1478 134, 146, 0, 126, 145, 0, 0, 90, 89, 0,
1479 180, 181, 0, 0, 92, 93, 94, 95, 96, 0,
1480 226, 0, 288, 250, 0, 209, 144, 102, 140, 142,
1481 0, 0, 0, 0, 0, 0, 133, 0, 0, 0,
1482 139, 0, 138, 0, 203, 120, 121, 122, 0, 0,
1483 0, 197, 97, 0, 220, 221, 222, 287, 273, 0,
1484 0, 0, 0, 91, 260, 261, 1, 2, 3, 4,
1485 5, 6, 7, 8, 9, 13, 14, 15, 10, 11,
1486 12, 0, 0, 0, 0, 0, 0, 16, 17, 18,
1487 19, 20, 21, 22, 23, 24, 25, 26, 27, 0,
1488 0, 0, 0, 0, 0, 0, 0, 0, 249, 91,
1489 264, 0, 286, 210, 137, 0, 107, 0, 0, 136,
1490 0, 147, 107, 199, 201, 0, 184, 165, 166, 161,
1491 163, 162, 164, 167, 160, 156, 157, 0, 0, 0,
1492 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1493 0, 159, 158, 116, 0, 272, 254, 0, 253, 0,
1494 0, 54, 0, 0, 28, 29, 30, 31, 32, 33,
1495 34, 35, 36, 37, 0, 52, 53, 48, 49, 50,
1496 51, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1497 47, 0, 111, 111, 293, 0, 0, 284, 0, 0,
1498 0, 0, 0, 0, 0, 0, 0, 0, 0, 98,
1499 99, 100, 101, 103, 143, 141, 130, 131, 132, 135,
1500 129, 116, 116, 0, 0, 0, 0, 0, 0, 0,
1501 0, 149, 179, 0, 0, 0, 153, 0, 150, 0,
1502 0, 0, 0, 198, 218, 229, 230, 231, 236, 232,
1503 233, 234, 235, 227, 0, 238, 245, 244, 246, 0,
1504 255, 0, 0, 0, 0, 0, 289, 0, 291, 270,
1505 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1506 0, 0, 0, 104, 105, 106, 108, 200, 202, 0,
1507 0, 0, 270, 0, 0, 0, 0, 0, 148, 134,
1508 146, 0, 151, 152, 0, 0, 0, 0, 0, 118,
1509 116, 217, 102, 215, 0, 228, 0, 0, 0, 0,
1510 0, 0, 0, 0, 0, 0, 296, 0, 0, 0,
1511 280, 281, 0, 0, 0, 0, 278, 0, 111, 0,
1512 0, 0, 0, 0, 0, 0, 0, 0, 178, 155,
1513 0, 0, 0, 0, 113, 119, 117, 60, 0, 107,
1514 0, 237, 0, 0, 269, 0, 0, 111, 112, 111,
1515 0, 0, 0, 0, 0, 0, 274, 275, 269, 0,
1516 294, 0, 185, 0, 0, 169, 0, 0, 0, 0,
1517 154, 0, 0, 0, 59, 214, 216, 102, 114, 0,
1518 0, 0, 0, 0, 276, 277, 290, 292, 271, 0,
1519 0, 279, 282, 283, 0, 111, 0, 0, 0, 175,
1520 0, 0, 171, 172, 168, 60, 115, 109, 239, 0,
1521 0, 102, 0, 107, 265, 0, 107, 295, 173, 174,
1522 0, 0, 0, 213, 0, 219, 0, 258, 0, 0,
1523 267, 0, 0, 266, 285, 170, 176, 177, 110, 256,
1524 0, 257, 0, 102, 0, 0, 0, 268, 0, 0,
1525 0, 0, 263, 0, 0, 262, 0, 259, 0, 0,
1529 static const short yydefgoto[] = { 249,
1530 250, 251, 275, 292, 149, 150, 72, 496, 11, 73,
1531 13, 14, 38, 39, 40, 44, 50, 110, 120, 314,
1532 215, 387, 317, 546, 367, 410, 528, 344, 411, 74,
1533 151, 129, 144, 130, 131, 103, 333, 356, 334, 113,
1534 81, 145, 579, 15, 16, 18, 17, 254, 322, 323,
1535 59, 21, 57, 94, 414, 415, 121, 157, 51, 89,
1536 52, 45, 417, 357, 76, 359, 259, 53, 85, 86,
1537 209, 550, 124, 298, 504, 427, 210, 211, 212, 213
1540 static const short yypact[] = { 58,
1541 -32768,-32768,-32768,-32768,-32768,-32768, -31, -88, 100, -74,
1542 156, -6, 492,-32768, 595,-32768, 78, 161, 76, 79,
1543 -32768, 99, 202,-32768, 1112,-32768,-32768,-32768,-32768,-32768,
1544 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 147, 147, 191,
1545 -32768,-32768,-32768, 147,-32768,-32768,-32768,-32768,-32768, 147,
1546 235,-32768, 37, 243, 256, 259,-32768,-32768,-32768,-32768,
1547 -32768, 150,-32768,-32768,-32768,-32768,-32768, 284, 300, 4,
1548 26,-32768,-32768,-32768, 169,-32768, 287, 287, 293,-32768,
1549 237, 199, 199,-32768,-32768, 95,-32768,-32768,-32768,-32768,
1550 -32768,-32768,-32768, -81, 453,-32768, 181, 184, 198, 150,
1551 -32768, 169, -97,-32768, 453, 237, 237,-32768,-32768, 956,
1552 -32768,-32768, 1148, 328,-32768,-32768,-32768,-32768,-32768, 1194,
1553 -32768, -8, 1356,-32768, 315,-32768,-32768, 169,-32768, 204,
1554 201, 1208, 1208, 208, -82, 1208,-32768, 206, 1148, 1208,
1555 150, 215, 169, 299,-32768, 96, 340, 354, 297, 355,
1556 781,-32768,-32768, 125,-32768,-32768,-32768,-32768,-32768, 314,
1557 1254, 162, 357, 199,-32768,-32768,-32768,-32768,-32768,-32768,
1558 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1559 -32768, 487, 467, 1208, 1208, 1208, 1208,-32768,-32768,-32768,
1560 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 1208,
1561 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208,-32768, 199,
1562 -32768, 187,-32768,-32768, 119, 1001,-32768, 10, 84,-32768,
1563 223, 169,-32768,-32768, 169, 956,-32768,-32768,-32768,-32768,
1564 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 487, 467, 234,
1565 236, 238, 239, 240, 1037, 1270, 260, 359, 253, 261,
1566 263,-32768,-32768, 246, 264,-32768, 150, 631,-32768, 759,
1567 759,-32768, 759, 1194,-32768,-32768,-32768,-32768,-32768,-32768,
1568 -32768,-32768,-32768,-32768, 1208,-32768,-32768,-32768,-32768,-32768,
1569 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1570 -32768, 1208, -45, -35,-32768, 631, 170, 269, 273, 274,
1571 275, 276, 278, 631, 631, 342, 1194, 1208, 1208,-32768,
1572 -32768,-32768,-32768,-32768,-32768,-32768, 2,-32768,-32768,-32768,
1573 2, 246, 246, 363, 279, 280, 1148, 1148, 1148, 1148,
1574 1148,-32768,-32768, -50, 379, -55,-32768, -69,-32768, 1148,
1575 1148, 1148, 30,-32768, 1052,-32768,-32768,-32768,-32768,-32768,
1576 -32768,-32768,-32768, 346, 1148,-32768,-32768,-32768,-32768, 281,
1577 -32768, 290, 759, 631, 631, 17,-32768, 19,-32768,-32768,
1578 759, 282, 1208, 1208, 1208, 1208, 1208, 292, 296, 1208,
1579 759, 631, 301,-32768,-32768,-32768,-32768,-32768,-32768, 1208,
1580 1148, 1148,-32768, 303, 305, 306, 307, 1148,-32768, 288,
1581 781, -68,-32768,-32768, 308, 309, 404, 430, 446,-32768,
1582 246,-32768, 169, 316, 313,-32768, 438, -49, 445, 448,
1583 327, 333, 336, 759, 471, 759, 343, 344, 759, 353,
1584 169,-32768, 356, 358, 759, 759, 169, 339, 361, 1208,
1585 49, 362, 364, -1, 1148, 1148, 1148, 1148,-32768,-32768,
1586 345, 1148, 1148, 1208,-32768,-32768,-32768, 16, 1098,-32768,
1587 367,-32768, 759, 759, 1208, 759, 759, 361,-32768, 361,
1588 1208, 759, 368, 1208, 1208, 1208,-32768,-32768, 1208, 452,
1589 -32768, 631,-32768, 1148, 1148,-32768, 369, 366, 371, 373,
1590 -32768, 370, 372, 182,-32768,-32768,-32768, 169, 106, 476,
1591 375, 374, 631, 18,-32768,-32768,-32768,-32768,-32768, 352,
1592 759,-32768,-32768,-32768, 60, 361, 376, 378, 1148,-32768,
1593 1148, 1148,-32768,-32768,-32768, 16,-32768, 472,-32768, 509,
1594 -2,-32768, 1208,-32768,-32768, 384,-32768,-32768,-32768,-32768,
1595 382, 395, 397,-32768, 536,-32768, 759,-32768, 912, 1,
1596 119, 631, 116,-32768, 2,-32768,-32768,-32768,-32768,-32768,
1597 403,-32768, 912,-32768, 528, 529, 406, 119, 759, 759,
1598 531, 480,-32768, 759, 535,-32768, 759,-32768, 554, 555,
1602 static const short yypgoto[] = { 433,
1603 460, 461, 349, 351, -162,-32768, 0, 65, 506, 11,
1604 -32768,-32768,-32768,-32768, 15,-32768,-32768,-32768, -120, -292,
1605 -407,-32768, -220,-32768, -281, 98,-32768, -272,-32768,-32768,
1606 -23, 386, -110,-32768, 493, 501, 31, -147, -228, 230,
1607 262, 377,-32768,-32768, 590,-32768,-32768,-32768,-32768,-32768,
1608 -32768,-32768,-32768,-32768,-32768,-32768, 523,-32768,-32768,-32768,
1609 -32768,-32768,-32768, -502, -137, 122, -181,-32768, 556,-32768,
1610 -32768,-32768,-32768,-32768, 128, 220,-32768,-32768,-32768,-32768
1617 static const short yytable[] = { 10,
1618 263, 75, 321, 252, 295, 458, 227, 98, 262, 154,
1619 12, 262, 369, 253, 10, 155, 19, 336, 338, 299,
1620 300, 301, 302, 303, 386, 12, 306, 424, 386, 426,
1621 20, 1, 60, 61, 3, 100, 63, 64, 65, 66,
1622 136, 1, 2, 264, 3, 4, 561, 102, 22, 388,
1623 389, 137, 77, 78, 84, 136, 125, -187, 82, 408,
1624 567, 87, 24, 126, 83, 425, 221, 425, 398, 398,
1625 67, 128, -62, 1, 2, 102, 3, 4, 409, 404,
1626 451, 128, 398, 5, 6, 10, 143, 398, 398, 307,
1627 526, 403, 366, 104, 399, 105, 143, 462, -54, -54,
1628 -54, -54, 368, 104, 7, 105, 402, 8, 218, 219,
1629 1, 9, 222, 3, 310, 311, 225, 228, 229, 42,
1630 358, 43, 358, 358, 551, 358, 418, 383, 310, 311,
1631 26, 384, 312, 313, 385, 408, 471, 258, 457, 156,
1632 486, 2, 548, 152, 4, 562, 312, 313, 104, 565,
1633 105, 99, 23, 363, 318, 533, 568, 481, 358, 534,
1634 293, 294, 258, 296, 255, 68, 358, 358, 69, 224,
1635 25, 70, 260, 71, 101, 261, 297, 258, 258, 258,
1636 258, 258, 304, 305, 258, 88, 507, 104, 508, 105,
1637 483, 430, 128, 432, 433, 434, 381, 533, 46, 47,
1638 48, 537, 143, 49, 60, 61, 386, 100, 63, 64,
1639 65, 66, 54, 1, 2, 55, 3, 4, 310, 311,
1640 58, 79, 104, 80, 105, 358, 358, 358, 310, 311,
1641 319, 310, 311, 358, 538, 384, 312, 313, 385, 499,
1642 143, 56, 67, 358, 358, 384, 312, 313, 385, 312,
1643 313, 364, 84, 252, 114, 115, 116, 117, 118, 119,
1644 386, 91, 386, 253, 111, 112, 60, 61, 365, 100,
1645 146, 147, 148, 66, 92, 1, 2, 93, 3, 4,
1646 35, 36, 37, 143, 382, 258, 358, 96, 358, 509,
1647 95, 358, 512, 513, 514, 308, 309, 358, 358, 230,
1648 231, 232, 233, 97, 67, 60, 61, 104, 104, 105,
1649 105, 401, 371, 553, 1, 2, 555, 3, 4, 80,
1650 104, 413, 105, 525, 132, 358, 358, 133, 358, 358,
1651 108, 153, 109, 214, 358, 139, 140, 68, 106, 107,
1652 69, 216, 217, 70, 358, 71, 134, 223, -55, 258,
1653 431, 258, 258, 258, 220, 226, 437, 393, 394, 395,
1654 396, 397, -56, 234, 256, 358, 441, 262, 549, 320,
1655 405, 406, 407, 358, 327, 380, 328, 339, 329, 330,
1656 331, 360, 361, 343, 362, 60, 61, 563, 100, 146,
1657 147, 148, 66, 340, 1, 2, 390, 3, 4, 68,
1658 416, 341, 69, 342, 345, 70, 372, 71, 337, 358,
1659 373, 374, 375, 376, 358, 377, 482, 370, 419, 391,
1660 392, 442, 443, 67, 429, 378, 379, 420, 449, 435,
1661 494, 358, 358, 436, 450, 498, 358, 454, 440, 358,
1662 445, 503, 446, 447, 448, 452, 453, 258, 455, 456,
1663 258, 258, 258, 459, 460, 503, 461, 495, 463, 60,
1664 61, 464, 100, 63, 64, 65, 66, 465, 1, 2,
1665 466, 3, 4, 467, 469, 487, 488, 489, 490, 479,
1666 471, 472, 492, 493, 421, 422, 423, 127, 276, 277,
1667 474, 491, 428, 475, 529, 476, 535, 67, 480, 484,
1668 425, 485, 438, 439, 500, 511, 519, 520, 521, 552,
1669 522, 523, 530, 524, 517, 518, 531, 539, 68, 540,
1670 545, 69, 547, 556, 70, 495, 71, 400, 554, 27,
1671 28, 29, 30, 31, 32, 33, 557, 34, 558, 559,
1672 566, 569, 570, 571, 574, 468, 575, 470, 577, 541,
1673 473, 542, 543, 580, 581, 206, 477, 478, 278, 279,
1674 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
1675 290, 291, 265, 266, 267, 268, 269, 270, 271, 272,
1676 273, 274, 207, 208, 501, 502, 325, 505, 506, 326,
1677 544, 123, 68, 510, -186, 69, 527, 138, 70, 135,
1678 71, 316, 324, 516, 41, 122, 515, 0, 90, -62,
1679 1, 2, 444, 3, 4, 0, 0, 0, 0, 0,
1680 5, 6, 0, 0, 532, 35, 36, 37, 0, 0,
1681 0, 0, 536, 346, 347, 0, 0, 60, 61, 348,
1682 0, 7, 0, 0, 8, 0, 1, 2, 9, 3,
1683 4, 349, 350, 351, 0, 0, 0, 0, 0, 0,
1684 0, 0, 0, 0, 0, 0, 352, 353, 560, 0,
1685 0, 0, 0, 564, 0, 0, 0, 0, 0, 0,
1686 0, 0, 0, 354, 0, 0, 0, 0, 0, 0,
1687 572, 573, 0, 0, 0, 576, 0, 0, 578, 167,
1688 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
1689 178, 179, 180, 181, 238, 239, 0, 0, 0, 0,
1690 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1691 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1692 0, 240, 188, 189, 190, 191, 192, 193, 194, 195,
1693 196, 197, 198, 199, 0, 241, 0, 242, 243, 244,
1694 0, 346, 347, 0, 0, 60, 61, 348, 0, 104,
1695 0, 105, 0, 0, 1, 2, 355, 3, 4, 349,
1696 350, 351, 0, 0, 0, 0, 0, 60, 61, 0,
1697 0, 0, 0, 0, 352, 353, 1, 2, 0, 3,
1698 4, 235, 0, 0, 0, 0, 0, 0, 0, 0,
1699 0, 354, 0, 0, 0, 0, 236, 237, 0, 0,
1700 0, 0, 0, 0, 0, 0, 0, 167, 168, 169,
1701 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
1702 180, 181, 238, 239, 0, 0, 0, 0, 0, 167,
1703 168, 169, 170, 171, 172, 173, 174, 175, 176, 177,
1704 178, 179, 180, 181, 238, 239, 0, 0, 0, 240,
1705 188, 189, 190, 191, 192, 193, 194, 195, 196, 197,
1706 198, 199, 0, 241, 0, 242, 243, 244, 0, 0,
1707 0, 240, 188, 189, 190, 191, 192, 193, 194, 195,
1708 196, 197, 198, 199, 355, 241, 0, 242, 243, 244,
1709 0, 0, 0, 0, 346, 347, 0, 0, 0, 104,
1710 348, 105, 0, 245, 0, 0, 246, 0, 247, 0,
1711 248, 0, 349, 350, 351, 0, 0, 0, 0, 0,
1712 0, 0, 0, 0, 0, 0, 0, 352, 353, 0,
1713 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1714 0, 0, 60, 61, 354, 141, 63, 64, 65, 66,
1715 0, 1, 2, 0, 3, 4, 0, 0, 0, 0,
1716 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
1717 177, 178, 179, 180, 181, 238, 239, 0, 0, 0,
1718 67, 0, 0, 0, 0, 0, 0, 60, 61, 0,
1719 100, 63, 64, 65, 66, 0, 1, 2, 0, 3,
1720 4, 0, 240, 188, 189, 190, 191, 192, 193, 194,
1721 195, 196, 197, 198, 199, 315, 241, 0, 242, 243,
1722 244, 0, 0, 60, 61, 67, 100, 146, 147, 148,
1723 66, 0, 1, 2, 0, 3, 4, 355, 60, 61,
1724 0, 100, 63, 64, 65, 66, 0, 1, 2, 0,
1725 3, 4, 142, 0, 0, 0, 0, 0, 0, 0,
1726 0, 67, 0, 0, 0, 0, 412, 0, 0, 0,
1727 0, 0, 0, 0, 0, 68, 67, 0, 69, 0,
1728 0, 70, 0, 71, 60, 61, 0, 100, 63, 64,
1729 65, 66, 0, 1, 2, 0, 3, 4, 60, 61,
1730 0, 62, 63, 64, 65, 66, 0, 1, 2, 0,
1731 3, 4, 497, 0, 0, 0, 0, 0, 0, 0,
1732 68, 0, 67, 69, 0, 0, 70, 0, 71, 0,
1733 0, 0, 0, 0, 60, 61, 67, 100, 146, 147,
1734 148, 66, 0, 1, 2, 0, 3, 4, 0, 0,
1735 0, 0, 0, 0, 0, 0, 68, 0, 0, 69,
1736 0, 332, 70, 0, 71, 0, 0, 0, 0, 0,
1737 0, 68, 67, 0, 69, 0, 0, 70, 0, 71,
1738 60, 61, 0, 141, 63, 64, 65, 66, 0, 1,
1739 2, 0, 3, 4, 60, 61, 0, 100, 63, 64,
1740 65, 66, 0, 1, 2, 0, 3, 4, 0, 0,
1741 0, 0, 0, 0, 0, 0, 0, 68, 67, 0,
1742 69, 0, 0, 70, 0, 71, 0, 0, 0, 0,
1743 0, 68, 67, 0, 69, 0, 0, 70, 0, 71,
1744 60, 61, 0, 257, 63, 64, 65, 66, 0, 1,
1745 2, 0, 3, 4, 0, 0, 60, 61, 0, 100,
1746 146, 147, 148, 66, 0, 1, 2, 68, 3, 4,
1747 69, 0, 0, 70, 0, 71, 0, 0, 67, 0,
1748 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1749 0, 0, 0, 0, 67, 0, 0, 0, 0, 0,
1750 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1751 0, 0, 0, 68, 0, 0, 69, 0, 0, 70,
1752 0, 71, 0, 0, 0, 0, 0, 68, 0, 0,
1753 69, 0, 0, 70, 0, 71, 0, 0, 0, 0,
1754 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1755 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1756 0, 0, 0, 0, 0, 0, 0, 158, 0, 0,
1757 0, 0, 0, 68, 0, 0, 69, 0, 0, 70,
1758 0, 71, 0, 0, 0, 0, 159, 160, 0, 68,
1759 0, 0, 69, 0, 0, 70, 0, 335, 161, 162,
1760 163, 164, 165, 166, 167, 168, 169, 170, 171, 172,
1761 173, 174, 175, 176, 177, 178, 179, 180, 181, 182,
1762 183, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1763 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1764 0, 184, 185, 186, 0, 0, 187, 188, 189, 190,
1765 191, 192, 193, 194, 195, 196, 197, 198, 199, 200,
1766 201, 202, 203, 204, 205
1769 static const short yycheck[] = { 0,
1770 163, 25, 223, 151, 186, 413, 144, 4, 11, 120,
1771 0, 11, 294, 151, 15, 24, 48, 246, 247, 201,
1772 202, 203, 204, 205, 317, 15, 208, 11, 321, 11,
1773 62, 16, 7, 8, 19, 10, 11, 12, 13, 14,
1774 138, 16, 17, 164, 19, 20, 549, 71, 137, 322,
1775 323, 149, 38, 39, 18, 138, 138, 0, 44, 30,
1776 563, 25, 137, 145, 50, 49, 149, 49, 138, 138,
1777 45, 95, 15, 16, 17, 99, 19, 20, 49, 149,
1778 149, 105, 138, 26, 27, 86, 110, 138, 138, 210,
1779 498, 147, 138, 139, 145, 141, 120, 147, 3, 4,
1780 5, 6, 138, 139, 47, 141, 335, 50, 132, 133,
1781 16, 54, 136, 19, 113, 114, 140, 22, 23, 42,
1782 258, 44, 260, 261, 532, 263, 355, 309, 113, 114,
1783 137, 130, 131, 132, 133, 30, 138, 161, 411, 148,
1784 142, 17, 145, 113, 20, 145, 131, 132, 139, 34,
1785 141, 148, 53, 264, 145, 138, 564, 439, 296, 142,
1786 184, 185, 186, 187, 154, 140, 304, 305, 143, 139,
1787 15, 146, 11, 148, 149, 14, 200, 201, 202, 203,
1788 204, 205, 206, 207, 208, 149, 468, 139, 470, 141,
1789 142, 373, 216, 375, 376, 377, 307, 138, 38, 39,
1790 40, 142, 226, 43, 7, 8, 499, 10, 11, 12,
1791 13, 14, 137, 16, 17, 137, 19, 20, 113, 114,
1792 19, 31, 139, 33, 141, 363, 364, 365, 113, 114,
1793 147, 113, 114, 371, 516, 130, 131, 132, 133, 460,
1794 264, 143, 45, 381, 382, 130, 131, 132, 133, 131,
1795 132, 275, 18, 401, 56, 57, 58, 59, 60, 61,
1796 553, 19, 555, 401, 28, 29, 7, 8, 292, 10,
1797 11, 12, 13, 14, 19, 16, 17, 19, 19, 20,
1798 134, 135, 136, 307, 308, 309, 424, 4, 426, 471,
1799 141, 429, 474, 475, 476, 109, 110, 435, 436, 3,
1800 4, 5, 6, 4, 45, 7, 8, 139, 139, 141,
1801 141, 335, 143, 534, 16, 17, 537, 19, 20, 33,
1802 139, 345, 141, 142, 144, 463, 464, 144, 466, 467,
1803 38, 4, 40, 19, 472, 106, 107, 140, 77, 78,
1804 143, 138, 142, 146, 482, 148, 149, 142, 9, 373,
1805 374, 375, 376, 377, 147, 141, 380, 327, 328, 329,
1806 330, 331, 9, 9, 51, 503, 390, 11, 531, 147,
1807 340, 341, 342, 511, 141, 34, 141, 19, 141, 141,
1808 141, 260, 261, 138, 263, 7, 8, 550, 10, 11,
1809 12, 13, 14, 141, 16, 17, 34, 19, 20, 140,
1810 55, 141, 143, 141, 141, 146, 138, 148, 149, 547,
1811 138, 138, 138, 138, 552, 138, 440, 296, 138, 141,
1812 141, 391, 392, 45, 143, 304, 305, 138, 398, 138,
1813 454, 569, 570, 138, 147, 459, 574, 34, 138, 577,
1814 138, 465, 138, 138, 138, 138, 138, 471, 19, 4,
1815 474, 475, 476, 138, 142, 479, 19, 458, 14, 7,
1816 8, 14, 10, 11, 12, 13, 14, 141, 16, 17,
1817 138, 19, 20, 138, 4, 445, 446, 447, 448, 141,
1818 138, 138, 452, 453, 363, 364, 365, 35, 22, 23,
1819 138, 147, 371, 138, 19, 138, 145, 45, 138, 138,
1820 49, 138, 381, 382, 138, 138, 138, 142, 138, 533,
1821 138, 142, 138, 142, 484, 485, 143, 142, 140, 142,
1822 49, 143, 14, 142, 146, 526, 148, 149, 145, 38,
1823 39, 40, 41, 42, 43, 44, 142, 46, 142, 4,
1824 138, 14, 14, 138, 14, 424, 67, 426, 14, 519,
1825 429, 521, 522, 0, 0, 123, 435, 436, 92, 93,
1826 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
1827 104, 105, 86, 87, 88, 89, 90, 91, 92, 93,
1828 94, 95, 123, 123, 463, 464, 238, 466, 467, 239,
1829 526, 86, 140, 472, 0, 143, 499, 105, 146, 99,
1830 148, 216, 226, 482, 15, 83, 479, -1, 53, 15,
1831 16, 17, 393, 19, 20, -1, -1, -1, -1, -1,
1832 26, 27, -1, -1, 503, 134, 135, 136, -1, -1,
1833 -1, -1, 511, 3, 4, -1, -1, 7, 8, 9,
1834 -1, 47, -1, -1, 50, -1, 16, 17, 54, 19,
1835 20, 21, 22, 23, -1, -1, -1, -1, -1, -1,
1836 -1, -1, -1, -1, -1, -1, 36, 37, 547, -1,
1837 -1, -1, -1, 552, -1, -1, -1, -1, -1, -1,
1838 -1, -1, -1, 53, -1, -1, -1, -1, -1, -1,
1839 569, 570, -1, -1, -1, 574, -1, -1, 577, 69,
1840 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1841 80, 81, 82, 83, 84, 85, -1, -1, -1, -1,
1842 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1843 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1844 -1, 111, 112, 113, 114, 115, 116, 117, 118, 119,
1845 120, 121, 122, 123, -1, 125, -1, 127, 128, 129,
1846 -1, 3, 4, -1, -1, 7, 8, 9, -1, 139,
1847 -1, 141, -1, -1, 16, 17, 146, 19, 20, 21,
1848 22, 23, -1, -1, -1, -1, -1, 7, 8, -1,
1849 -1, -1, -1, -1, 36, 37, 16, 17, -1, 19,
1850 20, 21, -1, -1, -1, -1, -1, -1, -1, -1,
1851 -1, 53, -1, -1, -1, -1, 36, 37, -1, -1,
1852 -1, -1, -1, -1, -1, -1, -1, 69, 70, 71,
1853 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
1854 82, 83, 84, 85, -1, -1, -1, -1, -1, 69,
1855 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
1856 80, 81, 82, 83, 84, 85, -1, -1, -1, 111,
1857 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
1858 122, 123, -1, 125, -1, 127, 128, 129, -1, -1,
1859 -1, 111, 112, 113, 114, 115, 116, 117, 118, 119,
1860 120, 121, 122, 123, 146, 125, -1, 127, 128, 129,
1861 -1, -1, -1, -1, 3, 4, -1, -1, -1, 139,
1862 9, 141, -1, 143, -1, -1, 146, -1, 148, -1,
1863 150, -1, 21, 22, 23, -1, -1, -1, -1, -1,
1864 -1, -1, -1, -1, -1, -1, -1, 36, 37, -1,
1865 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1866 -1, -1, 7, 8, 53, 10, 11, 12, 13, 14,
1867 -1, 16, 17, -1, 19, 20, -1, -1, -1, -1,
1868 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
1869 79, 80, 81, 82, 83, 84, 85, -1, -1, -1,
1870 45, -1, -1, -1, -1, -1, -1, 7, 8, -1,
1871 10, 11, 12, 13, 14, -1, 16, 17, -1, 19,
1872 20, -1, 111, 112, 113, 114, 115, 116, 117, 118,
1873 119, 120, 121, 122, 123, 35, 125, -1, 127, 128,
1874 129, -1, -1, 7, 8, 45, 10, 11, 12, 13,
1875 14, -1, 16, 17, -1, 19, 20, 146, 7, 8,
1876 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
1877 19, 20, 117, -1, -1, -1, -1, -1, -1, -1,
1878 -1, 45, -1, -1, -1, -1, 35, -1, -1, -1,
1879 -1, -1, -1, -1, -1, 140, 45, -1, 143, -1,
1880 -1, 146, -1, 148, 7, 8, -1, 10, 11, 12,
1881 13, 14, -1, 16, 17, -1, 19, 20, 7, 8,
1882 -1, 10, 11, 12, 13, 14, -1, 16, 17, -1,
1883 19, 20, 35, -1, -1, -1, -1, -1, -1, -1,
1884 140, -1, 45, 143, -1, -1, 146, -1, 148, -1,
1885 -1, -1, -1, -1, 7, 8, 45, 10, 11, 12,
1886 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
1887 -1, -1, -1, -1, -1, -1, 140, -1, -1, 143,
1888 -1, 145, 146, -1, 148, -1, -1, -1, -1, -1,
1889 -1, 140, 45, -1, 143, -1, -1, 146, -1, 148,
1890 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
1891 17, -1, 19, 20, 7, 8, -1, 10, 11, 12,
1892 13, 14, -1, 16, 17, -1, 19, 20, -1, -1,
1893 -1, -1, -1, -1, -1, -1, -1, 140, 45, -1,
1894 143, -1, -1, 146, -1, 148, -1, -1, -1, -1,
1895 -1, 140, 45, -1, 143, -1, -1, 146, -1, 148,
1896 7, 8, -1, 10, 11, 12, 13, 14, -1, 16,
1897 17, -1, 19, 20, -1, -1, 7, 8, -1, 10,
1898 11, 12, 13, 14, -1, 16, 17, 140, 19, 20,
1899 143, -1, -1, 146, -1, 148, -1, -1, 45, -1,
1900 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1901 -1, -1, -1, -1, 45, -1, -1, -1, -1, -1,
1902 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1903 -1, -1, -1, 140, -1, -1, 143, -1, -1, 146,
1904 -1, 148, -1, -1, -1, -1, -1, 140, -1, -1,
1905 143, -1, -1, 146, -1, 148, -1, -1, -1, -1,
1906 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1907 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1908 -1, -1, -1, -1, -1, -1, -1, 32, -1, -1,
1909 -1, -1, -1, 140, -1, -1, 143, -1, -1, 146,
1910 -1, 148, -1, -1, -1, -1, 51, 52, -1, 140,
1911 -1, -1, 143, -1, -1, 146, -1, 148, 63, 64,
1912 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1913 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1914 85, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1915 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1916 -1, 106, 107, 108, -1, -1, 111, 112, 113, 114,
1917 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1918 125, 126, 127, 128, 129
1920 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
1921 #line 3 "/usr/share/bison.simple"
1922 /* This file comes from bison-1.28. */
1924 /* Skeleton output parser for bison,
1925 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
1927 This program is free software; you can redistribute it and/or modify
1928 it under the terms of the GNU General Public License as published by
1929 the Free Software Foundation; either version 2, or (at your option)
1932 This program is distributed in the hope that it will be useful,
1933 but WITHOUT ANY WARRANTY; without even the implied warranty of
1934 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1935 GNU General Public License for more details.
1937 You should have received a copy of the GNU General Public License
1938 along with this program; if not, write to the Free Software
1939 Foundation, Inc., 59 Temple Place - Suite 330,
1940 Boston, MA 02111-1307, USA. */
1942 /* As a special exception, when this file is copied by Bison into a
1943 Bison output file, you may use that output file without restriction.
1944 This special exception was added by the Free Software Foundation
1945 in version 1.24 of Bison. */
1947 /* This is the parser code that is written into each bison parser
1948 when the %semantic_parser declaration is not specified in the grammar.
1949 It was written by Richard Stallman by simplifying the hairy parser
1950 used when %semantic_parser is specified. */
1952 #ifndef YYSTACK_USE_ALLOCA
1954 #define YYSTACK_USE_ALLOCA
1955 #else /* alloca not defined */
1957 #define YYSTACK_USE_ALLOCA
1958 #define alloca __builtin_alloca
1959 #else /* not GNU C. */
1960 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
1961 #define YYSTACK_USE_ALLOCA
1963 #else /* not sparc */
1964 /* We think this test detects Watcom and Microsoft C. */
1965 /* This used to test MSDOS, but that is a bad idea
1966 since that symbol is in the user namespace. */
1967 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
1968 #if 0 /* No need for malloc.h, which pollutes the namespace;
1969 instead, just don't use alloca. */
1972 #else /* not MSDOS, or __TURBOC__ */
1974 /* I don't know what this was needed for, but it pollutes the namespace.
1975 So I turned it off. rms, 2 May 1997. */
1976 /* #include <malloc.h> */
1978 #define YYSTACK_USE_ALLOCA
1979 #else /* not MSDOS, or __TURBOC__, or _AIX */
1981 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
1982 and on HPUX 10. Eventually we can turn this on. */
1983 #define YYSTACK_USE_ALLOCA
1984 #define alloca __builtin_alloca
1987 #endif /* not _AIX */
1988 #endif /* not MSDOS, or __TURBOC__ */
1989 #endif /* not sparc */
1990 #endif /* not GNU C */
1991 #endif /* alloca not defined */
1992 #endif /* YYSTACK_USE_ALLOCA not defined */
1994 #ifdef YYSTACK_USE_ALLOCA
1995 #define YYSTACK_ALLOC alloca
1997 #define YYSTACK_ALLOC malloc
2000 /* Note: there must be only one dollar sign in this file.
2001 It is replaced by the list of actions, each action
2002 as one case of the switch. */
2004 #define yyerrok (yyerrstatus = 0)
2005 #define yyclearin (yychar = YYEMPTY)
2008 #define YYACCEPT goto yyacceptlab
2009 #define YYABORT goto yyabortlab
2010 #define YYERROR goto yyerrlab1
2011 /* Like YYERROR except do call yyerror.
2012 This remains here temporarily to ease the
2013 transition to the new meaning of YYERROR, for GCC.
2014 Once GCC version 2 has supplanted version 1, this can go. */
2015 #define YYFAIL goto yyerrlab
2016 #define YYRECOVERING() (!!yyerrstatus)
2017 #define YYBACKUP(token, value) \
2019 if (yychar == YYEMPTY && yylen == 1) \
2020 { yychar = (token), yylval = (value); \
2021 yychar1 = YYTRANSLATE (yychar); \
2026 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2030 #define YYERRCODE 256
2033 #define YYLEX yylex()
2039 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
2041 #define YYLEX yylex(&yylval, &yylloc)
2043 #else /* not YYLSP_NEEDED */
2045 #define YYLEX yylex(&yylval, YYLEX_PARAM)
2047 #define YYLEX yylex(&yylval)
2049 #endif /* not YYLSP_NEEDED */
2052 /* If nonreentrant, generate the variables here */
2056 int yychar; /* the lookahead symbol */
2057 YYSTYPE yylval; /* the semantic value of the */
2058 /* lookahead symbol */
2061 YYLTYPE yylloc; /* location data for the lookahead */
2065 int yynerrs; /* number of parse errors so far */
2066 #endif /* not YYPURE */
2069 int yydebug; /* nonzero means print parse trace */
2070 /* Since this is uninitialized, it does not stop multiple parsers
2074 /* YYINITDEPTH indicates the initial size of the parser's stacks */
2077 #define YYINITDEPTH 200
2080 /* YYMAXDEPTH is the maximum size the stacks can grow to
2081 (effective only if the built-in stack extension method is used). */
2088 #define YYMAXDEPTH 10000
2091 /* Define __yy_memcpy. Note that the size argument
2092 should be passed with type unsigned int, because that is what the non-GCC
2093 definitions require. With GCC, __builtin_memcpy takes an arg
2094 of type size_t, but it can handle unsigned int. */
2096 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2097 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2098 #else /* not GNU C or C++ */
2101 /* This is the most reliable way to avoid incompatibilities
2102 in available built-in functions on various systems. */
2104 __yy_memcpy (to, from, count)
2109 register char *f = from;
2110 register char *t = to;
2111 register int i = count;
2117 #else /* __cplusplus */
2119 /* This is the most reliable way to avoid incompatibilities
2120 in available built-in functions on various systems. */
2122 __yy_memcpy (char *to, char *from, unsigned int count)
2124 register char *t = to;
2125 register char *f = from;
2126 register int i = count;
2135 #line 217 "/usr/share/bison.simple"
2137 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2138 into yyparse. The argument should have type void *.
2139 It should actually point to an object.
2140 Grammar actions can access the variable by casting it
2141 to the proper pointer type. */
2143 #ifdef YYPARSE_PARAM
2145 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2146 #define YYPARSE_PARAM_DECL
2147 #else /* not __cplusplus */
2148 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2149 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2150 #endif /* not __cplusplus */
2151 #else /* not YYPARSE_PARAM */
2152 #define YYPARSE_PARAM_ARG
2153 #define YYPARSE_PARAM_DECL
2154 #endif /* not YYPARSE_PARAM */
2156 /* Prevent warning if -Wstrict-prototypes. */
2158 #ifdef YYPARSE_PARAM
2159 int yyparse (void *);
2166 yyparse(YYPARSE_PARAM_ARG)
2169 register int yystate;
2171 register short *yyssp;
2172 register YYSTYPE *yyvsp;
2173 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2174 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2176 short yyssa[YYINITDEPTH]; /* the state stack */
2177 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2179 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2180 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2183 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2184 YYLTYPE *yyls = yylsa;
2187 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2189 #define YYPOPSTACK (yyvsp--, yyssp--)
2192 int yystacksize = YYINITDEPTH;
2193 int yyfree_stacks = 0;
2204 YYSTYPE yyval; /* the variable used to return */
2205 /* semantic values from the action */
2212 fprintf(stderr, "Starting parse\n");
2218 yychar = YYEMPTY; /* Cause a token to be read. */
2220 /* Initialize stack pointers.
2221 Waste one element of value and location stack
2222 so that they stay on the same level as the state stack.
2223 The wasted elements are never initialized. */
2231 /* Push a new state, which is found in yystate . */
2232 /* In all cases, when you get here, the value and location stacks
2233 have just been pushed. so pushing a state here evens the stacks. */
2238 if (yyssp >= yyss + yystacksize - 1)
2240 /* Give user a chance to reallocate the stack */
2241 /* Use copies of these so that the &'s don't force the real ones into memory. */
2242 YYSTYPE *yyvs1 = yyvs;
2243 short *yyss1 = yyss;
2245 YYLTYPE *yyls1 = yyls;
2248 /* Get the current used size of the three stacks, in elements. */
2249 int size = yyssp - yyss + 1;
2252 /* Each stack pointer address is followed by the size of
2253 the data in use in that stack, in bytes. */
2255 /* This used to be a conditional around just the two extra args,
2256 but that might be undefined if yyoverflow is a macro. */
2257 yyoverflow("parser stack overflow",
2258 &yyss1, size * sizeof (*yyssp),
2259 &yyvs1, size * sizeof (*yyvsp),
2260 &yyls1, size * sizeof (*yylsp),
2263 yyoverflow("parser stack overflow",
2264 &yyss1, size * sizeof (*yyssp),
2265 &yyvs1, size * sizeof (*yyvsp),
2269 yyss = yyss1; yyvs = yyvs1;
2273 #else /* no yyoverflow */
2274 /* Extend the stack our own way. */
2275 if (yystacksize >= YYMAXDEPTH)
2277 yyerror("parser stack overflow");
2289 if (yystacksize > YYMAXDEPTH)
2290 yystacksize = YYMAXDEPTH;
2291 #ifndef YYSTACK_USE_ALLOCA
2294 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2295 __yy_memcpy ((char *)yyss, (char *)yyss1,
2296 size * (unsigned int) sizeof (*yyssp));
2297 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2298 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2299 size * (unsigned int) sizeof (*yyvsp));
2301 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2302 __yy_memcpy ((char *)yyls, (char *)yyls1,
2303 size * (unsigned int) sizeof (*yylsp));
2305 #endif /* no yyoverflow */
2307 yyssp = yyss + size - 1;
2308 yyvsp = yyvs + size - 1;
2310 yylsp = yyls + size - 1;
2315 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2318 if (yyssp >= yyss + yystacksize - 1)
2324 fprintf(stderr, "Entering state %d\n", yystate);
2330 /* Do appropriate processing given the current state. */
2331 /* Read a lookahead token if we need one and don't already have one. */
2334 /* First try to decide what to do without reference to lookahead token. */
2336 yyn = yypact[yystate];
2340 /* Not known => get a lookahead token if don't already have one. */
2342 /* yychar is either YYEMPTY or YYEOF
2343 or a valid token in external form. */
2345 if (yychar == YYEMPTY)
2349 fprintf(stderr, "Reading a token: ");
2354 /* Convert token to internal form (in yychar1) for indexing tables with */
2356 if (yychar <= 0) /* This means end of input. */
2359 yychar = YYEOF; /* Don't call YYLEX any more */
2363 fprintf(stderr, "Now at end of input.\n");
2368 yychar1 = YYTRANSLATE(yychar);
2373 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2374 /* Give the individual parser a way to print the precise meaning
2375 of a token, for further debugging info. */
2377 YYPRINT (stderr, yychar, yylval);
2379 fprintf (stderr, ")\n");
2385 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2390 /* yyn is what to do for this token type in this state.
2391 Negative => reduce, -yyn is rule number.
2392 Positive => shift, yyn is new state.
2393 New state is final state => don't bother to shift,
2394 just return success.
2395 0, or most negative number => error. */
2410 /* Shift the lookahead token. */
2414 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2417 /* Discard the token being shifted unless it is eof. */
2418 if (yychar != YYEOF)
2426 /* count tokens shifted since error; after three, turn off error status. */
2427 if (yyerrstatus) yyerrstatus--;
2432 /* Do the default action for the current state. */
2435 yyn = yydefact[yystate];
2439 /* Do a reduction. yyn is the number of a rule to reduce with. */
2443 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2450 fprintf (stderr, "Reducing via rule %d (line %d), ",
2453 /* Print the symbols being reduced, and their result. */
2454 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2455 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2456 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2464 #line 1117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2465 { yyval.IPredicate = ICmpInst::ICMP_EQ; ;
2468 #line 1117 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2469 { yyval.IPredicate = ICmpInst::ICMP_NE; ;
2472 #line 1118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2473 { yyval.IPredicate = ICmpInst::ICMP_SLT; ;
2476 #line 1118 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2477 { yyval.IPredicate = ICmpInst::ICMP_SGT; ;
2480 #line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2481 { yyval.IPredicate = ICmpInst::ICMP_SLE; ;
2484 #line 1119 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2485 { yyval.IPredicate = ICmpInst::ICMP_SGE; ;
2488 #line 1120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2489 { yyval.IPredicate = ICmpInst::ICMP_ULT; ;
2492 #line 1120 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2493 { yyval.IPredicate = ICmpInst::ICMP_UGT; ;
2496 #line 1121 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2497 { yyval.IPredicate = ICmpInst::ICMP_ULE; ;
2500 #line 1121 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2501 { yyval.IPredicate = ICmpInst::ICMP_UGE; ;
2504 #line 1125 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2505 { yyval.FPredicate = FCmpInst::FCMP_OEQ; ;
2508 #line 1125 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2509 { yyval.FPredicate = FCmpInst::FCMP_ONE; ;
2512 #line 1126 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2513 { yyval.FPredicate = FCmpInst::FCMP_OLT; ;
2516 #line 1126 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2517 { yyval.FPredicate = FCmpInst::FCMP_OGT; ;
2520 #line 1127 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2521 { yyval.FPredicate = FCmpInst::FCMP_OLE; ;
2524 #line 1127 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2525 { yyval.FPredicate = FCmpInst::FCMP_OGE; ;
2528 #line 1128 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2529 { yyval.FPredicate = FCmpInst::FCMP_ORD; ;
2532 #line 1128 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2533 { yyval.FPredicate = FCmpInst::FCMP_UNO; ;
2536 #line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2537 { yyval.FPredicate = FCmpInst::FCMP_UEQ; ;
2540 #line 1129 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2541 { yyval.FPredicate = FCmpInst::FCMP_UNE; ;
2544 #line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2545 { yyval.FPredicate = FCmpInst::FCMP_ULT; ;
2548 #line 1130 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2549 { yyval.FPredicate = FCmpInst::FCMP_UGT; ;
2552 #line 1131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2553 { yyval.FPredicate = FCmpInst::FCMP_ULE; ;
2556 #line 1131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2557 { yyval.FPredicate = FCmpInst::FCMP_UGE; ;
2560 #line 1132 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2561 { yyval.FPredicate = FCmpInst::FCMP_TRUE; ;
2564 #line 1133 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2565 { yyval.FPredicate = FCmpInst::FCMP_FALSE; ;
2568 #line 1142 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2569 { yyval.StrVal = 0; ;
2572 #line 1146 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2574 yyval.StrVal = yyvsp[-1].StrVal;
2579 #line 1150 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2586 #line 1158 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2593 #line 1163 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2595 yyval.StrVal = yyvsp[-1].StrVal;
2600 #line 1169 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2601 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2604 #line 1170 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2605 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2608 #line 1171 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2609 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2612 #line 1172 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2613 { yyval.Linkage = GlobalValue::AppendingLinkage; ;
2616 #line 1173 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2617 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2620 #line 1177 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2621 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2624 #line 1178 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2625 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2628 #line 1179 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2629 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2632 #line 1183 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2633 { yyval.Visibility = GlobalValue::DefaultVisibility; ;
2636 #line 1184 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2637 { yyval.Visibility = GlobalValue::DefaultVisibility; ;
2640 #line 1185 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2641 { yyval.Visibility = GlobalValue::HiddenVisibility; ;
2644 #line 1186 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2645 { yyval.Visibility = GlobalValue::ProtectedVisibility; ;
2648 #line 1190 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2649 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2652 #line 1191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2653 { yyval.Linkage = GlobalValue::DLLImportLinkage; ;
2656 #line 1192 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2657 { yyval.Linkage = GlobalValue::ExternalWeakLinkage; ;
2660 #line 1196 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2661 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2664 #line 1197 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2665 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2668 #line 1198 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2669 { yyval.Linkage = GlobalValue::LinkOnceLinkage; ;
2672 #line 1199 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2673 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2676 #line 1200 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2677 { yyval.Linkage = GlobalValue::DLLExportLinkage; ;
2680 #line 1204 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2681 { yyval.Linkage = GlobalValue::ExternalLinkage; ;
2684 #line 1205 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2685 { yyval.Linkage = GlobalValue::WeakLinkage; ;
2688 #line 1206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2689 { yyval.Linkage = GlobalValue::InternalLinkage; ;
2692 #line 1209 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2693 { yyval.UIntVal = CallingConv::C; ;
2696 #line 1210 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2697 { yyval.UIntVal = CallingConv::C; ;
2700 #line 1211 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2701 { yyval.UIntVal = CallingConv::Fast; ;
2704 #line 1212 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2705 { yyval.UIntVal = CallingConv::Cold; ;
2708 #line 1213 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2709 { yyval.UIntVal = CallingConv::X86_StdCall; ;
2712 #line 1214 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2713 { yyval.UIntVal = CallingConv::X86_FastCall; ;
2716 #line 1215 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2718 if ((unsigned)yyvsp[0].UInt64Val != yyvsp[0].UInt64Val)
2719 GEN_ERROR("Calling conv too large");
2720 yyval.UIntVal = yyvsp[0].UInt64Val;
2725 #line 1222 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2726 { yyval.ParamAttrs = ParamAttr::ZExt; ;
2729 #line 1223 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2730 { yyval.ParamAttrs = ParamAttr::SExt; ;
2733 #line 1224 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2734 { yyval.ParamAttrs = ParamAttr::InReg; ;
2737 #line 1225 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2738 { yyval.ParamAttrs = ParamAttr::StructRet; ;
2741 #line 1228 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2742 { yyval.ParamAttrs = ParamAttr::None; ;
2745 #line 1229 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2747 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2751 #line 1234 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2752 { yyval.ParamAttrs = ParamAttr::NoReturn; ;
2755 #line 1235 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2756 { yyval.ParamAttrs = ParamAttr::NoUnwind; ;
2759 #line 1239 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2760 { yyval.ParamAttrs = ParamAttr::None; ;
2763 #line 1240 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2765 yyval.ParamAttrs = yyvsp[-1].ParamAttrs | yyvsp[0].ParamAttrs;
2769 #line 1247 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2770 { yyval.UIntVal = 0; ;
2773 #line 1248 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2775 yyval.UIntVal = yyvsp[0].UInt64Val;
2776 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2777 GEN_ERROR("Alignment must be a power of two");
2782 #line 1254 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2783 { yyval.UIntVal = 0; ;
2786 #line 1255 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2788 yyval.UIntVal = yyvsp[0].UInt64Val;
2789 if (yyval.UIntVal != 0 && !isPowerOf2_32(yyval.UIntVal))
2790 GEN_ERROR("Alignment must be a power of two");
2795 #line 1263 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2797 for (unsigned i = 0, e = strlen(yyvsp[0].StrVal); i != e; ++i)
2798 if (yyvsp[0].StrVal[i] == '"' || yyvsp[0].StrVal[i] == '\\')
2799 GEN_ERROR("Invalid character in section name");
2800 yyval.StrVal = yyvsp[0].StrVal;
2805 #line 1271 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2806 { yyval.StrVal = 0; ;
2809 #line 1272 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2810 { yyval.StrVal = yyvsp[0].StrVal; ;
2813 #line 1277 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2817 #line 1278 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2821 #line 1279 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2823 CurGV->setSection(yyvsp[0].StrVal);
2824 free(yyvsp[0].StrVal);
2829 #line 1284 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2831 if (yyvsp[0].UInt64Val != 0 && !isPowerOf2_32(yyvsp[0].UInt64Val))
2832 GEN_ERROR("Alignment must be a power of two");
2833 CurGV->setAlignment(yyvsp[0].UInt64Val);
2838 #line 1300 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2840 yyval.TypeVal = new PATypeHolder(OpaqueType::get());
2845 #line 1304 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2847 yyval.TypeVal = new PATypeHolder(yyvsp[0].PrimType);
2852 #line 1308 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2854 if (*yyvsp[-1].TypeVal == Type::LabelTy)
2855 GEN_ERROR("Cannot form a pointer to a basic block");
2856 yyval.TypeVal = new PATypeHolder(HandleUpRefs(PointerType::get(*yyvsp[-1].TypeVal)));
2857 delete yyvsp[-1].TypeVal;
2862 #line 1315 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2863 { // Named types are also simple types...
2864 const Type* tmp = getTypeVal(yyvsp[0].ValIDVal);
2866 yyval.TypeVal = new PATypeHolder(tmp);
2870 #line 1320 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2871 { // Type UpReference
2872 if (yyvsp[0].UInt64Val > (uint64_t)~0U) GEN_ERROR("Value out of range");
2873 OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder
2874 UpRefs.push_back(UpRefRecord((unsigned)yyvsp[0].UInt64Val, OT)); // Add to vector...
2875 yyval.TypeVal = new PATypeHolder(OT);
2876 UR_OUT("New Upreference!\n");
2881 #line 1328 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2883 std::vector<const Type*> Params;
2884 ParamAttrsVector Attrs;
2885 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
2886 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
2890 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
2891 for (; I != E; ++I, ++index) {
2892 const Type *Ty = I->Ty->get();
2893 Params.push_back(Ty);
2894 if (Ty != Type::VoidTy)
2895 if (I->Attrs != ParamAttr::None) {
2896 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
2900 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2901 if (isVarArg) Params.pop_back();
2903 ParamAttrsList *ActualAttrs = 0;
2905 ActualAttrs = ParamAttrsList::get(Attrs);
2906 FunctionType *FT = FunctionType::get(*yyvsp[-4].TypeVal, Params, isVarArg, ActualAttrs);
2907 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2908 delete yyvsp[-4].TypeVal; // Delete the return type handle
2909 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
2914 #line 1358 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2916 std::vector<const Type*> Params;
2917 ParamAttrsVector Attrs;
2918 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
2919 ParamAttrsWithIndex X; X.index = 0; X.attrs = yyvsp[0].ParamAttrs;
2922 TypeWithAttrsList::iterator I = yyvsp[-2].TypeWithAttrsList->begin(), E = yyvsp[-2].TypeWithAttrsList->end();
2924 for ( ; I != E; ++I, ++index) {
2925 const Type* Ty = I->Ty->get();
2926 Params.push_back(Ty);
2927 if (Ty != Type::VoidTy)
2928 if (I->Attrs != ParamAttr::None) {
2929 ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs;
2933 bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
2934 if (isVarArg) Params.pop_back();
2936 ParamAttrsList *ActualAttrs = 0;
2938 ActualAttrs = ParamAttrsList::get(Attrs);
2940 FunctionType *FT = FunctionType::get(yyvsp[-4].PrimType, Params, isVarArg, ActualAttrs);
2941 delete yyvsp[-2].TypeWithAttrsList; // Delete the argument list
2942 yyval.TypeVal = new PATypeHolder(HandleUpRefs(FT));
2947 #line 1389 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2948 { // Sized array type?
2949 yyval.TypeVal = new PATypeHolder(HandleUpRefs(ArrayType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2950 delete yyvsp[-1].TypeVal;
2955 #line 1394 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2957 const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
2958 if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
2959 GEN_ERROR("Unsigned result not equal to signed result");
2960 if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
2961 GEN_ERROR("Element type of a VectorType must be primitive");
2962 if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
2963 GEN_ERROR("Vector length should be a power of 2");
2964 yyval.TypeVal = new PATypeHolder(HandleUpRefs(VectorType::get(*yyvsp[-1].TypeVal, (unsigned)yyvsp[-3].UInt64Val)));
2965 delete yyvsp[-1].TypeVal;
2970 #line 1406 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2971 { // Structure type?
2972 std::vector<const Type*> Elements;
2973 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-1].TypeList->begin(),
2974 E = yyvsp[-1].TypeList->end(); I != E; ++I)
2975 Elements.push_back(*I);
2977 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements)));
2978 delete yyvsp[-1].TypeList;
2983 #line 1416 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2984 { // Empty structure type?
2985 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>()));
2990 #line 1420 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
2992 std::vector<const Type*> Elements;
2993 for (std::list<llvm::PATypeHolder>::iterator I = yyvsp[-2].TypeList->begin(),
2994 E = yyvsp[-2].TypeList->end(); I != E; ++I)
2995 Elements.push_back(*I);
2997 yyval.TypeVal = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true)));
2998 delete yyvsp[-2].TypeList;
3003 #line 1430 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3004 { // Empty structure type?
3005 yyval.TypeVal = new PATypeHolder(StructType::get(std::vector<const Type*>(), true));
3010 #line 1437 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3012 yyval.TypeWithAttrs.Ty = yyvsp[-1].TypeVal;
3013 yyval.TypeWithAttrs.Attrs = yyvsp[0].ParamAttrs;
3017 #line 1444 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3019 if (!UpRefs.empty())
3020 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3021 if (!(*yyvsp[0].TypeVal)->isFirstClassType())
3022 GEN_ERROR("LLVM functions cannot return aggregate types");
3023 yyval.TypeVal = yyvsp[0].TypeVal;
3027 #line 1451 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3029 yyval.TypeVal = new PATypeHolder(Type::VoidTy);
3033 #line 1456 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3035 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3036 yyval.TypeWithAttrsList->push_back(yyvsp[0].TypeWithAttrs);
3041 #line 1461 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3043 (yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList)->push_back(yyvsp[0].TypeWithAttrs);
3048 #line 1469 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3050 yyval.TypeWithAttrsList=yyvsp[-2].TypeWithAttrsList;
3051 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3052 TWA.Ty = new PATypeHolder(Type::VoidTy);
3053 yyval.TypeWithAttrsList->push_back(TWA);
3058 #line 1476 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3060 yyval.TypeWithAttrsList = new TypeWithAttrsList;
3061 TypeWithAttrs TWA; TWA.Attrs = ParamAttr::None;
3062 TWA.Ty = new PATypeHolder(Type::VoidTy);
3063 yyval.TypeWithAttrsList->push_back(TWA);
3068 #line 1483 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3070 yyval.TypeWithAttrsList = new TypeWithAttrsList();
3075 #line 1491 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3077 yyval.TypeList = new std::list<PATypeHolder>();
3078 yyval.TypeList->push_back(*yyvsp[0].TypeVal);
3079 delete yyvsp[0].TypeVal;
3084 #line 1497 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3086 (yyval.TypeList=yyvsp[-2].TypeList)->push_back(*yyvsp[0].TypeVal);
3087 delete yyvsp[0].TypeVal;
3092 #line 1509 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3093 { // Nonempty unsized arr
3094 if (!UpRefs.empty())
3095 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3096 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-3].TypeVal->get());
3098 GEN_ERROR("Cannot make array constant with type: '" +
3099 (*yyvsp[-3].TypeVal)->getDescription() + "'");
3100 const Type *ETy = ATy->getElementType();
3101 int NumElements = ATy->getNumElements();
3103 // Verify that we have the correct size...
3104 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
3105 GEN_ERROR("Type mismatch: constant sized array initialized with " +
3106 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
3107 itostr(NumElements) + "");
3109 // Verify all elements are correct type!
3110 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3111 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3112 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3113 ETy->getDescription() +"' as required!\nIt is of type '"+
3114 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3117 yyval.ConstVal = ConstantArray::get(ATy, *yyvsp[-1].ConstVector);
3118 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
3123 #line 1537 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3125 if (!UpRefs.empty())
3126 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3127 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
3129 GEN_ERROR("Cannot make array constant with type: '" +
3130 (*yyvsp[-2].TypeVal)->getDescription() + "'");
3132 int NumElements = ATy->getNumElements();
3133 if (NumElements != -1 && NumElements != 0)
3134 GEN_ERROR("Type mismatch: constant sized array initialized with 0"
3135 " arguments, but has size of " + itostr(NumElements) +"");
3136 yyval.ConstVal = ConstantArray::get(ATy, std::vector<Constant*>());
3137 delete yyvsp[-2].TypeVal;
3142 #line 1553 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3144 if (!UpRefs.empty())
3145 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3146 const ArrayType *ATy = dyn_cast<ArrayType>(yyvsp[-2].TypeVal->get());
3148 GEN_ERROR("Cannot make array constant with type: '" +
3149 (*yyvsp[-2].TypeVal)->getDescription() + "'");
3151 int NumElements = ATy->getNumElements();
3152 const Type *ETy = ATy->getElementType();
3153 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3154 if (NumElements != -1 && NumElements != (EndStr-yyvsp[0].StrVal))
3155 GEN_ERROR("Can't build string constant of size " +
3156 itostr((int)(EndStr-yyvsp[0].StrVal)) +
3157 " when array has size " + itostr(NumElements) + "");
3158 std::vector<Constant*> Vals;
3159 if (ETy == Type::Int8Ty) {
3160 for (unsigned char *C = (unsigned char *)yyvsp[0].StrVal;
3161 C != (unsigned char*)EndStr; ++C)
3162 Vals.push_back(ConstantInt::get(ETy, *C));
3164 free(yyvsp[0].StrVal);
3165 GEN_ERROR("Cannot build string arrays of non byte sized elements");
3167 free(yyvsp[0].StrVal);
3168 yyval.ConstVal = ConstantArray::get(ATy, Vals);
3169 delete yyvsp[-2].TypeVal;
3174 #line 1582 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3175 { // Nonempty unsized arr
3176 if (!UpRefs.empty())
3177 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
3178 const VectorType *PTy = dyn_cast<VectorType>(yyvsp[-3].TypeVal->get());
3180 GEN_ERROR("Cannot make packed constant with type: '" +
3181 (*yyvsp[-3].TypeVal)->getDescription() + "'");
3182 const Type *ETy = PTy->getElementType();
3183 int NumElements = PTy->getNumElements();
3185 // Verify that we have the correct size...
3186 if (NumElements != -1 && NumElements != (int)yyvsp[-1].ConstVector->size())
3187 GEN_ERROR("Type mismatch: constant sized packed initialized with " +
3188 utostr(yyvsp[-1].ConstVector->size()) + " arguments, but has size of " +
3189 itostr(NumElements) + "");
3191 // Verify all elements are correct type!
3192 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
3193 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
3194 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
3195 ETy->getDescription() +"' as required!\nIt is of type '"+
3196 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
3199 yyval.ConstVal = ConstantVector::get(PTy, *yyvsp[-1].ConstVector);
3200 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
3205 #line 1610 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3207 const StructType *STy = dyn_cast<StructType>(yyvsp[-3].TypeVal->get());
3209 GEN_ERROR("Cannot make struct constant with type: '" +
3210 (*yyvsp[-3].TypeVal)->getDescription() + "'");
3212 if (yyvsp[-1].ConstVector->size() != STy->getNumContainedTypes())
3213 GEN_ERROR("Illegal number of initializers for structure type");
3215 // Check to ensure that constants are compatible with the type initializer!
3216 for (unsigned i = 0, e = yyvsp[-1].ConstVector->size(); i != e; ++i)
3217 if ((*yyvsp[-1].ConstVector)[i]->getType() != STy->getElementType(i))
3218 GEN_ERROR("Expected type '" +
3219 STy->getElementType(i)->getDescription() +
3220 "' for element #" + utostr(i) +
3221 " of structure initializer");
3223 // Check to ensure that Type is not packed
3224 if (STy->isPacked())
3225 GEN_ERROR("Unpacked Initializer to vector type '" +
3226 STy->getDescription() + "'");
3228 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-1].ConstVector);
3229 delete yyvsp[-3].TypeVal; delete yyvsp[-1].ConstVector;
3234 #line 1636 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3236 if (!UpRefs.empty())
3237 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3238 const StructType *STy = dyn_cast<StructType>(yyvsp[-2].TypeVal->get());
3240 GEN_ERROR("Cannot make struct constant with type: '" +
3241 (*yyvsp[-2].TypeVal)->getDescription() + "'");
3243 if (STy->getNumContainedTypes() != 0)
3244 GEN_ERROR("Illegal number of initializers for structure type");
3246 // Check to ensure that Type is not packed
3247 if (STy->isPacked())
3248 GEN_ERROR("Unpacked Initializer to vector type '" +
3249 STy->getDescription() + "'");
3251 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3252 delete yyvsp[-2].TypeVal;
3257 #line 1656 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3259 const StructType *STy = dyn_cast<StructType>(yyvsp[-5].TypeVal->get());
3261 GEN_ERROR("Cannot make struct constant with type: '" +
3262 (*yyvsp[-5].TypeVal)->getDescription() + "'");
3264 if (yyvsp[-2].ConstVector->size() != STy->getNumContainedTypes())
3265 GEN_ERROR("Illegal number of initializers for structure type");
3267 // Check to ensure that constants are compatible with the type initializer!
3268 for (unsigned i = 0, e = yyvsp[-2].ConstVector->size(); i != e; ++i)
3269 if ((*yyvsp[-2].ConstVector)[i]->getType() != STy->getElementType(i))
3270 GEN_ERROR("Expected type '" +
3271 STy->getElementType(i)->getDescription() +
3272 "' for element #" + utostr(i) +
3273 " of structure initializer");
3275 // Check to ensure that Type is packed
3276 if (!STy->isPacked())
3277 GEN_ERROR("Vector initializer to non-vector type '" +
3278 STy->getDescription() + "'");
3280 yyval.ConstVal = ConstantStruct::get(STy, *yyvsp[-2].ConstVector);
3281 delete yyvsp[-5].TypeVal; delete yyvsp[-2].ConstVector;
3286 #line 1682 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3288 if (!UpRefs.empty())
3289 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
3290 const StructType *STy = dyn_cast<StructType>(yyvsp[-4].TypeVal->get());
3292 GEN_ERROR("Cannot make struct constant with type: '" +
3293 (*yyvsp[-4].TypeVal)->getDescription() + "'");
3295 if (STy->getNumContainedTypes() != 0)
3296 GEN_ERROR("Illegal number of initializers for structure type");
3298 // Check to ensure that Type is packed
3299 if (!STy->isPacked())
3300 GEN_ERROR("Vector initializer to non-vector type '" +
3301 STy->getDescription() + "'");
3303 yyval.ConstVal = ConstantStruct::get(STy, std::vector<Constant*>());
3304 delete yyvsp[-4].TypeVal;
3309 #line 1702 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3311 if (!UpRefs.empty())
3312 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3313 const PointerType *PTy = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3315 GEN_ERROR("Cannot make null pointer constant with type: '" +
3316 (*yyvsp[-1].TypeVal)->getDescription() + "'");
3318 yyval.ConstVal = ConstantPointerNull::get(PTy);
3319 delete yyvsp[-1].TypeVal;
3324 #line 1714 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3326 if (!UpRefs.empty())
3327 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3328 yyval.ConstVal = UndefValue::get(yyvsp[-1].TypeVal->get());
3329 delete yyvsp[-1].TypeVal;
3334 #line 1721 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3336 if (!UpRefs.empty())
3337 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3338 const PointerType *Ty = dyn_cast<PointerType>(yyvsp[-1].TypeVal->get());
3340 GEN_ERROR("Global const reference must be a pointer type");
3342 // ConstExprs can exist in the body of a function, thus creating
3343 // GlobalValues whenever they refer to a variable. Because we are in
3344 // the context of a function, getExistingVal will search the functions
3345 // symbol table instead of the module symbol table for the global symbol,
3346 // which throws things all off. To get around this, we just tell
3347 // getExistingVal that we are at global scope here.
3349 Function *SavedCurFn = CurFun.CurrentFunction;
3350 CurFun.CurrentFunction = 0;
3352 Value *V = getExistingVal(Ty, yyvsp[0].ValIDVal);
3355 CurFun.CurrentFunction = SavedCurFn;
3357 // If this is an initializer for a constant pointer, which is referencing a
3358 // (currently) undefined variable, create a stub now that shall be replaced
3359 // in the future with the right type of variable.
3362 assert(isa<PointerType>(Ty) && "Globals may only be used as pointers!");
3363 const PointerType *PT = cast<PointerType>(Ty);
3365 // First check to see if the forward references value is already created!
3366 PerModuleInfo::GlobalRefsType::iterator I =
3367 CurModule.GlobalRefs.find(std::make_pair(PT, yyvsp[0].ValIDVal));
3369 if (I != CurModule.GlobalRefs.end()) {
3370 V = I->second; // Placeholder already exists, use it...
3371 yyvsp[0].ValIDVal.destroy();
3374 if (yyvsp[0].ValIDVal.Type == ValID::GlobalName)
3375 Name = yyvsp[0].ValIDVal.Name;
3376 else if (yyvsp[0].ValIDVal.Type != ValID::GlobalID)
3377 GEN_ERROR("Invalid reference to global");
3379 // Create the forward referenced global.
3381 if (const FunctionType *FTy =
3382 dyn_cast<FunctionType>(PT->getElementType())) {
3383 GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name,
3384 CurModule.CurrentModule);
3386 GV = new GlobalVariable(PT->getElementType(), false,
3387 GlobalValue::ExternalWeakLinkage, 0,
3388 Name, CurModule.CurrentModule);
3391 // Keep track of the fact that we have a forward ref to recycle it
3392 CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, yyvsp[0].ValIDVal), GV));
3397 yyval.ConstVal = cast<GlobalValue>(V);
3398 delete yyvsp[-1].TypeVal; // Free the type handle
3403 #line 1787 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3405 if (!UpRefs.empty())
3406 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3407 if (yyvsp[-1].TypeVal->get() != yyvsp[0].ConstVal->getType())
3408 GEN_ERROR("Mismatched types for constant expression: " +
3409 (*yyvsp[-1].TypeVal)->getDescription() + " and " + yyvsp[0].ConstVal->getType()->getDescription());
3410 yyval.ConstVal = yyvsp[0].ConstVal;
3411 delete yyvsp[-1].TypeVal;
3416 #line 1797 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3418 if (!UpRefs.empty())
3419 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3420 const Type *Ty = yyvsp[-1].TypeVal->get();
3421 if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || isa<OpaqueType>(Ty))
3422 GEN_ERROR("Cannot create a null initialized value of this type");
3423 yyval.ConstVal = Constant::getNullValue(Ty);
3424 delete yyvsp[-1].TypeVal;
3429 #line 1807 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3430 { // integral constants
3431 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].SInt64Val))
3432 GEN_ERROR("Constant value doesn't fit in type");
3433 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].SInt64Val, true);
3438 #line 1813 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3439 { // arbitrary precision integer constants
3440 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3441 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
3442 GEN_ERROR("Constant value does not fit in type");
3444 yyvsp[0].APIntVal->sextOrTrunc(BitWidth);
3445 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3446 delete yyvsp[0].APIntVal;
3451 #line 1823 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3452 { // integral constants
3453 if (!ConstantInt::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].UInt64Val))
3454 GEN_ERROR("Constant value doesn't fit in type");
3455 yyval.ConstVal = ConstantInt::get(yyvsp[-1].PrimType, yyvsp[0].UInt64Val, false);
3460 #line 1829 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3461 { // arbitrary precision integer constants
3462 uint32_t BitWidth = cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth();
3463 if (yyvsp[0].APIntVal->getBitWidth() > BitWidth) {
3464 GEN_ERROR("Constant value does not fit in type");
3466 yyvsp[0].APIntVal->zextOrTrunc(BitWidth);
3467 yyval.ConstVal = ConstantInt::get(*yyvsp[0].APIntVal);
3468 delete yyvsp[0].APIntVal;
3473 #line 1839 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3474 { // Boolean constants
3475 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3476 yyval.ConstVal = ConstantInt::getTrue();
3481 #line 1844 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3482 { // Boolean constants
3483 assert(cast<IntegerType>(yyvsp[-1].PrimType)->getBitWidth() == 1 && "Not Bool?");
3484 yyval.ConstVal = ConstantInt::getFalse();
3489 #line 1849 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3490 { // Float & Double constants
3491 if (!ConstantFP::isValueValidForType(yyvsp[-1].PrimType, yyvsp[0].FPVal))
3492 GEN_ERROR("Floating point constant invalid for type");
3493 yyval.ConstVal = ConstantFP::get(yyvsp[-1].PrimType, yyvsp[0].FPVal);
3498 #line 1857 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3500 if (!UpRefs.empty())
3501 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
3502 Constant *Val = yyvsp[-3].ConstVal;
3503 const Type *DestTy = yyvsp[-1].TypeVal->get();
3504 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
3505 GEN_ERROR("invalid cast opcode for cast from '" +
3506 Val->getType()->getDescription() + "' to '" +
3507 DestTy->getDescription() + "'");
3508 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3509 delete yyvsp[-1].TypeVal;
3513 #line 1869 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3515 if (!isa<PointerType>(yyvsp[-2].ConstVal->getType()))
3516 GEN_ERROR("GetElementPtr requires a pointer operand");
3519 GetElementPtrInst::getIndexedType(yyvsp[-2].ConstVal->getType(), &(*yyvsp[-1].ValueList)[0], yyvsp[-1].ValueList->size(),
3522 GEN_ERROR("Index list invalid for constant getelementptr");
3524 SmallVector<Constant*, 8> IdxVec;
3525 for (unsigned i = 0, e = yyvsp[-1].ValueList->size(); i != e; ++i)
3526 if (Constant *C = dyn_cast<Constant>((*yyvsp[-1].ValueList)[i]))
3527 IdxVec.push_back(C);
3529 GEN_ERROR("Indices to constant getelementptr must be constants");
3531 delete yyvsp[-1].ValueList;
3533 yyval.ConstVal = ConstantExpr::getGetElementPtr(yyvsp[-2].ConstVal, &IdxVec[0], IdxVec.size());
3538 #line 1891 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3540 if (yyvsp[-5].ConstVal->getType() != Type::Int1Ty)
3541 GEN_ERROR("Select condition must be of boolean type");
3542 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3543 GEN_ERROR("Select operand types must match");
3544 yyval.ConstVal = ConstantExpr::getSelect(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3549 #line 1899 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3551 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3552 GEN_ERROR("Binary operator types must match");
3554 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3558 #line 1905 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3560 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3561 GEN_ERROR("Logical operator types must match");
3562 if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
3563 if (Instruction::isShift(yyvsp[-5].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].ConstVal->getType()) ||
3564 !cast<VectorType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
3565 GEN_ERROR("Logical operator requires integral operands");
3567 yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3572 #line 1916 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3574 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3575 GEN_ERROR("icmp operand types must match");
3576 yyval.ConstVal = ConstantExpr::getICmp(yyvsp[-5].IPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3580 #line 1921 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3582 if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
3583 GEN_ERROR("fcmp operand types must match");
3584 yyval.ConstVal = ConstantExpr::getFCmp(yyvsp[-5].FPredicate, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3588 #line 1926 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3590 if (!ExtractElementInst::isValidOperands(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3591 GEN_ERROR("Invalid extractelement operands");
3592 yyval.ConstVal = ConstantExpr::getExtractElement(yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3597 #line 1932 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3599 if (!InsertElementInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3600 GEN_ERROR("Invalid insertelement operands");
3601 yyval.ConstVal = ConstantExpr::getInsertElement(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3606 #line 1938 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3608 if (!ShuffleVectorInst::isValidOperands(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal))
3609 GEN_ERROR("Invalid shufflevector operands");
3610 yyval.ConstVal = ConstantExpr::getShuffleVector(yyvsp[-5].ConstVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
3615 #line 1947 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3617 (yyval.ConstVector = yyvsp[-2].ConstVector)->push_back(yyvsp[0].ConstVal);
3622 #line 1951 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3624 yyval.ConstVector = new std::vector<Constant*>();
3625 yyval.ConstVector->push_back(yyvsp[0].ConstVal);
3630 #line 1959 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3631 { yyval.BoolVal = false; ;
3634 #line 1959 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3635 { yyval.BoolVal = true; ;
3638 #line 1962 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3639 { yyval.BoolVal = true; ;
3642 #line 1962 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3643 { yyval.BoolVal = false; ;
3646 #line 1965 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3648 const Type* VTy = yyvsp[-1].TypeVal->get();
3649 Value *V = getVal(VTy, yyvsp[0].ValIDVal);
3650 GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
3652 GEN_ERROR("Aliases can be created only to global values");
3654 yyval.ConstVal = Aliasee;
3656 delete yyvsp[-1].TypeVal;
3660 #line 1976 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3662 Constant *Val = yyvsp[-3].ConstVal;
3663 const Type *DestTy = yyvsp[-1].TypeVal->get();
3664 if (!CastInst::castIsValid(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy))
3665 GEN_ERROR("invalid cast opcode for cast from '" +
3666 Val->getType()->getDescription() + "' to '" +
3667 DestTy->getDescription() + "'");
3669 yyval.ConstVal = ConstantExpr::getCast(yyvsp[-5].CastOpVal, yyvsp[-3].ConstVal, DestTy);
3671 delete yyvsp[-1].TypeVal;
3675 #line 1997 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3677 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
3678 CurModule.ModuleDone();
3683 #line 2002 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3685 yyval.ModuleVal = ParserResult = CurModule.CurrentModule;
3686 CurModule.ModuleDone();
3691 #line 2015 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3692 { CurFun.isDeclare = false; ;
3695 #line 2015 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3697 CurFun.FunctionDone();
3702 #line 2019 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3703 { CurFun.isDeclare = true; ;
3706 #line 2019 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3712 #line 2022 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3718 #line 2025 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3720 if (!UpRefs.empty())
3721 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3722 // Eagerly resolve types. This is not an optimization, this is a
3723 // requirement that is due to the fact that we could have this:
3725 // %list = type { %list * }
3726 // %list = type { %list * } ; repeated type decl
3728 // If types are not resolved eagerly, then the two types will not be
3729 // determined to be the same type!
3731 ResolveTypeTo(yyvsp[-2].StrVal, *yyvsp[0].TypeVal);
3733 if (!setTypeName(*yyvsp[0].TypeVal, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3735 // If this is a named type that is not a redefinition, add it to the slot
3737 CurModule.Types.push_back(*yyvsp[0].TypeVal);
3740 delete yyvsp[0].TypeVal;
3745 #line 2049 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3747 ResolveTypeTo(yyvsp[-2].StrVal, yyvsp[0].PrimType);
3749 if (!setTypeName(yyvsp[0].PrimType, yyvsp[-2].StrVal) && !yyvsp[-2].StrVal) {
3751 // If this is a named type that is not a redefinition, add it to the slot
3753 CurModule.Types.push_back(yyvsp[0].PrimType);
3759 #line 2060 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3761 /* "Externally Visible" Linkage */
3762 if (yyvsp[0].ConstVal == 0)
3763 GEN_ERROR("Global value initializer is not a constant");
3764 CurGV = ParseGlobalVariable(yyvsp[-4].StrVal, GlobalValue::ExternalLinkage,
3765 yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
3770 #line 2067 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3776 #line 2071 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3778 if (yyvsp[0].ConstVal == 0)
3779 GEN_ERROR("Global value initializer is not a constant");
3780 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, yyvsp[0].ConstVal->getType(), yyvsp[0].ConstVal, yyvsp[-2].BoolVal);
3785 #line 2076 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3791 #line 2080 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3793 if (!UpRefs.empty())
3794 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
3795 CurGV = ParseGlobalVariable(yyvsp[-5].StrVal, yyvsp[-4].Linkage, yyvsp[-3].Visibility, yyvsp[-1].BoolVal, *yyvsp[0].TypeVal, 0, yyvsp[-2].BoolVal);
3797 delete yyvsp[0].TypeVal;
3801 #line 2086 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3808 #line 2090 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3810 std::string Name(yyvsp[-4].StrVal);
3812 GEN_ERROR("Alias name cannot be empty");
3814 Constant* Aliasee = yyvsp[0].ConstVal;
3816 GEN_ERROR(std::string("Invalid aliasee for alias: ") + yyvsp[-4].StrVal);
3818 GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), yyvsp[-1].Linkage, Name, Aliasee,
3819 CurModule.CurrentModule);
3820 GA->setVisibility(yyvsp[-3].Visibility);
3821 InsertValue(GA, CurModule.Values);
3826 #line 2105 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3832 #line 2108 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3838 #line 2114 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3840 const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm();
3841 char *EndStr = UnEscapeLexed(yyvsp[0].StrVal, true);
3842 std::string NewAsm(yyvsp[0].StrVal, EndStr);
3843 free(yyvsp[0].StrVal);
3845 if (AsmSoFar.empty())
3846 CurModule.CurrentModule->setModuleInlineAsm(NewAsm);
3848 CurModule.CurrentModule->setModuleInlineAsm(AsmSoFar+"\n"+NewAsm);
3853 #line 2127 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3855 CurModule.CurrentModule->setTargetTriple(yyvsp[0].StrVal);
3856 free(yyvsp[0].StrVal);
3860 #line 2131 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3862 CurModule.CurrentModule->setDataLayout(yyvsp[0].StrVal);
3863 free(yyvsp[0].StrVal);
3867 #line 2138 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3869 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3870 free(yyvsp[0].StrVal);
3875 #line 2143 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3877 CurModule.CurrentModule->addLibrary(yyvsp[0].StrVal);
3878 free(yyvsp[0].StrVal);
3883 #line 2148 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3889 #line 2157 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3891 if (!UpRefs.empty())
3892 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3893 if (*yyvsp[-2].TypeVal == Type::VoidTy)
3894 GEN_ERROR("void typed arguments are invalid");
3895 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3896 yyval.ArgList = yyvsp[-4].ArgList;
3897 yyvsp[-4].ArgList->push_back(E);
3902 #line 2167 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3904 if (!UpRefs.empty())
3905 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
3906 if (*yyvsp[-2].TypeVal == Type::VoidTy)
3907 GEN_ERROR("void typed arguments are invalid");
3908 ArgListEntry E; E.Attrs = yyvsp[-1].ParamAttrs; E.Ty = yyvsp[-2].TypeVal; E.Name = yyvsp[0].StrVal;
3909 yyval.ArgList = new ArgListType;
3910 yyval.ArgList->push_back(E);
3915 #line 2178 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3917 yyval.ArgList = yyvsp[0].ArgList;
3922 #line 2182 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3924 yyval.ArgList = yyvsp[-2].ArgList;
3925 struct ArgListEntry E;
3926 E.Ty = new PATypeHolder(Type::VoidTy);
3928 E.Attrs = ParamAttr::None;
3929 yyval.ArgList->push_back(E);
3934 #line 2191 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3936 yyval.ArgList = new ArgListType;
3937 struct ArgListEntry E;
3938 E.Ty = new PATypeHolder(Type::VoidTy);
3940 E.Attrs = ParamAttr::None;
3941 yyval.ArgList->push_back(E);
3946 #line 2200 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3953 #line 2206 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
3955 UnEscapeLexed(yyvsp[-6].StrVal);
3956 std::string FunctionName(yyvsp[-6].StrVal);
3957 free(yyvsp[-6].StrVal); // Free strdup'd memory!
3959 // Check the function result for abstractness if this is a define. We should
3960 // have no abstract types at this point
3961 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(yyvsp[-7].TypeVal))
3962 GEN_ERROR("Reference to abstract result: "+ yyvsp[-7].TypeVal->get()->getDescription());
3964 std::vector<const Type*> ParamTypeList;
3965 ParamAttrsVector Attrs;
3966 if (yyvsp[-2].ParamAttrs != ParamAttr::None) {
3967 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-2].ParamAttrs;
3968 Attrs.push_back(PAWI);
3970 if (yyvsp[-4].ArgList) { // If there are arguments...
3972 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin(); I != yyvsp[-4].ArgList->end(); ++I, ++index) {
3973 const Type* Ty = I->Ty->get();
3974 if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty))
3975 GEN_ERROR("Reference to abstract argument: " + Ty->getDescription());
3976 ParamTypeList.push_back(Ty);
3977 if (Ty != Type::VoidTy)
3978 if (I->Attrs != ParamAttr::None) {
3979 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
3980 Attrs.push_back(PAWI);
3985 bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
3986 if (isVarArg) ParamTypeList.pop_back();
3988 ParamAttrsList *PAL = 0;
3990 PAL = ParamAttrsList::get(Attrs);
3992 FunctionType *FT = FunctionType::get(*yyvsp[-7].TypeVal, ParamTypeList, isVarArg, PAL);
3993 const PointerType *PFT = PointerType::get(FT);
3994 delete yyvsp[-7].TypeVal;
3997 if (!FunctionName.empty()) {
3998 ID = ValID::createGlobalName((char*)FunctionName.c_str());
4000 ID = ValID::createGlobalID(CurModule.Values.size());
4004 // See if this function was forward referenced. If so, recycle the object.
4005 if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) {
4006 // Move the function to the end of the list, from whereever it was
4007 // previously inserted.
4008 Fn = cast<Function>(FWRef);
4009 CurModule.CurrentModule->getFunctionList().remove(Fn);
4010 CurModule.CurrentModule->getFunctionList().push_back(Fn);
4011 } else if (!FunctionName.empty() && // Merge with an earlier prototype?
4012 (Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
4013 if (Fn->getFunctionType() != FT) {
4014 // The existing function doesn't have the same type. This is an overload
4016 GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
4017 } else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
4018 // Neither the existing or the current function is a declaration and they
4019 // have the same name and same type. Clearly this is a redefinition.
4020 GEN_ERROR("Redefinition of function '" + FunctionName + "'");
4021 } if (Fn->isDeclaration()) {
4022 // Make sure to strip off any argument names so we can't get conflicts.
4023 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
4027 } else { // Not already defined?
4028 Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName,
4029 CurModule.CurrentModule);
4031 InsertValue(Fn, CurModule.Values);
4034 CurFun.FunctionStart(Fn);
4036 if (CurFun.isDeclare) {
4037 // If we have declaration, always overwrite linkage. This will allow us to
4038 // correctly handle cases, when pointer to function is passed as argument to
4039 // another function.
4040 Fn->setLinkage(CurFun.Linkage);
4041 Fn->setVisibility(CurFun.Visibility);
4043 Fn->setCallingConv(yyvsp[-8].UIntVal);
4044 Fn->setAlignment(yyvsp[0].UIntVal);
4045 if (yyvsp[-1].StrVal) {
4046 Fn->setSection(yyvsp[-1].StrVal);
4047 free(yyvsp[-1].StrVal);
4050 // Add all of the arguments we parsed to the function...
4051 if (yyvsp[-4].ArgList) { // Is null if empty...
4052 if (isVarArg) { // Nuke the last entry
4053 assert(yyvsp[-4].ArgList->back().Ty->get() == Type::VoidTy && yyvsp[-4].ArgList->back().Name == 0 &&
4054 "Not a varargs marker!");
4055 delete yyvsp[-4].ArgList->back().Ty;
4056 yyvsp[-4].ArgList->pop_back(); // Delete the last entry
4058 Function::arg_iterator ArgIt = Fn->arg_begin();
4059 Function::arg_iterator ArgEnd = Fn->arg_end();
4061 for (ArgListType::iterator I = yyvsp[-4].ArgList->begin();
4062 I != yyvsp[-4].ArgList->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
4063 delete I->Ty; // Delete the typeholder...
4064 setValueName(ArgIt, I->Name); // Insert arg into symtab...
4070 delete yyvsp[-4].ArgList; // We're now done with the argument list
4076 #line 2329 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4078 yyval.FunctionVal = CurFun.CurrentFunction;
4080 // Make sure that we keep track of the linkage type even if there was a
4081 // previous "declare".
4082 yyval.FunctionVal->setLinkage(yyvsp[-3].Linkage);
4083 yyval.FunctionVal->setVisibility(yyvsp[-2].Visibility);
4087 #line 2340 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4089 yyval.FunctionVal = yyvsp[-1].FunctionVal;
4094 #line 2345 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4096 CurFun.CurrentFunction->setLinkage(yyvsp[-2].Linkage);
4097 CurFun.CurrentFunction->setVisibility(yyvsp[-1].Visibility);
4098 yyval.FunctionVal = CurFun.CurrentFunction;
4099 CurFun.FunctionDone();
4104 #line 2357 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4106 yyval.BoolVal = false;
4111 #line 2361 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4113 yyval.BoolVal = true;
4118 #line 2366 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4119 { // A reference to a direct constant
4120 yyval.ValIDVal = ValID::create(yyvsp[0].SInt64Val);
4125 #line 2370 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4127 yyval.ValIDVal = ValID::create(yyvsp[0].UInt64Val);
4132 #line 2374 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4133 { // Perhaps it's an FP constant?
4134 yyval.ValIDVal = ValID::create(yyvsp[0].FPVal);
4139 #line 2378 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4141 yyval.ValIDVal = ValID::create(ConstantInt::getTrue());
4146 #line 2382 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4148 yyval.ValIDVal = ValID::create(ConstantInt::getFalse());
4153 #line 2386 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4155 yyval.ValIDVal = ValID::createNull();
4160 #line 2390 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4162 yyval.ValIDVal = ValID::createUndef();
4167 #line 2394 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4168 { // A vector zero constant.
4169 yyval.ValIDVal = ValID::createZeroInit();
4174 #line 2398 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4175 { // Nonempty unsized packed vector
4176 const Type *ETy = (*yyvsp[-1].ConstVector)[0]->getType();
4177 int NumElements = yyvsp[-1].ConstVector->size();
4179 VectorType* pt = VectorType::get(ETy, NumElements);
4180 PATypeHolder* PTy = new PATypeHolder(
4188 // Verify all elements are correct type!
4189 for (unsigned i = 0; i < yyvsp[-1].ConstVector->size(); i++) {
4190 if (ETy != (*yyvsp[-1].ConstVector)[i]->getType())
4191 GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
4192 ETy->getDescription() +"' as required!\nIt is of type '" +
4193 (*yyvsp[-1].ConstVector)[i]->getType()->getDescription() + "'.");
4196 yyval.ValIDVal = ValID::create(ConstantVector::get(pt, *yyvsp[-1].ConstVector));
4197 delete PTy; delete yyvsp[-1].ConstVector;
4202 #line 2423 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4204 yyval.ValIDVal = ValID::create(yyvsp[0].ConstVal);
4209 #line 2427 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4211 char *End = UnEscapeLexed(yyvsp[-2].StrVal, true);
4212 std::string AsmStr = std::string(yyvsp[-2].StrVal, End);
4213 End = UnEscapeLexed(yyvsp[0].StrVal, true);
4214 std::string Constraints = std::string(yyvsp[0].StrVal, End);
4215 yyval.ValIDVal = ValID::createInlineAsm(AsmStr, Constraints, yyvsp[-3].BoolVal);
4216 free(yyvsp[-2].StrVal);
4217 free(yyvsp[0].StrVal);
4222 #line 2441 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4223 { // Is it an integer reference...?
4224 yyval.ValIDVal = ValID::createLocalID(yyvsp[0].UIntVal);
4229 #line 2445 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4231 yyval.ValIDVal = ValID::createGlobalID(yyvsp[0].UIntVal);
4236 #line 2449 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4237 { // Is it a named reference...?
4238 yyval.ValIDVal = ValID::createLocalName(yyvsp[0].StrVal);
4243 #line 2453 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4244 { // Is it a named reference...?
4245 yyval.ValIDVal = ValID::createGlobalName(yyvsp[0].StrVal);
4250 #line 2465 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4252 if (!UpRefs.empty())
4253 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4254 yyval.ValueVal = getVal(*yyvsp[-1].TypeVal, yyvsp[0].ValIDVal);
4255 delete yyvsp[-1].TypeVal;
4260 #line 2474 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4262 yyval.FunctionVal = yyvsp[-1].FunctionVal;
4267 #line 2478 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4268 { // Do not allow functions with 0 basic blocks
4269 yyval.FunctionVal = yyvsp[-1].FunctionVal;
4274 #line 2487 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4276 setValueName(yyvsp[0].TermInstVal, yyvsp[-1].StrVal);
4278 InsertValue(yyvsp[0].TermInstVal);
4279 yyvsp[-2].BasicBlockVal->getInstList().push_back(yyvsp[0].TermInstVal);
4280 yyval.BasicBlockVal = yyvsp[-2].BasicBlockVal;
4285 #line 2496 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4287 if (CastInst *CI1 = dyn_cast<CastInst>(yyvsp[0].InstVal))
4288 if (CastInst *CI2 = dyn_cast<CastInst>(CI1->getOperand(0)))
4289 if (CI2->getParent() == 0)
4290 yyvsp[-1].BasicBlockVal->getInstList().push_back(CI2);
4291 yyvsp[-1].BasicBlockVal->getInstList().push_back(yyvsp[0].InstVal);
4292 yyval.BasicBlockVal = yyvsp[-1].BasicBlockVal;
4297 #line 2505 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4298 { // Empty space between instruction lists
4299 yyval.BasicBlockVal = defineBBVal(ValID::createLocalID(CurFun.NextValNum));
4304 #line 2509 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4305 { // Labelled (named) basic block
4306 yyval.BasicBlockVal = defineBBVal(ValID::createLocalName(yyvsp[0].StrVal));
4311 #line 2514 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4312 { // Return with a result...
4313 yyval.TermInstVal = new ReturnInst(yyvsp[0].ValueVal);
4318 #line 2518 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4319 { // Return with no result...
4320 yyval.TermInstVal = new ReturnInst();
4325 #line 2522 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4326 { // Unconditional Branch...
4327 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4329 yyval.TermInstVal = new BranchInst(tmpBB);
4333 #line 2527 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4335 assert(cast<IntegerType>(yyvsp[-7].PrimType)->getBitWidth() == 1 && "Not Bool?");
4336 BasicBlock* tmpBBA = getBBVal(yyvsp[-3].ValIDVal);
4338 BasicBlock* tmpBBB = getBBVal(yyvsp[0].ValIDVal);
4340 Value* tmpVal = getVal(Type::Int1Ty, yyvsp[-6].ValIDVal);
4342 yyval.TermInstVal = new BranchInst(tmpBBA, tmpBBB, tmpVal);
4346 #line 2537 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4348 Value* tmpVal = getVal(yyvsp[-7].PrimType, yyvsp[-6].ValIDVal);
4350 BasicBlock* tmpBB = getBBVal(yyvsp[-3].ValIDVal);
4352 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, yyvsp[-1].JumpTable->size());
4353 yyval.TermInstVal = S;
4355 std::vector<std::pair<Constant*,BasicBlock*> >::iterator I = yyvsp[-1].JumpTable->begin(),
4356 E = yyvsp[-1].JumpTable->end();
4357 for (; I != E; ++I) {
4358 if (ConstantInt *CI = dyn_cast<ConstantInt>(I->first))
4359 S->addCase(CI, I->second);
4361 GEN_ERROR("Switch case is constant, but not a simple integer");
4363 delete yyvsp[-1].JumpTable;
4368 #line 2556 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4370 Value* tmpVal = getVal(yyvsp[-6].PrimType, yyvsp[-5].ValIDVal);
4372 BasicBlock* tmpBB = getBBVal(yyvsp[-2].ValIDVal);
4374 SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0);
4375 yyval.TermInstVal = S;
4380 #line 2566 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4383 // Handle the short syntax
4384 const PointerType *PFTy = 0;
4385 const FunctionType *Ty = 0;
4386 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-11].TypeVal->get())) ||
4387 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4388 // Pull out the types of all of the arguments...
4389 std::vector<const Type*> ParamTypes;
4390 ParamAttrsVector Attrs;
4391 if (yyvsp[-6].ParamAttrs != ParamAttr::None) {
4392 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[-6].ParamAttrs;
4393 Attrs.push_back(PAWI);
4395 ValueRefList::iterator I = yyvsp[-8].ValueRefList->begin(), E = yyvsp[-8].ValueRefList->end();
4397 for (; I != E; ++I, ++index) {
4398 const Type *Ty = I->Val->getType();
4399 if (Ty == Type::VoidTy)
4400 GEN_ERROR("Short call syntax cannot be used with varargs");
4401 ParamTypes.push_back(Ty);
4402 if (I->Attrs != ParamAttr::None) {
4403 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4404 Attrs.push_back(PAWI);
4408 ParamAttrsList *PAL = 0;
4410 PAL = ParamAttrsList::get(Attrs);
4411 Ty = FunctionType::get(yyvsp[-11].TypeVal->get(), ParamTypes, false, PAL);
4412 PFTy = PointerType::get(Ty);
4415 delete yyvsp[-11].TypeVal;
4417 Value *V = getVal(PFTy, yyvsp[-10].ValIDVal); // Get the function we're calling...
4419 BasicBlock *Normal = getBBVal(yyvsp[-3].ValIDVal);
4421 BasicBlock *Except = getBBVal(yyvsp[0].ValIDVal);
4424 // Check the arguments
4426 if (yyvsp[-8].ValueRefList->empty()) { // Has no arguments?
4427 // Make sure no arguments is a good thing!
4428 if (Ty->getNumParams() != 0)
4429 GEN_ERROR("No arguments passed to a function that "
4430 "expects arguments");
4431 } else { // Has arguments?
4432 // Loop through FunctionType's arguments and ensure they are specified
4434 FunctionType::param_iterator I = Ty->param_begin();
4435 FunctionType::param_iterator E = Ty->param_end();
4436 ValueRefList::iterator ArgI = yyvsp[-8].ValueRefList->begin(), ArgE = yyvsp[-8].ValueRefList->end();
4438 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4439 if (ArgI->Val->getType() != *I)
4440 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
4441 (*I)->getDescription() + "'");
4442 Args.push_back(ArgI->Val);
4445 if (Ty->isVarArg()) {
4447 for (; ArgI != ArgE; ++ArgI)
4448 Args.push_back(ArgI->Val); // push the remaining varargs
4449 } else if (I != E || ArgI != ArgE)
4450 GEN_ERROR("Invalid number of parameters detected");
4453 // Create the InvokeInst
4454 InvokeInst *II = new InvokeInst(V, Normal, Except, &Args[0], Args.size());
4455 II->setCallingConv(yyvsp[-12].UIntVal);
4456 yyval.TermInstVal = II;
4457 delete yyvsp[-8].ValueRefList;
4462 #line 2645 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4464 yyval.TermInstVal = new UnwindInst();
4469 #line 2649 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4471 yyval.TermInstVal = new UnreachableInst();
4476 #line 2656 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4478 yyval.JumpTable = yyvsp[-5].JumpTable;
4479 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
4482 GEN_ERROR("May only switch on a constant pool value");
4484 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4486 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4490 #line 2667 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4492 yyval.JumpTable = new std::vector<std::pair<Constant*, BasicBlock*> >();
4493 Constant *V = cast<Constant>(getExistingVal(yyvsp[-4].PrimType, yyvsp[-3].ValIDVal));
4497 GEN_ERROR("May only switch on a constant pool value");
4499 BasicBlock* tmpBB = getBBVal(yyvsp[0].ValIDVal);
4501 yyval.JumpTable->push_back(std::make_pair(V, tmpBB));
4505 #line 2680 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4507 // Is this definition named?? if so, assign the name...
4508 setValueName(yyvsp[0].InstVal, yyvsp[-1].StrVal);
4510 InsertValue(yyvsp[0].InstVal);
4511 yyval.InstVal = yyvsp[0].InstVal;
4516 #line 2690 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4517 { // Used for PHI nodes
4518 if (!UpRefs.empty())
4519 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-5].TypeVal)->getDescription());
4520 yyval.PHIList = new std::list<std::pair<Value*, BasicBlock*> >();
4521 Value* tmpVal = getVal(*yyvsp[-5].TypeVal, yyvsp[-3].ValIDVal);
4523 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
4525 yyval.PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4526 delete yyvsp[-5].TypeVal;
4530 #line 2701 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4532 yyval.PHIList = yyvsp[-6].PHIList;
4533 Value* tmpVal = getVal(yyvsp[-6].PHIList->front().first->getType(), yyvsp[-3].ValIDVal);
4535 BasicBlock* tmpBB = getBBVal(yyvsp[-1].ValIDVal);
4537 yyvsp[-6].PHIList->push_back(std::make_pair(tmpVal, tmpBB));
4541 #line 2711 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4543 if (!UpRefs.empty())
4544 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4545 // Used for call and invoke instructions
4546 yyval.ValueRefList = new ValueRefList();
4547 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4548 yyval.ValueRefList->push_back(E);
4549 delete yyvsp[-2].TypeVal;
4553 #line 2720 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4555 if (!UpRefs.empty())
4556 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4557 yyval.ValueRefList = yyvsp[-4].ValueRefList;
4558 ValueRefListEntry E; E.Attrs = yyvsp[0].ParamAttrs; E.Val = getVal(yyvsp[-2].TypeVal->get(), yyvsp[-1].ValIDVal);
4559 yyval.ValueRefList->push_back(E);
4560 delete yyvsp[-2].TypeVal;
4565 #line 2729 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4566 { yyval.ValueRefList = new ValueRefList(); ;
4569 #line 2732 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4570 { yyval.ValueList = new std::vector<Value*>(); ;
4573 #line 2733 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4575 yyval.ValueList = yyvsp[-2].ValueList;
4576 yyval.ValueList->push_back(yyvsp[0].ValueVal);
4581 #line 2740 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4583 yyval.BoolVal = true;
4588 #line 2744 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4590 yyval.BoolVal = false;
4595 #line 2749 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4597 if (!UpRefs.empty())
4598 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4599 if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
4600 !isa<VectorType>((*yyvsp[-3].TypeVal).get()))
4602 "Arithmetic operator requires integer, FP, or packed operands");
4603 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()) &&
4604 (yyvsp[-4].BinaryOpVal == Instruction::URem ||
4605 yyvsp[-4].BinaryOpVal == Instruction::SRem ||
4606 yyvsp[-4].BinaryOpVal == Instruction::FRem))
4607 GEN_ERROR("Remainder not supported on vector types");
4608 Value* val1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4610 Value* val2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4612 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, val1, val2);
4613 if (yyval.InstVal == 0)
4614 GEN_ERROR("binary operator returned null");
4615 delete yyvsp[-3].TypeVal;
4619 #line 2770 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4621 if (!UpRefs.empty())
4622 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4623 if (!(*yyvsp[-3].TypeVal)->isInteger()) {
4624 if (Instruction::isShift(yyvsp[-4].BinaryOpVal) || !isa<VectorType>(yyvsp[-3].TypeVal->get()) ||
4625 !cast<VectorType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
4626 GEN_ERROR("Logical operator requires integral operands");
4628 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4630 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4632 yyval.InstVal = BinaryOperator::create(yyvsp[-4].BinaryOpVal, tmpVal1, tmpVal2);
4633 if (yyval.InstVal == 0)
4634 GEN_ERROR("binary operator returned null");
4635 delete yyvsp[-3].TypeVal;
4639 #line 2787 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4641 if (!UpRefs.empty())
4642 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4643 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
4644 GEN_ERROR("Vector types not supported by icmp instruction");
4645 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4647 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4649 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].IPredicate, tmpVal1, tmpVal2);
4650 if (yyval.InstVal == 0)
4651 GEN_ERROR("icmp operator returned null");
4652 delete yyvsp[-3].TypeVal;
4656 #line 2801 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4658 if (!UpRefs.empty())
4659 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
4660 if (isa<VectorType>((*yyvsp[-3].TypeVal).get()))
4661 GEN_ERROR("Vector types not supported by fcmp instruction");
4662 Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
4664 Value* tmpVal2 = getVal(*yyvsp[-3].TypeVal, yyvsp[0].ValIDVal);
4666 yyval.InstVal = CmpInst::create(yyvsp[-5].OtherOpVal, yyvsp[-4].FPredicate, tmpVal1, tmpVal2);
4667 if (yyval.InstVal == 0)
4668 GEN_ERROR("fcmp operator returned null");
4669 delete yyvsp[-3].TypeVal;
4673 #line 2815 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4675 if (!UpRefs.empty())
4676 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4677 Value* Val = yyvsp[-2].ValueVal;
4678 const Type* DestTy = yyvsp[0].TypeVal->get();
4679 if (!CastInst::castIsValid(yyvsp[-3].CastOpVal, Val, DestTy))
4680 GEN_ERROR("invalid cast opcode for cast from '" +
4681 Val->getType()->getDescription() + "' to '" +
4682 DestTy->getDescription() + "'");
4683 yyval.InstVal = CastInst::create(yyvsp[-3].CastOpVal, Val, DestTy);
4684 delete yyvsp[0].TypeVal;
4688 #line 2827 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4690 if (yyvsp[-4].ValueVal->getType() != Type::Int1Ty)
4691 GEN_ERROR("select condition must be boolean");
4692 if (yyvsp[-2].ValueVal->getType() != yyvsp[0].ValueVal->getType())
4693 GEN_ERROR("select value types should match");
4694 yyval.InstVal = new SelectInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4699 #line 2835 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4701 if (!UpRefs.empty())
4702 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[0].TypeVal)->getDescription());
4703 yyval.InstVal = new VAArgInst(yyvsp[-2].ValueVal, *yyvsp[0].TypeVal);
4704 delete yyvsp[0].TypeVal;
4709 #line 2842 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4711 if (!ExtractElementInst::isValidOperands(yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4712 GEN_ERROR("Invalid extractelement operands");
4713 yyval.InstVal = new ExtractElementInst(yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4718 #line 2848 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4720 if (!InsertElementInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4721 GEN_ERROR("Invalid insertelement operands");
4722 yyval.InstVal = new InsertElementInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4727 #line 2854 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4729 if (!ShuffleVectorInst::isValidOperands(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal))
4730 GEN_ERROR("Invalid shufflevector operands");
4731 yyval.InstVal = new ShuffleVectorInst(yyvsp[-4].ValueVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
4736 #line 2860 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4738 const Type *Ty = yyvsp[0].PHIList->front().first->getType();
4739 if (!Ty->isFirstClassType())
4740 GEN_ERROR("PHI node operands must be of first class type");
4741 yyval.InstVal = new PHINode(Ty);
4742 ((PHINode*)yyval.InstVal)->reserveOperandSpace(yyvsp[0].PHIList->size());
4743 while (yyvsp[0].PHIList->begin() != yyvsp[0].PHIList->end()) {
4744 if (yyvsp[0].PHIList->front().first->getType() != Ty)
4745 GEN_ERROR("All elements of a PHI node must be of the same type");
4746 cast<PHINode>(yyval.InstVal)->addIncoming(yyvsp[0].PHIList->front().first, yyvsp[0].PHIList->front().second);
4747 yyvsp[0].PHIList->pop_front();
4749 delete yyvsp[0].PHIList; // Free the list...
4754 #line 2876 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4757 // Handle the short syntax
4758 const PointerType *PFTy = 0;
4759 const FunctionType *Ty = 0;
4760 if (!(PFTy = dyn_cast<PointerType>(yyvsp[-5].TypeVal->get())) ||
4761 !(Ty = dyn_cast<FunctionType>(PFTy->getElementType()))) {
4762 // Pull out the types of all of the arguments...
4763 std::vector<const Type*> ParamTypes;
4764 ParamAttrsVector Attrs;
4765 if (yyvsp[0].ParamAttrs != ParamAttr::None) {
4766 ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = yyvsp[0].ParamAttrs;
4767 Attrs.push_back(PAWI);
4770 ValueRefList::iterator I = yyvsp[-2].ValueRefList->begin(), E = yyvsp[-2].ValueRefList->end();
4771 for (; I != E; ++I, ++index) {
4772 const Type *Ty = I->Val->getType();
4773 if (Ty == Type::VoidTy)
4774 GEN_ERROR("Short call syntax cannot be used with varargs");
4775 ParamTypes.push_back(Ty);
4776 if (I->Attrs != ParamAttr::None) {
4777 ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs;
4778 Attrs.push_back(PAWI);
4782 ParamAttrsList *PAL = 0;
4784 PAL = ParamAttrsList::get(Attrs);
4786 Ty = FunctionType::get(yyvsp[-5].TypeVal->get(), ParamTypes, false, PAL);
4787 PFTy = PointerType::get(Ty);
4790 Value *V = getVal(PFTy, yyvsp[-4].ValIDVal); // Get the function we're calling...
4793 // Check for call to invalid intrinsic to avoid crashing later.
4794 if (Function *theF = dyn_cast<Function>(V)) {
4795 if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) &&
4796 (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) &&
4797 !theF->getIntrinsicID(true))
4798 GEN_ERROR("Call to invalid LLVM intrinsic function '" +
4799 theF->getName() + "'");
4802 // Check the arguments
4804 if (yyvsp[-2].ValueRefList->empty()) { // Has no arguments?
4805 // Make sure no arguments is a good thing!
4806 if (Ty->getNumParams() != 0)
4807 GEN_ERROR("No arguments passed to a function that "
4808 "expects arguments");
4809 } else { // Has arguments?
4810 // Loop through FunctionType's arguments and ensure they are specified
4813 FunctionType::param_iterator I = Ty->param_begin();
4814 FunctionType::param_iterator E = Ty->param_end();
4815 ValueRefList::iterator ArgI = yyvsp[-2].ValueRefList->begin(), ArgE = yyvsp[-2].ValueRefList->end();
4817 for (; ArgI != ArgE && I != E; ++ArgI, ++I) {
4818 if (ArgI->Val->getType() != *I)
4819 GEN_ERROR("Parameter " + ArgI->Val->getName()+ " is not of type '" +
4820 (*I)->getDescription() + "'");
4821 Args.push_back(ArgI->Val);
4823 if (Ty->isVarArg()) {
4825 for (; ArgI != ArgE; ++ArgI)
4826 Args.push_back(ArgI->Val); // push the remaining varargs
4827 } else if (I != E || ArgI != ArgE)
4828 GEN_ERROR("Invalid number of parameters detected");
4830 // Create the call node
4831 CallInst *CI = new CallInst(V, &Args[0], Args.size());
4832 CI->setTailCall(yyvsp[-7].BoolVal);
4833 CI->setCallingConv(yyvsp[-6].UIntVal);
4835 delete yyvsp[-2].ValueRefList;
4836 delete yyvsp[-5].TypeVal;
4841 #line 2960 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4843 yyval.InstVal = yyvsp[0].InstVal;
4848 #line 2965 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4850 yyval.BoolVal = true;
4855 #line 2969 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4857 yyval.BoolVal = false;
4862 #line 2976 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4864 if (!UpRefs.empty())
4865 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4866 yyval.InstVal = new MallocInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4867 delete yyvsp[-1].TypeVal;
4872 #line 2983 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4874 if (!UpRefs.empty())
4875 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4876 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
4878 yyval.InstVal = new MallocInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4879 delete yyvsp[-4].TypeVal;
4883 #line 2991 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4885 if (!UpRefs.empty())
4886 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-1].TypeVal)->getDescription());
4887 yyval.InstVal = new AllocaInst(*yyvsp[-1].TypeVal, 0, yyvsp[0].UIntVal);
4888 delete yyvsp[-1].TypeVal;
4893 #line 2998 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4895 if (!UpRefs.empty())
4896 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-4].TypeVal)->getDescription());
4897 Value* tmpVal = getVal(yyvsp[-2].PrimType, yyvsp[-1].ValIDVal);
4899 yyval.InstVal = new AllocaInst(*yyvsp[-4].TypeVal, tmpVal, yyvsp[0].UIntVal);
4900 delete yyvsp[-4].TypeVal;
4904 #line 3006 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4906 if (!isa<PointerType>(yyvsp[0].ValueVal->getType()))
4907 GEN_ERROR("Trying to free nonpointer type " +
4908 yyvsp[0].ValueVal->getType()->getDescription() + "");
4909 yyval.InstVal = new FreeInst(yyvsp[0].ValueVal);
4914 #line 3014 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4916 if (!UpRefs.empty())
4917 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4918 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4919 GEN_ERROR("Can't load from nonpointer type: " +
4920 (*yyvsp[-2].TypeVal)->getDescription());
4921 if (!cast<PointerType>(yyvsp[-2].TypeVal->get())->getElementType()->isFirstClassType())
4922 GEN_ERROR("Can't load from pointer of non-first-class type: " +
4923 (*yyvsp[-2].TypeVal)->getDescription());
4924 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
4926 yyval.InstVal = new LoadInst(tmpVal, "", yyvsp[-4].BoolVal, yyvsp[0].UIntVal);
4927 delete yyvsp[-2].TypeVal;
4931 #line 3028 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4933 if (!UpRefs.empty())
4934 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4935 const PointerType *PT = dyn_cast<PointerType>(yyvsp[-2].TypeVal->get());
4937 GEN_ERROR("Can't store to a nonpointer type: " +
4938 (*yyvsp[-2].TypeVal)->getDescription());
4939 const Type *ElTy = PT->getElementType();
4940 if (ElTy != yyvsp[-4].ValueVal->getType())
4941 GEN_ERROR("Can't store '" + yyvsp[-4].ValueVal->getType()->getDescription() +
4942 "' into space of type '" + ElTy->getDescription() + "'");
4944 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
4946 yyval.InstVal = new StoreInst(yyvsp[-4].ValueVal, tmpVal, yyvsp[-6].BoolVal, yyvsp[0].UIntVal);
4947 delete yyvsp[-2].TypeVal;
4951 #line 3045 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
4953 if (!UpRefs.empty())
4954 GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-2].TypeVal)->getDescription());
4955 if (!isa<PointerType>(yyvsp[-2].TypeVal->get()))
4956 GEN_ERROR("getelementptr insn requires pointer operand");
4958 if (!GetElementPtrInst::getIndexedType(*yyvsp[-2].TypeVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size(), true))
4959 GEN_ERROR("Invalid getelementptr indices for type '" +
4960 (*yyvsp[-2].TypeVal)->getDescription()+ "'");
4961 Value* tmpVal = getVal(*yyvsp[-2].TypeVal, yyvsp[-1].ValIDVal);
4963 yyval.InstVal = new GetElementPtrInst(tmpVal, &(*yyvsp[0].ValueList)[0], yyvsp[0].ValueList->size());
4964 delete yyvsp[-2].TypeVal;
4965 delete yyvsp[0].ValueList;
4969 /* the action file gets copied in in place of this dollarsign */
4970 #line 543 "/usr/share/bison.simple"
4981 short *ssp1 = yyss - 1;
4982 fprintf (stderr, "state stack now");
4983 while (ssp1 != yyssp)
4984 fprintf (stderr, " %d", *++ssp1);
4985 fprintf (stderr, "\n");
4995 yylsp->first_line = yylloc.first_line;
4996 yylsp->first_column = yylloc.first_column;
4997 yylsp->last_line = (yylsp-1)->last_line;
4998 yylsp->last_column = (yylsp-1)->last_column;
5003 yylsp->last_line = (yylsp+yylen-1)->last_line;
5004 yylsp->last_column = (yylsp+yylen-1)->last_column;
5008 /* Now "shift" the result of the reduction.
5009 Determine what state that goes to,
5010 based on the state we popped back to
5011 and the rule number reduced by. */
5015 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5016 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5017 yystate = yytable[yystate];
5019 yystate = yydefgoto[yyn - YYNTBASE];
5023 yyerrlab: /* here on detecting error */
5026 /* If not already recovering from an error, report this error. */
5030 #ifdef YYERROR_VERBOSE
5031 yyn = yypact[yystate];
5033 if (yyn > YYFLAG && yyn < YYLAST)
5040 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5041 for (x = (yyn < 0 ? -yyn : 0);
5042 x < (sizeof(yytname) / sizeof(char *)); x++)
5043 if (yycheck[x + yyn] == x)
5044 size += strlen(yytname[x]) + 15, count++;
5045 msg = (char *) malloc(size + 15);
5048 strcpy(msg, "parse error");
5053 for (x = (yyn < 0 ? -yyn : 0);
5054 x < (sizeof(yytname) / sizeof(char *)); x++)
5055 if (yycheck[x + yyn] == x)
5057 strcat(msg, count == 0 ? ", expecting `" : " or `");
5058 strcat(msg, yytname[x]);
5067 yyerror ("parse error; also virtual memory exceeded");
5070 #endif /* YYERROR_VERBOSE */
5071 yyerror("parse error");
5075 yyerrlab1: /* here on error raised explicitly by an action */
5077 if (yyerrstatus == 3)
5079 /* if just tried and failed to reuse lookahead token after an error, discard it. */
5081 /* return failure if at end of input */
5082 if (yychar == YYEOF)
5087 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5093 /* Else will try to reuse lookahead token
5094 after shifting the error token. */
5096 yyerrstatus = 3; /* Each real token shifted decrements this */
5100 yyerrdefault: /* current state does not do anything special for the error token. */
5103 /* This is wrong; only states that explicitly want error tokens
5104 should shift them. */
5105 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5106 if (yyn) goto yydefault;
5109 yyerrpop: /* pop the current state because it cannot handle the error token */
5111 if (yyssp == yyss) YYABORT;
5121 short *ssp1 = yyss - 1;
5122 fprintf (stderr, "Error: state stack now");
5123 while (ssp1 != yyssp)
5124 fprintf (stderr, " %d", *++ssp1);
5125 fprintf (stderr, "\n");
5131 yyn = yypact[yystate];
5136 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5155 fprintf(stderr, "Shifting error token, ");
5167 /* YYACCEPT comes here. */
5179 /* YYABORT comes here. */
5190 #line 3062 "/Users/sabre/cvs/llvm/lib/AsmParser/llvmAsmParser.y"
5193 // common code from the two 'RunVMAsmParser' functions
5194 static Module* RunParser(Module * M) {
5196 llvmAsmlineno = 1; // Reset the current line number...
5197 CurModule.CurrentModule = M;
5202 // Check to make sure the parser succeeded
5205 delete ParserResult;
5209 // Emit an error if there are any unresolved types left.
5210 if (!CurModule.LateResolveTypes.empty()) {
5211 const ValID &DID = CurModule.LateResolveTypes.begin()->first;
5212 if (DID.Type == ValID::LocalName) {
5213 GenerateError("Undefined type remains at eof: '"+DID.getName() + "'");
5215 GenerateError("Undefined type remains at eof: #" + itostr(DID.Num));
5218 delete ParserResult;
5222 // Emit an error if there are any unresolved values left.
5223 if (!CurModule.LateResolveValues.empty()) {
5224 Value *V = CurModule.LateResolveValues.back();
5225 std::map<Value*, std::pair<ValID, int> >::iterator I =
5226 CurModule.PlaceHolderInfo.find(V);
5228 if (I != CurModule.PlaceHolderInfo.end()) {
5229 ValID &DID = I->second.first;
5230 if (DID.Type == ValID::LocalName) {
5231 GenerateError("Undefined value remains at eof: "+DID.getName() + "'");
5233 GenerateError("Undefined value remains at eof: #" + itostr(DID.Num));
5236 delete ParserResult;
5241 // Check to make sure that parsing produced a result
5245 // Reset ParserResult variable while saving its value for the result.
5246 Module *Result = ParserResult;
5252 void llvm::GenerateError(const std::string &message, int LineNo) {
5253 if (LineNo == -1) LineNo = llvmAsmlineno;
5254 // TODO: column number in exception
5256 TheParseError->setError(CurFilename, message, LineNo);
5260 int yyerror(const char *ErrorMsg) {
5262 = std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
5263 + ":" + utostr((unsigned) llvmAsmlineno) + ": ";
5264 std::string errMsg = where + "error: " + std::string(ErrorMsg);
5265 if (yychar != YYEMPTY && yychar != 0)
5266 errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
5268 GenerateError(errMsg);