blob: de83deb2e9ad0bfcc30ebd487345df985c0ca2e1 [file] [log] [blame]
Bill Wendling034b94b2012-12-19 07:18:57 +00001//===-- Attribute.cpp - Implement AttributesList -------------------------===//
Chris Lattner50ee9dd2008-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//
Bill Wendling034b94b2012-12-19 07:18:57 +000010// This file implements the Attribute, AttributeImpl, AttrBuilder,
Bill Wendling18e72112012-12-19 22:42:22 +000011// AttributeSetImpl, and AttributeSet classes.
Chris Lattner50ee9dd2008-01-02 23:42:30 +000012//
13//===----------------------------------------------------------------------===//
14
Devang Pateleaf42ab2008-09-23 23:03:40 +000015#include "llvm/Attributes.h"
Bill Wendlingf6670722012-12-20 01:36:59 +000016#include "AttributeImpl.h"
Bill Wendling2c79ecb2012-09-26 21:07:29 +000017#include "LLVMContextImpl.h"
Chris Lattner58d74912008-03-12 17:45:29 +000018#include "llvm/ADT/FoldingSet.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000019#include "llvm/ADT/StringExtras.h"
Michael J. Spencer1f6efa32010-11-29 18:16:10 +000020#include "llvm/Support/Atomic.h"
David Greeneef1894e2010-01-05 01:29:58 +000021#include "llvm/Support/Debug.h"
Chris Lattner50ee9dd2008-01-02 23:42:30 +000022#include "llvm/Support/ManagedStatic.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000023#include "llvm/Support/Mutex.h"
Benjamin Kramercfa6ec92009-08-23 11:37:21 +000024#include "llvm/Support/raw_ostream.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000025#include "llvm/Type.h"
Chris Lattner50ee9dd2008-01-02 23:42:30 +000026using namespace llvm;
27
Chris Lattner58d74912008-03-12 17:45:29 +000028//===----------------------------------------------------------------------===//
Bill Wendling034b94b2012-12-19 07:18:57 +000029// Attribute Implementation
Chris Lattner58d74912008-03-12 17:45:29 +000030//===----------------------------------------------------------------------===//
Chris Lattnerfabfde32008-01-03 00:10:22 +000031
Bill Wendling629fb822012-12-22 00:37:52 +000032Attribute Attribute::get(LLVMContext &Context, ArrayRef<AttrKind> Vals) {
Bill Wendling702cc912012-10-15 20:35:56 +000033 AttrBuilder B;
Bill Wendling629fb822012-12-22 00:37:52 +000034 for (ArrayRef<AttrKind>::iterator I = Vals.begin(), E = Vals.end();
Bill Wendlingcb3de0b2012-10-15 04:46:55 +000035 I != E; ++I)
36 B.addAttribute(*I);
Bill Wendling034b94b2012-12-19 07:18:57 +000037 return Attribute::get(Context, B);
Bill Wendlingcb3de0b2012-10-15 04:46:55 +000038}
Bill Wendling8e635db2012-10-08 21:47:17 +000039
Bill Wendling034b94b2012-12-19 07:18:57 +000040Attribute Attribute::get(LLVMContext &Context, AttrBuilder &B) {
41 // If there are no attributes, return an empty Attribute class.
Bill Wendlinga5c699d2012-10-16 05:55:09 +000042 if (!B.hasAttributes())
Bill Wendling034b94b2012-12-19 07:18:57 +000043 return Attribute();
Bill Wendling8e635db2012-10-08 21:47:17 +000044
45 // Otherwise, build a key to look up the existing attributes.
46 LLVMContextImpl *pImpl = Context.pImpl;
47 FoldingSetNodeID ID;
Bill Wendlingc966e082012-12-30 01:05:42 +000048 ID.AddInteger(B.getBitMask());
Bill Wendling8e635db2012-10-08 21:47:17 +000049
50 void *InsertPoint;
Bill Wendlingf6670722012-12-20 01:36:59 +000051 AttributeImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
Bill Wendling8e635db2012-10-08 21:47:17 +000052
53 if (!PA) {
54 // If we didn't find any existing attributes of the same shape then create a
55 // new one and insert it.
Bill Wendlingc966e082012-12-30 01:05:42 +000056 PA = new AttributeImpl(Context, B.getBitMask());
Bill Wendling8e635db2012-10-08 21:47:17 +000057 pImpl->AttrsSet.InsertNode(PA, InsertPoint);
58 }
59
60 // Return the AttributesList that we found or created.
Bill Wendling034b94b2012-12-19 07:18:57 +000061 return Attribute(PA);
Bill Wendling8e635db2012-10-08 21:47:17 +000062}
63
Bill Wendling629fb822012-12-22 00:37:52 +000064bool Attribute::hasAttribute(AttrKind Val) const {
Bill Wendling27107f62012-12-20 21:28:43 +000065 return pImpl && pImpl->hasAttribute(Val);
Bill Wendlinge66f3d32012-10-05 06:44:41 +000066}
67
Bill Wendling034b94b2012-12-19 07:18:57 +000068bool Attribute::hasAttributes() const {
Bill Wendling27107f62012-12-20 21:28:43 +000069 return pImpl && pImpl->hasAttributes();
Bill Wendling05cc40d2012-10-15 05:40:12 +000070}
71
Bill Wendling034b94b2012-12-19 07:18:57 +000072bool Attribute::hasAttributes(const Attribute &A) const {
Bill Wendling27107f62012-12-20 21:28:43 +000073 return pImpl && pImpl->hasAttributes(A);
Bill Wendling2e879bc2012-10-09 09:11:20 +000074}
75
Bill Wendlinge66f3d32012-10-05 06:44:41 +000076/// This returns the alignment field of an attribute as a byte alignment value.
Bill Wendling034b94b2012-12-19 07:18:57 +000077unsigned Attribute::getAlignment() const {
78 if (!hasAttribute(Attribute::Alignment))
Bill Wendling9ef99c92012-10-09 20:56:48 +000079 return 0;
Bill Wendling27107f62012-12-20 21:28:43 +000080 return 1U << ((pImpl->getAlignment() >> 16) - 1);
Bill Wendlinge66f3d32012-10-05 06:44:41 +000081}
82
83/// This returns the stack alignment field of an attribute as a byte alignment
84/// value.
Bill Wendling034b94b2012-12-19 07:18:57 +000085unsigned Attribute::getStackAlignment() const {
86 if (!hasAttribute(Attribute::StackAlignment))
Bill Wendling9ef99c92012-10-09 20:56:48 +000087 return 0;
Bill Wendling27107f62012-12-20 21:28:43 +000088 return 1U << ((pImpl->getStackAlignment() >> 26) - 1);
Bill Wendlinge66f3d32012-10-05 06:44:41 +000089}
90
Bill Wendlingc966e082012-12-30 01:05:42 +000091uint64_t Attribute::getBitMask() const {
92 return pImpl ? pImpl->getBitMask() : 0;
Bill Wendlingb10c88f2012-10-07 08:55:05 +000093}
94
Bill Wendling034b94b2012-12-19 07:18:57 +000095Attribute Attribute::typeIncompatible(Type *Ty) {
Bill Wendling702cc912012-10-15 20:35:56 +000096 AttrBuilder Incompatible;
Bill Wendling77898682012-10-16 06:01:44 +000097
Bill Wendling3a106e62012-10-09 19:01:18 +000098 if (!Ty->isIntegerTy())
Bill Wendling034b94b2012-12-19 07:18:57 +000099 // Attribute that only apply to integers.
100 Incompatible.addAttribute(Attribute::SExt)
101 .addAttribute(Attribute::ZExt);
Bill Wendling77898682012-10-16 06:01:44 +0000102
Bill Wendling3a106e62012-10-09 19:01:18 +0000103 if (!Ty->isPointerTy())
Bill Wendling034b94b2012-12-19 07:18:57 +0000104 // Attribute that only apply to pointers.
105 Incompatible.addAttribute(Attribute::ByVal)
106 .addAttribute(Attribute::Nest)
107 .addAttribute(Attribute::NoAlias)
108 .addAttribute(Attribute::NoCapture)
109 .addAttribute(Attribute::StructRet);
Bill Wendling77898682012-10-16 06:01:44 +0000110
Bill Wendling034b94b2012-12-19 07:18:57 +0000111 return Attribute::get(Ty->getContext(), Incompatible);
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000112}
113
Bill Wendling702cc912012-10-15 20:35:56 +0000114/// encodeLLVMAttributesForBitcode - This returns an integer containing an
115/// encoding of all the LLVM attributes found in the given attribute bitset.
116/// Any change to this encoding is a breaking change to bitcode compatibility.
Bill Wendling034b94b2012-12-19 07:18:57 +0000117uint64_t Attribute::encodeLLVMAttributesForBitcode(Attribute Attrs) {
Bill Wendling702cc912012-10-15 20:35:56 +0000118 // FIXME: It doesn't make sense to store the alignment information as an
119 // expanded out value, we should store it as a log2 value. However, we can't
120 // just change that here without breaking bitcode compatibility. If this ever
121 // becomes a problem in practice, we should introduce new tag numbers in the
122 // bitcode file and have those tags use a more efficiently encoded alignment
123 // field.
124
125 // Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit
126 // log2 encoded value. Shift the bits above the alignment up by 11 bits.
Bill Wendlingc966e082012-12-30 01:05:42 +0000127 uint64_t EncodedAttrs = Attrs.getBitMask() & 0xffff;
Bill Wendling034b94b2012-12-19 07:18:57 +0000128 if (Attrs.hasAttribute(Attribute::Alignment))
Bill Wendling702cc912012-10-15 20:35:56 +0000129 EncodedAttrs |= Attrs.getAlignment() << 16;
Bill Wendlingc966e082012-12-30 01:05:42 +0000130 EncodedAttrs |= (Attrs.getBitMask() & (0xffffULL << 21)) << 11;
Bill Wendling702cc912012-10-15 20:35:56 +0000131 return EncodedAttrs;
132}
133
134/// decodeLLVMAttributesForBitcode - This returns an attribute bitset containing
135/// the LLVM attributes that have been decoded from the given integer. This
136/// function must stay in sync with 'encodeLLVMAttributesForBitcode'.
Bill Wendling034b94b2012-12-19 07:18:57 +0000137Attribute Attribute::decodeLLVMAttributesForBitcode(LLVMContext &C,
Bill Wendling702cc912012-10-15 20:35:56 +0000138 uint64_t EncodedAttrs) {
139 // The alignment is stored as a 16-bit raw value from bits 31--16. We shift
140 // the bits above 31 down by 11 bits.
141 unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
142 assert((!Alignment || isPowerOf2_32(Alignment)) &&
143 "Alignment must be a power of two.");
144
145 AttrBuilder B(EncodedAttrs & 0xffff);
146 if (Alignment)
147 B.addAlignmentAttr(Alignment);
Nadav Roteme7439422012-10-22 17:33:31 +0000148 B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
Bill Wendling034b94b2012-12-19 07:18:57 +0000149 return Attribute::get(C, B);
Bill Wendling702cc912012-10-15 20:35:56 +0000150}
151
Bill Wendling034b94b2012-12-19 07:18:57 +0000152std::string Attribute::getAsString() const {
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000153 std::string Result;
Bill Wendling034b94b2012-12-19 07:18:57 +0000154 if (hasAttribute(Attribute::ZExt))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000155 Result += "zeroext ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000156 if (hasAttribute(Attribute::SExt))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000157 Result += "signext ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000158 if (hasAttribute(Attribute::NoReturn))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000159 Result += "noreturn ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000160 if (hasAttribute(Attribute::NoUnwind))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000161 Result += "nounwind ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000162 if (hasAttribute(Attribute::UWTable))
Rafael Espindolafc2bb8c2011-05-25 03:44:17 +0000163 Result += "uwtable ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000164 if (hasAttribute(Attribute::ReturnsTwice))
Rafael Espindola25456ef2011-10-03 14:45:37 +0000165 Result += "returns_twice ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000166 if (hasAttribute(Attribute::InReg))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000167 Result += "inreg ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000168 if (hasAttribute(Attribute::NoAlias))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000169 Result += "noalias ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000170 if (hasAttribute(Attribute::NoCapture))
Nick Lewycky73ddd4f2008-12-19 09:38:31 +0000171 Result += "nocapture ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000172 if (hasAttribute(Attribute::StructRet))
Anton Korobeynikovc5ec8a72009-07-17 18:07:26 +0000173 Result += "sret ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000174 if (hasAttribute(Attribute::ByVal))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000175 Result += "byval ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000176 if (hasAttribute(Attribute::Nest))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000177 Result += "nest ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000178 if (hasAttribute(Attribute::ReadNone))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000179 Result += "readnone ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000180 if (hasAttribute(Attribute::ReadOnly))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000181 Result += "readonly ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000182 if (hasAttribute(Attribute::OptimizeForSize))
Devang Patel19c87462008-09-26 22:53:05 +0000183 Result += "optsize ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000184 if (hasAttribute(Attribute::NoInline))
Devang Patel19c87462008-09-26 22:53:05 +0000185 Result += "noinline ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000186 if (hasAttribute(Attribute::InlineHint))
Jakob Stoklund Olesen570a4a52010-02-06 01:16:28 +0000187 Result += "inlinehint ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000188 if (hasAttribute(Attribute::AlwaysInline))
Devang Patel19c87462008-09-26 22:53:05 +0000189 Result += "alwaysinline ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000190 if (hasAttribute(Attribute::StackProtect))
Bill Wendlinge9e6bdf2008-11-13 01:02:14 +0000191 Result += "ssp ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000192 if (hasAttribute(Attribute::StackProtectReq))
Bill Wendlinge9e6bdf2008-11-13 01:02:14 +0000193 Result += "sspreq ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000194 if (hasAttribute(Attribute::NoRedZone))
Devang Pateld18e31a2009-06-04 22:05:33 +0000195 Result += "noredzone ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000196 if (hasAttribute(Attribute::NoImplicitFloat))
Devang Patel578efa92009-06-05 21:57:13 +0000197 Result += "noimplicitfloat ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000198 if (hasAttribute(Attribute::Naked))
Anton Korobeynikovc5ec8a72009-07-17 18:07:26 +0000199 Result += "naked ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000200 if (hasAttribute(Attribute::NonLazyBind))
John McCall3a3465b2011-06-15 20:36:13 +0000201 Result += "nonlazybind ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000202 if (hasAttribute(Attribute::AddressSafety))
Kostya Serebryany164b86b2012-01-20 17:56:17 +0000203 Result += "address_safety ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000204 if (hasAttribute(Attribute::MinSize))
Quentin Colombet9a419f62012-10-30 16:32:52 +0000205 Result += "minsize ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000206 if (hasAttribute(Attribute::StackAlignment)) {
Charles Davis1e063d12010-02-12 00:31:15 +0000207 Result += "alignstack(";
Bill Wendlingef99fe82012-09-21 15:26:31 +0000208 Result += utostr(getStackAlignment());
Charles Davis1e063d12010-02-12 00:31:15 +0000209 Result += ") ";
210 }
Bill Wendling034b94b2012-12-19 07:18:57 +0000211 if (hasAttribute(Attribute::Alignment)) {
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000212 Result += "align ";
Bill Wendlingef99fe82012-09-21 15:26:31 +0000213 Result += utostr(getAlignment());
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000214 Result += " ";
215 }
James Molloy67ae1352012-12-20 16:04:27 +0000216 if (hasAttribute(Attribute::NoDuplicate))
217 Result += "noduplicate ";
Dan Gohmanc3be0fd2008-08-05 15:51:44 +0000218 // Trim the trailing space.
Nick Lewycky73ddd4f2008-12-19 09:38:31 +0000219 assert(!Result.empty() && "Unknown attribute!");
Dan Gohmanc3be0fd2008-08-05 15:51:44 +0000220 Result.erase(Result.end()-1);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000221 return Result;
222}
223
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000224//===----------------------------------------------------------------------===//
Bill Wendling702cc912012-10-15 20:35:56 +0000225// AttrBuilder Implementation
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000226//===----------------------------------------------------------------------===//
227
Bill Wendling629fb822012-12-22 00:37:52 +0000228AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val){
Bill Wendlingf6670722012-12-20 01:36:59 +0000229 Bits |= AttributeImpl::getAttrMask(Val);
Bill Wendling3a106e62012-10-09 19:01:18 +0000230 return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000231}
232
Bill Wendling702cc912012-10-15 20:35:56 +0000233AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
Bill Wendlinga19a5302012-10-14 04:10:01 +0000234 Bits |= Val;
235 return *this;
236}
237
Bill Wendling702cc912012-10-15 20:35:56 +0000238AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) {
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000239 if (Align == 0) return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000240 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
241 assert(Align <= 0x40000000 && "Alignment too large.");
242 Bits |= (Log2_32(Align) + 1) << 16;
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000243 return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000244}
Bill Wendling702cc912012-10-15 20:35:56 +0000245AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align){
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000246 // Default alignment, allow the target to define how to align it.
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000247 if (Align == 0) return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000248 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
249 assert(Align <= 0x100 && "Alignment too large.");
250 Bits |= (Log2_32(Align) + 1) << 26;
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000251 return *this;
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000252}
253
Bill Wendling629fb822012-12-22 00:37:52 +0000254AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
Bill Wendlingf6670722012-12-20 01:36:59 +0000255 Bits &= ~AttributeImpl::getAttrMask(Val);
Bill Wendling3a106e62012-10-09 19:01:18 +0000256 return *this;
Bill Wendling2e879bc2012-10-09 09:11:20 +0000257}
258
Bill Wendling034b94b2012-12-19 07:18:57 +0000259AttrBuilder &AttrBuilder::addAttributes(const Attribute &A) {
Bill Wendlingc966e082012-12-30 01:05:42 +0000260 Bits |= A.getBitMask();
Bill Wendling432e6062012-10-14 07:17:34 +0000261 return *this;
262}
263
Bill Wendling034b94b2012-12-19 07:18:57 +0000264AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){
Bill Wendlingc966e082012-12-30 01:05:42 +0000265 Bits &= ~A.getBitMask();
Bill Wendling5886b7b2012-10-14 06:39:53 +0000266 return *this;
Bill Wendling8831c062012-10-09 00:01:21 +0000267}
268
Bill Wendling37766032012-12-30 09:17:46 +0000269bool AttrBuilder::contains(Attribute::AttrKind A) const {
Bill Wendlingf6670722012-12-20 01:36:59 +0000270 return Bits & AttributeImpl::getAttrMask(A);
Bill Wendling7d2f2492012-10-10 07:36:45 +0000271}
272
Bill Wendling702cc912012-10-15 20:35:56 +0000273bool AttrBuilder::hasAttributes() const {
Bill Wendlingf385f4c2012-10-08 23:27:46 +0000274 return Bits != 0;
275}
Bill Wendling034b94b2012-12-19 07:18:57 +0000276bool AttrBuilder::hasAttributes(const Attribute &A) const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000277 return Bits & A.getBitMask();
Bill Wendling8831c062012-10-09 00:01:21 +0000278}
Bill Wendling702cc912012-10-15 20:35:56 +0000279bool AttrBuilder::hasAlignmentAttr() const {
Bill Wendlingf6670722012-12-20 01:36:59 +0000280 return Bits & AttributeImpl::getAttrMask(Attribute::Alignment);
Bill Wendlingf385f4c2012-10-08 23:27:46 +0000281}
282
Bill Wendling702cc912012-10-15 20:35:56 +0000283uint64_t AttrBuilder::getAlignment() const {
Bill Wendling9ef99c92012-10-09 20:56:48 +0000284 if (!hasAlignmentAttr())
285 return 0;
NAKAMURA Takumi1fcbb8f2012-11-19 10:03:09 +0000286 return 1ULL <<
Bill Wendlingf6670722012-12-20 01:36:59 +0000287 (((Bits & AttributeImpl::getAttrMask(Attribute::Alignment)) >> 16) - 1);
Bill Wendlingf385f4c2012-10-08 23:27:46 +0000288}
289
Bill Wendling702cc912012-10-15 20:35:56 +0000290uint64_t AttrBuilder::getStackAlignment() const {
Bill Wendling7d2f2492012-10-10 07:36:45 +0000291 if (!hasAlignmentAttr())
292 return 0;
NAKAMURA Takumi1fcbb8f2012-11-19 10:03:09 +0000293 return 1ULL <<
Bill Wendlingf6670722012-12-20 01:36:59 +0000294 (((Bits & AttributeImpl::getAttrMask(Attribute::StackAlignment))>>26)-1);
Bill Wendling7d2f2492012-10-10 07:36:45 +0000295}
296
Chris Lattner58d74912008-03-12 17:45:29 +0000297//===----------------------------------------------------------------------===//
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000298// AttributeImpl Definition
299//===----------------------------------------------------------------------===//
300
Bill Wendling7c1683d2012-12-29 12:29:38 +0000301AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data) {
302 Data = ConstantInt::get(Type::getInt64Ty(C), data);
303}
Bill Wendling979aff62012-12-30 02:22:16 +0000304AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data) {
305 Data = ConstantInt::get(Type::getInt64Ty(C), data);
306}
307AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data,
308 ArrayRef<Constant*> values) {
309 Data = ConstantInt::get(Type::getInt64Ty(C), data);
310 Vals.reserve(values.size());
311 Vals.append(values.begin(), values.end());
312}
313AttributeImpl::AttributeImpl(LLVMContext &C, StringRef data) {
314 Data = ConstantDataArray::getString(C, data);
315}
Bill Wendling7c1683d2012-12-29 12:29:38 +0000316
Bill Wendling529ec712012-12-30 01:38:39 +0000317bool AttributeImpl::contains(Attribute::AttrKind Kind) const {
318 if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))
319 return CI->getZExtValue() == Kind;
320 return false;
321}
322
323bool AttributeImpl::contains(StringRef Kind) const {
324 if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data))
325 if (CDA->isString())
326 return CDA->getAsString() == Kind;
327 return false;
328}
329
Bill Wendlingc966e082012-12-30 01:05:42 +0000330uint64_t AttributeImpl::getBitMask() const {
Bill Wendling529ec712012-12-30 01:38:39 +0000331 // FIXME: Remove this.
Bill Wendling7c1683d2012-12-29 12:29:38 +0000332 return cast<ConstantInt>(Data)->getZExtValue();
333}
334
Bill Wendlingf6670722012-12-20 01:36:59 +0000335uint64_t AttributeImpl::getAttrMask(uint64_t Val) {
Bill Wendling67658342012-10-09 07:45:08 +0000336 switch (Val) {
Bill Wendling034b94b2012-12-19 07:18:57 +0000337 case Attribute::None: return 0;
338 case Attribute::ZExt: return 1 << 0;
339 case Attribute::SExt: return 1 << 1;
340 case Attribute::NoReturn: return 1 << 2;
341 case Attribute::InReg: return 1 << 3;
342 case Attribute::StructRet: return 1 << 4;
343 case Attribute::NoUnwind: return 1 << 5;
344 case Attribute::NoAlias: return 1 << 6;
345 case Attribute::ByVal: return 1 << 7;
346 case Attribute::Nest: return 1 << 8;
347 case Attribute::ReadNone: return 1 << 9;
348 case Attribute::ReadOnly: return 1 << 10;
349 case Attribute::NoInline: return 1 << 11;
350 case Attribute::AlwaysInline: return 1 << 12;
351 case Attribute::OptimizeForSize: return 1 << 13;
352 case Attribute::StackProtect: return 1 << 14;
353 case Attribute::StackProtectReq: return 1 << 15;
354 case Attribute::Alignment: return 31 << 16;
355 case Attribute::NoCapture: return 1 << 21;
356 case Attribute::NoRedZone: return 1 << 22;
357 case Attribute::NoImplicitFloat: return 1 << 23;
358 case Attribute::Naked: return 1 << 24;
359 case Attribute::InlineHint: return 1 << 25;
360 case Attribute::StackAlignment: return 7 << 26;
361 case Attribute::ReturnsTwice: return 1 << 29;
362 case Attribute::UWTable: return 1 << 30;
363 case Attribute::NonLazyBind: return 1U << 31;
364 case Attribute::AddressSafety: return 1ULL << 32;
365 case Attribute::MinSize: return 1ULL << 33;
James Molloy67ae1352012-12-20 16:04:27 +0000366 case Attribute::NoDuplicate: return 1ULL << 34;
Bill Wendling67658342012-10-09 07:45:08 +0000367 }
368 llvm_unreachable("Unsupported attribute type");
369}
370
Bill Wendlingf6670722012-12-20 01:36:59 +0000371bool AttributeImpl::hasAttribute(uint64_t A) const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000372 return (getBitMask() & getAttrMask(A)) != 0;
Bill Wendling8e635db2012-10-08 21:47:17 +0000373}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000374
Bill Wendlingf6670722012-12-20 01:36:59 +0000375bool AttributeImpl::hasAttributes() const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000376 return getBitMask() != 0;
Bill Wendling8e635db2012-10-08 21:47:17 +0000377}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000378
Bill Wendlingf6670722012-12-20 01:36:59 +0000379bool AttributeImpl::hasAttributes(const Attribute &A) const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000380 // FIXME: getBitMask() won't work here in the future.
381 return getBitMask() & A.getBitMask();
Bill Wendling8e635db2012-10-08 21:47:17 +0000382}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000383
Bill Wendlingf6670722012-12-20 01:36:59 +0000384uint64_t AttributeImpl::getAlignment() const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000385 return getBitMask() & getAttrMask(Attribute::Alignment);
Bill Wendling8e635db2012-10-08 21:47:17 +0000386}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000387
Bill Wendlingf6670722012-12-20 01:36:59 +0000388uint64_t AttributeImpl::getStackAlignment() const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000389 return getBitMask() & getAttrMask(Attribute::StackAlignment);
Bill Wendling8e635db2012-10-08 21:47:17 +0000390}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000391
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000392//===----------------------------------------------------------------------===//
Bill Wendling18e72112012-12-19 22:42:22 +0000393// AttributeSetImpl Definition
Chris Lattner58d74912008-03-12 17:45:29 +0000394//===----------------------------------------------------------------------===//
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000395
Bill Wendling99faa3b2012-12-07 23:16:57 +0000396AttributeSet AttributeSet::get(LLVMContext &C,
Bill Wendling1ce47ac2012-12-12 19:21:53 +0000397 ArrayRef<AttributeWithIndex> Attrs) {
Devang Patel05988662008-09-25 21:00:45 +0000398 // If there are no attributes then return a null AttributesList pointer.
Chris Lattnerd509d0b2012-05-28 01:47:44 +0000399 if (Attrs.empty())
Bill Wendling99faa3b2012-12-07 23:16:57 +0000400 return AttributeSet();
Bill Wendling77898682012-10-16 06:01:44 +0000401
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000402#ifndef NDEBUG
Chris Lattnerd509d0b2012-05-28 01:47:44 +0000403 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
Bill Wendling77898682012-10-16 06:01:44 +0000404 assert(Attrs[i].Attrs.hasAttributes() &&
Devang Patel05988662008-09-25 21:00:45 +0000405 "Pointless attribute!");
Chris Lattner58d74912008-03-12 17:45:29 +0000406 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
Devang Patel05988662008-09-25 21:00:45 +0000407 "Misordered AttributesList!");
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000408 }
409#endif
Bill Wendling77898682012-10-16 06:01:44 +0000410
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000411 // Otherwise, build a key to look up the existing attributes.
Bill Wendling0976e002012-11-20 05:09:20 +0000412 LLVMContextImpl *pImpl = C.pImpl;
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000413 FoldingSetNodeID ID;
Bill Wendling18e72112012-12-19 22:42:22 +0000414 AttributeSetImpl::Profile(ID, Attrs);
Bill Wendling77898682012-10-16 06:01:44 +0000415
Bill Wendling0976e002012-11-20 05:09:20 +0000416 void *InsertPoint;
Bill Wendling18e72112012-12-19 22:42:22 +0000417 AttributeSetImpl *PA = pImpl->AttrsLists.FindNodeOrInsertPos(ID,
Bill Wendling0976e002012-11-20 05:09:20 +0000418 InsertPoint);
Bill Wendling77898682012-10-16 06:01:44 +0000419
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000420 // If we didn't find any existing attributes of the same shape then
421 // create a new one and insert it.
Bill Wendling0976e002012-11-20 05:09:20 +0000422 if (!PA) {
Bill Wendling5f93e2b2012-12-19 23:55:43 +0000423 PA = new AttributeSetImpl(C, Attrs);
Bill Wendling0976e002012-11-20 05:09:20 +0000424 pImpl->AttrsLists.InsertNode(PA, InsertPoint);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000425 }
Bill Wendling77898682012-10-16 06:01:44 +0000426
Devang Patel05988662008-09-25 21:00:45 +0000427 // Return the AttributesList that we found or created.
Bill Wendling99faa3b2012-12-07 23:16:57 +0000428 return AttributeSet(PA);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000429}
430
Chris Lattner58d74912008-03-12 17:45:29 +0000431//===----------------------------------------------------------------------===//
Bill Wendling99faa3b2012-12-07 23:16:57 +0000432// AttributeSet Method Implementations
Chris Lattner58d74912008-03-12 17:45:29 +0000433//===----------------------------------------------------------------------===//
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000434
Bill Wendling99faa3b2012-12-07 23:16:57 +0000435const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) {
Bill Wendling0976e002012-11-20 05:09:20 +0000436 AttrList = RHS.AttrList;
437 return *this;
Chris Lattner58d74912008-03-12 17:45:29 +0000438}
439
Bill Wendling77898682012-10-16 06:01:44 +0000440/// getNumSlots - Return the number of slots used in this attribute list.
Chris Lattner58d74912008-03-12 17:45:29 +0000441/// This is the number of arguments that have an attribute set on them
442/// (including the function itself).
Bill Wendling99faa3b2012-12-07 23:16:57 +0000443unsigned AttributeSet::getNumSlots() const {
Devang Patel05988662008-09-25 21:00:45 +0000444 return AttrList ? AttrList->Attrs.size() : 0;
Chris Lattner58d74912008-03-12 17:45:29 +0000445}
446
Devang Patel05988662008-09-25 21:00:45 +0000447/// getSlot - Return the AttributeWithIndex at the specified slot. This
448/// holds a number plus a set of attributes.
Bill Wendling99faa3b2012-12-07 23:16:57 +0000449const AttributeWithIndex &AttributeSet::getSlot(unsigned Slot) const {
Devang Patel05988662008-09-25 21:00:45 +0000450 assert(AttrList && Slot < AttrList->Attrs.size() && "Slot # out of range!");
451 return AttrList->Attrs[Slot];
Chris Lattner58d74912008-03-12 17:45:29 +0000452}
453
Bill Wendling831737d2012-12-30 10:32:01 +0000454bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{
455 return getAttributes(Index).hasAttribute(Kind);
456}
457
458bool AttributeSet::hasAttributes(unsigned Index) const {
459 return getAttributes(Index).hasAttributes();
460}
461
462std::string AttributeSet::getAsString(unsigned Index) const {
463 return getAttributes(Index).getAsString();
464}
465
466unsigned AttributeSet::getStackAlignment(unsigned Index) const {
467 return getAttributes(Index).getStackAlignment();
468}
469
470uint64_t AttributeSet::getBitMask(unsigned Index) const {
471 // FIXME: Remove this.
472 return getAttributes(Index).getBitMask();
473}
474
Bill Wendling77898682012-10-16 06:01:44 +0000475/// getAttributes - The attributes for the specified index are returned.
Bill Wendling034b94b2012-12-19 07:18:57 +0000476/// Attribute for the result are denoted with Idx = 0. Function notes are
Bill Wendling77898682012-10-16 06:01:44 +0000477/// denoted with idx = ~0.
Bill Wendling034b94b2012-12-19 07:18:57 +0000478Attribute AttributeSet::getAttributes(unsigned Idx) const {
479 if (AttrList == 0) return Attribute();
Bill Wendling77898682012-10-16 06:01:44 +0000480
Devang Patel05988662008-09-25 21:00:45 +0000481 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner58d74912008-03-12 17:45:29 +0000482 for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
483 if (Attrs[i].Index == Idx)
484 return Attrs[i].Attrs;
Bill Wendlingef99fe82012-09-21 15:26:31 +0000485
Bill Wendling034b94b2012-12-19 07:18:57 +0000486 return Attribute();
Chris Lattner58d74912008-03-12 17:45:29 +0000487}
488
489/// hasAttrSomewhere - Return true if the specified attribute is set for at
490/// least one parameter or for the return value.
Bill Wendling629fb822012-12-22 00:37:52 +0000491bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
Devang Patel05988662008-09-25 21:00:45 +0000492 if (AttrList == 0) return false;
Bill Wendling7d2f2492012-10-10 07:36:45 +0000493
Devang Patel05988662008-09-25 21:00:45 +0000494 const SmallVector<AttributeWithIndex, 4> &Attrs = AttrList->Attrs;
Chris Lattner58d74912008-03-12 17:45:29 +0000495 for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
Bill Wendling7d2f2492012-10-10 07:36:45 +0000496 if (Attrs[i].Attrs.hasAttribute(Attr))
Chris Lattner58d74912008-03-12 17:45:29 +0000497 return true;
Bill Wendling0976e002012-11-20 05:09:20 +0000498
Chris Lattner58d74912008-03-12 17:45:29 +0000499 return false;
500}
501
Bill Wendling99faa3b2012-12-07 23:16:57 +0000502unsigned AttributeSet::getNumAttrs() const {
Bill Wendling8831c062012-10-09 00:01:21 +0000503 return AttrList ? AttrList->Attrs.size() : 0;
504}
505
Bill Wendling034b94b2012-12-19 07:18:57 +0000506Attribute &AttributeSet::getAttributesAtIndex(unsigned i) const {
Bill Wendling8831c062012-10-09 00:01:21 +0000507 assert(AttrList && "Trying to get an attribute from an empty list!");
508 assert(i < AttrList->Attrs.size() && "Index out of range!");
509 return AttrList->Attrs[i].Attrs;
510}
Chris Lattner58d74912008-03-12 17:45:29 +0000511
Bill Wendling99faa3b2012-12-07 23:16:57 +0000512AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
Bill Wendling034b94b2012-12-19 07:18:57 +0000513 Attribute Attrs) const {
514 Attribute OldAttrs = getAttributes(Idx);
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000515#ifndef NDEBUG
516 // FIXME it is not obvious how this should work for alignment.
517 // For now, say we can't change a known alignment.
Bill Wendlingef99fe82012-09-21 15:26:31 +0000518 unsigned OldAlign = OldAttrs.getAlignment();
519 unsigned NewAlign = Attrs.getAlignment();
Anton Korobeynikov4aefd6b2008-02-20 12:07:57 +0000520 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000521 "Attempt to change alignment!");
522#endif
Bill Wendling77898682012-10-16 06:01:44 +0000523
Bill Wendling702cc912012-10-15 20:35:56 +0000524 AttrBuilder NewAttrs =
525 AttrBuilder(OldAttrs).addAttributes(Attrs);
526 if (NewAttrs == AttrBuilder(OldAttrs))
Chris Lattner58d74912008-03-12 17:45:29 +0000527 return *this;
Bill Wendling77898682012-10-16 06:01:44 +0000528
Devang Patel05988662008-09-25 21:00:45 +0000529 SmallVector<AttributeWithIndex, 8> NewAttrList;
530 if (AttrList == 0)
531 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner58d74912008-03-12 17:45:29 +0000532 else {
Devang Patel05988662008-09-25 21:00:45 +0000533 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner58d74912008-03-12 17:45:29 +0000534 unsigned i = 0, e = OldAttrList.size();
535 // Copy attributes for arguments before this one.
536 for (; i != e && OldAttrList[i].Index < Idx; ++i)
537 NewAttrList.push_back(OldAttrList[i]);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000538
Chris Lattner58d74912008-03-12 17:45:29 +0000539 // If there are attributes already at this index, merge them in.
540 if (i != e && OldAttrList[i].Index == Idx) {
Bill Wendlingc4167952012-10-14 07:35:59 +0000541 Attrs =
Bill Wendling034b94b2012-12-19 07:18:57 +0000542 Attribute::get(C, AttrBuilder(Attrs).
Bill Wendlingc4167952012-10-14 07:35:59 +0000543 addAttributes(OldAttrList[i].Attrs));
Chris Lattner58d74912008-03-12 17:45:29 +0000544 ++i;
545 }
Bill Wendling77898682012-10-16 06:01:44 +0000546
Devang Patel05988662008-09-25 21:00:45 +0000547 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Bill Wendling77898682012-10-16 06:01:44 +0000548
Chris Lattner58d74912008-03-12 17:45:29 +0000549 // Copy attributes for arguments after this one.
Bill Wendling77898682012-10-16 06:01:44 +0000550 NewAttrList.insert(NewAttrList.end(),
Chris Lattner58d74912008-03-12 17:45:29 +0000551 OldAttrList.begin()+i, OldAttrList.end());
552 }
Bill Wendling77898682012-10-16 06:01:44 +0000553
Bill Wendling0976e002012-11-20 05:09:20 +0000554 return get(C, NewAttrList);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000555}
556
Bill Wendling99faa3b2012-12-07 23:16:57 +0000557AttributeSet AttributeSet::removeAttr(LLVMContext &C, unsigned Idx,
Bill Wendling034b94b2012-12-19 07:18:57 +0000558 Attribute Attrs) const {
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000559#ifndef NDEBUG
560 // FIXME it is not obvious how this should work for alignment.
561 // For now, say we can't pass in alignment, which no current use does.
Bill Wendling034b94b2012-12-19 07:18:57 +0000562 assert(!Attrs.hasAttribute(Attribute::Alignment) &&
Bill Wendling67658342012-10-09 07:45:08 +0000563 "Attempt to exclude alignment!");
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000564#endif
Bill Wendling99faa3b2012-12-07 23:16:57 +0000565 if (AttrList == 0) return AttributeSet();
Bill Wendling77898682012-10-16 06:01:44 +0000566
Bill Wendling034b94b2012-12-19 07:18:57 +0000567 Attribute OldAttrs = getAttributes(Idx);
Bill Wendling702cc912012-10-15 20:35:56 +0000568 AttrBuilder NewAttrs =
569 AttrBuilder(OldAttrs).removeAttributes(Attrs);
570 if (NewAttrs == AttrBuilder(OldAttrs))
Chris Lattner58d74912008-03-12 17:45:29 +0000571 return *this;
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000572
Devang Patel05988662008-09-25 21:00:45 +0000573 SmallVector<AttributeWithIndex, 8> NewAttrList;
574 const SmallVector<AttributeWithIndex, 4> &OldAttrList = AttrList->Attrs;
Chris Lattner58d74912008-03-12 17:45:29 +0000575 unsigned i = 0, e = OldAttrList.size();
Bill Wendling77898682012-10-16 06:01:44 +0000576
Chris Lattner58d74912008-03-12 17:45:29 +0000577 // Copy attributes for arguments before this one.
578 for (; i != e && OldAttrList[i].Index < Idx; ++i)
579 NewAttrList.push_back(OldAttrList[i]);
Bill Wendling77898682012-10-16 06:01:44 +0000580
Chris Lattner58d74912008-03-12 17:45:29 +0000581 // If there are attributes already at this index, merge them in.
582 assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
Bill Wendling034b94b2012-12-19 07:18:57 +0000583 Attrs = Attribute::get(C, AttrBuilder(OldAttrList[i].Attrs).
Bill Wendling5886b7b2012-10-14 06:39:53 +0000584 removeAttributes(Attrs));
Chris Lattner58d74912008-03-12 17:45:29 +0000585 ++i;
Bill Wendling7be78482012-10-14 08:54:26 +0000586 if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
Devang Patel05988662008-09-25 21:00:45 +0000587 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Bill Wendling77898682012-10-16 06:01:44 +0000588
Chris Lattner58d74912008-03-12 17:45:29 +0000589 // Copy attributes for arguments after this one.
Bill Wendling77898682012-10-16 06:01:44 +0000590 NewAttrList.insert(NewAttrList.end(),
Chris Lattner58d74912008-03-12 17:45:29 +0000591 OldAttrList.begin()+i, OldAttrList.end());
Bill Wendling77898682012-10-16 06:01:44 +0000592
Bill Wendling0976e002012-11-20 05:09:20 +0000593 return get(C, NewAttrList);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000594}
595
Bill Wendling99faa3b2012-12-07 23:16:57 +0000596void AttributeSet::dump() const {
David Greeneef1894e2010-01-05 01:29:58 +0000597 dbgs() << "PAL[ ";
Chris Lattner58d74912008-03-12 17:45:29 +0000598 for (unsigned i = 0; i < getNumSlots(); ++i) {
Devang Patel05988662008-09-25 21:00:45 +0000599 const AttributeWithIndex &PAWI = getSlot(i);
Bill Wendling7be78482012-10-14 08:54:26 +0000600 dbgs() << "{" << PAWI.Index << "," << PAWI.Attrs.getAsString() << "} ";
Chris Lattner58d74912008-03-12 17:45:29 +0000601 }
Bill Wendling77898682012-10-16 06:01:44 +0000602
David Greeneef1894e2010-01-05 01:29:58 +0000603 dbgs() << "]\n";
Duncan Sandsad9a9e12008-01-06 18:27:01 +0000604}