summaryrefslogtreecommitdiffstats
path: root/mlir/test
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/test')
-rw-r--r--mlir/test/Pass/pipeline-options-parsing.mlir6
-rw-r--r--mlir/test/lib/Pass/TestPassManager.cpp47
-rw-r--r--mlir/test/lib/Transforms/TestLoopParametricTiling.cpp24
3 files changed, 31 insertions, 46 deletions
diff --git a/mlir/test/Pass/pipeline-options-parsing.mlir b/mlir/test/Pass/pipeline-options-parsing.mlir
index 02452a35f23..bfb24af9302 100644
--- a/mlir/test/Pass/pipeline-options-parsing.mlir
+++ b/mlir/test/Pass/pipeline-options-parsing.mlir
@@ -13,6 +13,6 @@
// CHECK_ERROR_4: 'notaninteger' value invalid for integer argument
// CHECK_ERROR_5: string option: may only occur zero or one times
-// CHECK_1: test-options-pass{list=1,2,3,4,5 string-list=a,b,c,d string=some_value}
-// CHECK_2: test-options-pass{list=1 string-list=a,b}
-// CHECK_3: module(func(test-options-pass{list=3}), func(test-options-pass{list=1,2,3,4}))
+// CHECK_1: test-options-pass{list=1,2,3,4,5 string=some_value string-list=a,b,c,d}
+// CHECK_2: test-options-pass{list=1 string= string-list=a,b}
+// CHECK_3: module(func(test-options-pass{list=3 string= string-list=}), func(test-options-pass{list=1,2,3,4 string= string-list=}))
diff --git a/mlir/test/lib/Pass/TestPassManager.cpp b/mlir/test/lib/Pass/TestPassManager.cpp
index 2e811634880..cc926e1c01e 100644
--- a/mlir/test/lib/Pass/TestPassManager.cpp
+++ b/mlir/test/lib/Pass/TestPassManager.cpp
@@ -21,43 +21,34 @@ struct TestFunctionPass : public FunctionPass<TestFunctionPass> {
};
class TestOptionsPass : public FunctionPass<TestOptionsPass> {
public:
- struct Options : public PassOptions<Options> {
- List<int> listOption{*this, "list", llvm::cl::MiscFlags::CommaSeparated,
- llvm::cl::desc("Example list option")};
- List<std::string> stringListOption{
+ struct Options : public PassPipelineOptions<Options> {
+ ListOption<int> listOption{*this, "list",
+ llvm::cl::MiscFlags::CommaSeparated,
+ llvm::cl::desc("Example list option")};
+ ListOption<std::string> stringListOption{
*this, "string-list", llvm::cl::MiscFlags::CommaSeparated,
llvm::cl::desc("Example string list option")};
Option<std::string> stringOption{*this, "string",
llvm::cl::desc("Example string option")};
};
+ TestOptionsPass() = default;
+ TestOptionsPass(const TestOptionsPass &) {}
TestOptionsPass(const Options &options) {
- listOption.assign(options.listOption.begin(), options.listOption.end());
- stringOption = options.stringOption;
- stringListOption.assign(options.stringListOption.begin(),
- options.stringListOption.end());
- }
-
- void printAsTextualPipeline(raw_ostream &os) final {
- os << "test-options-pass{";
- if (!listOption.empty()) {
- os << "list=";
- // Not interleaveComma to avoid spaces between the elements.
- interleave(listOption, os, ",");
- }
- if (!stringListOption.empty()) {
- os << " string-list=";
- interleave(stringListOption, os, ",");
- }
- if (!stringOption.empty())
- os << " string=" << stringOption;
- os << "}";
+ listOption->assign(options.listOption.begin(), options.listOption.end());
+ stringOption.setValue(options.stringOption);
+ stringListOption->assign(options.stringListOption.begin(),
+ options.stringListOption.end());
}
void runOnFunction() final {}
- SmallVector<int64_t, 4> listOption;
- SmallVector<std::string, 4> stringListOption;
- std::string stringOption;
+ ListOption<int> listOption{*this, "list", llvm::cl::MiscFlags::CommaSeparated,
+ llvm::cl::desc("Example list option")};
+ ListOption<std::string> stringListOption{
+ *this, "string-list", llvm::cl::MiscFlags::CommaSeparated,
+ llvm::cl::desc("Example string list option")};
+ Option<std::string> stringOption{*this, "string",
+ llvm::cl::desc("Example string option")};
};
/// A test pass that always aborts to enable testing the crash recovery
@@ -97,7 +88,7 @@ static void testNestedPipelineTextual(OpPassManager &pm) {
(void)parsePassPipeline("test-pm-nested-pipeline", pm);
}
-static PassRegistration<TestOptionsPass, TestOptionsPass::Options>
+static PassRegistration<TestOptionsPass>
reg("test-options-pass", "Test options parsing capabilities");
static PassRegistration<TestModulePass>
diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp
index 7b0cdcade4d..e793ee54cda 100644
--- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp
+++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp
@@ -25,18 +25,10 @@ namespace {
class SimpleParametricLoopTilingPass
: public FunctionPass<SimpleParametricLoopTilingPass> {
public:
- struct Options : public PassOptions<Options> {
- List<int> clOuterLoopSizes{
- *this, "test-outer-loop-sizes", llvm::cl::MiscFlags::CommaSeparated,
- llvm::cl::desc(
- "fixed number of iterations that the outer loops should have")};
- };
-
- explicit SimpleParametricLoopTilingPass(ArrayRef<int64_t> outerLoopSizes)
- : sizes(outerLoopSizes.begin(), outerLoopSizes.end()) {}
- explicit SimpleParametricLoopTilingPass(const Options &options) {
- sizes.assign(options.clOuterLoopSizes.begin(),
- options.clOuterLoopSizes.end());
+ SimpleParametricLoopTilingPass() = default;
+ SimpleParametricLoopTilingPass(const SimpleParametricLoopTilingPass &) {}
+ explicit SimpleParametricLoopTilingPass(ArrayRef<int64_t> outerLoopSizes) {
+ sizes = outerLoopSizes;
}
void runOnFunction() override {
@@ -49,7 +41,10 @@ public:
});
}
- SmallVector<int64_t, 4> sizes;
+ ListOption<int64_t> sizes{
+ *this, "test-outer-loop-sizes", llvm::cl::MiscFlags::CommaSeparated,
+ llvm::cl::desc(
+ "fixed number of iterations that the outer loops should have")};
};
} // end namespace
@@ -58,8 +53,7 @@ mlir::createSimpleParametricTilingPass(ArrayRef<int64_t> outerLoopSizes) {
return std::make_unique<SimpleParametricLoopTilingPass>(outerLoopSizes);
}
-static PassRegistration<SimpleParametricLoopTilingPass,
- SimpleParametricLoopTilingPass::Options>
+static PassRegistration<SimpleParametricLoopTilingPass>
reg("test-extract-fixed-outer-loops",
"test application of parametric tiling to the outer loops so that the "
"ranges of outer loops become static");
OpenPOWER on IntegriCloud