LLVM 19.0.0git
AttributeMask.h
Go to the documentation of this file.
1//===- llvm/AttributeMask.h - Mask for Attributes ---------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// \file
10// This file declares the AttributeMask class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_ATTRIBUTEMASK_H
15#define LLVM_IR_ATTRIBUTEMASK_H
16
18#include "llvm/IR/Attributes.h"
19#include <bitset>
20#include <cassert>
21#include <set>
22
23namespace llvm {
24
25//===----------------------------------------------------------------------===//
26/// \class
27/// This class stores enough information to efficiently remove some attributes
28/// from an existing AttrBuilder, AttributeSet or AttributeList.
30 std::bitset<Attribute::EndAttrKinds> Attrs;
31 std::set<SmallString<32>, std::less<>> TargetDepAttrs;
32
33public:
34 AttributeMask() = default;
35 AttributeMask(const AttributeMask &) = delete;
37
39 for (Attribute A : AS)
41 }
42
43 /// Add an attribute to the mask.
45 assert((unsigned)Val < Attribute::EndAttrKinds &&
46 "Attribute out of range!");
47 Attrs[Val] = true;
48 return *this;
49 }
50
51 /// Add the Attribute object to the builder.
53 if (A.isStringAttribute())
54 addAttribute(A.getKindAsString());
55 else
56 addAttribute(A.getKindAsEnum());
57 return *this;
58 }
59
60 /// Add the target-dependent attribute to the builder.
62 TargetDepAttrs.insert(A);
63 return *this;
64 }
65
66 /// Return true if the builder has the specified attribute.
68 assert((unsigned)A < Attribute::EndAttrKinds && "Attribute out of range!");
69 return Attrs[A];
70 }
71
72 /// Return true if the builder has the specified target-dependent
73 /// attribute.
74 bool contains(StringRef A) const { return TargetDepAttrs.count(A); }
75
76 /// Return true if the mask contains the specified attribute.
77 bool contains(Attribute A) const {
78 if (A.isStringAttribute())
79 return contains(A.getKindAsString());
80 return contains(A.getKindAsEnum());
81 }
82};
83
84} // end namespace llvm
85
86#endif // LLVM_IR_ATTRIBUTEMASK_H
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
AttributeMask(AttributeSet AS)
Definition: AttributeMask.h:38
bool contains(StringRef A) const
Return true if the builder has the specified target-dependent attribute.
Definition: AttributeMask.h:74
AttributeMask(const AttributeMask &)=delete
AttributeMask & addAttribute(StringRef A)
Add the target-dependent attribute to the builder.
Definition: AttributeMask.h:61
AttributeMask & addAttribute(Attribute::AttrKind Val)
Add an attribute to the mask.
Definition: AttributeMask.h:44
AttributeMask()=default
AttributeMask(AttributeMask &&)=default
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
Definition: AttributeMask.h:67
AttributeMask & addAttribute(Attribute A)
Add the Attribute object to the builder.
Definition: AttributeMask.h:52
bool contains(Attribute A) const
Return true if the mask contains the specified attribute.
Definition: AttributeMask.h:77
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:85
@ EndAttrKinds
Sentinel value useful for loops.
Definition: Attributes.h:90
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18