Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mlir/include/mlir/Dialect/DLTI/DLTI.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ namespace dlti {
/// query interface-implementing attrs, starting from attr obtained from `op`.
FailureOr<Attribute> query(Operation *op, ArrayRef<DataLayoutEntryKey> keys,
bool emitError = false);

/// Perform a DLTI-query at `op` using string `keys` as DLTI entry keys,
/// recursively querying on query interface-implementing attrs, starting from
/// attr obtained from `op`.
FailureOr<Attribute> query(Operation *op, ArrayRef<StringRef> keys,
bool emitError = false);
} // namespace dlti
} // namespace mlir

Expand Down
16 changes: 16 additions & 0 deletions mlir/lib/Dialect/DLTI/DLTI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ getClosestQueryable(Operation *op) {

FailureOr<Attribute>
dlti::query(Operation *op, ArrayRef<DataLayoutEntryKey> keys, bool emitError) {
if (!op)
return failure();

if (keys.empty()) {
if (emitError) {
auto diag = op->emitError() << "target op of failed DLTI query";
Expand Down Expand Up @@ -562,6 +565,19 @@ dlti::query(Operation *op, ArrayRef<DataLayoutEntryKey> keys, bool emitError) {
return currentAttr;
}

FailureOr<Attribute> dlti::query(Operation *op, ArrayRef<StringRef> keys,
bool emitError) {
if (!op)
return failure();

MLIRContext *ctx = op->getContext();
SmallVector<DataLayoutEntryKey> entryKeys;
for (StringRef key : keys)
entryKeys.push_back(StringAttr::get(ctx, key));

return dlti::query(op, entryKeys, emitError);
}

constexpr const StringLiteral mlir::DLTIDialect::kDataLayoutAttrName;
constexpr const StringLiteral mlir::DLTIDialect::kDataLayoutEndiannessKey;
constexpr const StringLiteral mlir::DLTIDialect::kDataLayoutEndiannessBig;
Expand Down