blob: 5057f783bb5a727ba8c64255c84e3281c7d4f422 [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
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000015#include "llvm/IR/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"
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000020#include "llvm/IR/Type.h"
Michael J. Spencer1f6efa32010-11-29 18:16:10 +000021#include "llvm/Support/Atomic.h"
David Greeneef1894e2010-01-05 01:29:58 +000022#include "llvm/Support/Debug.h"
Chris Lattner50ee9dd2008-01-02 23:42:30 +000023#include "llvm/Support/ManagedStatic.h"
Chandler Carruthd04a8d42012-12-03 16:50:05 +000024#include "llvm/Support/Mutex.h"
Benjamin Kramercfa6ec92009-08-23 11:37:21 +000025#include "llvm/Support/raw_ostream.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 Wendlinge66f3d32012-10-05 06:44:41 +000072/// This returns the alignment field of an attribute as a byte alignment value.
Bill Wendling034b94b2012-12-19 07:18:57 +000073unsigned Attribute::getAlignment() const {
74 if (!hasAttribute(Attribute::Alignment))
Bill Wendling9ef99c92012-10-09 20:56:48 +000075 return 0;
Bill Wendling27107f62012-12-20 21:28:43 +000076 return 1U << ((pImpl->getAlignment() >> 16) - 1);
Bill Wendlinge66f3d32012-10-05 06:44:41 +000077}
78
79/// This returns the stack alignment field of an attribute as a byte alignment
80/// value.
Bill Wendling034b94b2012-12-19 07:18:57 +000081unsigned Attribute::getStackAlignment() const {
82 if (!hasAttribute(Attribute::StackAlignment))
Bill Wendling9ef99c92012-10-09 20:56:48 +000083 return 0;
Bill Wendling27107f62012-12-20 21:28:43 +000084 return 1U << ((pImpl->getStackAlignment() >> 26) - 1);
Bill Wendlinge66f3d32012-10-05 06:44:41 +000085}
86
Bill Wendling92e287f2012-12-31 11:51:54 +000087bool Attribute::operator==(AttrKind K) const {
Bill Wendling60507d52013-01-04 20:54:35 +000088 return pImpl && *pImpl == K;
Bill Wendling92e287f2012-12-31 11:51:54 +000089}
Bill Wendling92e287f2012-12-31 11:51:54 +000090bool Attribute::operator!=(AttrKind K) const {
Bill Wendling60507d52013-01-04 20:54:35 +000091 return !(*this == K);
Bill Wendling92e287f2012-12-31 11:51:54 +000092}
93
Bill Wendlingc966e082012-12-30 01:05:42 +000094uint64_t Attribute::getBitMask() const {
95 return pImpl ? pImpl->getBitMask() : 0;
Bill Wendlingb10c88f2012-10-07 08:55:05 +000096}
97
Bill Wendling034b94b2012-12-19 07:18:57 +000098Attribute Attribute::typeIncompatible(Type *Ty) {
Bill Wendling702cc912012-10-15 20:35:56 +000099 AttrBuilder Incompatible;
Bill Wendling77898682012-10-16 06:01:44 +0000100
Bill Wendling3a106e62012-10-09 19:01:18 +0000101 if (!Ty->isIntegerTy())
Bill Wendling034b94b2012-12-19 07:18:57 +0000102 // Attribute that only apply to integers.
103 Incompatible.addAttribute(Attribute::SExt)
104 .addAttribute(Attribute::ZExt);
Bill Wendling77898682012-10-16 06:01:44 +0000105
Bill Wendling3a106e62012-10-09 19:01:18 +0000106 if (!Ty->isPointerTy())
Bill Wendling034b94b2012-12-19 07:18:57 +0000107 // Attribute that only apply to pointers.
108 Incompatible.addAttribute(Attribute::ByVal)
109 .addAttribute(Attribute::Nest)
110 .addAttribute(Attribute::NoAlias)
111 .addAttribute(Attribute::NoCapture)
112 .addAttribute(Attribute::StructRet);
Bill Wendling77898682012-10-16 06:01:44 +0000113
Bill Wendling034b94b2012-12-19 07:18:57 +0000114 return Attribute::get(Ty->getContext(), Incompatible);
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000115}
116
Bill Wendling702cc912012-10-15 20:35:56 +0000117/// encodeLLVMAttributesForBitcode - This returns an integer containing an
118/// encoding of all the LLVM attributes found in the given attribute bitset.
119/// Any change to this encoding is a breaking change to bitcode compatibility.
Bill Wendling034b94b2012-12-19 07:18:57 +0000120uint64_t Attribute::encodeLLVMAttributesForBitcode(Attribute Attrs) {
Bill Wendling702cc912012-10-15 20:35:56 +0000121 // FIXME: It doesn't make sense to store the alignment information as an
122 // expanded out value, we should store it as a log2 value. However, we can't
123 // just change that here without breaking bitcode compatibility. If this ever
124 // becomes a problem in practice, we should introduce new tag numbers in the
125 // bitcode file and have those tags use a more efficiently encoded alignment
126 // field.
127
128 // Store the alignment in the bitcode as a 16-bit raw value instead of a 5-bit
129 // log2 encoded value. Shift the bits above the alignment up by 11 bits.
Bill Wendlingc966e082012-12-30 01:05:42 +0000130 uint64_t EncodedAttrs = Attrs.getBitMask() & 0xffff;
Bill Wendling034b94b2012-12-19 07:18:57 +0000131 if (Attrs.hasAttribute(Attribute::Alignment))
Bill Wendling702cc912012-10-15 20:35:56 +0000132 EncodedAttrs |= Attrs.getAlignment() << 16;
Bill Wendlingc966e082012-12-30 01:05:42 +0000133 EncodedAttrs |= (Attrs.getBitMask() & (0xffffULL << 21)) << 11;
Bill Wendling702cc912012-10-15 20:35:56 +0000134 return EncodedAttrs;
135}
136
137/// decodeLLVMAttributesForBitcode - This returns an attribute bitset containing
138/// the LLVM attributes that have been decoded from the given integer. This
139/// function must stay in sync with 'encodeLLVMAttributesForBitcode'.
Bill Wendling034b94b2012-12-19 07:18:57 +0000140Attribute Attribute::decodeLLVMAttributesForBitcode(LLVMContext &C,
Bill Wendling702cc912012-10-15 20:35:56 +0000141 uint64_t EncodedAttrs) {
142 // The alignment is stored as a 16-bit raw value from bits 31--16. We shift
143 // the bits above 31 down by 11 bits.
144 unsigned Alignment = (EncodedAttrs & (0xffffULL << 16)) >> 16;
145 assert((!Alignment || isPowerOf2_32(Alignment)) &&
146 "Alignment must be a power of two.");
147
148 AttrBuilder B(EncodedAttrs & 0xffff);
149 if (Alignment)
150 B.addAlignmentAttr(Alignment);
Nadav Roteme7439422012-10-22 17:33:31 +0000151 B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
Bill Wendling034b94b2012-12-19 07:18:57 +0000152 return Attribute::get(C, B);
Bill Wendling702cc912012-10-15 20:35:56 +0000153}
154
Bill Wendling034b94b2012-12-19 07:18:57 +0000155std::string Attribute::getAsString() const {
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000156 std::string Result;
Bill Wendling034b94b2012-12-19 07:18:57 +0000157 if (hasAttribute(Attribute::ZExt))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000158 Result += "zeroext ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000159 if (hasAttribute(Attribute::SExt))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000160 Result += "signext ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000161 if (hasAttribute(Attribute::NoReturn))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000162 Result += "noreturn ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000163 if (hasAttribute(Attribute::NoUnwind))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000164 Result += "nounwind ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000165 if (hasAttribute(Attribute::UWTable))
Rafael Espindolafc2bb8c2011-05-25 03:44:17 +0000166 Result += "uwtable ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000167 if (hasAttribute(Attribute::ReturnsTwice))
Rafael Espindola25456ef2011-10-03 14:45:37 +0000168 Result += "returns_twice ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000169 if (hasAttribute(Attribute::InReg))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000170 Result += "inreg ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000171 if (hasAttribute(Attribute::NoAlias))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000172 Result += "noalias ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000173 if (hasAttribute(Attribute::NoCapture))
Nick Lewycky73ddd4f2008-12-19 09:38:31 +0000174 Result += "nocapture ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000175 if (hasAttribute(Attribute::StructRet))
Anton Korobeynikovc5ec8a72009-07-17 18:07:26 +0000176 Result += "sret ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000177 if (hasAttribute(Attribute::ByVal))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000178 Result += "byval ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000179 if (hasAttribute(Attribute::Nest))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000180 Result += "nest ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000181 if (hasAttribute(Attribute::ReadNone))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000182 Result += "readnone ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000183 if (hasAttribute(Attribute::ReadOnly))
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000184 Result += "readonly ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000185 if (hasAttribute(Attribute::OptimizeForSize))
Devang Patel19c87462008-09-26 22:53:05 +0000186 Result += "optsize ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000187 if (hasAttribute(Attribute::NoInline))
Devang Patel19c87462008-09-26 22:53:05 +0000188 Result += "noinline ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000189 if (hasAttribute(Attribute::InlineHint))
Jakob Stoklund Olesen570a4a52010-02-06 01:16:28 +0000190 Result += "inlinehint ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000191 if (hasAttribute(Attribute::AlwaysInline))
Devang Patel19c87462008-09-26 22:53:05 +0000192 Result += "alwaysinline ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000193 if (hasAttribute(Attribute::StackProtect))
Bill Wendlinge9e6bdf2008-11-13 01:02:14 +0000194 Result += "ssp ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000195 if (hasAttribute(Attribute::StackProtectReq))
Bill Wendlinge9e6bdf2008-11-13 01:02:14 +0000196 Result += "sspreq ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000197 if (hasAttribute(Attribute::NoRedZone))
Devang Pateld18e31a2009-06-04 22:05:33 +0000198 Result += "noredzone ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000199 if (hasAttribute(Attribute::NoImplicitFloat))
Devang Patel578efa92009-06-05 21:57:13 +0000200 Result += "noimplicitfloat ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000201 if (hasAttribute(Attribute::Naked))
Anton Korobeynikovc5ec8a72009-07-17 18:07:26 +0000202 Result += "naked ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000203 if (hasAttribute(Attribute::NonLazyBind))
John McCall3a3465b2011-06-15 20:36:13 +0000204 Result += "nonlazybind ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000205 if (hasAttribute(Attribute::AddressSafety))
Kostya Serebryany164b86b2012-01-20 17:56:17 +0000206 Result += "address_safety ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000207 if (hasAttribute(Attribute::MinSize))
Quentin Colombet9a419f62012-10-30 16:32:52 +0000208 Result += "minsize ";
Bill Wendling034b94b2012-12-19 07:18:57 +0000209 if (hasAttribute(Attribute::StackAlignment)) {
Charles Davis1e063d12010-02-12 00:31:15 +0000210 Result += "alignstack(";
Bill Wendlingef99fe82012-09-21 15:26:31 +0000211 Result += utostr(getStackAlignment());
Charles Davis1e063d12010-02-12 00:31:15 +0000212 Result += ") ";
213 }
Bill Wendling034b94b2012-12-19 07:18:57 +0000214 if (hasAttribute(Attribute::Alignment)) {
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000215 Result += "align ";
Bill Wendlingef99fe82012-09-21 15:26:31 +0000216 Result += utostr(getAlignment());
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000217 Result += " ";
218 }
James Molloy67ae1352012-12-20 16:04:27 +0000219 if (hasAttribute(Attribute::NoDuplicate))
220 Result += "noduplicate ";
Dan Gohmanc3be0fd2008-08-05 15:51:44 +0000221 // Trim the trailing space.
Nick Lewycky73ddd4f2008-12-19 09:38:31 +0000222 assert(!Result.empty() && "Unknown attribute!");
Dan Gohmanc3be0fd2008-08-05 15:51:44 +0000223 Result.erase(Result.end()-1);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000224 return Result;
225}
226
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000227//===----------------------------------------------------------------------===//
Bill Wendling702cc912012-10-15 20:35:56 +0000228// AttrBuilder Implementation
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000229//===----------------------------------------------------------------------===//
230
Bill Wendling629fb822012-12-22 00:37:52 +0000231AttrBuilder &AttrBuilder::addAttribute(Attribute::AttrKind Val){
Bill Wendlingf6670722012-12-20 01:36:59 +0000232 Bits |= AttributeImpl::getAttrMask(Val);
Bill Wendling3a106e62012-10-09 19:01:18 +0000233 return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000234}
235
Bill Wendling702cc912012-10-15 20:35:56 +0000236AttrBuilder &AttrBuilder::addRawValue(uint64_t Val) {
Bill Wendlinga19a5302012-10-14 04:10:01 +0000237 Bits |= Val;
238 return *this;
239}
240
Bill Wendling702cc912012-10-15 20:35:56 +0000241AttrBuilder &AttrBuilder::addAlignmentAttr(unsigned Align) {
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000242 if (Align == 0) return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000243 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
244 assert(Align <= 0x40000000 && "Alignment too large.");
245 Bits |= (Log2_32(Align) + 1) << 16;
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000246 return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000247}
Bill Wendlinge5ab1be2013-01-03 02:01:50 +0000248AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align){
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000249 // Default alignment, allow the target to define how to align it.
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000250 if (Align == 0) return *this;
Bill Wendlinge66f3d32012-10-05 06:44:41 +0000251 assert(isPowerOf2_32(Align) && "Alignment must be a power of two.");
252 assert(Align <= 0x100 && "Alignment too large.");
253 Bits |= (Log2_32(Align) + 1) << 26;
Bill Wendlingda3f9d82012-10-14 03:58:29 +0000254 return *this;
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000255}
256
Bill Wendling629fb822012-12-22 00:37:52 +0000257AttrBuilder &AttrBuilder::removeAttribute(Attribute::AttrKind Val) {
Bill Wendlingf6670722012-12-20 01:36:59 +0000258 Bits &= ~AttributeImpl::getAttrMask(Val);
Bill Wendling3a106e62012-10-09 19:01:18 +0000259 return *this;
Bill Wendling2e879bc2012-10-09 09:11:20 +0000260}
261
Bill Wendling034b94b2012-12-19 07:18:57 +0000262AttrBuilder &AttrBuilder::addAttributes(const Attribute &A) {
Bill Wendlingc966e082012-12-30 01:05:42 +0000263 Bits |= A.getBitMask();
Bill Wendling432e6062012-10-14 07:17:34 +0000264 return *this;
265}
266
Bill Wendling034b94b2012-12-19 07:18:57 +0000267AttrBuilder &AttrBuilder::removeAttributes(const Attribute &A){
Bill Wendlingc966e082012-12-30 01:05:42 +0000268 Bits &= ~A.getBitMask();
Bill Wendling5886b7b2012-10-14 06:39:53 +0000269 return *this;
Bill Wendling8831c062012-10-09 00:01:21 +0000270}
271
Bill Wendling22bd6412013-01-03 01:54:39 +0000272bool AttrBuilder::contains(Attribute::AttrKind A) const {
Bill Wendlingf6670722012-12-20 01:36:59 +0000273 return Bits & AttributeImpl::getAttrMask(A);
Bill Wendling7d2f2492012-10-10 07:36:45 +0000274}
275
Bill Wendling702cc912012-10-15 20:35:56 +0000276bool AttrBuilder::hasAttributes() const {
Bill Wendlingf385f4c2012-10-08 23:27:46 +0000277 return Bits != 0;
278}
Bill Wendling60507d52013-01-04 20:54:35 +0000279
Bill Wendling034b94b2012-12-19 07:18:57 +0000280bool AttrBuilder::hasAttributes(const Attribute &A) const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000281 return Bits & A.getBitMask();
Bill Wendling8831c062012-10-09 00:01:21 +0000282}
Bill Wendling60507d52013-01-04 20:54:35 +0000283
Bill Wendling702cc912012-10-15 20:35:56 +0000284bool AttrBuilder::hasAlignmentAttr() const {
Bill Wendlingf6670722012-12-20 01:36:59 +0000285 return Bits & AttributeImpl::getAttrMask(Attribute::Alignment);
Bill Wendlingf385f4c2012-10-08 23:27:46 +0000286}
287
Bill Wendling702cc912012-10-15 20:35:56 +0000288uint64_t AttrBuilder::getAlignment() const {
Bill Wendling9ef99c92012-10-09 20:56:48 +0000289 if (!hasAlignmentAttr())
290 return 0;
NAKAMURA Takumi1fcbb8f2012-11-19 10:03:09 +0000291 return 1ULL <<
Bill Wendlingf6670722012-12-20 01:36:59 +0000292 (((Bits & AttributeImpl::getAttrMask(Attribute::Alignment)) >> 16) - 1);
Bill Wendlingf385f4c2012-10-08 23:27:46 +0000293}
294
Bill Wendling702cc912012-10-15 20:35:56 +0000295uint64_t AttrBuilder::getStackAlignment() const {
Bill Wendling7d2f2492012-10-10 07:36:45 +0000296 if (!hasAlignmentAttr())
297 return 0;
NAKAMURA Takumi1fcbb8f2012-11-19 10:03:09 +0000298 return 1ULL <<
Bill Wendlingf6670722012-12-20 01:36:59 +0000299 (((Bits & AttributeImpl::getAttrMask(Attribute::StackAlignment))>>26)-1);
Bill Wendling7d2f2492012-10-10 07:36:45 +0000300}
301
Chris Lattner58d74912008-03-12 17:45:29 +0000302//===----------------------------------------------------------------------===//
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000303// AttributeImpl Definition
304//===----------------------------------------------------------------------===//
305
Bill Wendling7c1683d2012-12-29 12:29:38 +0000306AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data) {
307 Data = ConstantInt::get(Type::getInt64Ty(C), data);
308}
Bill Wendling979aff62012-12-30 02:22:16 +0000309AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data) {
310 Data = ConstantInt::get(Type::getInt64Ty(C), data);
311}
312AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind data,
313 ArrayRef<Constant*> values) {
314 Data = ConstantInt::get(Type::getInt64Ty(C), data);
315 Vals.reserve(values.size());
316 Vals.append(values.begin(), values.end());
317}
318AttributeImpl::AttributeImpl(LLVMContext &C, StringRef data) {
319 Data = ConstantDataArray::getString(C, data);
320}
Bill Wendling7c1683d2012-12-29 12:29:38 +0000321
Bill Wendling60507d52013-01-04 20:54:35 +0000322bool AttributeImpl::operator==(Attribute::AttrKind Kind) const {
Bill Wendling529ec712012-12-30 01:38:39 +0000323 if (ConstantInt *CI = dyn_cast<ConstantInt>(Data))
324 return CI->getZExtValue() == Kind;
325 return false;
326}
Bill Wendling60507d52013-01-04 20:54:35 +0000327bool AttributeImpl::operator!=(Attribute::AttrKind Kind) const {
328 return !(*this == Kind);
329}
Bill Wendling529ec712012-12-30 01:38:39 +0000330
Bill Wendling60507d52013-01-04 20:54:35 +0000331bool AttributeImpl::operator==(StringRef Kind) const {
Bill Wendling529ec712012-12-30 01:38:39 +0000332 if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data))
333 if (CDA->isString())
334 return CDA->getAsString() == Kind;
335 return false;
336}
Bill Wendling60507d52013-01-04 20:54:35 +0000337bool AttributeImpl::operator!=(StringRef Kind) const {
338 return !(*this == Kind);
339}
Bill Wendling529ec712012-12-30 01:38:39 +0000340
Bill Wendlingc966e082012-12-30 01:05:42 +0000341uint64_t AttributeImpl::getBitMask() const {
Bill Wendling529ec712012-12-30 01:38:39 +0000342 // FIXME: Remove this.
Bill Wendling7c1683d2012-12-29 12:29:38 +0000343 return cast<ConstantInt>(Data)->getZExtValue();
344}
345
Bill Wendling60507d52013-01-04 20:54:35 +0000346uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {
Bill Wendling67658342012-10-09 07:45:08 +0000347 switch (Val) {
Bill Wendling034b94b2012-12-19 07:18:57 +0000348 case Attribute::None: return 0;
349 case Attribute::ZExt: return 1 << 0;
350 case Attribute::SExt: return 1 << 1;
351 case Attribute::NoReturn: return 1 << 2;
352 case Attribute::InReg: return 1 << 3;
353 case Attribute::StructRet: return 1 << 4;
354 case Attribute::NoUnwind: return 1 << 5;
355 case Attribute::NoAlias: return 1 << 6;
356 case Attribute::ByVal: return 1 << 7;
357 case Attribute::Nest: return 1 << 8;
358 case Attribute::ReadNone: return 1 << 9;
359 case Attribute::ReadOnly: return 1 << 10;
360 case Attribute::NoInline: return 1 << 11;
361 case Attribute::AlwaysInline: return 1 << 12;
362 case Attribute::OptimizeForSize: return 1 << 13;
363 case Attribute::StackProtect: return 1 << 14;
364 case Attribute::StackProtectReq: return 1 << 15;
365 case Attribute::Alignment: return 31 << 16;
366 case Attribute::NoCapture: return 1 << 21;
367 case Attribute::NoRedZone: return 1 << 22;
368 case Attribute::NoImplicitFloat: return 1 << 23;
369 case Attribute::Naked: return 1 << 24;
370 case Attribute::InlineHint: return 1 << 25;
371 case Attribute::StackAlignment: return 7 << 26;
372 case Attribute::ReturnsTwice: return 1 << 29;
373 case Attribute::UWTable: return 1 << 30;
374 case Attribute::NonLazyBind: return 1U << 31;
375 case Attribute::AddressSafety: return 1ULL << 32;
376 case Attribute::MinSize: return 1ULL << 33;
James Molloy67ae1352012-12-20 16:04:27 +0000377 case Attribute::NoDuplicate: return 1ULL << 34;
Bill Wendling67658342012-10-09 07:45:08 +0000378 }
379 llvm_unreachable("Unsupported attribute type");
380}
381
Bill Wendling60507d52013-01-04 20:54:35 +0000382bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000383 return (getBitMask() & getAttrMask(A)) != 0;
Bill Wendling8e635db2012-10-08 21:47:17 +0000384}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000385
Bill Wendlingf6670722012-12-20 01:36:59 +0000386bool AttributeImpl::hasAttributes() const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000387 return getBitMask() != 0;
Bill Wendling8e635db2012-10-08 21:47:17 +0000388}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000389
Bill Wendlingf6670722012-12-20 01:36:59 +0000390uint64_t AttributeImpl::getAlignment() const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000391 return getBitMask() & getAttrMask(Attribute::Alignment);
Bill Wendling8e635db2012-10-08 21:47:17 +0000392}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000393
Bill Wendlingf6670722012-12-20 01:36:59 +0000394uint64_t AttributeImpl::getStackAlignment() const {
Bill Wendlingc966e082012-12-30 01:05:42 +0000395 return getBitMask() & getAttrMask(Attribute::StackAlignment);
Bill Wendling8e635db2012-10-08 21:47:17 +0000396}
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000397
Bill Wendling2c79ecb2012-09-26 21:07:29 +0000398//===----------------------------------------------------------------------===//
Bill Wendling18e72112012-12-19 22:42:22 +0000399// AttributeSetImpl Definition
Chris Lattner58d74912008-03-12 17:45:29 +0000400//===----------------------------------------------------------------------===//
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000401
Bill Wendling99faa3b2012-12-07 23:16:57 +0000402AttributeSet AttributeSet::get(LLVMContext &C,
Bill Wendling1ce47ac2012-12-12 19:21:53 +0000403 ArrayRef<AttributeWithIndex> Attrs) {
Devang Patel05988662008-09-25 21:00:45 +0000404 // If there are no attributes then return a null AttributesList pointer.
Chris Lattnerd509d0b2012-05-28 01:47:44 +0000405 if (Attrs.empty())
Bill Wendling99faa3b2012-12-07 23:16:57 +0000406 return AttributeSet();
Bill Wendling77898682012-10-16 06:01:44 +0000407
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000408#ifndef NDEBUG
Chris Lattnerd509d0b2012-05-28 01:47:44 +0000409 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
Bill Wendling77898682012-10-16 06:01:44 +0000410 assert(Attrs[i].Attrs.hasAttributes() &&
Devang Patel05988662008-09-25 21:00:45 +0000411 "Pointless attribute!");
Chris Lattner58d74912008-03-12 17:45:29 +0000412 assert((!i || Attrs[i-1].Index < Attrs[i].Index) &&
Devang Patel05988662008-09-25 21:00:45 +0000413 "Misordered AttributesList!");
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000414 }
415#endif
Bill Wendling77898682012-10-16 06:01:44 +0000416
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000417 // Otherwise, build a key to look up the existing attributes.
Bill Wendling0976e002012-11-20 05:09:20 +0000418 LLVMContextImpl *pImpl = C.pImpl;
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000419 FoldingSetNodeID ID;
Bill Wendling18e72112012-12-19 22:42:22 +0000420 AttributeSetImpl::Profile(ID, Attrs);
Bill Wendling77898682012-10-16 06:01:44 +0000421
Bill Wendling0976e002012-11-20 05:09:20 +0000422 void *InsertPoint;
Bill Wendling18e72112012-12-19 22:42:22 +0000423 AttributeSetImpl *PA = pImpl->AttrsLists.FindNodeOrInsertPos(ID,
Bill Wendling0976e002012-11-20 05:09:20 +0000424 InsertPoint);
Bill Wendling77898682012-10-16 06:01:44 +0000425
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000426 // If we didn't find any existing attributes of the same shape then
427 // create a new one and insert it.
Bill Wendling0976e002012-11-20 05:09:20 +0000428 if (!PA) {
Bill Wendling5f93e2b2012-12-19 23:55:43 +0000429 PA = new AttributeSetImpl(C, Attrs);
Bill Wendling0976e002012-11-20 05:09:20 +0000430 pImpl->AttrsLists.InsertNode(PA, InsertPoint);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000431 }
Bill Wendling77898682012-10-16 06:01:44 +0000432
Devang Patel05988662008-09-25 21:00:45 +0000433 // Return the AttributesList that we found or created.
Bill Wendling99faa3b2012-12-07 23:16:57 +0000434 return AttributeSet(PA);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000435}
436
Chris Lattner58d74912008-03-12 17:45:29 +0000437//===----------------------------------------------------------------------===//
Bill Wendling99faa3b2012-12-07 23:16:57 +0000438// AttributeSet Method Implementations
Chris Lattner58d74912008-03-12 17:45:29 +0000439//===----------------------------------------------------------------------===//
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000440
Bill Wendling99faa3b2012-12-07 23:16:57 +0000441const AttributeSet &AttributeSet::operator=(const AttributeSet &RHS) {
Bill Wendling0976e002012-11-20 05:09:20 +0000442 AttrList = RHS.AttrList;
443 return *this;
Chris Lattner58d74912008-03-12 17:45:29 +0000444}
445
Bill Wendling77898682012-10-16 06:01:44 +0000446/// getNumSlots - Return the number of slots used in this attribute list.
Chris Lattner58d74912008-03-12 17:45:29 +0000447/// This is the number of arguments that have an attribute set on them
448/// (including the function itself).
Bill Wendling99faa3b2012-12-07 23:16:57 +0000449unsigned AttributeSet::getNumSlots() const {
Bill Wendling60507d52013-01-04 20:54:35 +0000450 return AttrList ? AttrList->getNumAttributes() : 0;
Chris Lattner58d74912008-03-12 17:45:29 +0000451}
452
Devang Patel05988662008-09-25 21:00:45 +0000453/// getSlot - Return the AttributeWithIndex at the specified slot. This
454/// holds a number plus a set of attributes.
Bill Wendling99faa3b2012-12-07 23:16:57 +0000455const AttributeWithIndex &AttributeSet::getSlot(unsigned Slot) const {
Bill Wendling60507d52013-01-04 20:54:35 +0000456 assert(AttrList && Slot < AttrList->getNumAttributes() &&
457 "Slot # out of range!");
458 return AttrList->getAttributes()[Slot];
Chris Lattner58d74912008-03-12 17:45:29 +0000459}
460
Bill Wendling831737d2012-12-30 10:32:01 +0000461bool AttributeSet::hasAttribute(unsigned Index, Attribute::AttrKind Kind) const{
462 return getAttributes(Index).hasAttribute(Kind);
463}
464
465bool AttributeSet::hasAttributes(unsigned Index) const {
466 return getAttributes(Index).hasAttributes();
467}
468
469std::string AttributeSet::getAsString(unsigned Index) const {
470 return getAttributes(Index).getAsString();
471}
472
473unsigned AttributeSet::getStackAlignment(unsigned Index) const {
474 return getAttributes(Index).getStackAlignment();
475}
476
477uint64_t AttributeSet::getBitMask(unsigned Index) const {
478 // FIXME: Remove this.
479 return getAttributes(Index).getBitMask();
480}
481
Bill Wendling77898682012-10-16 06:01:44 +0000482/// getAttributes - The attributes for the specified index are returned.
Bill Wendling92e287f2012-12-31 11:51:54 +0000483/// Attributes for the result are denoted with Idx = 0. Function attributes are
484/// denoted with Idx = ~0.
Bill Wendling034b94b2012-12-19 07:18:57 +0000485Attribute AttributeSet::getAttributes(unsigned Idx) const {
486 if (AttrList == 0) return Attribute();
Bill Wendling77898682012-10-16 06:01:44 +0000487
Bill Wendling60507d52013-01-04 20:54:35 +0000488 ArrayRef<AttributeWithIndex> Attrs = AttrList->getAttributes();
Chris Lattner58d74912008-03-12 17:45:29 +0000489 for (unsigned i = 0, e = Attrs.size(); i != e && Attrs[i].Index <= Idx; ++i)
490 if (Attrs[i].Index == Idx)
491 return Attrs[i].Attrs;
Bill Wendlingef99fe82012-09-21 15:26:31 +0000492
Bill Wendling034b94b2012-12-19 07:18:57 +0000493 return Attribute();
Chris Lattner58d74912008-03-12 17:45:29 +0000494}
495
496/// hasAttrSomewhere - Return true if the specified attribute is set for at
497/// least one parameter or for the return value.
Bill Wendling629fb822012-12-22 00:37:52 +0000498bool AttributeSet::hasAttrSomewhere(Attribute::AttrKind Attr) const {
Devang Patel05988662008-09-25 21:00:45 +0000499 if (AttrList == 0) return false;
Bill Wendling7d2f2492012-10-10 07:36:45 +0000500
Bill Wendling60507d52013-01-04 20:54:35 +0000501 ArrayRef<AttributeWithIndex> Attrs = AttrList->getAttributes();
Chris Lattner58d74912008-03-12 17:45:29 +0000502 for (unsigned i = 0, e = Attrs.size(); i != e; ++i)
Bill Wendling7d2f2492012-10-10 07:36:45 +0000503 if (Attrs[i].Attrs.hasAttribute(Attr))
Chris Lattner58d74912008-03-12 17:45:29 +0000504 return true;
Bill Wendling0976e002012-11-20 05:09:20 +0000505
Chris Lattner58d74912008-03-12 17:45:29 +0000506 return false;
507}
508
Bill Wendling99faa3b2012-12-07 23:16:57 +0000509AttributeSet AttributeSet::addAttr(LLVMContext &C, unsigned Idx,
Bill Wendling9d30e722012-12-31 00:49:59 +0000510 Attribute Attrs) const {
Bill Wendling034b94b2012-12-19 07:18:57 +0000511 Attribute OldAttrs = getAttributes(Idx);
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000512#ifndef NDEBUG
513 // FIXME it is not obvious how this should work for alignment.
514 // For now, say we can't change a known alignment.
Bill Wendlingef99fe82012-09-21 15:26:31 +0000515 unsigned OldAlign = OldAttrs.getAlignment();
516 unsigned NewAlign = Attrs.getAlignment();
Anton Korobeynikov4aefd6b2008-02-20 12:07:57 +0000517 assert((!OldAlign || !NewAlign || OldAlign == NewAlign) &&
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000518 "Attempt to change alignment!");
519#endif
Bill Wendling77898682012-10-16 06:01:44 +0000520
Bill Wendling702cc912012-10-15 20:35:56 +0000521 AttrBuilder NewAttrs =
522 AttrBuilder(OldAttrs).addAttributes(Attrs);
523 if (NewAttrs == AttrBuilder(OldAttrs))
Chris Lattner58d74912008-03-12 17:45:29 +0000524 return *this;
Bill Wendling77898682012-10-16 06:01:44 +0000525
Devang Patel05988662008-09-25 21:00:45 +0000526 SmallVector<AttributeWithIndex, 8> NewAttrList;
527 if (AttrList == 0)
528 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Chris Lattner58d74912008-03-12 17:45:29 +0000529 else {
Bill Wendling60507d52013-01-04 20:54:35 +0000530 ArrayRef<AttributeWithIndex> OldAttrList = AttrList->getAttributes();
Chris Lattner58d74912008-03-12 17:45:29 +0000531 unsigned i = 0, e = OldAttrList.size();
532 // Copy attributes for arguments before this one.
533 for (; i != e && OldAttrList[i].Index < Idx; ++i)
534 NewAttrList.push_back(OldAttrList[i]);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000535
Chris Lattner58d74912008-03-12 17:45:29 +0000536 // If there are attributes already at this index, merge them in.
537 if (i != e && OldAttrList[i].Index == Idx) {
Bill Wendlingc4167952012-10-14 07:35:59 +0000538 Attrs =
Bill Wendling034b94b2012-12-19 07:18:57 +0000539 Attribute::get(C, AttrBuilder(Attrs).
Bill Wendlingc4167952012-10-14 07:35:59 +0000540 addAttributes(OldAttrList[i].Attrs));
Chris Lattner58d74912008-03-12 17:45:29 +0000541 ++i;
542 }
Bill Wendling77898682012-10-16 06:01:44 +0000543
Devang Patel05988662008-09-25 21:00:45 +0000544 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Bill Wendling77898682012-10-16 06:01:44 +0000545
Chris Lattner58d74912008-03-12 17:45:29 +0000546 // Copy attributes for arguments after this one.
Bill Wendling77898682012-10-16 06:01:44 +0000547 NewAttrList.insert(NewAttrList.end(),
Chris Lattner58d74912008-03-12 17:45:29 +0000548 OldAttrList.begin()+i, OldAttrList.end());
549 }
Bill Wendling77898682012-10-16 06:01:44 +0000550
Bill Wendling0976e002012-11-20 05:09:20 +0000551 return get(C, NewAttrList);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000552}
553
Bill Wendling99faa3b2012-12-07 23:16:57 +0000554AttributeSet AttributeSet::removeAttr(LLVMContext &C, unsigned Idx,
Bill Wendling9d30e722012-12-31 00:49:59 +0000555 Attribute Attrs) const {
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000556#ifndef NDEBUG
557 // FIXME it is not obvious how this should work for alignment.
558 // For now, say we can't pass in alignment, which no current use does.
Bill Wendling034b94b2012-12-19 07:18:57 +0000559 assert(!Attrs.hasAttribute(Attribute::Alignment) &&
Bill Wendling67658342012-10-09 07:45:08 +0000560 "Attempt to exclude alignment!");
Dale Johannesen6167c3f2008-02-19 23:51:49 +0000561#endif
Bill Wendling99faa3b2012-12-07 23:16:57 +0000562 if (AttrList == 0) return AttributeSet();
Bill Wendling77898682012-10-16 06:01:44 +0000563
Bill Wendling034b94b2012-12-19 07:18:57 +0000564 Attribute OldAttrs = getAttributes(Idx);
Bill Wendling702cc912012-10-15 20:35:56 +0000565 AttrBuilder NewAttrs =
566 AttrBuilder(OldAttrs).removeAttributes(Attrs);
567 if (NewAttrs == AttrBuilder(OldAttrs))
Chris Lattner58d74912008-03-12 17:45:29 +0000568 return *this;
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000569
Devang Patel05988662008-09-25 21:00:45 +0000570 SmallVector<AttributeWithIndex, 8> NewAttrList;
Bill Wendling60507d52013-01-04 20:54:35 +0000571 ArrayRef<AttributeWithIndex> OldAttrList = AttrList->getAttributes();
Chris Lattner58d74912008-03-12 17:45:29 +0000572 unsigned i = 0, e = OldAttrList.size();
Bill Wendling77898682012-10-16 06:01:44 +0000573
Chris Lattner58d74912008-03-12 17:45:29 +0000574 // Copy attributes for arguments before this one.
575 for (; i != e && OldAttrList[i].Index < Idx; ++i)
576 NewAttrList.push_back(OldAttrList[i]);
Bill Wendling77898682012-10-16 06:01:44 +0000577
Chris Lattner58d74912008-03-12 17:45:29 +0000578 // If there are attributes already at this index, merge them in.
579 assert(OldAttrList[i].Index == Idx && "Attribute isn't set?");
Bill Wendling034b94b2012-12-19 07:18:57 +0000580 Attrs = Attribute::get(C, AttrBuilder(OldAttrList[i].Attrs).
Bill Wendling5886b7b2012-10-14 06:39:53 +0000581 removeAttributes(Attrs));
Chris Lattner58d74912008-03-12 17:45:29 +0000582 ++i;
Bill Wendling7be78482012-10-14 08:54:26 +0000583 if (Attrs.hasAttributes()) // If any attributes left for this param, add them.
Devang Patel05988662008-09-25 21:00:45 +0000584 NewAttrList.push_back(AttributeWithIndex::get(Idx, Attrs));
Bill Wendling77898682012-10-16 06:01:44 +0000585
Chris Lattner58d74912008-03-12 17:45:29 +0000586 // Copy attributes for arguments after this one.
Bill Wendling77898682012-10-16 06:01:44 +0000587 NewAttrList.insert(NewAttrList.end(),
Chris Lattner58d74912008-03-12 17:45:29 +0000588 OldAttrList.begin()+i, OldAttrList.end());
Bill Wendling77898682012-10-16 06:01:44 +0000589
Bill Wendling0976e002012-11-20 05:09:20 +0000590 return get(C, NewAttrList);
Chris Lattner50ee9dd2008-01-02 23:42:30 +0000591}
592
Bill Wendling99faa3b2012-12-07 23:16:57 +0000593void AttributeSet::dump() const {
David Greeneef1894e2010-01-05 01:29:58 +0000594 dbgs() << "PAL[ ";
Chris Lattner58d74912008-03-12 17:45:29 +0000595 for (unsigned i = 0; i < getNumSlots(); ++i) {
Devang Patel05988662008-09-25 21:00:45 +0000596 const AttributeWithIndex &PAWI = getSlot(i);
Bill Wendling60507d52013-01-04 20:54:35 +0000597 dbgs() << "{ " << PAWI.Index << ", " << PAWI.Attrs.getAsString() << " } ";
Chris Lattner58d74912008-03-12 17:45:29 +0000598 }
Bill Wendling77898682012-10-16 06:01:44 +0000599
David Greeneef1894e2010-01-05 01:29:58 +0000600 dbgs() << "]\n";
Duncan Sandsad9a9e12008-01-06 18:27:01 +0000601}