Commit Graph

296 Commits

Author SHA1 Message Date
Giacomo Vercesi 27f419c8cd Fix and ban namespace clobbering
Fix an instance where the `std` namespace got clobbered into the global
namespace by accident.
2026-02-16 10:34:38 +01:00
Alessandro Di Federico 1429b526ab 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 17:25:03 +01:00
Alessandro Di Federico db8eb227b9 TupleTreePath: rewrite with TraitfulAny 2025-10-28 09:18:27 +01: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 2d618120e0 TTG: add default: value support
This also unifies `get_default_value` helper across all the target
languages.

Before this, there were two different versions of it for python
and typescript while c++ side didn't have one at all.
2025-10-13 18:33:10 +03:00
Ivan Krysak 23a0a09d21 TTG: add --string-type support to cpp generator
Note that other code-generating TTG-backends (namely python and
typescript) emitting ones already support this. This is just a matter
of extending similar logic to the c++ backend.
2025-10-13 18:33:10 +03:00
Ivan Krysak 75e505b2ec TTG: do not print an unnecessary comment
`Tracking helpers` comment would be printed even if invalidation is
disabled for a given TTG instance.
2025-10-13 18:33:10 +03:00
Ivan Krysak da7623acb0 TTG: introduce a simple isValid helper for enums
It checks whether value is within the valid range:
```
Invalid < Value < Count
```
2025-10-13 18:33:10 +03: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 59ffacf61b localCompare: mention fields as they are skipped 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
Ivan Krysak 480443f358 TTG: drop upcastable: configuration option
Instead, detect whether `UpcastablePointer` wrapping is needed or not
based on the type.
2025-10-13 18:33:10 +03:00
Ivan Krysak e9bb8c43cf TTG: make sure emission order is stable
Debugging is a lot harder when you cannot just diff outputs of
the generator.

This commit ensures types are always emitted in the same order,
no matter the input schema ordering or the target language.
2025-10-13 18:33:10 +03:00
Ivan Krysak d1fdb4d649 TTG: drop an unused global 2025-10-13 18:33:10 +03:00
Ivan Krysak 2315248938 TTG: remove a broken KOT-compatibility check 2025-10-13 18:33:10 +03:00
Ivan Krysak 38921fb85e TTG: drop an unnecessary TODO 2025-10-13 18:33:10 +03:00
Ivan Krysak 95845277a9 TTG: verify given schema 2025-10-13 18:33:10 +03:00
Ivan Krysak 89282f31da Minor improvements 2025-10-13 18:33:10 +03: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 c68b7f1ab6 TupleTreeGenerator: make all keys hashable
Make all `Key` structs generated by TupleTreeGenerator have a
`std::hash` specicialization.
2025-09-17 14:02:40 +02:00
Tommaso Fontana 680f5cacf2 Apply revng check-conventions --force-format 2025-09-10 12:05:14 +02:00
Ivan Krysak 2b9b925e8c TTG: make doc mandatory in fields too 2025-07-23 11:38:52 +02:00
Ivan Krysak f49ec25de3 TTG: make doc mandatory in structs and enums 2025-07-23 11:38:52 +02:00
Ivan Krysak b5337d78da Minor Improvements 2025-07-23 11:38:50 +02:00
Giacomo Vercesi d8ec6b7721 revng.model: add serialize() to all TTG types 2025-07-18 09:30:56 +02:00
Giacomo Vercesi 82dccc0bea revng.tupletree: add TypedListDescriptor
Add a class implementing the descriptor protocol to allow TypedList
fields to be assigned a `list` and automatically convert it to the
TypedList class.
2025-07-18 09:30:56 +02:00
Giacomo Vercesi 0a2cb4df12 TTG: move namespace to the cpp generator
The `namespace` property is strictly used just by the cpp generator.
Move the code so the `--namespace` option is exclusive to it and removed
for all the other generators.
2025-06-25 15:40:13 +02:00
Giacomo Vercesi d62b7b6b1a TTG: inline root type in schema
Move the root type inside the schema definition, as it is a property of
it and not of the generator.
2025-06-25 15:40:13 +02:00
Giacomo Vercesi d404fee38f Unify TTG CLI tool for generation
Merge all the command-line scripts for generating tuple-tree
implementations into a single `tuple-tree-generate.py` script. Move all
the other files a directory down.
2025-06-25 15:40:13 +02:00
Giacomo Vercesi d53312d867 Rename CppHeadersGenerator to CppGenerator
Since the generator produces more than just headers, rename the class
and the file to just `cpp`.
2025-06-25 15:40:13 +02:00
Giacomo Vercesi 3e3779498e Implement python interface for revng
Add a python interface (`revng.profile`) for interacting with the rev.ng
infrastructure as a whole; either through the CLI (`CLIProject`) or the
GraphQL API (`DaemonProject`).
2025-05-07 10:48:51 +02:00
Giacomo Vercesi de997ca2e4 python TTG: add mixins infrastructure
Add the infrastructure code needed to allow to add mixins to Tuple-Tree
Generated classes in python.
2025-05-07 10:48:50 +02:00
Giacomo Vercesi d8fffc0980 Improve Python's TTG typing
Improve the typing signatures in a few place in the `revng.tupletree`
package and in the auto-generated python TTGs.
2025-05-07 10:48:46 +02:00
Jurij Srebrnič 3050b291b1 Implement diff and apply for python model wrapper
Add the necessary code for the python model wrapper to allow diffing and
applying a diff.
2025-05-07 10:48:45 +02:00
Giacomo Vercesi 9d017ec94d TTG python: change template variable delimiter
Change the variable delimiter for the template used to generate the
tuple-tree wrapper from `'` to `#{` and `}#`.
2025-05-07 10:48:44 +02:00
Giacomo Vercesi 6b7af19817 tuple_tree.ts: rename TypeHints to TypesMetadata
Rename the `TypeHints` to `TypesMetadata` (and related function
arguments) to better convey their contents.
2025-05-07 10:47:27 +02:00
Giacomo Vercesi 57c4f89dd3 python: remove relative imports
Remove all the relative imports from the python code that are not
relative to the current module (e.g. `from .<X> import ...`).
2025-05-05 16:02:40 +02:00
Khaled Ismaeel 8b355fc896 Add primitive support for generating migrations 2025-04-30 15:08:45 +02:00
Khaled Ismaeel 030becfeba Adapt the build to the new schema version field
This is a followup to the commit where we introduced the `version`
field in the schema YAML.
2025-04-30 15:08:45 +02:00
Khaled Ismaeel 383af5b6b0 Add the version field to schemas YAML
Here we start restructuring the the schemas YAML such that it
contains a top-level `version` field. In this commit we only modify
the YAML, the build system changes will come later, to avoid
enormous commits.
2025-04-30 15:08:45 +02:00
Khaled Ismaeel 531d9b866c Remove the now-redundant HEADERS list 2025-04-30 15:08:45 +02:00
Khaled Ismaeel 63469c9cd6 Use unified YAML schemas in the build process
In this commit we instruct the build system to use the unified schema
files  instead of collecting the `TUPLE-TREE-YAML` comments.

The fixes to C++ files are necessary because they depend on the order
of the fields in the schema, which was changed.
2025-04-30 15:08:45 +02:00
Giacomo Vercesi e7fdd22966 extract-helper-names.sh: fix unquoted variable 2025-04-24 13:22:14 +02:00
Ivan Krysak 80d8ac2b1d Introduce helper list collection 2025-04-17 11:19:17 +03:00
Giacomo Vercesi 140735a913 tuple-tree-generate-typescript: drop --prettier
The `prettier` binary is now assumed to be installed as part of the
system. No need to manually install it and use the `--prettier`
command-line option.
2025-03-13 14:06:02 +01:00
Giacomo Vercesi 6c31138374 Drop unused files in scripts/
Some files under `scripts/` were unused. Delete them as they are no
longer needed.
2025-03-13 14:06:02 +01:00
Giacomo Vercesi 6d0eb467f7 tuple_tree python: implement keying
Implement keying functions for classes that have them.
2025-02-25 09:18:24 +01:00
Alessandro Di Federico 620d142d53 Reroganize and expand documentation 2024-12-11 16:15:37 +01:00
Alessandro Di Federico 0c7c20ad48 Introduce model, artifacts and analyses references 2024-12-11 16:15:27 +01:00
Alessandro Di Federico 276a4aa974 Generate model docs 2024-12-11 16:15:10 +01:00