[Mlir-commits] [mlir] [mlir][tblgen] Adds support for embedded LIT tests in TableGen records (PR #158017)
Mehdi Amini
llvmlistbot at llvm.org
Sun Sep 14 11:07:49 PDT 2025
================
@@ -0,0 +1,65 @@
+// RUN: mlir-tblgen -gen-lit-tests -I %S/../../include -dialect=test %s | FileCheck %s
+
+include "mlir/Pass/PassBase.td"
+include "mlir/IR/Testable.td"
+
+def TestPassWithEmbeddedLitTests : Pass<"test-pass-with-embedded-lit-tests"> {
+ let summary = "pass summary";
+ let description = [{
+ Pass description
+ }];
+
+ let tests = [
+ LitTest<
+ "lit_test_file_1.mlir",
+ [{
+ func.func @test1() {
----------------
joker-eph wrote:
> Do we always want to include the IR examples in the documentation or do we want to give the user an option to only generate LIT tests from them?
If it's not the documentation, I'd question why is it in ODS?
> If it's the former then we'd always need the user to also specify the full "after" version of the IR.
I don't quite get what is the "after" version in the context of the documentation?
> It seemed to me, from the comments, that there may be a third option of just generating a --verify-roundtrip test.
Right.
> If so, I'm not sure what utility such IR can provide either for documentation or for testing.
I don't follow: the IR here isn't meant to be useful for testing, we already have tests for it. The problem statement as I understand it is that we want examples in the doc that are maintained up-to-date in terms of being "correct". That is: we want to test the documentation to actually have examples reflecting the implementation.
https://github.com/llvm/llvm-project/pull/158017
More information about the Mlir-commits
mailing list