[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.355 -> 1.356 --- Log message: fix a bug where llvm-as couldn't assemble the .ll file for 252.eon. --- Diffs of the changes: (+1 -1) llvmAsmParser.y |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.355 llvm/lib/AsmParser/llvmAsmParser.y:1.356 --- llvm/lib/AsmParser/llvmAsmParser.y:1.355Sun Apr 29 13:35:00 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Thu May 3 23:01:07 2007 @@ -2574,7 +2574,7 @@ std::vector ParamTypes; ParamAttrsVector Attrs; if ($8 != ParamAttr::None) { -ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = 8; +ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = $8; Attrs.push_back(PAWI); } ValueRefList::iterator I = $6->begin(), E = $6->end(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
> + switch (ID.Type) { > + case ValID::GlobalName: > + case ValID::GlobalID: > + const PointerType *PTy = dyn_cast(Ty); > + if (!PTy) { > + GenerateError("Invalid type for reference to global" ); > + return 0; > + } > + const Type* ElTy = PTy->getElementType(); > + if (const FunctionType *FTy = dyn_cast(ElTy)) > + V = new Function(FTy, GlobalValue::ExternalLinkage); > + else > + V = new GlobalVariable(ElTy, false, > GlobalValue::ExternalLinkage); > + break; > + default: > + V = new Argument(Ty); > + } Very nice. Please indent the code in the case statements one more space though :) > @@ -1943,6 +1959,30 @@ > // ThreadLocal > ThreadLocal : THREAD_LOCAL { $$ = true; } | { $$ = false; }; > > +// AliaseeRef - Match either GlobalValue or bitcast to GlobalValue. > +AliaseeRef : ResultTypes SymbolicValueRef { > +const Type* VTy = $1->get(); > +Value *V = getVal(VTy, $2); > +GlobalValue* Aliasee = dyn_cast(V); > +if (!Aliasee) > + GEN_ERROR("Aliases can be created only to global values"); > + > +$$ = Aliasee; > +CHECK_FOR_ERROR > +delete $1; > + } > + | BITCAST '(' AliaseeRef TO Types ')' { > +Constant *Val = $3; > +const Type *DestTy = $5->get(); > +if (!CastInst::castIsValid($1, $3, DestTy)) > + GEN_ERROR("invalid cast opcode for cast from '" + > +Val->getType()->getDescription() + "' to '" + > +DestTy->getDescription() + "'"); > + > +$$ = ConstantExpr::getCast($1, $3, DestTy); > +CHECK_FOR_ERROR > +delete $5; > + }; I'd suggest eliminating this production and... > @@ -2045,34 +2085,20 @@ > CurGV = 0; > CHECK_FOR_ERROR >} > - | OptGlobalAssign GVVisibilityStyle ALIAS AliasLinkage ResultTypes > -SymbolicValueRef { > + | OptGlobalAssign GVVisibilityStyle ALIAS AliasLinkage AliaseeRef { Instead of AliaseeRef, use ResolvedVal here. Then just check ResolvedVal for the two acceptable forms. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.353 -> 1.354 --- Log message: Revert the premature portion of the last commit. --- Diffs of the changes: (+76 -62) llvmAsmParser.y | 138 ++-- 1 files changed, 76 insertions(+), 62 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.353 llvm/lib/AsmParser/llvmAsmParser.y:1.354 --- llvm/lib/AsmParser/llvmAsmParser.y:1.353Sat Apr 28 09:13:42 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Sat Apr 28 11:06:50 2007 @@ -139,18 +139,14 @@ // GetForwardRefForGlobal - Check to see if there is a forward reference // for this global. If so, remove it from the GlobalRefs map and return it. // If not, just return null. - GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ParamAttrsList *PAL, - ValID ID) { + GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { // Check to see if there is a forward reference to this global variable... // if there is, eliminate it and patch the reference to use the new def'n. GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); GlobalValue *Ret = 0; if (I != GlobalRefs.end()) { Ret = I->second; - if (PAL && isa(Ret)) -Ret = cast(Ret)->getParamAttrs() == PAL ? Ret : 0; - if (Ret) -GlobalRefs.erase(I); + GlobalRefs.erase(I); } return Ret; } @@ -748,7 +744,7 @@ ID = ValID::createGlobalID(CurModule.Values.size()); } - if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, 0, ID)) { + if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { // Move the global to the end of the list, from whereever it was // previously inserted. GlobalVariable *GV = cast(FWGV); @@ -1328,35 +1324,62 @@ UR_OUT("New Upreference!\n"); CHECK_FOR_ERROR } - | Types '(' ArgTypeListI ')' { + | Types '(' ArgTypeListI ')' OptFuncAttrs { std::vector Params; +ParamAttrsVector Attrs; +if ($5 != ParamAttr::None) { + ParamAttrsWithIndex X; X.index = 0; X.attrs = $5; + Attrs.push_back(X); +} unsigned index = 1; TypeWithAttrsList::iterator I = $3->begin(), E = $3->end(); for (; I != E; ++I, ++index) { const Type *Ty = I->Ty->get(); Params.push_back(Ty); + if (Ty != Type::VoidTy) +if (I->Attrs != ParamAttr::None) { + ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; + Attrs.push_back(X); +} } bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); -FunctionType *FT = FunctionType::get(*$1, Params, isVarArg); +ParamAttrsList *ActualAttrs = 0; +if (!Attrs.empty()) + ActualAttrs = ParamAttrsList::get(Attrs); +FunctionType *FT = FunctionType::get(*$1, Params, isVarArg, ActualAttrs); delete $3; // Delete the argument list delete $1; // Delete the return type handle $$ = new PATypeHolder(HandleUpRefs(FT)); CHECK_FOR_ERROR } - | VOID '(' ArgTypeListI ')' { + | VOID '(' ArgTypeListI ')' OptFuncAttrs { std::vector Params; +ParamAttrsVector Attrs; +if ($5 != ParamAttr::None) { + ParamAttrsWithIndex X; X.index = 0; X.attrs = $5; + Attrs.push_back(X); +} TypeWithAttrsList::iterator I = $3->begin(), E = $3->end(); unsigned index = 1; for ( ; I != E; ++I, ++index) { const Type* Ty = I->Ty->get(); Params.push_back(Ty); + if (Ty != Type::VoidTy) +if (I->Attrs != ParamAttr::None) { + ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; + Attrs.push_back(X); +} } bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); -FunctionType *FT = FunctionType::get($1, Params, isVarArg); +ParamAttrsList *ActualAttrs = 0; +if (!Attrs.empty()) + ActualAttrs = ParamAttrsList::get(Attrs); + +FunctionType *FT = FunctionType::get($1, Params, isVarArg, ActualAttrs); delete $3; // Delete the argument list $$ = new PATypeHolder(HandleUpRefs(FT)); CHECK_FOR_ERROR @@ -1410,9 +1433,9 @@ ; ArgType - : Types { + : Types OptParamAttrs { $$.Ty = $1; -$$.Attrs = ParamAttr::None; +$$.Attrs = $2; } ; @@ -2217,7 +2240,7 @@ if (!Attrs.empty()) PAL = ParamAttrsList::get(Attrs); - FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg); + FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg, PAL); const PointerType *PFT = PointerType::get(FT); delete $2; @@ -2230,7 +2253,7 @@ Function *Fn = 0; // See if this function was forward referenced. If so, recycle the object. - if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, PAL, ID)) { + if (GlobalValue *FWRef = CurMo
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.352 -> 1.353 --- Log message: Fix a compilation error (jump to case label). --- Diffs of the changes: (+64 -77) llvmAsmParser.y | 141 +--- 1 files changed, 64 insertions(+), 77 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.352 llvm/lib/AsmParser/llvmAsmParser.y:1.353 --- llvm/lib/AsmParser/llvmAsmParser.y:1.352Sat Apr 28 08:44:59 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Sat Apr 28 09:13:42 2007 @@ -139,14 +139,18 @@ // GetForwardRefForGlobal - Check to see if there is a forward reference // for this global. If so, remove it from the GlobalRefs map and return it. // If not, just return null. - GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { + GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ParamAttrsList *PAL, + ValID ID) { // Check to see if there is a forward reference to this global variable... // if there is, eliminate it and patch the reference to use the new def'n. GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); GlobalValue *Ret = 0; if (I != GlobalRefs.end()) { Ret = I->second; - GlobalRefs.erase(I); + if (PAL && isa(Ret)) +Ret = cast(Ret)->getParamAttrs() == PAL ? Ret : 0; + if (Ret) +GlobalRefs.erase(I); } return Ret; } @@ -482,7 +486,7 @@ // switch (ID.Type) { case ValID::GlobalName: - case ValID::GlobalID: + case ValID::GlobalID: { const PointerType *PTy = dyn_cast(Ty); if (!PTy) { GenerateError("Invalid type for reference to global" ); @@ -494,6 +498,7 @@ else V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage); break; + } default: V = new Argument(Ty); } @@ -743,7 +748,7 @@ ID = ValID::createGlobalID(CurModule.Values.size()); } - if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { + if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, 0, ID)) { // Move the global to the end of the list, from whereever it was // previously inserted. GlobalVariable *GV = cast(FWGV); @@ -1323,62 +1328,35 @@ UR_OUT("New Upreference!\n"); CHECK_FOR_ERROR } - | Types '(' ArgTypeListI ')' OptFuncAttrs { + | Types '(' ArgTypeListI ')' { std::vector Params; -ParamAttrsVector Attrs; -if ($5 != ParamAttr::None) { - ParamAttrsWithIndex X; X.index = 0; X.attrs = $5; - Attrs.push_back(X); -} unsigned index = 1; TypeWithAttrsList::iterator I = $3->begin(), E = $3->end(); for (; I != E; ++I, ++index) { const Type *Ty = I->Ty->get(); Params.push_back(Ty); - if (Ty != Type::VoidTy) -if (I->Attrs != ParamAttr::None) { - ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; - Attrs.push_back(X); -} } bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); -ParamAttrsList *ActualAttrs = 0; -if (!Attrs.empty()) - ActualAttrs = ParamAttrsList::get(Attrs); -FunctionType *FT = FunctionType::get(*$1, Params, isVarArg, ActualAttrs); +FunctionType *FT = FunctionType::get(*$1, Params, isVarArg); delete $3; // Delete the argument list delete $1; // Delete the return type handle $$ = new PATypeHolder(HandleUpRefs(FT)); CHECK_FOR_ERROR } - | VOID '(' ArgTypeListI ')' OptFuncAttrs { + | VOID '(' ArgTypeListI ')' { std::vector Params; -ParamAttrsVector Attrs; -if ($5 != ParamAttr::None) { - ParamAttrsWithIndex X; X.index = 0; X.attrs = $5; - Attrs.push_back(X); -} TypeWithAttrsList::iterator I = $3->begin(), E = $3->end(); unsigned index = 1; for ( ; I != E; ++I, ++index) { const Type* Ty = I->Ty->get(); Params.push_back(Ty); - if (Ty != Type::VoidTy) -if (I->Attrs != ParamAttr::None) { - ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; - Attrs.push_back(X); -} } bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); -ParamAttrsList *ActualAttrs = 0; -if (!Attrs.empty()) - ActualAttrs = ParamAttrsList::get(Attrs); - -FunctionType *FT = FunctionType::get($1, Params, isVarArg, ActualAttrs); +FunctionType *FT = FunctionType::get($1, Params, isVarArg); delete $3; // Delete the argument list $$ = new PATypeHolder(HandleUpRefs(FT)); CHECK_FOR_ERROR @@ -1432,9 +1410,9 @@ ; ArgType - : Types OptParamAttrs { + : Types { $$.Ty = $1; -$$.Attrs = $2; +$$.Attrs = ParamAttr::None; } ; @@ -2239,7 +2217,7 @@ if (!Attrs.empty()) PAL = ParamAttrsList::get(Attrs); - FunctionType *FT = FunctionType::get(*$
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.351 -> 1.352 --- Log message: Implement review feedback. Aliasees can be either GlobalValue's or bitcasts of them. --- Diffs of the changes: (+53 -27) llvmAsmParser.y | 80 +--- 1 files changed, 53 insertions(+), 27 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.351 llvm/lib/AsmParser/llvmAsmParser.y:1.352 --- llvm/lib/AsmParser/llvmAsmParser.y:1.351Thu Apr 26 00:30:35 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Sat Apr 28 08:44:59 2007 @@ -480,8 +480,24 @@ // or an id number that hasn't been read yet. We may be referencing something // forward, so just create an entry to be resolved later and get to it... // - V = new Argument(Ty); - + switch (ID.Type) { + case ValID::GlobalName: + case ValID::GlobalID: + const PointerType *PTy = dyn_cast(Ty); + if (!PTy) { + GenerateError("Invalid type for reference to global" ); + return 0; + } + const Type* ElTy = PTy->getElementType(); + if (const FunctionType *FTy = dyn_cast(ElTy)) + V = new Function(FTy, GlobalValue::ExternalLinkage); + else + V = new GlobalVariable(ElTy, false, GlobalValue::ExternalLinkage); + break; + default: + V = new Argument(Ty); + } + // Remember where this forward reference came from. FIXME, shouldn't we try // to recycle these things?? CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, @@ -987,7 +1003,7 @@ %type BasicBlock InstructionList %typeBBTerminatorInst %typeInst InstVal MemoryInst -%type ConstVal ConstExpr +%type ConstVal ConstExpr AliaseeRef %typeConstVector %typeArgList ArgListH %typePHIList @@ -1943,6 +1959,30 @@ // ThreadLocal ThreadLocal : THREAD_LOCAL { $$ = true; } | { $$ = false; }; +// AliaseeRef - Match either GlobalValue or bitcast to GlobalValue. +AliaseeRef : ResultTypes SymbolicValueRef { +const Type* VTy = $1->get(); +Value *V = getVal(VTy, $2); +GlobalValue* Aliasee = dyn_cast(V); +if (!Aliasee) + GEN_ERROR("Aliases can be created only to global values"); + +$$ = Aliasee; +CHECK_FOR_ERROR +delete $1; + } + | BITCAST '(' AliaseeRef TO Types ')' { +Constant *Val = $3; +const Type *DestTy = $5->get(); +if (!CastInst::castIsValid($1, $3, DestTy)) + GEN_ERROR("invalid cast opcode for cast from '" + +Val->getType()->getDescription() + "' to '" + +DestTy->getDescription() + "'"); + +$$ = ConstantExpr::getCast($1, $3, DestTy); +CHECK_FOR_ERROR +delete $5; + }; //===--===// // Rules to match Modules @@ -2045,34 +2085,20 @@ CurGV = 0; CHECK_FOR_ERROR } - | OptGlobalAssign GVVisibilityStyle ALIAS AliasLinkage ResultTypes -SymbolicValueRef { + | OptGlobalAssign GVVisibilityStyle ALIAS AliasLinkage AliaseeRef { std::string Name($1); if (Name.empty()) - GEN_ERROR("Alias name cannot be empty") -const PointerType *PFTy = 0; -const FunctionType *Ty = 0; -Value* V = 0; -const Type* VTy = 0; -if (!(PFTy = dyn_cast($5->get())) || -!(Ty = dyn_cast(PFTy->getElementType( { - VTy = $5->get(); - V = getExistingVal(VTy, $6); -} else { - VTy = PFTy; - V = getExistingVal(PFTy, $6); -} -if (V == 0) + GEN_ERROR("Alias name cannot be empty"); + +Constant* Aliasee = $5; +if (Aliasee == 0) GEN_ERROR(std::string("Invalid aliasee for alias: ") + $1); -if (GlobalValue* Aliasee = dyn_cast(V)) { - GlobalAlias* GA = new GlobalAlias(VTy, $4, Name, Aliasee, -CurModule.CurrentModule); - GA->setVisibility($2); - InsertValue(GA, CurModule.Values); -} else - GEN_ERROR("Aliases can be created only to global values"); + +GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), $4, Name, Aliasee, + CurModule.CurrentModule); +GA->setVisibility($2); +InsertValue(GA, CurModule.Values); CHECK_FOR_ERROR -delete $5; } | TARGET TargetDefinition { CHECK_FOR_ERROR ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.350 -> 1.351 --- Log message: wrap long lines Fix PR1358: http://llvm.org/PR1358 and test/Assembler/2007-04-25-AssemblerFoldExternWeak.ll, by creating forward decl globals with linkage extern_weak to defeat implicit constant folding. --- Diffs of the changes: (+16 -10) llvmAsmParser.y | 26 -- 1 files changed, 16 insertions(+), 10 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.350 llvm/lib/AsmParser/llvmAsmParser.y:1.351 --- llvm/lib/AsmParser/llvmAsmParser.y:1.350Wed Apr 25 18:52:02 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Thu Apr 26 00:30:35 2007 @@ -1608,7 +1608,8 @@ // Check to ensure that Type is not packed if (STy->isPacked()) - GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); + GEN_ERROR("Unpacked Initializer to vector type '" + +STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, *$3); delete $1; delete $3; @@ -1627,7 +1628,8 @@ // Check to ensure that Type is not packed if (STy->isPacked()) - GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); + GEN_ERROR("Unpacked Initializer to vector type '" + +STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, std::vector()); delete $1; @@ -1746,11 +1748,11 @@ GlobalValue *GV; if (const FunctionType *FTy = dyn_cast(PT->getElementType())) { - GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, + GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name, CurModule.CurrentModule); } else { GV = new GlobalVariable(PT->getElementType(), false, - GlobalValue::ExternalLinkage, 0, + GlobalValue::ExternalWeakLinkage, 0, Name, CurModule.CurrentModule); } @@ -2023,7 +2025,8 @@ } GlobalVarAttributes { CurGV = 0; } - | OptGlobalAssign GVInternalLinkage GVVisibilityStyle ThreadLocal GlobalType ConstVal { + | OptGlobalAssign GVInternalLinkage GVVisibilityStyle ThreadLocal GlobalType +ConstVal { if ($6 == 0) GEN_ERROR("Global value initializer is not a constant"); CurGV = ParseGlobalVariable($1, $2, $3, $5, $6->getType(), $6, $4); @@ -2031,7 +2034,8 @@ } GlobalVarAttributes { CurGV = 0; } - | OptGlobalAssign GVExternalLinkage GVVisibilityStyle ThreadLocal GlobalType Types { + | OptGlobalAssign GVExternalLinkage GVVisibilityStyle ThreadLocal GlobalType +Types { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$6)->getDescription()); CurGV = ParseGlobalVariable($1, $2, $3, $5, *$6, 0, $4); @@ -2041,7 +2045,8 @@ CurGV = 0; CHECK_FOR_ERROR } - | OptGlobalAssign GVVisibilityStyle ALIAS AliasLinkage ResultTypes SymbolicValueRef { + | OptGlobalAssign GVVisibilityStyle ALIAS AliasLinkage ResultTypes +SymbolicValueRef { std::string Name($1); if (Name.empty()) GEN_ERROR("Alias name cannot be empty") @@ -2060,7 +2065,8 @@ if (V == 0) GEN_ERROR(std::string("Invalid aliasee for alias: ") + $1); if (GlobalValue* Aliasee = dyn_cast(V)) { - GlobalAlias* GA = new GlobalAlias(VTy, $4, Name, Aliasee, CurModule.CurrentModule); + GlobalAlias* GA = new GlobalAlias(VTy, $4, Name, Aliasee, +CurModule.CurrentModule); GA->setVisibility($2); InsertValue(GA, CurModule.Values); } else @@ -2228,7 +2234,7 @@ CurModule.CurrentModule->getFunctionList().push_back(Fn); } else if (!FunctionName.empty() && // Merge with an earlier prototype? (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { -if (Fn->getFunctionType() != FT ) { +if (Fn->getFunctionType() != FT) { // The existing function doesn't have the same type. This is an overload // error. GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); @@ -2243,7 +2249,7 @@ AI->setName(""); } } else { // Not already defined? -Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, +Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName, CurModule.CurrentModule); InsertValue(Fn, CurModule.Values); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.349 -> 1.350 --- Log message: Quiet a compiler warning about assignment in an if-then conditional. --- Diffs of the changes: (+1 -2) llvmAsmParser.y |3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.349 llvm/lib/AsmParser/llvmAsmParser.y:1.350 --- llvm/lib/AsmParser/llvmAsmParser.y:1.349Wed Apr 25 13:07:40 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Apr 25 18:52:02 2007 @@ -2059,8 +2059,7 @@ } if (V == 0) GEN_ERROR(std::string("Invalid aliasee for alias: ") + $1); -GlobalValue* Aliasee; -if (Aliasee = dyn_cast(V)) { +if (GlobalValue* Aliasee = dyn_cast(V)) { GlobalAlias* GA = new GlobalAlias(VTy, $4, Name, Aliasee, CurModule.CurrentModule); GA->setVisibility($2); InsertValue(GA, CurModule.Values); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
On Apr 25, 2007, at 1:21 PM, Anton Korobeynikov wrote: >> Don't forget to check in the .cvs files, > No .cvs files change. Ah, nifty. Thanks, -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
> Don't forget to check in the .cvs files, No .cvs files change. -- With best regards, Anton Korobeynikov. Faculty of Mathematics & Mechanics, Saint Petersburg State University. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Don't forget to check in the .cvs files, -Chris On Apr 25, 2007, at 11:07 AM, Anton Korobeynikov wrote: > > > Changes in directory llvm/lib/AsmParser: > > llvmAsmParser.y updated: 1.348 -> 1.349 > --- > Log message: > > Add missed semicolon. Resotre compatibility with older bisons > > > --- > Diffs of the changes: (+1 -1) > > llvmAsmParser.y |2 +- > 1 files changed, 1 insertion(+), 1 deletion(-) > > > Index: llvm/lib/AsmParser/llvmAsmParser.y > diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.348 llvm/lib/AsmParser/ > llvmAsmParser.y:1.349 > --- llvm/lib/AsmParser/llvmAsmParser.y:1.348 Wed Apr 25 09:27:10 2007 > +++ llvm/lib/AsmParser/llvmAsmParser.yWed Apr 25 13:07:40 2007 > @@ -1146,7 +1146,7 @@ > GlobalAssign : GlobalName '=' { > $$ = $1; > CHECK_FOR_ERROR > - } > + }; > > GVInternalLinkage >: INTERNAL{ $$ = GlobalValue::InternalLinkage; } > > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.348 -> 1.349 --- Log message: Add missed semicolon. Resotre compatibility with older bisons --- Diffs of the changes: (+1 -1) llvmAsmParser.y |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.348 llvm/lib/AsmParser/llvmAsmParser.y:1.349 --- llvm/lib/AsmParser/llvmAsmParser.y:1.348Wed Apr 25 09:27:10 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Apr 25 13:07:40 2007 @@ -1146,7 +1146,7 @@ GlobalAssign : GlobalName '=' { $$ = $1; CHECK_FOR_ERROR - } + }; GVInternalLinkage : INTERNAL{ $$ = GlobalValue::InternalLinkage; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.346 -> 1.347 --- Log message: PR400: http://llvm.org/PR400 work phase 1. Add attributed load/store instructions for volatile/align to LLVM. --- Diffs of the changes: (+4 -4) llvmAsmParser.y |8 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.346 llvm/lib/AsmParser/llvmAsmParser.y:1.347 --- llvm/lib/AsmParser/llvmAsmParser.y:1.346Sun Apr 22 00:46:44 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Apr 22 14:24:39 2007 @@ -2940,7 +2940,7 @@ CHECK_FOR_ERROR } - | OptVolatile LOAD Types ValueRef { + | OptVolatile LOAD Types ValueRef OptCAlign { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription()); if (!isa($3->get())) @@ -2951,10 +2951,10 @@ (*$3)->getDescription()); Value* tmpVal = getVal(*$3, $4); CHECK_FOR_ERROR -$$ = new LoadInst(tmpVal, "", $1); +$$ = new LoadInst(tmpVal, "", $1, $5); delete $3; } - | OptVolatile STORE ResolvedVal ',' Types ValueRef { + | OptVolatile STORE ResolvedVal ',' Types ValueRef OptCAlign { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$5)->getDescription()); const PointerType *PT = dyn_cast($5->get()); @@ -2968,7 +2968,7 @@ Value* tmpVal = getVal(*$5, $6); CHECK_FOR_ERROR -$$ = new StoreInst($3, tmpVal, $1); +$$ = new StoreInst($3, tmpVal, $1, $7); delete $5; } | GETELEMENTPTR Types ValueRef IndexList { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.345 -> 1.346 --- Log message: For PR1146: http://llvm.org/PR1146 : Make ParamAttrsList objects unique. You can no longer directly create or destroy them but instead must go through the ParamAttrsList::get() interface. --- Diffs of the changes: (+59 -40) llvmAsmParser.y | 99 +--- 1 files changed, 59 insertions(+), 40 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.345 llvm/lib/AsmParser/llvmAsmParser.y:1.346 --- llvm/lib/AsmParser/llvmAsmParser.y:1.345Sat Apr 21 13:36:27 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Apr 22 00:46:44 2007 @@ -1299,24 +1299,28 @@ } | Types '(' ArgTypeListI ')' OptFuncAttrs { std::vector Params; -ParamAttrsList Attrs; -if ($5 != ParamAttr::None) - Attrs.addAttributes(0, $5); +ParamAttrsVector Attrs; +if ($5 != ParamAttr::None) { + ParamAttrsWithIndex X; X.index = 0; X.attrs = $5; + Attrs.push_back(X); +} unsigned index = 1; TypeWithAttrsList::iterator I = $3->begin(), E = $3->end(); for (; I != E; ++I, ++index) { const Type *Ty = I->Ty->get(); Params.push_back(Ty); if (Ty != Type::VoidTy) -if (I->Attrs != ParamAttr::None) - Attrs.addAttributes(index, I->Attrs); +if (I->Attrs != ParamAttr::None) { + ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; + Attrs.push_back(X); +} } bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); ParamAttrsList *ActualAttrs = 0; if (!Attrs.empty()) - ActualAttrs = new ParamAttrsList(Attrs); + ActualAttrs = ParamAttrsList::get(Attrs); FunctionType *FT = FunctionType::get(*$1, Params, isVarArg, ActualAttrs); delete $3; // Delete the argument list delete $1; // Delete the return type handle @@ -1325,24 +1329,28 @@ } | VOID '(' ArgTypeListI ')' OptFuncAttrs { std::vector Params; -ParamAttrsList Attrs; -if ($5 != ParamAttr::None) - Attrs.addAttributes(0, $5); +ParamAttrsVector Attrs; +if ($5 != ParamAttr::None) { + ParamAttrsWithIndex X; X.index = 0; X.attrs = $5; + Attrs.push_back(X); +} TypeWithAttrsList::iterator I = $3->begin(), E = $3->end(); unsigned index = 1; for ( ; I != E; ++I, ++index) { const Type* Ty = I->Ty->get(); Params.push_back(Ty); if (Ty != Type::VoidTy) -if (I->Attrs != ParamAttr::None) - Attrs.addAttributes(index, I->Attrs); +if (I->Attrs != ParamAttr::None) { + ParamAttrsWithIndex X; X.index = index; X.attrs = I->Attrs; + Attrs.push_back(X); +} } bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); ParamAttrsList *ActualAttrs = 0; if (!Attrs.empty()) - ActualAttrs = new ParamAttrsList(Attrs); + ActualAttrs = ParamAttrsList::get(Attrs); FunctionType *FT = FunctionType::get($1, Params, isVarArg, ActualAttrs); delete $3; // Delete the argument list @@ -2135,9 +2143,11 @@ GEN_ERROR("Reference to abstract result: "+ $2->get()->getDescription()); std::vector ParamTypeList; - ParamAttrsList ParamAttrs; - if ($7 != ParamAttr::None) -ParamAttrs.addAttributes(0, $7); + ParamAttrsVector Attrs; + if ($7 != ParamAttr::None) { +ParamAttrsWithIndex PAWI; PAWI.index = 0; PAWI.attrs = $7; +Attrs.push_back(PAWI); + } if ($5) { // If there are arguments... unsigned index = 1; for (ArgListType::iterator I = $5->begin(); I != $5->end(); ++I, ++index) { @@ -2146,20 +2156,21 @@ GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); ParamTypeList.push_back(Ty); if (Ty != Type::VoidTy) -if (I->Attrs != ParamAttr::None) - ParamAttrs.addAttributes(index, I->Attrs); +if (I->Attrs != ParamAttr::None) { + ParamAttrsWithIndex PAWI; PAWI.index = index; PAWI.attrs = I->Attrs; + Attrs.push_back(PAWI); +} } } bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; if (isVarArg) ParamTypeList.pop_back(); - ParamAttrsList *ActualAttrs = 0; - if (!ParamAttrs.empty()) -ActualAttrs = new ParamAttrsList(ParamAttrs); + ParamAttrsList *PAL = 0; + if (!Attrs.empty()) +PAL = ParamAttrsList::get(Attrs); - FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg, - ActualAttrs); + FunctionType *FT = FunctionType::get(*$2, ParamTypeList, isVarArg, PAL); const PointerType *PFT = PointerType::get(FT); delete $2; @@ -2490,9 +2501,11 @@ !(Ty = dyn_cast(PFTy->getElementType( { // Pull out the types of all of the arguments... std::vector ParamTypes; - ParamA
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.342 -> 1.343 --- Log message: Okay, yes there *is* a getKeyLength method on ValueName. And, it should be used because we *do* want to allow nulls in names. --- Diffs of the changes: (+1 -1) llvmAsmParser.y |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.342 llvm/lib/AsmParser/llvmAsmParser.y:1.343 --- llvm/lib/AsmParser/llvmAsmParser.y:1.342Mon Apr 16 15:31:06 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Apr 16 17:01:57 2007 @@ -2823,7 +2823,7 @@ // Check for call to invalid intrinsic to avoid crashing later. if (Function *theF = dyn_cast(V)) { - if (theF->hasName() && (strlen(theF->getValueName()->getKeyData()) >= 5)&& + if (theF->hasName() && (theF->getValueName()->getKeyLength() >= 5) && (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) && !theF->getIntrinsicID(true)) GEN_ERROR("Call to invalid LLVM intrinsic function '" + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
On Apr 16, 2007, at 2:46 PM, Reid Spencer wrote: > On Mon, 2007-04-16 at 14:33 -0700, Chris Lattner wrote: >>> Check length of string before we walk off the end of it. >>> Thanks, Chris. >> >> but I want to support nul characters in my names! > > Okay, so this whole "ValueName" and "StringMap" thing I don't > understand. How do you get the length of a name now? getKeyLength() method on the ValueName. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
On Mon, 2007-04-16 at 14:33 -0700, Chris Lattner wrote: > > Check length of string before we walk off the end of it. > > Thanks, Chris. > > but I want to support nul characters in my names! Okay, so this whole "ValueName" and "StringMap" thing I don't understand. How do you get the length of a name now? Reid. > > -Chris > > > > > --- > > Diffs of the changes: (+3 -3) > > > > llvmAsmParser.y |6 +++--- > > 1 files changed, 3 insertions(+), 3 deletions(-) > > > > > > Index: llvm/lib/AsmParser/llvmAsmParser.y > > diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.341 llvm/lib/AsmParser/ > > llvmAsmParser.y:1.342 > > --- llvm/lib/AsmParser/llvmAsmParser.y:1.341Mon Apr 16 12:45:50 2007 > > +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Apr 16 15:31:06 2007 > > @@ -2823,9 +2823,9 @@ > > > > // Check for call to invalid intrinsic to avoid crashing later. > > if (Function *theF = dyn_cast(V)) { > > - if (theF->hasName() && > > - 0 == strncmp(theF->getValueName()->getKeyData(), > > "llvm.", 5) && > > -!theF->getIntrinsicID(true)) > > + if (theF->hasName() && (strlen(theF->getValueName()- > > >getKeyData()) >= 5)&& > > + (0 == strncmp(theF->getValueName()->getKeyData(), > > "llvm.", 5)) && > > + !theF->getIntrinsicID(true)) > > GEN_ERROR("Call to invalid LLVM intrinsic function '" + > >theF->getName() + "'"); > > } > > > > > > > > ___ > > llvm-commits mailing list > > llvm-commits@cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
> Check length of string before we walk off the end of it. > Thanks, Chris. but I want to support nul characters in my names! -Chris > > --- > Diffs of the changes: (+3 -3) > > llvmAsmParser.y |6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > > > Index: llvm/lib/AsmParser/llvmAsmParser.y > diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.341 llvm/lib/AsmParser/ > llvmAsmParser.y:1.342 > --- llvm/lib/AsmParser/llvmAsmParser.y:1.341 Mon Apr 16 12:45:50 2007 > +++ llvm/lib/AsmParser/llvmAsmParser.yMon Apr 16 15:31:06 2007 > @@ -2823,9 +2823,9 @@ > > // Check for call to invalid intrinsic to avoid crashing later. > if (Function *theF = dyn_cast(V)) { > - if (theF->hasName() && > - 0 == strncmp(theF->getValueName()->getKeyData(), > "llvm.", 5) && > -!theF->getIntrinsicID(true)) > + if (theF->hasName() && (strlen(theF->getValueName()- > >getKeyData()) >= 5)&& > + (0 == strncmp(theF->getValueName()->getKeyData(), > "llvm.", 5)) && > + !theF->getIntrinsicID(true)) > GEN_ERROR("Call to invalid LLVM intrinsic function '" + >theF->getName() + "'"); > } > > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.341 -> 1.342 --- Log message: Check length of string before we walk off the end of it. Thanks, Chris. --- Diffs of the changes: (+3 -3) llvmAsmParser.y |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.341 llvm/lib/AsmParser/llvmAsmParser.y:1.342 --- llvm/lib/AsmParser/llvmAsmParser.y:1.341Mon Apr 16 12:45:50 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Apr 16 15:31:06 2007 @@ -2823,9 +2823,9 @@ // Check for call to invalid intrinsic to avoid crashing later. if (Function *theF = dyn_cast(V)) { - if (theF->hasName() && - 0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5) && -!theF->getIntrinsicID(true)) + if (theF->hasName() && (strlen(theF->getValueName()->getKeyData()) >= 5)&& + (0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5)) && + !theF->getIntrinsicID(true)) GEN_ERROR("Call to invalid LLVM intrinsic function '" + theF->getName() + "'"); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
> Use a more optimal way to get the name of a function. Thanks, Chris. Cool, please check that the name is >= 5 chars long too :) -Chris > > --- > Diffs of the changes: (+2 -1) > > llvmAsmParser.y |3 ++- > 1 files changed, 2 insertions(+), 1 deletion(-) > > > Index: llvm/lib/AsmParser/llvmAsmParser.y > diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.340 llvm/lib/AsmParser/ > llvmAsmParser.y:1.341 > --- llvm/lib/AsmParser/llvmAsmParser.y:1.340 Mon Apr 16 01:55:42 2007 > +++ llvm/lib/AsmParser/llvmAsmParser.yMon Apr 16 12:45:50 2007 > @@ -2823,7 +2823,8 @@ > > // Check for call to invalid intrinsic to avoid crashing later. > if (Function *theF = dyn_cast(V)) { > - if (theF->hasName() && 0 == strncmp(theF->getName().c_str(), > "llvm.", 5)&& > + if (theF->hasName() && > + 0 == strncmp(theF->getValueName()->getKeyData(), > "llvm.", 5) && > !theF->getIntrinsicID(true)) > GEN_ERROR("Call to invalid LLVM intrinsic function '" + >theF->getName() + "'"); > > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.340 -> 1.341 --- Log message: Use a more optimal way to get the name of a function. Thanks, Chris. --- Diffs of the changes: (+2 -1) llvmAsmParser.y |3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.340 llvm/lib/AsmParser/llvmAsmParser.y:1.341 --- llvm/lib/AsmParser/llvmAsmParser.y:1.340Mon Apr 16 01:55:42 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Apr 16 12:45:50 2007 @@ -2823,7 +2823,8 @@ // Check for call to invalid intrinsic to avoid crashing later. if (Function *theF = dyn_cast(V)) { - if (theF->hasName() && 0 == strncmp(theF->getName().c_str(), "llvm.", 5)&& + if (theF->hasName() && + 0 == strncmp(theF->getValueName()->getKeyData(), "llvm.", 5) && !theF->getIntrinsicID(true)) GEN_ERROR("Call to invalid LLVM intrinsic function '" + theF->getName() + "'"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
> +// Check for call to invalid intrinsic to avoid crashing later. > +if (Function *theF = dyn_cast(V)) { > + if (theF->hasName() && 0 == strncmp(theF->getName().c_str(), > "llvm.", 5)&& Please don't use getName().c_str(). This requires construction of a temporary std::string (i.e. heap traffic). Instead, plz use Value::getValueName() etc. -Chris > +!theF->getIntrinsicID(true)) > +GEN_ERROR("Call to invalid LLVM intrinsic function '" + > + theF->getName() + "'"); > +} > + > // Check the arguments > ValueList Args; > if ($6->empty()) { // Has no > arguments? > > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.339 -> 1.340 --- Log message: For PR1328: http://llvm.org/PR1328 : Use the new parameter on Function::getIntrinsicID to identify cases where a function is being called with an "llvm." name but it isn't actually an intrinsic. In such cases generate an error. --- Diffs of the changes: (+8 -0) llvmAsmParser.y |8 1 files changed, 8 insertions(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.339 llvm/lib/AsmParser/llvmAsmParser.y:1.340 --- llvm/lib/AsmParser/llvmAsmParser.y:1.339Thu Apr 12 13:32:50 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Apr 16 01:55:42 2007 @@ -2821,6 +2821,14 @@ Value *V = getVal(PFTy, $4); // Get the function we're calling... CHECK_FOR_ERROR +// Check for call to invalid intrinsic to avoid crashing later. +if (Function *theF = dyn_cast(V)) { + if (theF->hasName() && 0 == strncmp(theF->getName().c_str(), "llvm.", 5)&& +!theF->getIntrinsicID(true)) +GEN_ERROR("Call to invalid LLVM intrinsic function '" + + theF->getName() + "'"); +} + // Check the arguments ValueList Args; if ($6->empty()) { // Has no arguments? ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.334 -> 1.335 --- Log message: For PR1289: http://llvm.org/PR1289 : Check at the end of the parse that there are no unresolved types and no undefined values. Issue errors if there are. This gets rid of the need for implementation or checkpoint by ensuring you can't finish a parse with undefined things. --- Diffs of the changes: (+32 -0) llvmAsmParser.y | 32 1 files changed, 32 insertions(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.334 llvm/lib/AsmParser/llvmAsmParser.y:1.335 --- llvm/lib/AsmParser/llvmAsmParser.y:1.334Thu Mar 29 13:49:28 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Thu Mar 29 20:37:13 2007 @@ -2950,6 +2950,38 @@ return 0; } + // Emit an error if there are any unresolved types left. + if (!CurModule.LateResolveTypes.empty()) { +const ValID &DID = CurModule.LateResolveTypes.begin()->first; +if (DID.Type == ValID::LocalName) { + GenerateError("Undefined type remains at eof: '"+DID.getName() + "'"); +} else { + GenerateError("Undefined type remains at eof: #" + itostr(DID.Num)); +} +if (ParserResult) + delete ParserResult; +return 0; + } + + // Emit an error if there are any unresolved values left. + if (!CurModule.LateResolveValues.empty()) { +Value *V = CurModule.LateResolveValues.back(); +std::map >::iterator I = + CurModule.PlaceHolderInfo.find(V); + +if (I != CurModule.PlaceHolderInfo.end()) { + ValID &DID = I->second.first; + if (DID.Type == ValID::LocalName) { +GenerateError("Undefined value remains at eof: "+DID.getName() + "'"); + } else { +GenerateError("Undefined value remains at eof: #" + itostr(DID.Num)); + } + if (ParserResult) +delete ParserResult; + return 0; +} + } + // Check to make sure that parsing produced a result if (!ParserResult) return 0; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Lexer.l
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.333 -> 1.334 Lexer.l updated: 1.102 -> 1.103 --- Log message: Give users a grace period on the implementation keyword. This *will* get removed in a few days. --- Diffs of the changes: (+3 -3) Lexer.l |2 +- llvmAsmParser.y |4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.333 llvm/lib/AsmParser/llvmAsmParser.y:1.334 --- llvm/lib/AsmParser/llvmAsmParser.y:1.333Tue Mar 27 21:36:42 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Thu Mar 29 13:49:28 2007 @@ -1039,7 +1039,7 @@ %type OptAlign OptCAlign %type OptSection SectionString -%token CHECKPOINT ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK +%token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK %token DECLARE DEFINE GLOBAL CONSTANT SECTION VOLATILE %token TO DOTDOTDOT NULL_TOK UNDEF INTERNAL LINKONCE WEAK APPENDING %token DLLIMPORT DLLEXPORT EXTERN_WEAK @@ -1942,7 +1942,7 @@ | MODULE ASM_TOK AsmBlock { CHECK_FOR_ERROR } - | CHECKPOINT { + | IMPLEMENTATION { // Emit an error if there are any unresolved types left. if (!CurModule.LateResolveTypes.empty()) { const ValID &DID = CurModule.LateResolveTypes.begin()->first; Index: llvm/lib/AsmParser/Lexer.l diff -u llvm/lib/AsmParser/Lexer.l:1.102 llvm/lib/AsmParser/Lexer.l:1.103 --- llvm/lib/AsmParser/Lexer.l:1.102Tue Mar 27 21:36:42 2007 +++ llvm/lib/AsmParser/Lexer.l Thu Mar 29 13:49:28 2007 @@ -208,7 +208,7 @@ hidden { return HIDDEN; } extern_weak { return EXTERN_WEAK; } external{ return EXTERNAL; } -checkpoint { return CHECKPOINT; } +implementation { return IMPLEMENTATION; } zeroinitializer { return ZEROINITIALIZER; } \.\.\. { return DOTDOTDOT; } undef { return UNDEF; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.330 -> 1.331 --- Log message: Don't delete things before their last use (avoids bad reads). --- Diffs of the changes: (+0 -2) llvmAsmParser.y |2 -- 1 files changed, 2 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.330 llvm/lib/AsmParser/llvmAsmParser.y:1.331 --- llvm/lib/AsmParser/llvmAsmParser.y:1.330Mon Mar 19 20:13:00 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Mar 20 12:18:33 2007 @@ -1302,7 +1302,6 @@ Attrs.push_back($5); for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) { const Type *Ty = I->Ty->get(); - delete I->Ty; I->Ty = 0; Params.push_back(Ty); if (Ty != Type::VoidTy) Attrs.push_back(I->Attrs); @@ -1322,7 +1321,6 @@ Attrs.push_back($5); for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) { const Type* Ty = I->Ty->get(); - delete I->Ty; I->Ty = 0; Params.push_back(Ty); if (Ty != Type::VoidTy) Attrs.push_back(I->Attrs); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.329 -> 1.330 --- Log message: Plug some PATypeHolder memory leaks. --- Diffs of the changes: (+25 -6) llvmAsmParser.y | 31 +-- 1 files changed, 25 insertions(+), 6 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.329 llvm/lib/AsmParser/llvmAsmParser.y:1.330 --- llvm/lib/AsmParser/llvmAsmParser.y:1.329Mon Mar 19 15:40:22 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Mar 19 20:13:00 2007 @@ -513,9 +513,16 @@ CurFun.CurrentFunction->getBasicBlockList().remove(BB); CurFun.CurrentFunction->getBasicBlockList().push_back(BB); +// We're about to erase the entry, save the key so we can clean it up. +ValID Tmp = BBI->first; + // Erase the forward ref from the map as its no longer "forward" CurFun.BBForwardRefs.erase(ID); +// The key has been removed from the map but so we don't want to leave +// strdup'd memory around so destroy it too. +Tmp.destroy(); + // If its a numbered definition, bump the number and set the BB value. if (ID.Type == ValID::LocalID) { assert(ID.Num == CurFun.NextValNum && "Invalid new block number"); @@ -1294,8 +1301,10 @@ std::vector Attrs; Attrs.push_back($5); for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) { - Params.push_back(I->Ty->get()); - if (I->Ty->get() != Type::VoidTy) + const Type *Ty = I->Ty->get(); + delete I->Ty; I->Ty = 0; + Params.push_back(Ty); + if (Ty != Type::VoidTy) Attrs.push_back(I->Attrs); } bool isVarArg = Params.size() && Params.back() == Type::VoidTy; @@ -1312,8 +1321,10 @@ std::vector Attrs; Attrs.push_back($5); for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) { - Params.push_back(I->Ty->get()); - if (I->Ty->get() != Type::VoidTy) + const Type* Ty = I->Ty->get(); + delete I->Ty; I->Ty = 0; + Params.push_back(Ty); + if (Ty != Type::VoidTy) Attrs.push_back(I->Attrs); } bool isVarArg = Params.size() && Params.back() == Type::VoidTy; @@ -1429,11 +1440,13 @@ // TypeListI : Types { $$ = new std::list(); -$$->push_back(*$1); delete $1; +$$->push_back(*$1); +delete $1; CHECK_FOR_ERROR } | TypeListI ',' Types { -($$=$1)->push_back(*$3); delete $3; +($$=$1)->push_back(*$3); +delete $3; CHECK_FOR_ERROR }; @@ -2479,6 +2492,8 @@ PFTy = PointerType::get(Ty); } +delete $3; + Value *V = getVal(PFTy, $4); // Get the function we're calling... CHECK_FOR_ERROR BasicBlock *Normal = getBBVal($11); @@ -2595,6 +2610,7 @@ $$ = new ValueRefList(); ValueRefListEntry E; E.Attrs = $3; E.Val = getVal($1->get(), $2); $$->push_back(E); +delete $1; } | ValueRefList ',' Types ValueRef OptParamAttrs { if (!UpRefs.empty()) @@ -2602,6 +2618,7 @@ $$ = $1; ValueRefListEntry E; E.Attrs = $5; E.Val = getVal($3->get(), $4); $$->push_back(E); +delete $3; CHECK_FOR_ERROR } | /*empty*/ { $$ = new ValueRefList(); }; @@ -2674,6 +2691,7 @@ $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("icmp operator returned null"); +delete $3; } | FCMP FPredicates Types ValueRef ',' ValueRef { if (!UpRefs.empty()) @@ -2687,6 +2705,7 @@ $$ = CmpInst::create($1, $2, tmpVal1, tmpVal2); if ($$ == 0) GEN_ERROR("fcmp operator returned null"); +delete $3; } | CastOps ResolvedVal TO Types { if (!UpRefs.empty()) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.328 -> 1.329 --- Log message: Fix test/Assembler/2007-03-19-NegValue.ll by using the new "isSigned" parameter on ConstantInt::get to indicate the signedness of the intended value. --- Diffs of the changes: (+4 -9) llvmAsmParser.y | 13 - 1 files changed, 4 insertions(+), 9 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.328 llvm/lib/AsmParser/llvmAsmParser.y:1.329 --- llvm/lib/AsmParser/llvmAsmParser.y:1.328Mon Mar 19 13:39:36 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Mar 19 15:40:22 2007 @@ -392,7 +392,7 @@ Ty->getDescription() + "'"); return 0; } -return ConstantInt::get(Ty, D.ConstPool64); +return ConstantInt::get(Ty, D.ConstPool64, true); case ValID::ConstUIntVal: // Is it an unsigned const pool reference? if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { @@ -401,7 +401,7 @@ "' is invalid or out of range"); return 0; } else { // This is really a signed reference. Transmogrify. -return ConstantInt::get(Ty, D.ConstPool64); +return ConstantInt::get(Ty, D.ConstPool64, true); } } else { return ConstantInt::get(Ty, D.UConstPool64); @@ -1742,10 +1742,7 @@ | IntType ESINT64VAL { // integral constants if (!ConstantInt::isValueValidForType($1, $2)) GEN_ERROR("Constant value doesn't fit in type"); -APInt Val(64, $2); -uint32_t BitWidth = cast($1)->getBitWidth(); -Val.sextOrTrunc(BitWidth); -$$ = ConstantInt::get(Val); +$$ = ConstantInt::get($1, $2, true); CHECK_FOR_ERROR } | IntType ESAPINTVAL { // arbitrary precision integer constants @@ -1761,9 +1758,7 @@ | IntType EUINT64VAL { // integral constants if (!ConstantInt::isValueValidForType($1, $2)) GEN_ERROR("Constant value doesn't fit in type"); -uint32_t BitWidth = cast($1)->getBitWidth(); -APInt Val(BitWidth, $2); -$$ = ConstantInt::get(Val); +$$ = ConstantInt::get($1, $2, false); CHECK_FOR_ERROR } | IntType EUAPINTVAL { // arbitrary precision integer constants ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.327 -> 1.328 --- Log message: For PR1248: http://llvm.org/PR1248 : Eliminate support for type planes in numbered values. This simplifies the data structures involved in managing forward definitions, etc. Instead of requiring maps from type to value, we can now just use a vector of values. These changes also required rewrites of some support functions such as InsertValue, getBBVal, and ResolveDefinitions. Some other cosmetic changes were made as well. --- Diffs of the changes: (+171 -157) llvmAsmParser.y | 328 +--- 1 files changed, 171 insertions(+), 157 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.327 llvm/lib/AsmParser/llvmAsmParser.y:1.328 --- llvm/lib/AsmParser/llvmAsmParser.y:1.327Thu Mar 1 13:32:01 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Mar 19 13:39:36 2007 @@ -84,13 +84,12 @@ typedef std::vector ValueList; // Numbered defs static void -ResolveDefinitions(std::map &LateResolvers, - std::map *FutureLateResolvers = 0); +ResolveDefinitions(ValueList &LateResolvers, ValueList *FutureLateResolvers=0); static struct PerModuleInfo { Module *CurrentModule; - std::map Values; // Module level numbered definitions - std::map LateResolveValues; + ValueList Values; // Module level numbered definitions + ValueList LateResolveValues; std::vectorTypes; std::map LateResolveTypes; @@ -208,17 +207,16 @@ static struct PerFunctionInfo { Function *CurrentFunction; // Pointer to current function being created - std::map Values; // Keep track of #'d definitions - std::map LateResolveValues; + ValueList Values; // Keep track of #'d definitions + unsigned NextValNum; + ValueList LateResolveValues; bool isDeclare; // Is this function a forward declararation? GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration. GlobalValue::VisibilityTypes Visibility; /// BBForwardRefs - When we see forward references to basic blocks, keep /// track of them here. - std::map > BBForwardRefs; - std::vector NumberedBlocks; - unsigned NextBBNum; + std::map BBForwardRefs; inline PerFunctionInfo() { CurrentFunction = 0; @@ -229,16 +227,14 @@ inline void FunctionStart(Function *M) { CurrentFunction = M; -NextBBNum = 0; +NextValNum = 0; } void FunctionDone() { -NumberedBlocks.clear(); - // Any forward referenced blocks left? if (!BBForwardRefs.empty()) { GenerateError("Undefined reference to label " + - BBForwardRefs.begin()->first->getName()); + BBForwardRefs.begin()->second->getName()); return; } @@ -246,6 +242,7 @@ ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); Values.clear(); // Clear out function local definitions +BBForwardRefs.clear(); CurrentFunction = 0; isDeclare = false; Linkage = GlobalValue::ExternalLinkage; @@ -260,14 +257,23 @@ // Code to handle definitions of all the types //===--===// -static int InsertValue(Value *V, - std::map &ValueTab = CurFun.Values) { - if (V->hasName()) return -1; // Is this a numbered definition? - - // Yes, insert the value into the value table... - ValueList &List = ValueTab[V->getType()]; - List.push_back(V); - return List.size()-1; +static void InsertValue(Value *V, ValueList &ValueTab = CurFun.Values) { + // Things that have names or are void typed don't get slot numbers + if (V->hasName() || (V->getType() == Type::VoidTy)) +return; + + // In the case of function values, we have to allow for the forward reference + // of basic blocks, which are included in the numbering. Consequently, we keep + // track of the next insertion location with NextValNum. When a BB gets + // inserted, it could change the size of the CurFun.Values vector. + if (&ValueTab == &CurFun.Values) { +if (ValueTab.size() <= CurFun.NextValNum) + ValueTab.resize(CurFun.NextValNum+1); +ValueTab[CurFun.NextValNum++] = V; +return; + } + // For all other lists, its okay to just tack it on the back of the vector. + ValueTab.push_back(V); } static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { @@ -314,11 +320,11 @@ return Typ; } -// getValNonImprovising - Look up the value specified by the provided type and +// getExistingVal - Look up the value specified by the provided type and // the provided ValID. If the value exists and has already been defined, return // it. Otherwise return null. // -static Value *getValNonImprovising(const Type *Ty, const ValID &D) { +static Value *getExistingVal(const Type *Ty, const ValID &D) { if (isa(Ty)) { GenerateError("Fu
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.326 -> 1.327 --- Log message: Use a simpler constructor when constructing ConstantInt. Also, replace verbose code to sext/trunc or zext/trunc and APInt with new methods on that class. --- Diffs of the changes: (+9 -16) llvmAsmParser.y | 25 + 1 files changed, 9 insertions(+), 16 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.326 llvm/lib/AsmParser/llvmAsmParser.y:1.327 --- llvm/lib/AsmParser/llvmAsmParser.y:1.326Tue Feb 27 20:23:44 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Thu Mar 1 13:32:01 2007 @@ -1713,22 +1713,17 @@ GEN_ERROR("Constant value doesn't fit in type"); APInt Val(64, $2); uint32_t BitWidth = cast($1)->getBitWidth(); -if (BitWidth > 64) - Val.sext(BitWidth); -else if (BitWidth < 64) - Val.trunc(BitWidth); -$$ = ConstantInt::get($1, Val); +Val.sextOrTrunc(BitWidth); +$$ = ConstantInt::get(Val); CHECK_FOR_ERROR } | IntType ESAPINTVAL { // arbitrary precision integer constants uint32_t BitWidth = cast($1)->getBitWidth(); if ($2->getBitWidth() > BitWidth) { GEN_ERROR("Constant value does not fit in type"); -} else if ($2->getBitWidth() < BitWidth) - $2->sext(BitWidth); -else if ($2->getBitWidth() > BitWidth) - $2->trunc(BitWidth); -$$ = ConstantInt::get($1, *$2); +} +$2->sextOrTrunc(BitWidth); +$$ = ConstantInt::get(*$2); delete $2; CHECK_FOR_ERROR } @@ -1737,18 +1732,16 @@ GEN_ERROR("Constant value doesn't fit in type"); uint32_t BitWidth = cast($1)->getBitWidth(); APInt Val(BitWidth, $2); -$$ = ConstantInt::get($1, Val); +$$ = ConstantInt::get(Val); CHECK_FOR_ERROR } | IntType EUAPINTVAL { // arbitrary precision integer constants uint32_t BitWidth = cast($1)->getBitWidth(); if ($2->getBitWidth() > BitWidth) { GEN_ERROR("Constant value does not fit in type"); -} else if ($2->getBitWidth() < BitWidth) - $2->zext(BitWidth); -else if ($2->getBitWidth() > BitWidth) - $2->trunc(BitWidth); -$$ = ConstantInt::get($1, *$2); +} +$2->zextOrTrunc(BitWidth); +$$ = ConstantInt::get(*$2); delete $2; CHECK_FOR_ERROR } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.325 -> 1.326 --- Log message: Implement support for aribrary precision integers by creating two new tokens: ESAPINTVAL and EUAPINTVAL and adding an APInt* as a semantic value. This allows us to extend the definition of an integer constant to allow arbitrary precision integer constant values. --- Diffs of the changes: (+41 -2) llvmAsmParser.y | 43 +-- 1 files changed, 41 insertions(+), 2 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.325 llvm/lib/AsmParser/llvmAsmParser.y:1.326 --- llvm/lib/AsmParser/llvmAsmParser.y:1.325Wed Feb 14 21:39:17 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Feb 27 20:23:44 2007 @@ -925,6 +925,7 @@ llvm::GlobalValue::LinkageTypes Linkage; llvm::GlobalValue::VisibilityTypes Visibility; llvm::FunctionType::ParameterAttributes ParamAttrs; + llvm::APInt *APIntVal; int64_t SInt64Val; uint64_t UInt64Val; int SIntVal; @@ -978,6 +979,12 @@ // EUINT64VAL - A positive number within uns. long long range %token EUINT64VAL +// ESAPINTVAL - A negative number with arbitrary precision +%token ESAPINTVAL + +// EUAPINTVAL - A positive number with arbitrary precision +%token EUAPINTVAL + %token LOCALVAL_ID GLOBALVAL_ID // %123 @123 %token FPVAL // Float or Double constant @@ -1704,13 +1711,45 @@ | IntType ESINT64VAL { // integral constants if (!ConstantInt::isValueValidForType($1, $2)) GEN_ERROR("Constant value doesn't fit in type"); -$$ = ConstantInt::get($1, $2); +APInt Val(64, $2); +uint32_t BitWidth = cast($1)->getBitWidth(); +if (BitWidth > 64) + Val.sext(BitWidth); +else if (BitWidth < 64) + Val.trunc(BitWidth); +$$ = ConstantInt::get($1, Val); +CHECK_FOR_ERROR + } + | IntType ESAPINTVAL { // arbitrary precision integer constants +uint32_t BitWidth = cast($1)->getBitWidth(); +if ($2->getBitWidth() > BitWidth) { + GEN_ERROR("Constant value does not fit in type"); +} else if ($2->getBitWidth() < BitWidth) + $2->sext(BitWidth); +else if ($2->getBitWidth() > BitWidth) + $2->trunc(BitWidth); +$$ = ConstantInt::get($1, *$2); +delete $2; CHECK_FOR_ERROR } | IntType EUINT64VAL { // integral constants if (!ConstantInt::isValueValidForType($1, $2)) GEN_ERROR("Constant value doesn't fit in type"); -$$ = ConstantInt::get($1, $2); +uint32_t BitWidth = cast($1)->getBitWidth(); +APInt Val(BitWidth, $2); +$$ = ConstantInt::get($1, Val); +CHECK_FOR_ERROR + } + | IntType EUAPINTVAL { // arbitrary precision integer constants +uint32_t BitWidth = cast($1)->getBitWidth(); +if ($2->getBitWidth() > BitWidth) { + GEN_ERROR("Constant value does not fit in type"); +} else if ($2->getBitWidth() < BitWidth) + $2->zext(BitWidth); +else if ($2->getBitWidth() > BitWidth) + $2->trunc(BitWidth); +$$ = ConstantInt::get($1, *$2); +delete $2; CHECK_FOR_ERROR } | INTTYPE TRUETOK { // Boolean constants ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.324 -> 1.325 --- Log message: For PR1195: http://llvm.org/PR1195 : Change use of "packed" term to "vector" in comments, strings, variable names, etc. --- Diffs of the changes: (+10 -8) llvmAsmParser.y | 18 ++ 1 files changed, 10 insertions(+), 8 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.324 llvm/lib/AsmParser/llvmAsmParser.y:1.325 --- llvm/lib/AsmParser/llvmAsmParser.y:1.324Wed Feb 14 20:26:09 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Feb 14 21:39:17 2007 @@ -1292,7 +1292,7 @@ delete $4; CHECK_FOR_ERROR } - | '<' EUINT64VAL 'x' Types '>' { // Packed array type? + | '<' EUINT64VAL 'x' Types '>' { // Vector type? const llvm::Type* ElemTy = $4->get(); if ((unsigned)$2 != $2) GEN_ERROR("Unsigned result not equal to signed result"); @@ -1525,7 +1525,7 @@ // Check to ensure that Type is not packed if (STy->isPacked()) - GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); + GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, *$3); delete $1; delete $3; @@ -1544,7 +1544,7 @@ // Check to ensure that Type is not packed if (STy->isPacked()) - GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); + GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, std::vector()); delete $1; @@ -1569,7 +1569,8 @@ // Check to ensure that Type is packed if (!STy->isPacked()) - GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); + GEN_ERROR("Vector initializer to non-vector type '" + +STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, *$4); delete $1; delete $4; @@ -1588,7 +1589,8 @@ // Check to ensure that Type is packed if (!STy->isPacked()) - GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); + GEN_ERROR("Vector initializer to non-vector type '" + +STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, std::vector()); delete $1; @@ -2592,7 +2594,7 @@ ($1 == Instruction::URem || $1 == Instruction::SRem || $1 == Instruction::FRem)) - GEN_ERROR("Remainder not supported on packed types"); + GEN_ERROR("Remainder not supported on vector types"); Value* val1 = getVal(*$2, $3); CHECK_FOR_ERROR Value* val2 = getVal(*$2, $5); @@ -2623,7 +2625,7 @@ if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription()); if (isa((*$3).get())) - GEN_ERROR("Packed types not supported by icmp instruction"); + GEN_ERROR("Vector types not supported by icmp instruction"); Value* tmpVal1 = getVal(*$3, $4); CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); @@ -2636,7 +2638,7 @@ if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription()); if (isa((*$3).get())) - GEN_ERROR("Packed types not supported by fcmp instruction"); + GEN_ERROR("Vector types not supported by fcmp instruction"); Value* tmpVal1 = getVal(*$3, $4); CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.321 -> 1.322 --- Log message: eliminate use of methods that take vectors as args --- Diffs of the changes: (+4 -3) llvmAsmParser.y |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.321 llvm/lib/AsmParser/llvmAsmParser.y:1.322 --- llvm/lib/AsmParser/llvmAsmParser.y:1.321Sun Feb 11 15:39:35 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Feb 12 18:57:40 2007 @@ -1746,7 +1746,8 @@ GEN_ERROR("GetElementPtr requires a pointer operand"); const Type *IdxTy = - GetElementPtrInst::getIndexedType($3->getType(), *$4, true); + GetElementPtrInst::getIndexedType($3->getType(), &(*$4)[0], $4->size(), +true); if (!IdxTy) GEN_ERROR("Index list invalid for constant getelementptr"); @@ -2859,12 +2860,12 @@ if (!isa($2->get())) GEN_ERROR("getelementptr insn requires pointer operand"); -if (!GetElementPtrInst::getIndexedType(*$2, *$4, true)) +if (!GetElementPtrInst::getIndexedType(*$2, &(*$4)[0], $4->size(), true)) GEN_ERROR("Invalid getelementptr indices for type '" + (*$2)->getDescription()+ "'"); Value* tmpVal = getVal(*$2, $3); CHECK_FOR_ERROR -$$ = new GetElementPtrInst(tmpVal, *$4); +$$ = new GetElementPtrInst(tmpVal, &(*$4)[0], $4->size()); delete $2; delete $4; }; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.320 -> 1.321 --- Log message: add #include --- Diffs of the changes: (+1 -0) llvmAsmParser.y |1 + 1 files changed, 1 insertion(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.320 llvm/lib/AsmParser/llvmAsmParser.y:1.321 --- llvm/lib/AsmParser/llvmAsmParser.y:1.320Mon Feb 5 14:47:20 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Feb 11 15:39:35 2007 @@ -26,6 +26,7 @@ #include "llvm/Support/Streams.h" #include #include +#include #include #ifndef NDEBUG #define YYDEBUG 1 ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.318 -> 1.319 --- Log message: ! removal was a little over zealous. Put the ! back in asserts. --- Diffs of the changes: (+9 -9) llvmAsmParser.y | 18 +- 1 files changed, 9 insertions(+), 9 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.318 llvm/lib/AsmParser/llvmAsmParser.y:1.319 --- llvm/lib/AsmParser/llvmAsmParser.y:1.318Mon Feb 5 04:16:10 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Feb 5 11:01:20 2007 @@ -429,11 +429,11 @@ return IA; } default: -assert(0 && "Unhandled case"); +assert(0 && "Unhandled case!"); return 0; } // End of switch - assert(0 && "Unhandled case"); + assert(0 && "Unhandled case!"); return 0; } @@ -484,7 +484,7 @@ ///or may not be a forward reference. /// static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { - assert(inFunctionScope() && "Can't get basic block at global scope"); + assert(inFunctionScope() && "Can't get basic block at global scope!"); std::string Name; BasicBlock *BB = 0; @@ -573,7 +573,7 @@ std::map >::iterator PHI = CurModule.PlaceHolderInfo.find(V); - assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error"); + assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); ValID &DID = PHI->second.first; @@ -639,7 +639,7 @@ return; } - assert(inFunctionScope() && "Must be in function scope"); + assert(inFunctionScope() && "Must be in function scope!"); SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); if (ST.lookup(V->getType(), Name)) { GenerateError("Redefinition of value '" + Name + "' of type '" + @@ -724,7 +724,7 @@ // allowed to be redefined in the specified context. If the name is a new name // for the type plane, it is inserted and false is returned. static bool setTypeName(const Type *T, char *NameStr) { - assert(!inFunctionScope() && "Can't give types function-local names"); + assert(!inFunctionScope() && "Can't give types function-local names!"); if (NameStr == 0) return false; std::string Name(NameStr); // Copy string @@ -741,7 +741,7 @@ if (AlreadyExists) { // Inserting a name that is already defined??? const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); -assert(Existing && "Conflict but no matching type?"); +assert(Existing && "Conflict but no matching type?!"); // There is only one case where this is allowed: when we are refining an // opaque type. In this case, Existing will be an opaque type. @@ -1625,7 +1625,7 @@ // in the future with the right type of variable. // if (V == 0) { - assert(isa(Ty) && "Globals may only be used as pointers"); + assert(isa(Ty) && "Globals may only be used as pointers!"); const PointerType *PT = cast(Ty); // First check to see if the forward references value is already created! @@ -2116,7 +2116,7 @@ if ($5) { // Is null if empty... if (isVarArg) { // Nuke the last entry assert($5->back().Ty->get() == Type::VoidTy && $5->back().Name == 0&& - "Not a varargs marker"); + "Not a varargs marker!"); delete $5->back().Ty; $5->pop_back(); // Delete the last entry } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.317 -> 1.318 --- Log message: There is nothing exclamatory about an error message. No other compiler or assembler uses ! at the end of every message. We shouldn't either. --- Diffs of the changes: (+102 -102) llvmAsmParser.y | 204 1 files changed, 102 insertions(+), 102 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.317 llvm/lib/AsmParser/llvmAsmParser.y:1.318 --- llvm/lib/AsmParser/llvmAsmParser.y:1.317Thu Feb 1 20:16:22 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Feb 5 04:16:10 2007 @@ -283,7 +283,7 @@ } break; default: -GenerateError("Internal parser error: Invalid symbol type reference!"); +GenerateError("Internal parser error: Invalid symbol type reference"); return 0; } @@ -370,7 +370,7 @@ if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { GenerateError("Signed integral constant '" + itostr(D.ConstPool64) + "' is invalid for type '" + - Ty->getDescription() + "'!"); + Ty->getDescription() + "'"); return 0; } return ConstantInt::get(Ty, D.ConstPool64); @@ -379,7 +379,7 @@ if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) { if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) { GenerateError("Integral constant '" + utostr(D.UConstPool64) + - "' is invalid or out of range!"); + "' is invalid or out of range"); return 0; } else { // This is really a signed reference. Transmogrify. return ConstantInt::get(Ty, D.ConstPool64); @@ -390,14 +390,14 @@ case ValID::ConstFPVal:// Is it a floating point const pool reference? if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP)) { - GenerateError("FP constant invalid for type!!"); + GenerateError("FP constant invalid for type"); return 0; } return ConstantFP::get(Ty, D.ConstPoolFP); case ValID::ConstNullVal: // Is it a null value? if (!isa(Ty)) { - GenerateError("Cannot create a a non pointer null!"); + GenerateError("Cannot create a a non pointer null"); return 0; } return ConstantPointerNull::get(cast(Ty)); @@ -410,7 +410,7 @@ case ValID::ConstantVal: // Fully resolved constant? if (D.ConstantValue->getType() != Ty) { - GenerateError("Constant expression type different from required type!"); + GenerateError("Constant expression type different from required type"); return 0; } return D.ConstantValue; @@ -420,7 +420,7 @@ const FunctionType *FTy = PTy ? dyn_cast(PTy->getElementType()) : 0; if (!FTy || !InlineAsm::Verify(FTy, D.IAD->Constraints)) { - GenerateError("Invalid type for asm constraint string!"); + GenerateError("Invalid type for asm constraint string"); return 0; } InlineAsm *IA = InlineAsm::get(FTy, D.IAD->AsmString, D.IAD->Constraints, @@ -429,11 +429,11 @@ return IA; } default: -assert(0 && "Unhandled case!"); +assert(0 && "Unhandled case"); return 0; } // End of switch - assert(0 && "Unhandled case!"); + assert(0 && "Unhandled case"); return 0; } @@ -455,7 +455,7 @@ if (TriggerError) return 0; if (!Ty->isFirstClassType() && !isa(Ty)) { -GenerateError("Invalid use of a composite type!"); +GenerateError("Invalid use of a composite type"); return 0; } @@ -484,7 +484,7 @@ ///or may not be a forward reference. /// static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { - assert(inFunctionScope() && "Can't get basic block at global scope!"); + assert(inFunctionScope() && "Can't get basic block at global scope"); std::string Name; BasicBlock *BB = 0; @@ -573,7 +573,7 @@ std::map >::iterator PHI = CurModule.PlaceHolderInfo.find(V); - assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); + assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error"); ValID &DID = PHI->second.first; @@ -635,15 +635,15 @@ free(NameStr); // Free old string if (V->getType() == Type::VoidTy) { -GenerateError("Can't assign name '" + Name+"' to value with void type!"); +GenerateError("Can't assign name '" + Name+"' to value with void type"); return; } - assert(inFunctionScope() && "Must be in function scope!"); + assert(inFunctionScope() && "Must be in function scope"); SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable(); if (ST.lookup(V->getType(), Name)) { GenerateError("Redefinition of value '" + Name + "' of type '" + - V->getType()->getDescription() + "'!"); + V->getType()->getDescription() + "'");
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.315 -> 1.316 --- Log message: eliminate a temporary vector --- Diffs of the changes: (+3 -2) llvmAsmParser.y |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.315 llvm/lib/AsmParser/llvmAsmParser.y:1.316 --- llvm/lib/AsmParser/llvmAsmParser.y:1.315Tue Jan 30 14:08:37 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jan 30 22:43:46 2007 @@ -20,6 +20,7 @@ #include "llvm/SymbolTable.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/CommandLine.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/Streams.h" @@ -1733,7 +1734,7 @@ if (!IdxTy) GEN_ERROR("Index list invalid for constant getelementptr!"); -std::vector IdxVec; +SmallVector IdxVec; for (unsigned i = 0, e = $4->size(); i != e; ++i) if (Constant *C = dyn_cast((*$4)[i])) IdxVec.push_back(C); @@ -1742,7 +1743,7 @@ delete $4; -$$ = ConstantExpr::getGetElementPtr($3, IdxVec); +$$ = ConstantExpr::getGetElementPtr($3, &IdxVec[0], IdxVec.size()); CHECK_FOR_ERROR } | SELECT '(' ConstVal ',' ConstVal ',' ConstVal ')' { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Lexer.l ParserInternals.h
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.312 -> 1.313 Lexer.l updated: 1.95 -> 1.96 ParserInternals.h updated: 1.52 -> 1.53 --- Log message: For PR645: http://llvm.org/PR645 : Implement separation of local and global symbols. Local symbols and types now use % prefix. Global variables and functions now use @ prefix. For PR761: http://llvm.org/PR761 : Replace: target endian = target pointersize = With: target datalayout = --- Diffs of the changes: (+173 -157) Lexer.l | 59 +++-- ParserInternals.h | 38 +--- llvmAsmParser.y | 233 ++ 3 files changed, 173 insertions(+), 157 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.312 llvm/lib/AsmParser/llvmAsmParser.y:1.313 --- llvm/lib/AsmParser/llvmAsmParser.y:1.312Sun Jan 21 13:19:31 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Jan 26 02:04:51 2007 @@ -270,12 +270,12 @@ static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { switch (D.Type) { - case ValID::NumberVal: // Is it a numbered definition? + case ValID::LocalID: // Is it a numbered definition? // Module constants occupy the lowest numbered slots... -if ((unsigned)D.Num < CurModule.Types.size()) - return CurModule.Types[(unsigned)D.Num]; +if (D.Num < CurModule.Types.size()) + return CurModule.Types[D.Num]; break; - case ValID::NameVal: // Is it a named definition? + case ValID::LocalName: // Is it a named definition? if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { D.destroy(); // Free old strdup'd memory... return N; @@ -294,11 +294,11 @@ if (inFunctionScope()) { -if (D.Type == ValID::NameVal) { +if (D.Type == ValID::LocalName) { GenerateError("Reference to an undefined type: '" + D.getName() + "'"); return 0; } else { - GenerateError("Reference to an undefined type: #" + itostr(D.Num)); + GenerateError("Reference to an undefined type: #" + utostr(D.Num)); return 0; } } @@ -312,13 +312,6 @@ return Typ; } -static Value *lookupInSymbolTable(const Type *Ty, const std::string &Name) { - SymbolTable &SymTab = -inFunctionScope() ? CurFun.CurrentFunction->getValueSymbolTable() : -CurModule.CurrentModule->getValueSymbolTable(); - return SymTab.lookup(Ty, Name); -} - // getValNonImprovising - Look up the value specified by the provided type and // the provided ValID. If the value exists and has already been defined, return // it. Otherwise return null. @@ -331,29 +324,39 @@ } switch (D.Type) { - case ValID::NumberVal: { // Is it a numbered definition? -unsigned Num = (unsigned)D.Num; - -// Module constants occupy the lowest numbered slots... -std::map::iterator VI = CurModule.Values.find(Ty); -if (VI != CurModule.Values.end()) { - if (Num < VI->second.size()) -return VI->second[Num]; - Num -= VI->second.size(); -} - -// Make sure that our type is within bounds -VI = CurFun.Values.find(Ty); + case ValID::LocalID: { // Is it a numbered definition? +// Module constants occupy the lowest numbered slots. +std::map::iterator VI = CurFun.Values.find(Ty); +// Make sure that our type is within bounds. if (VI == CurFun.Values.end()) return 0; -// Check that the number is within bounds... -if (VI->second.size() <= Num) return 0; +// Check that the number is within bounds. +if (D.Num >= VI->second.size()) return 0; +return VI->second[D.Num]; + } + case ValID::GlobalID: { // Is it a numbered definition? +unsigned Num = D.Num; + +// Module constants occupy the lowest numbered slots... +std::map::iterator VI = CurModule.Values.find(Ty); +if (VI == CurModule.Values.end()) return 0; +if (D.Num >= VI->second.size()) return 0; return VI->second[Num]; } - - case ValID::NameVal: {// Is it a named definition? -Value *N = lookupInSymbolTable(Ty, std::string(D.Name)); + + case ValID::LocalName: {// Is it a named definition? +if (!inFunctionScope()) return 0; +SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable(); +Value *N = SymTab.lookup(Ty, D.Name); +if (N == 0) return 0; + +D.destroy(); // Free old strdup'd memory... +return N; + } + case ValID::GlobalName: {// Is it a named definition? +SymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable(); +Value *N = SymTab.lookup(Ty, D.Name); if (N == 0) return 0; D.destroy(); // Free old strdup'd memory... @@ -488,12 +491,12 @@ default: GenerateError("Illegal label reference " + ID.getName()); return 0; - case ValID::NumberVal:
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.310 -> 1.311 --- Log message: For PR1117: http://llvm.org/PR1117 : Make the assembler generate a nice error message if a bad cast instruction is attempted instead of asserting out. This is made possible by the recently exposed method CastInst::castIsValid() which checks the validity of any cast instruction. --- Diffs of the changes: (+12 -15) llvmAsmParser.y | 27 --- 1 files changed, 12 insertions(+), 15 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.310 llvm/lib/AsmParser/llvmAsmParser.y:1.311 --- llvm/lib/AsmParser/llvmAsmParser.y:1.310Sun Jan 14 20:27:26 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jan 16 20:47:33 2007 @@ -1708,14 +1708,12 @@ if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$5)->getDescription()); Constant *Val = $3; -const Type *Ty = $5->get(); -if (!Val->getType()->isFirstClassType()) - GEN_ERROR("cast constant expression from a non-primitive type: '" + - Val->getType()->getDescription() + "'!"); -if (!Ty->isFirstClassType()) - GEN_ERROR("cast constant expression to a non-primitive type: '" + -Ty->getDescription() + "'!"); -$$ = ConstantExpr::getCast($1, $3, $5->get()); +const Type *DestTy = $5->get(); +if (!CastInst::castIsValid($1, $3, DestTy)) + GEN_ERROR("invalid cast opcode for cast from '" + +Val->getType()->getDescription() + "' to '" + +DestTy->getDescription() + "'!"); +$$ = ConstantExpr::getCast($1, $3, DestTy); delete $5; } | GETELEMENTPTR '(' ConstVal IndexList ')' { @@ -2647,13 +2645,12 @@ if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$4)->getDescription()); Value* Val = $2; -const Type* Ty = $4->get(); -if (!Val->getType()->isFirstClassType()) - GEN_ERROR("cast from a non-primitive type: '" + -Val->getType()->getDescription() + "'!"); -if (!Ty->isFirstClassType()) - GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!"); -$$ = CastInst::create($1, Val, $4->get()); +const Type* DestTy = $4->get(); +if (!CastInst::castIsValid($1, Val, DestTy)) + GEN_ERROR("invalid cast opcode for cast from '" + +Val->getType()->getDescription() + "' to '" + +DestTy->getDescription() + "'!"); +$$ = CastInst::create($1, Val, DestTy); delete $4; } | SELECT ResolvedVal ',' ResolvedVal ',' ResolvedVal { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.308 -> 1.309 --- Log message: allow i1 to operators like shift and add. --- Diffs of the changes: (+4 -4) llvmAsmParser.y |8 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.308 llvm/lib/AsmParser/llvmAsmParser.y:1.309 --- llvm/lib/AsmParser/llvmAsmParser.y:1.308Fri Jan 12 23:00:20 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Jan 14 20:00:29 2007 @@ -1274,7 +1274,7 @@ const llvm::Type* ElemTy = $4->get(); if ((unsigned)$2 != $2) GEN_ERROR("Unsigned result not equal to signed result"); - if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger()) + if (!ElemTy->isFloatingPoint() && !ElemTy->isIntegral()) GEN_ERROR("Element type of a PackedType must be primitive"); if (!isPowerOf2_32($2)) GEN_ERROR("Vector length should be a power of 2!"); @@ -1777,7 +1777,7 @@ | ShiftOps '(' ConstVal ',' ConstVal ')' { if ($5->getType() != Type::Int8Ty) GEN_ERROR("Shift count for shift constant must be i8 type!"); -if (!$3->getType()->isInteger()) +if (!$3->getType()->isIntegral()) GEN_ERROR("Shift constant expression requires integer operand!"); CHECK_FOR_ERROR; $$ = ConstantExpr::get($1, $3, $5); @@ -2573,7 +2573,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription()); -if (!(*$2)->isInteger() && !(*$2)->isFloatingPoint() && +if (!(*$2)->isIntegral() && !(*$2)->isFloatingPoint() && !isa((*$2).get())) GEN_ERROR( "Arithmetic operator requires integer, FP, or packed operands!"); @@ -2637,7 +2637,7 @@ | ShiftOps ResolvedVal ',' ResolvedVal { if ($4->getType() != Type::Int8Ty) GEN_ERROR("Shift amount must be i8 type!"); -if (!$2->getType()->isInteger()) +if (!$2->getType()->isIntegral()) GEN_ERROR("Shift constant expression requires integer operand!"); CHECK_FOR_ERROR; $$ = new ShiftInst($1, $2, $4); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
On Fri, 12 Jan 2007, Reid Spencer wrote: >> This didn't use to be dead and you've just broken llvm-upgrade which >> will pass "NOT" through. If the intention is not to support "NOT" any >> more than I will add the necessary transform in llvm-upgrade. > > Okay, I'm wrong. The llvm-upgrade lexer wasn't recognizing it either. > NOT is just plain dead now :) Even if it did pass it in, the lexer would not have lexed it. The Lexer never make the token, so the code in the parser is certainly dead. -Chris >>> --- >>> Diffs of the changes: (+1 -14) >>> >>> llvmAsmParser.y | 15 +-- >>> 1 files changed, 1 insertion(+), 14 deletions(-) >>> >>> >>> Index: llvm/lib/AsmParser/llvmAsmParser.y >>> diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.305 >>> llvm/lib/AsmParser/llvmAsmParser.y:1.306 >>> --- llvm/lib/AsmParser/llvmAsmParser.y:1.305Fri Jan 12 01:05:13 2007 >>> +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Jan 12 12:32:39 2007 >>> @@ -974,7 +974,7 @@ >>> %token DECLARE DEFINE GLOBAL CONSTANT SECTION VOLATILE >>> %token TO DOTDOTDOT NULL_TOK UNDEF INTERNAL LINKONCE WEAK APPENDING >>> %token DLLIMPORT DLLEXPORT EXTERN_WEAK >>> -%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG >>> ALIGN >>> +%token OPAQUE EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN >>> %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT >>> %token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK >>> %token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK >>> @@ -2611,19 +2611,6 @@ >>> if ($$ == 0) >>>GEN_ERROR("fcmp operator returned null!"); >>>} >>> - | NOT ResolvedVal { >>> -cerr << "WARNING: Use of eliminated 'not' instruction:" >>> - << " Replacing with 'xor'.\n"; >>> - >>> -Value *Ones = ConstantInt::getAllOnesValue($2->getType()); >>> -if (Ones == 0) >>> - GEN_ERROR("Expected integral type for not instruction!"); >>> - >>> -$$ = BinaryOperator::create(Instruction::Xor, $2, Ones); >>> -if ($$ == 0) >>> - GEN_ERROR("Could not create a xor instruction!"); >>> -CHECK_FOR_ERROR >>> - } >>>| ShiftOps ResolvedVal ',' ResolvedVal { >>> if ($4->getType() != Type::Int8Ty) >>>GEN_ERROR("Shift amount must be i8 type!"); >>> >>> >>> >>> ___ >>> llvm-commits mailing list >>> llvm-commits@cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> ___ >> llvm-commits mailing list >> llvm-commits@cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -Chris -- http://nondot.org/sabre/ http://llvm.org/ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
On Fri, 2007-01-12 at 11:59 -0800, Reid Spencer wrote: > On Fri, 2007-01-12 at 12:32 -0600, Chris Lattner wrote: > > > > Changes in directory llvm/lib/AsmParser: > > > > llvmAsmParser.y updated: 1.305 -> 1.306 > > --- > > Log message: > > > > This production is dead, the lexer can never return 'NOT' > > This didn't use to be dead and you've just broken llvm-upgrade which > will pass "NOT" through. If the intention is not to support "NOT" any > more than I will add the necessary transform in llvm-upgrade. Okay, I'm wrong. The llvm-upgrade lexer wasn't recognizing it either. NOT is just plain dead now :) Reid. > > > > > > > --- > > Diffs of the changes: (+1 -14) > > > > llvmAsmParser.y | 15 +-- > > 1 files changed, 1 insertion(+), 14 deletions(-) > > > > > > Index: llvm/lib/AsmParser/llvmAsmParser.y > > diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.305 > > llvm/lib/AsmParser/llvmAsmParser.y:1.306 > > --- llvm/lib/AsmParser/llvmAsmParser.y:1.305Fri Jan 12 01:05:13 2007 > > +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Jan 12 12:32:39 2007 > > @@ -974,7 +974,7 @@ > > %token DECLARE DEFINE GLOBAL CONSTANT SECTION VOLATILE > > %token TO DOTDOTDOT NULL_TOK UNDEF INTERNAL LINKONCE WEAK APPENDING > > %token DLLIMPORT DLLEXPORT EXTERN_WEAK > > -%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG > > ALIGN > > +%token OPAQUE EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN > > %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT > > %token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK > > %token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK > > @@ -2611,19 +2611,6 @@ > > if ($$ == 0) > >GEN_ERROR("fcmp operator returned null!"); > >} > > - | NOT ResolvedVal { > > -cerr << "WARNING: Use of eliminated 'not' instruction:" > > - << " Replacing with 'xor'.\n"; > > - > > -Value *Ones = ConstantInt::getAllOnesValue($2->getType()); > > -if (Ones == 0) > > - GEN_ERROR("Expected integral type for not instruction!"); > > - > > -$$ = BinaryOperator::create(Instruction::Xor, $2, Ones); > > -if ($$ == 0) > > - GEN_ERROR("Could not create a xor instruction!"); > > -CHECK_FOR_ERROR > > - } > >| ShiftOps ResolvedVal ',' ResolvedVal { > > if ($4->getType() != Type::Int8Ty) > >GEN_ERROR("Shift amount must be i8 type!"); > > > > > > > > ___ > > llvm-commits mailing list > > llvm-commits@cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
On Fri, 2007-01-12 at 12:32 -0600, Chris Lattner wrote: > > Changes in directory llvm/lib/AsmParser: > > llvmAsmParser.y updated: 1.305 -> 1.306 > --- > Log message: > > This production is dead, the lexer can never return 'NOT' This didn't use to be dead and you've just broken llvm-upgrade which will pass "NOT" through. If the intention is not to support "NOT" any more than I will add the necessary transform in llvm-upgrade. > > > --- > Diffs of the changes: (+1 -14) > > llvmAsmParser.y | 15 +-- > 1 files changed, 1 insertion(+), 14 deletions(-) > > > Index: llvm/lib/AsmParser/llvmAsmParser.y > diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.305 > llvm/lib/AsmParser/llvmAsmParser.y:1.306 > --- llvm/lib/AsmParser/llvmAsmParser.y:1.305 Fri Jan 12 01:05:13 2007 > +++ llvm/lib/AsmParser/llvmAsmParser.yFri Jan 12 12:32:39 2007 > @@ -974,7 +974,7 @@ > %token DECLARE DEFINE GLOBAL CONSTANT SECTION VOLATILE > %token TO DOTDOTDOT NULL_TOK UNDEF INTERNAL LINKONCE WEAK APPENDING > %token DLLIMPORT DLLEXPORT EXTERN_WEAK > -%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN > +%token OPAQUE EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN > %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT > %token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK > %token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK > @@ -2611,19 +2611,6 @@ > if ($$ == 0) >GEN_ERROR("fcmp operator returned null!"); >} > - | NOT ResolvedVal { > -cerr << "WARNING: Use of eliminated 'not' instruction:" > - << " Replacing with 'xor'.\n"; > - > -Value *Ones = ConstantInt::getAllOnesValue($2->getType()); > -if (Ones == 0) > - GEN_ERROR("Expected integral type for not instruction!"); > - > -$$ = BinaryOperator::create(Instruction::Xor, $2, Ones); > -if ($$ == 0) > - GEN_ERROR("Could not create a xor instruction!"); > -CHECK_FOR_ERROR > - } >| ShiftOps ResolvedVal ',' ResolvedVal { > if ($4->getType() != Type::Int8Ty) >GEN_ERROR("Shift amount must be i8 type!"); > > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.305 -> 1.306 --- Log message: This production is dead, the lexer can never return 'NOT' --- Diffs of the changes: (+1 -14) llvmAsmParser.y | 15 +-- 1 files changed, 1 insertion(+), 14 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.305 llvm/lib/AsmParser/llvmAsmParser.y:1.306 --- llvm/lib/AsmParser/llvmAsmParser.y:1.305Fri Jan 12 01:05:13 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Jan 12 12:32:39 2007 @@ -974,7 +974,7 @@ %token DECLARE DEFINE GLOBAL CONSTANT SECTION VOLATILE %token TO DOTDOTDOT NULL_TOK UNDEF INTERNAL LINKONCE WEAK APPENDING %token DLLIMPORT DLLEXPORT EXTERN_WEAK -%token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN +%token OPAQUE EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT %token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK %token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK @@ -2611,19 +2611,6 @@ if ($$ == 0) GEN_ERROR("fcmp operator returned null!"); } - | NOT ResolvedVal { -cerr << "WARNING: Use of eliminated 'not' instruction:" - << " Replacing with 'xor'.\n"; - -Value *Ones = ConstantInt::getAllOnesValue($2->getType()); -if (Ones == 0) - GEN_ERROR("Expected integral type for not instruction!"); - -$$ = BinaryOperator::create(Instruction::Xor, $2, Ones); -if ($$ == 0) - GEN_ERROR("Could not create a xor instruction!"); -CHECK_FOR_ERROR - } | ShiftOps ResolvedVal ',' ResolvedVal { if ($4->getType() != Type::Int8Ty) GEN_ERROR("Shift amount must be i8 type!"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.301 -> 1.302 --- Log message: Make packed structs use packed initialiers for consistency --- Diffs of the changes: (+52 -0) llvmAsmParser.y | 52 1 files changed, 52 insertions(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.301 llvm/lib/AsmParser/llvmAsmParser.y:1.302 --- llvm/lib/AsmParser/llvmAsmParser.y:1.301Sat Jan 6 01:24:43 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Jan 8 12:16:47 2007 @@ -1484,6 +1484,10 @@ "' for element #" + utostr(i) + " of structure initializer!"); +// Check to ensure that Type is not packed +if (STy->isPacked()) + GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); + $$ = ConstantStruct::get(STy, *$3); delete $1; delete $3; CHECK_FOR_ERROR @@ -1499,6 +1503,54 @@ if (STy->getNumContainedTypes() != 0) GEN_ERROR("Illegal number of initializers for structure type!"); +// Check to ensure that Type is not packed +if (STy->isPacked()) + GEN_ERROR("Unpacked Initializer to packed type '" + STy->getDescription() + "'"); + +$$ = ConstantStruct::get(STy, std::vector()); +delete $1; +CHECK_FOR_ERROR + } + | Types '<' '{' ConstVector '}' '>' { +const StructType *STy = dyn_cast($1->get()); +if (STy == 0) + GEN_ERROR("Cannot make struct constant with type: '" + + (*$1)->getDescription() + "'!"); + +if ($4->size() != STy->getNumContainedTypes()) + GEN_ERROR("Illegal number of initializers for structure type!"); + +// Check to ensure that constants are compatible with the type initializer! +for (unsigned i = 0, e = $4->size(); i != e; ++i) + if ((*$4)[i]->getType() != STy->getElementType(i)) +GEN_ERROR("Expected type '" + + STy->getElementType(i)->getDescription() + + "' for element #" + utostr(i) + + " of structure initializer!"); + +// Check to ensure that Type is packed +if (!STy->isPacked()) + GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); + +$$ = ConstantStruct::get(STy, *$4); +delete $1; delete $4; +CHECK_FOR_ERROR + } + | Types '<' '{' '}' '>' { +if (!UpRefs.empty()) + GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription()); +const StructType *STy = dyn_cast($1->get()); +if (STy == 0) + GEN_ERROR("Cannot make struct constant with type: '" + + (*$1)->getDescription() + "'!"); + +if (STy->getNumContainedTypes() != 0) + GEN_ERROR("Illegal number of initializers for structure type!"); + +// Check to ensure that Type is packed +if (!STy->isPacked()) + GEN_ERROR("Packed Initializer to unpacked type '" + STy->getDescription() + "'"); + $$ = ConstantStruct::get(STy, std::vector()); delete $1; CHECK_FOR_ERROR ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.299 -> 1.300 --- Log message: For PR1077: http://llvm.org/PR1077 : Disallow merging of dupliate global variables. It is now illegal to declare or define two global variables of the same name and same type. llvm-gcc3 is dead in 2.0 and llvm-gcc4 doesn't have that problem nor need the hack. --- Diffs of the changes: (+7 -26) llvmAsmParser.y | 33 +++-- 1 files changed, 7 insertions(+), 26 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.299 llvm/lib/AsmParser/llvmAsmParser.y:1.300 --- llvm/lib/AsmParser/llvmAsmParser.y:1.299Fri Jan 5 11:06:19 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Jan 5 15:50:38 2007 @@ -635,8 +635,8 @@ assert(inFunctionScope() && "Must be in function scope!"); SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable(); if (ST.lookup(V->getType(), Name)) { - GenerateError("Redefinition of value named '" + Name + "' in the '" + - V->getType()->getDescription() + "' type plane!"); + GenerateError("Redefinition of value '" + Name + "' of type '" + + V->getType()->getDescription() + "'!"); return; } @@ -687,32 +687,13 @@ } // If this global has a name, check to see if there is already a definition - // of this global in the module. If so, merge as appropriate. Note that - // this is really just a hack around problems in the CFE. :( + // of this global in the module. If so, it is an error. if (!Name.empty()) { // We are a simple redefinition of a value, check to see if it is defined // the same as the old one. -if (GlobalVariable *EGV = -CurModule.CurrentModule->getGlobalVariable(Name, Ty)) { - // We are allowed to redefine a global variable in two circumstances: - // 1. If at least one of the globals is uninitialized or - // 2. If both initializers have the same value. - // - if (!EGV->hasInitializer() || !Initializer || - EGV->getInitializer() == Initializer) { - -// Make sure the existing global version gets the initializer! Make -// sure that it also gets marked const if the new version is. -if (Initializer && !EGV->hasInitializer()) - EGV->setInitializer(Initializer); -if (isConstantGlobal) - EGV->setConstant(true); -EGV->setLinkage(Linkage); -return EGV; - } - +if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) { GenerateError("Redefinition of global variable named '" + Name + - "' in the '" + Ty->getDescription() + "' type plane!"); + "' of type '" + Ty->getDescription() + "'!"); return 0; } } @@ -767,8 +748,8 @@ if (Existing == T) return true; // Yes, it's equal. // Any other kind of (non-equivalent) redefinition is an error. -GenerateError("Redefinition of type named '" + Name + "' in the '" + - T->getDescription() + "' type plane!"); +GenerateError("Redefinition of type named '" + Name + "' of type '" + + T->getDescription() + "'!"); } return false; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.298 -> 1.299 --- Log message: Change the syntax for parameter attributes: 1. The @ sign is no longer necessary. 2. We now support "function attributes" as parameter attribute 0. 3. Instead of locating the return type attributes after the type of a function result, they are now located after the function header's closing paranthesis and before any alignment or section options. 4. The way has been prepared for a new "noreturn" function attribute but there is no support for recognizing it in the lexer nor doing anything with it if it does get set. 5. The FunctionType::getParamAttrsText method now has support for returning multiple attributes. This required a change in its interface. I'm unhappy that this change leads to 6 new shift/reduce conflicts, but in each case bison's decision to choose the shift is correct so there shouldn't be any damage from these conflicts. --- Diffs of the changes: (+52 -45) llvmAsmParser.y | 97 ++-- 1 files changed, 52 insertions(+), 45 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.298 llvm/lib/AsmParser/llvmAsmParser.y:1.299 --- llvm/lib/AsmParser/llvmAsmParser.y:1.298Wed Jan 3 20:57:22 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Jan 5 11:06:19 2007 @@ -951,7 +951,7 @@ %type IndexList // For GEP indices %type TypeListI %type ArgTypeList ArgTypeListI -%type ArgType ResultType +%type ArgType %type JumpTable %typeGlobalType // GLOBAL or CONSTANT? %typeOptVolatile // 'volatile' or not @@ -978,7 +978,7 @@ %token FPVAL // Float or Double constant // Built in types... -%type Types +%type Types ResultTypes %type IntType FPType PrimType // Classifications %token VOID BOOL INT8 INT16 INT32 INT64 %token FLOAT DOUBLE LABEL @@ -999,7 +999,8 @@ %token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK %token DATALAYOUT %type OptCallingConv -%type OptParamAttrs ParamAttrList ParamAttr +%type OptParamAttrs ParamAttr +%type OptFuncAttrs FuncAttr // Basic Block Terminating Operators %token RET BR SWITCH INVOKE UNWIND UNREACHABLE @@ -1026,6 +1027,8 @@ %token PHI_TOK SELECT SHL LSHR ASHR VAARG %token EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR +// Function Attributes +%token NORETURN %start Module %% @@ -1129,15 +1132,20 @@ | SEXT { $$ = FunctionType::SExtAttribute; } ; -ParamAttrList : ParamAttr{ $$ = $1; } - | ParamAttrList ',' ParamAttr { -$$ = FunctionType::ParameterAttributes($1 | $3); +OptParamAttrs : /* empty */ { $$ = FunctionType::NoAttributeSet; } + | OptParamAttrs ParamAttr { +$$ = FunctionType::ParameterAttributes($1 | $2); } ; -OptParamAttrs : /* empty */ { $$ = FunctionType::NoAttributeSet; } - | '@' ParamAttr { $$ = $2; } - | '@' '(' ParamAttrList ')' { $$ = $3; } +FuncAttr : NORETURN { $$ = FunctionType::NoReturnAttribute; } + | ParamAttr + ; + +OptFuncAttrs : /* empty */ { $$ = FunctionType::NoAttributeSet; } + | OptFuncAttrs FuncAttr { +$$ = FunctionType::ParameterAttributes($1 | $2); + } ; // OptAlign/OptCAlign - An optional alignment, and an optional alignment with @@ -1223,11 +1231,11 @@ UR_OUT("New Upreference!\n"); CHECK_FOR_ERROR } - | Types OptParamAttrs '(' ArgTypeListI ')' { + | Types '(' ArgTypeListI ')' OptFuncAttrs { std::vector Params; std::vector Attrs; -Attrs.push_back($2); -for (TypeWithAttrsList::iterator I=$4->begin(), E=$4->end(); I != E; ++I) { +Attrs.push_back($5); +for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) { Params.push_back(I->Ty->get()); if (I->Ty->get() != Type::VoidTy) Attrs.push_back(I->Attrs); @@ -1236,16 +1244,16 @@ if (isVarArg) Params.pop_back(); FunctionType *FT = FunctionType::get(*$1, Params, isVarArg, Attrs); -delete $4; // Delete the argument list +delete $3; // Delete the argument list delete $1; // Delete the return type handle $$ = new PATypeHolder(HandleUpRefs(FT)); CHECK_FOR_ERROR } - | VOID OptParamAttrs '(' ArgTypeListI ')' { + | VOID '(' ArgTypeListI ')' OptFuncAttrs { std::vector Params; std::vector Attrs; -Attrs.push_back($2); -for (TypeWithAttrsList::iterator I=$4->begin(), E=$4->end(); I != E; ++I) { +Attrs.push_back($5); +for (TypeWithAttrsList::iterator I=$3->begin(), E=$3->end(); I != E; ++I) { Params.push_back(I->Ty->get()); if (I->Ty->get() != Type::VoidTy) Attrs.push_back(I->Attrs); @@ -1254,7 +1262,7 @@ if (isVarArg) Params.pop_back(); Fun
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.297 -> 1.298 --- Log message: Disallow packed types in icmp/fcmp instructions. The code generator is not prepared to handle them yet. --- Diffs of the changes: (+4 -0) llvmAsmParser.y |4 1 files changed, 4 insertions(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.297 llvm/lib/AsmParser/llvmAsmParser.y:1.298 --- llvm/lib/AsmParser/llvmAsmParser.y:1.297Wed Jan 3 18:05:48 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jan 3 20:57:22 2007 @@ -2549,6 +2549,8 @@ | ICMP IPredicates Types ValueRef ',' ValueRef { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription()); +if (isa((*$3).get())) + GEN_ERROR("Packed types not supported by icmp instruction"); Value* tmpVal1 = getVal(*$3, $4); CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); @@ -2560,6 +2562,8 @@ | FCMP FPredicates Types ValueRef ',' ValueRef { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription()); +if (isa((*$3).get())) + GEN_ERROR("Packed types not supported by fcmp instruction"); Value* tmpVal1 = getVal(*$3, $4); CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.296 -> 1.297 --- Log message: Permit icmp and fcmp to have packed operands. Make an error message a little more useful. --- Diffs of the changes: (+2 -5) llvmAsmParser.y |7 ++- 1 files changed, 2 insertions(+), 5 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.296 llvm/lib/AsmParser/llvmAsmParser.y:1.297 --- llvm/lib/AsmParser/llvmAsmParser.y:1.296Tue Jan 2 15:53:43 2007 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jan 3 18:05:48 2007 @@ -1602,7 +1602,8 @@ if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription()); if ($1->get() != $2->getType()) - GEN_ERROR("Mismatched types for constant expression!"); + GEN_ERROR("Mismatched types for constant expression: " + +(*$1)->getDescription() + " and " + $2->getType()->getDescription()); $$ = $2; delete $1; CHECK_FOR_ERROR @@ -2548,8 +2549,6 @@ | ICMP IPredicates Types ValueRef ',' ValueRef { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription()); -if (isa((*$3).get())) - GEN_ERROR("Packed types not supported by icmp instruction"); Value* tmpVal1 = getVal(*$3, $4); CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); @@ -2561,8 +2560,6 @@ | FCMP FPredicates Types ValueRef ',' ValueRef { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$3)->getDescription()); -if (isa((*$3).get())) - GEN_ERROR("Packed types not supported by fcmp instruction"); Value* tmpVal1 = getVal(*$3, $4); CHECK_FOR_ERROR Value* tmpVal2 = getVal(*$3, $6); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.295 -> 1.296 --- Log message: Implement checking for unresolved types in the argument types and result type of function definitions. This fixes test/Regression/Assember/2007-01-02-Undefined-Arg-Type.ll --- Diffs of the changes: (+59 -0) llvmAsmParser.y | 59 1 files changed, 59 insertions(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.295 llvm/lib/AsmParser/llvmAsmParser.y:1.296 --- llvm/lib/AsmParser/llvmAsmParser.y:1.295Sun Dec 31 15:46:36 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jan 2 15:53:43 2007 @@ -149,6 +149,58 @@ } return Ret; } + + bool TypeIsUnresolved(PATypeHolder* PATy) { +// If it isn't abstract, its resolved +const Type* Ty = PATy->get(); +if (!Ty->isAbstract()) + return false; +// Traverse the type looking for abstract types. If it isn't abstract then +// we don't need to traverse that leg of the type. +std::vector WorkList, SeenList; +WorkList.push_back(Ty); +while (!WorkList.empty()) { + const Type* Ty = WorkList.back(); + SeenList.push_back(Ty); + WorkList.pop_back(); + if (const OpaqueType* OpTy = dyn_cast(Ty)) { +// Check to see if this is an unresolved type +std::map::iterator I = LateResolveTypes.begin(); +std::map::iterator E = LateResolveTypes.end(); +for ( ; I != E; ++I) { + if (I->second.get() == OpTy) +return true; +} + } else if (const SequentialType* SeqTy = dyn_cast(Ty)) { +const Type* TheTy = SeqTy->getElementType(); +if (TheTy->isAbstract() && TheTy != Ty) { + std::vector::iterator I = SeenList.begin(), + E = SeenList.end(); + for ( ; I != E; ++I) +if (*I == TheTy) + break; + if (I == E) +WorkList.push_back(TheTy); +} + } else if (const StructType* StrTy = dyn_cast(Ty)) { +for (unsigned i = 0; i < StrTy->getNumElements(); ++i) { + const Type* TheTy = StrTy->getElementType(i); + if (TheTy->isAbstract() && TheTy != Ty) { +std::vector::iterator I = SeenList.begin(), + E = SeenList.end(); +for ( ; I != E; ++I) + if (*I == TheTy) +break; +if (I == E) + WorkList.push_back(TheTy); + } +} + } +} +return false; + } + + } CurModule; static struct PerFunctionInfo { @@ -1943,12 +1995,19 @@ std::string FunctionName($3); free($3); // Free strdup'd memory! + // Check the function result for abstractness if this is a define. We should + // have no abstract types at this point + if (!CurFun.isDeclare && CurModule.TypeIsUnresolved($2.Ty)) +GEN_ERROR("Reference to abstract result: "+ $2.Ty->get()->getDescription()); + std::vector ParamTypeList; std::vector ParamAttrs; ParamAttrs.push_back($2.Attrs); if ($5) { // If there are arguments... for (ArgListType::iterator I = $5->begin(); I != $5->end(); ++I) { const Type* Ty = I->Ty->get(); + if (!CurFun.isDeclare && CurModule.TypeIsUnresolved(I->Ty)) +GEN_ERROR("Reference to abstract argument: " + Ty->getDescription()); ParamTypeList.push_back(Ty); if (Ty != Type::VoidTy) ParamAttrs.push_back(I->Attrs); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.294 -> 1.295 --- Log message: Remove an extra semi-colon. --- Diffs of the changes: (+1 -1) llvmAsmParser.y |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.294 llvm/lib/AsmParser/llvmAsmParser.y:1.295 --- llvm/lib/AsmParser/llvmAsmParser.y:1.294Sun Dec 31 15:25:25 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Dec 31 15:46:36 2006 @@ -2431,7 +2431,7 @@ | /*empty*/ { $$ = new ValueRefList(); }; IndexList // Used for gep instructions and constant expressions - : /*empty*/ { $$ = new std::vector(); }; + : /*empty*/ { $$ = new std::vector(); } | IndexList ',' ResolvedVal { $$ = $1; $$->push_back($3); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.293 -> 1.294 --- Log message: Add a missing colon. Noticed by Jeff Cohen. --- Diffs of the changes: (+1 -0) llvmAsmParser.y |1 + 1 files changed, 1 insertion(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.293 llvm/lib/AsmParser/llvmAsmParser.y:1.294 --- llvm/lib/AsmParser/llvmAsmParser.y:1.293Sat Dec 30 23:40:12 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Dec 31 15:25:25 2006 @@ -2437,6 +2437,7 @@ $$->push_back($3); CHECK_FOR_ERROR } + ; OptTailCall : TAIL CALL { $$ = true; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.289 -> 1.290 --- Log message: Allow negative constants for unsigned integers and unsigned constants greater than MAX_INT64 for signed integers. This is now valid and is just waiting for the distinction between signed and unsigned to go away. --- Diffs of the changes: (+13 -11) llvmAsmParser.y | 24 +--- 1 files changed, 13 insertions(+), 11 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.289 llvm/lib/AsmParser/llvmAsmParser.y:1.290 --- llvm/lib/AsmParser/llvmAsmParser.y:1.289Fri Dec 8 12:06:15 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Dec 20 11:20:09 2006 @@ -926,7 +926,6 @@ // EUINT64VAL - A positive number within uns. long long range %token EUINT64VAL -%type EINT64VAL %token SINTVAL // Signed 32 bit ints... %token UINTVAL // Unsigned 32 bit ints... @@ -995,15 +994,6 @@ CHECK_FOR_ERROR }; - -EINT64VAL : ESINT64VAL; // These have same type and can't cause problems... -EINT64VAL : EUINT64VAL { - if ($1 > (uint64_t)INT64_MAX) // Outside of my range! -GEN_ERROR("Value too large for type!"); - $$ = (int64_t)$1; - CHECK_FOR_ERROR -}; - // Operations that are notably excluded from this list include: // RET, BR, & SWITCH because they end basic blocks and are treated specially. // @@ -1486,7 +1476,13 @@ delete $1; CHECK_FOR_ERROR } - | SIntType EINT64VAL { // integral constants + | SIntType ESINT64VAL { // integral constants +if (!ConstantInt::isValueValidForType($1, $2)) + GEN_ERROR("Constant value doesn't fit in type!"); +$$ = ConstantInt::get($1, $2); +CHECK_FOR_ERROR + } + | SIntType EUINT64VAL { // integral constants if (!ConstantInt::isValueValidForType($1, $2)) GEN_ERROR("Constant value doesn't fit in type!"); $$ = ConstantInt::get($1, $2); @@ -1498,6 +1494,12 @@ $$ = ConstantInt::get($1, $2); CHECK_FOR_ERROR } + | UIntType ESINT64VAL { +if (!ConstantInt::isValueValidForType($1, $2)) + GEN_ERROR("Constant value doesn't fit in type!"); +$$ = ConstantInt::get($1, $2); +CHECK_FOR_ERROR + } | BOOL TRUETOK { // Boolean constants $$ = ConstantBool::getTrue(); CHECK_FOR_ERROR ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
On 12/8/06, Reid Spencer <[EMAIL PROTECTED]> wrote: > Andrew, > > It looks like you haven't accounted for global constants of packed > structure type here. They are. structure initializers are structure initializers, whether they are initializing a packed struct or a normal struct. e.g.: %E1 = global <{ sbyte, int, int }> { sbyte 1, int 2, int 3 } ; <<{ sbyte, int, int }>*> [#uses=0] %E2 = global { sbyte, int, int } { sbyte 4, int 5, int 6 } ; <{ sbyte, int, int }*> [#uses=0] Since the type is embedded before the constant, I don't think it makes sense to have two types of initializer. Or were you taking about something else? Andrew > Reid. > > On Fri, 2006-12-08 at 12:07 -0600, Andrew Lenharth wrote: > > > > Changes in directory llvm/lib/AsmParser: > > > > llvmAsmParser.y updated: 1.288 -> 1.289 > > --- > > Log message: > > > > Packed Structures > > > > --- > > Diffs of the changes: (+14 -0) > > > > llvmAsmParser.y | 14 ++ > > 1 files changed, 14 insertions(+) > > > > > > Index: llvm/lib/AsmParser/llvmAsmParser.y > > diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.288 > > llvm/lib/AsmParser/llvmAsmParser.y:1.289 > > --- llvm/lib/AsmParser/llvmAsmParser.y:1.288 Wed Dec 6 19:30:31 2006 > > +++ llvm/lib/AsmParser/llvmAsmParser.yFri Dec 8 12:06:15 2006 > > @@ -1209,6 +1209,20 @@ > > $$ = new PATypeHolder(StructType::get(std::vector())); > > CHECK_FOR_ERROR > >} > > + | '<' '{' TypeListI '}' '>' { > > +std::vector Elements; > > +for (std::list::iterator I = $3->begin(), > > + E = $3->end(); I != E; ++I) > > + Elements.push_back(*I); > > + > > +$$ = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); > > +delete $3; > > +CHECK_FOR_ERROR > > + } > > + | '<' '{' '}' '>' { // Empty structure type? > > +$$ = new PATypeHolder(StructType::get(std::vector(), > > true)); > > +CHECK_FOR_ERROR > > + } > >| UpRTypes '*' { // Pointer type? > > if (*$1 == Type::LabelTy) > >GEN_ERROR("Cannot form a pointer to a basic block"); > > > > > > > > ___ > > llvm-commits mailing list > > llvm-commits@cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Andrew, It looks like you haven't accounted for global constants of packed structure type here. Reid. On Fri, 2006-12-08 at 12:07 -0600, Andrew Lenharth wrote: > > Changes in directory llvm/lib/AsmParser: > > llvmAsmParser.y updated: 1.288 -> 1.289 > --- > Log message: > > Packed Structures > > --- > Diffs of the changes: (+14 -0) > > llvmAsmParser.y | 14 ++ > 1 files changed, 14 insertions(+) > > > Index: llvm/lib/AsmParser/llvmAsmParser.y > diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.288 > llvm/lib/AsmParser/llvmAsmParser.y:1.289 > --- llvm/lib/AsmParser/llvmAsmParser.y:1.288 Wed Dec 6 19:30:31 2006 > +++ llvm/lib/AsmParser/llvmAsmParser.yFri Dec 8 12:06:15 2006 > @@ -1209,6 +1209,20 @@ > $$ = new PATypeHolder(StructType::get(std::vector())); > CHECK_FOR_ERROR >} > + | '<' '{' TypeListI '}' '>' { > +std::vector Elements; > +for (std::list::iterator I = $3->begin(), > + E = $3->end(); I != E; ++I) > + Elements.push_back(*I); > + > +$$ = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); > +delete $3; > +CHECK_FOR_ERROR > + } > + | '<' '{' '}' '>' { // Empty structure type? > +$$ = new PATypeHolder(StructType::get(std::vector(), true)); > +CHECK_FOR_ERROR > + } >| UpRTypes '*' { // Pointer type? > if (*$1 == Type::LabelTy) >GEN_ERROR("Cannot form a pointer to a basic block"); > > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.288 -> 1.289 --- Log message: Packed Structures --- Diffs of the changes: (+14 -0) llvmAsmParser.y | 14 ++ 1 files changed, 14 insertions(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.288 llvm/lib/AsmParser/llvmAsmParser.y:1.289 --- llvm/lib/AsmParser/llvmAsmParser.y:1.288Wed Dec 6 19:30:31 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Dec 8 12:06:15 2006 @@ -1209,6 +1209,20 @@ $$ = new PATypeHolder(StructType::get(std::vector())); CHECK_FOR_ERROR } + | '<' '{' TypeListI '}' '>' { +std::vector Elements; +for (std::list::iterator I = $3->begin(), + E = $3->end(); I != E; ++I) + Elements.push_back(*I); + +$$ = new PATypeHolder(HandleUpRefs(StructType::get(Elements, true))); +delete $3; +CHECK_FOR_ERROR + } + | '<' '{' '}' '>' { // Empty structure type? +$$ = new PATypeHolder(StructType::get(std::vector(), true)); +CHECK_FOR_ERROR + } | UpRTypes '*' { // Pointer type? if (*$1 == Type::LabelTy) GEN_ERROR("Cannot form a pointer to a basic block"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.286 -> 1.287 --- Log message: Remove dead var NewVarArgs. --- Diffs of the changes: (+0 -3) llvmAsmParser.y |3 --- 1 files changed, 3 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.286 llvm/lib/AsmParser/llvmAsmParser.y:1.287 --- llvm/lib/AsmParser/llvmAsmParser.y:1.286Tue Dec 5 17:28:06 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Dec 5 17:46:41 2006 @@ -64,7 +64,6 @@ #define YYERROR_VERBOSE 1 -static bool NewVarArgs; static GlobalVariable *CurGV; @@ -809,7 +808,6 @@ static Module* RunParser(Module * M) { llvmAsmlineno = 1; // Reset the current line number... - NewVarArgs = false; CurModule.CurrentModule = M; // Check to make sure the parser succeeded @@ -2433,7 +2431,6 @@ CHECK_FOR_ERROR } | VAARG ResolvedVal ',' Types { -NewVarArgs = true; $$ = new VAArgInst($2, *$4); delete $4; CHECK_FOR_ERROR ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.285 -> 1.286 --- Log message: Dump the old va_arg and va_next upgrade support. No need to keep track of the current basic block any more either. --- Diffs of the changes: (+2 -156) llvmAsmParser.y | 158 1 files changed, 2 insertions(+), 156 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.285 llvm/lib/AsmParser/llvmAsmParser.y:1.286 --- llvm/lib/AsmParser/llvmAsmParser.y:1.285Tue Dec 5 13:15:41 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Dec 5 17:28:06 2006 @@ -64,9 +64,7 @@ #define YYERROR_VERBOSE 1 -static bool ObsoleteVarArgs; static bool NewVarArgs; -static BasicBlock *CurBB; static GlobalVariable *CurGV; @@ -811,7 +809,6 @@ static Module* RunParser(Module * M) { llvmAsmlineno = 1; // Reset the current line number... - ObsoleteVarArgs = false; NewVarArgs = false; CurModule.CurrentModule = M; @@ -830,113 +827,6 @@ Module *Result = ParserResult; ParserResult = 0; - //Not all functions use vaarg, so make a second check for ObsoleteVarArgs - { -Function* F; -if ((F = Result->getNamedFunction("llvm.va_start")) -&& F->getFunctionType()->getNumParams() == 0) - ObsoleteVarArgs = true; -if((F = Result->getNamedFunction("llvm.va_copy")) - && F->getFunctionType()->getNumParams() == 1) - ObsoleteVarArgs = true; - } - - if (ObsoleteVarArgs && NewVarArgs) { -GenerateError( - "This file is corrupt: it uses both new and old style varargs"); -return 0; - } - - if(ObsoleteVarArgs) { -if(Function* F = Result->getNamedFunction("llvm.va_start")) { - if (F->arg_size() != 0) { -GenerateError("Obsolete va_start takes 0 argument!"); -return 0; - } - - //foo = va_start() - // -> - //bar = alloca typeof(foo) - //va_start(bar) - //foo = load bar - - const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); - const Type* ArgTy = F->getFunctionType()->getReturnType(); - const Type* ArgTyPtr = PointerType::get(ArgTy); - Function* NF = Result->getOrInsertFunction("llvm.va_start", - RetTy, ArgTyPtr, (Type *)0); - - while (!F->use_empty()) { -CallInst* CI = cast(F->use_back()); -AllocaInst* bar = new AllocaInst(ArgTy, 0, "vastart.fix.1", CI); -new CallInst(NF, bar, "", CI); -Value* foo = new LoadInst(bar, "vastart.fix.2", CI); -CI->replaceAllUsesWith(foo); -CI->getParent()->getInstList().erase(CI); - } - Result->getFunctionList().erase(F); -} - -if(Function* F = Result->getNamedFunction("llvm.va_end")) { - if(F->arg_size() != 1) { -GenerateError("Obsolete va_end takes 1 argument!"); -return 0; - } - - //vaend foo - // -> - //bar = alloca 1 of typeof(foo) - //vaend bar - const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); - const Type* ArgTy = F->getFunctionType()->getParamType(0); - const Type* ArgTyPtr = PointerType::get(ArgTy); - Function* NF = Result->getOrInsertFunction("llvm.va_end", - RetTy, ArgTyPtr, (Type *)0); - - while (!F->use_empty()) { -CallInst* CI = cast(F->use_back()); -AllocaInst* bar = new AllocaInst(ArgTy, 0, "vaend.fix.1", CI); -new StoreInst(CI->getOperand(1), bar, CI); -new CallInst(NF, bar, "", CI); -CI->getParent()->getInstList().erase(CI); - } - Result->getFunctionList().erase(F); -} - -if(Function* F = Result->getNamedFunction("llvm.va_copy")) { - if(F->arg_size() != 1) { -GenerateError("Obsolete va_copy takes 1 argument!"); -return 0; - } - //foo = vacopy(bar) - // -> - //a = alloca 1 of typeof(foo) - //b = alloca 1 of typeof(foo) - //store bar -> b - //vacopy(a, b) - //foo = load a - - const Type* RetTy = Type::getPrimitiveType(Type::VoidTyID); - const Type* ArgTy = F->getFunctionType()->getReturnType(); - const Type* ArgTyPtr = PointerType::get(ArgTy); - Function* NF = Result->getOrInsertFunction("llvm.va_copy", - RetTy, ArgTyPtr, ArgTyPtr, - (Type *)0); - - while (!F->use_empty()) { -CallInst* CI = cast(F->use_back()); -AllocaInst* a = new AllocaInst(ArgTy, 0, "vacopy.fix.1", CI); -AllocaInst* b = new AllocaInst(ArgTy, 0, "vacopy.fix.2", CI); -new StoreInst(CI->getOperand(1), b, CI); -new CallInst(NF, a, b, "", CI); -Value* foo = new LoadInst(a, "vacopy.fix.3", CI); -CI->replaceAllUsesWith(foo); -CI->getParent()->getInstList().erase(CI); - } - Result->getFunctionList().eras
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
On Dec 5, 2006, at 11:15 AM, Reid Spencer wrote: > > > Changes in directory llvm/lib/AsmParser: > > llvmAsmParser.y updated: 1.284 -> 1.285 > --- > Log message: > > Remove various old upgrade hacks that are no longer needed. > Nice. You should also be able to nuke VAARG_old/VANEXT_old, as well as CurBB, ObsoleteVarArgs etc. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.284 -> 1.285 --- Log message: Remove various old upgrade hacks that are no longer needed. --- Diffs of the changes: (+1 -41) llvmAsmParser.y | 42 +- 1 files changed, 1 insertion(+), 41 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.284 llvm/lib/AsmParser/llvmAsmParser.y:1.285 --- llvm/lib/AsmParser/llvmAsmParser.y:1.284Sun Dec 3 23:20:06 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Dec 5 13:15:41 2006 @@ -1629,17 +1629,6 @@ if (!isa($3->getType())) GEN_ERROR("GetElementPtr requires a pointer operand!"); -// LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct -// indices to uint struct indices for compatibility. -generic_gep_type_iterator::iterator> - GTI = gep_type_begin($3->getType(), $4->begin(), $4->end()), - GTE = gep_type_end($3->getType(), $4->begin(), $4->end()); -for (unsigned i = 0, e = $4->size(); i != e && GTI != GTE; ++i, ++GTI) - if (isa(*GTI))// Only change struct indices -if (ConstantInt *CUI = dyn_cast((*$4)[i])) - if (CUI->getType() == Type::UByteTy) -(*$4)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); - const Type *IdxTy = GetElementPtrInst::getIndexedType($3->getType(), *$4, true); if (!IdxTy) @@ -1669,25 +1658,7 @@ if ($3->getType() != $5->getType()) GEN_ERROR("Binary operator types must match!"); CHECK_FOR_ERROR; - -// HACK: llvm 1.3 and earlier used to emit invalid pointer constant exprs. -// To retain backward compatibility with these early compilers, we emit a -// cast to the appropriate integer type automatically if we are in the -// broken case. See PR424 for more information. -if (!isa($3->getType())) { - $$ = ConstantExpr::get($1, $3, $5); -} else { - const Type *IntPtrTy = 0; - switch (CurModule.CurrentModule->getPointerSize()) { - case Module::Pointer32: IntPtrTy = Type::IntTy; break; - case Module::Pointer64: IntPtrTy = Type::LongTy; break; - default: GEN_ERROR("invalid pointer binary constant expr!"); - } - $$ = ConstantExpr::get($1, ConstantExpr::getCast($3, IntPtrTy), - ConstantExpr::getCast($5, IntPtrTy)); - $$ = ConstantExpr::getCast($$, $3->getType()); -} -CHECK_FOR_ERROR +$$ = ConstantExpr::get($1, $3, $5); } | LogicalOps '(' ConstVal ',' ConstVal ')' { if ($3->getType() != $5->getType()) @@ -2800,17 +2771,6 @@ if (!isa($2->get())) GEN_ERROR("getelementptr insn requires pointer operand!"); -// LLVM 1.2 and earlier used ubyte struct indices. Convert any ubyte struct -// indices to uint struct indices for compatibility. -generic_gep_type_iterator::iterator> - GTI = gep_type_begin($2->get(), $4->begin(), $4->end()), - GTE = gep_type_end($2->get(), $4->begin(), $4->end()); -for (unsigned i = 0, e = $4->size(); i != e && GTI != GTE; ++i, ++GTI) - if (isa(*GTI))// Only change struct indices -if (ConstantInt *CUI = dyn_cast((*$4)[i])) - if (CUI->getType() == Type::UByteTy) -(*$4)[i] = ConstantExpr::getCast(CUI, Type::UIntTy); - if (!GetElementPtrInst::getIndexedType(*$2, *$4, true)) GEN_ERROR("Invalid getelementptr indices for type '" + (*$2)->getDescription()+ "'!"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Done. On Mon, 2006-12-04 at 11:19 -0800, Chris Lattner wrote: > > > > For PR950: http://llvm.org/PR950 : For ICmp and FCmp constant > > expressions, put the predicate outiside the parentheses to match > > what llvm-upgrade generates. > > Please document the syntax of these constant exprs in: > http://llvm.org/docs/LangRef.html#constantexprs > > -Chris > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
> > For PR950: http://llvm.org/PR950 : For ICmp and FCmp constant > expressions, put the predicate outiside the parentheses to match > what llvm-upgrade generates. Please document the syntax of these constant exprs in: http://llvm.org/docs/LangRef.html#constantexprs -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.283 -> 1.284 --- Log message: For PR950: http://llvm.org/PR950 : For ICmp and FCmp constant expressions, put the predicate outiside the parentheses to match what llvm-upgrade generates. --- Diffs of the changes: (+7 -7) llvmAsmParser.y | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.283 llvm/lib/AsmParser/llvmAsmParser.y:1.284 --- llvm/lib/AsmParser/llvmAsmParser.y:1.283Sun Dec 3 10:19:43 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Dec 3 23:20:06 2006 @@ -1127,7 +1127,7 @@ UITOFP | SITOFP | FPTOUI | FPTOSI | INTTOPTR | PTRTOINT; ShiftOps : SHL | LSHR | ASHR; IPredicates - : EQ { $$ = ICmpInst::ICMP_EQ; } | NE { $$ = ICmpInst::ICMP_NE; } + : EQ { $$ = ICmpInst::ICMP_EQ; } | NE { $$ = ICmpInst::ICMP_NE; } | SLT { $$ = ICmpInst::ICMP_SLT; } | SGT { $$ = ICmpInst::ICMP_SGT; } | SLE { $$ = ICmpInst::ICMP_SLE; } | SGE { $$ = ICmpInst::ICMP_SGE; } | ULT { $$ = ICmpInst::ICMP_ULT; } | UGT { $$ = ICmpInst::ICMP_UGT; } @@ -1706,15 +1706,15 @@ $$ = ConstantExpr::get($1, $3, $5); CHECK_FOR_ERROR } - | ICMP '(' IPredicates ',' ConstVal ',' ConstVal ')' { -if ($5->getType() != $7->getType()) + | ICMP IPredicates '(' ConstVal ',' ConstVal ')' { +if ($4->getType() != $6->getType()) GEN_ERROR("icmp operand types must match!"); -$$ = ConstantExpr::getICmp($3, $5, $7); +$$ = ConstantExpr::getICmp($2, $4, $6); } - | FCMP '(' FPredicates ',' ConstVal ',' ConstVal ')' { -if ($5->getType() != $7->getType()) + | FCMP FPredicates '(' ConstVal ',' ConstVal ')' { +if ($4->getType() != $6->getType()) GEN_ERROR("fcmp operand types must match!"); -$$ = ConstantExpr::getFCmp($3, $5, $7); +$$ = ConstantExpr::getFCmp($2, $4, $6); } | ShiftOps '(' ConstVal ',' ConstVal ')' { if ($5->getType() != Type::UByteTy) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.282 -> 1.283 --- Log message: Remove useless #include. --- Diffs of the changes: (+0 -1) llvmAsmParser.y |1 - 1 files changed, 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.282 llvm/lib/AsmParser/llvmAsmParser.y:1.283 --- llvm/lib/AsmParser/llvmAsmParser.y:1.282Sun Dec 3 00:58:07 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Dec 3 10:19:43 2006 @@ -18,7 +18,6 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/SymbolTable.h" -#include "llvm/Assembly/AutoUpgrade.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/MathExtras.h" ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.279 -> 1.280 --- Log message: Introducing external weak linkage. Darwin codegen should be added later. --- Diffs of the changes: (+1 -1) llvmAsmParser.y |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.279 llvm/lib/AsmParser/llvmAsmParser.y:1.280 --- llvm/lib/AsmParser/llvmAsmParser.y:1.279Tue Nov 28 16:47:12 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Thu Nov 30 18:25:12 2006 @@ -2201,7 +2201,7 @@ FnDeclareLinkage: /*default*/ | DLLIMPORT { CurFun.Linkage = GlobalValue::DLLImportLinkage; } | - EXTERN_WEAK { CurFun.Linkage = GlobalValue::DLLImportLinkage; }; + EXTERN_WEAK { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; }; FunctionProto : DECLARE { CurFun.isDeclare = true; } FnDeclareLinkage FunctionHeaderH { $$ = CurFun.CurrentFunction; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.278 -> 1.279 --- Log message: Removed #include and used llvm streams --- Diffs of the changes: (+3 -3) llvmAsmParser.y |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.278 llvm/lib/AsmParser/llvmAsmParser.y:1.279 --- llvm/lib/AsmParser/llvmAsmParser.y:1.278Tue Nov 28 01:28:14 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Nov 28 16:47:12 2006 @@ -22,8 +22,8 @@ #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/Streams.h" #include -#include #include #include @@ -58,7 +58,7 @@ // //#define DEBUG_UPREFS 1 #ifdef DEBUG_UPREFS -#define UR_OUT(X) std::cerr << X +#define UR_OUT(X) llvm_cerr << X #else #define UR_OUT(X) #endif @@ -2633,7 +2633,7 @@ delete $2.type; } | NOT ResolvedVal { -std::cerr << "WARNING: Use of eliminated 'not' instruction:" +llvm_cerr << "WARNING: Use of eliminated 'not' instruction:" << " Replacing with 'xor'.\n"; Value *Ones = ConstantIntegral::getAllOnesValue($2.val->getType()); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.274 -> 1.275 --- Log message: Initialize some pointers to quiet the compiler (when doing build_gcc builds). --- Diffs of the changes: (+2 -2) llvmAsmParser.y |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.274 llvm/lib/AsmParser/llvmAsmParser.y:1.275 --- llvm/lib/AsmParser/llvmAsmParser.y:1.274Wed Nov 8 00:47:33 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Nov 12 05:10:39 2006 @@ -2666,8 +2666,8 @@ CHECK_FOR_ERROR } | OptTailCall OptCallingConv TypesV ValueRef '(' ValueRefListE ')' { -const PointerType *PFTy; -const FunctionType *Ty; +const PointerType *PFTy = 0; +const FunctionType *Ty = 0; if (!(PFTy = dyn_cast($3->get())) || !(Ty = dyn_cast(PFTy->getElementType( { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.272 -> 1.273 --- Log message: Fix a bug noticed by Emil Mikulic. --- Diffs of the changes: (+2 -2) llvmAsmParser.y |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.272 llvm/lib/AsmParser/llvmAsmParser.y:1.273 --- llvm/lib/AsmParser/llvmAsmParser.y:1.272Wed Nov 1 19:53:58 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Nov 7 23:58:11 2006 @@ -2102,8 +2102,8 @@ }; FnDeclareLinkage: /*default*/ | - DLLIMPORT { CurFun.Linkage = GlobalValue::DLLImportLinkage } | - EXTERN_WEAK { CurFun.Linkage = GlobalValue::DLLImportLinkage }; + DLLIMPORT { CurFun.Linkage = GlobalValue::DLLImportLinkage; } | + EXTERN_WEAK { CurFun.Linkage = GlobalValue::DLLImportLinkage; }; FunctionProto : DECLARE { CurFun.isDeclare = true; } FnDeclareLinkage FunctionHeaderH { $$ = CurFun.CurrentFunction; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y llvmAsmParser.y.cvs
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.269 -> 1.270 llvmAsmParser.y.cvs updated: 1.21 -> 1.22 --- Log message: Removed extraneous semi-colon; this was prevening the grammar file from bison'ing correctly. --- Diffs of the changes: (+2 -2) llvmAsmParser.y |2 +- llvmAsmParser.y.cvs |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.269 llvm/lib/AsmParser/llvmAsmParser.y:1.270 --- llvm/lib/AsmParser/llvmAsmParser.y:1.269Sun Oct 22 02:03:09 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Oct 24 14:09:48 2006 @@ -1872,7 +1872,7 @@ | TRIPLE '=' STRINGCONSTANT { CurModule.CurrentModule->setTargetTriple($3); free($3); - }; + } | DATALAYOUT '=' STRINGCONSTANT { CurModule.CurrentModule->setDataLayout($3); free($3); Index: llvm/lib/AsmParser/llvmAsmParser.y.cvs diff -u llvm/lib/AsmParser/llvmAsmParser.y.cvs:1.21 llvm/lib/AsmParser/llvmAsmParser.y.cvs:1.22 --- llvm/lib/AsmParser/llvmAsmParser.y.cvs:1.21 Sun Oct 22 02:03:43 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y.cvs Tue Oct 24 14:09:48 2006 @@ -1872,7 +1872,7 @@ | TRIPLE '=' STRINGCONSTANT { CurModule.CurrentModule->setTargetTriple($3); free($3); - }; + } | DATALAYOUT '=' STRINGCONSTANT { CurModule.CurrentModule->setDataLayout($3); free($3); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Lexer.l
On Sat, 2006-10-21 at 23:09 -0700, Chris Lattner wrote: > >> @@ -1873,6 +1874,11 @@ > >> free($3); > >> CHECK_FOR_ERROR > >>}; > >> + | DATA '=' STRINGCONSTANT { > >> +CurModule.CurrentModule->setDataLayout($3); > >> +free($3); > >> +CHECK_FOR_ERROR > > > > I don't think you need a CHECK_FOR_ERROR here. Neither of the two > > preceding calls will call GENERATE_ERROR. > > Owen/Reid: can one of you take care of this? Done. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.268 -> 1.269 --- Log message: Remove unneeded CHECK_FOR_ERROR invocations. --- Diffs of the changes: (+0 -2) llvmAsmParser.y |2 -- 1 files changed, 2 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.268 llvm/lib/AsmParser/llvmAsmParser.y:1.269 --- llvm/lib/AsmParser/llvmAsmParser.y:1.268Sun Oct 22 01:07:41 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Oct 22 02:03:09 2006 @@ -1872,12 +1872,10 @@ | TRIPLE '=' STRINGCONSTANT { CurModule.CurrentModule->setTargetTriple($3); free($3); -CHECK_FOR_ERROR }; | DATALAYOUT '=' STRINGCONSTANT { CurModule.CurrentModule->setDataLayout($3); free($3); -CHECK_FOR_ERROR }; LibrariesDefinition : '[' LibList ']'; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Lexer.l
On Oct 17, 2006, at 7:28 PM, Reid Spencer wrote: >> Index: llvm/lib/AsmParser/llvmAsmParser.y >> diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.265 llvm/lib/ >> AsmParser/llvmAsmParser.y:1.266 >> --- llvm/lib/AsmParser/llvmAsmParser.y:1.265 Sun Oct 15 18:26:46 2006 >> +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Oct 17 21:19:55 2006 >> @@ -1068,6 +1068,7 @@ >> %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT >> %token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK >> %token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK >> +%token DATA > > The word "Data" is somewhat bland. Since the method on Module is > "setDataLayout" can we make this "DataLayout" instead? I'd like > this to > be a bit more specific. > > Chris: your thoughts? Agree, I just changed this. >> %type OptCallingConv >> >> // Basic Block Terminating Operators >> @@ -1873,6 +1874,11 @@ >> free($3); >> CHECK_FOR_ERROR >>}; >> + | DATA '=' STRINGCONSTANT { >> +CurModule.CurrentModule->setDataLayout($3); >> +free($3); >> +CHECK_FOR_ERROR > > I don't think you need a CHECK_FOR_ERROR here. Neither of the two > preceding calls will call GENERATE_ERROR. Owen/Reid: can one of you take care of this? Thx, -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Lexer.l
Owen, Some comments .. On Tue, 2006-10-17 at 21:20 -0500, Owen Anderson wrote: > > Changes in directory llvm/lib/AsmParser: > > llvmAsmParser.y updated: 1.265 -> 1.266 > Lexer.l updated: 1.77 -> 1.78 > --- > Log message: > > Add support for the new "target data" information in .ll files. This > provides > a better encoding of the targets data layout, rather than trying to guess it > from the endianness and pointersize like before. > > > --- > Diffs of the changes: (+7 -0) > > Lexer.l |1 + > llvmAsmParser.y |6 ++ > 2 files changed, 7 insertions(+) > > > Index: llvm/lib/AsmParser/llvmAsmParser.y > diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.265 > llvm/lib/AsmParser/llvmAsmParser.y:1.266 > --- llvm/lib/AsmParser/llvmAsmParser.y:1.265 Sun Oct 15 18:26:46 2006 > +++ llvm/lib/AsmParser/llvmAsmParser.yTue Oct 17 21:19:55 2006 > @@ -1068,6 +1068,7 @@ > %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT > %token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK > %token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK > +%token DATA The word "Data" is somewhat bland. Since the method on Module is "setDataLayout" can we make this "DataLayout" instead? I'd like this to be a bit more specific. Chris: your thoughts? > %type OptCallingConv > > // Basic Block Terminating Operators > @@ -1873,6 +1874,11 @@ > free($3); > CHECK_FOR_ERROR >}; > + | DATA '=' STRINGCONSTANT { > +CurModule.CurrentModule->setDataLayout($3); > +free($3); > +CHECK_FOR_ERROR I don't think you need a CHECK_FOR_ERROR here. Neither of the two preceding calls will call GENERATE_ERROR. > + }; > > LibrariesDefinition : '[' LibList ']'; > > > > Index: llvm/lib/AsmParser/Lexer.l > diff -u llvm/lib/AsmParser/Lexer.l:1.77 llvm/lib/AsmParser/Lexer.l:1.78 > --- llvm/lib/AsmParser/Lexer.l:1.77 Sun Sep 17 15:25:45 2006 > +++ llvm/lib/AsmParser/Lexer.lTue Oct 17 21:19:55 2006 > @@ -210,6 +210,7 @@ > deplibs { return DEPLIBS; } > endian { return ENDIAN; } > pointersize { return POINTERSIZE; } > +data { return DATA; } Same comment as above .. perhaps datalayout ? > little { return LITTLE; } > big { return BIG; } > volatile{ return VOLATILE; } > > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Lexer.l
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.265 -> 1.266 Lexer.l updated: 1.77 -> 1.78 --- Log message: Add support for the new "target data" information in .ll files. This provides a better encoding of the targets data layout, rather than trying to guess it from the endianness and pointersize like before. --- Diffs of the changes: (+7 -0) Lexer.l |1 + llvmAsmParser.y |6 ++ 2 files changed, 7 insertions(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.265 llvm/lib/AsmParser/llvmAsmParser.y:1.266 --- llvm/lib/AsmParser/llvmAsmParser.y:1.265Sun Oct 15 18:26:46 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Oct 17 21:19:55 2006 @@ -1068,6 +1068,7 @@ %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT %token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK %token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK +%token DATA %type OptCallingConv // Basic Block Terminating Operators @@ -1873,6 +1874,11 @@ free($3); CHECK_FOR_ERROR }; + | DATA '=' STRINGCONSTANT { +CurModule.CurrentModule->setDataLayout($3); +free($3); +CHECK_FOR_ERROR + }; LibrariesDefinition : '[' LibList ']'; Index: llvm/lib/AsmParser/Lexer.l diff -u llvm/lib/AsmParser/Lexer.l:1.77 llvm/lib/AsmParser/Lexer.l:1.78 --- llvm/lib/AsmParser/Lexer.l:1.77 Sun Sep 17 15:25:45 2006 +++ llvm/lib/AsmParser/Lexer.l Tue Oct 17 21:19:55 2006 @@ -210,6 +210,7 @@ deplibs { return DEPLIBS; } endian { return ENDIAN; } pointersize { return POINTERSIZE; } +data { return DATA; } little { return LITTLE; } big { return BIG; } volatile{ return VOLATILE; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.264 -> 1.265 --- Log message: Produce a useful error message for Regression/Verifier/2006-10-15-AddrLabel.ll --- Diffs of the changes: (+2 -0) llvmAsmParser.y |2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.264 llvm/lib/AsmParser/llvmAsmParser.y:1.265 --- llvm/lib/AsmParser/llvmAsmParser.y:1.264Mon Oct 9 12:36:59 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Oct 15 18:26:46 2006 @@ -1296,6 +1296,8 @@ CHECK_FOR_ERROR } | UpRTypes '*' { // Pointer type? +if (*$1 == Type::LabelTy) + GEN_ERROR("Cannot form a pointer to a basic block"); $$ = new PATypeHolder(HandleUpRefs(PointerType::get(*$1))); delete $1; CHECK_FOR_ERROR ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.257 -> 1.258 --- Log message: trivial optimization --- Diffs of the changes: (+4 -1) llvmAsmParser.y |5 - 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.257 llvm/lib/AsmParser/llvmAsmParser.y:1.258 --- llvm/lib/AsmParser/llvmAsmParser.y:1.257Fri Aug 18 12:32:55 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Aug 18 12:34:24 2006 @@ -714,7 +714,10 @@ /// thus we can complete the cycle. /// static PATypeHolder HandleUpRefs(const Type *ty) { - if (!ty->isAbstract()) return ty; + // If Ty isn't abstract, or if there are no up-references in it, then there is + // nothing to resolve here. + if (!ty->isAbstract() || UpRefs.empty()) return ty; + PATypeHolder Ty(ty); UR_OUT("Type '" << Ty->getDescription() << "' newly formed. Resolving upreferences.\n" << ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.254 -> 1.255 --- Log message: Fix grammar in a comment. --- Diffs of the changes: (+1 -1) llvmAsmParser.y |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.254 llvm/lib/AsmParser/llvmAsmParser.y:1.255 --- llvm/lib/AsmParser/llvmAsmParser.y:1.254Fri May 19 16:28:34 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun May 28 21:33:58 2006 @@ -72,7 +72,7 @@ std::map LateResolveTypes; /// PlaceHolderInfo - When temporary placeholder objects are created, remember - /// how they were referenced and one which line of the input they came from so + /// how they were referenced and on which line of the input they came from so /// that we can resolve them later and print error messages as appropriate. std::map > PlaceHolderInfo; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Lexer.l
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.253 -> 1.254 Lexer.l updated: 1.73 -> 1.74 --- Log message: Add support for parsing csret --- Diffs of the changes: (+3 -1) Lexer.l |1 + llvmAsmParser.y |3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.253 llvm/lib/AsmParser/llvmAsmParser.y:1.254 --- llvm/lib/AsmParser/llvmAsmParser.y:1.253Fri Apr 7 23:08:32 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri May 19 16:28:34 2006 @@ -981,7 +981,7 @@ %token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING %token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN %token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT -%token CC_TOK CCC_TOK FASTCC_TOK COLDCC_TOK +%token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK %type OptCallingConv // Basic Block Terminating Operators @@ -1054,6 +1054,7 @@ OptCallingConv : /*empty*/ { $$ = CallingConv::C; } | CCC_TOK{ $$ = CallingConv::C; } | + CSRETCC_TOK{ $$ = CallingConv::CSRet; } | FASTCC_TOK { $$ = CallingConv::Fast; } | COLDCC_TOK { $$ = CallingConv::Cold; } | CC_TOK EUINT64VAL { Index: llvm/lib/AsmParser/Lexer.l diff -u llvm/lib/AsmParser/Lexer.l:1.73 llvm/lib/AsmParser/Lexer.l:1.74 --- llvm/lib/AsmParser/Lexer.l:1.73 Fri Apr 7 20:18:35 2006 +++ llvm/lib/AsmParser/Lexer.l Fri May 19 16:28:34 2006 @@ -218,6 +218,7 @@ cc { return CC_TOK; } ccc { return CCC_TOK; } +csretcc { return CSRETCC_TOK; } fastcc { return FASTCC_TOK; } coldcc { return COLDCC_TOK; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.252 -> 1.253 --- Log message: Use isValidOperands instead of duplicating or eliding checks. --- Diffs of the changes: (+8 -19) llvmAsmParser.y | 27 --- 1 files changed, 8 insertions(+), 19 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.252 llvm/lib/AsmParser/llvmAsmParser.y:1.253 --- llvm/lib/AsmParser/llvmAsmParser.y:1.252Fri Apr 7 22:53:34 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Apr 7 23:08:32 2006 @@ -1541,14 +1541,13 @@ $$ = ConstantExpr::get($1, $3, $5); } | EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' { -if (!isa($3->getType())) - ThrowException("First operand of extractelement must be " - "packed type!"); -if ($5->getType() != Type::UIntTy) - ThrowException("Second operand of extractelement must be uint!"); +if (!ExtractElementInst::isValidOperands($3, $5)) + ThrowException("Invalid extractelement operands!"); $$ = ConstantExpr::getExtractElement($3, $5); } | INSERTELEMENT '(' ConstVal ',' ConstVal ',' ConstVal ')' { +if (!InsertElementInst::isValidOperands($3, $5, $7)) + ThrowException("Invalid insertelement operands!"); $$ = ConstantExpr::getInsertElement($3, $5, $7); } | SHUFFLEVECTOR '(' ConstVal ',' ConstVal ',' ConstVal ')' { @@ -2250,23 +2249,13 @@ delete $4; } | EXTRACTELEMENT ResolvedVal ',' ResolvedVal { -if (!isa($2->getType())) - ThrowException("First operand of extractelement must be " - "packed type!"); -if ($4->getType() != Type::UIntTy) - ThrowException("Second operand of extractelement must be uint!"); +if (!ExtractElementInst::isValidOperands($2, $4)) + ThrowException("Invalid extractelement operands!"); $$ = new ExtractElementInst($2, $4); } | INSERTELEMENT ResolvedVal ',' ResolvedVal ',' ResolvedVal { -if (!isa($2->getType())) - ThrowException("First operand of insertelement must be " - "packed type!"); -if ($4->getType() != -cast($2->getType())->getElementType()) - ThrowException("Second operand of insertelement must be " - "packed element type!"); -if ($6->getType() != Type::UIntTy) - ThrowException("Third operand of insertelement must be uint!"); +if (!InsertElementInst::isValidOperands($2, $4, $6)) + ThrowException("Invalid insertelement operands!"); $$ = new InsertElementInst($2, $4, $6); } | SHUFFLEVECTOR ResolvedVal ',' ResolvedVal ',' ResolvedVal { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.251 -> 1.252 --- Log message: Add insertelement and shufflevector constantexpr support --- Diffs of the changes: (+9 -0) llvmAsmParser.y |9 + 1 files changed, 9 insertions(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.251 llvm/lib/AsmParser/llvmAsmParser.y:1.252 --- llvm/lib/AsmParser/llvmAsmParser.y:1.251Fri Apr 7 20:18:35 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Apr 7 22:53:34 2006 @@ -1547,8 +1547,17 @@ if ($5->getType() != Type::UIntTy) ThrowException("Second operand of extractelement must be uint!"); $$ = ConstantExpr::getExtractElement($3, $5); + } + | INSERTELEMENT '(' ConstVal ',' ConstVal ',' ConstVal ')' { +$$ = ConstantExpr::getInsertElement($3, $5, $7); + } + | SHUFFLEVECTOR '(' ConstVal ',' ConstVal ',' ConstVal ')' { +if (!ShuffleVectorInst::isValidOperands($3, $5, $7)) + ThrowException("Invalid shufflevector operands!"); +$$ = ConstantExpr::getShuffleVector($3, $5, $7); }; + // ConstVector - A list of comma separated constants. ConstVector : ConstVector ',' ConstVal { ($$ = $1)->push_back($3); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.249 -> 1.250 --- Log message: Don't use invalidated iterators! --- Diffs of the changes: (+3 -3) llvmAsmParser.y |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.249 llvm/lib/AsmParser/llvmAsmParser.y:1.250 --- llvm/lib/AsmParser/llvmAsmParser.y:1.249Wed Jan 25 16:26:43 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Sat Mar 4 01:53:16 2006 @@ -107,9 +107,9 @@ } // Look for intrinsic functions and CallInst that need to be upgraded -for (Module::iterator FI = CurrentModule->begin(),FE = CurrentModule->end(); - FI != FE; ++FI) - UpgradeCallsToIntrinsic(FI); +for (Module::iterator FI = CurrentModule->begin(), + FE = CurrentModule->end(); FI != FE; ) + UpgradeCallsToIntrinsic(FI++); Values.clear(); // Clear out function local definitions Types.clear(); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Lexer.l
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.246 -> 1.247 Lexer.l updated: 1.69 -> 1.70 --- Log message: syntax change --- Diffs of the changes: (+4 -3) Lexer.l |1 + llvmAsmParser.y |6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.246 llvm/lib/AsmParser/llvmAsmParser.y:1.247 --- llvm/lib/AsmParser/llvmAsmParser.y:1.246Mon Jan 23 17:05:15 2006 +++ llvm/lib/AsmParser/llvmAsmParser.y Mon Jan 23 18:40:17 2006 @@ -967,7 +967,7 @@ %token DECLARE GLOBAL CONSTANT SECTION VOLATILE %token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING %token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN -%token DEPLIBS CALL TAIL ASM_TOK +%token DEPLIBS CALL TAIL ASM_TOK MODULE %token CC_TOK CCC_TOK FASTCC_TOK COLDCC_TOK %type OptCallingConv @@ -1571,7 +1571,7 @@ | FunctionList FunctionProto { $$ = $1; } - | FunctionList ASM_TOK AsmBlock { + | FunctionList MODULE ASM_TOK AsmBlock { $$ = $1; } | FunctionList IMPLEMENTATION { @@ -1612,7 +1612,7 @@ } | ConstPool FunctionProto { // Function prototypes can be in const pool } - | ConstPool ASM_TOK AsmBlock {// Asm blocks can be in the const pool + | ConstPool MODULE ASM_TOK AsmBlock { // Asm blocks can be in the const pool } | ConstPool OptAssign OptLinkage GlobalType ConstVal { if ($5 == 0) ThrowException("Global value initializer is not a constant!"); Index: llvm/lib/AsmParser/Lexer.l diff -u llvm/lib/AsmParser/Lexer.l:1.69 llvm/lib/AsmParser/Lexer.l:1.70 --- llvm/lib/AsmParser/Lexer.l:1.69 Mon Jan 23 17:05:15 2006 +++ llvm/lib/AsmParser/Lexer.l Mon Jan 23 18:40:17 2006 @@ -212,6 +212,7 @@ volatile{ return VOLATILE; } align { return ALIGN; } section { return SECTION; } +module { return MODULE; } asm { return ASM_TOK; } cc { return CC_TOK; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.240 -> 1.241 --- Log message: allow logical operators on packed integral types --- Diffs of the changes: (+10 -4) llvmAsmParser.y | 14 ++ 1 files changed, 10 insertions(+), 4 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.240 llvm/lib/AsmParser/llvmAsmParser.y:1.241 --- llvm/lib/AsmParser/llvmAsmParser.y:1.240Wed Dec 21 11:53:02 2005 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Dec 21 12:31:29 2005 @@ -1501,8 +1501,11 @@ | LogicalOps '(' ConstVal ',' ConstVal ')' { if ($3->getType() != $5->getType()) ThrowException("Logical operator types must match!"); -if (!$3->getType()->isIntegral()) - ThrowException("Logical operands must have integral types!"); +if (!$3->getType()->isIntegral()) { + if (!isa($3->getType()) || + !cast($3->getType())->getElementType()->isIntegral()) +ThrowException("Logical operator requires integral operands!"); +} $$ = ConstantExpr::get($1, $3, $5); } | SetCondOps '(' ConstVal ',' ConstVal ')' { @@ -2079,8 +2082,11 @@ delete $2; } | LogicalOps Types ValueRef ',' ValueRef { -if (!(*$2)->isIntegral()) - ThrowException("Logical operator requires integral operands!"); +if (!(*$2)->isIntegral()) { + if (!isa($2->get()) || + !cast($2->get())->getElementType()->isIntegral()) +ThrowException("Logical operator requires integral operands!"); +} $$ = BinaryOperator::create($1, getVal(*$2, $3), getVal(*$2, $5)); if ($$ == 0) ThrowException("binary operator returned null!"); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y ParserInternals.h
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.239 -> 1.240 ParserInternals.h updated: 1.41 -> 1.42 --- Log message: Implement Regression/Assembler/2005-12-21-ZeroInitVector.ll --- Diffs of the changes: (+13 -1) ParserInternals.h |8 +++- llvmAsmParser.y |6 ++ 2 files changed, 13 insertions(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.239 llvm/lib/AsmParser/llvmAsmParser.y:1.240 --- llvm/lib/AsmParser/llvmAsmParser.y:1.239Sat Nov 12 12:21:21 2005 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Dec 21 11:53:02 2005 @@ -303,6 +303,9 @@ case ValID::ConstUndefVal: // Is it an undef value? return UndefValue::get(Ty); + case ValID::ConstZeroVal: // Is it a zero value? +return Constant::getNullValue(Ty); + case ValID::ConstantVal: // Fully resolved constant? if (D.ConstantValue->getType() != Ty) ThrowException("Constant expression type different from required type!"); @@ -1816,6 +1819,9 @@ | UNDEF { $$ = ValID::createUndef(); } + | ZEROINITIALIZER { // A vector zero constant. +$$ = ValID::createZeroInit(); + } | '<' ConstVector '>' { // Nonempty unsized packed vector const Type *ETy = (*$2)[0]->getType(); int NumElements = $2->size(); Index: llvm/lib/AsmParser/ParserInternals.h diff -u llvm/lib/AsmParser/ParserInternals.h:1.41 llvm/lib/AsmParser/ParserInternals.h:1.42 --- llvm/lib/AsmParser/ParserInternals.h:1.41 Thu May 19 22:25:47 2005 +++ llvm/lib/AsmParser/ParserInternals.hWed Dec 21 11:53:02 2005 @@ -82,7 +82,7 @@ struct ValID { enum { NumberVal, NameVal, ConstSIntVal, ConstUIntVal, ConstFPVal, ConstNullVal, -ConstUndefVal, ConstantVal, +ConstUndefVal, ConstZeroVal, ConstantVal, } Type; union { @@ -122,6 +122,10 @@ ValID D; D.Type = ConstUndefVal; return D; } + static ValID createZeroInit() { +ValID D; D.Type = ConstZeroVal; return D; + } + static ValID create(Constant *Val) { ValID D; D.Type = ConstantVal; D.ConstantValue = Val; return D; } @@ -145,6 +149,7 @@ case ConstFPVal: return ftostr(ConstPoolFP); case ConstNullVal : return "null"; case ConstUndefVal : return "undef"; +case ConstZeroVal : return "zeroinitializer"; case ConstUIntVal : case ConstSIntVal : return std::string("%") + itostr(ConstPool64); case ConstantVal: @@ -168,6 +173,7 @@ case ConstFPVal:return ConstPoolFP < V.ConstPoolFP; case ConstNullVal: return false; case ConstUndefVal: return false; +case ConstZeroVal: return false; case ConstantVal: return ConstantValue < V.ConstantValue; default: assert(0 && "Unknown value type!"); return false; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.238 -> 1.239 --- Log message: refactor grammar to eliminate shift-reduce conflict. Move alignment checking code out of all of the clients and into OptAlign/OptCAlign --- Diffs of the changes: (+45 -49) llvmAsmParser.y | 94 ++-- 1 files changed, 45 insertions(+), 49 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.238 llvm/lib/AsmParser/llvmAsmParser.y:1.239 --- llvm/lib/AsmParser/llvmAsmParser.y:1.238Fri Nov 11 18:11:10 2005 +++ llvm/lib/AsmParser/llvmAsmParser.y Sat Nov 12 12:21:21 2005 @@ -50,7 +50,8 @@ static bool ObsoleteVarArgs; static bool NewVarArgs; -static BasicBlock* CurBB; +static BasicBlock *CurBB; +static GlobalVariable *CurGV; // This contains info used when building the body of a function. It is @@ -515,13 +516,10 @@ /// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, /// this is a declaration, otherwise it is a definition. -static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, -bool isConstantGlobal, const Type *Ty, -Constant *Initializer, char *Section, -unsigned Align) { - if (Align != 0 && !isPowerOf2_32(Align)) -ThrowException("Global alignment must be a power of two!"); - +static GlobalVariable * +ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, +bool isConstantGlobal, const Type *Ty, +Constant *Initializer) { if (isa(Ty)) ThrowException("Cannot declare global vars of function type!"); @@ -551,13 +549,8 @@ GV->setInitializer(Initializer); GV->setLinkage(Linkage); GV->setConstant(isConstantGlobal); -GV->setAlignment(Align); -if (Section) { - free(Section); - GV->setSection(Section); -} InsertValue(GV, CurModule.Values); -return; +return GV; } // If this global has a name, check to see if there is already a definition @@ -582,12 +575,7 @@ if (isConstantGlobal) EGV->setConstant(true); EGV->setLinkage(Linkage); -EGV->setAlignment(Align); -if (Section) { - free(Section); - EGV->setSection(Section); -} -return; +return EGV; } ThrowException("Redefinition of global variable named '" + Name + @@ -599,12 +587,8 @@ GlobalVariable *GV = new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, CurModule.CurrentModule); - GV->setAlignment(Align); - if (Section) { -free(Section); -GV->setSection(Section); - } InsertValue(GV, CurModule.Values); + return GV; } // setTypeName - Set the specified type to the name given. The name may be @@ -969,7 +953,7 @@ %token VAR_ID LABELSTR STRINGCONSTANT %type Name OptName OptAssign %type OptAlign OptCAlign -%type OptSection OptCSection SectionString +%type OptSection SectionString %token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK %token DECLARE GLOBAL CONSTANT SECTION VOLATILE @@ -1059,9 +1043,18 @@ // OptAlign/OptCAlign - An optional alignment, and an optional alignment with // a comma before it. OptAlign : /*empty*/{ $$ = 0; } | - ALIGN EUINT64VAL { $$ = $2; }; + ALIGN EUINT64VAL { + $$ = $2; + if ($$ != 0 && !isPowerOf2_32($$)) +ThrowException("Alignment must be a power of two!"); +}; OptCAlign : /*empty*/{ $$ = 0; } | -',' ALIGN EUINT64VAL { $$ = $3; }; +',' ALIGN EUINT64VAL { + $$ = $3; + if ($$ != 0 && !isPowerOf2_32($$)) +ThrowException("Alignment must be a power of two!"); +}; + SectionString : SECTION STRINGCONSTANT { for (unsigned i = 0, e = strlen($2); i != e; ++i) @@ -1072,9 +1065,21 @@ OptSection : /*empty*/ { $$ = 0; } | SectionString { $$ = $1; }; -OptCSection : /*empty*/ { $$ = 0; } | - ',' SectionString { $$ = $2; }; +// GlobalVarAttributes - Used to pass the attributes string on a global. CurGV +// is set to be the global we are processing. +// +GlobalVarAttributes : /* empty */ {} | + ',' GlobalVarAttribute GlobalVarAttributes {}; +GlobalVarAttribute : SectionString { +CurGV->setSection($1); +free($1); + } + | ALIGN EUINT64VAL { +if ($2 != 0 && !isPowerOf2_32($2)) + ThrowException("Alignment must be a power of two!"); +CurGV->setAlignment($2); + }; //===--===// // Types includes all predefined types... except void, because it can only be @@ -1584,13 +1589,18 @@ } | ConstPool FunctionProto { // Function prototypes can be in const pool } - | ConstPool OptAssign OptLinkage GlobalType ConstVal OptCSection OptCAlign { + |
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.237 -> 1.238 --- Log message: Parse section info --- Diffs of the changes: (+41 -9) llvmAsmParser.y | 50 +- 1 files changed, 41 insertions(+), 9 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.237 llvm/lib/AsmParser/llvmAsmParser.y:1.238 --- llvm/lib/AsmParser/llvmAsmParser.y:1.237Wed Nov 9 19:42:43 2005 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Nov 11 18:11:10 2005 @@ -517,7 +517,8 @@ /// this is a declaration, otherwise it is a definition. static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, bool isConstantGlobal, const Type *Ty, -Constant *Initializer, unsigned Align) { +Constant *Initializer, char *Section, +unsigned Align) { if (Align != 0 && !isPowerOf2_32(Align)) ThrowException("Global alignment must be a power of two!"); @@ -551,6 +552,10 @@ GV->setLinkage(Linkage); GV->setConstant(isConstantGlobal); GV->setAlignment(Align); +if (Section) { + free(Section); + GV->setSection(Section); +} InsertValue(GV, CurModule.Values); return; } @@ -578,6 +583,10 @@ EGV->setConstant(true); EGV->setLinkage(Linkage); EGV->setAlignment(Align); +if (Section) { + free(Section); + EGV->setSection(Section); +} return; } @@ -591,6 +600,10 @@ new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, CurModule.CurrentModule); GV->setAlignment(Align); + if (Section) { +free(Section); +GV->setSection(Section); + } InsertValue(GV, CurModule.Values); } @@ -956,9 +969,10 @@ %token VAR_ID LABELSTR STRINGCONSTANT %type Name OptName OptAssign %type OptAlign OptCAlign +%type OptSection OptCSection SectionString %token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK -%token DECLARE GLOBAL CONSTANT VOLATILE +%token DECLARE GLOBAL CONSTANT SECTION VOLATILE %token TO DOTDOTDOT NULL_TOK UNDEF CONST INTERNAL LINKONCE WEAK APPENDING %token OPAQUE NOT EXTERNAL TARGET TRIPLE ENDIAN POINTERSIZE LITTLE BIG ALIGN %token DEPLIBS CALL TAIL @@ -1049,6 +1063,19 @@ OptCAlign : /*empty*/{ $$ = 0; } | ',' ALIGN EUINT64VAL { $$ = $3; }; +SectionString : SECTION STRINGCONSTANT { + for (unsigned i = 0, e = strlen($2); i != e; ++i) +if ($2[i] == '"' || $2[i] == '\\') + ThrowException("Invalid character in section name!"); + $$ = $2; +}; + +OptSection : /*empty*/ { $$ = 0; } | + SectionString { $$ = $1; }; +OptCSection : /*empty*/ { $$ = 0; } | + ',' SectionString { $$ = $2; }; + + //===--===// // Types includes all predefined types... except void, because it can only be // used in specific contexts (function returning void for example). To have @@ -1557,12 +1584,12 @@ } | ConstPool FunctionProto { // Function prototypes can be in const pool } - | ConstPool OptAssign OptLinkage GlobalType ConstVal OptCAlign { + | ConstPool OptAssign OptLinkage GlobalType ConstVal OptCSection OptCAlign { if ($5 == 0) ThrowException("Global value initializer is not a constant!"); -ParseGlobalVariable($2, $3, $4, $5->getType(), $5, $6); +ParseGlobalVariable($2, $3, $4, $5->getType(), $5, $6, $7); } - | ConstPool OptAssign EXTERNAL GlobalType Types OptCAlign { -ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, *$5, 0, $6); + | ConstPool OptAssign EXTERNAL GlobalType Types OptCSection OptCAlign { +ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, *$5, 0, $6, $7); delete $5; } | ConstPool TARGET TargetDefinition { @@ -1647,14 +1674,15 @@ $$ = 0; }; -FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')' OptAlign { +FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')' + OptSection OptAlign { UnEscapeLexed($3); std::string FunctionName($3); free($3); // Free strdup'd memory! if (!(*$2)->isFirstClassType() && *$2 != Type::VoidTy) ThrowException("LLVM functions cannot return aggregate types!"); - if ($7 != 0 && !isPowerOf2_32($7)) + if ($8 != 0 && !isPowerOf2_32($8)) ThrowException("Function alignment must be a power of two!"); std::vector ParamTypeList; @@ -1707,7 +1735,11 @@ CurFun.FunctionStart(Fn); Fn->setCallingConv($1); - Fn->setAlignment($7); + Fn->setAlignment($8); + if ($7) { +Fn->setSection($7); +free($7); + } // Add all of the arguments we parsed to the function... if ($5) { // Is null if empty... ___ llvm-commits mailing list llvm
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.235 -> 1.236 --- Log message: Allow globals to have an alignment specified. Switch to using isPowerOf2_32 at Jim's request for the checking code. --- Diffs of the changes: (+25 -13) llvmAsmParser.y | 38 +- 1 files changed, 25 insertions(+), 13 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.235 llvm/lib/AsmParser/llvmAsmParser.y:1.236 --- llvm/lib/AsmParser/llvmAsmParser.y:1.235Sun Nov 6 00:34:12 2005 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Nov 6 00:46:28 2005 @@ -19,6 +19,7 @@ #include "llvm/SymbolTable.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/MathExtras.h" #include #include #include @@ -516,7 +517,10 @@ /// this is a declaration, otherwise it is a definition. static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, bool isConstantGlobal, const Type *Ty, -Constant *Initializer) { +Constant *Initializer, unsigned Align) { + if (Align != 0 && !isPowerOf2_32(Align)) +ThrowException("Global alignment must be a power of two!"); + if (isa(Ty)) ThrowException("Cannot declare global vars of function type!"); @@ -546,6 +550,7 @@ GV->setInitializer(Initializer); GV->setLinkage(Linkage); GV->setConstant(isConstantGlobal); +GV->setAlignment(Align); InsertValue(GV, CurModule.Values); return; } @@ -572,6 +577,7 @@ if (isConstantGlobal) EGV->setConstant(true); EGV->setLinkage(Linkage); +EGV->setAlignment(Align); return; } @@ -584,6 +590,7 @@ GlobalVariable *GV = new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, CurModule.CurrentModule); + GV->setAlignment(Align); InsertValue(GV, CurModule.Values); } @@ -948,7 +955,7 @@ %token VAR_ID LABELSTR STRINGCONSTANT %type Name OptName OptAssign -%type OptCAlign +%type OptAlign OptCAlign %token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK %token DECLARE GLOBAL CONSTANT VOLATILE @@ -1037,6 +1044,8 @@ // OptAlign/OptCAlign - An optional alignment, and an optional alignment with // a comma before it. +OptAlign : /*empty*/{ $$ = 0; } | + ALIGN EUINT64VAL { $$ = $2; }; OptCAlign : /*empty*/{ $$ = 0; } | ',' ALIGN EUINT64VAL { $$ = $3; }; @@ -1548,12 +1557,12 @@ } | ConstPool FunctionProto { // Function prototypes can be in const pool } - | ConstPool OptAssign OptLinkage GlobalType ConstVal { + | ConstPool OptAssign OptLinkage GlobalType ConstVal OptCAlign { if ($5 == 0) ThrowException("Global value initializer is not a constant!"); -ParseGlobalVariable($2, $3, $4, $5->getType(), $5); +ParseGlobalVariable($2, $3, $4, $5->getType(), $5, $6); } - | ConstPool OptAssign EXTERNAL GlobalType Types { -ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, *$5, 0); + | ConstPool OptAssign EXTERNAL GlobalType Types OptCAlign { +ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, *$5, 0, $6); delete $5; } | ConstPool TARGET TargetDefinition { @@ -1638,13 +1647,15 @@ $$ = 0; }; -FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')' { +FunctionHeaderH : OptCallingConv TypesV Name '(' ArgList ')' OptAlign { UnEscapeLexed($3); std::string FunctionName($3); free($3); // Free strdup'd memory! if (!(*$2)->isFirstClassType() && *$2 != Type::VoidTy) ThrowException("LLVM functions cannot return aggregate types!"); + if ($7 != 0 && !isPowerOf2_32($7)) +ThrowException("Function alignment must be a power of two!"); std::vector ParamTypeList; if ($5) { // If there are arguments... @@ -1696,6 +1707,7 @@ CurFun.FunctionStart(Fn); Fn->setCallingConv($1); + Fn->setAlignment($7); // Add all of the arguments we parsed to the function... if ($5) { // Is null if empty... @@ -2210,28 +,28 @@ MemoryInst : MALLOC Types OptCAlign { - if ($3 & ($3-1)) -ThrowException("Alignment amount '" + utostr($3) + - "' is not a power of 2!"); +if ($3 != 0 && !isPowerOf2_32($3)) + ThrowException("Alignment amount '" + utostr($3) + + "' is not a power of 2!"); $$ = new MallocInst(*$2, 0, $3); delete $2; } | MALLOC Types ',' UINT ValueRef OptCAlign { -if ($6 & ($6-1)) +if ($6 != 0 && !isPowerOf2_32($6)) ThrowException("Alignment amount '" + utostr($6) + "' is not a power of 2!"); $$ = new MallocInst(*$2, getVal($4, $5), $6); delete $2; } | ALLOCA Types OptCAlign { -if ($3 & ($3-1)) +if ($3 != 0 && !isPowerOf2_32($3)) ThrowEx
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.234 -> 1.235 --- Log message: factor optional alignment --- Diffs of the changes: (+23 -34) llvmAsmParser.y | 57 ++-- 1 files changed, 23 insertions(+), 34 deletions(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.234 llvm/lib/AsmParser/llvmAsmParser.y:1.235 --- llvm/lib/AsmParser/llvmAsmParser.y:1.234Sat Nov 5 15:54:03 2005 +++ llvm/lib/AsmParser/llvmAsmParser.y Sun Nov 6 00:34:12 2005 @@ -948,7 +948,7 @@ %token VAR_ID LABELSTR STRINGCONSTANT %type Name OptName OptAssign - +%type OptCAlign %token IMPLEMENTATION ZEROINITIALIZER TRUETOK FALSETOK BEGINTOK ENDTOK %token DECLARE GLOBAL CONSTANT VOLATILE @@ -1035,6 +1035,11 @@ $$ = $2; }; +// OptAlign/OptCAlign - An optional alignment, and an optional alignment with +// a comma before it. +OptCAlign : /*empty*/{ $$ = 0; } | +',' ALIGN EUINT64VAL { $$ = $3; }; + //===--===// // Types includes all predefined types... except void, because it can only be // used in specific contexts (function returning void for example). To have @@ -2204,48 +2209,32 @@ -MemoryInst : MALLOC Types { -$$ = new MallocInst(*$2); +MemoryInst : MALLOC Types OptCAlign { + if ($3 & ($3-1)) +ThrowException("Alignment amount '" + utostr($3) + + "' is not a power of 2!"); +$$ = new MallocInst(*$2, 0, $3); delete $2; } - | MALLOC Types ',' ALIGN EUINT64VAL { -if ($5 & ($5-1)) - ThrowException("Alignment amount '" + utostr($5) + + | MALLOC Types ',' UINT ValueRef OptCAlign { +if ($6 & ($6-1)) + ThrowException("Alignment amount '" + utostr($6) + "' is not a power of 2!"); -$$ = new MallocInst(*$2, 0, $5); -delete $2; - } - | MALLOC Types ',' UINT ValueRef { -$$ = new MallocInst(*$2, getVal($4, $5)); +$$ = new MallocInst(*$2, getVal($4, $5), $6); delete $2; } - | MALLOC Types ',' UINT ValueRef ',' ALIGN EUINT64VAL { -if ($8 & ($8-1)) - ThrowException("Alignment amount '" + utostr($8) + + | ALLOCA Types OptCAlign { +if ($3 & ($3-1)) + ThrowException("Alignment amount '" + utostr($3) + "' is not a power of 2!"); -$$ = new MallocInst(*$2, getVal($4, $5), $8); -delete $2; - } - | ALLOCA Types { -$$ = new AllocaInst(*$2); -delete $2; - } - | ALLOCA Types ',' ALIGN EUINT64VAL { -if ($5 & ($5-1)) - ThrowException("Alignment amount '" + utostr($5) + - "' is not a power of 2!"); -$$ = new AllocaInst(*$2, 0, $5); -delete $2; - } - | ALLOCA Types ',' UINT ValueRef { -$$ = new AllocaInst(*$2, getVal($4, $5)); +$$ = new AllocaInst(*$2, 0, $3); delete $2; } - | ALLOCA Types ',' UINT ValueRef ',' ALIGN EUINT64VAL { -if ($8 & ($8-1)) - ThrowException("Alignment amount '" + utostr($8) + + | ALLOCA Types ',' UINT ValueRef OptCAlign { +if ($6 & ($6-1)) + ThrowException("Alignment amount '" + utostr($6) + "' is not a power of 2!"); -$$ = new AllocaInst(*$2, getVal($4, $5), $8); +$$ = new AllocaInst(*$2, getVal($4, $5), $6); delete $2; } | FREE ResolvedVal { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.233 -> 1.234 --- Log message: Verify that alignment amounts are a power of 2 --- Diffs of the changes: (+12 -0) llvmAsmParser.y | 12 1 files changed, 12 insertions(+) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.233 llvm/lib/AsmParser/llvmAsmParser.y:1.234 --- llvm/lib/AsmParser/llvmAsmParser.y:1.233Sat Nov 5 03:21:28 2005 +++ llvm/lib/AsmParser/llvmAsmParser.y Sat Nov 5 15:54:03 2005 @@ -2209,6 +2209,9 @@ delete $2; } | MALLOC Types ',' ALIGN EUINT64VAL { +if ($5 & ($5-1)) + ThrowException("Alignment amount '" + utostr($5) + + "' is not a power of 2!"); $$ = new MallocInst(*$2, 0, $5); delete $2; } @@ -2217,6 +2220,9 @@ delete $2; } | MALLOC Types ',' UINT ValueRef ',' ALIGN EUINT64VAL { +if ($8 & ($8-1)) + ThrowException("Alignment amount '" + utostr($8) + + "' is not a power of 2!"); $$ = new MallocInst(*$2, getVal($4, $5), $8); delete $2; } @@ -2225,6 +2231,9 @@ delete $2; } | ALLOCA Types ',' ALIGN EUINT64VAL { +if ($5 & ($5-1)) + ThrowException("Alignment amount '" + utostr($5) + + "' is not a power of 2!"); $$ = new AllocaInst(*$2, 0, $5); delete $2; } @@ -2233,6 +2242,9 @@ delete $2; } | ALLOCA Types ',' UINT ValueRef ',' ALIGN EUINT64VAL { +if ($8 & ($8-1)) + ThrowException("Alignment amount '" + utostr($8) + + "' is not a power of 2!"); $$ = new AllocaInst(*$2, getVal($4, $5), $8); delete $2; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits