Skip to content

Commit 6ae7f66

Browse files
committed
[mlir] Add config for PDL (#69927)
Make it so that PDL in pattern rewrites can be optionally disabled. PDL is still enabled by default and not optional bazel. So this should be a NOP for most folks, while enabling other to disable. This only works with tests disabled. With tests enabled this still compiles but tests fail as there is no lit config to disable tests that depend on PDL rewrites yet.
1 parent cda388c commit 6ae7f66

File tree

27 files changed

+1327
-1091
lines changed

27 files changed

+1327
-1091
lines changed

mlir/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ set(MLIR_ENABLE_NVPTXCOMPILER 0 CACHE BOOL
133133
"Statically link the nvptxlibrary instead of calling ptxas as a subprocess \
134134
for compiling PTX to cubin")
135135

136+
set(MLIR_ENABLE_PDL_IN_PATTERNMATCH 1 CACHE BOOL "Enable PDL in PatternMatch")
137+
136138
option(MLIR_INCLUDE_TESTS
137139
"Generate build targets for the MLIR unit tests."
138140
${LLVM_INCLUDE_TESTS})
@@ -178,10 +180,9 @@ include_directories( ${MLIR_INCLUDE_DIR})
178180
# Adding tools/mlir-tblgen here as calling add_tablegen sets some variables like
179181
# MLIR_TABLEGEN_EXE in PARENT_SCOPE which gets lost if that folder is included
180182
# from another directory like tools
181-
add_subdirectory(tools/mlir-tblgen)
182183
add_subdirectory(tools/mlir-linalg-ods-gen)
183184
add_subdirectory(tools/mlir-pdll)
184-
185+
add_subdirectory(tools/mlir-tblgen)
185186
set(MLIR_TABLEGEN_EXE "${MLIR_TABLEGEN_EXE}" CACHE INTERNAL "")
186187
set(MLIR_TABLEGEN_TARGET "${MLIR_TABLEGEN_TARGET}" CACHE INTERNAL "")
187188
set(MLIR_PDLL_TABLEGEN_EXE "${MLIR_PDLL_TABLEGEN_EXE}" CACHE INTERNAL "")

mlir/examples/minimal-opt/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ Below are some example measurements taken at the time of the LLVM 17 release,
1414
using clang-14 on a X86 Ubuntu and [bloaty](https://github.com/google/bloaty).
1515

1616
| | Base | Os | Oz | Os LTO | Oz LTO |
17-
| :-----------------------------: | ------ | ------ | ------ | ------ | ------ |
18-
| `mlir-cat` | 1018kB | 836KB | 879KB | 697KB | 649KB |
19-
| `mlir-minimal-opt` | 1.54MB | 1.25MB | 1.29MB | 1.10MB | 1.00MB |
20-
| `mlir-minimal-opt-canonicalize` | 2.24MB | 1.81MB | 1.86MB | 1.62MB | 1.48MB |
17+
| :------------------------------: | ------ | ------ | ------ | ------ | ------ |
18+
| `mlir-cat` | 1024KB | 840KB | 885KB | 706KB | 657KB |
19+
| `mlir-minimal-opt` | 1.62MB | 1.32MB | 1.36MB | 1.17MB | 1.07MB |
20+
| `mlir-minimal-opt-canonicalize` | 1.83MB | 1.40MB | 1.45MB | 1.25MB | 1.14MB |
2121

2222
Base configuration:
2323

@@ -32,6 +32,7 @@ cmake ../llvm/ -G Ninja \
3232
-DCMAKE_CXX_COMPILER=clang++ \
3333
-DLLVM_ENABLE_LLD=ON \
3434
-DLLVM_ENABLE_BACKTRACES=OFF \
35+
-DMLIR_ENABLE_PDL_IN_PATTERNMATCH=OFF \
3536
-DCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO=-Wl,-icf=all
3637
```
3738

mlir/include/mlir/Config/mlir-config.h.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@
2626
numeric seed that is passed to the random number generator. */
2727
#cmakedefine MLIR_GREEDY_REWRITE_RANDOMIZER_SEED ${MLIR_GREEDY_REWRITE_RANDOMIZER_SEED}
2828

29+
/* If set, enables PDL usage. */
30+
#cmakedefine01 MLIR_ENABLE_PDL_IN_PATTERNMATCH
31+
2932
#endif

mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define MLIR_CONVERSION_LLVMCOMMON_TYPECONVERTER_H
1616

1717
#include "mlir/Conversion/LLVMCommon/LoweringOptions.h"
18+
#include "mlir/IR/BuiltinTypes.h"
1819
#include "mlir/Transforms/DialectConversion.h"
1920

2021
namespace mlir {

mlir/include/mlir/Dialect/Vector/IR/VectorOps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "mlir/Interfaces/SideEffectInterfaces.h"
3030
#include "mlir/Interfaces/VectorInterfaces.h"
3131
#include "mlir/Interfaces/ViewLikeInterface.h"
32+
#include "llvm/ADT/SetVector.h"
3233
#include "llvm/ADT/StringExtras.h"
3334

3435
// Pull in all enum type definitions and utility function declarations.

0 commit comments

Comments
 (0)