Skip to content

Commit 7c7eb6d

Browse files
MogballMogball
authored andcommitted
[mlir][test] Shard and reorganize the test dialect
Shard the test dialect by 4. This patch also reorganizes the manually-written op hooks into `TestOpDefs.cpp` and format custom directive parser and printers into `TestFormatUtils`, adds missing comment blocks, and moves around where generated source files are included for types, attributes, enums, etc. In my case, the compilation time of the test dialect drops from >60s to ~10s.
1 parent 4cb871c commit 7c7eb6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2133
-1366
lines changed

mlir/test/lib/Analysis/DataFlow/TestDenseBackwardDataFlowAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "TestDenseDataFlowAnalysis.h"
1414
#include "TestDialect.h"
15+
#include "TestOps.h"
1516
#include "mlir/Analysis/DataFlow/ConstantPropagationAnalysis.h"
1617
#include "mlir/Analysis/DataFlow/DeadCodeAnalysis.h"
1718
#include "mlir/Analysis/DataFlow/DenseAnalysis.h"

mlir/test/lib/Analysis/DataFlow/TestDenseForwardDataFlowAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "TestDenseDataFlowAnalysis.h"
1414
#include "TestDialect.h"
15+
#include "TestOps.h"
1516
#include "mlir/Analysis/DataFlow/ConstantPropagationAnalysis.h"
1617
#include "mlir/Analysis/DataFlow/DeadCodeAnalysis.h"
1718
#include "mlir/Analysis/DataFlow/DenseAnalysis.h"

mlir/test/lib/Conversion/FuncToLLVM/TestConvertCallOp.cpp

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

99
#include "TestDialect.h"
10+
#include "TestOps.h"
1011
#include "TestTypes.h"
1112
#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h"
1213
#include "mlir/Conversion/LLVMCommon/Pattern.h"

mlir/test/lib/Conversion/OneToNTypeConversion/TestOneToNTypeConversionPass.cpp

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

99
#include "TestDialect.h"
10+
#include "TestOps.h"
1011
#include "mlir/Dialect/Func/Transforms/OneToNFuncConversions.h"
1112
#include "mlir/Dialect/SCF/Transforms/Patterns.h"
1213
#include "mlir/Pass/Pass.h"

mlir/test/lib/Dialect/Affine/TestReifyValueBounds.cpp

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

99
#include "TestDialect.h"
10+
#include "TestOps.h"
1011
#include "mlir/Dialect/Affine/IR/AffineOps.h"
1112
#include "mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h"
1213
#include "mlir/Dialect/Affine/Transforms/Transforms.h"

mlir/test/lib/Dialect/DLTI/TestDataLayoutQuery.cpp

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

9-
#include "TestDialect.h"
9+
#include "TestOps.h"
1010
#include "mlir/Analysis/DataLayoutAnalysis.h"
1111
#include "mlir/Dialect/DLTI/DLTI.h"
1212
#include "mlir/IR/BuiltinAttributes.h"

mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp

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

99
#include "TestDialect.h"
10+
#include "TestOps.h"
1011
#include "mlir/Dialect/Func/IR/FuncOps.h"
1112
#include "mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h"
1213
#include "mlir/IR/Builders.h"

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ mlir_tablegen(TestOpEnums.cpp.inc -gen-enum-defs)
3131
add_public_tablegen_target(MLIRTestEnumDefIncGen)
3232

3333
set(LLVM_TARGET_DEFINITIONS TestOps.td)
34-
mlir_tablegen(TestOps.h.inc -gen-op-decls)
35-
mlir_tablegen(TestOps.cpp.inc -gen-op-defs)
3634
mlir_tablegen(TestOpsDialect.h.inc -gen-dialect-decls -dialect=test)
3735
mlir_tablegen(TestOpsDialect.cpp.inc -gen-dialect-defs -dialect=test)
3836
mlir_tablegen(TestPatterns.inc -gen-rewriters)
@@ -43,16 +41,22 @@ mlir_tablegen(TestOpsSyntax.h.inc -gen-op-decls)
4341
mlir_tablegen(TestOpsSyntax.cpp.inc -gen-op-defs)
4442
add_public_tablegen_target(MLIRTestOpsSyntaxIncGen)
4543

44+
add_sharded_ops(TestOps 20)
45+
4646
# Exclude tests from libMLIR.so
4747
add_mlir_library(MLIRTestDialect
4848
TestAttributes.cpp
4949
TestDialect.cpp
50+
TestFormatUtils.cpp
5051
TestInterfaces.cpp
52+
TestOpDefs.cpp
53+
TestOps.cpp
5154
TestPatterns.cpp
5255
TestTraits.cpp
5356
TestTypes.cpp
5457
TestOpsSyntax.cpp
5558
TestDialectInterfaces.cpp
59+
${SHARDED_SRCS}
5660

5761
EXCLUDE_FROM_LIBMLIR
5862

@@ -63,6 +67,7 @@ add_mlir_library(MLIRTestDialect
6367
MLIRTestTypeDefIncGen
6468
MLIRTestOpsIncGen
6569
MLIRTestOpsSyntaxIncGen
70+
MLIRTestOpsShardGen
6671

6772
LINK_LIBS PUBLIC
6873
MLIRControlFlowInterfaces

mlir/test/lib/Dialect/Test/TestAttributes.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "mlir/IR/Types.h"
2020
#include "mlir/Support/LogicalResult.h"
2121
#include "llvm/ADT/Hashing.h"
22+
#include "llvm/ADT/StringExtras.h"
2223
#include "llvm/ADT/TypeSwitch.h"
2324
#include "llvm/ADT/bit.h"
2425
#include "llvm/Support/ErrorHandling.h"
@@ -244,7 +245,7 @@ static void printConditionalAlias(AsmPrinter &p, StringAttr value) {
244245
//===----------------------------------------------------------------------===//
245246

246247
#include "TestAttrInterfaces.cpp.inc"
247-
248+
#include "TestOpEnums.cpp.inc"
248249
#define GET_ATTRDEF_CLASSES
249250
#include "TestAttrDefs.cpp.inc"
250251

0 commit comments

Comments
 (0)