llvm.org GIT mirror llvm / 4aa1899
Revert r164308 to fix buildbots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164309 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 8 years ago
5 changed file(s) with 31 addition(s) and 34 deletion(s). Raw diff Collapse all Expand all
204204 return Bits & Attribute::StackAlignment_i;
205205 }
206206
207 /// This returns the alignment field of an attribute as a byte alignment
208 /// value.
209 unsigned getAlignment() const {
210 if (!hasAlignmentAttr())
211 return 0;
212
213 return 1U << ((getRawAlignment() >> 16) - 1);
214 }
215
216 /// This returns the stack alignment field of an attribute as a byte alignment
217 /// value.
218 unsigned getStackAlignment() const {
219 if (!hasStackAlignmentAttr())
220 return 0;
221
222 return 1U << ((getRawStackAlignment() >> 26) - 1);
223 }
224
225207 // This is a "safe bool() operator".
226208 operator const void *() const { return Bits ? this : 0; }
227209 bool isEmptyOrSingleton() const { return (Bits & (Bits - 1)) == 0; }
229211 return Bits == Attrs.Bits;
230212 }
231213 bool operator != (const Attributes &Attrs) const {
232 return !(this == Attrs);
233 }
234
214 return Bits != Attrs.Bits;
215 }
235216 Attributes operator | (const Attributes &Attrs) const {
236217 return Attributes(Bits | Attrs.Bits);
237218 }
312293 return Attributes((Log2_32(i)+1) << 16);
313294 }
314295
296 /// This returns the alignment field of an attribute as a byte alignment value.
297 inline unsigned getAlignmentFromAttrs(Attributes A) {
298 if (!A.hasAlignmentAttr())
299 return 0;
300
301 return 1U << ((A.getRawAlignment() >> 16) - 1);
302 }
303
315304 /// This turns an int stack alignment (which must be a power of 2) into
316305 /// the form used internally in Attributes.
317306 inline Attributes constructStackAlignmentFromInt(unsigned i) {
322311 assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
323312 assert(i <= 0x100 && "Alignment too large.");
324313 return Attributes((Log2_32(i)+1) << 26);
314 }
315
316 /// This returns the stack alignment field of an attribute as a byte alignment
317 /// value.
318 inline unsigned getStackAlignmentFromAttrs(Attributes A) {
319 if (!A.hasStackAlignmentAttr())
320 return 0;
321
322 return 1U << ((A.getRawStackAlignment() >> 26) - 1);
325323 }
326324
327325 /// This returns an integer containing an encoding of all the
451449 /// getParamAlignment - Return the alignment for the specified function
452450 /// parameter.
453451 unsigned getParamAlignment(unsigned Idx) const {
454 return getAttributes(Idx).getAlignment();
452 return Attribute::getAlignmentFromAttrs(getAttributes(Idx));
455453 }
456454
457455 /// hasAttrSomewhere - Return true if the specified attribute is set for at
27162716
27172717 // If the alignment was parsed as an attribute, move to the alignment field.
27182718 if (FuncAttrs & Attribute::Alignment) {
2719 Alignment = FuncAttrs.getAlignment();
2719 Alignment = Attribute::getAlignmentFromAttrs(FuncAttrs);
27202720 FuncAttrs &= ~Attribute::Alignment;
27212721 }
27222722
5959 MFInfo = 0;
6060 FrameInfo = new (Allocator) MachineFrameInfo(*TM.getFrameLowering());
6161 if (Fn->hasFnAttr(Attribute::StackAlignment))
62 FrameInfo->ensureMaxAlignment(Fn->getAttributes().
63 getFnAttributes().getStackAlignment());
62 FrameInfo->ensureMaxAlignment(Attribute::getStackAlignmentFromAttrs(
63 Fn->getAttributes().getFnAttributes()));
6464 ConstantPool = new (Allocator) MachineConstantPool(TM.getTargetData());
6565 Alignment = TM.getTargetLowering()->getMinFunctionAlignment();
6666 // FIXME: Shouldn't use pref alignment if explicit alignment is set on Fn.
507507 #undef HANDLE_ATTR
508508 if (attrs & Attribute::StackAlignment)
509509 Out << " | Attribute::constructStackAlignmentFromInt("
510 << attrs.getStackAlignment()
510 << Attribute::getStackAlignmentFromAttrs(attrs)
511511 << ")";
512512 attrs &= ~Attribute::StackAlignment;
513513 assert(attrs == 0 && "Unhandled attribute!");
7979 Result += "address_safety ";
8080 if (hasStackAlignmentAttr()) {
8181 Result += "alignstack(";
82 Result += utostr(getStackAlignment());
82 Result += utostr(Attribute::getStackAlignmentFromAttrs(*this));
8383 Result += ") ";
8484 }
8585 if (hasAlignmentAttr()) {
8686 Result += "align ";
87 Result += utostr(getAlignment());
87 Result += utostr(Attribute::getAlignmentFromAttrs(*this));
8888 Result += " ";
8989 }
9090 // Trim the trailing space.
173173
174174 #ifndef NDEBUG
175175 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
176 assert(Attrs[i].Attrs.hasAttributes() &&
176 assert(Attrs[i].Attrs != Attribute::None &&
177177 "Pointless attribute!");
178178 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
179179 "Misordered AttributesList!");
246246 /// returned. Attributes for the result are denoted with Idx = 0.
247247 /// Function notes are denoted with idx = ~0.
248248 Attributes AttrListPtr::getAttributes(unsigned Idx) const {
249 if (AttrList == 0) return Attributes();
249 if (AttrList == 0) return Attribute::None;
250250
251251 const SmallVector &Attrs = AttrList->Attrs;
252252 for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
253253 if (Attrs[i].Index == Idx)
254254 return Attrs[i].Attrs;
255
256 return Attributes();
255 return Attribute::None;
257256 }
258257
259258 /// hasAttrSomewhere - Return true if the specified attribute is set for at
274273 #ifndef NDEBUG
275274 // FIXME it is not obvious how this should work for alignment.
276275 // For now, say we can't change a known alignment.
277 unsigned OldAlign = OldAttrs.getAlignment();
278 unsigned NewAlign = Attrs.getAlignment();
276 unsigned OldAlign = Attribute::getAlignmentFromAttrs(OldAttrs);
277 unsigned NewAlign = Attribute::getAlignmentFromAttrs(Attrs);
279278 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
280279 "Attempt to change alignment!");
281280 #endif