Repository navigation
Check in generated VM opcode table - #4092
Conversation
ScottTodd
left a comment
There was a problem hiding this comment.
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
| |* *| | ||
| |* IREE VM Operation Tables *| | ||
| |* *| | ||
| |* Automatically generated file, do not edit! *| |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
... 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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
Generating this file will allow the java bindings to build without the LLVM dependency. Progress on #357