Skip to content

Conversation

Copy link

Copilot AI commented Oct 25, 2025

JSIR's default MLIR assembly output is verbose, printing unnecessary type annotations and syntax for every operation since all expressions uniformly return !jsir.any.

Changes

Added declarative assemblyFormat to all 87 JSIR operations:

  • jsir_ops.td (20 handwritten ops): statements, control flow, class/object members
  • jsir_ops.generated.td (67 generated ops): core expressions, literals, identifiers

Format patterns

  • Operations with only attributes: attr-dict
  • With operands: `(` $operands `)` attr-dict
  • With regions: attr-dict $region or attr-dict-with-keyword `(` $regions `)`
  • Optional operands: (`(` $arg^ `)`)? attr-dict

Example

Before:

%0 = "jsir.identifier"() <{name = "a"}> : () -> !jsir.any
"jshir.if_statement"(%0) ({
  %2 = "jsir.identifier"() <{name = "b"}> : () -> !jsir.any
  "jsir.expression_statement"(%2) : (!jsir.any) -> ()
}, {
}) : (!jsir.any) -> ()

After:

%0 = jsir.identifier {name = "a"}
jshir.if_statement(%0) ({
  %2 = jsir.identifier {name = "b"}
  jsir.expression_statement(%2)
}, {
})

Notes

jsir_ops.generated.td is auto-generated by astgen which doesn't yet emit assemblyFormat. Future regeneration requires updating astgen's IrTableGenPrinter.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • releases.bazel.build
    • Triggering command: /usr/local/lib/node_modules/@bazel/bazelisk/bazelisk-linux_amd64 version (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Define a simplified assembly format</issue_title>
<issue_description>Currently when we mlir::debugPrint JSIR, we get the default format, which is pretty verbose:

"jsir.file"() <{comments = []}> ({
  "jsir.program"() <{source_type = "script"}> ({
    %0 = "jsir.identifier"() <{name = "a"}> : () -> !jsir.any
    "jshir.if_statement"(%0) ({
      %2 = "jsir.identifier"() <{name = "b"}> : () -> !jsir.any
      "jsir.expression_statement"(%2) : (!jsir.any) -> ()
    }, {
    }) : (!jsir.any) -> ()
    %1 = "jsir.identifier"() <{name = "a"}> : () -> !jsir.any
    "jshir.if_statement"(%1) ({
      "jshir.block_statement"() ({
        %2 = "jsir.identifier"() <{name = "b"}> : () -> !jsir.any
        "jsir.expression_statement"(%2) : (!jsir.any) -> ()
      }, {
      ^bb0:
      }) : () -> ()
    }, {
      %2 = "jsir.identifier"() <{name = "c"}> : () -> !jsir.any
      "jsir.expression_statement"(%2) : (!jsir.any) -> ()
    }) : (!jsir.any) -> ()
  }, {
  ^bb0:
  }) : () -> ()
}) : () -> ()

We should provide a custom, simplified assembly format, like this:

jsir.file {
  jsir.program {source_type = "script"} {
    %0 = jsir.identifier {name = "a"}
    jshir.if_statement(%0) ({
      %2 = jsir.identifier {name = "b"}
      jsir.expression_statement(%2)
    }, {
    })
    %1 = jsir.identifier{name = "a"}
    jshir.if_statement(%1) ({
      jshir.block_statement() ({
        %2 = jsir.identifier {name = "b"}
        jsir.expression_statement(%2)
      }, {
      ^bb0:
      })
    }, {
      %2 = jsir.identifier {name = "c"}
      jsir.expression_statement(%2)
    })
  }, {
  ^bb0:
  })
})

Note: Since JSIR currently doesn't support TypeScript, every expression has the type jsir.any and doesn't have to be spelled out explicitly.

The custom assemblyFormat should be declared in jsir_ops.generated.td and jsir_ops.td. jsir_ops.generated.td is generated by astgen.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@google-cla
Copy link

google-cla bot commented Oct 25, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Co-authored-by: phisiart <4835507+phisiart@users.noreply.github.com>
Copilot AI changed the title [WIP] Define a simplified assembly format for JSIR Add custom assembly formats to JSIR operations Oct 25, 2025
Copilot AI requested a review from phisiart October 25, 2025 23:13
@phisiart
Copy link
Collaborator

I know this PR won't pass the test cases, but I'm curious if copilot can figure out how to fix them.

@phisiart
Copy link
Collaborator

Oh, I just realized that google policy does not allow using GitHub copilot for google/ repos.

@phisiart phisiart closed this Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define a simplified assembly format

1 participant