1 //===-- AttributeImpl.h - Attribute Internals -------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief This file defines various helper methods and classes used by
12 /// LLVMContextImpl for creating and managing attributes.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_ATTRIBUTESIMPL_H
17 #define LLVM_ATTRIBUTESIMPL_H
19 #include "llvm/ADT/FoldingSet.h"
20 #include "llvm/Attributes.h"
27 //===----------------------------------------------------------------------===//
29 /// \brief This class represents a single, uniqued attribute. That attribute
30 /// could be a single enum, a tuple, or a string. It uses a discriminated union
31 /// to distinguish them.
32 class AttributeImpl : public FoldingSetNode {
35 AttributeImpl(LLVMContext &C, uint64_t data);
37 bool hasAttribute(uint64_t A) const;
39 bool hasAttributes() const;
40 bool hasAttributes(const Attribute &A) const;
42 uint64_t getAlignment() const;
43 uint64_t getStackAlignment() const;
45 uint64_t getBitMask() const; // FIXME: Remove.
47 static uint64_t getAttrMask(uint64_t Val);
49 void Profile(FoldingSetNodeID &ID) const {
52 static void Profile(FoldingSetNodeID &ID, Constant *Data) {
57 //===----------------------------------------------------------------------===//
59 /// \brief This class represents a set of attributes.
60 class AttributeSetImpl : public FoldingSetNode {
61 // AttributesList is uniqued, these should not be publicly available.
62 void operator=(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
63 AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
66 SmallVector<AttributeWithIndex, 4> Attrs;
68 AttributeSetImpl(LLVMContext &C, ArrayRef<AttributeWithIndex> attrs)
69 : Context(C), Attrs(attrs.begin(), attrs.end()) {}
71 void Profile(FoldingSetNodeID &ID) const {
74 static void Profile(FoldingSetNodeID &ID, ArrayRef<AttributeWithIndex> Attrs){
75 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
76 ID.AddInteger(Attrs[i].Attrs.getBitMask());
77 ID.AddInteger(Attrs[i].Index);
82 } // end llvm namespace