File indexing completed on 2026-05-10 08:43:56
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_IR_ATTRIBUTEMASK_H
0015 #define LLVM_IR_ATTRIBUTEMASK_H
0016
0017 #include "llvm/ADT/SmallString.h"
0018 #include "llvm/IR/Attributes.h"
0019 #include <bitset>
0020 #include <cassert>
0021 #include <set>
0022
0023 namespace llvm {
0024
0025
0026
0027
0028
0029 class AttributeMask {
0030 std::bitset<Attribute::EndAttrKinds> Attrs;
0031 std::set<SmallString<32>, std::less<>> TargetDepAttrs;
0032
0033 public:
0034 AttributeMask() = default;
0035 AttributeMask(const AttributeMask &) = delete;
0036 AttributeMask(AttributeMask &&) = default;
0037
0038 AttributeMask(AttributeSet AS) {
0039 for (Attribute A : AS)
0040 addAttribute(A);
0041 }
0042
0043
0044 AttributeMask &addAttribute(Attribute::AttrKind Val) {
0045 assert((unsigned)Val < Attribute::EndAttrKinds &&
0046 "Attribute out of range!");
0047 Attrs[Val] = true;
0048 return *this;
0049 }
0050
0051
0052 AttributeMask &addAttribute(Attribute A) {
0053 if (A.isStringAttribute())
0054 addAttribute(A.getKindAsString());
0055 else
0056 addAttribute(A.getKindAsEnum());
0057 return *this;
0058 }
0059
0060
0061 AttributeMask &addAttribute(StringRef A) {
0062 TargetDepAttrs.insert(A);
0063 return *this;
0064 }
0065
0066
0067 bool contains(Attribute::AttrKind A) const {
0068 assert((unsigned)A < Attribute::EndAttrKinds && "Attribute out of range!");
0069 return Attrs[A];
0070 }
0071
0072
0073
0074 bool contains(StringRef A) const { return TargetDepAttrs.count(A); }
0075
0076
0077 bool contains(Attribute A) const {
0078 if (A.isStringAttribute())
0079 return contains(A.getKindAsString());
0080 return contains(A.getKindAsEnum());
0081 }
0082 };
0083
0084 }
0085
0086 #endif