MLIR — 18 Operations for AI Agents

MLIR is the intermediate representation underneath modern ML compilers — dialects, ops, and lowering passes. act101 navigates that IR structurally, so agents inspect compiler output without losing their place in nested regions.

This page is the canonical reference an AI coding agent uses to refactor, query, and analyze MLIR code through the act MCP server. 18 operations available: 0 refactor, 18 query, 0 analysis. Each operation is callable from Claude Code, Cursor, Codex, OpenCode, or any MCP-compatible agent host. Click any operation for a stable anchor link suitable for citation.

18Query

Worked MLIR examples

act101 reads an MLIR module's named module operation and every func.func/llvm.func definition it contains as declarations — the module comes back kind module, both dialects' functions come back kind function, from the shared symbol_ref_id each carries. symbols covers the same module and functions and adds a construct skeleton does not read: every SSA operation result (%name = ...) inside a function body. The unit of structure in this grammar is the named operation: skeleton stops at the function boundary, while symbols reaches inside a function body to its individual value bindings. Each example below is the verbatim output of the command shown, run against the file shown. Query outputs are pretty-printed with the timing block omitted.

Read the pipeline's module and functions as a skeleton

fir_filter.mlir is a small DSP pipeline: a @dsp_pipeline module holding a @fir_filter function that multiplies and accumulates one filter tap, a @normalize function, and an llvm.func @log_sample.

$ act query skeleton fir_filter.mlir

Before

module @dsp_pipeline {
  func.func @fir_filter(%input: f32, %coeff: f32) -> f32 {
    %acc = arith.constant 0.0 : f32
    %scaled = arith.mulf %input, %coeff : f32
    %sum = arith.addf %acc, %scaled : f32
    return %sum : f32
  }

  func.func @normalize(%value: f32, %peak: f32) -> f32 {
    %result = arith.divf %value, %peak : f32
    return %result : f32
  }

  llvm.func @log_sample(%val: f32) {
    llvm.return
  }
}

Output

{
    "type": "Skeleton",
    "declarations": [
        {
            "kind": "module",
            "name": "@dsp_pipeline",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 1,
                    "column": 1,
                    "byte_offset": 0
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 17,
                    "column": 2,
                    "byte_offset": 423
                }
            },
            "name_range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 1,
                    "column": 8,
                    "byte_offset": 7
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 1,
                    "column": 21,
                    "byte_offset": 20
                }
            }
        },
        {
            "kind": "function",
            "name": "@fir_filter",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 2,
                    "column": 3,
                    "byte_offset": 25
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 7,
                    "column": 4,
                    "byte_offset": 231
                }
            },
            "name_range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 2,
                    "column": 13,
                    "byte_offset": 35
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 2,
                    "column": 24,
                    "byte_offset": 46
                }
            }
        },
        {
            "kind": "function",
            "name": "@normalize",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 9,
                    "column": 3,
                    "byte_offset": 235
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 12,
                    "column": 4,
                    "byte_offset": 363
                }
            },
            "name_range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 9,
                    "column": 13,
                    "byte_offset": 245
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 9,
                    "column": 23,
                    "byte_offset": 255
                }
            }
        },
        {
            "kind": "function",
            "name": "@log_sample",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 14,
                    "column": 3,
                    "byte_offset": 367
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 16,
                    "column": 4,
                    "byte_offset": 421
                }
            },
            "name_range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 14,
                    "column": 13,
                    "byte_offset": 377
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 14,
                    "column": 24,
                    "byte_offset": 388
                }
            }
        }
    ]
}

The skeleton reports four declarations: @dsp_pipeline as module, and @fir_filter, @normalize, and @log_sample all as function — the func.func and llvm.func operations report the same kind despite being two different dialects.

List the module, functions, and their SSA value bindings as symbols

@fir_filter binds three values in its body — %acc, %scaled, %sum — and @normalize binds one, %result.

$ act query symbols fir_filter.mlir

Before

module @dsp_pipeline {
  func.func @fir_filter(%input: f32, %coeff: f32) -> f32 {
    %acc = arith.constant 0.0 : f32
    %scaled = arith.mulf %input, %coeff : f32
    %sum = arith.addf %acc, %scaled : f32
    return %sum : f32
  }

  func.func @normalize(%value: f32, %peak: f32) -> f32 {
    %result = arith.divf %value, %peak : f32
    return %result : f32
  }

  llvm.func @log_sample(%val: f32) {
    llvm.return
  }
}

Output

{
    "type": "Symbols",
    "symbols": [
        {
            "name": "@dsp_pipeline",
            "kind": "module",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 1,
                    "column": 8,
                    "byte_offset": 7
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 1,
                    "column": 21,
                    "byte_offset": 20
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "@fir_filter",
            "kind": "function",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 2,
                    "column": 13,
                    "byte_offset": 35
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 2,
                    "column": 24,
                    "byte_offset": 46
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "%acc",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 3,
                    "column": 5,
                    "byte_offset": 86
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 3,
                    "column": 9,
                    "byte_offset": 90
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "%scaled",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 4,
                    "column": 5,
                    "byte_offset": 122
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 4,
                    "column": 12,
                    "byte_offset": 129
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "%sum",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 5,
                    "column": 5,
                    "byte_offset": 168
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 5,
                    "column": 9,
                    "byte_offset": 172
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "@normalize",
            "kind": "function",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 9,
                    "column": 13,
                    "byte_offset": 245
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 9,
                    "column": 23,
                    "byte_offset": 255
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "%result",
            "kind": "variable",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 10,
                    "column": 5,
                    "byte_offset": 294
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 10,
                    "column": 12,
                    "byte_offset": 301
                }
            },
            "visibility": "unknown"
        },
        {
            "name": "@log_sample",
            "kind": "function",
            "range": {
                "start": {
                    "file": "fir_filter.mlir",
                    "line": 14,
                    "column": 13,
                    "byte_offset": 377
                },
                "end": {
                    "file": "fir_filter.mlir",
                    "line": 14,
                    "column": 24,
                    "byte_offset": 388
                }
            },
            "visibility": "unknown"
        }
    ]
}

symbols adds all four SSA results to the same four top-level names, for eight entries total; the four value bindings come back kind variable, distinct from the module/function kinds skeleton already showed.

Query

18 query tools, the same on every supported language. Descriptions live in the shared reference: /docs/query-tools.

callers control_flow data_flow definition diagnostics effect_closure effect_summary fix_auto get_type graph import_organize interface mutations references repo_outline skeleton symbols symbols_batch

← MermaidModelica →