18 Commits

Author SHA1 Message Date
Jakub Kuderski
ae11c5c2c4
[mlir] Switch uses of deprecated .create methods to free function. NFC. (#164635)
See https://discourse.llvm.org/t/psa-opty-create-now-with-100-more-tab-complete/87339.
2025-10-22 14:51:03 +00:00
Vlad Lazar
c3aa1584e0
[mlir][emitc] Add emitc.do op to the dialect (#143008)
This patch adds:
- Emission of the corresponding ops in the CppEmitter
- Conversion from the SCF dialect to the EmitC dialect for the ops
- Corresponding tests
2025-10-08 16:02:53 +03:00
Matthias Springer
21b607adbe
[mlir][SCF] scf.for: Add support for unsigned integer comparison (#153379)
Add a new unit attribute to allow for unsigned integer comparison.

Example:
```mlir
scf.for unsigned %iv_32 = %lb_32 to %ub_32 step %step_32 : i32 {
  // body
}
```

Discussion:
https://discourse.llvm.org/t/scf-should-scf-for-support-unsigned-comparison/84655
2025-08-15 10:59:14 +02:00
Maksim Levental
38976a03cd
[mlir][NFC] update Conversion create APIs (7/n) (#149889)
See https://github.com/llvm/llvm-project/pull/147168 for more info.
2025-07-22 10:41:06 -04:00
Kazu Hirata
fa9adbfda9
[mlir] Remove unused includes (NFC) (#147101)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-07-04 13:30:21 -07:00
Simon Camphausen
0009a17834
[mlir][EmitC] Add pass that combines all available emitc conversions (#117549) 2025-05-01 07:24:01 -07:00
Longsheng Mou
c34dc9a0cf
[mlir][SCFToEmitC] Don't convert unsupported types in EmitC (#131786)
This PR adds check for unsupported types in emitc, which fixes a crash.
Fixes #131442.
2025-03-19 14:18:51 +08:00
josel-amd
d622b66a82
Re-introduce Type Conversion on EmitC (#121476)
This PR reintroduces https://github.com/llvm/llvm-project/pull/118940
with a fix for the build issues on
cd9caf3aeed55280537052227f08bb1b41154efd
2025-01-02 14:58:15 +01:00
Matthias Gehre
df728cf1d7 Revert "[MLIR][SCFToEmitC] Convert types while converting from SCF to EmitC (#118940)"
This reverts commit 450c6b02d224245656c41033cc0c849bde2045f3.
2025-01-02 11:55:35 +01:00
josel-amd
450c6b02d2
[MLIR][SCFToEmitC] Convert types while converting from SCF to EmitC (#118940)
Switch from rewrite patterns to conversion patterns. This allows to
perform type conversions together with other parts of the IR. For
example, this allows to convert from index to emit.size_t types.
2025-01-02 11:36:23 +01:00
Simon Camphausen
e47b507562
[mlir][EmitC] Model lvalues as a type in EmitC (#91475)
This adds an `emitc.lvalue` type which models assignable lvlaues in the
type system. Operations modifying memory are restricted to this type
accordingly.

See also the discussion on
[discourse](https://discourse.llvm.org/t/rfc-separate-variables-from-ssa-values-in-emitc/75224/9).
The most notable changes are as follows.

- `emitc.variable` and `emitc.global` ops are restricted to return
`emitc.array` or `emitc.lvalue` types
- Taking the address of a value is restricted to operands with lvalue
type
- Conversion from lvalues into SSA values is done with the new
`emitc.load` op
- The var operand of the `emitc.assign` op is restricted to lvalue type 
- The result of the `emitc.subscript` and `emitc.get_global` ops is a
lvalue type
- The operands and results of the `emitc.member` and
`emitc.member_of_ptr` ops are restricted to lvalue types

---------

Co-authored-by: Matthias Gehre <matthias.gehre@amd.com>
2024-08-20 11:52:16 +02:00
Andrey Timonin
97f0ab71c0
[mlir][emitc] Add 'emitc.switch' op to the dialect (#102331)
This PR is continuation of the [previous
one](https://github.com/llvm/llvm-project/pull/101478). As a result, the
`emitc::SwitchOp` op was developed inspired by `scf::IndexSwitchOp`.

Main points of PR:

- Added the `emitc::SwitchOp` op  to the EmitC dialect + CppEmitter
- Corresponding tests were added
- Conversion from the SCF dialect to the EmitC dialect for the op
2024-08-16 18:25:06 +02:00
Gil Rapaport
8b7e836570
[mlir][emitc] Remove copy from scf.for lowering (#94898)
Remove the copy into fresh variables done when lowering scf.for into
emitc.for and use the variables carrying the init and iter values as
the loop's results.
2024-06-10 13:57:38 +03:00
Marius Brehler
dea855de46
[mlir][EmitC] Drop unused code (NFC) (#80325)
To register the conversion the autogenerated function
`registerSCFToEmitC()` calls `createSCFToEmitC()`, which itself is also
autogenerated. The removed function, however, isn't used in the upstream
codebase.
2024-02-04 18:51:47 +01:00
Gil Rapaport
2633d94f28
[mlir][emitc] Add a structured for operation (#68206)
Add an emitc.for op to the EmitC dialect as a lowering target for
scf.for, replacing its current direct translation to C; The translator
now handles emitc.for instead.
2023-10-26 16:40:18 +03:00
Gil Rapaport
a5b4ada6fe Recommit "Add a structured if operation (#67234)"
This patch recommits 126f0374cbc2110aa97e2141ac898014a8b9531a, reverted by
3ada774d0f65b44f21b360d222f446e533df1a34, along with the missing dependence.
2023-09-28 01:52:30 +03:00
Gil Rapaport
3ada774d0f Revert "Add a structured if operation (#67234)"
This reverts commit 126f0374cbc2110aa97e2141ac898014a8b9531a.

Reverting due to bot failures.
2023-09-28 00:22:42 +03:00
Gil Rapaport
126f0374cb
Add a structured if operation (#67234)
Add an emitc.if op to the EmitC dialect. A new convert-scf-to-emitc
pass replaces the existing direct translation of scf.if to C; The
translator now handles emitc.if instead.

The emitc.if op doesn't return any value and its then/else regions are
terminated with a new scf.yield op. Values returned by scf.if are
lowered using emitc.variable ops, assigned to in the then/else regions
using a new emitc.assign op.
2023-09-27 22:40:15 +03:00