blob: 396634ed0fe74263446ae6a3e84c013543d19623 [file] [log] [blame]
Bill Wendling034b94b2012-12-19 07:18:57 +00001//===-- AttributesImpl.h - Attribute Internals -----------------*- C++ -*-===//
Bill Wendling2c79ecb2012-09-26 21:07:29 +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//
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 Carrutha1514e22012-12-04 07:12:27 +000019#include "llvm/Attributes.h"
Bill Wendling2c79ecb2012-09-26 21:07:29 +000020
21namespace llvm {
22
Bill Wendling5f93e2b2012-12-19 23:55:43 +000023class LLVMContext;
24
Bill Wendling8e635db2012-10-08 21:47:17 +000025class AttributesImpl : public FoldingSetNode {
Bill Wendling8e635db2012-10-08 21:47:17 +000026 uint64_t Bits; // FIXME: We will be expanding this.
Bill Wendling2c79ecb2012-09-26 21:07:29 +000027public:
28 AttributesImpl(uint64_t bits) : Bits(bits) {}
29
Bill Wendling8e635db2012-10-08 21:47:17 +000030 bool hasAttribute(uint64_t A) const;
Bill Wendling67658342012-10-09 07:45:08 +000031
Bill Wendling8e635db2012-10-08 21:47:17 +000032 bool hasAttributes() const;
Bill Wendling034b94b2012-12-19 07:18:57 +000033 bool hasAttributes(const Attribute &A) const;
Bill Wendling8e635db2012-10-08 21:47:17 +000034
35 uint64_t getAlignment() const;
36 uint64_t getStackAlignment() const;
37
Bill Wendling925bcb12012-10-16 05:57:28 +000038 uint64_t Raw() const { return Bits; } // FIXME: Remove.
39
Bill Wendling2e879bc2012-10-09 09:11:20 +000040 static uint64_t getAttrMask(uint64_t Val);
41
Bill Wendling2c79ecb2012-09-26 21:07:29 +000042 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
Bill Wendling18e72112012-12-19 22:42:22 +000050class AttributeSetImpl : public FoldingSetNode {
Bill Wendling0976e002012-11-20 05:09:20 +000051 // AttributesList is uniqued, these should not be publicly available.
Bill Wendling18e72112012-12-19 22:42:22 +000052 void operator=(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
53 AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
Bill Wendling0976e002012-11-20 05:09:20 +000054public:
Bill Wendling5f93e2b2012-12-19 23:55:43 +000055 LLVMContext &Context;
Bill Wendling0976e002012-11-20 05:09:20 +000056 SmallVector<AttributeWithIndex, 4> Attrs;
57
Bill Wendling5f93e2b2012-12-19 23:55:43 +000058 AttributeSetImpl(LLVMContext &C, ArrayRef<AttributeWithIndex> attrs)
59 : Context(C), Attrs(attrs.begin(), attrs.end()) {}
Bill Wendling0976e002012-11-20 05:09:20 +000060
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
Bill Wendling2c79ecb2012-09-26 21:07:29 +000072} // end llvm namespace
73
74#endif