Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 1 | //===-- AttributesImpl.h - Attribute Internals -----------------*- C++ -*-===// |
Bill Wendling | 2c79ecb | 2012-09-26 21:07:29 +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 | // |
| 10 | // This file defines various helper methods and classes used by LLVMContextImpl |
| 11 | // for creating and managing attributes. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_ATTRIBUTESIMPL_H |
| 16 | #define LLVM_ATTRIBUTESIMPL_H |
| 17 | |
| 18 | #include "llvm/ADT/FoldingSet.h" |
Chandler Carruth | a1514e2 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 19 | #include "llvm/Attributes.h" |
Bill Wendling | 2c79ecb | 2012-09-26 21:07:29 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
| 22 | |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 23 | class AttributesImpl : public FoldingSetNode { |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 24 | uint64_t Bits; // FIXME: We will be expanding this. |
Bill Wendling | 2c79ecb | 2012-09-26 21:07:29 +0000 | [diff] [blame] | 25 | public: |
| 26 | AttributesImpl(uint64_t bits) : Bits(bits) {} |
| 27 | |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 28 | bool hasAttribute(uint64_t A) const; |
Bill Wendling | 6765834 | 2012-10-09 07:45:08 +0000 | [diff] [blame] | 29 | |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 30 | bool hasAttributes() const; |
Bill Wendling | 034b94b | 2012-12-19 07:18:57 +0000 | [diff] [blame] | 31 | bool hasAttributes(const Attribute &A) const; |
Bill Wendling | 8e635db | 2012-10-08 21:47:17 +0000 | [diff] [blame] | 32 | |
| 33 | uint64_t getAlignment() const; |
| 34 | uint64_t getStackAlignment() const; |
| 35 | |
Bill Wendling | 925bcb1 | 2012-10-16 05:57:28 +0000 | [diff] [blame] | 36 | uint64_t Raw() const { return Bits; } // FIXME: Remove. |
| 37 | |
Bill Wendling | 2e879bc | 2012-10-09 09:11:20 +0000 | [diff] [blame] | 38 | static uint64_t getAttrMask(uint64_t Val); |
| 39 | |
Bill Wendling | 2c79ecb | 2012-09-26 21:07:29 +0000 | [diff] [blame] | 40 | void Profile(FoldingSetNodeID &ID) const { |
| 41 | Profile(ID, Bits); |
| 42 | } |
| 43 | static void Profile(FoldingSetNodeID &ID, uint64_t Bits) { |
| 44 | ID.AddInteger(Bits); |
| 45 | } |
| 46 | }; |
| 47 | |
Bill Wendling | 18e7211 | 2012-12-19 22:42:22 +0000 | [diff] [blame^] | 48 | class AttributeSetImpl : public FoldingSetNode { |
Bill Wendling | 0976e00 | 2012-11-20 05:09:20 +0000 | [diff] [blame] | 49 | // AttributesList is uniqued, these should not be publicly available. |
Bill Wendling | 18e7211 | 2012-12-19 22:42:22 +0000 | [diff] [blame^] | 50 | void operator=(const AttributeSetImpl &) LLVM_DELETED_FUNCTION; |
| 51 | AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION; |
Bill Wendling | 0976e00 | 2012-11-20 05:09:20 +0000 | [diff] [blame] | 52 | public: |
| 53 | SmallVector<AttributeWithIndex, 4> Attrs; |
| 54 | |
Bill Wendling | 18e7211 | 2012-12-19 22:42:22 +0000 | [diff] [blame^] | 55 | AttributeSetImpl(ArrayRef<AttributeWithIndex> attrs) |
Bill Wendling | 0976e00 | 2012-11-20 05:09:20 +0000 | [diff] [blame] | 56 | : Attrs(attrs.begin(), attrs.end()) {} |
| 57 | |
| 58 | void Profile(FoldingSetNodeID &ID) const { |
| 59 | Profile(ID, Attrs); |
| 60 | } |
| 61 | static void Profile(FoldingSetNodeID &ID, ArrayRef<AttributeWithIndex> Attrs){ |
| 62 | for (unsigned i = 0, e = Attrs.size(); i != e; ++i) { |
| 63 | ID.AddInteger(Attrs[i].Attrs.Raw()); |
| 64 | ID.AddInteger(Attrs[i].Index); |
| 65 | } |
| 66 | } |
| 67 | }; |
| 68 | |
Bill Wendling | 2c79ecb | 2012-09-26 21:07:29 +0000 | [diff] [blame] | 69 | } // end llvm namespace |
| 70 | |
| 71 | #endif |