Skip to content

[Tools][Dialect] MLIR Dialect & Transform Generator #11

@copparihollmann

Description

@copparihollmann

Context

Creating a new MLIR dialect requires creating ~10 files (Ops.td, Dialect.cpp, CMakeLists.txt, TypeDetail.h, etc.). This high friction slows down experimental IR development. Furthermore, we need a way to verify that the generated dialect behaves as expected.

Objective

Create a scaffolding tool (src/tools/scaffold_dialect.py) that generates a fully compilable MLIR dialect directory structure, including a LIT-style test suite for verification.

Scope of Work

  1. Template Engine: Create Jinja2 templates for standard ODS (TableGen), C++ headers, and CMake config.
  2. Test Scaffolding:
    • Generate a tests/Dialect/{Name} directory.
    • Create a lit.cfg.py configuration file.
    • Generate a sample ops.mlir test file with // CHECK-LABEL: assertions.
  3. Scaffolder:
    • Input: dialect_name, namespace, cpp_namespace.
    • Output: A folder src/Dialect/{Name} registered in the main CMake build.

Acceptance Criteria

  • Test 1: Run scaffold_dialect.py --name "MyTest" --namespace "mt".
  • Condition: Run the main build system.
  • Success: The build completes, and iree-opt --help lists the --convert-mt-to-standard pass.
  • Test 2: The generated Ops.td includes standard boilerplate (mnemonic, description, assemblyFormat) and compiles via mlir-tblgen.
  • Test 3 (LIT Verification):
    • Input: The tool generates tests/Dialect/MyTest/ops.mlir.
    • Condition: Run lit tests/Dialect/MyTest.
    • Success: The test passes. This proves that iree-opt can parse the new dialect's IR and that the printed output matches the // CHECK expectations (Round-trip verification).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions