Commit Graph

808 Commits

Author SHA1 Message Date
Alessandro Di Federico b1feb5b989 Introduce libtcg
This commit drops libptc in favor of its new form libtcg.

It brings several improvements, among which:

* The QEMU version we work on has been upgraded.
* CPUStateAccessAnalysis has been reimplemented in a way that makes it
  easier to debug and solves some limitations (e.g., tracking leaking
  pointers).
* Identification of pieces of the CPU state that are read by each helper
  and fixing access to the CPU state is now performed at build-time.
* We no longer mmap the code we need to translate, dropping all the
  issues related to code that needed to be mapped where something is
  already present.
* We now have two distinct flavors of helper modules: the full one and
  the "slim" one. The latter contains the definition only of functions
  we intend to inline. It is used in most of the pipeline, a good thing
  since we spend less time optimizing code we don't really care about.
  The full module is only used on the re-compilation branch of the
  pipeline.
* We no longer split the `cpu_loop` function.
* We change MetaAddress to rely on architectures from `model::` as
  opposed to the LLVM ones.
* We no longer attach debug info to LLVM IR containing the original
  assembly.
* We now verify that the lifted code only contains code we expect.
2025-10-31 14:49:05 +01:00
Alessandro Di Federico 8f21f3b5e1 check-conventions for older commits 2025-10-31 13:23:45 +01:00
Lauri Vasama a77fdd3f99 Add new RecursiveCoroutine unit test 2025-10-31 09:30:54 +01:00
Alessandro Di Federico dfbe005307 ReadFields: switch to vectors 2025-10-29 15:10:18 +01:00
Ivan Krysak 2ba5ca3e3d Suppress selected IRBuilder checks 2025-10-21 19:17:37 +03:00
Ivan Krysak 3561c2b907 Adopt IRBuilder wrapper 2025-10-21 19:17:01 +03:00
Lauri Vasama 7980e57fb5 Add Clift C legalization pass 2025-10-21 09:15:40 +02:00
Lauri Vasama 02d3c82887 Add support for Clift for-loop initializers 2025-10-21 09:15:40 +02:00
Lauri Vasama bf5adce413 Overhaul Clift loop syntax, add break/continue 2025-10-21 09:15:40 +02:00
Lauri Vasama 3d9df0f50d Add then marker for Clift if-statement assembly 2025-10-21 09:15:40 +02:00
Lauri Vasama 7da5792f0a Add Clift label and jump operation interfaces 2025-10-21 09:15:40 +02:00
Lauri Vasama 143fce8f62 Fix switch statement C emission
No newline was previously emitted before the first case:
```
switch (C) {case 1: {
  } break;
}
```
2025-10-21 09:15:40 +02:00
Giacomo Vercesi b622fe8f19 Implement FileProvider interface
Implement the `FileProvider` interface, this allows pipes to request
files given a `FileRequest` (hash and optional size/name).
2025-10-16 17:48:45 +02:00
Giacomo Vercesi 40da49548b Add Binaries list to the model
Add to the model an entry detailing the list of input binaries under
`Binaries`. This will be referenced by `Segments` when needed.
2025-10-16 17:48:45 +02:00
Giacomo Vercesi e57442fafe Introduce Tar.h
Split off the `GzipTarReader` into `Tar.h`, include a normal
`TarWriter` class which leverages libarchive to generate the tar file.
2025-10-16 16:08:05 +02:00
Giacomo Vercesi 0f7dc7047d pypeline.Container: fix signature of (de)serialize
Change the signature of `Container.serialize` and
`Container.deserialize` to use `Buffer` instead of `bytes`, as this
makes the functions compatible with the `revng::pypeline::Buffer`
classes.
2025-10-16 16:08:05 +02:00
Giacomo Vercesi ca0f312b1e Pipebox: remove const from ArrayRef
Remove the `const` from `ArrayRef<const char>` as the `ArrayRef` already
implies the underlying type will be accessed only in `const`.
2025-10-16 16:07:09 +02:00
Giacomo Vercesi d08c490993 pypeline::Model: expose children function
Expose the `revng::pypeline::Model.children` function to python, as it
was not previously exposed.
2025-10-16 12:51:55 +02:00
Giacomo Vercesi f165f99392 pypeline.Model: make deserialize to static
Change the `Model.deserialize` to a static function, which will return
a new instance of the Model.
2025-10-16 10:30:01 +02:00
Giacomo Vercesi bad8d0f622 Add test for pypeline's StorageProviders
Add a test that checks that the newly implemented invalidation logic
actually works and the objects stored as children or parent objectids
are also dropped when invalidating.
2025-10-15 17:43:09 +02:00
Giacomo Vercesi d92f4cdca3 ObjectID: introduce byte (de)serialization
Add the `to_bytes` and `from_bytes` to `ObjectID`. This allows
serializing an `ObjectID` instance to raw bytes with a specific binary
format.
2025-10-15 11:58:41 +02:00
Giacomo Vercesi 46654c8b26 TupleTree: narrow enums to the smallest uint
When emitting `EnumDefinition`s in C++, use the smallest uint type as
the base class.
2025-10-15 11:58:40 +02:00
Ivan Krysak cc57e57fd1 TTG: remove support for optional: true fields
After this commit, every non-key field is treated as if it was optional
while every key field (plus every auto-generated `Kind` field) - as if
it was required.
2025-10-13 18:33:10 +03:00
Ivan Krysak 10ca432cb2 TTG: simplify reference field usage
This allows to avoid having to specify the `rootType` (stable within
the entire tree) manually each time a reference is introduced.
Thanks to that, a much nicer syntax of:
```yaml
- name: MyTypeField
  reference-to: TypeDefinition
```
can replace the current one:
```yaml
- name: MyTypeField
  reference:
    pointeeType: TypeDefinition
    rootType: Binary
```
2025-10-13 18:33:10 +03:00
Lauri Vasama 22d6f70ee2 Clift directory structure overhaul 2025-10-13 15:08:20 +02:00
Lauri Vasama 3c191122dc Rename Clift to CliftDialect, CliftOps to Clift 2025-10-13 15:08:20 +02:00
Ivan Krysak 5717d835f8 Add missing llvm::Error checks 2025-10-13 10:26:37 +03:00
Ivan Krysak e6d30936f3 Avoid llvm::ExitOnError in non-tool binaries 2025-10-08 12:22:34 +03:00
Ivan Krysak d1fbf2eee6 Model: Drop ToolHelpers.h 2025-10-08 12:22:34 +03:00
Giacomo Vercesi 6d1fbdca97 Implement infrastructure for PipeRuns
Add the needed infrastructures that allow ephemeral classes (`PipeRun`s)
to be wrapped as a regular pypeline `Pipe` class. These automatically
have their dependencies tracked and propagated to the pypeline.
2025-10-03 17:40:45 +02:00
Lauri Vasama 110fb23d58 Improve Clift backend string literal test 2025-09-29 18:05:55 +03:00
Lauri Vasama 18773ba22c Add Clift declaration attribute support 2025-09-29 18:05:55 +03:00
Lauri Vasama cd48916c8d Convert Clift backend tests to use clift-opt 2025-09-29 18:05:55 +03:00
Lauri Vasama a50138998d Model agnostic Clift backend using CTokenEmitter 2025-09-29 18:05:55 +03:00
Lauri Vasama 9eb6b5d6df Remove Clift backend stack frame inlining 2025-09-29 18:05:55 +03:00
Lauri Vasama 16a5ee0a56 Disable elaborated type specifier emission 2025-09-29 18:05:55 +03:00
Lauri Vasama 6914795e9e Fix Clift backend type emission 2025-09-29 18:05:55 +03:00
Lauri Vasama 77adbcc5ba Add import-model-names pipe 2025-09-29 18:05:55 +03:00
Lauri Vasama 549fc933f1 Add handle parameters to fields and enumerators 2025-09-29 18:05:55 +03:00
Lauri Vasama bf0f9e00f0 Remove NameBuilder from Clift model type import 2025-09-29 18:05:55 +03:00
Lauri Vasama 1ce6f256a7 Improve Clift local and global syntax 2025-09-29 18:05:54 +03:00
Lauri Vasama 6b703e6ccd Fix C backend output on double negation 2025-09-29 18:05:54 +03:00
Andrea Gussoni 855a9309ec MaterializeLoopScopes: drop pass
Drop the `MaterializeLoopScopes` pass after the re-design the loop
matching stage to work entirely on `clift`, without the need to insert a
`scope_closer` edge to guide the emission.

Simultaneously, drop the DAGify `Head` metadata insertion, since it will
not be checked anymore during the `MaterializeLoopScopes` pass.
2025-09-26 10:39:09 +02:00
Andrea Gussoni 2ba365bc45 DAGify: fix Head election
During the `Head` election phase, we now introduce the following
additional criterion:
When processing a `GenericRegion` nested into an outer one (its
`ParentRegion`), if the inner `Region` contains the block that has been
elected as `Head` of the `ParentRegion`, we also force that block to be
the `Head` of the inner `GenericRegion`.

We add a unit test to check this behavior.
2025-09-24 15:51:06 +02:00
Giacomo Vercesi 448f70e7dc Add trace runner
Add the tool `pypeline-trace-runner` which allows reading a serialized
pypeline schedule and execute it purely in C++.
2025-09-17 14:09:16 +02:00
Giacomo Vercesi 688b9fe111 Introduce compatibility with revng-pypeline
Add the necessary machinery to allow `Pipe`s, `Analysis`es,
`Container`s, `Model` and `ObjectID` to be implemented in C++ and used
by Python.
2025-09-17 14:02:40 +02:00
Giacomo Vercesi 5f5d2da842 check-conventions: check CMakeLists.txt license
The `check-conventions` script inadvertently ignored checking the
license header in `CMakeLists.txt`. Change the script so that those are
checked. Also add the missing headers to the reported files.
2025-09-17 14:02:40 +02:00
Ivan Krysak dbd8a720b7 Reduce using namespace abuse 2025-09-10 17:44:02 +02:00
Andrea Gussoni dab3fb3403 MLoopScopes: introduce unit tests 2025-09-10 13:36:09 +02:00
Andrea Gussoni 7965fa3039 DAGify: implement abnormal entry normalization
Perform the abnormal (late) entries normalization in the DAGify pass.

In this way, we are exploiting the information computed by
`GenericRegionInfo` as close as possible to where it is computed the
first time (in DAGify).

Actualize the unit tests to reflect these changes.
2025-09-10 13:36:09 +02:00