[Mlir-commits] [mlir] [mlir][ArmSME] Verify ops on tile types post LLVM conversion (PR #92076)
Cullen Rhodes
llvmlistbot at llvm.org
Wed May 15 01:36:48 PDT 2024
================
@@ -872,9 +873,33 @@ struct ConvertArmSMEToLLVMPass
configureArmSMEToLLVMConversionLegality(target);
populateArmSMEToLLVMConversionPatterns(converter, patterns);
- if (failed(applyPartialConversion(getOperation(), target,
- std::move(patterns))))
+ Operation *moduleOp = getOperation();
+ if (failed(applyPartialConversion(moduleOp, target, std::move(patterns))))
signalPassFailure();
+
+ // Walk the function(s) and fail if there are unexpected operations on SME
+ // tile types after conversion.
+ moduleOp->walk([&](func::FuncOp funcOp) {
+ funcOp->walk([&](Operation *op) {
+ // These ops are legal post conversion, skip these.
+ // Note: 'test.some_use' is a dummy op we use extensively in the tests
+ // to prevent tile ops being DCE'd.
+ if (isa<arm_sme::MaterializeSSATileOp, cf::BranchOp, scf::ForOp,
+ scf::YieldOp>(op) ||
+ op->getName().getStringRef() == "test.some_use")
+ return;
+ auto isSMETileType = [](Type type) -> bool {
+ auto vecType = dyn_cast<VectorType>(type);
+ return vecType && arm_sme::isValidSMETileVectorType(vecType);
+ };
+ if (llvm::any_of(op->getResultTypes(), isSMETileType) ||
+ llvm::any_of(op->getOperandTypes(), isSMETileType)) {
----------------
c-rhodes wrote:
it didn't like that (error) below so I wrapped it in a lambda
> /home/culrho01/llvm-project/mlir/lib/Conversion/ArmSMEToLLVM/ArmSMEToLLVM.cpp:889:11: error: no matching function for call to 'any_of'
889 | if (llvm::any_of(op->getResultTypes(), arm_sme::isValidSMETileVectorType) ||
| ^~~~~~~~~~~~
/home/culrho01/llvm-project/llvm/include/llvm/ADT/STLExtras.h:1729:6: note: candidate template ignored: couldn't infer template argument 'UnaryPredicate'
1729 | bool any_of(R &&Range, UnaryPredicate P) {
| ^
https://github.com/llvm/llvm-project/pull/92076
More information about the Mlir-commits
mailing list