s/AttributesImpl/AttributeImpl/g This is going to apply to Attribute, not Attributes.
[oota-llvm.git] / lib / VMCore / AttributeImpl.h
1 //===-- AttributeImpl.h - Attribute Internals -------------------*- C++ -*-===//
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"
19 #include "llvm/Attributes.h"
20
21 namespace llvm {
22
23 class LLVMContext;
24
25 class AttributeImpl : public FoldingSetNode {
26   uint64_t Bits;                // FIXME: We will be expanding this.
27 public:
28   AttributeImpl(uint64_t bits) : Bits(bits) {}
29
30   bool hasAttribute(uint64_t A) const;
31
32   bool hasAttributes() const;
33   bool hasAttributes(const Attribute &A) const;
34
35   uint64_t getAlignment() const;
36   uint64_t getStackAlignment() const;
37
38   uint64_t Raw() const { return Bits; } // FIXME: Remove.
39
40   static uint64_t getAttrMask(uint64_t Val);
41
42   void Profile(FoldingSetNodeID &ID) const {
43     Profile(ID, Bits);
44   }
45   static void Profile(FoldingSetNodeID &ID, uint64_t Bits) {
46     ID.AddInteger(Bits);
47   }
48 };
49
50 class AttributeSetImpl : public FoldingSetNode {
51   // AttributesList is uniqued, these should not be publicly available.
52   void operator=(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
53   AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
54 public:
55   LLVMContext &Context;
56   SmallVector<AttributeWithIndex, 4> Attrs;
57
58   AttributeSetImpl(LLVMContext &C, ArrayRef<AttributeWithIndex> attrs)
59     : Context(C), Attrs(attrs.begin(), attrs.end()) {}
60
61   void Profile(FoldingSetNodeID &ID) const {
62     Profile(ID, Attrs);
63   }
64   static void Profile(FoldingSetNodeID &ID, ArrayRef<AttributeWithIndex> Attrs){
65     for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
66       ID.AddInteger(Attrs[i].Attrs.Raw());
67       ID.AddInteger(Attrs[i].Index);
68     }
69   }
70 };
71
72 } // end llvm namespace
73
74 #endif