File indexing completed on 2026-05-10 08:44:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef LLVM_IR_MEMORYMODELRELAXATIONANNOTATIONS_H
0019 #define LLVM_IR_MEMORYMODELRELAXATIONANNOTATIONS_H
0020
0021 #include "llvm/ADT/DenseSet.h"
0022 #include "llvm/ADT/StringRef.h"
0023 #include <tuple> // for std::pair
0024
0025 namespace llvm {
0026
0027 template <typename T> class ArrayRef;
0028
0029 class MDNode;
0030 class MDTuple;
0031 class Metadata;
0032 class raw_ostream;
0033 class LLVMContext;
0034 class Instruction;
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 class MMRAMetadata {
0047 public:
0048 using TagT = std::pair<StringRef, StringRef>;
0049 using SetT = DenseSet<TagT>;
0050 using const_iterator = SetT::const_iterator;
0051
0052
0053
0054 MMRAMetadata() = default;
0055 MMRAMetadata(const Instruction &I);
0056 MMRAMetadata(MDNode *MD);
0057
0058
0059
0060
0061
0062
0063
0064 static MDNode *combine(LLVMContext &Ctx, const MMRAMetadata &A,
0065 const MMRAMetadata &B);
0066
0067
0068
0069
0070
0071 static MDTuple *getTagMD(LLVMContext &Ctx, StringRef Prefix,
0072 StringRef Suffix);
0073 static MDTuple *getTagMD(LLVMContext &Ctx, const TagT &T) {
0074 return getTagMD(Ctx, T.first, T.second);
0075 }
0076
0077
0078
0079 static MDTuple *getMD(LLVMContext &Ctx, ArrayRef<TagT> Tags);
0080
0081
0082 static bool isTagMD(const Metadata *MD);
0083
0084
0085
0086
0087
0088
0089
0090 static bool checkCompatibility(const Instruction &A, const Instruction &B) {
0091 return MMRAMetadata(A).isCompatibleWith(B);
0092 }
0093
0094
0095 bool isCompatibleWith(const MMRAMetadata &Other) const;
0096
0097
0098
0099
0100
0101
0102 bool hasTag(StringRef Prefix, StringRef Suffix) const;
0103 bool hasTagWithPrefix(StringRef Prefix) const;
0104
0105 const_iterator begin() const;
0106 const_iterator end() const;
0107 bool empty() const;
0108 unsigned size() const;
0109
0110
0111
0112 void print(raw_ostream &OS) const;
0113 void dump() const;
0114
0115 operator bool() const { return !Tags.empty(); }
0116 bool operator==(const MMRAMetadata &Other) const {
0117 return Tags == Other.Tags;
0118 }
0119 bool operator!=(const MMRAMetadata &Other) const {
0120 return Tags != Other.Tags;
0121 }
0122
0123 private:
0124 SetT Tags;
0125 };
0126
0127
0128 bool canInstructionHaveMMRAs(const Instruction &I);
0129
0130 }
0131
0132 #endif