Skip to content

Check in generated VM opcode table - #4092

Merged
not-jenni merged 7 commits into
iree-org:mainfrom
not-jenni:vm-opcode-table
Dec 8, 2020
Merged

not-jenni merged 7 commits into
iree-org:mainfrom
not-jenni:vm-opcode-table

Conversation

@not-jenni

@not-jenni not-jenni commented Dec 4, 2020 •

Copy link
Copy Markdown
Contributor

Generating this file will allow the java bindings to build without the LLVM dependency. Progress on #357

@google-cla google-cla Bot added the cla: yes label Dec 4, 2020

@ScottTodd ScottTodd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put "progress on #357" or "fixes #357" in the PR description to tag that issue (depending on if you want to close the issue or just mark as progress on it)
https://stackoverflow.com/questions/1687262/link-to-the-issue-number-on-github-within-a-commit-message

Comment thread iree/vm/BUILD Resolved
Comment thread iree/vm/BUILD Resolved
@not-jenni not-jenni changed the title Add generated VM opcode table to java bindings Check in generated VM opcode table Dec 4, 2020
Comment thread iree/vm/BUILD Resolved
Comment thread iree/vm/BUILD Resolved
|* *|
|* IREE VM Operation Tables *|
|* *|
|* Automatically generated file, do not edit! *|

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to exclude this file from clang-format checks.

@GMNGeoffrey any suggestions? Maybe move to a vm/generated/ directory and add a disabled .clang-format file like https://github.com/google/iree/blob/main/third_party/.clang-format ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and while you're here, any suggestions on a command line (or script) to run this generation, instead of commenting out the build target?

Here's what CMake is running for the tablegen rule:

[cmake] IREE bytecode_op_table.h -gen-iree-vm-op-table-defs -ID:/dev/projects/iree/third_party/llvm-project/mlir/include;-ID:/dev/projects/iree-build/third_party/llvm-project/llvm/tools/mlir/include;-ID:/dev/projects/iree;-ID:/dev/projects/iree/iree/vm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion would be to leave the genrule and have its output be called something else and then have a diff test that confirms the built one is always the same as the generated one. That way they won't drift. We're basically caching this genrule in source code 🙃

bazel_skylib has a diff test. In terms of regeneration, I would copy the build rule output.

A separate directory with a similar .clang-format to third_party SGTM. Note that because we pass individual file names to git-clang-format for our lint action I think it will still ignore that, which is annoying.

load("@bazel_skylib//rules:diff_test.bzl", "diff_test")

gentbl(
    name = "bytecode_op_table_gen",
    tbl_outs = [
        ("-gen-iree-vm-op-table-defs", "generated_bytecode_op_table.h"),
    ],
    tblgen = "//iree/tools:iree-tblgen",
    td_file = "//iree/compiler/Dialect/VM/IR:VMOps.td",
    td_srcs = [
        "//iree/compiler/Dialect/IREE/IR:td_files",
        "//iree/compiler/Dialect/VM/IR:td_files",
        "@llvm-project//mlir:OpBaseTdFiles",
        "@llvm-project//mlir:include/mlir/IR/SymbolInterfaces.td",
        "@llvm-project//mlir:include/mlir/Interfaces/CallInterfaces.td",
        "@llvm-project//mlir:include/mlir/Interfaces/ControlFlowInterfaces.td",
        "@llvm-project//mlir:SideEffectTdFiles",
    ],
)

diff_test(
    name = "diff_bytecode_op_table",
    file1 = ":bytecode_op_table_gen",
    file2 = "generated/bytecode_op_table.h",
)

Update process is

$ bazel build iree/vm:bytecode_op_table_gen
$ cp bazel-bin/iree/vm/bytecode_op_table.h iree/vm/generated/bytecode_op_table.h

(or same thing with cmake)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we can leave the automatic generation + diff tests or other supporting infra for a follow-up PR. That diff_test approach looks pretty good to me. Not to difficult to maintain and easy enough to run.

Another thing I like about a separate directory like iree/vm/generated/ is that we can exclude all generated/ directories for license checks and other things that we exclude third_party/ from.

Comment thread iree/vm/BUILD Resolved
Comment thread iree/vm/CMakeLists.txt Resolved
@not-jenni
not-jenni merged commit 17856ed into iree-org:main Dec 8, 2020
@not-jenni
not-jenni deleted the vm-opcode-table branch December 8, 2020 22:47
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.

3 participants