Commit Graph

108 Commits

Author SHA1 Message Date
Antonio Frighetto c2815949c7 Adopt std::same_as of libcxx 2022-04-15 18:25:08 +02:00
Giacomo Vercesi 457d782ea8 UpcastablePointer::YAMLTraits: use Kind 2022-04-08 17:32:12 +02:00
Alessandro Di Federico f6c9b04c81 Adopt clang-tidy: readability-identifier-naming 2022-04-04 21:15:52 +02:00
Pietro Fezzardi b27432fcbd Move NotVoid and DerivesFrom to ADT/Concepts.h
since they can be useful elsewhere.
2022-03-30 17:11:40 +02:00
Pietro Fezzardi b4c733ab57 Move Concepts.h into include/ADT for better reuse 2022-03-30 17:09:24 +02:00
Ivan Krysak fbc59747bc STLExtras.h: introduce append 2022-03-28 15:37:02 +02:00
Massimo Fioravanti bb23892df7 Fix detail namespaces
Some `revng::detail` namespace were already inside a different namespace
which lead to the `revng::revng` namespace.
2022-03-28 12:17:05 +02:00
Alessandro Di Federico 0793e4afcb Turn lifting into a pass 2022-03-11 15:37:12 +01:00
Alessandro Di Federico 5e38805063 Rename detail namespaces into revng::detail 2022-03-11 15:37:12 +01:00
Alessandro Di Federico ee0b8f44c1 Introduce BinaryImporter
This is a big step to split revng-lift in two parts: one that only
writes the model and one that actually lifts to LLVM IR.

* Introduce `revng import binary`
* Split off `BinaryFile.h`
* Drop `revng.h`
* `GeneratedCodeBasicInfo`: use model
* Reduce role of `GeneratedCodeBasicInfo` in favor of
  `model::Architecture` and `model::Register` methods
* `CodeGenerator`: adopt `RawBinaryView` and model
* `JumpTargetManager`: adopt `RawBinaryView` and model
* `ExternalJumpsHandler`: adopt model
* `InstructionTranslator`: discard `Architecture` in favor of
  `EndianessMismatch`
* Many other changes
2022-03-08 15:15:24 +01:00
Alessandro Di Federico af79107b8b Move Integral concept to Concepts.h 2022-03-08 12:25:35 +01:00
Pietro Fezzardi 269d729554 FilteredGraphs: add filter() method
The method allows to access the filter function and is useful for
templating.
2022-03-02 15:40:27 +01:00
Ivan Krysak 3bb266125c Add always_true and always_false traits 2022-02-14 10:57:10 +01:00
Alessandro Di Federico 0f084ed620 Minor changes 2022-02-07 16:55:46 +01:00
Alessandro Di Federico 78be0e9268 Explode TupleTree.h 2022-01-31 16:28:26 +01:00
Alessandro Di Federico 5c89a6a858 callOnPathSteps: fix UpcastablePointer handling
The version of callOnPathSteps without an actual instance was completely
ignoring the upcasted type of `UpcastablePointer`s. We now fix this by
calling the right template specialization, which we choose by inspecting
the key of the `UpcastablePointer`.
2022-01-31 14:13:25 +01:00
Alessandro Di Federico 48565ee905 Move skip to STLExtras.h
It has nothing to do with IR.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 56536ba231 STLExtras.h: introduce IsTupleLike concept
One day we'll need to make it report error messages in a more effective
way.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 4f29a70df8 UpcastablePointer.h: pointee: skip over const 2022-01-27 11:51:03 +01:00
Alessandro Di Federico 97db1d5f50 Make TypePaths comparable 2022-01-27 11:51:03 +01:00
Alessandro Di Federico 3799f1e973 Whitespace and other minor changes 2022-01-25 21:27:05 +01:00
Filippo Cremonese 74217b4fe5 Generate C++ model from YAML definition
Model classes are now described by a YAML document, which is used to
generate C++ headers containing classes and all the boilerplate
required for YAML serialization/deserialization, usage in
SortedVectors, etc. See the README in include/revng/Model for more
info.
2022-01-13 14:34:11 +01:00
Filippo Cremonese a97efbaaf7 Add missing <map> include 2022-01-10 10:31:27 +01:00
Alessandro Di Federico cfb47157b9 clang-tidy: readability-identifier-naming
This commit fixes all the non-compliance with our preliminary clang-tidy
configuration, which will be merged soon.
2022-01-07 09:18:05 +01:00
Massimo Fioravanti ca4c7e2c09 Add dereferenceIterator and mapToValueIterator
A dereference iterator is used to map a pointer-like object to the
pointee, as an example given a `vector<unique_ptr<int>> Vector`, using
`dereferenceRange(Vector)` will present a range of `int &` rather than a
range of `unique_ptr<int> &`.

mapToValueIterator can be used  on a map range
to access the underlying object directly rather
than the pair<key, object>.
2022-01-05 14:45:01 +01:00
Pietro Fezzardi 2f524114e8 RecursiveCoroutine: add operator* for ergonomics
This allows e.g. the following programming pattern:

```
RecursiveCoroutine<std::optional<SomeType>> f();

int g() {
  return *f();
}
```

Without operator* defined for `RecursiveCoroutine` this would fail,
requiring an explicit cast such as:

```
int g() {
  return *static_cast<std::optional<SomeType>>(f());
}
```
2022-01-05 14:37:37 +01:00
Pietro Fezzardi 0e1402adfc Fix is_specialization<const X<T>, X>
Before this commit `is_specialization<const X<T>, X>` was not
specialized, so that `const X<T>` did not count as a specialization of
`X`. This resulted in bad selection of template specialization based on
concepts that were using `is_specialization_v`, such as
`IsUpcastablePointer`.

This commit fixes the problem, so that now the concept
`IsUpcastablePointer` is true for `const UpcastablePointer<T>` as well.

This also enabled to remove some workarounds for the `IsMutableSet` and
`IsSortedVector` concepts, and treat them uniformly with other concepts
that were using `is_specialization_v`.
2022-01-05 13:33:52 +01:00
Pietro Fezzardi 69715dafed TupleTreePath: add empty() method 2022-01-05 13:33:52 +01:00
Alessandro Di Federico 4d7a175996 Extract TupleTree 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 455bf10648 Specialize KeyedObjectTraits for std::string 2021-12-22 13:47:21 +01:00
Antonio Frighetto b80be110ae ZipMapIterator: add support for llvm::DenseMap 2021-12-15 18:03:30 +01:00
Alvise de Faveri 2e19fade43 Fix memory leak in TupleTreeKeyWrapper::clone
ConcreteTupleTreeKeyWrapper::clone() should cleanup the Target object
befor cloning, otherwise the destructor of the inner Pointer object
is never called.
2021-10-27 08:42:53 +02:00
Alessandro Di Federico d5bfb872d6 Introduce SortedVector::isSorted
This is a debug method.
2021-10-18 20:44:58 +02:00
Ivan Krysak 6714c4cb58 Add Node::copy() and Node::move()
Those member functions are an easy way to reach the underlying node data
without affecting the edges stored by the node.
2021-10-04 14:38:42 +02:00
Ivan Krysak 612461cffa Enable more explicit edge iteration
Add reverse iterator support
2021-09-02 11:09:29 +03:00
Ivan Krysak 509ee3c41a Disallow label-less mutable edge graphs 2021-09-02 11:09:17 +03:00
Ivan Krysak 95e983fef3 Rename has_parent into HasParent 2021-09-02 11:09:04 +03:00
Ivan Krysak b6d95c2cbc Add GenericGraph::clear 2021-09-02 11:08:52 +03:00
Ivan Krysak 3f1f99deff Add GenericGraph::reserve 2021-09-02 11:08:39 +03:00
Ivan Krysak 9a902cc8ab Implement in-place node creation 2021-09-02 11:08:27 +03:00
Ivan Krysak 009a5ae060 Rework EdgeView to improve code consistency 2021-09-02 11:08:14 +03:00
Ivan Krysak 7d24eeaf48 Add a move-only addNode overload 2021-09-02 11:08:01 +03:00
Ivan Krysak 4df418fcbc Add a EdgeLabel alias 2021-09-02 11:07:49 +03:00
Ivan Krysak 334cdf9f05 Make iterators and mapping filters consistent 2021-09-02 11:07:39 +03:00
Ivan Krysak 027be0b030 Implement renvg::mapped_iterator
It's a specialization of `llvm::mapped_iterator` with better
support for temporary objects (`operator->` doesn't cause UB)
2021-09-02 11:05:22 +03:00
Ivan Krysak e5be45ab3b Add explicit names for iterator types 2021-09-02 11:05:10 +03:00
Ivan Krysak 8535f166a9 Prevent multiple edges between a pair of nodes 2021-09-02 11:04:59 +03:00
Ivan Krysak f15e41433f Make graph testing node type agnostic 2021-09-02 11:04:44 +03:00
Ivan Krysak c8a60f9d8e Implement safe node removal 2021-09-02 09:14:20 +03:00
Ivan Krysak 5b60c22feb Implement the core of the mutable edge node 2021-09-02 09:14:20 +03:00