From 1ccd1bc1cfb92942c0aa203a22ee50d40eed47fe Mon Sep 17 00:00:00 2001 From: Jeremy Kun Date: Fri, 8 Aug 2025 20:21:36 -0700 Subject: [PATCH] initial attempt --- mlir/include/mlir/Pass/PipelineBase.td | 80 ++++ mlir/include/mlir/TableGen/Pipeline.h | 102 +++++ mlir/lib/TableGen/CMakeLists.txt | 1 + mlir/lib/TableGen/Pipeline.cpp | 101 +++++ mlir/test/mlir-tblgen/gen-pipeline-decls.td | 29 ++ mlir/test/mlir-tblgen/gen-pipeline-doc.td | 32 ++ mlir/test/mlir-tblgen/pipelines-test.td | 107 ++++++ mlir/tools/mlir-tblgen/CMakeLists.txt | 1 + mlir/tools/mlir-tblgen/PipelineGen-fixed.cpp | 46 +++ mlir/tools/mlir-tblgen/PipelineGen.cpp | 385 +++++++++++++++++++ mlir/tools/mlir-tblgen/PipelineGen.h | 39 ++ mlir/tools/mlir-tblgen/mlir-tblgen.cpp | 1 + 12 files changed, 924 insertions(+) create mode 100644 mlir/include/mlir/Pass/PipelineBase.td create mode 100644 mlir/include/mlir/TableGen/Pipeline.h create mode 100644 mlir/lib/TableGen/Pipeline.cpp create mode 100644 mlir/test/mlir-tblgen/gen-pipeline-decls.td create mode 100644 mlir/test/mlir-tblgen/gen-pipeline-doc.td create mode 100644 mlir/test/mlir-tblgen/pipelines-test.td create mode 100644 mlir/tools/mlir-tblgen/PipelineGen-fixed.cpp create mode 100644 mlir/tools/mlir-tblgen/PipelineGen.cpp create mode 100644 mlir/tools/mlir-tblgen/PipelineGen.h diff --git a/mlir/include/mlir/Pass/PipelineBase.td b/mlir/include/mlir/Pass/PipelineBase.td new file mode 100644 index 0000000000000..70c8553bc27e0 --- /dev/null +++ b/mlir/include/mlir/Pass/PipelineBase.td @@ -0,0 +1,80 @@ +//===-- PipelineBase.td - Base pipeline definition file -----*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains definitions for defining pipeline registration and other +// mechanisms. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_PASS_PIPELINEBASE +#define MLIR_PASS_PIPELINEBASE + +include "mlir/Pass/PassBase.td" +include "mlir/IR/Utils.td" + +//===----------------------------------------------------------------------===// +// Pipeline Elements +//===----------------------------------------------------------------------===// + +// Base class for all pipeline elements +class PipelineElement; + +// Reference to a pass with options +class PassElement : PipelineElement { + // The pass to instantiate (must match registered pass argument) + string pass = passName; + + // Options to pass to this pass instance as a list of strings + // Format: ["option_name", "option_value", "option_name", "option_value", ...] + list options = []; +} + +// Nested pipeline for a different operation type +class NestedElement : PipelineElement { + // The operation type this nested pipeline targets + string operation = targetOp; + + // Sequence of elements in this nested pipeline + list elements = []; +} + +// Reference to a pipeline with options +class PipelineRef : PipelineElement { + // The pipeline to instantiate + string pipeline = pipelineName; + + // Options to pass to the pipeline as a list of strings + list options = []; +} + +//===----------------------------------------------------------------------===// +// Pipeline Definitions +//===----------------------------------------------------------------------===// + +// Main pipeline definition class +class Pipeline { + // Command line argument for the pipeline + string argument = pipelineArg; + + // Target operation type (empty means any/module-level) + string operation = targetOp; + + // Short summary of the pipeline + string summary = ""; + + // Detailed description + string description = ""; + + // Pipeline-level options + list