Bill Wendling | 87e10df | 2013-01-28 21:55:20 +0000 | [diff] [blame] | 1 | //===-- Attributes.cpp - Implement AttributesList -------------------------===// |
Chris Lattner | 50ee9dd | 2008-01-02 23:42:30 +0000 | [diff] [blame] | 2 | // |
| 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 | // |
Bill Wendling | 87e10df | 2013-01-28 21:55:20 +0000 | [diff] [blame] | 10 | // \file |
| 11 | // \brief This file implements the Attribute, AttributeImpl, AttrBuilder, |
Bill Wendling | 18e7211 | 2012-12-19 22:42:22 +0000 | [diff] [blame] | 12 | // AttributeSetImpl, and AttributeSet classes. |
Chris Lattner | 50ee9dd | 2008-01-02 23:42:30 +0000 | [diff] [blame] | 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Chandler Carruth | 0b8c9a8 | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 16 | #include "llvm/IR/Attributes.h" |
Bill Wendling | f667072 | 2012-12-20 01:36:59 +0000 | [diff] [blame] | 17 | #include "AttributeImpl.h" |
Bill Wendling | 2c79ecb | 2012-09-26 21:07:29 +0000 | [diff] [blame] | 18 | #include "LLVMContextImpl.h" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/StringExtras.h" |
Chandler Carruth | 0b8c9a8 | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 20 | #include "llvm/IR/Type.h" |
Michael J. Spencer | 1f6efa3 | 2010-11-29 18:16:10 +0000 | [diff] [blame] | 21 | #include "llvm/Support/Atomic.h" |
David Greene | ef1894e | 2010-01-05 01:29:58 +0000 | [diff] [blame] | 22 | #include "llvm/Support/Debug.h" |
Chris Lattner | 50ee9dd | 2008-01-02 23:42:30 +0000 | [diff] [blame] | 23 | #include "llvm/Support/ManagedStatic.h" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 24 | #include "llvm/Support/Mutex.h" |
Benjamin Kramer | cfa6ec9 | 2009-08-23 11:37:21 +0000 | [diff] [blame] | 25 | #include "llvm/Support/raw_ostream.h" |
Bill Wendling | 3467e30 | 2013-01-24 00:06:56 +0000 | [diff] [blame] | 26 | #include <algorithm> |
Chris Lattner | 50ee9dd | 2008-01-02 23:42:30 +0000 | [diff] [blame] | 27 | using namespace llvm; |
| 28 | |
Chris Lattner | 58d7491 | 2008-03-12 17:45:29 +0000 | [diff] [blame] | 29 | //===----------------------------------------------------------------------===// |
Bill Wendling | 817abdd | 2013-01-29 00:48:16 +0000 | [diff] [blame] | 30 | // Attribute Construction Methods |
Chris Lattner | 58d7491 | 2008-03-12 17:45:29 +0000 | [diff] [blame] | 31 | //===----------------------------------------------------------------------===// |
Chris Lattner | fabfde3 | 2008-01-03 00:10:22 +0000 | [diff] [blame] | 32 | |
Bill Wendling | 6bdbf06 | 2013-01-28 22:33:39 +0000 | [diff] [blame] | 33 | Attribute Attribute::get(LLVMContext &Context, AttrKind Kind) { |
Bill Wendling | 16f9566 | 2013-01-27 10:28:39 +0000 | [diff] [blame] | 34 | AttrBuilder B; |
Bill Wendling | 6bdbf06 | 2013-01-28 22:33:39 +0000 | [diff] [blame] | 35 | return Attribute::get(Context, B.addAttribute(Kind)); |
Bill Wendling | cb3de0b | 2012-10-15 04:46:55 +0000 | [diff] [blame] | 36 | } |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 37 | |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 38 | Attribute Attribute::get(LLVMContext &Context, AttrBuilder &B) { |
| 39 | // If there are no attributes, return an empty Attribute class. |
Bill Wendling | a5c699d | 2012-10-16 05:55:09 +0000 | [diff] [blame] | 40 | if (!B.hasAttributes()) |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 41 | return Attribute(); |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 42 | |
| 43 | // Otherwise, build a key to look up the existing attributes. |
| 44 | LLVMContextImpl *pImpl = Context.pImpl; |
| 45 | FoldingSetNodeID ID; |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 46 | ConstantInt *CI = ConstantInt::get(Type::getInt64Ty(Context), B.Raw()); |
| 47 | ID.AddPointer(CI); |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 48 | |
| 49 | void *InsertPoint; |
Bill Wendling | f667072 | 2012-12-20 01:36:59 +0000 | [diff] [blame] | 50 | AttributeImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint); |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 51 | |
| 52 | if (!PA) { |
| 53 | // If we didn't find any existing attributes of the same shape then create a |
| 54 | // new one and insert it. |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 55 | PA = new AttributeImpl(Context, CI); |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 56 | pImpl->AttrsSet.InsertNode(PA, InsertPoint); |
| 57 | } |
| 58 | |
| 59 | // Return the AttributesList that we found or created. |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 60 | return Attribute(PA); |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Bill Wendling | c08a5ef | 2013-01-27 22:43:04 +0000 | [diff] [blame] | 63 | Attribute Attribute::getWithAlignment(LLVMContext &Context, uint64_t Align) { |
| 64 | AttrBuilder B; |
| 65 | return get(Context, B.addAlignmentAttr(Align)); |
| 66 | } |
| 67 | |
| 68 | Attribute Attribute::getWithStackAlignment(LLVMContext &Context, |
| 69 | uint64_t Align) { |
| 70 | AttrBuilder B; |
| 71 | return get(Context, B.addStackAlignmentAttr(Align)); |
| 72 | } |
| 73 | |
Bill Wendling | 817abdd | 2013-01-29 00:48:16 +0000 | [diff] [blame] | 74 | //===----------------------------------------------------------------------===// |
| 75 | // Attribute Accessor Methods |
| 76 | //===----------------------------------------------------------------------===// |
| 77 | |
Bill Wendling | 629fb82 | 2012-12-22 00:37:52 +0000 | [diff] [blame] | 78 | bool Attribute::hasAttribute(AttrKind Val) const { |
Bill Wendling | 27107f6 | 2012-12-20 21:28:43 +0000 | [diff] [blame] | 79 | return pImpl && pImpl->hasAttribute(Val); |
Bill Wendling | e66f3d3 | 2012-10-05 06:44:41 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 82 | bool Attribute::hasAttributes() const { |
Bill Wendling | 27107f6 | 2012-12-20 21:28:43 +0000 | [diff] [blame] | 83 | return pImpl && pImpl->hasAttributes(); |
Bill Wendling | 05cc40d | 2012-10-15 05:40:12 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Bill Wendling | e66f3d3 | 2012-10-05 06:44:41 +0000 | [diff] [blame] | 86 | /// This returns the alignment field of an attribute as a byte alignment value. |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 87 | unsigned Attribute::getAlignment() const { |
| 88 | if (!hasAttribute(Attribute::Alignment)) |
Bill Wendling | 9ef99c9 | 2012-10-09 20:56:48 +0000 | [diff] [blame] | 89 | return 0; |
Bill Wendling | a8ab5fc | 2013-01-23 23:00:05 +0000 | [diff] [blame] | 90 | return pImpl->getAlignment(); |
Bill Wendling | e66f3d3 | 2012-10-05 06:44:41 +0000 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | /// This returns the stack alignment field of an attribute as a byte alignment |
| 94 | /// value. |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 95 | unsigned Attribute::getStackAlignment() const { |
| 96 | if (!hasAttribute(Attribute::StackAlignment)) |
Bill Wendling | 9ef99c9 | 2012-10-09 20:56:48 +0000 | [diff] [blame] | 97 | return 0; |
Bill Wendling | a8ab5fc | 2013-01-23 23:00:05 +0000 | [diff] [blame] | 98 | return pImpl->getStackAlignment(); |
Bill Wendling | e66f3d3 | 2012-10-05 06:44:41 +0000 | [diff] [blame] | 99 | } |
| 100 | |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 101 | std::string Attribute::getAsString() const { |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 102 | if (hasAttribute(Attribute::ZExt)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 103 | return "zeroext"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 104 | if (hasAttribute(Attribute::SExt)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 105 | return "signext"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 106 | if (hasAttribute(Attribute::NoReturn)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 107 | return "noreturn"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 108 | if (hasAttribute(Attribute::NoUnwind)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 109 | return "nounwind"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 110 | if (hasAttribute(Attribute::UWTable)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 111 | return "uwtable"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 112 | if (hasAttribute(Attribute::ReturnsTwice)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 113 | return "returns_twice"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 114 | if (hasAttribute(Attribute::InReg)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 115 | return "inreg"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 116 | if (hasAttribute(Attribute::NoAlias)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 117 | return "noalias"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 118 | if (hasAttribute(Attribute::NoCapture)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 119 | return "nocapture"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 120 | if (hasAttribute(Attribute::StructRet)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 121 | return "sret"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 122 | if (hasAttribute(Attribute::ByVal)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 123 | return "byval"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 124 | if (hasAttribute(Attribute::Nest)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 125 | return "nest"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 126 | if (hasAttribute(Attribute::ReadNone)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 127 | return "readnone"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 128 | if (hasAttribute(Attribute::ReadOnly)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 129 | return "readonly"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 130 | if (hasAttribute(Attribute::OptimizeForSize)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 131 | return "optsize"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 132 | if (hasAttribute(Attribute::NoInline)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 133 | return "noinline"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 134 | if (hasAttribute(Attribute::InlineHint)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 135 | return "inlinehint"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 136 | if (hasAttribute(Attribute::AlwaysInline)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 137 | return "alwaysinline"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 138 | if (hasAttribute(Attribute::StackProtect)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 139 | return "ssp"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 140 | if (hasAttribute(Attribute::StackProtectReq)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 141 | return "sspreq"; |
Bill Wendling | 114baee | 2013-01-23 06:41:41 +0000 | [diff] [blame] | 142 | if (hasAttribute(Attribute::StackProtectStrong)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 143 | return "sspstrong"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 144 | if (hasAttribute(Attribute::NoRedZone)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 145 | return "noredzone"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 146 | if (hasAttribute(Attribute::NoImplicitFloat)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 147 | return "noimplicitfloat"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 148 | if (hasAttribute(Attribute::Naked)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 149 | return "naked"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 150 | if (hasAttribute(Attribute::NonLazyBind)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 151 | return "nonlazybind"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 152 | if (hasAttribute(Attribute::AddressSafety)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 153 | return "address_safety"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 154 | if (hasAttribute(Attribute::MinSize)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 155 | return "minsize"; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 156 | if (hasAttribute(Attribute::StackAlignment)) { |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 157 | std::string Result; |
Charles Davis | 1e063d1 | 2010-02-12 00:31:15 +0000 | [diff] [blame] | 158 | Result += "alignstack("; |
Bill Wendling | ef99fe8 | 2012-09-21 15:26:31 +0000 | [diff] [blame] | 159 | Result += utostr(getStackAlignment()); |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 160 | Result += ")"; |
| 161 | return Result; |
Charles Davis | 1e063d1 | 2010-02-12 00:31:15 +0000 | [diff] [blame] | 162 | } |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 163 | if (hasAttribute(Attribute::Alignment)) { |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 164 | std::string Result; |
Dale Johannesen | 6167c3f | 2008-02-19 23:51:49 +0000 | [diff] [blame] | 165 | Result += "align "; |
Bill Wendling | ef99fe8 | 2012-09-21 15:26:31 +0000 | [diff] [blame] | 166 | Result += utostr(getAlignment()); |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 167 | Result += ""; |
| 168 | return Result; |
Dale Johannesen | 6167c3f | 2008-02-19 23:51:49 +0000 | [diff] [blame] | 169 | } |
James Molloy | 67ae135 | 2012-12-20 16:04:27 +0000 | [diff] [blame] | 170 | if (hasAttribute(Attribute::NoDuplicate)) |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 171 | return "noduplicate"; |
| 172 | |
| 173 | llvm_unreachable("Unknown attribute"); |
Chris Lattner | 50ee9dd | 2008-01-02 23:42:30 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 176 | bool Attribute::operator==(AttrKind K) const { |
| 177 | return pImpl && *pImpl == K; |
| 178 | } |
| 179 | bool Attribute::operator!=(AttrKind K) const { |
| 180 | return !(*this == K); |
| 181 | } |
| 182 | |
| 183 | bool Attribute::operator<(Attribute A) const { |
| 184 | if (!pImpl && !A.pImpl) return false; |
| 185 | if (!pImpl) return true; |
| 186 | if (!A.pImpl) return false; |
| 187 | return *pImpl < *A.pImpl; |
| 188 | } |
| 189 | |
| 190 | uint64_t Attribute::Raw() const { |
| 191 | return pImpl ? pImpl->Raw() : 0; |
| 192 | } |
| 193 | |
| 194 | //===----------------------------------------------------------------------===// |
| 195 | // AttributeImpl Definition |
| 196 | //===----------------------------------------------------------------------===// |
| 197 | |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 198 | AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind kind) |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 199 | : Context(C) { |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 200 | Kind = ConstantInt::get(Type::getInt64Ty(C), kind); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 201 | } |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 202 | AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind kind, |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 203 | ArrayRef<Constant*> values) |
| 204 | : Context(C) { |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 205 | Kind = ConstantInt::get(Type::getInt64Ty(C), kind); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 206 | Vals.reserve(values.size()); |
| 207 | Vals.append(values.begin(), values.end()); |
| 208 | } |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 209 | AttributeImpl::AttributeImpl(LLVMContext &C, StringRef kind) |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 210 | : Context(C) { |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 211 | Kind = ConstantDataArray::getString(C, kind); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const { |
| 215 | return (Raw() & getAttrMask(A)) != 0; |
| 216 | } |
| 217 | |
| 218 | bool AttributeImpl::hasAttributes() const { |
| 219 | return Raw() != 0; |
| 220 | } |
| 221 | |
| 222 | uint64_t AttributeImpl::getAlignment() const { |
| 223 | uint64_t Mask = Raw() & getAttrMask(Attribute::Alignment); |
| 224 | return 1ULL << ((Mask >> 16) - 1); |
| 225 | } |
| 226 | |
| 227 | uint64_t AttributeImpl::getStackAlignment() const { |
| 228 | uint64_t Mask = Raw() & getAttrMask(Attribute::StackAlignment); |
| 229 | return 1ULL << ((Mask >> 26) - 1); |
| 230 | } |
| 231 | |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 232 | bool AttributeImpl::operator==(Attribute::AttrKind kind) const { |
| 233 | if (ConstantInt *CI = dyn_cast<ConstantInt>(Kind)) |
| 234 | return CI->getZExtValue() == kind; |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 235 | return false; |
| 236 | } |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 237 | bool AttributeImpl::operator!=(Attribute::AttrKind kind) const { |
| 238 | return !(*this == kind); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 239 | } |
| 240 | |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 241 | bool AttributeImpl::operator==(StringRef kind) const { |
| 242 | if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Kind)) |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 243 | if (CDA->isString()) |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 244 | return CDA->getAsString() == kind; |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 245 | return false; |
| 246 | } |
| 247 | |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 248 | bool AttributeImpl::operator!=(StringRef kind) const { |
| 249 | return !(*this == kind); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | bool AttributeImpl::operator<(const AttributeImpl &AI) const { |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 253 | if (!Kind && !AI.Kind) return false; |
| 254 | if (!Kind && AI.Kind) return true; |
| 255 | if (Kind && !AI.Kind) return false; |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 256 | |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 257 | ConstantInt *ThisCI = dyn_cast<ConstantInt>(Kind); |
| 258 | ConstantInt *ThatCI = dyn_cast<ConstantInt>(AI.Kind); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 259 | |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 260 | ConstantDataArray *ThisCDA = dyn_cast<ConstantDataArray>(Kind); |
| 261 | ConstantDataArray *ThatCDA = dyn_cast<ConstantDataArray>(AI.Kind); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 262 | |
| 263 | if (ThisCI && ThatCI) |
| 264 | return ThisCI->getZExtValue() < ThatCI->getZExtValue(); |
| 265 | |
| 266 | if (ThisCI && ThatCDA) |
| 267 | return true; |
| 268 | |
| 269 | if (ThisCDA && ThatCI) |
| 270 | return false; |
| 271 | |
| 272 | return ThisCDA->getAsString() < ThatCDA->getAsString(); |
| 273 | } |
| 274 | |
| 275 | uint64_t AttributeImpl::Raw() const { |
| 276 | // FIXME: Remove this. |
Bill Wendling | 9f175f8 | 2013-01-29 20:37:10 +0000 | [diff] [blame^] | 277 | return cast<ConstantInt>(Kind)->getZExtValue(); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) { |
| 281 | // FIXME: Remove this. |
| 282 | switch (Val) { |
| 283 | case Attribute::EndAttrKinds: |
| 284 | case Attribute::AttrKindEmptyKey: |
| 285 | case Attribute::AttrKindTombstoneKey: |
| 286 | llvm_unreachable("Synthetic enumerators which should never get here"); |
| 287 | |
| 288 | case Attribute::None: return 0; |
| 289 | case Attribute::ZExt: return 1 << 0; |
| 290 | case Attribute::SExt: return 1 << 1; |
| 291 | case Attribute::NoReturn: return 1 << 2; |
| 292 | case Attribute::InReg: return 1 << 3; |
| 293 | case Attribute::StructRet: return 1 << 4; |
| 294 | case Attribute::NoUnwind: return 1 << 5; |
| 295 | case Attribute::NoAlias: return 1 << 6; |
| 296 | case Attribute::ByVal: return 1 << 7; |
| 297 | case Attribute::Nest: return 1 << 8; |
| 298 | case Attribute::ReadNone: return 1 << 9; |
| 299 | case Attribute::ReadOnly: return 1 << 10; |
| 300 | case Attribute::NoInline: return 1 << 11; |
| 301 | case Attribute::AlwaysInline: return 1 << 12; |
| 302 | case Attribute::OptimizeForSize: return 1 << 13; |
| 303 | case Attribute::StackProtect: return 1 << 14; |
| 304 | case Attribute::StackProtectReq: return 1 << 15; |
| 305 | case Attribute::Alignment: return 31 << 16; |
| 306 | case Attribute::NoCapture: return 1 << 21; |
| 307 | case Attribute::NoRedZone: return 1 << 22; |
| 308 | case Attribute::NoImplicitFloat: return 1 << 23; |
| 309 | case Attribute::Naked: return 1 << 24; |
| 310 | case Attribute::InlineHint: return 1 << 25; |
| 311 | case Attribute::StackAlignment: return 7 << 26; |
| 312 | case Attribute::ReturnsTwice: return 1 << 29; |
| 313 | case Attribute::UWTable: return 1 << 30; |
| 314 | case Attribute::NonLazyBind: return 1U << 31; |
| 315 | case Attribute::AddressSafety: return 1ULL << 32; |
| 316 | case Attribute::MinSize: return 1ULL << 33; |
| 317 | case Attribute::NoDuplicate: return 1ULL << 34; |
| 318 | case Attribute::StackProtectStrong: return 1ULL << 35; |
| 319 | } |
| 320 | llvm_unreachable("Unsupported attribute type"); |
| 321 | } |
| 322 | |
| 323 | //===----------------------------------------------------------------------===// |
| 324 | // AttributeSetNode Definition |
| 325 | //===----------------------------------------------------------------------===// |
| 326 | |
| 327 | AttributeSetNode *AttributeSetNode::get(LLVMContext &C, |
| 328 | ArrayRef<Attribute> Attrs) { |
| 329 | if (Attrs.empty()) |
| 330 | return 0; |
| 331 | |
| 332 | // Otherwise, build a key to look up the existing attributes. |
| 333 | LLVMContextImpl *pImpl = C.pImpl; |
| 334 | FoldingSetNodeID ID; |
| 335 | |
| 336 | SmallVector<Attribute, 8> SortedAttrs(Attrs.begin(), Attrs.end()); |
| 337 | std::sort(SortedAttrs.begin(), SortedAttrs.end()); |
| 338 | |
| 339 | for (SmallVectorImpl<Attribute>::iterator I = SortedAttrs.begin(), |
| 340 | E = SortedAttrs.end(); I != E; ++I) |
| 341 | I->Profile(ID); |
| 342 | |
| 343 | void *InsertPoint; |
| 344 | AttributeSetNode *PA = |
| 345 | pImpl->AttrsSetNodes.FindNodeOrInsertPos(ID, InsertPoint); |
| 346 | |
| 347 | // If we didn't find any existing attributes of the same shape then create a |
| 348 | // new one and insert it. |
| 349 | if (!PA) { |
| 350 | PA = new AttributeSetNode(SortedAttrs); |
| 351 | pImpl->AttrsSetNodes.InsertNode(PA, InsertPoint); |
| 352 | } |
| 353 | |
| 354 | // Return the AttributesListNode that we found or created. |
| 355 | return PA; |
| 356 | } |
| 357 | |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 358 | bool AttributeSetNode::hasAttribute(Attribute::AttrKind Kind) const { |
| 359 | for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(), |
| 360 | E = AttrList.end(); I != E; ++I) |
| 361 | if (I->hasAttribute(Kind)) |
| 362 | return true; |
| 363 | return false; |
| 364 | } |
| 365 | |
| 366 | unsigned AttributeSetNode::getAlignment() const { |
| 367 | for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(), |
| 368 | E = AttrList.end(); I != E; ++I) |
| 369 | if (I->hasAttribute(Attribute::Alignment)) |
| 370 | return I->getAlignment(); |
| 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | unsigned AttributeSetNode::getStackAlignment() const { |
| 375 | for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(), |
| 376 | E = AttrList.end(); I != E; ++I) |
| 377 | if (I->hasAttribute(Attribute::StackAlignment)) |
| 378 | return I->getStackAlignment(); |
| 379 | return 0; |
| 380 | } |
| 381 | |
| 382 | std::string AttributeSetNode::getAsString() const { |
| 383 | std::string Str = ""; |
| 384 | for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(), |
| 385 | E = AttrList.end(); I != E; ++I) { |
| 386 | if (I != AttrList.begin()) Str += " "; |
| 387 | Str += I->getAsString(); |
| 388 | } |
| 389 | return Str; |
| 390 | } |
| 391 | |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 392 | //===----------------------------------------------------------------------===// |
| 393 | // AttributeSetImpl Definition |
| 394 | //===----------------------------------------------------------------------===// |
| 395 | |
| 396 | uint64_t AttributeSetImpl::Raw(uint64_t Index) const { |
| 397 | for (unsigned I = 0, E = getNumAttributes(); I != E; ++I) { |
| 398 | if (getSlotIndex(I) != Index) continue; |
| 399 | const AttributeSetNode *ASN = AttrNodes[I].second; |
| 400 | AttrBuilder B; |
| 401 | |
| 402 | for (AttributeSetNode::const_iterator II = ASN->begin(), |
| 403 | IE = ASN->end(); II != IE; ++II) |
| 404 | B.addAttributes(*II); |
| 405 | return B.Raw(); |
| 406 | } |
| 407 | |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | //===----------------------------------------------------------------------===// |
| 412 | // AttributeSet Construction and Mutation Methods |
| 413 | //===----------------------------------------------------------------------===// |
| 414 | |
Bill Wendling | 8232ece | 2013-01-29 01:43:29 +0000 | [diff] [blame] | 415 | AttributeSet |
| 416 | AttributeSet::getImpl(LLVMContext &C, |
| 417 | ArrayRef<std::pair<unsigned, AttributeSetNode*> > Attrs) { |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 418 | LLVMContextImpl *pImpl = C.pImpl; |
| 419 | FoldingSetNodeID ID; |
| 420 | AttributeSetImpl::Profile(ID, Attrs); |
| 421 | |
| 422 | void *InsertPoint; |
| 423 | AttributeSetImpl *PA = pImpl->AttrsLists.FindNodeOrInsertPos(ID, InsertPoint); |
| 424 | |
| 425 | // If we didn't find any existing attributes of the same shape then |
| 426 | // create a new one and insert it. |
| 427 | if (!PA) { |
| 428 | PA = new AttributeSetImpl(C, Attrs); |
| 429 | pImpl->AttrsLists.InsertNode(PA, InsertPoint); |
| 430 | } |
| 431 | |
| 432 | // Return the AttributesList that we found or created. |
| 433 | return AttributeSet(PA); |
| 434 | } |
| 435 | |
| 436 | AttributeSet AttributeSet::get(LLVMContext &C, |
| 437 | ArrayRef<std::pair<unsigned, Attribute> > Attrs){ |
| 438 | // If there are no attributes then return a null AttributesList pointer. |
| 439 | if (Attrs.empty()) |
| 440 | return AttributeSet(); |
| 441 | |
| 442 | #ifndef NDEBUG |
| 443 | for (unsigned i = 0, e = Attrs.size(); i != e; ++i) { |
| 444 | assert((!i || Attrs[i-1].first <= Attrs[i].first) && |
| 445 | "Misordered Attributes list!"); |
| 446 | assert(Attrs[i].second.hasAttributes() && |
| 447 | "Pointless attribute!"); |
| 448 | } |
| 449 | #endif |
| 450 | |
| 451 | // Create a vector if (unsigned, AttributeSetNode*) pairs from the attributes |
| 452 | // list. |
| 453 | SmallVector<std::pair<unsigned, AttributeSetNode*>, 8> AttrPairVec; |
| 454 | for (ArrayRef<std::pair<unsigned, Attribute> >::iterator I = Attrs.begin(), |
| 455 | E = Attrs.end(); I != E; ) { |
| 456 | unsigned Index = I->first; |
| 457 | SmallVector<Attribute, 4> AttrVec; |
NAKAMURA Takumi | 3ba51ce | 2013-01-29 15:18:16 +0000 | [diff] [blame] | 458 | while (I != E && I->first == Index) { |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 459 | AttrVec.push_back(I->second); |
| 460 | ++I; |
| 461 | } |
| 462 | |
| 463 | AttrPairVec.push_back(std::make_pair(Index, |
| 464 | AttributeSetNode::get(C, AttrVec))); |
| 465 | } |
| 466 | |
| 467 | return getImpl(C, AttrPairVec); |
| 468 | } |
| 469 | |
| 470 | AttributeSet AttributeSet::get(LLVMContext &C, |
| 471 | ArrayRef<std::pair<unsigned, |
| 472 | AttributeSetNode*> > Attrs) { |
| 473 | // If there are no attributes then return a null AttributesList pointer. |
| 474 | if (Attrs.empty()) |
| 475 | return AttributeSet(); |
| 476 | |
| 477 | return getImpl(C, Attrs); |
| 478 | } |
| 479 | |
| 480 | AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx, AttrBuilder &B) { |
| 481 | if (!B.hasAttributes()) |
| 482 | return AttributeSet(); |
Bill Wendling | 8fbc0c2 | 2013-01-29 01:02:03 +0000 | [diff] [blame] | 483 | |
| 484 | SmallVector<std::pair<unsigned, Attribute>, 8> Attrs; |
| 485 | for (AttrBuilder::iterator I = B.begin(), E = B.end(); I != E; ++I) { |
| 486 | Attribute::AttrKind Kind = *I; |
| 487 | if (Kind == Attribute::Alignment) |
| 488 | Attrs.push_back(std::make_pair(Idx, Attribute:: |
| 489 | getWithAlignment(C, B.getAlignment()))); |
| 490 | else if (Kind == Attribute::StackAlignment) |
| 491 | Attrs.push_back(std::make_pair(Idx, Attribute:: |
| 492 | getWithStackAlignment(C, B.getStackAlignment()))); |
| 493 | else |
| 494 | Attrs.push_back(std::make_pair(Idx, Attribute::get(C, Kind))); |
| 495 | } |
| 496 | |
| 497 | return get(C, Attrs); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | AttributeSet AttributeSet::get(LLVMContext &C, unsigned Idx, |
| 501 | ArrayRef<Attribute::AttrKind> Kind) { |
| 502 | SmallVector<std::pair<unsigned, Attribute>, 8> Attrs; |
| 503 | for (ArrayRef<Attribute::AttrKind>::iterator I = Kind.begin(), |
| 504 | E = Kind.end(); I != E; ++I) |
| 505 | Attrs.push_back(std::make_pair(Idx, Attribute::get(C, *I))); |
| 506 | return get(C, Attrs); |
| 507 | } |
| 508 | |
| 509 | AttributeSet AttributeSet::get(LLVMContext &C, ArrayRef<AttributeSet> Attrs) { |
| 510 | if (Attrs.empty()) return AttributeSet(); |
| 511 | |
| 512 | SmallVector<std::pair<unsigned, AttributeSetNode*>, 8> AttrNodeVec; |
| 513 | for (unsigned I = 0, E = Attrs.size(); I != E; ++I) { |
| 514 | AttributeSet AS = Attrs[I]; |
| 515 | if (!AS.pImpl) continue; |
| 516 | AttrNodeVec.append(AS.pImpl->AttrNodes.begin(), AS.pImpl->AttrNodes.end()); |
| 517 | } |
| 518 | |
| 519 | return getImpl(C, AttrNodeVec); |
| 520 | } |
| 521 | |
| 522 | AttributeSet AttributeSet::addAttribute(LLVMContext &C, unsigned Idx, |
| 523 | Attribute::AttrKind Attr) const { |
| 524 | return addAttributes(C, Idx, AttributeSet::get(C, Idx, Attr)); |
| 525 | } |
| 526 | |
| 527 | AttributeSet AttributeSet::addAttributes(LLVMContext &C, unsigned Idx, |
| 528 | AttributeSet Attrs) const { |
| 529 | if (!pImpl) return Attrs; |
| 530 | if (!Attrs.pImpl) return *this; |
| 531 | |
| 532 | #ifndef NDEBUG |
| 533 | // FIXME it is not obvious how this should work for alignment. For now, say |
| 534 | // we can't change a known alignment. |
| 535 | unsigned OldAlign = getParamAlignment(Idx); |
| 536 | unsigned NewAlign = Attrs.getParamAlignment(Idx); |
| 537 | assert((!OldAlign || !NewAlign || OldAlign == NewAlign) && |
| 538 | "Attempt to change alignment!"); |
| 539 | #endif |
| 540 | |
| 541 | // Add the attribute slots before the one we're trying to add. |
| 542 | SmallVector<AttributeSet, 4> AttrSet; |
| 543 | uint64_t NumAttrs = pImpl->getNumAttributes(); |
| 544 | AttributeSet AS; |
| 545 | uint64_t LastIndex = 0; |
| 546 | for (unsigned I = 0, E = NumAttrs; I != E; ++I) { |
| 547 | if (getSlotIndex(I) >= Idx) { |
| 548 | if (getSlotIndex(I) == Idx) AS = getSlotAttributes(LastIndex++); |
| 549 | break; |
| 550 | } |
| 551 | LastIndex = I + 1; |
| 552 | AttrSet.push_back(getSlotAttributes(I)); |
| 553 | } |
| 554 | |
| 555 | // Now add the attribute into the correct slot. There may already be an |
| 556 | // AttributeSet there. |
| 557 | AttrBuilder B(AS, Idx); |
| 558 | |
| 559 | for (unsigned I = 0, E = Attrs.pImpl->getNumAttributes(); I != E; ++I) |
| 560 | if (Attrs.getSlotIndex(I) == Idx) { |
| 561 | for (AttributeSetImpl::const_iterator II = Attrs.pImpl->begin(I), |
| 562 | IE = Attrs.pImpl->end(I); II != IE; ++II) |
| 563 | B.addAttributes(*II); |
| 564 | break; |
| 565 | } |
| 566 | |
| 567 | AttrSet.push_back(AttributeSet::get(C, Idx, B)); |
| 568 | |
| 569 | // Add the remaining attribute slots. |
| 570 | for (unsigned I = LastIndex, E = NumAttrs; I < E; ++I) |
| 571 | AttrSet.push_back(getSlotAttributes(I)); |
| 572 | |
| 573 | return get(C, AttrSet); |
| 574 | } |
| 575 | |
| 576 | AttributeSet AttributeSet::removeAttribute(LLVMContext &C, unsigned Idx, |
| 577 | Attribute::AttrKind Attr) const { |
| 578 | return removeAttributes(C, Idx, AttributeSet::get(C, Idx, Attr)); |
| 579 | } |
| 580 | |
| 581 | AttributeSet AttributeSet::removeAttributes(LLVMContext &C, unsigned Idx, |
| 582 | AttributeSet Attrs) const { |
| 583 | if (!pImpl) return AttributeSet(); |
| 584 | if (!Attrs.pImpl) return *this; |
| 585 | |
| 586 | #ifndef NDEBUG |
| 587 | // FIXME it is not obvious how this should work for alignment. |
| 588 | // For now, say we can't pass in alignment, which no current use does. |
| 589 | assert(!Attrs.hasAttribute(Idx, Attribute::Alignment) && |
| 590 | "Attempt to change alignment!"); |
| 591 | #endif |
| 592 | |
| 593 | // Add the attribute slots before the one we're trying to add. |
| 594 | SmallVector<AttributeSet, 4> AttrSet; |
| 595 | uint64_t NumAttrs = pImpl->getNumAttributes(); |
| 596 | AttributeSet AS; |
| 597 | uint64_t LastIndex = 0; |
| 598 | for (unsigned I = 0, E = NumAttrs; I != E; ++I) { |
| 599 | if (getSlotIndex(I) >= Idx) { |
| 600 | if (getSlotIndex(I) == Idx) AS = getSlotAttributes(LastIndex++); |
| 601 | break; |
| 602 | } |
| 603 | LastIndex = I + 1; |
| 604 | AttrSet.push_back(getSlotAttributes(I)); |
| 605 | } |
| 606 | |
| 607 | // Now add the attribute into the correct slot. There may already be an |
| 608 | // AttributeSet there. |
| 609 | AttrBuilder B(AS, Idx); |
| 610 | |
| 611 | for (unsigned I = 0, E = Attrs.pImpl->getNumAttributes(); I != E; ++I) |
| 612 | if (Attrs.getSlotIndex(I) == Idx) { |
| 613 | for (AttributeSetImpl::const_iterator II = Attrs.pImpl->begin(I), |
| 614 | IE = Attrs.pImpl->end(I); II != IE; ++II) |
| 615 | B.removeAttributes(*II); |
| 616 | break; |
| 617 | } |
| 618 | |
| 619 | AttrSet.push_back(AttributeSet::get(C, Idx, B)); |
| 620 | |
| 621 | // Add the remaining attribute slots. |
| 622 | for (unsigned I = LastIndex, E = NumAttrs; I < E; ++I) |
| 623 | AttrSet.push_back(getSlotAttributes(I)); |
| 624 | |
| 625 | return get(C, AttrSet); |
| 626 | } |
| 627 | |
| 628 | //===----------------------------------------------------------------------===// |
| 629 | // AttributeSet Accessor Methods |
| 630 | //===----------------------------------------------------------------------===// |
| 631 | |
| 632 | AttributeSet AttributeSet::getParamAttributes(unsigned Idx) const { |
| 633 | return pImpl && hasAttributes(Idx) ? |
| 634 | AttributeSet::get(pImpl->getContext(), |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 635 | ArrayRef<std::pair<unsigned, AttributeSetNode*> >( |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 636 | std::make_pair(Idx, getAttributes(Idx)))) : |
| 637 | AttributeSet(); |
| 638 | } |
| 639 | |
| 640 | AttributeSet AttributeSet::getRetAttributes() const { |
| 641 | return pImpl && hasAttributes(ReturnIndex) ? |
| 642 | AttributeSet::get(pImpl->getContext(), |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 643 | ArrayRef<std::pair<unsigned, AttributeSetNode*> >( |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 644 | std::make_pair(ReturnIndex, |
| 645 | getAttributes(ReturnIndex)))) : |
| 646 | AttributeSet(); |
| 647 | } |
| 648 | |
| 649 | AttributeSet AttributeSet::getFnAttributes() const { |
| 650 | return pImpl && hasAttributes(FunctionIndex) ? |
| 651 | AttributeSet::get(pImpl->getContext(), |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 652 | ArrayRef<std::pair<unsigned, AttributeSetNode*> >( |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 653 | std::make_pair(FunctionIndex, |
| 654 | getAttributes(FunctionIndex)))) : |
| 655 | AttributeSet(); |
| 656 | } |
| 657 | |
| 658 | bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{ |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 659 | AttributeSetNode *ASN = getAttributes(Index); |
| 660 | return ASN ? ASN->hasAttribute(Kind) : false; |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | bool AttributeSet::hasAttributes(unsigned Index) const { |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 664 | AttributeSetNode *ASN = getAttributes(Index); |
| 665 | return ASN ? ASN->hasAttributes() : false; |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | /// \brief Return true if the specified attribute is set for at least one |
| 669 | /// parameter or for the return value. |
| 670 | bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const { |
| 671 | if (pImpl == 0) return false; |
| 672 | |
| 673 | for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I) |
| 674 | for (AttributeSetImpl::const_iterator II = pImpl->begin(I), |
| 675 | IE = pImpl->end(I); II != IE; ++II) |
| 676 | if (II->hasAttribute(Attr)) |
| 677 | return true; |
| 678 | |
| 679 | return false; |
| 680 | } |
| 681 | |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 682 | unsigned AttributeSet::getParamAlignment(unsigned Index) const { |
| 683 | AttributeSetNode *ASN = getAttributes(Index); |
| 684 | return ASN ? ASN->getAlignment() : 0; |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 685 | } |
| 686 | |
| 687 | unsigned AttributeSet::getStackAlignment(unsigned Index) const { |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 688 | AttributeSetNode *ASN = getAttributes(Index); |
| 689 | return ASN ? ASN->getStackAlignment() : 0; |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | std::string AttributeSet::getAsString(unsigned Index) const { |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 693 | AttributeSetNode *ASN = getAttributes(Index); |
| 694 | return ASN ? ASN->getAsString() : std::string(""); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | /// \brief The attributes for the specified index are returned. |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 698 | AttributeSetNode *AttributeSet::getAttributes(unsigned Idx) const { |
| 699 | if (!pImpl) return 0; |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 700 | |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 701 | // Loop through to find the attribute node we want. |
| 702 | for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I) |
| 703 | if (pImpl->getSlotIndex(I) == Idx) |
| 704 | return pImpl->getSlotNode(I); |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 705 | |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 706 | return 0; |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | //===----------------------------------------------------------------------===// |
| 710 | // AttributeSet Introspection Methods |
| 711 | //===----------------------------------------------------------------------===// |
| 712 | |
| 713 | /// \brief Return the number of slots used in this attribute list. This is the |
| 714 | /// number of arguments that have an attribute set on them (including the |
| 715 | /// function itself). |
| 716 | unsigned AttributeSet::getNumSlots() const { |
| 717 | return pImpl ? pImpl->getNumAttributes() : 0; |
| 718 | } |
| 719 | |
| 720 | uint64_t AttributeSet::getSlotIndex(unsigned Slot) const { |
| 721 | assert(pImpl && Slot < pImpl->getNumAttributes() && |
| 722 | "Slot # out of range!"); |
| 723 | return pImpl->getSlotIndex(Slot); |
| 724 | } |
| 725 | |
| 726 | AttributeSet AttributeSet::getSlotAttributes(unsigned Slot) const { |
| 727 | assert(pImpl && Slot < pImpl->getNumAttributes() && |
| 728 | "Slot # out of range!"); |
| 729 | return pImpl->getSlotAttributes(Slot); |
| 730 | } |
| 731 | |
| 732 | uint64_t AttributeSet::Raw(unsigned Index) const { |
| 733 | // FIXME: Remove this. |
| 734 | return pImpl ? pImpl->Raw(Index) : 0; |
| 735 | } |
| 736 | |
| 737 | void AttributeSet::dump() const { |
| 738 | dbgs() << "PAL[\n"; |
| 739 | |
| 740 | for (unsigned i = 0, e = getNumSlots(); i < e; ++i) { |
| 741 | uint64_t Index = getSlotIndex(i); |
| 742 | dbgs() << " { "; |
| 743 | if (Index == ~0U) |
| 744 | dbgs() << "~0U"; |
| 745 | else |
| 746 | dbgs() << Index; |
| 747 | dbgs() << " => " << getAsString(Index) << " }\n"; |
| 748 | } |
| 749 | |
| 750 | dbgs() << "]\n"; |
| 751 | } |
| 752 | |
Bill Wendling | e66f3d3 | 2012-10-05 06:44:41 +0000 | [diff] [blame] | 753 | //===----------------------------------------------------------------------===// |
Bill Wendling | 0319888 | 2013-01-04 23:27:34 +0000 | [diff] [blame] | 754 | // AttrBuilder Method Implementations |
Bill Wendling | e66f3d3 | 2012-10-05 06:44:41 +0000 | [diff] [blame] | 755 | //===----------------------------------------------------------------------===// |
| 756 | |
Bill Wendling | a90a99a | 2013-01-07 08:24:35 +0000 | [diff] [blame] | 757 | AttrBuilder::AttrBuilder(AttributeSet AS, unsigned Idx) |
| 758 | : Alignment(0), StackAlignment(0) { |
Bill Wendling | ec25898 | 2013-01-27 21:23:46 +0000 | [diff] [blame] | 759 | AttributeSetImpl *pImpl = AS.pImpl; |
Bill Wendling | a90a99a | 2013-01-07 08:24:35 +0000 | [diff] [blame] | 760 | if (!pImpl) return; |
| 761 | |
Bill Wendling | 73bc452 | 2013-01-28 00:21:34 +0000 | [diff] [blame] | 762 | AttrBuilder B; |
Bill Wendling | a90a99a | 2013-01-07 08:24:35 +0000 | [diff] [blame] | 763 | |
Bill Wendling | 73bc452 | 2013-01-28 00:21:34 +0000 | [diff] [blame] | 764 | for (unsigned I = 0, E = pImpl->getNumAttributes(); I != E; ++I) { |
| 765 | if (pImpl->getSlotIndex(I) != Idx) continue; |
Bill Wendling | a90a99a | 2013-01-07 08:24:35 +0000 | [diff] [blame] | 766 | |
Bill Wendling | 73bc452 | 2013-01-28 00:21:34 +0000 | [diff] [blame] | 767 | for (AttributeSetNode::const_iterator II = pImpl->begin(I), |
| 768 | IE = pImpl->end(I); II != IE; ++II) |
| 769 | B.addAttributes(*II); |
| 770 | |
| 771 | break; |
| 772 | } |
| 773 | |
| 774 | if (!B.hasAttributes()) return; |
| 775 | |
| 776 | uint64_t Mask = B.Raw(); |
Bill Wendling | a90a99a | 2013-01-07 08:24:35 +0000 | [diff] [blame] | 777 | |
Bill Wendling | 956f134 | 2013-01-18 21:11:39 +0000 | [diff] [blame] | 778 | for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds; |
| 779 | I = Attribute::AttrKind(I + 1)) { |
| 780 | if (uint64_t A = (Mask & AttributeImpl::getAttrMask(I))) { |
| 781 | Attrs.insert(I); |
| 782 | |
| 783 | if (I == Attribute::Alignment) |
| 784 | Alignment = 1ULL << ((A >> 16) - 1); |
| 785 | else if (I == Attribute::StackAlignment) |
| 786 | StackAlignment = 1ULL << ((A >> 26)-1); |
| 787 | } |
| 788 | } |
Bill Wendling | a90a99a | 2013-01-07 08:24:35 +0000 | [diff] [blame] | 789 | } |
| 790 | |
Bill Wendling | 0319888 | 2013-01-04 23:27:34 +0000 | [diff] [blame] | 791 | void AttrBuilder::clear() { |
| 792 | Attrs.clear(); |
| 793 | Alignment = StackAlignment = 0; |
| 794 | } |
| 795 | |
| 796 | AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val) { |
| 797 | Attrs.insert(Val); |
Bill Wendling | 3a106e6 | 2012-10-09 19:01:18 +0000 | [diff] [blame] | 798 | return *this; |
Bill Wendling | e66f3d3 | 2012-10-05 06:44:41 +0000 | [diff] [blame] | 799 | } |
| 800 | |
Bill Wendling | 0319888 | 2013-01-04 23:27:34 +0000 | [diff] [blame] | 801 | AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) { |
| 802 | Attrs.erase(Val); |
| 803 | if (Val == Attribute::Alignment) |
| 804 | Alignment = 0; |
| 805 | else if (Val == Attribute::StackAlignment) |
| 806 | StackAlignment = 0; |
| 807 | |
Bill Wendling | a19a530 | 2012-10-14 04:10:01 +0000 | [diff] [blame] | 808 | return *this; |
| 809 | } |
| 810 | |
Bill Wendling | 49f6060 | 2013-01-28 05:23:28 +0000 | [diff] [blame] | 811 | AttrBuilder &AttrBuilder::addAttributes(Attribute Attr) { |
| 812 | uint64_t Mask = Attr.Raw(); |
| 813 | |
| 814 | for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds; |
| 815 | I = Attribute::AttrKind(I + 1)) |
| 816 | if ((Mask & AttributeImpl::getAttrMask(I)) != 0) |
| 817 | Attrs.insert(I); |
| 818 | |
| 819 | if (Attr.getAlignment()) |
| 820 | Alignment = Attr.getAlignment(); |
| 821 | if (Attr.getStackAlignment()) |
| 822 | StackAlignment = Attr.getStackAlignment(); |
| 823 | return *this; |
| 824 | } |
| 825 | |
| 826 | AttrBuilder &AttrBuilder::removeAttributes(Attribute A) { |
| 827 | uint64_t Mask = A.Raw(); |
| 828 | |
| 829 | for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds; |
| 830 | I = Attribute::AttrKind(I + 1)) { |
| 831 | if (Mask & AttributeImpl::getAttrMask(I)) { |
| 832 | Attrs.erase(I); |
| 833 | |
| 834 | if (I == Attribute::Alignment) |
| 835 | Alignment = 0; |
| 836 | else if (I == Attribute::StackAlignment) |
| 837 | StackAlignment = 0; |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | return *this; |
| 842 | } |
| 843 | |
Bill Wendling | 702cc91 | 2012-10-15 20:35:56 +0000 | [diff] [blame] | 844 | AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) { |
Bill Wendling | da3f9d8 | 2012-10-14 03:58:29 +0000 | [diff] [blame] | 845 | if (Align == 0) return *this; |
Bill Wendling | 0319888 | 2013-01-04 23:27:34 +0000 | [diff] [blame] | 846 | |
Bill Wendling | e66f3d3 | 2012-10-05 06:44:41 +0000 | [diff] [blame] | 847 | assert(isPowerOf2_32(Align) && "Alignment must be a power of two."); |
| 848 | assert(Align <= 0x40000000 && "Alignment too large."); |
Bill Wendling | 0319888 | 2013-01-04 23:27:34 +0000 | [diff] [blame] | 849 | |
| 850 | Attrs.insert(Attribute::Alignment); |
| 851 | Alignment = Align; |
Bill Wendling | da3f9d8 | 2012-10-14 03:58:29 +0000 | [diff] [blame] | 852 | return *this; |
Chris Lattner | 50ee9dd | 2008-01-02 23:42:30 +0000 | [diff] [blame] | 853 | } |
| 854 | |
Bill Wendling | 0319888 | 2013-01-04 23:27:34 +0000 | [diff] [blame] | 855 | AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align) { |
| 856 | // Default alignment, allow the target to define how to align it. |
| 857 | if (Align == 0) return *this; |
| 858 | |
| 859 | assert(isPowerOf2_32(Align) && "Alignment must be a power of two."); |
| 860 | assert(Align <= 0x100 && "Alignment too large."); |
| 861 | |
| 862 | Attrs.insert(Attribute::StackAlignment); |
| 863 | StackAlignment = Align; |
| 864 | return *this; |
| 865 | } |
| 866 | |
Bill Wendling | 22bd641 | 2013-01-03 01:54:39 +0000 | [diff] [blame] | 867 | bool AttrBuilder::contains(Attribute::AttrKind A) const { |
Bill Wendling | 0319888 | 2013-01-04 23:27:34 +0000 | [diff] [blame] | 868 | return Attrs.count(A); |
Bill Wendling | 7d2f249 | 2012-10-10 07:36:45 +0000 | [diff] [blame] | 869 | } |
| 870 | |
Bill Wendling | 702cc91 | 2012-10-15 20:35:56 +0000 | [diff] [blame] | 871 | bool AttrBuilder::hasAttributes() const { |
Bill Wendling | 0319888 | 2013-01-04 23:27:34 +0000 | [diff] [blame] | 872 | return !Attrs.empty(); |
Bill Wendling | f385f4c | 2012-10-08 23:27:46 +0000 | [diff] [blame] | 873 | } |
Bill Wendling | 60507d5 | 2013-01-04 20:54:35 +0000 | [diff] [blame] | 874 | |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 875 | bool AttrBuilder::hasAttributes(const Attribute &A) const { |
Bill Wendling | 1db9b69 | 2013-01-09 23:36:50 +0000 | [diff] [blame] | 876 | return Raw() & A.Raw(); |
Bill Wendling | 8831c06 | 2012-10-09 00:01:21 +0000 | [diff] [blame] | 877 | } |
Bill Wendling | 60507d5 | 2013-01-04 20:54:35 +0000 | [diff] [blame] | 878 | |
Bill Wendling | 702cc91 | 2012-10-15 20:35:56 +0000 | [diff] [blame] | 879 | bool AttrBuilder::hasAlignmentAttr() const { |
Bill Wendling | 0319888 | 2013-01-04 23:27:34 +0000 | [diff] [blame] | 880 | return Alignment != 0; |
Bill Wendling | f385f4c | 2012-10-08 23:27:46 +0000 | [diff] [blame] | 881 | } |
| 882 | |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 883 | bool AttrBuilder::operator==(const AttrBuilder &B) { |
| 884 | SmallVector<Attribute::AttrKind, 8> This(Attrs.begin(), Attrs.end()); |
| 885 | SmallVector<Attribute::AttrKind, 8> That(B.Attrs.begin(), B.Attrs.end()); |
| 886 | return This == That; |
| 887 | } |
| 888 | |
| 889 | AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) { |
Bill Wendling | 8232ece | 2013-01-29 01:43:29 +0000 | [diff] [blame] | 890 | if (!Val) return *this; |
| 891 | |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 892 | for (Attribute::AttrKind I = Attribute::None; I != Attribute::EndAttrKinds; |
| 893 | I = Attribute::AttrKind(I + 1)) { |
| 894 | if (uint64_t A = (Val & AttributeImpl::getAttrMask(I))) { |
| 895 | Attrs.insert(I); |
| 896 | |
| 897 | if (I == Attribute::Alignment) |
| 898 | Alignment = 1ULL << ((A >> 16) - 1); |
| 899 | else if (I == Attribute::StackAlignment) |
| 900 | StackAlignment = 1ULL << ((A >> 26)-1); |
| 901 | } |
| 902 | } |
| 903 | |
| 904 | return *this; |
| 905 | } |
| 906 | |
Bill Wendling | 1db9b69 | 2013-01-09 23:36:50 +0000 | [diff] [blame] | 907 | uint64_t AttrBuilder::Raw() const { |
Bill Wendling | 0319888 | 2013-01-04 23:27:34 +0000 | [diff] [blame] | 908 | uint64_t Mask = 0; |
| 909 | |
| 910 | for (DenseSet<Attribute::AttrKind>::const_iterator I = Attrs.begin(), |
| 911 | E = Attrs.end(); I != E; ++I) { |
| 912 | Attribute::AttrKind Kind = *I; |
| 913 | |
| 914 | if (Kind == Attribute::Alignment) |
| 915 | Mask |= (Log2_32(Alignment) + 1) << 16; |
| 916 | else if (Kind == Attribute::StackAlignment) |
| 917 | Mask |= (Log2_32(StackAlignment) + 1) << 26; |
| 918 | else |
| 919 | Mask |= AttributeImpl::getAttrMask(Kind); |
| 920 | } |
| 921 | |
| 922 | return Mask; |
Bill Wendling | f385f4c | 2012-10-08 23:27:46 +0000 | [diff] [blame] | 923 | } |
| 924 | |
Bill Wendling | 8e47daf | 2013-01-25 23:09:36 +0000 | [diff] [blame] | 925 | //===----------------------------------------------------------------------===// |
| 926 | // AttributeFuncs Function Defintions |
| 927 | //===----------------------------------------------------------------------===// |
| 928 | |
| 929 | Attribute AttributeFuncs::typeIncompatible(Type *Ty) { |
| 930 | AttrBuilder Incompatible; |
| 931 | |
| 932 | if (!Ty->isIntegerTy()) |
| 933 | // Attribute that only apply to integers. |
| 934 | Incompatible.addAttribute(Attribute::SExt) |
| 935 | .addAttribute(Attribute::ZExt); |
| 936 | |
| 937 | if (!Ty->isPointerTy()) |
| 938 | // Attribute that only apply to pointers. |
| 939 | Incompatible.addAttribute(Attribute::ByVal) |
| 940 | .addAttribute(Attribute::Nest) |
| 941 | .addAttribute(Attribute::NoAlias) |
| 942 | .addAttribute(Attribute::NoCapture) |
| 943 | .addAttribute(Attribute::StructRet); |
| 944 | |
| 945 | return Attribute::get(Ty->getContext(), Incompatible); |
| 946 | } |
| 947 | |
Bill Wendling | c22f4aa | 2013-01-29 00:34:06 +0000 | [diff] [blame] | 948 | /// \brief This returns an integer containing an encoding of all the LLVM |
| 949 | /// attributes found in the given attribute bitset. Any change to this encoding |
| 950 | /// is a breaking change to bitcode compatibility. |
Bill Wendling | 8232ece | 2013-01-29 01:43:29 +0000 | [diff] [blame] | 951 | /// N.B. This should be used only by the bitcode reader! |
Bill Wendling | 8e47daf | 2013-01-25 23:09:36 +0000 | [diff] [blame] | 952 | uint64_t AttributeFuncs::encodeLLVMAttributesForBitcode(AttributeSet Attrs, |
| 953 | unsigned Index) { |
| 954 | // FIXME: It doesn't make sense to store the alignment information as an |
| 955 | // expanded out value, we should store it as a log2 value. However, we can't |
| 956 | // just change that here without breaking bitcode compatibility. If this ever |
| 957 | // becomes a problem in practice, we should introduce new tag numbers in the |
| 958 | // bitcode file and have those tags use a more efficiently encoded alignment |
| 959 | // field. |
| 960 | |
| 961 | // Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit |
| 962 | // log2 encoded value. Shift the bits above the alignment up by 11 bits. |
| 963 | uint64_t EncodedAttrs = Attrs.Raw(Index) & 0xffff; |
| 964 | if (Attrs.hasAttribute(Index, Attribute::Alignment)) |
| 965 | EncodedAttrs |= Attrs.getParamAlignment(Index) << 16; |
| 966 | EncodedAttrs |= (Attrs.Raw(Index) & (0xffffULL << 21)) << 11; |
| 967 | return EncodedAttrs; |
| 968 | } |
| 969 | |
Bill Wendling | 8232ece | 2013-01-29 01:43:29 +0000 | [diff] [blame] | 970 | /// \brief This fills an AttrBuilder object with the LLVM attributes that have |
| 971 | /// been decoded from the given integer. This function must stay in sync with |
| 972 | /// 'encodeLLVMAttributesForBitcode'. |
| 973 | /// N.B. This should be used only by the bitcode reader! |
| 974 | void AttributeFuncs::decodeLLVMAttributesForBitcode(LLVMContext &C, |
| 975 | AttrBuilder &B, |
| 976 | uint64_t EncodedAttrs) { |
Bill Wendling | 8e47daf | 2013-01-25 23:09:36 +0000 | [diff] [blame] | 977 | // The alignment is stored as a 16-bit raw value from bits 31--16. We shift |
| 978 | // the bits above 31 down by 11 bits. |
| 979 | unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16; |
| 980 | assert((!Alignment || isPowerOf2_32(Alignment)) && |
| 981 | "Alignment must be a power of two."); |
| 982 | |
Bill Wendling | 8e47daf | 2013-01-25 23:09:36 +0000 | [diff] [blame] | 983 | if (Alignment) |
| 984 | B.addAlignmentAttr(Alignment); |
Bill Wendling | 606c8e3 | 2013-01-29 03:20:31 +0000 | [diff] [blame] | 985 | B.addRawValue(((EncodedAttrs & (0xffffULL << 32)) >> 11) | |
| 986 | (EncodedAttrs & 0xffff)); |
Bill Wendling | 8e47daf | 2013-01-25 23:09:36 +0000 | [diff] [blame] | 987 | } |