[Mlir-commits] [mlir] [mlir][spirv] Implement vector type legalization for function signatures (PR #98337)
Angel Zhang
llvmlistbot at llvm.org
Fri Jul 12 07:54:42 PDT 2024
================
@@ -37,20 +37,37 @@ using namespace mlir;
namespace {
/// A pass to perform the SPIR-V conversion.
-struct ConvertToSPIRVPass final
- : impl::ConvertToSPIRVPassBase<ConvertToSPIRVPass> {
+struct ConvertToSPIRVPass
+ : public impl::ConvertToSPIRVPassBase<ConvertToSPIRVPass> {
+ using ConvertToSPIRVPassBase::ConvertToSPIRVPassBase;
void runOnOperation() override {
MLIRContext *context = &getContext();
Operation *op = getOperation();
+ if (runSignatureConversion) {
+ // Unroll vectors in function signatures to native vector size.
+ {
+ RewritePatternSet patterns(context);
+ populateFuncOpVectorRewritePatterns(patterns);
+ populateReturnOpVectorRewritePatterns(patterns);
+ GreedyRewriteConfig config;
+ config.strictMode = GreedyRewriteStrictness::ExistingOps;
+ if (failed(
+ applyPatternsAndFoldGreedily(op, std::move(patterns), config)))
+ return signalPassFailure();
+ }
+ return;
----------------
angelz913 wrote:
My thinking is that this PR only takes care of the new patterns, so the new tests I added only check for the correctness of those patterns, without going through the SPIR-V dialect conversion (the rest of this pass). In the future, I will add more vector patterns and more command-line options for controlling/testing.
https://github.com/llvm/llvm-project/pull/98337
More information about the Mlir-commits
mailing list