Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/IR/AttributeDetail.h
Show First 20 Lines • Show All 313 Lines • ▼ Show 20 Lines | construct(AttributeStorageAllocator &allocator, KeyTy key) { | ||||
return new (allocator.allocate<DenseStringElementsAttrStorage>()) | return new (allocator.allocate<DenseStringElementsAttrStorage>()) | ||||
DenseStringElementsAttrStorage(key.type, copy, key.isSplat); | DenseStringElementsAttrStorage(key.type, copy, key.isSplat); | ||||
} | } | ||||
ArrayRef<StringRef> data; | ArrayRef<StringRef> data; | ||||
}; | }; | ||||
//===----------------------------------------------------------------------===// | |||||
// StringAttr | |||||
//===----------------------------------------------------------------------===// | |||||
struct StringAttrStorage : public AttributeStorage { | |||||
StringAttrStorage(StringRef value, Type type) | |||||
: AttributeStorage(type), value(value), referencedDialect(nullptr) {} | |||||
/// The hash key is a tuple of the parameter types. | |||||
using KeyTy = std::pair<StringRef, Type>; | |||||
bool operator==(const KeyTy &key) const { | |||||
return value == key.first && getType() == key.second; | |||||
} | |||||
static ::llvm::hash_code hashKey(const KeyTy &key) { | |||||
return DenseMapInfo<KeyTy>::getHashValue(key); | |||||
} | |||||
/// Define a construction method for creating a new instance of this | |||||
/// storage. | |||||
static StringAttrStorage *construct(AttributeStorageAllocator &allocator, | |||||
const KeyTy &key) { | |||||
return new (allocator.allocate<StringAttrStorage>()) | |||||
StringAttrStorage(allocator.copyInto(key.first), key.second); | |||||
} | |||||
/// Initialize the storage given an MLIRContext. | |||||
void initialize(MLIRContext *context); | |||||
/// The raw string value. | |||||
StringRef value; | |||||
/// If the string value contains a dialect namespace prefix (e.g. | |||||
/// dialect.blah), this is the dialect referenced. | |||||
Dialect *referencedDialect; | |||||
}; | |||||
} // namespace detail | } // namespace detail | ||||
} // namespace mlir | } // namespace mlir | ||||
#endif // ATTRIBUTEDETAIL_H_ | #endif // ATTRIBUTEDETAIL_H_ |