[Mlir-commits] [mlir] [MLIR][Standalone] use narrow registration instead of RegisterEverything (PR #160469)
Mehdi Amini
llvmlistbot at llvm.org
Wed Sep 24 04:52:54 PDT 2025
================
@@ -12,21 +12,14 @@
#include <stdio.h>
#include "Standalone-c/Dialects.h"
+#include "mlir-c/Dialect/Arith.h"
+#include "mlir-c/Dialect/Builtin.h"
#include "mlir-c/IR.h"
-#include "mlir-c/RegisterEverything.h"
-
-static void registerAllUpstreamDialects(MlirContext ctx) {
- MlirDialectRegistry registry = mlirDialectRegistryCreate();
- mlirRegisterAllDialects(registry);
- mlirContextAppendDialectRegistry(ctx, registry);
- mlirDialectRegistryDestroy(registry);
-}
int main(int argc, char **argv) {
MlirContext ctx = mlirContextCreate();
- // TODO: Create the dialect handles for the builtin dialects and avoid this.
- // This adds dozens of MB of binary size over just the standalone dialect.
- registerAllUpstreamDialects(ctx);
+ mlirDialectHandleRegisterDialect(mlirGetDialectHandle__arith__(), ctx);
+ mlirDialectHandleRegisterDialect(mlirGetDialectHandle__builtin__(), ctx);
----------------
joker-eph wrote:
I'm slightly confused here, we never need to register the builtin dialect when using the C++ APIs, because it's loaded in the MLIRContext by default.
What is the effect of doing this here?
https://github.com/llvm/llvm-project/pull/160469
More information about the Mlir-commits
mailing list