Commit Graph

53 Commits

Author SHA1 Message Date
Roberto Bertolini 5dcd6334b3 Add Clift local variable scope tightening 2026-05-13 15:32:34 +02:00
Lauri Vasama c7e3a12657 Add implicit cast elision pass 2026-05-04 10:49:07 +03:00
Lauri Vasama 04fe27b8e9 Migrate Clift users to CDataModel 2026-05-04 10:49:03 +03:00
Lauri Vasama dd4e452f96 Add data model import pipes 2026-05-04 10:48:16 +03:00
Lauri Vasama 9bd76c71f9 Split up Clift optimization pipe 2026-04-30 15:09:16 +03:00
Lauri Vasama 90e5dfd4c9 Pass MLIRContext by address
Passing by address is more conventional. This is what MLIR does most of
the time, and it avoids dereferences and addressofs everywhere.
2026-04-30 15:09:16 +03:00
Lauri Vasama a338194eb7 Move namespace mlir::clift out of namespace mlir 2026-04-27 12:48:24 +03:00
Ivan Krysak 71845dcbbb CliftEmitC: stop using mlir::clift namespace 2026-04-22 08:19:47 +00:00
Ivan Krysak 5f511d8e17 verify-against-model: split into two
The resulting pipes are:
1. binary-granularity one with the name unchanged
2. function-granularity one called `verify-function-against-model`.
2026-04-22 08:19:30 +00:00
Ivan Krysak e693cdbd53 model-verify-clift -> verify-against-model 2026-04-22 08:19:30 +00:00
Ivan Krysak f3df0e20b9 Minor improvements 2026-04-21 07:54:50 +00:00
Ivan Krysak 19741a32ab ImportModel: expose a high level type importer 2026-03-27 08:15:23 +00:00
Ivan Krysak 35fe2309c3 import-types: use clift.types as the attribute
Before this, `clift.test` was used
2026-03-27 08:14:53 +00:00
Ivan Krysak cdc633e31d CliftPipes: drop Pipe from filenames
This removes unnecessary Pipe from filenames which the directory name
already contains.

This also renames some of them to match the *new* pipeline.
2026-03-27 07:18:49 +00:00
Ivan Krysak 278b898793 llvm-to-clift -> clifter 2026-03-27 07:05:44 +00:00
Ivan Krysak 24b08e5439 Drop an unused clift-legalization pipe
It was never used as the corresponding `clift-opt` was used everywhere.
2026-03-27 07:02:32 +00:00
Ivan Krysak 73ddff7126 import-clift-types -> import-types 2026-03-26 16:28:48 +00:00
Ivan Krysak addfc543c8 import-model-names -> import-descriptive-info 2026-03-26 16:28:48 +00:00
Ivan Krysak 6dc6ad2cf3 importModelTypes -> importTypes 2026-03-26 16:28:48 +00:00
Ivan Krysak 53a476e9ee importNames -> importDescriptiveInfo
This opens up the possibility of importing more than just names.
2026-03-26 16:28:48 +00:00
Ivan Krysak 79618b3b63 CliftImportModel: extract name importing 2026-03-26 16:00:49 +00:00
Ivan Krysak 01658cab09 import-model-names: split into two
One is module-granularity (name unchanged). The other (new) one
is function-granularity: `import-function-model-names`.
2026-03-26 16:00:49 +00:00
Ivan Krysak 62c6f6ecd1 import-model-names: factor importing logic out 2026-03-26 16:00:49 +00:00
Ivan Krysak 2cc7edb4b2 import-model-names: fix invalidation problems
Model fields were read *after* invalidation data is written, which is
not acceptable.
2026-03-26 16:00:49 +00:00
Ivan Krysak 7244b12825 import-clift-types: switch to binary rank 2026-03-26 16:00:46 +00:00
Ivan Krysak 2841f8ab84 Introduce module-level CliftContainer 2026-03-25 17:26:24 +00:00
Ivan Krysak a3c43f92d4 Rename CliftContainer > CliftFunctionContainer 2026-03-25 15:42:13 +00:00
Ivan Krysak 5fdc99c4da Minor improvements 2026-03-25 15:42:13 +00:00
Andrea Gussoni 02cc6923d0 EmitFieldAccesses: implement pass
The `EmitFieldAccesses` pass transforms `clift` by taking pointer-typed
expressions computed via integerr arithmetic with type-safe field
accesses and array accesses.

The transformation is split in three main phases:
1) `PointerArithmetic` computation.
2) `BestTraversal` computation.
3) `FieldAccess` `clift` rewrite.

The high level driver is implemented in the `EmitFieldAccesses` header
and cpp, while the nested 3 phases are implemented respectively in
`PointerArithmetic`, `BestTraversal` and `FieldAccessReplacement`.

The `computerPointerArithmetic` phase is concerned with taking a
pointer-typed `ExpressionOp`, called `PointerToReplace`, and expressing
it in a `BasePointer+Offset` form.

The `computeBestTraversal` phase is concerned with computing the best
traversal of the type pointed to by `BasePointer`, that can be used to
rewrite the pointer arithmetic in `clift` with just field accesses and
array subscripts.

The `replaceFieldAccess` phase takes the `Traversal` computed at the
previous step, and actually rewrites in `clift` the `PointerToReplace`
in terms of field accesses and array accesses w.r.t. the `BasePointer`.
2026-03-18 17:25:13 +01:00
Ivan Krysak d521651b1e ImportModelNamesPipe: set helper names too 2026-02-25 14:10:44 +01:00
Giacomo Vercesi cdfe858840 clift NameImporter: handle empty FunctionOps
Handle the case where a clift `FunctionOp` is present but has no body in
`NameImporter`.
2026-02-16 12:17:56 +01:00
Lauri Vasama 57c49e4302 Implement Clift statement comment import 2026-02-13 08:41:39 +02:00
Lauri Vasama db8fd8de39 Avoid sanitizing identifiers in Clift name import 2026-02-13 08:41:39 +02:00
Lauri Vasama dd75b0aebc Improve Clift local name import
* Names are now only imported for locals with valid handles.
* Stack frame variable is now handled separately.
2026-02-13 08:41:39 +02:00
Lauri Vasama 8b709ea532 Assign local variable and label handles in Clifter
Handles were previously assigned in the model name import pipe, but as
they are not expected to change often, they can be improted in the
Clifter. Additionally, in some cases it may be desirable to emit C
using generated names instead of those imported from the model, in which
case no handles would be available.
2026-02-13 08:41:39 +02:00
Lauri Vasama 811478771e Make local op name attributes inherent
The handle was already inherent, but was not being used. Discardable
attributes were instead previously used for both handle and name.
2026-02-13 08:41:39 +02:00
Lauri Vasama 8cbc0e6d24 Move CTokenEmitter into namespace ptml 2026-02-11 12:48:33 +02:00
Giacomo Vercesi e260d05082 Add EmitC to pypeline 2025-12-10 16:16:14 +01:00
Giacomo Vercesi 9b527c8b69 Add ImportModelNames to pypeline 2025-12-10 16:16:14 +01:00
Giacomo Vercesi cfe476c701 Add ModelVerifyClift to pypeline 2025-12-10 16:16:14 +01:00
Giacomo Vercesi 97fe9203e1 Add LLVMToClift to pypeline 2025-12-10 16:16:14 +01:00
Lauri Vasama 21a51af54f Add immediate radix deduction pass 2025-12-05 19:53:41 +02:00
Lauri Vasama 33450e9306 Add terminal-branch-complement-hoisting pass 2025-12-05 19:53:41 +02:00
Lauri Vasama 73d7a77442 Add expression rewrite pass 2025-12-05 19:53:41 +02:00
Lauri Vasama 0f04483517 Add statement rewrite pass 2025-12-05 19:53:41 +02:00
Lauri Vasama 448276915e Add label-merging pass 2025-12-05 19:53:41 +02:00
Lauri Vasama f2911da190 Add trivial-return-elimination pass 2025-12-05 19:53:41 +02:00
Alessandro Di Federico 54cbadfc0f ImportModelNamesPipe: use prototypeOrDefault 2025-12-03 17:59:19 +01:00
Alessandro Di Federico 1dff54ba60 Make new backend independent from the old one 2025-12-03 17:59:18 +01:00
Lauri Vasama fbc1563b43 Add loop detection pass 2025-11-12 15:28:54 +02:00