llvm.org GIT mirror llvm / 73bc452
Remove a use of AttributeWithIndex. We want to remove AttributeWithIndex because it provides a non-encapsulated view of the AttributeSetImpl object. Instead, use accessor methods and iterators. Eventually, this code can be simplified because the Attribute object will hold only one attribute instead of multiple attributes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173641 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 7 years ago
2 changed file(s) with 35 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
116116 LLVMContext &Context;
117117 SmallVector AttrList;
118118
119 SmallVector, 4> AttrNodes;
119 typedef std::pair IndexAttrPair;
120 SmallVector AttrNodes;
120121
121122 // AttributesSet is uniqued, these should not be publicly available.
122123 void operator=(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
136137 /// is the index of the return, parameter, or function object that the
137138 /// attributes are applied to, not the index into the AttrNodes list where the
138139 /// attributes reside.
139 uint64_t getSlotIndex(unsigned Slot) const { return AttrNodes[Slot].first; }
140 uint64_t getSlotIndex(unsigned Slot) const {
141 return AttrNodes[Slot].first;
142 }
140143
141144 /// \brief Retrieve the attributes for the given "slot" in the AttrNode list.
142145 /// \p Slot is an index into the AttrNodes list, not the index of the return /
145148 // FIXME: This needs to use AttrNodes instead.
146149 return AttributeSet::get(Context, AttrList[Slot]);
147150 }
151
152 typedef AttributeSetNode::iterator iterator;
153 typedef AttributeSetNode::const_iterator const_iterator;
154
155 iterator begin(unsigned Idx)
156 { return AttrNodes[Idx].second->begin(); }
157 iterator end(unsigned Idx)
158 { return AttrNodes[Idx].second->end(); }
159
160 const_iterator begin(unsigned Idx) const
161 { return AttrNodes[Idx].second->begin(); }
162 const_iterator end(unsigned Idx) const
163 { return AttrNodes[Idx].second->end(); }
148164
149165 void Profile(FoldingSetNodeID &ID) const {
150166 Profile(ID, AttrList);
196196 AttributeSetImpl *pImpl = AS.pImpl;
197197 if (!pImpl) return;
198198
199 ArrayRef AttrList = pImpl->getAttributes();
200 const AttributeWithIndex *AWI = 0;
201 for (unsigned I = 0, E = AttrList.size(); I != E; ++I)
202 if (AttrList[I].Index == Idx) {
203 AWI = &AttrList[I];
204 break;
205 }
206
207 if (!AWI) return;
208
209 uint64_t Mask = AWI->Attrs.Raw();
199 AttrBuilder B;
200
201 for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I) {
202 if (pImpl->getSlotIndex(I) != Idx) continue;
203
204 for (AttributeSetNode::const_iterator II = pImpl->begin(I),
205 IE = pImpl->end(I); II != IE; ++II)
206 B.addAttributes(*II);
207
208 break;
209 }
210
211 if (!B.hasAttributes()) return;
212
213 uint64_t Mask = B.Raw();
210214
211215 for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds;
212216 I = Attribute::AttrKind(I + 1)) {
860864 }
861865
862866 void AttributeSet::dump() const {
863 dbgs() << "PAL[ ";
864 for (unsigned i = 0; i < getNumSlots(); ++i) {
867 dbgs() << "PAL[\n";
868 for (unsigned i = 0, e = getNumSlots(); i < e; ++i) {
865869 uint64_t Index = getSlotIndex(i);
866870 dbgs() << " { ";
867871 if (Index == ~0U)