My Project
AttributeDetail.h
Go to the documentation of this file.
1 //===- AttributeDetail.h - MLIR Affine Map details Class --------*- C++ -*-===//
2 //
3 // Part of the MLIR 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 // This holds implementation details of Attribute.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef ATTRIBUTEDETAIL_H_
14 #define ATTRIBUTEDETAIL_H_
15 
16 #include "mlir/IR/AffineMap.h"
17 #include "mlir/IR/Attributes.h"
18 #include "mlir/IR/Identifier.h"
19 #include "mlir/IR/IntegerSet.h"
20 #include "mlir/IR/MLIRContext.h"
21 #include "mlir/IR/StandardTypes.h"
23 #include "llvm/ADT/APFloat.h"
24 #include "llvm/ADT/PointerIntPair.h"
25 #include "llvm/Support/TrailingObjects.h"
26 
27 namespace mlir {
28 namespace detail {
29 // An attribute representing a reference to an affine map.
31  using KeyTy = AffineMap;
32 
34  : AttributeStorage(IndexType::get(value.getContext())), value(value) {}
35 
37  bool operator==(const KeyTy &key) const { return key == value; }
38 
42  return new (allocator.allocate<AffineMapAttributeStorage>())
44  }
45 
47 };
48 
52 
54 
56  bool operator==(const KeyTy &key) const { return key == value; }
57 
60  const KeyTy &key) {
61  return new (allocator.allocate<ArrayAttributeStorage>())
62  ArrayAttributeStorage(allocator.copyInto(key));
63  }
64 
66 };
67 
70  using KeyTy = std::pair<MLIRContext *, bool>;
71 
73  : AttributeStorage(type), value(value) {}
74 
76  bool operator==(const KeyTy &key) const { return key.second == value; }
77  static unsigned hashKey(const KeyTy &key) {
78  return llvm::hash_value(key.second);
79  }
80 
82  const KeyTy &key) {
83  return new (allocator.allocate<BoolAttributeStorage>())
84  BoolAttributeStorage(IntegerType::get(1, key.first), key.second);
85  }
86 
87  bool value;
88 };
89 
92  : public AttributeStorage,
93  private llvm::TrailingObjects<DictionaryAttributeStorage,
94  NamedAttribute> {
96 
100 
102  bool operator==(const KeyTy &key) const { return key == getElements(); }
103 
106  construct(AttributeStorageAllocator &allocator, const KeyTy &key) {
107  auto size = DictionaryAttributeStorage::totalSizeToAlloc<NamedAttribute>(
108  key.size());
109  auto rawMem = allocator.allocate(size, alignof(NamedAttribute));
110 
111  // Initialize the storage and trailing attribute list.
112  auto result = ::new (rawMem) DictionaryAttributeStorage(key.size());
113  std::uninitialized_copy(key.begin(), key.end(),
114  result->getTrailingObjects<NamedAttribute>());
115  return result;
116  }
117 
120  return {getTrailingObjects<NamedAttribute>(), numElements};
121  }
122 
123 private:
124  friend class llvm::TrailingObjects<DictionaryAttributeStorage,
126 
127  // This is used by the llvm::TrailingObjects base class.
128  size_t numTrailingObjects(OverloadToken<NamedAttribute>) const {
129  return numElements;
130  }
131  DictionaryAttributeStorage(unsigned numElements) : numElements(numElements) {}
132 
134  const unsigned numElements;
135 };
136 
139  : public AttributeStorage,
140  public llvm::TrailingObjects<FloatAttributeStorage, uint64_t> {
141  using KeyTy = std::pair<Type, APFloat>;
142 
143  FloatAttributeStorage(const llvm::fltSemantics &semantics, Type type,
144  size_t numObjects)
145  : AttributeStorage(type), semantics(semantics), numObjects(numObjects) {}
146 
148  bool operator==(const KeyTy &key) const {
149  return key.first == getType() && key.second.bitwiseIsEqual(getValue());
150  }
151  static unsigned hashKey(const KeyTy &key) {
152  return llvm::hash_combine(key.first, llvm::hash_value(key.second));
153  }
154 
156  static KeyTy getKey(Type type, double value) {
157  // Treat BF16 as double because it is not supported in LLVM's APFloat.
158  // TODO(b/121118307): add BF16 support to APFloat?
159  if (type.isBF16() || type.isF64())
160  return KeyTy(type, APFloat(value));
161 
162  // This handles, e.g., F16 because there is no APFloat constructor for it.
163  bool unused;
164  APFloat val(value);
165  val.convert(type.cast<FloatType>().getFloatSemantics(),
166  APFloat::rmNearestTiesToEven, &unused);
167  return KeyTy(type, val);
168  }
169 
172  const KeyTy &key) {
173  const auto &apint = key.second.bitcastToAPInt();
174 
175  // Here one word's bitwidth equals to that of uint64_t.
176  auto elements = ArrayRef<uint64_t>(apint.getRawData(), apint.getNumWords());
177 
178  auto byteSize =
179  FloatAttributeStorage::totalSizeToAlloc<uint64_t>(elements.size());
180  auto rawMem = allocator.allocate(byteSize, alignof(FloatAttributeStorage));
181  auto result = ::new (rawMem) FloatAttributeStorage(
182  key.second.getSemantics(), key.first, elements.size());
183  std::uninitialized_copy(elements.begin(), elements.end(),
184  result->getTrailingObjects<uint64_t>());
185  return result;
186  }
187 
189  APFloat getValue() const {
190  auto val = APInt(APFloat::getSizeInBits(semantics),
191  {getTrailingObjects<uint64_t>(), numObjects});
192  return APFloat(semantics, val);
193  }
194 
195  const llvm::fltSemantics &semantics;
196  size_t numObjects;
197 };
198 
201  : public AttributeStorage,
202  public llvm::TrailingObjects<IntegerAttributeStorage, uint64_t> {
203  using KeyTy = std::pair<Type, APInt>;
204 
205  IntegerAttributeStorage(Type type, size_t numObjects)
206  : AttributeStorage(type), numObjects(numObjects) {
207  assert((type.isIndex() || type.isa<IntegerType>()) && "invalid type");
208  }
209 
211  bool operator==(const KeyTy &key) const {
212  return key == KeyTy(getType(), getValue());
213  }
214  static unsigned hashKey(const KeyTy &key) {
215  return llvm::hash_combine(key.first, llvm::hash_value(key.second));
216  }
217 
219  static IntegerAttributeStorage *
220  construct(AttributeStorageAllocator &allocator, const KeyTy &key) {
221  Type type;
222  APInt value;
223  std::tie(type, value) = key;
224 
225  auto elements = ArrayRef<uint64_t>(value.getRawData(), value.getNumWords());
226  auto size =
227  IntegerAttributeStorage::totalSizeToAlloc<uint64_t>(elements.size());
228  auto rawMem = allocator.allocate(size, alignof(IntegerAttributeStorage));
229  auto result = ::new (rawMem) IntegerAttributeStorage(type, elements.size());
230  std::uninitialized_copy(elements.begin(), elements.end(),
231  result->getTrailingObjects<uint64_t>());
232  return result;
233  }
234 
236  APInt getValue() const {
237  if (getType().isIndex())
238  return APInt(64, {getTrailingObjects<uint64_t>(), numObjects});
239  return APInt(getType().getIntOrFloatBitWidth(),
240  {getTrailingObjects<uint64_t>(), numObjects});
241  }
242 
243  size_t numObjects;
244 };
245 
246 // An attribute representing a reference to an integer set.
248  using KeyTy = IntegerSet;
249 
251 
253  bool operator==(const KeyTy &key) const { return key == value; }
254 
258  return new (allocator.allocate<IntegerSetAttributeStorage>())
260  }
261 
263 };
264 
267  OpaqueAttributeStorage(Identifier dialectNamespace, StringRef attrData,
268  Type type)
269  : AttributeStorage(type), dialectNamespace(dialectNamespace),
270  attrData(attrData) {}
271 
273  using KeyTy = std::tuple<Identifier, StringRef, Type>;
274  bool operator==(const KeyTy &key) const {
275  return key == KeyTy(dialectNamespace, attrData, getType());
276  }
277 
279  const KeyTy &key) {
280  return new (allocator.allocate<OpaqueAttributeStorage>())
281  OpaqueAttributeStorage(std::get<0>(key),
282  allocator.copyInto(std::get<1>(key)),
283  std::get<2>(key));
284  }
285 
286  // The dialect namespace.
288 
289  // The parser attribute data for this opaque attribute.
290  StringRef attrData;
291 };
292 
295  using KeyTy = std::pair<StringRef, Type>;
296 
298  : AttributeStorage(type), value(value) {}
299 
301  bool operator==(const KeyTy &key) const {
302  return key == KeyTy(value, getType());
303  }
304 
307  const KeyTy &key) {
308  return new (allocator.allocate<StringAttributeStorage>())
309  StringAttributeStorage(allocator.copyInto(key.first), key.second);
310  }
311 
312  StringRef value;
313 };
314 
317  : public AttributeStorage,
318  public llvm::TrailingObjects<SymbolRefAttributeStorage,
319  FlatSymbolRefAttr> {
320  using KeyTy = std::pair<StringRef, ArrayRef<FlatSymbolRefAttr>>;
321 
322  SymbolRefAttributeStorage(StringRef value, size_t numNestedRefs)
323  : value(value), numNestedRefs(numNestedRefs) {}
324 
326  bool operator==(const KeyTy &key) const {
327  return key == KeyTy(value, getNestedRefs());
328  }
329 
332  construct(AttributeStorageAllocator &allocator, const KeyTy &key) {
333  auto size = SymbolRefAttributeStorage::totalSizeToAlloc<FlatSymbolRefAttr>(
334  key.second.size());
335  auto rawMem = allocator.allocate(size, alignof(SymbolRefAttributeStorage));
336  auto result = ::new (rawMem) SymbolRefAttributeStorage(
337  allocator.copyInto(key.first), key.second.size());
338  std::uninitialized_copy(key.second.begin(), key.second.end(),
339  result->getTrailingObjects<FlatSymbolRefAttr>());
340  return result;
341  }
342 
345  return {getTrailingObjects<FlatSymbolRefAttr>(), numNestedRefs};
346  }
347 
348  StringRef value;
350 };
351 
354  using KeyTy = Type;
355 
356  TypeAttributeStorage(Type value) : value(value) {}
357 
359  bool operator==(const KeyTy &key) const { return key == value; }
360 
363  KeyTy key) {
364  return new (allocator.allocate<TypeAttributeStorage>())
366  }
367 
369 };
370 
371 //===----------------------------------------------------------------------===//
372 // Elements Attributes
373 //===----------------------------------------------------------------------===//
374 
377  struct KeyTy {
378  KeyTy(ShapedType type, ArrayRef<char> data, llvm::hash_code hashCode,
379  bool isSplat = false)
380  : type(type), data(data), hashCode(hashCode), isSplat(isSplat) {}
381 
384 
387 
389  llvm::hash_code hashCode;
390 
392  bool isSplat;
393  };
394 
396  bool isSplat = false)
397  : AttributeStorage(ty), data(data), isSplat(isSplat) {}
398 
400  bool operator==(const KeyTy &key) const {
401  if (key.type != getType())
402  return false;
403 
404  // For boolean splats we need to explicitly check that the first bit is the
405  // same. Boolean values are packed at the bit level, and even though a splat
406  // is detected the rest of the bits in the first byte may differ from the
407  // splat value.
408  if (key.type.getElementTypeBitWidth() == 1) {
409  if (key.isSplat != isSplat)
410  return false;
411  if (isSplat)
412  return (key.data.front() & 1) == data.front();
413  }
414 
415  // Otherwise, we can default to just checking the data.
416  return key.data == data;
417  }
418 
423  static KeyTy getKey(ShapedType ty, ArrayRef<char> data, bool isKnownSplat) {
424  // Handle an empty storage instance.
425  if (data.empty())
426  return KeyTy(ty, data, 0);
427 
428  // If the data is already known to be a splat, the key hash value is
429  // directly the data buffer.
430  if (isKnownSplat)
431  return KeyTy(ty, data, llvm::hash_value(data), isKnownSplat);
432 
433  // Otherwise, we need to check if the data corresponds to a splat or not.
434 
435  // Handle the simple case of only one element.
436  size_t numElements = ty.getNumElements();
437  assert(numElements != 1 && "splat of 1 element should already be detected");
438 
439  // Handle boolean values directly as they are packed to 1-bit.
440  size_t elementWidth = ty.getElementTypeBitWidth();
441  if (elementWidth == 1)
442  return getKeyForBoolData(ty, data, numElements);
443 
444  // FIXME(b/121118307): using 64 bits for BF16 because it is currently stored
445  // with double semantics.
446  if (ty.getElementType().isBF16())
447  elementWidth = 64;
448 
449  // Non 1-bit dense elements are padded to 8-bits.
450  size_t storageSize = llvm::divideCeil(elementWidth, CHAR_BIT);
451  assert(((data.size() / storageSize) == numElements) &&
452  "data does not hold expected number of elements");
453 
454  // Create the initial hash value with just the first element.
455  auto firstElt = data.take_front(storageSize);
456  auto hashVal = llvm::hash_value(firstElt);
457 
458  // Check to see if this storage represents a splat. If it doesn't then
459  // combine the hash for the data starting with the first non splat element.
460  for (size_t i = storageSize, e = data.size(); i != e; i += storageSize)
461  if (memcmp(data.data(), &data[i], storageSize))
462  return KeyTy(ty, data, llvm::hash_combine(hashVal, data.drop_front(i)));
463 
464  // Otherwise, this is a splat so just return the hash of the first element.
465  return KeyTy(ty, firstElt, hashVal, /*isSplat=*/true);
466  }
467 
470  size_t numElements) {
471  ArrayRef<char> splatData = data;
472  bool splatValue = splatData.front() & 1;
473 
474  // Helper functor to generate a KeyTy for a boolean splat value.
475  auto generateSplatKey = [=] {
476  return KeyTy(ty, data.take_front(1),
477  llvm::hash_value(ArrayRef<char>(splatValue ? 1 : 0)),
478  /*isSplat=*/true);
479  };
480 
481  // Handle the case where the potential splat value is 1 and the number of
482  // elements is non 8-bit aligned.
483  size_t numOddElements = numElements % CHAR_BIT;
484  if (splatValue && numOddElements != 0) {
485  // Check that all bits are set in the last value.
486  char lastElt = splatData.back();
487  if (lastElt != llvm::maskTrailingOnes<unsigned char>(numOddElements))
488  return KeyTy(ty, data, llvm::hash_value(data));
489 
490  // If this is the only element, the data is known to be a splat.
491  if (splatData.size() == 1)
492  return generateSplatKey();
493  splatData = splatData.drop_back();
494  }
495 
496  // Check that the data buffer corresponds to a splat of the proper mask.
497  char mask = splatValue ? ~0 : 0;
498  return llvm::all_of(splatData, [mask](char c) { return c == mask; })
499  ? generateSplatKey()
500  : KeyTy(ty, data, llvm::hash_value(data));
501  }
502 
504  static llvm::hash_code hashKey(const KeyTy &key) {
505  return llvm::hash_combine(key.type, key.hashCode);
506  }
507 
511  // If the data buffer is non-empty, we copy it into the allocator with a
512  // 64-bit alignment.
513  ArrayRef<char> copy, data = key.data;
514  if (!data.empty()) {
515  char *rawData = reinterpret_cast<char *>(
516  allocator.allocate(data.size(), alignof(uint64_t)));
517  std::memcpy(rawData, data.data(), data.size());
518 
519  // If this is a boolean splat, make sure only the first bit is used.
520  if (key.isSplat && key.type.getElementTypeBitWidth() == 1)
521  rawData[0] &= 1;
522  copy = ArrayRef<char>(rawData, data.size());
523  }
524 
525  return new (allocator.allocate<DenseElementsAttributeStorage>())
527  }
528 
530  bool isSplat;
531 };
532 
536  using KeyTy = std::tuple<Type, Dialect *, StringRef>;
537 
538  OpaqueElementsAttributeStorage(Type type, Dialect *dialect, StringRef bytes)
539  : AttributeStorage(type), dialect(dialect), bytes(bytes) {}
540 
542  bool operator==(const KeyTy &key) const {
543  return key == std::make_tuple(getType(), dialect, bytes);
544  }
545  static unsigned hashKey(const KeyTy &key) {
546  return llvm::hash_combine(std::get<0>(key), std::get<1>(key),
547  std::get<2>(key));
548  }
549 
553  // TODO(b/131468830): Provide a way to avoid copying content of large opaque
554  // tensors This will likely require a new reference attribute kind.
555  return new (allocator.allocate<OpaqueElementsAttributeStorage>())
556  OpaqueElementsAttributeStorage(std::get<0>(key), std::get<1>(key),
557  allocator.copyInto(std::get<2>(key)));
558  }
559 
561  StringRef bytes;
562 };
563 
566  using KeyTy = std::tuple<Type, DenseIntElementsAttr, DenseElementsAttr>;
567 
569  DenseElementsAttr values)
570  : AttributeStorage(type), indices(indices), values(values) {}
571 
573  bool operator==(const KeyTy &key) const {
574  return key == std::make_tuple(getType(), indices, values);
575  }
576  static unsigned hashKey(const KeyTy &key) {
577  return llvm::hash_combine(std::get<0>(key), std::get<1>(key),
578  std::get<2>(key));
579  }
580 
584  return new (allocator.allocate<SparseElementsAttributeStorage>())
585  SparseElementsAttributeStorage(std::get<0>(key), std::get<1>(key),
586  std::get<2>(key));
587  }
588 
591 };
592 } // namespace detail
593 } // namespace mlir
594 
595 #endif // ATTRIBUTEDETAIL_H_
Type getType() const
Get the type of this attribute.
Definition: Attributes.cpp:31
Definition: InferTypeOpInterface.cpp:20
Dialect * dialect
Definition: AttributeDetail.h:560
static unsigned hashKey(const KeyTy &key)
Definition: AttributeDetail.h:214
bool operator==(const KeyTy &key) const
We only check equality for and hash with the boolean key parameter.
Definition: AttributeDetail.h:76
size_t numObjects
Definition: AttributeDetail.h:196
static IntegerSetAttributeStorage * construct(AttributeStorageAllocator &allocator, KeyTy key)
Construct a new storage instance.
Definition: AttributeDetail.h:257
bool isSplat
A boolean that indicates if this data is a splat or not.
Definition: AttributeDetail.h:392
static unsigned hashKey(const KeyTy &key)
Definition: AttributeDetail.h:77
An attribute representing a floating point value.
Definition: AttributeDetail.h:138
IntegerAttributeStorage(Type type, size_t numObjects)
Definition: AttributeDetail.h:205
Integer types can have arbitrary bitwidth up to a large fixed limit.
Definition: StandardTypes.h:82
Definition: Attributes.h:139
SymbolRefAttributeStorage(StringRef value, size_t numNestedRefs)
Definition: AttributeDetail.h:322
Definition: Attributes.h:129
Definition: Attributes.h:491
mlir::edsc::intrinsics::OperationBuilder< CopyOp > copy
Definition: Intrinsics.h:21
SparseElementsAttributeStorage(Type type, DenseIntElementsAttr indices, DenseElementsAttr values)
Definition: AttributeDetail.h:568
OpaqueElementsAttributeStorage(Type type, Dialect *dialect, StringRef bytes)
Definition: AttributeDetail.h:538
bool operator==(const KeyTy &key) const
Definition: AttributeDetail.h:274
Definition: StorageUniquer.h:89
Definition: Identifier.h:26
FloatAttributeStorage(const llvm::fltSemantics &semantics, Type type, size_t numObjects)
Definition: AttributeDetail.h:143
Definition: StandardTypes.h:113
static StringAttributeStorage * construct(AttributeStorageAllocator &allocator, const KeyTy &key)
Construct a new storage instance.
Definition: AttributeDetail.h:306
size_t numNestedRefs
Definition: AttributeDetail.h:349
AffineMap value
Definition: AttributeDetail.h:46
static ArrayAttributeStorage * construct(AttributeStorageAllocator &allocator, const KeyTy &key)
Construct a new storage instance.
Definition: AttributeDetail.h:59
StringRef value
Definition: AttributeDetail.h:312
bool operator==(const KeyTy &key) const
Key equality function.
Definition: AttributeDetail.h:359
BoolAttributeStorage(Type type, bool value)
Definition: AttributeDetail.h:72
static unsigned hashKey(const KeyTy &key)
Definition: AttributeDetail.h:545
static BoolAttributeStorage * construct(AttributeStorageAllocator &allocator, const KeyTy &key)
Definition: AttributeDetail.h:81
bool operator==(const KeyTy &key) const
Key equality function.
Definition: AttributeDetail.h:102
AffineMap KeyTy
Definition: AttributeDetail.h:31
Definition: StandardTypes.h:178
bool operator==(const KeyTy &key) const
Key equality and hash functions.
Definition: AttributeDetail.h:542
An attribute representing an array of other attributes.
Definition: AttributeDetail.h:50
std::pair< Identifier, Attribute > NamedAttribute
Definition: Attributes.h:264
std::tuple< Type, Dialect *, StringRef > KeyTy
Definition: AttributeDetail.h:536
const llvm::fltSemantics & getFloatSemantics()
Return the floating semantics of this float type.
Definition: StandardTypes.cpp:86
bool isIndex()
Definition: StandardTypes.cpp:30
bool value
Definition: AttributeDetail.h:87
An attribute representing a reference to a sparse vector or tensor object.
Definition: AttributeDetail.h:565
std::pair< StringRef, ArrayRef< FlatSymbolRefAttr > > KeyTy
Definition: AttributeDetail.h:320
static SparseElementsAttributeStorage * construct(AttributeStorageAllocator &allocator, KeyTy key)
Construct a new storage instance.
Definition: AttributeDetail.h:583
static IntegerType get(unsigned width, MLIRContext *context)
Definition: MLIRContext.cpp:511
bool operator==(const KeyTy &key) const
Key equality function.
Definition: AttributeDetail.h:301
T * allocate()
Allocate an instance of the provided type.
Definition: StorageUniquer.h:109
DenseElementsAttributeStorage(ShapedType ty, ArrayRef< char > data, bool isSplat=false)
Definition: AttributeDetail.h:395
DenseElementsAttr values
Definition: AttributeDetail.h:590
An attribute representing a integral value.
Definition: AttributeDetail.h:200
IntegerSet value
Definition: AttributeDetail.h:262
An attribute representing a boolean value.
Definition: AttributeDetail.h:69
static IntegerAttributeStorage * construct(AttributeStorageAllocator &allocator, const KeyTy &key)
Construct a new storage instance.
Definition: AttributeDetail.h:220
Definition: LLVM.h:37
AffineMapAttributeStorage(AffineMap value)
Definition: AttributeDetail.h:33
size_t numObjects
Definition: AttributeDetail.h:243
Definition: Attributes.h:660
StringRef value
Definition: AttributeDetail.h:348
std::pair< MLIRContext *, bool > KeyTy
Definition: AttributeDetail.h:70
std::tuple< Identifier, StringRef, Type > KeyTy
The hash key used for uniquing.
Definition: AttributeDetail.h:273
bool isBF16()
Definition: StandardTypes.cpp:25
An attribute representing a reference to a dense vector or tensor object.
Definition: AttributeDetail.h:376
bool operator==(const KeyTy &key) const
Key equality function.
Definition: AttributeDetail.h:37
Definition: Dialect.h:39
StringAttributeStorage(StringRef value, Type type)
Definition: AttributeDetail.h:297
StringRef bytes
Definition: AttributeDetail.h:561
static KeyTy getKey(Type type, double value)
Construct a key with a type and double.
Definition: AttributeDetail.h:156
static llvm::hash_code hashKey(const KeyTy &key)
Hash the key for the storage.
Definition: AttributeDetail.h:504
TypeAttributeStorage(Type value)
Definition: AttributeDetail.h:356
bool operator==(const KeyTy &key) const
Key equality function.
Definition: AttributeDetail.h:326
bool operator==(const KeyTy &key) const
Key equality function.
Definition: AttributeDetail.h:253
Definition: AffineMap.h:37
APFloat getValue() const
Returns an APFloat representing the stored value.
Definition: AttributeDetail.h:189
Type value
Definition: AttributeDetail.h:368
ArrayRef< NamedAttribute > getElements() const
Return the elements of this dictionary attribute.
Definition: AttributeDetail.h:119
static FloatAttributeStorage * construct(AttributeStorageAllocator &allocator, const KeyTy &key)
Construct a new storage instance.
Definition: AttributeDetail.h:171
bool operator==(const KeyTy &key) const
Key equality and hash functions.
Definition: AttributeDetail.h:211
Opaque Attribute Storage and Uniquing.
Definition: AttributeDetail.h:266
ArrayRef< char > data
The raw buffer for the data storage.
Definition: AttributeDetail.h:386
Definition: AttributeDetail.h:247
static KeyTy getKeyForBoolData(ShapedType ty, ArrayRef< char > data, size_t numElements)
Construct a key with a set of boolean data.
Definition: AttributeDetail.h:469
static OpaqueElementsAttributeStorage * construct(AttributeStorageAllocator &allocator, KeyTy key)
Construct a new storage instance.
Definition: AttributeDetail.h:552
Definition: Types.h:84
Definition: AttributeDetail.h:30
DenseIntElementsAttr indices
Definition: AttributeDetail.h:589
An attribute representing a symbol reference.
Definition: AttributeDetail.h:316
static AffineMapAttributeStorage * construct(AttributeStorageAllocator &allocator, KeyTy key)
Construct a new storage instance.
Definition: AttributeDetail.h:41
Type getElementType() const
Return the element type.
Definition: StandardTypes.cpp:119
inline ::llvm::hash_code hash_value(AffineExpr arg)
Make AffineExpr hashable.
Definition: AffineExpr.h:201
static unsigned hashKey(const KeyTy &key)
Definition: AttributeDetail.h:576
Definition: AttributeDetail.h:535
static DenseElementsAttributeStorage * construct(AttributeStorageAllocator &allocator, KeyTy key)
Construct a new storage instance.
Definition: AttributeDetail.h:510
std::pair< StringRef, Type > KeyTy
Definition: AttributeDetail.h:295
Identifier dialectNamespace
Definition: AttributeDetail.h:287
std::tuple< Type, DenseIntElementsAttr, DenseElementsAttr > KeyTy
Definition: AttributeDetail.h:566
IntegerSetAttributeStorage(IntegerSet value)
Definition: AttributeDetail.h:250
bool operator==(const KeyTy &key) const
Key equality and hash functions.
Definition: AttributeDetail.h:148
KeyTy(ShapedType type, ArrayRef< char > data, llvm::hash_code hashCode, bool isSplat=false)
Definition: AttributeDetail.h:378
static DictionaryAttributeStorage * construct(AttributeStorageAllocator &allocator, const KeyTy &key)
Construct a new storage instance.
Definition: AttributeDetail.h:106
An attribute representing a string value.
Definition: AttributeDetail.h:294
static OpaqueAttributeStorage * construct(AttributeStorageAllocator &allocator, const KeyTy &key)
Definition: AttributeDetail.h:278
APInt getValue() const
Returns an APInt representing the stored value.
Definition: AttributeDetail.h:236
static TypeAttributeStorage * construct(AttributeStorageAllocator &allocator, KeyTy key)
Construct a new storage instance.
Definition: AttributeDetail.h:362
std::pair< Type, APFloat > KeyTy
Definition: AttributeDetail.h:141
ArrayRef< char > data
Definition: AttributeDetail.h:529
Definition: AttributeSupport.h:34
bool isSplat
Definition: AttributeDetail.h:530
const llvm::fltSemantics & semantics
Definition: AttributeDetail.h:195
ArrayRef< T > copyInto(ArrayRef< T > elements)
Definition: StorageUniquer.h:93
llvm::hash_code hashCode
The computed hash code for the storage data.
Definition: AttributeDetail.h:389
StringRef attrData
Definition: AttributeDetail.h:290
bool isa() const
Definition: Types.h:254
An attribute representing a dictionary of sorted named attributes.
Definition: AttributeDetail.h:91
Definition: StandardTypes.h:70
bool operator==(const KeyTy &key) const
Compare this storage instance with the provided key.
Definition: AttributeDetail.h:400
int64_t getNumElements() const
If it has static shape, return the number of elements. Otherwise, abort.
Definition: StandardTypes.cpp:127
bool operator==(const KeyTy &key) const
Key equality and hash functions.
Definition: AttributeDetail.h:573
bool operator==(const KeyTy &key) const
Key equality function.
Definition: AttributeDetail.h:56
unsigned getElementTypeBitWidth() const
Definition: StandardTypes.cpp:123
ArrayRef< FlatSymbolRefAttr > getNestedRefs() const
Returns the set of nested references.
Definition: AttributeDetail.h:344
std::pair< Type, APInt > KeyTy
Definition: AttributeDetail.h:203
ArrayRef< Attribute > value
Definition: AttributeDetail.h:65
bool isF64()
Definition: StandardTypes.cpp:28
Definition: Attributes.h:135
static SymbolRefAttributeStorage * construct(AttributeStorageAllocator &allocator, const KeyTy &key)
Construct a new storage instance.
Definition: AttributeDetail.h:332
static unsigned hashKey(const KeyTy &key)
Definition: AttributeDetail.h:151
ArrayAttributeStorage(ArrayRef< Attribute > value)
Definition: AttributeDetail.h:53
ShapedType type
The type of the dense elements.
Definition: AttributeDetail.h:383
Definition: Attributes.h:1012
U cast() const
Definition: Types.h:264
static KeyTy getKey(ShapedType ty, ArrayRef< char > data, bool isKnownSplat)
Definition: AttributeDetail.h:423
OpaqueAttributeStorage(Identifier dialectNamespace, StringRef attrData, Type type)
Definition: AttributeDetail.h:267
An attribute representing a reference to a type.
Definition: AttributeDetail.h:353
Definition: IntegerSet.h:42