[SAOC 2026] MLIR support Weekly Update #6
Asadbek
aosindarov at gmail.com
Wed Oct 28 13:15:00 UTC 2026
Hello everyone,
This week, I spent some time refactoring my `inlineMLIR` changes
[1] to reduce the binary size overhead caused by registering all
MLIR dialects, including the ones we don't actually use.
I finally got basic integer binary operations lowering from D to
the MLIR `arith`[2] and `func`[3] dialects! For example, this D
code:
```d
int add(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
int div(int a, int b) { return a / b; }
int min(int a, int b) { return a - b; }
```
now lowers directly to:
```
module {
func.func @_D4test3addFiiZi(%arg0: i32, %arg1: i32) -> i32 {
%0 = arith.addi %arg0, %arg1 : i32
return %0 : i32
}
func.func @_D4test3mulFiiZi(%arg0: i32, %arg1: i32) -> i32 {
%0 = arith.muli %arg0, %arg1 : i32
return %0 : i32
}
func.func @_D4test3divFiiZi(%arg0: i32, %arg1: i32) -> i32 {
%0 = arith.divsi %arg0, %arg1 : i32
return %0 : i32
}
func.func @_D4test3minFiiZi(%arg0: i32, %arg1: i32) -> i32 {
%0 = arith.subi %arg0, %arg1 : i32
return %0 : i32
}
}
```
Next, I will continue expanding support for more binary ops,
including floating-point types. Nicholas also suggested adding
control flow constructs soon to better test the MLIR integration,
so I plan to start lowering into the `scf`[4] (Structured Control
Flow) dialect in the coming days. Once that is working, I want to
start experimenting with D-specific optimizations and constructs
in MLIR, which is the main goal of the project.
Feedback and questions are welcome!
Best,
Asadbek
[1] https://github.com/ldc-developers/ldc/pull/5307
[2] https://mlir.llvm.org/docs/Dialects/ArithOps/
[3] https://mlir.llvm.org/docs/Dialects/Func/
[4] https://mlir.llvm.org/docs/Dialects/SCFDialect/
More information about the Digitalmars-d
mailing list