Commit Graph

137 Commits

Author SHA1 Message Date
Alessandro Di Federico 0f8fa271d9 TupleTree: reduce INTROSPECTION responsibilities
This commit also introduces support for optional YAML serialization of
fields.
2021-07-21 18:19:45 +02:00
Alessandro Di Federico a546ac2a37 Introduce model::Register::getSize 2021-07-21 18:19:45 +02:00
Alessandro Di Federico 69367669d7 model::Register: enable as KOC key 2021-07-21 18:19:45 +02:00
Alessandro Di Federico 56644b8512 Move model::Register in its own file 2021-07-15 13:50:53 +02:00
Pietro Fezzardi 8fa8ca2d03 Rework getWriteableModel to return a TupleTree
The previous design returned a model::Binary &, which did not allow
users writing the model to properly initialize cross references between
different parts of the model.
2021-07-15 13:30:25 +02:00
Alessandro Di Federico b4929b431c Drop IsTupleEnd concept 2021-07-15 13:30:25 +02:00
Alessandro Di Federico 6d10581163 Whitespace and other minor changes 2021-07-15 13:30:25 +02:00
Pietro Fezzardi 6f7de910a6 Enable warning -Wunused-local-typedefs 2021-06-14 23:04:02 +02:00
Pietro Fezzardi a7a55f974a Require TupleTreeCompatible concept on TupleTree 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 3cb6dcd163 Move IsYamlizable generic lambda in TupleTree.h 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 75bff8f29c Move CompositeScalar in YAMLTraits.h
Soon Binary.h will not be the only user.
This commit makes the same machinery usable elsewhere.
2021-06-09 20:13:27 +02:00
Pietro Fezzardi 4b7f383ea5 Conceptify YAMLTraits.h 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 8557a30206 TupleTree: improve serialization 2021-06-09 20:13:27 +02:00
Pietro Fezzardi b78d52ac3c Add TupleTreeReference::operator==, ignoring Root 2021-06-09 20:13:27 +02:00
Pietro Fezzardi 88a48015dc TupleTree.h: require IsKeyedObjectContainer
Requires IsKeyedObjectContainer in TupleTree.h wherever possible,
instead of IsContainer. This enables using std::vectors.
In this way, they will not be diffed based on the key, but on the entire
vector. This is intended.
2021-06-09 20:13:27 +02:00
Pietro Fezzardi 0a293b5881 CallByPathVisitorWithInstance on UpcastablePointer
Add a specialization for
CallByPathVisitorWithInstance::visitContainerElement to handle cases
where the element of the container is an UpcastablePointer, that needs
to be unwrapped before visiting.

This fixes a problem causing bad TupleTree traversal with
TupleTreeReference. Specifically, CallByPathVisitorWithInstance did not
know how to visitContainerElement when the element of the container was
an UpcastablePointer. This caused the visit to always return nullptr
even when the TupleTreeReference was well-formed. This has been fixed by
adding an overload with proper concept constraint, that teaches
CallByPathVisitorWithInstance how to properly traverse
UpcastablePointers.
2021-06-09 20:13:27 +02:00
Alessandro Di Federico 871931b9cd Test TupleTreeDiff on Model
`TupleTreeDiff` was not being tested.

This commit implements several `operator==` that are required to
successfully instantiate `TupleTreeDiff`.
2021-05-06 15:42:16 +02:00
Alessandro Di Federico e62f888381 Drop KeyTraits
This commit drops the KeyTraits in favor of a std::any-like solution.
Basically, we type erase any key the user wants to employ, just exposing
a virtual version of the destructor, a comparison operator and a clone
primitive.
2021-05-06 15:42:00 +02:00
Alessandro Di Federico 7e637beef3 Import static TupleTree validation routines 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 9650369fa7 Import TupleTree and TupleTreeReference 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 6fd8a87572 TupleTree, visit: rename and make more usable 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 51682eb024 model::FunctionEdge: carve out CallEdge 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 582dee6fcc TupleTree: support UpcastablePointer 2021-05-05 17:10:12 +02:00
Pietro Fezzardi 50681284c0 Conceptify revng
Use concepts across revng wherever possible, to keep the code concise
and easier to understand.
2021-05-05 17:10:12 +02:00
Alessandro Di Federico aeb81c4218 Don't implicitly use StringRef as std::string 2021-04-22 18:06:27 +02:00
Alessandro Di Federico 2b9cbb98ec Introduce --invoke-isolated-functions
This commit ensures that FunctionIsolation and EnforceABI do only
thing. This means that they no longer modify `root`.

Instead, we have a new pass, `invoke-isolated-functions` that needs to
be run after them and replaces the entry point of the functions with
invokes to the isolated functions, possibly with the appropriate
arguments.
2021-04-22 14:45:52 +02:00
Alessandro Di Federico b25c43705c SerializeModelPass: support new pass manager 2021-03-16 11:55:58 +01:00
Alessandro Di Federico c2d6631216 LoadModelPass: support new pass manager 2021-03-16 11:55:58 +01:00
Alessandro Di Federico 0f7de0c2e0 Call to noreturn functions are not killer
We used to mark call to noreturn functions as killers, but this is not
correct.

Note that this is a temporary solution, we need to explicitly handle
such situations.
2021-02-19 09:39:49 +01:00
Alessandro Di Federico 93b7420c8a Implement model::Function::dumpCFG 2021-02-19 09:39:49 +01:00
Alessandro Di Federico 82605514c4 model: prepare for ABI information
This commit also drops some dead code and fixes Model tests accordingly.
2021-02-19 09:39:49 +01:00
Alessandro Di Federico 49287e9de7 Improve Model and TupleTree
This commit:

* Drops `KeyTraits::toString`: if needed, use `getNameFromYAMLScalar`.
* Makes many methods in TupleTree.h return `nullptr` or `std::optional`
  in order to gracefully handle failures.
* Provides `KeyTraits` specializations for integral types and tuple-like
  composed by types providing `KeyTraits`.
* Introduces `CompositeScalar`, which enables tuple-like objects to be
  YAML-serializable scalars by joining the YAML-serialization of its
  members through a customziable character.
* Implements `PathMatcher`, a very simple "regular expression" mechanism
  for paths on tuple trees.
* Introduce testing for the Model.
2021-02-17 11:48:46 +01:00
Pietro Fezzardi 10b90d6e15 SerializeModelPass: static method to write Model 2021-02-17 11:37:00 +01:00
Pietro Fezzardi 645484f699 LoadModelPass: add static function to read Model 2021-02-17 11:37:00 +01:00
Alain Carlucci f3d755e0ff TupleTree*.h: add missing include 2021-02-08 12:25:34 +01:00
Alain Carlucci f1808c9db6 TupleTree: extend FOR_EACH up to 16 arguments
This commit extends the support for the FOR_EACH macro used in
INTROSPECTION_NS to allow serialization of structs with more than
5 entries. Now it supports up to 16 entries.
2021-02-01 11:03:53 +01:00
Alessandro Di Federico 38031f2f8a Import preliminary model
This commit imports:

* support for (de-)serializing tuple-like objects in YAML
* the Model data structure
* the {Load,Serialize}ModelPass
2021-01-27 19:46:53 +01:00