[all-commits] [llvm/llvm-project] 1e0a4c: [mlir][emitc] Lower multiple results as a struct (...
Gil Rapaport via All-commits
all-commits at lists.llvm.org
Wed Jun 10 01:46:21 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1e0a4c7a9154e46ef52a7c5b0ddbca69fbdcfacd
https://github.com/llvm/llvm-project/commit/1e0a4c7a9154e46ef52a7c5b0ddbca69fbdcfacd
Author: Gil Rapaport <gil.rapaport at mobileye.com>
Date: 2026-06-10 (Wed, 10 Jun 2026)
Changed paths:
M mlir/include/mlir/Conversion/ConvertToEmitC/ConvertToEmitCPatternInterface.td
M mlir/include/mlir/Conversion/ConvertToEmitC/ToEmitCInterface.h
M mlir/include/mlir/Conversion/FuncToEmitC/FuncToEmitC.h
M mlir/include/mlir/Conversion/Passes.td
M mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp
M mlir/lib/Conversion/ConvertToEmitC/ConvertToEmitCPass.cpp
M mlir/lib/Conversion/FuncToEmitC/FuncToEmitC.cpp
M mlir/lib/Conversion/FuncToEmitC/FuncToEmitCPass.cpp
M mlir/lib/Conversion/MemRefToEmitC/MemRefToEmitC.cpp
M mlir/lib/Conversion/SCFToEmitC/SCFToEmitC.cpp
M mlir/test/Conversion/FuncToEmitC/func-to-emitc-failed.mlir
M mlir/test/Conversion/FuncToEmitC/func-to-emitc.mlir
M mlir/test/Target/Cpp/func.mlir
Log Message:
-----------
[mlir][emitc] Lower multiple results as a struct (#200659)
Previously, func-to-emitc lowering rejected func.{func,call,return} with
more than one result/operand. Such ops are directly handled by the
translator which emits an `std::tuple` packing ther results, but is only
relevant for C++ users. This patch lifts that restriction by packing
multiple return values into an automatically-generated struct, e.g. for
a function returning (i32, i32):
emitc.class struct @return_i32_i32 {
emitc.field @field0 : i32
emitc.field @field1 : i32
}
On return, the operands are packed into a local struct variable which is
then loaded and returned. On call sites, the struct is stored in a local
variable, and each field is extracted to recreate the individual SSA
values of the original results. As with single-result functions,
`emitc.array` return types are not supported.
If a class with that name already exists, it is verified to have exactly
the expected fields with the correct types and no methods. Two functions
with the same return type tuple share a single class definition.
Backward compatibility is maintained by a new lower-to-cpp option which
defaults to `true` (unlike the same flag in memref-to-emitc), in which case
func-to-emitc continues to bail out on multi-return functions.
Assisted-by: Copilot
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list