Commit Graph

911 Commits

Author SHA1 Message Date
Andrea Gussoni 4e3af009fe Expressions: fold x[0] into *x
Implement a DDR rewriting for folding the `x[0]` into `*x`, in order
to avoid a useless verbose syntax. Due to concatenation of rewrites, we
will get `&(x[0])` transformed into `x`, which is the rewriting we are
aiming to.
2026-04-14 09:52:07 +02:00
Andrea Gussoni 8359b4da26 EmitFieldAccesses: indirection propagation test 2026-04-14 09:50:48 +02:00
Andrea Gussoni f6b1772bbd EmitFieldAccesses: add const-qualified test 2026-04-14 09:50:48 +02:00
Giacomo Vercesi 18e3501731 pypeline: implement proper config parsing
Overhaul the pipeline configuration logic by collapsing all dynamic
configuration options, both for analyses and pipes into a single
dictionary. Change all the interfaces so that there is no longer
distinction between the configuration of an analysis and of pipes.
Expose these options to the command line via `--{name}-configuration`
options for each pipe/analysis that is applicable to the command-line
invocation.
2026-04-10 11:45:12 +02:00
Lauri Vasama 79a4fbc808 Fix DoxygenEmitter line prefix emission 2026-04-09 18:37:46 +03:00
Lauri Vasama 8085a1e8e9 Improve integer literal emission 2026-04-08 12:31:45 +03:00
Lauri Vasama 4cadcafa2c Move operand constraints from C++ to tablegen 2026-04-08 12:30:31 +03:00
Lauri Vasama 0e7703e312 CBackend null pointer constant 2026-04-08 12:29:58 +03:00
Lauri Vasama d35e54627c Add Clift ValueType interface
Value types is the set of non-array object types. These types are
assignable, can be used as function parameters, and as return types
(along with void), and in other scenarios where the type must have usual
value-like behaviour with no weirdness (such as array decay).
2026-04-08 12:28:45 +03:00
Lauri Vasama be8351a17d Split up Clift PrimitiveType
* PrimitiveType is now an interface.
* VoidKind is now VoidType.
* FloatKind is now FloatType.
* The integer kinds are now IntegerType with IntegerKind.
2026-04-08 12:18:10 +03:00
Lauri Vasama a2be1b476a Split up Clift CastOp
* DecayOp - array or function to pointer decay. Not shown in C.
* BitCastOp - bit-preserving conversion. Emitted as bit_cast if
  necessary.
* ExtendOp - zero- or sign-extending conversion from any integer type to
  any wider integer type.
* TruncateOp - truncating conversion from any integer type to any
  narrower integer type.
* PtrResizeOp - resizes a pointer without changing its pointee type.
2026-04-08 12:11:54 +03:00
Lauri Vasama 90658bbbed Change default C target size of long
Currently there is only a single default target used for all C emission.
However, the emitted code is actually compiled using multiple
implementations (32-bit and 64-bit targets), some of which use a 32-bit
wide long. This causes integer literals to be emitted with wrong sizes
on those targets. This change forces all 64-bit literals to be emitted
using long long, which is 64 bits wide in all relevant implementations.
2026-04-08 11:12:41 +03:00
Lauri Vasama 00e9ed8c5d Remove unnecessary Clift unit test 2026-04-08 11:12:41 +03:00
Giacomo Vercesi 2e6193e77f test_pypeline_daemon: fix flaky SIGSEGV
Avoid triggering a flaky SIGSEGV caused by running the asyncio event
loop in a thread. Switch to using `Process` which avoids the issue
altogether.
2026-03-31 17:00:49 +02:00
Giacomo Vercesi 9b68cf4a39 pypeline-daemon: rework /artifact endpoint
Rework the artifact endpoint, making it similar to the CLI invocation.
It now works on a single artifact and can be made to return both `json`
and `tar` as formats.
2026-03-31 17:00:49 +02:00
Giacomo Vercesi 4c6436f7b2 pypeline: introduce artifact category
Add categories in the pipeline, allow an artifact to have a category
specified which allows it to be shown or hidden by default. Adapt the
CLI tools to hide artifacts of the category that don't
`show_by_default=True`.
2026-03-31 17:00:48 +02:00
Giacomo Vercesi 39f1a9c3a9 pypeline: drop underscores from pipeline yaml
Remove the only instance of underscores in the pipeline yaml from the
use of `analysis_lists`. Substitute it with `analysis-list`.
2026-03-31 17:00:48 +02:00
Giacomo Vercesi 550ac7b700 pypeline-daemon: add put-file endpoint
Add an endpoint to the daemon that allows adding a file to the file
storage.
2026-03-31 17:00:48 +02:00
Giacomo Vercesi 6dc053e55c pypeline-daemon: rework error propagation
Rework how errors are propagated from the daemon code to the HTTP
client, creating an exception hierarchy to handle the most common
cases.
2026-03-31 17:00:48 +02:00
Giacomo Vercesi 14d95a924d pypeline: rework fields in pipeline metadata
Rework which information is transmitted in the pipeline metadata,
avoiding redundancy and moving some information there instead of
returning it every time a request is made.
2026-03-31 17:00:48 +02:00
Giacomo Vercesi c53e615fa0 Cleanup pypeline code
Remove some cruft and apply trivial changes to the existing pypeline
code, especially on the daemon side.
2026-03-31 17:00:48 +02:00
Giacomo Vercesi 773245b893 pypeline/cli: use dataclass for ctx.obj
Add typing to the `ctx.obj` object used to store pypeline-specific data
while parsing the command-line in click.
2026-03-31 17:00:48 +02:00
Andrea Gussoni 30a1396a64 EmitFieldAccesses: typedef pointer as array tests 2026-03-30 16:03:37 +02:00
Andrea Gussoni 4c27971ed8 EmitFieldAccesses: pointer as array tests 2026-03-30 16:03:37 +02:00
Ivan Krysak 979a384763 mlir_lit_tests: test unit attribute emission 2026-03-27 08:28:21 +00:00
Ivan Krysak 82e86cf167 Emit prototype attributes *before* the prototype 2026-03-27 08:27:52 +00:00
Ivan Krysak 69a6508ea7 mlir_lit_tests: introduce comment-specific tests 2026-03-27 08:21:58 +00:00
Ivan Krysak 8f747e7ff3 Name-import tests: be explicit about the ABI 2026-03-27 08:15:56 +00:00
Ivan Krysak 9524312ed4 C-Attributes: test typed arguments 2026-03-27 08:07:41 +00:00
Ivan Krysak 58257d5520 ImportModel: import _ABI 2026-03-27 08:04:10 +00:00
Ivan Krysak 105f15266b ImportModel: import _CAN_CONTAIN_CODE 2026-03-27 07:19:27 +00:00
Ivan Krysak f4e7d50361 Allow C-Attributes to accept integers and types 2026-03-27 07:18:49 +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 1310b6ab62 Clift: append C to attribute classes we emit 2026-03-25 15:42:13 +00:00
Andrea Gussoni d54b8a5767 EmitFieldAccesses: array access argument and shl
Add two unit tests having a `struct` -> `array` -> `struct` access,
where the offset is computed through a `shl` operation, applied to a
dynamic index obtained through the argument.
2026-03-23 17:34:50 +01:00
Andrea Gussoni 732c880cd8 EmitFieldAccesses: array access argument and mul
Add a unit test having a `struct` -> `array` -> `struct` access, where
the offset is computed through a `mul` operation, applied to a dynamic
index obtained through an argument.
2026-03-23 17:34:50 +01:00
Andrea Gussoni cd3a30d346 EmitFieldAccesses: nested array access
Add a unit test for nested `array`s access, and a unit test for nested
`array`s access with a `struct` indirection level in the middle.
2026-03-23 17:34:50 +01:00
Andrea Gussoni 5a4a281677 EmitFieldAccesses: array with dynamic index test
Add a `EmitFieldAccess` unit test where we perform am `array` access,
using a dynamic index contained in another field of the `struct`
containing the `array` itself.
2026-03-23 17:34:50 +01:00
Andrea Gussoni 9e2528faec EmitFieldAccesses: ptr_add LinearCombination test
Add a test exercising the `LinearCombination` propagation through
`composePtrAdd`.
2026-03-23 17:34:50 +01:00
Andrea Gussoni b70c9aed66 EmitFieldAccess: ptr_add.offset as BasePointer
Additional test in to struct-ptradd-access.mlir that exercises the case
where the base pointer information comes from the offset operand (RHS)
of ptr_add rather than the pointer operand (LHS).

This tests the relaxed assumptions introduced in the previous commit
where `composePtrAdd` no longer requires the `PointerOperand` to be an
`Address` `PA`.
2026-03-19 17:31:42 +01: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
Andrea Gussoni cbb3f03910 Clift: fix CastKind::Decay verify
Perform `dealias` over argument operand of the `CastOp`.
2026-03-18 17:25:13 +01:00
Giacomo Vercesi ce60d8a1e5 pypeline: integrate model migration infrastructure
When calling `Model.deserialize` the model will be automatically be
migrated if it needs to.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi f4d0573017 pypeline: StorageProvider works with Model
Change the `get_model` and `set_model` interface of `StorageProvider` so
that it is responsibility of the `StorageProvider` to
serialize/deserialize the model before returning to the caller.
This is in preparation to the model migration being implemented, since
it's now a responsibility of the storage provider to deserialize it it
can trivially re-save it to disk if it is migrated.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi a6a3e15e6b pypeline: add env prefixes
Add the `PYPELINE_` prefix to all the pypeline environment variables.
2026-03-05 14:23:06 +01:00
Giacomo Vercesi 704c5e9bbb TupleTree: fix broken operator==
The `operator==` for keyed `StructDefinitions` was the comparison
between keys, which is misleading.
2026-03-04 14:58:02 +01:00
Giacomo Vercesi 9287c51d27 pypeline: fix -C option
Instead of executing `chdir` when using the `-C` option, which is
fragile when other paths are involved, store the option in the click
context and propagate it to the required code paths that require knowing
what the base directory is.
2026-03-04 14:58:02 +01:00
Ivan Krysak 69d006382b Fix revng build with coroutines disabled 2026-02-25 12:47:27 +01:00