|
23 | 23 | namespace mlir {
|
24 | 24 | namespace LLVM {
|
25 | 25 |
|
| 26 | +namespace detail { |
| 27 | +struct ConstantRangeAttrStorage : public AttributeStorage { |
| 28 | + ConstantRangeAttrStorage(llvm::APInt lower, llvm::APInt upper) |
| 29 | + : lower(lower), upper(upper) {} |
| 30 | + |
| 31 | + /// The hash key for this storage is a pair of the integer and type params. |
| 32 | + using KeyTy = std::pair<llvm::APInt, llvm::APInt>; |
| 33 | + |
| 34 | + /// Define the comparison function for the key type. |
| 35 | + bool operator==(const KeyTy &key) const { |
| 36 | + if (lower.getBitWidth() != key.first.getBitWidth() || |
| 37 | + upper.getBitWidth() != key.second.getBitWidth()) { |
| 38 | + return false; |
| 39 | + } |
| 40 | + return lower == key.first && upper == key.second; |
| 41 | + } |
| 42 | + |
| 43 | + /// Define a hash function for the key type. |
| 44 | + /// Note: This isn't necessary because std::pair, unsigned, and Type all have |
| 45 | + /// hash functions already available. |
| 46 | + static llvm::hash_code hashKey(const KeyTy &key) { |
| 47 | + return llvm::hash_combine(key.first, key.second); |
| 48 | + } |
| 49 | + |
| 50 | + /// Define a construction function for the key type. |
| 51 | + /// Note: This isn't necessary because KeyTy can be directly constructed with |
| 52 | + /// the given parameters. |
| 53 | + static KeyTy getKey(llvm::APInt lower, llvm::APInt upper) { |
| 54 | + return KeyTy(lower, upper); |
| 55 | + } |
| 56 | + |
| 57 | + /// Define a construction method for creating a new instance of this storage. |
| 58 | + static ConstantRangeAttrStorage *construct(mlir::StorageUniquer::StorageAllocator &allocator, const KeyTy &key) { |
| 59 | + return new (allocator.allocate<ConstantRangeAttrStorage>()) |
| 60 | + ConstantRangeAttrStorage(key.first, key.second); |
| 61 | + } |
| 62 | + |
| 63 | + /// Construct an instance of the key from this storage class. |
| 64 | + KeyTy getAsKey() const { |
| 65 | + return KeyTy(lower, upper); |
| 66 | + } |
| 67 | + |
| 68 | + /// The parametric data held by the storage class. |
| 69 | + llvm::APInt lower; |
| 70 | + llvm::APInt upper; |
| 71 | +}; |
| 72 | +} |
| 73 | + |
26 | 74 | /// This class represents the base attribute for all debug info attributes.
|
27 | 75 | class DINodeAttr : public Attribute {
|
28 | 76 | public:
|
@@ -96,6 +144,9 @@ using linkage::Linkage;
|
96 | 144 |
|
97 | 145 | #include "mlir/Dialect/LLVMIR/LLVMAttrInterfaces.h.inc"
|
98 | 146 |
|
| 147 | + |
| 148 | + |
| 149 | + |
99 | 150 | #define GET_ATTRDEF_CLASSES
|
100 | 151 | #include "mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.h.inc"
|
101 | 152 |
|
|
0 commit comments