Skip to content

Commit

Permalink
(Partial backport) [mlir][NFC] Simplify type checks with isa predicat…
Browse files Browse the repository at this point in the history
…es (llvm#87183)

For more context on isa predicates, see:
llvm#83753.
  • Loading branch information
kuhar authored and mgehre-amd committed Apr 26, 2024
1 parent ac88769 commit 79f313a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions mlir/lib/Dialect/EmitC/IR/EmitC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ LogicalResult emitc::CallOpaqueOp::verify() {
}
}

if (llvm::any_of(getResultTypes(),
[](Type type) { return isa<ArrayType>(type); })) {
if (llvm::any_of(getResultTypes(), llvm::IsaPred<ArrayType>)) {
return emitOpError() << "cannot return array type";
}

Expand Down
5 changes: 2 additions & 3 deletions mlir/lib/Target/Cpp/TranslateToCpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,7 @@ static LogicalResult printOperation(CppEmitter &emitter,
"with multiple blocks needs variables declared at top");
}

if (llvm::any_of(functionOp.getResultTypes(),
[](Type type) { return isa<ArrayType>(type); })) {
if (llvm::any_of(functionOp.getResultTypes(), llvm::IsaPred<ArrayType>)) {
return functionOp.emitOpError() << "cannot emit array type as result type";
}

Expand Down Expand Up @@ -1619,7 +1618,7 @@ LogicalResult CppEmitter::emitTypes(Location loc, ArrayRef<Type> types) {
}

LogicalResult CppEmitter::emitTupleType(Location loc, ArrayRef<Type> types) {
if (llvm::any_of(types, [](Type type) { return isa<ArrayType>(type); })) {
if (llvm::any_of(types, llvm::IsaPred<ArrayType>)) {
return emitError(loc, "cannot emit tuple of array type");
}
os << "std::tuple<";
Expand Down

0 comments on commit 79f313a

Please sign in to comment.