TL;DR: This PR [mlir][tblgen] add concrete create methods has landed. That means OpTy::create
APIs are now available for creating ops.
They look almost exactly like the conventional/prior builder.create<OpTy>(...)
APIs but instead pass the builder
as the first arg: OpTy::create(builder, ...)
. E.g.,
static arith::ConstantIndexOp create(OpBuilder& builder, Location location, int64_t value);
The advantage is they will tab complete, showing all of the possible generated builder signatures:
Note, both OpBuilder
and ImplicitLocBuilder
are supported.
Regarding deprecation
Given the importance of this particular API, we are planning to deprecate the prior builder.create
API slowly. So deprecation after the next release branches, and removal one or two releases after that (probably two).
For downstream users, the migration path is straightforward:
- A regex like
(\w+)\.create<(.*?)>\(
→$2::create($1,
; - Hand decls/defns only for ops not defined in tablegen (like
arith::ConstantIntOp
);- Conversely, if all of your ops are defined in tablegen, you don’t need to do anything.
I will be migrating upstream to these new APIs over the next couple of weeks (see this PR).
EDIT: if you have “dangling” builders, like this
https://github.com/llvm/llvm-project/pull/147619
then this PR will break you in the sense that you will no longer be able to link (because the generated create methods will reference the non-existent defns of those dangling decls). The solution is to remove the dangling builder decls from your tablegen.