[Mlir-commits] [mlir] [MLIR][DLTI] Enable types as keys in DLTI-query utils (PR #105995)
Rolf Morel
llvmlistbot at llvm.org
Mon Aug 26 15:13:04 PDT 2024
================
@@ -438,6 +446,15 @@ FailureOr<Attribute> dlti::query(Operation *op, ArrayRef<StringAttr> keys,
return failure();
}
+ auto keyToStr = [](DataLayoutEntryKey key) -> std::string {
+ std::string buf;
+ llvm::TypeSwitch<DataLayoutEntryKey>(key)
+ .Case<StringAttr, Type>( // The only two kinds of key we know of.
+ [&](auto key) { llvm::raw_string_ostream(buf) << key; })
+ .Default([](auto) { llvm_unreachable("unexpected entry key kind"); });
+ return buf;
+ };
----------------
rolfmorel wrote:
This lambda is only invoked when `emitError=true`, i.e. these conversions to a string only happen when error messages get generated.
I am only making use of `::print(..)` here because I had no other way of obtaining an accurate representation of a `Type` key. If there's a more efficient way to get a string representation of an arbitrary `Type`, I am more than happy to use that instead.
https://github.com/llvm/llvm-project/pull/105995
More information about the Mlir-commits
mailing list