blob: 6905e4df39c46a13735812426413e3824172855c [file] [log] [blame]
Devang Patel4c758ea2008-09-25 21:00:45 +00001//===-- Attributes.cpp - Implement AttributesList -------------------------===//
Chris Lattner3e13b8c2008-01-02 23:42:30 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Devang Patel4c758ea2008-09-25 21:00:45 +000010// This file implements the AttributesList class and Attribute utilities.
Chris Lattner3e13b8c2008-01-02 23:42:30 +000011//
12//===----------------------------------------------------------------------===//
13
Devang Patelba3fa6c2008-09-23 23:03:40 +000014#include "llvm/Attributes.h"
Bill Wendlinge38b8042012-09-26 21:07:29 +000015#include "LLVMContextImpl.h"
Chris Lattner8a923e72008-03-12 17:45:29 +000016#include "llvm/Type.h"
Dan Gohmanfc429612008-03-10 23:55:07 +000017#include "llvm/ADT/StringExtras.h"
Chris Lattner8a923e72008-03-12 17:45:29 +000018#include "llvm/ADT/FoldingSet.h"
Michael J. Spencer447762d2010-11-29 18:16:10 +000019#include "llvm/Support/Atomic.h"
20#include "llvm/Support/Mutex.h"
David Greenef7014732010-01-05 01:29:58 +000021#include "llvm/Support/Debug.h"
Chris Lattner3e13b8c2008-01-02 23:42:30 +000022#include "llvm/Support/ManagedStatic.h"
Benjamin Kramer1a25d732009-08-23 11:37:21 +000023#include "llvm/Support/raw_ostream.h"
Chris Lattner3e13b8c2008-01-02 23:42:30 +000024using namespace llvm;
25
Chris Lattner8a923e72008-03-12 17:45:29 +000026//===----------------------------------------------------------------------===//
Bill Wendling73ea2de2012-10-08 21:47:17 +000027// Attributes Implementation
Chris Lattner8a923e72008-03-12 17:45:29 +000028//===----------------------------------------------------------------------===//
Chris Lattnerd0e1f102008-01-03 00:10:22 +000029
Bill Wendling73ea2de2012-10-08 21:47:17 +000030Attributes::Attributes(uint64_t Val) : Attrs(Val) {}
31
32Attributes::Attributes(Attribute::AttrConst Val) : Attrs(Val.v) {}
33
34Attributes::Attributes(AttributesImpl *A) : Attrs(A->Bits) {}
35
Bill Wendlingc6daefa2012-10-08 23:27:46 +000036Attributes::Attributes(const Attributes &A) : Attrs(A.Attrs) {}
37
Bill Wendling68d24012012-10-08 22:20:14 +000038// FIXME: This is temporary until we have implemented the uniquified version of
39// AttributesImpl.
40Attributes Attributes::get(Attributes::Builder &B) {
41 return Attributes(B.Bits);
42}
43
Bill Wendling73ea2de2012-10-08 21:47:17 +000044Attributes Attributes::get(LLVMContext &Context, Attributes::Builder &B) {
45 // If there are no attributes, return an empty Attributes class.
46 if (B.Bits == 0)
47 return Attributes();
48
49 // Otherwise, build a key to look up the existing attributes.
50 LLVMContextImpl *pImpl = Context.pImpl;
51 FoldingSetNodeID ID;
52 ID.AddInteger(B.Bits);
53
54 void *InsertPoint;
55 AttributesImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
56
57 if (!PA) {
58 // If we didn't find any existing attributes of the same shape then create a
59 // new one and insert it.
60 PA = new AttributesImpl(B.Bits);
61 pImpl->AttrsSet.InsertNode(PA, InsertPoint);
62 }
63
64 // Return the AttributesList that we found or created.
65 return Attributes(PA);
66}
67
Bill Wendlingbe7c6f22012-10-07 08:55:05 +000068bool Attributes::hasAttributes(const Attributes &A) const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000069 return Attrs.hasAttributes(A);
Bill Wendlingbe7c6f22012-10-07 08:55:05 +000070}
Bill Wendlingabf3feb2012-10-05 06:44:41 +000071bool Attributes::hasAddressSafetyAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000072 return Attrs.hasAttribute(Attribute::AddressSafety_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000073}
74bool Attributes::hasAlignmentAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000075 return Attrs.hasAttribute(Attribute::Alignment_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000076}
77bool Attributes::hasAlwaysInlineAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000078 return Attrs.hasAttribute(Attribute::AlwaysInline_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000079}
80bool Attributes::hasByValAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000081 return Attrs.hasAttribute(Attribute::ByVal_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000082}
83bool Attributes::hasInlineHintAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000084 return Attrs.hasAttribute(Attribute::InlineHint_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000085}
86bool Attributes::hasInRegAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000087 return Attrs.hasAttribute(Attribute::InReg_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000088}
89bool Attributes::hasNakedAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000090 return Attrs.hasAttribute(Attribute::Naked_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000091}
92bool Attributes::hasNestAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000093 return Attrs.hasAttribute(Attribute::Nest_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000094}
95bool Attributes::hasNoAliasAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000096 return Attrs.hasAttribute(Attribute::NoAlias_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +000097}
98bool Attributes::hasNoCaptureAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +000099 return Attrs.hasAttribute(Attribute::NoCapture_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000100}
101bool Attributes::hasNoImplicitFloatAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000102 return Attrs.hasAttribute(Attribute::NoImplicitFloat_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000103}
104bool Attributes::hasNoInlineAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000105 return Attrs.hasAttribute(Attribute::NoInline_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000106}
107bool Attributes::hasNonLazyBindAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000108 return Attrs.hasAttribute(Attribute::NonLazyBind_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000109}
110bool Attributes::hasNoRedZoneAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000111 return Attrs.hasAttribute(Attribute::NoRedZone_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000112}
113bool Attributes::hasNoReturnAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000114 return Attrs.hasAttribute(Attribute::NoReturn_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000115}
116bool Attributes::hasNoUnwindAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000117 return Attrs.hasAttribute(Attribute::NoUnwind_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000118}
119bool Attributes::hasOptimizeForSizeAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000120 return Attrs.hasAttribute(Attribute::OptimizeForSize_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000121}
122bool Attributes::hasReadNoneAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000123 return Attrs.hasAttribute(Attribute::ReadNone_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000124}
125bool Attributes::hasReadOnlyAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000126 return Attrs.hasAttribute(Attribute::ReadOnly_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000127}
128bool Attributes::hasReturnsTwiceAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000129 return Attrs.hasAttribute(Attribute::ReturnsTwice_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000130}
131bool Attributes::hasSExtAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000132 return Attrs.hasAttribute(Attribute::SExt_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000133}
134bool Attributes::hasStackAlignmentAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000135 return Attrs.hasAttribute(Attribute::StackAlignment_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000136}
137bool Attributes::hasStackProtectAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000138 return Attrs.hasAttribute(Attribute::StackProtect_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000139}
140bool Attributes::hasStackProtectReqAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000141 return Attrs.hasAttribute(Attribute::StackProtectReq_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000142}
143bool Attributes::hasStructRetAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000144 return Attrs.hasAttribute(Attribute::StructRet_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000145}
146bool Attributes::hasUWTableAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000147 return Attrs.hasAttribute(Attribute::UWTable_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000148}
149bool Attributes::hasZExtAttr() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000150 return Attrs.hasAttribute(Attribute::ZExt_i);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000151}
152
153/// This returns the alignment field of an attribute as a byte alignment value.
154unsigned Attributes::getAlignment() const {
155 if (!hasAlignmentAttr())
156 return 0;
Bill Wendling73ea2de2012-10-08 21:47:17 +0000157 return 1U << ((Attrs.getAlignment() >> 16) - 1);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000158}
159
160/// This returns the stack alignment field of an attribute as a byte alignment
161/// value.
162unsigned Attributes::getStackAlignment() const {
163 if (!hasStackAlignmentAttr())
164 return 0;
Bill Wendling73ea2de2012-10-08 21:47:17 +0000165 return 1U << ((Attrs.getStackAlignment() >> 26) - 1);
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000166}
167
Bill Wendlingbe7c6f22012-10-07 08:55:05 +0000168bool Attributes::isEmptyOrSingleton() const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000169 return Attrs.isEmptyOrSingleton();
Bill Wendlingbe7c6f22012-10-07 08:55:05 +0000170}
171
Bill Wendling73ea2de2012-10-08 21:47:17 +0000172Attributes Attributes::operator | (const Attributes &A) const {
173 return Attributes(Raw() | A.Raw());
Bill Wendlingbe7c6f22012-10-07 08:55:05 +0000174}
Bill Wendling73ea2de2012-10-08 21:47:17 +0000175Attributes Attributes::operator & (const Attributes &A) const {
176 return Attributes(Raw() & A.Raw());
Bill Wendlingbe7c6f22012-10-07 08:55:05 +0000177}
Bill Wendling73ea2de2012-10-08 21:47:17 +0000178Attributes Attributes::operator ^ (const Attributes &A) const {
179 return Attributes(Raw() ^ A.Raw());
Bill Wendlingbe7c6f22012-10-07 08:55:05 +0000180}
Bill Wendling73ea2de2012-10-08 21:47:17 +0000181Attributes &Attributes::operator |= (const Attributes &A) {
182 Attrs.Bits |= A.Raw();
Bill Wendlingbe7c6f22012-10-07 08:55:05 +0000183 return *this;
184}
Bill Wendling73ea2de2012-10-08 21:47:17 +0000185Attributes &Attributes::operator &= (const Attributes &A) {
186 Attrs.Bits &= A.Raw();
Bill Wendlingbe7c6f22012-10-07 08:55:05 +0000187 return *this;
188}
189Attributes Attributes::operator ~ () const {
Bill Wendling73ea2de2012-10-08 21:47:17 +0000190 return Attributes(~Raw());
191}
192
193uint64_t Attributes::Raw() const {
194 return Attrs.Bits;
Bill Wendlingbe7c6f22012-10-07 08:55:05 +0000195}
196
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000197Attributes Attributes::typeIncompatible(Type *Ty) {
198 Attributes::Builder Incompatible;
199
200 if (!Ty->isIntegerTy()) {
201 // Attributes that only apply to integers.
202 Incompatible.addSExtAttr();
203 Incompatible.addZExtAttr();
204 }
205
206 if (!Ty->isPointerTy()) {
207 // Attributes that only apply to pointers.
208 Incompatible.addByValAttr();
209 Incompatible.addNestAttr();
210 Incompatible.addNoAliasAttr();
211 Incompatible.addNoCaptureAttr();
212 Incompatible.addStructRetAttr();
213 }
214
215 return Attributes(Incompatible.Bits); // FIXME: Use Attributes::get().
216}
217
Bill Wendlingde74cf52012-09-20 14:44:42 +0000218std::string Attributes::getAsString() const {
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000219 std::string Result;
Bill Wendlingde74cf52012-09-20 14:44:42 +0000220 if (hasZExtAttr())
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000221 Result += "zeroext ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000222 if (hasSExtAttr())
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000223 Result += "signext ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000224 if (hasNoReturnAttr())
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000225 Result += "noreturn ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000226 if (hasNoUnwindAttr())
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000227 Result += "nounwind ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000228 if (hasUWTableAttr())
Rafael Espindolafc9bae62011-05-25 03:44:17 +0000229 Result += "uwtable ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000230 if (hasReturnsTwiceAttr())
Rafael Espindolacc349c82011-10-03 14:45:37 +0000231 Result += "returns_twice ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000232 if (hasInRegAttr())
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000233 Result += "inreg ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000234 if (hasNoAliasAttr())
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000235 Result += "noalias ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000236 if (hasNoCaptureAttr())
Nick Lewycky8d69f482008-12-19 09:38:31 +0000237 Result += "nocapture ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000238 if (hasStructRetAttr())
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +0000239 Result += "sret ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000240 if (hasByValAttr())
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000241 Result += "byval ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000242 if (hasNestAttr())
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000243 Result += "nest ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000244 if (hasReadNoneAttr())
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000245 Result += "readnone ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000246 if (hasReadOnlyAttr())
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000247 Result += "readonly ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000248 if (hasOptimizeForSizeAttr())
Devang Patela05633e2008-09-26 22:53:05 +0000249 Result += "optsize ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000250 if (hasNoInlineAttr())
Devang Patela05633e2008-09-26 22:53:05 +0000251 Result += "noinline ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000252 if (hasInlineHintAttr())
Jakob Stoklund Olesen74bb06c2010-02-06 01:16:28 +0000253 Result += "inlinehint ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000254 if (hasAlwaysInlineAttr())
Devang Patela05633e2008-09-26 22:53:05 +0000255 Result += "alwaysinline ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000256 if (hasStackProtectAttr())
Bill Wendlingccb67a3d2008-11-13 01:02:14 +0000257 Result += "ssp ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000258 if (hasStackProtectReqAttr())
Bill Wendlingccb67a3d2008-11-13 01:02:14 +0000259 Result += "sspreq ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000260 if (hasNoRedZoneAttr())
Devang Patel72a4d2f2009-06-04 22:05:33 +0000261 Result += "noredzone ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000262 if (hasNoImplicitFloatAttr())
Devang Pateld1c7d342009-06-05 21:57:13 +0000263 Result += "noimplicitfloat ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000264 if (hasNakedAttr())
Anton Korobeynikovc8ce7b082009-07-17 18:07:26 +0000265 Result += "naked ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000266 if (hasNonLazyBindAttr())
John McCall4b7a8d62011-06-15 20:36:13 +0000267 Result += "nonlazybind ";
Bill Wendlingde74cf52012-09-20 14:44:42 +0000268 if (hasAddressSafetyAttr())
Kostya Serebryanya5054ad2012-01-20 17:56:17 +0000269 Result += "address_safety ";
Bill Wendlingb4e211c2012-09-20 15:20:36 +0000270 if (hasStackAlignmentAttr()) {
Charles Davisbe5557e2010-02-12 00:31:15 +0000271 Result += "alignstack(";
Bill Wendling9be77592012-09-21 15:26:31 +0000272 Result += utostr(getStackAlignment());
Charles Davisbe5557e2010-02-12 00:31:15 +0000273 Result += ") ";
274 }
Bill Wendlingb4e211c2012-09-20 15:20:36 +0000275 if (hasAlignmentAttr()) {
Dale Johannesen11a555e2008-02-19 23:51:49 +0000276 Result += "align ";
Bill Wendling9be77592012-09-21 15:26:31 +0000277 Result += utostr(getAlignment());
Dale Johannesen11a555e2008-02-19 23:51:49 +0000278 Result += " ";
279 }
Dan Gohman1a70bcc2008-08-05 15:51:44 +0000280 // Trim the trailing space.
Nick Lewycky8d69f482008-12-19 09:38:31 +0000281 assert(!Result.empty() && "Unknown attribute!");
Dan Gohman1a70bcc2008-08-05 15:51:44 +0000282 Result.erase(Result.end()-1);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000283 return Result;
284}
285
Bill Wendlingabf3feb2012-10-05 06:44:41 +0000286//===----------------------------------------------------------------------===//
287// Attributes::Builder Implementation
288//===----------------------------------------------------------------------===//
289
290void Attributes::Builder::addAddressSafetyAttr() {
291 Bits |= Attribute::AddressSafety_i;
292}
293void Attributes::Builder::addAlwaysInlineAttr() {
294 Bits |= Attribute::AlwaysInline_i;
295}
296void Attributes::Builder::addByValAttr() {
297 Bits |= Attribute::ByVal_i;
298}
299void Attributes::Builder::addInlineHintAttr() {
300 Bits |= Attribute::InlineHint_i;
301}
302void Attributes::Builder::addInRegAttr() {
303 Bits |= Attribute::InReg_i;
304}
305void Attributes::Builder::addNakedAttr() {
306 Bits |= Attribute::Naked_i;
307}
308void Attributes::Builder::addNestAttr() {
309 Bits |= Attribute::Nest_i;
310}
311void Attributes::Builder::addNoAliasAttr() {
312 Bits |= Attribute::NoAlias_i;
313}
314void Attributes::Builder::addNoCaptureAttr() {
315 Bits |= Attribute::NoCapture_i;
316}
317void Attributes::Builder::addNoImplicitFloatAttr() {
318 Bits |= Attribute::NoImplicitFloat_i;
319}
320void Attributes::Builder::addNoInlineAttr() {
321 Bits |= Attribute::NoInline_i;
322}
323void Attributes::Builder::addNonLazyBindAttr() {
324 Bits |= Attribute::NonLazyBind_i;
325}
326void Attributes::Builder::addNoRedZoneAttr() {
327 Bits |= Attribute::NoRedZone_i;
328}
329void Attributes::Builder::addNoReturnAttr() {
330 Bits |= Attribute::NoReturn_i;
331}
332void Attributes::Builder::addNoUnwindAttr() {
333 Bits |= Attribute::NoUnwind_i;
334}
335void Attributes::Builder::addOptimizeForSizeAttr() {
336 Bits |= Attribute::OptimizeForSize_i;
337}
338void Attributes::Builder::addReadNoneAttr() {
339 Bits |= Attribute::ReadNone_i;
340}
341void Attributes::Builder::addReadOnlyAttr() {
342 Bits |= Attribute::ReadOnly_i;
343}
344void Attributes::Builder::addReturnsTwiceAttr() {
345 Bits |= Attribute::ReturnsTwice_i;
346}
347void Attributes::Builder::addSExtAttr() {
348 Bits |= Attribute::SExt_i;
349}
350void Attributes::Builder::addStackProtectAttr() {
351 Bits |= Attribute::StackProtect_i;
352}
353void Attributes::Builder::addStackProtectReqAttr() {
354 Bits |= Attribute::StackProtectReq_i;
355}
356void Attributes::Builder::addStructRetAttr() {
357 Bits |= Attribute::StructRet_i;
358}
359void Attributes::Builder::addUWTableAttr() {
360 Bits |= Attribute::UWTable_i;
361}
362void Attributes::Builder::addZExtAttr() {
363 Bits |= Attribute::ZExt_i;
364}
365
366void Attributes::Builder::addAlignmentAttr(unsigned Align) {
367 if (Align == 0) return;
368 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
369 assert(Align <= 0x40000000 && "Alignment too large.");
370 Bits |= (Log2_32(Align) + 1) << 16;
371}
372void Attributes::Builder::addStackAlignmentAttr(unsigned Align) {
373 // Default alignment, allow the target to define how to align it.
374 if (Align == 0) return;
375 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
376 assert(Align <= 0x100 && "Alignment too large.");
377 Bits |= (Log2_32(Align) + 1) << 26;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000378}
379
Bill Wendling73ea2de2012-10-08 21:47:17 +0000380void Attributes::Builder::removeAddressSafetyAttr() {
381 Bits &= ~Attribute::AddressSafety_i;
382}
383void Attributes::Builder::removeAlwaysInlineAttr() {
384 Bits &= ~Attribute::AlwaysInline_i;
385}
386void Attributes::Builder::removeByValAttr() {
387 Bits &= ~Attribute::ByVal_i;
388}
389void Attributes::Builder::removeInlineHintAttr() {
390 Bits &= ~Attribute::InlineHint_i;
391}
392void Attributes::Builder::removeInRegAttr() {
393 Bits &= ~Attribute::InReg_i;
394}
395void Attributes::Builder::removeNakedAttr() {
396 Bits &= ~Attribute::Naked_i;
397}
398void Attributes::Builder::removeNestAttr() {
399 Bits &= ~Attribute::Nest_i;
400}
401void Attributes::Builder::removeNoAliasAttr() {
402 Bits &= ~Attribute::NoAlias_i;
403}
404void Attributes::Builder::removeNoCaptureAttr() {
405 Bits &= ~Attribute::NoCapture_i;
406}
407void Attributes::Builder::removeNoImplicitFloatAttr() {
408 Bits &= ~Attribute::NoImplicitFloat_i;
409}
410void Attributes::Builder::removeNoInlineAttr() {
411 Bits &= ~Attribute::NoInline_i;
412}
413void Attributes::Builder::removeNonLazyBindAttr() {
414 Bits &= ~Attribute::NonLazyBind_i;
415}
416void Attributes::Builder::removeNoRedZoneAttr() {
417 Bits &= ~Attribute::NoRedZone_i;
418}
419void Attributes::Builder::removeNoReturnAttr() {
420 Bits &= ~Attribute::NoReturn_i;
421}
422void Attributes::Builder::removeNoUnwindAttr() {
423 Bits &= ~Attribute::NoUnwind_i;
424}
425void Attributes::Builder::removeOptimizeForSizeAttr() {
426 Bits &= ~Attribute::OptimizeForSize_i;
427}
428void Attributes::Builder::removeReadNoneAttr() {
429 Bits &= ~Attribute::ReadNone_i;
430}
431void Attributes::Builder::removeReadOnlyAttr() {
432 Bits &= ~Attribute::ReadOnly_i;
433}
434void Attributes::Builder::removeReturnsTwiceAttr() {
435 Bits &= ~Attribute::ReturnsTwice_i;
436}
437void Attributes::Builder::removeSExtAttr() {
438 Bits &= ~Attribute::SExt_i;
439}
440void Attributes::Builder::removeStackProtectAttr() {
441 Bits &= ~Attribute::StackProtect_i;
442}
443void Attributes::Builder::removeStackProtectReqAttr() {
444 Bits &= ~Attribute::StackProtectReq_i;
445}
446void Attributes::Builder::removeStructRetAttr() {
447 Bits &= ~Attribute::StructRet_i;
448}
449void Attributes::Builder::removeUWTableAttr() {
450 Bits &= ~Attribute::UWTable_i;
451}
452void Attributes::Builder::removeZExtAttr() {
453 Bits &= ~Attribute::ZExt_i;
454}
455
Bill Wendlingc6daefa2012-10-08 23:27:46 +0000456void Attributes::Builder::removeAlignmentAttr() {
457 Bits &= ~Attribute::Alignment_i;
458}
459void Attributes::Builder::removeStackAlignmentAttr() {
460 Bits &= ~Attribute::StackAlignment_i;
461}
462
463bool Attributes::Builder::hasAttributes() const {
464 return Bits != 0;
465}
466bool Attributes::Builder::hasAlignmentAttr() const {
467 return Bits & Attribute::Alignment_i;
468}
469
470uint64_t Attributes::Builder::getAlignment() const {
471 if (!hasAlignmentAttr())
472 return 0;
473 return 1U << (((Bits & Attribute::Alignment_i) >> 16) - 1);
474}
475
Chris Lattner8a923e72008-03-12 17:45:29 +0000476//===----------------------------------------------------------------------===//
Bill Wendlinge38b8042012-09-26 21:07:29 +0000477// AttributeImpl Definition
478//===----------------------------------------------------------------------===//
479
Bill Wendling73ea2de2012-10-08 21:47:17 +0000480bool AttributesImpl::hasAttribute(uint64_t A) const {
481 return (Bits & A) != 0;
482}
Bill Wendlinge38b8042012-09-26 21:07:29 +0000483
Bill Wendling73ea2de2012-10-08 21:47:17 +0000484bool AttributesImpl::hasAttributes() const {
485 return Bits != 0;
486}
Bill Wendlinge38b8042012-09-26 21:07:29 +0000487
Bill Wendling73ea2de2012-10-08 21:47:17 +0000488bool AttributesImpl::hasAttributes(const Attributes &A) const {
489 return Bits & A.Raw(); // FIXME: Raw() won't work here in the future.
490}
Bill Wendlinge38b8042012-09-26 21:07:29 +0000491
Bill Wendling73ea2de2012-10-08 21:47:17 +0000492uint64_t AttributesImpl::getAlignment() const {
493 return Bits & Attribute::Alignment_i;
494}
Bill Wendlinge38b8042012-09-26 21:07:29 +0000495
Bill Wendling73ea2de2012-10-08 21:47:17 +0000496uint64_t AttributesImpl::getStackAlignment() const {
497 return Bits & Attribute::StackAlignment_i;
498}
Bill Wendlinge38b8042012-09-26 21:07:29 +0000499
Bill Wendling73ea2de2012-10-08 21:47:17 +0000500bool AttributesImpl::isEmptyOrSingleton() const {
501 return (Bits & (Bits - 1)) == 0;
Bill Wendlinge38b8042012-09-26 21:07:29 +0000502}
503
504//===----------------------------------------------------------------------===//
Devang Patel00095052008-09-24 00:29:49 +0000505// AttributeListImpl Definition
Chris Lattner8a923e72008-03-12 17:45:29 +0000506//===----------------------------------------------------------------------===//
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000507
Owen Anderson2e831892010-11-18 18:59:13 +0000508namespace llvm {
509 class AttributeListImpl;
510}
511
512static ManagedStatic<FoldingSet<AttributeListImpl> > AttributesLists;
Owen Anderson9b14a252010-11-09 00:27:03 +0000513
Chris Lattner8a923e72008-03-12 17:45:29 +0000514namespace llvm {
Owen Anderson9b14a252010-11-09 00:27:03 +0000515static ManagedStatic<sys::SmartMutex<true> > ALMutex;
516
Devang Patel00095052008-09-24 00:29:49 +0000517class AttributeListImpl : public FoldingSetNode {
Owen Andersonc1a3a472009-08-20 19:03:20 +0000518 sys::cas_flag RefCount;
Chris Lattner8a923e72008-03-12 17:45:29 +0000519
Devang Patel4c758ea2008-09-25 21:00:45 +0000520 // AttributesList is uniqued, these should not be publicly available.
Craig Topperb1d83e82012-09-18 02:01:41 +0000521 void operator=(const AttributeListImpl &) LLVM_DELETED_FUNCTION;
522 AttributeListImpl(const AttributeListImpl &) LLVM_DELETED_FUNCTION;
Devang Patel00095052008-09-24 00:29:49 +0000523 ~AttributeListImpl(); // Private implementation
Chris Lattner8a923e72008-03-12 17:45:29 +0000524public:
Devang Patel4c758ea2008-09-25 21:00:45 +0000525 SmallVector<AttributeWithIndex, 4> Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000526
Chris Lattner3cb6f832012-05-28 01:47:44 +0000527 AttributeListImpl(ArrayRef<AttributeWithIndex> attrs)
528 : Attrs(attrs.begin(), attrs.end()) {
Chris Lattner8a923e72008-03-12 17:45:29 +0000529 RefCount = 0;
530 }
531
Owen Anderson9b14a252010-11-09 00:27:03 +0000532 void AddRef() {
533 sys::SmartScopedLock<true> Lock(*ALMutex);
534 ++RefCount;
535 }
Owen Andersonc1a3a472009-08-20 19:03:20 +0000536 void DropRef() {
Owen Anderson9b14a252010-11-09 00:27:03 +0000537 sys::SmartScopedLock<true> Lock(*ALMutex);
Owen Anderson2e831892010-11-18 18:59:13 +0000538 if (!AttributesLists.isConstructed())
539 return;
Owen Anderson91bfeb12010-11-09 17:47:10 +0000540 sys::cas_flag new_val = --RefCount;
Owen Anderson2d335432010-11-09 17:46:38 +0000541 if (new_val == 0)
Owen Anderson9b14a252010-11-09 00:27:03 +0000542 delete this;
Owen Andersonc1a3a472009-08-20 19:03:20 +0000543 }
Chris Lattner8a923e72008-03-12 17:45:29 +0000544
545 void Profile(FoldingSetNodeID &ID) const {
Chris Lattner3cb6f832012-05-28 01:47:44 +0000546 Profile(ID, Attrs);
Chris Lattner8a923e72008-03-12 17:45:29 +0000547 }
Chris Lattner3cb6f832012-05-28 01:47:44 +0000548 static void Profile(FoldingSetNodeID &ID, ArrayRef<AttributeWithIndex> Attrs){
549 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
550 ID.AddInteger(Attrs[i].Attrs.Raw());
551 ID.AddInteger(Attrs[i].Index);
Kostya Serebryanya5054ad2012-01-20 17:56:17 +0000552 }
Chris Lattner8a923e72008-03-12 17:45:29 +0000553 }
554};
555}
556
Devang Patel00095052008-09-24 00:29:49 +0000557AttributeListImpl::~AttributeListImpl() {
Owen Anderson9b14a252010-11-09 00:27:03 +0000558 // NOTE: Lock must be acquired by caller.
Devang Patel4c758ea2008-09-25 21:00:45 +0000559 AttributesLists->RemoveNode(this);
Chris Lattner8a923e72008-03-12 17:45:29 +0000560}
561
562
Chris Lattner3cb6f832012-05-28 01:47:44 +0000563AttrListPtr AttrListPtr::get(ArrayRef<AttributeWithIndex> Attrs) {
Devang Patel4c758ea2008-09-25 21:00:45 +0000564 // If there are no attributes then return a null AttributesList pointer.
Chris Lattner3cb6f832012-05-28 01:47:44 +0000565 if (Attrs.empty())
Devang Patel4c758ea2008-09-25 21:00:45 +0000566 return AttrListPtr();
Chris Lattner8a923e72008-03-12 17:45:29 +0000567
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000568#ifndef NDEBUG
Chris Lattner3cb6f832012-05-28 01:47:44 +0000569 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
Bill Wendling9be77592012-09-21 15:26:31 +0000570 assert(Attrs[i].Attrs.hasAttributes() &&
Devang Patel4c758ea2008-09-25 21:00:45 +0000571 "Pointless attribute!");
Chris Lattner8a923e72008-03-12 17:45:29 +0000572 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
Devang Patel4c758ea2008-09-25 21:00:45 +0000573 "Misordered AttributesList!");
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000574 }
575#endif
Chris Lattner8a923e72008-03-12 17:45:29 +0000576
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000577 // Otherwise, build a key to look up the existing attributes.
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000578 FoldingSetNodeID ID;
Chris Lattner3cb6f832012-05-28 01:47:44 +0000579 AttributeListImpl::Profile(ID, Attrs);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000580 void *InsertPos;
Owen Andersond91e6b02009-08-17 17:10:58 +0000581
582 sys::SmartScopedLock<true> Lock(*ALMutex);
583
Devang Patel00095052008-09-24 00:29:49 +0000584 AttributeListImpl *PAL =
Devang Patel4c758ea2008-09-25 21:00:45 +0000585 AttributesLists->FindNodeOrInsertPos(ID, InsertPos);
Chris Lattner8a923e72008-03-12 17:45:29 +0000586
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000587 // If we didn't find any existing attributes of the same shape then
588 // create a new one and insert it.
589 if (!PAL) {
Chris Lattner3cb6f832012-05-28 01:47:44 +0000590 PAL = new AttributeListImpl(Attrs);
Devang Patel4c758ea2008-09-25 21:00:45 +0000591 AttributesLists->InsertNode(PAL, InsertPos);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000592 }
Chris Lattner8a923e72008-03-12 17:45:29 +0000593
Devang Patel4c758ea2008-09-25 21:00:45 +0000594 // Return the AttributesList that we found or created.
595 return AttrListPtr(PAL);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000596}
597
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000598
Chris Lattner8a923e72008-03-12 17:45:29 +0000599//===----------------------------------------------------------------------===//
Devang Patel4c758ea2008-09-25 21:00:45 +0000600// AttrListPtr Method Implementations
Chris Lattner8a923e72008-03-12 17:45:29 +0000601//===----------------------------------------------------------------------===//
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000602
Devang Patel4c758ea2008-09-25 21:00:45 +0000603AttrListPtr::AttrListPtr(AttributeListImpl *LI) : AttrList(LI) {
Chris Lattner8a923e72008-03-12 17:45:29 +0000604 if (LI) LI->AddRef();
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000605}
606
Devang Patel4c758ea2008-09-25 21:00:45 +0000607AttrListPtr::AttrListPtr(const AttrListPtr &P) : AttrList(P.AttrList) {
608 if (AttrList) AttrList->AddRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000609}
610
Devang Patel4c758ea2008-09-25 21:00:45 +0000611const AttrListPtr &AttrListPtr::operator=(const AttrListPtr &RHS) {
Owen Anderson8dc0b042010-09-16 00:27:35 +0000612 sys::SmartScopedLock<true> Lock(*ALMutex);
Devang Patel4c758ea2008-09-25 21:00:45 +0000613 if (AttrList == RHS.AttrList) return *this;
614 if (AttrList) AttrList->DropRef();
615 AttrList = RHS.AttrList;
616 if (AttrList) AttrList->AddRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000617 return *this;
618}
619
Devang Patel4c758ea2008-09-25 21:00:45 +0000620AttrListPtr::~AttrListPtr() {
621 if (AttrList) AttrList->DropRef();
Chris Lattner8a923e72008-03-12 17:45:29 +0000622}
623
624/// getNumSlots - Return the number of slots used in this attribute list.
625/// This is the number of arguments that have an attribute set on them
626/// (including the function itself).
Devang Patel4c758ea2008-09-25 21:00:45 +0000627unsigned AttrListPtr::getNumSlots() const {
628 return AttrList ? AttrList->Attrs.size() : 0;
Chris Lattner8a923e72008-03-12 17:45:29 +0000629}
630
Devang Patel4c758ea2008-09-25 21:00:45 +0000631/// getSlot - Return the AttributeWithIndex at the specified slot. This
632/// holds a number plus a set of attributes.
633const AttributeWithIndex &AttrListPtr::getSlot(unsigned Slot) const {
634 assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!");
635 return AttrList->Attrs[Slot];
Chris Lattner8a923e72008-03-12 17:45:29 +0000636}
637
638
Devang Patel4c758ea2008-09-25 21:00:45 +0000639/// getAttributes - The attributes for the specified index are
640/// returned. Attributes for the result are denoted with Idx = 0.
Devang Patel82fed672008-09-23 22:35:17 +0000641/// Function notes are denoted with idx = ~0.
Devang Patel4c758ea2008-09-25 21:00:45 +0000642Attributes AttrListPtr::getAttributes(unsigned Idx) const {
Bill Wendling9be77592012-09-21 15:26:31 +0000643 if (AttrList == 0) return Attributes();
Chris Lattner8a923e72008-03-12 17:45:29 +0000644
Devang Patel4c758ea2008-09-25 21:00:45 +0000645 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000646 for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
647 if (Attrs[i].Index == Idx)
648 return Attrs[i].Attrs;
Bill Wendling9be77592012-09-21 15:26:31 +0000649
650 return Attributes();
Chris Lattner8a923e72008-03-12 17:45:29 +0000651}
652
653/// hasAttrSomewhere - Return true if the specified attribute is set for at
654/// least one parameter or for the return value.
Devang Patel4c758ea2008-09-25 21:00:45 +0000655bool AttrListPtr::hasAttrSomewhere(Attributes Attr) const {
656 if (AttrList == 0) return false;
Chris Lattner8a923e72008-03-12 17:45:29 +0000657
Devang Patel4c758ea2008-09-25 21:00:45 +0000658 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000659 for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
Bill Wendlingb4e211c2012-09-20 15:20:36 +0000660 if (Attrs[i].Attrs.hasAttributes(Attr))
Chris Lattner8a923e72008-03-12 17:45:29 +0000661 return true;
662 return false;
663}
664
665
Devang Patel4c758ea2008-09-25 21:00:45 +0000666AttrListPtr AttrListPtr::addAttr(unsigned Idx, Attributes Attrs) const {
667 Attributes OldAttrs = getAttributes(Idx);
Dale Johannesen11a555e2008-02-19 23:51:49 +0000668#ifndef NDEBUG
669 // FIXME it is not obvious how this should work for alignment.
670 // For now, say we can't change a known alignment.
Bill Wendling9be77592012-09-21 15:26:31 +0000671 unsigned OldAlign = OldAttrs.getAlignment();
672 unsigned NewAlign = Attrs.getAlignment();
Anton Korobeynikov18991d72008-02-20 12:07:57 +0000673 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
Dale Johannesen11a555e2008-02-19 23:51:49 +0000674 "Attempt to change alignment!");
675#endif
Chris Lattner8a923e72008-03-12 17:45:29 +0000676
Devang Patelba3fa6c2008-09-23 23:03:40 +0000677 Attributes NewAttrs = OldAttrs | Attrs;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000678 if (NewAttrs == OldAttrs)
Chris Lattner8a923e72008-03-12 17:45:29 +0000679 return *this;
680
Devang Patel4c758ea2008-09-25 21:00:45 +0000681 SmallVector<AttributeWithIndex, 8> NewAttrList;
682 if (AttrList == 0)
683 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000684 else {
Devang Patel4c758ea2008-09-25 21:00:45 +0000685 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000686 unsigned i = 0, e = OldAttrList.size();
687 // Copy attributes for arguments before this one.
688 for (; i != e && OldAttrList[i].Index < Idx; ++i)
689 NewAttrList.push_back(OldAttrList[i]);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000690
Chris Lattner8a923e72008-03-12 17:45:29 +0000691 // If there are attributes already at this index, merge them in.
692 if (i != e && OldAttrList[i].Index == Idx) {
693 Attrs |= OldAttrList[i].Attrs;
694 ++i;
695 }
696
Devang Patel4c758ea2008-09-25 21:00:45 +0000697 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000698
699 // Copy attributes for arguments after this one.
700 NewAttrList.insert(NewAttrList.end(),
701 OldAttrList.begin()+i, OldAttrList.end());
702 }
703
Chris Lattner3cb6f832012-05-28 01:47:44 +0000704 return get(NewAttrList);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000705}
706
Devang Patel4c758ea2008-09-25 21:00:45 +0000707AttrListPtr AttrListPtr::removeAttr(unsigned Idx, Attributes Attrs) const {
Dale Johannesen11a555e2008-02-19 23:51:49 +0000708#ifndef NDEBUG
709 // FIXME it is not obvious how this should work for alignment.
710 // For now, say we can't pass in alignment, which no current use does.
Bill Wendlingb4e211c2012-09-20 15:20:36 +0000711 assert(!Attrs.hasAlignmentAttr() && "Attempt to exclude alignment!");
Dale Johannesen11a555e2008-02-19 23:51:49 +0000712#endif
Devang Patel4c758ea2008-09-25 21:00:45 +0000713 if (AttrList == 0) return AttrListPtr();
Chris Lattner8a923e72008-03-12 17:45:29 +0000714
Devang Patel4c758ea2008-09-25 21:00:45 +0000715 Attributes OldAttrs = getAttributes(Idx);
Devang Patelba3fa6c2008-09-23 23:03:40 +0000716 Attributes NewAttrs = OldAttrs & ~Attrs;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000717 if (NewAttrs == OldAttrs)
Chris Lattner8a923e72008-03-12 17:45:29 +0000718 return *this;
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000719
Devang Patel4c758ea2008-09-25 21:00:45 +0000720 SmallVector<AttributeWithIndex, 8> NewAttrList;
721 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner8a923e72008-03-12 17:45:29 +0000722 unsigned i = 0, e = OldAttrList.size();
723
724 // Copy attributes for arguments before this one.
725 for (; i != e && OldAttrList[i].Index < Idx; ++i)
726 NewAttrList.push_back(OldAttrList[i]);
727
728 // If there are attributes already at this index, merge them in.
729 assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
730 Attrs = OldAttrList[i].Attrs & ~Attrs;
731 ++i;
732 if (Attrs) // If any attributes left for this parameter, add them.
Devang Patel4c758ea2008-09-25 21:00:45 +0000733 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner8a923e72008-03-12 17:45:29 +0000734
735 // Copy attributes for arguments after this one.
736 NewAttrList.insert(NewAttrList.end(),
737 OldAttrList.begin()+i, OldAttrList.end());
738
Chris Lattner3cb6f832012-05-28 01:47:44 +0000739 return get(NewAttrList);
Chris Lattner3e13b8c2008-01-02 23:42:30 +0000740}
741
Devang Patel4c758ea2008-09-25 21:00:45 +0000742void AttrListPtr::dump() const {
David Greenef7014732010-01-05 01:29:58 +0000743 dbgs() << "PAL[ ";
Chris Lattner8a923e72008-03-12 17:45:29 +0000744 for (unsigned i = 0; i < getNumSlots(); ++i) {
Devang Patel4c758ea2008-09-25 21:00:45 +0000745 const AttributeWithIndex &PAWI = getSlot(i);
David Greenef7014732010-01-05 01:29:58 +0000746 dbgs() << "{" << PAWI.Index << "," << PAWI.Attrs << "} ";
Chris Lattner8a923e72008-03-12 17:45:29 +0000747 }
748
David Greenef7014732010-01-05 01:29:58 +0000749 dbgs() << "]\n";
Duncan Sands404eb052008-01-06 18:27:01 +0000750}