Skip to content

Commit df85259

Browse files
committed
[mlir] Split up VectorToLLVM pass
Currently, the VectorToLLVM patterns are built into a library along with the corresponding pass, which also pulls in all the platform-specific vector dialects (like AMXDialect) to apply all the vector to LLVM conversions. This causes dependency bloat when writing libraries - for example the GPU to LLVM passes, which use the vector to LLVM patterns, don't need the X86Vector dialect to be present at all. This commit partitions the library into VectorToLLVM and VectorToLLVMPass, where the latter pulls in all the other vector transformations. Reviewed By: nicolasvasilache, mehdi_amini Differential Revision: https://reviews.llvm.org/D158287
1 parent b4b4d8b commit df85259

File tree

13 files changed

+51
-24
lines changed

13 files changed

+51
-24
lines changed

mlir/include/mlir/Conversion/Passes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
#include "mlir/Conversion/UBToSPIRV/UBToSPIRV.h"
6464
#include "mlir/Conversion/VectorToArmSME/VectorToArmSME.h"
6565
#include "mlir/Conversion/VectorToGPU/VectorToGPU.h"
66-
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
66+
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h"
6767
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
6868
#include "mlir/Conversion/VectorToSPIRV/VectorToSPIRVPass.h"
6969

mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
namespace mlir {
1414
class LLVMTypeConverter;
15-
class Pass;
16-
17-
#define GEN_PASS_DECL_CONVERTVECTORTOLLVMPASS
18-
#include "mlir/Conversion/Passes.h.inc"
1915

2016
/// Collect a set of patterns to convert from Vector contractions to LLVM Matrix
2117
/// Intrinsics. To lower to assembly, the LLVM flag -lower-matrix-intrinsics
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===- ConvertVectorToLLVMPass.h - Pass to check Vector->LLVM --- --===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
#ifndef MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLLVMPASS_H_
9+
#define MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLLVMPASS_H_
10+
11+
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
12+
13+
namespace mlir {
14+
class Pass;
15+
16+
#define GEN_PASS_DECL_CONVERTVECTORTOLLVMPASS
17+
#include "mlir/Conversion/Passes.h.inc"
18+
} // namespace mlir
19+
#endif // MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLLVMPASS_H_

mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#ifndef MLIR_DIALECT_SPARSETENSOR_PIPELINES_PASSES_H_
1414
#define MLIR_DIALECT_SPARSETENSOR_PIPELINES_PASSES_H_
1515

16-
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
16+
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h"
1717
#include "mlir/Dialect/SparseTensor/Transforms/Passes.h"
1818
#include "mlir/Pass/PassOptions.h"
1919

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_mlir_conversion_library(MLIRVectorToLLVM
2+
PARTIAL_SOURCES_INTENDED
23
ConvertVectorToLLVM.cpp
3-
ConvertVectorToLLVMPass.cpp
44

55
ADDITIONAL_HEADER_DIRS
66
${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/VectorToLLVM
@@ -14,21 +14,33 @@ add_mlir_conversion_library(MLIRVectorToLLVM
1414

1515
LINK_LIBS PUBLIC
1616
MLIRArithDialect
17-
MLIRArmNeonDialect
18-
MLIRArmSMEDialect
19-
MLIRArmSMETransforms
20-
MLIRVectorToArmSME
21-
MLIRArmSVEDialect
22-
MLIRArmSVETransforms
23-
MLIRAMXDialect
24-
MLIRAMXTransforms
2517
MLIRLLVMCommonConversion
2618
MLIRLLVMDialect
2719
MLIRMemRefDialect
2820
MLIRTargetLLVMIRExport
2921
MLIRTransforms
3022
MLIRVectorDialect
3123
MLIRVectorTransforms
24+
)
25+
26+
add_mlir_conversion_library(MLIRVectorToLLVMPass
27+
PARTIAL_SOURCES_INTENDED
28+
29+
ConvertVectorToLLVMPass.cpp
30+
ADDITIONAL_HEADER_DIRS
31+
${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/VectorToLLVM
32+
33+
LINK_LIBS PUBLIC
34+
MLIRVectorToLLVM
35+
36+
MLIRArmNeonDialect
37+
MLIRArmSMEDialect
38+
MLIRArmSMETransforms
39+
MLIRArmSVEDialect
40+
MLIRArmSVETransforms
41+
MLIRVectorToArmSME
42+
MLIRAMXDialect
43+
MLIRAMXTransforms
3244
MLIRX86VectorDialect
3345
MLIRX86VectorTransforms
34-
)
46+
)

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
9+
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h"
1010

1111
#include "mlir/Conversion/LLVMCommon/ConversionTarget.h"
1212
#include "mlir/Conversion/LLVMCommon/TypeConverter.h"

mlir/lib/Dialect/SparseTensor/Pipelines/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ add_mlir_dialect_library(MLIRSparseTensorPipelines
2424
MLIRSparseTensorDialect
2525
MLIRSparseTensorTransforms
2626
MLIRTensorTransforms
27-
MLIRVectorToLLVM
27+
MLIRVectorToLLVMPass
2828
MLIRVectorTransforms
2929
)

mlir/test/lib/Dialect/GPU/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set(LIBS
2727
MLIRTransforms
2828
MLIRTransformUtils
2929
MLIRTranslateLib
30-
MLIRVectorToLLVM
30+
MLIRVectorToLLVMPass
3131
)
3232

3333
add_mlir_library(MLIRGPUTestPasses

mlir/test/lib/Dialect/GPU/TestLowerToNVVM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "mlir/Conversion/NVGPUToNVVM/NVGPUToNVVM.h"
2323
#include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h"
2424
#include "mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h"
25-
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
25+
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h"
2626
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
2727
#include "mlir/Dialect/Func/IR/FuncOps.h"
2828
#include "mlir/Dialect/GPU/IR/GPUDialect.h"

mlir/test/lib/Dialect/LLVM/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ add_mlir_library(MLIRLLVMTestPasses
1919
MLIRReconcileUnrealizedCasts
2020
MLIRSCFToControlFlow
2121
MLIRTransforms
22-
MLIRVectorToLLVM
22+
MLIRVectorToLLVMPass
2323
MLIRVectorToSCF
2424
)

mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h"
1919
#include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h"
2020
#include "mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h"
21-
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
21+
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h"
2222
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
2323
#include "mlir/Dialect/Func/IR/FuncOps.h"
2424
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"

mlir/tools/mlir-vulkan-runner/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ if (MLIR_ENABLE_VULKAN_RUNNER)
7272
MLIRTransforms
7373
MLIRTranslateLib
7474
MLIRVectorDialect
75-
MLIRVectorToLLVM
75+
MLIRVectorToLLVMPass
7676
${Vulkan_LIBRARY}
7777
)
7878

mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "mlir/Conversion/LLVMCommon/LoweringOptions.h"
1919
#include "mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h"
2020
#include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h"
21-
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
21+
#include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.h"
2222
#include "mlir/Dialect/Arith/IR/Arith.h"
2323
#include "mlir/Dialect/Func/IR/FuncOps.h"
2424
#include "mlir/Dialect/GPU/IR/GPUDialect.h"

0 commit comments

Comments
 (0)