From ffb8bf03ed09e08cb554111f103105999118f288 Mon Sep 17 00:00:00 2001 From: Md Abdullah Shahneous Bari <98356296+mshahneo@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:36:54 -0400 Subject: [PATCH] =?UTF-8?q?[XeGPUToVC]=20Add=20target=20based=20legality?= =?UTF-8?q?=20check=20for=20MathToVC=20patterns=20ear=E2=80=A6=20(#950)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [XeGPUToVC] Add target based legality check for MathToVC patterns early in the pass. Configuring the legality for MathToVC pass has to be done early. Since, XeGPUToVC makes some arith ops dynamically legal in the target environment. Making the whole dialect legal (needed for MathToVC) has to be done before conditionally making some ops legal. Also add MathToVC as the link target for the XeGPUToVC pass. --- lib/Conversion/XeGPUToVC/CMakeLists.txt | 1 + lib/Conversion/XeGPUToVC/XeGPUToVC.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Conversion/XeGPUToVC/CMakeLists.txt b/lib/Conversion/XeGPUToVC/CMakeLists.txt index 262a04ec9..1c1594bf5 100644 --- a/lib/Conversion/XeGPUToVC/CMakeLists.txt +++ b/lib/Conversion/XeGPUToVC/CMakeLists.txt @@ -11,6 +11,7 @@ add_imex_conversion_library(IMEXXeGPUToVC #LINK_COMPONENTS LINK_LIBS PUBLIC + IMEXMathToVC MLIRIR MLIRSupport # MLIRTransforms diff --git a/lib/Conversion/XeGPUToVC/XeGPUToVC.cpp b/lib/Conversion/XeGPUToVC/XeGPUToVC.cpp index 6c5200137..61fb8efc4 100644 --- a/lib/Conversion/XeGPUToVC/XeGPUToVC.cpp +++ b/lib/Conversion/XeGPUToVC/XeGPUToVC.cpp @@ -865,6 +865,9 @@ struct XeGPUToVCPass : public imex::impl::ConvertXeGPUToVCBase { RewritePatternSet patterns(&getContext()); ConversionTarget target(getContext()); + // Configure the legality of the conversion target for MathToVC patterns. + configureMathToVCConversionLegality(target); + target.addLegalDialect(); target.addIllegalDialect(); @@ -960,8 +963,6 @@ struct XeGPUToVCPass : public imex::impl::ConvertXeGPUToVCBase { populateMathToVCPatterns(typeConverter, patterns); - configureMathToVCConversionLegality(target); - if (failed(applyPartialConversion(m, target, std::move(patterns)))) return signalPassFailure(); }