Changes in directory llvm/lib/VMCore:
Function.cpp updated: 1.116 -> 1.117 Instructions.cpp updated: 1.81 -> 1.82 Type.cpp updated: 1.179 -> 1.180 --- Log message: For PR1146: http://llvm.org/PR1146 : * Add ParamAttrList pointers to Function and CallInst. * Move the implementation of ParamAttrList from Type.cpp to Function.cpp --- Diffs of the changes: (+68 -59) Function.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ Instructions.cpp | 4 +++ Type.cpp | 59 -------------------------------------------------- 3 files changed, 68 insertions(+), 59 deletions(-) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.116 llvm/lib/VMCore/Function.cpp:1.117 --- llvm/lib/VMCore/Function.cpp:1.116 Mon Apr 9 01:11:23 2007 +++ llvm/lib/VMCore/Function.cpp Mon Apr 9 10:01:12 2007 @@ -72,12 +72,76 @@ } //===----------------------------------------------------------------------===// +// ParamAttrsList Implementation +//===----------------------------------------------------------------------===// + +uint16_t +ParamAttrsList::getParamAttrs(uint16_t Index) const { + unsigned limit = attrs.size(); + for (unsigned i = 0; i < limit; ++i) + if (attrs[i].index == Index) + return attrs[i].attrs; + return NoAttributeSet; +} + + +std::string +ParamAttrsList::getParamAttrsText(uint16_t Attrs) { + std::string Result; + if (Attrs & ZExtAttribute) + Result += "zext "; + if (Attrs & SExtAttribute) + Result += "sext "; + if (Attrs & NoReturnAttribute) + Result += "noreturn "; + if (Attrs & NoUnwindAttribute) + Result += "nounwind "; + if (Attrs & InRegAttribute) + Result += "inreg "; + if (Attrs & StructRetAttribute) + Result += "sret "; + return Result; +} + +void +ParamAttrsList::addAttributes(uint16_t Index, uint16_t Attrs) { + // First, try to replace an existing one + for (unsigned i = 0; i < attrs.size(); ++i) + if (attrs[i].index == Index) { + attrs[i].attrs |= Attrs; + return; + } + + // If not found, add a new one + ParamAttrsWithIndex Val; + Val.attrs = Attrs; + Val.index = Index; + attrs.push_back(Val); +} + +void +ParamAttrsList::removeAttributes(uint16_t Index, uint16_t Attrs) { + // Find the index from which to remove the attributes + for (unsigned i = 0; i < attrs.size(); ++i) + if (attrs[i].index == Index) { + attrs[i].attrs &= ~Attrs; + if (attrs[i].attrs == NoAttributeSet) + attrs.erase(&attrs[i]); + return; + } + + // The index wasn't found above + assert(0 && "Index not found for removeAttributes"); +} + +//===----------------------------------------------------------------------===// // Function Implementation //===----------------------------------------------------------------------===// Function::Function(const FunctionType *Ty, LinkageTypes Linkage, const std::string &name, Module *ParentModule) : GlobalValue(PointerType::get(Ty), Value::FunctionVal, 0, 0, Linkage, name) { + ParamAttrs = 0; CallingConvention = 0; BasicBlocks.setItemParent(this); BasicBlocks.setParent(this); Index: llvm/lib/VMCore/Instructions.cpp diff -u llvm/lib/VMCore/Instructions.cpp:1.81 llvm/lib/VMCore/Instructions.cpp:1.82 --- llvm/lib/VMCore/Instructions.cpp:1.81 Thu Mar 22 11:38:57 2007 +++ llvm/lib/VMCore/Instructions.cpp Mon Apr 9 10:01:12 2007 @@ -188,6 +188,7 @@ } void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) { + ParamAttrs = 0; NumOperands = NumParams+1; Use *OL = OperandList = new Use[NumParams+1]; OL[0].init(Func, this); @@ -208,6 +209,7 @@ } void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) { + ParamAttrs = 0; NumOperands = 3; Use *OL = OperandList = new Use[3]; OL[0].init(Func, this); @@ -230,6 +232,7 @@ } void CallInst::init(Value *Func, Value *Actual) { + ParamAttrs = 0; NumOperands = 2; Use *OL = OperandList = new Use[2]; OL[0].init(Func, this); @@ -248,6 +251,7 @@ } void CallInst::init(Value *Func) { + ParamAttrs = 0; NumOperands = 1; Use *OL = OperandList = new Use[1]; OL[0].init(Func, this); Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.179 llvm/lib/VMCore/Type.cpp:1.180 --- llvm/lib/VMCore/Type.cpp:1.179 Mon Apr 9 01:07:52 2007 +++ llvm/lib/VMCore/Type.cpp Mon Apr 9 10:01:12 2007 @@ -1121,65 +1121,6 @@ return false; } -uint16_t -ParamAttrsList::getParamAttrs(uint16_t Index) const { - unsigned limit = attrs.size(); - for (unsigned i = 0; i < limit; ++i) - if (attrs[i].index == Index) - return attrs[i].attrs; - return NoAttributeSet; -} - - -std::string -ParamAttrsList::getParamAttrsText(uint16_t Attrs) { - std::string Result; - if (Attrs & ZExtAttribute) - Result += "zext "; - if (Attrs & SExtAttribute) - Result += "sext "; - if (Attrs & NoReturnAttribute) - Result += "noreturn "; - if (Attrs & NoUnwindAttribute) - Result += "nounwind "; - if (Attrs & InRegAttribute) - Result += "inreg "; - if (Attrs & StructRetAttribute) - Result += "sret "; - return Result; -} - -void -ParamAttrsList::addAttributes(uint16_t Index, uint16_t Attrs) { - // First, try to replace an existing one - for (unsigned i = 0; i < attrs.size(); ++i) - if (attrs[i].index == Index) { - attrs[i].attrs |= Attrs; - return; - } - - // If not found, add a new one - ParamAttrsWithIndex Val; - Val.attrs = Attrs; - Val.index = Index; - attrs.push_back(Val); -} - -void -ParamAttrsList::removeAttributes(uint16_t Index, uint16_t Attrs) { - // Find the index from which to remove the attributes - for (unsigned i = 0; i < attrs.size(); ++i) - if (attrs[i].index == Index) { - attrs[i].attrs &= ~Attrs; - if (attrs[i].attrs == NoAttributeSet) - attrs.erase(&attrs[i]); - return; - } - - // The index wasn't found above - assert(0 && "Index not found for removeAttributes"); -} - //===----------------------------------------------------------------------===// // Array Type Factory... // _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits