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);
55 //===----------------------------------------------------------------------===//
57 /// \brief This class represents a set of attributes.
58 class AttributeSetImpl : public FoldingSetNode {
59 // AttributesList is uniqued, these should not be publicly available.
60 void operator=(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
61 AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
64 SmallVector<AttributeWithIndex, 4> Attrs;
66 AttributeSetImpl(LLVMContext &C, ArrayRef<AttributeWithIndex> attrs)
67 : Context(C), Attrs(attrs.begin(), attrs.end()) {}
69 void Profile(FoldingSetNodeID &ID) const {
72 static void Profile(FoldingSetNodeID &ID, ArrayRef<AttributeWithIndex> Attrs){
73 for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
74 ID.AddInteger(Attrs[i].Attrs.getBitMask());
75 ID.AddInteger(Attrs[i].Index);
80 } // end llvm namespace