Commit Graph

44 Commits

Author SHA1 Message Date
Ivan Krysak 795a84dfe6 MetaAddressType: introduce a prefix consumer 2025-04-15 16:35:42 +03:00
Ivan Krysak 2e85653873 MetaAddressType: introduce Count 2025-04-15 16:35:42 +03:00
Ivan Krysak 169383daa8 MetaAddress: introduce toIdentifier() method
It's equivalent to the existing `toString()` except for the fact that
it uses an identifier-friendly separator (`_`).
2025-04-15 16:35:42 +03:00
Ivan Krysak 3edb6cbb9b Minor improvements 2025-04-15 16:35:42 +03:00
Ivan Krysak 66688134bf MetaAddress: rework hashing 2025-02-13 13:09:50 +02:00
Alessandro Di Federico 15d72e580d MetaAddress::address*: simply ignore Type 2024-08-05 17:41:41 +02:00
Ivan Krysak ac587cbb4f Model: rename Type into TypeDefinition 2024-06-27 11:05:48 +02:00
Alessandro Di Federico 9fce67eee9 Reduce IRBuilder usage in favor of IRBuilderBase 2024-06-20 10:24:50 +02:00
Ivan Krysak e2018fa1c3 MetaAddress: add partial serialization option 2024-03-18 11:58:11 +01:00
Ivan Krysak 86fdb19b9f MetaAddress: pull separator into the header 2024-03-18 11:58:11 +01:00
Ivan Krysak a150b49c70 Support: remove unused dumper 2024-03-18 07:20:41 +00:00
Ivan Krysak cfe28d8e56 Stop using std:: prefix for u?int\d+_t types 2023-11-02 17:10:03 +01:00
Ivan Krysak bc98e0079f Formatting: change PenaltyReturnTypeOnItsOwnLine
The new value is 21.
2023-07-02 13:20:49 +02:00
Ivan Krysak 01b4ec36c9 Formatting: set AllowShortEnumsOnASingleLine
The new value is `false`.
2023-07-02 13:15:08 +02:00
Alessandro Di Federico a65ccc3413 Introduce ValueMaterializer
`ValueMaterializer` is a rewrite of what was called `AdvancedValueInfo`
which follows the same principles.

The main benefits over the old version is:

* We materialize the data-flow graph and the CFG of the relevant part of
  root. This makes debugging significantly easier.
* We drop the old MonotoneFramework infrastructure in favor of
  getMaximalFixedPoint.
* We significantly reduce the amount of queries we make to
  AdvancedValueInfo.
2023-06-30 13:39:22 +02:00
Alessandro Di Federico 4edcb6dd49 MetaAddress::decomposeIntegerPC: accept APInt 2023-06-30 13:35:04 +02:00
Djordje Todorovic c9b2ffaf72 JumpTargetManager: improve data structures
This commit adopts `llvm::DenseSet`, `llvm::DenseMap` and
`std::unordered_set` where needed.
It also tweaks some `llvm::SmallVector` sizes.

It brings an additional ~3% improvement during lifting.
2023-04-27 19:22:03 +02:00
Alessandro Di Federico dbcdad0a4d Switch from llvm::Optional to std::optional 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 52521f8cac Adopt more standard library's features 2023-04-08 08:42:23 +02:00
Alessandro Di Federico f68b7866b3 Introduce BasicBlockID
This commit introduces `BasicBlockID` as the unique identifier for a
`efa::BasicBlock` into the CFG. A `BasicBlockID` is defined by a
`MetaAddress` plus an incremental integer. This enables us to have
multiple instances of the same block in a single function, which is
particularly useful when inlining multiple times the same function.

Apart from this, the commit also does the following:

* It drops representing `MetaAddress`es a `structs` in the IR. This created
  several issues related to ABI. We now represent them as strings.

* It defines more functions in `support.h`, instead of defining prototypes
  by hand in `CodeGenerator.cpp` and the like. Specifically, `unknownPC`
  and `raise_exception_helper`. We also introduce a C "constructor" for
  `PlainMetaAddress`.

* It significantly reduces the API of `GeneratedCodeBasicInfo`, which
  was supposed to be put on a diet since a long time.  Specifically,
  many jump target related methods have been moved to free functions in
  `IRHelpers.h`.  Also `GCBI::getSuccessors` has been pushed into its
  only user, `PruneRetSuccessors`, to prevent further usage of a
  deprecated API. In the future, it would be nice to drop it entirely.

* It introduces `efa::BasicBlock::InlinedFrom`.

* Introduce an enum to represent named argument indices for `newpc`.
  This enables us to more effectively manipulate its argument list.

* It improves the verification and error reporting for
  `efa::FunctionMetadata`.

* Update tests.

This commit is preliminary to another piece of work to improve the
generality of inlining beyond the simple "fake function" scenario, for
which the feature was originally conceived.
2023-02-23 14:51:10 +01:00
Ivan Krysak 53ae25bcde MetaAddress: improve constexpr-friendliness 2022-09-26 10:33:43 +02:00
Alessandro Di Federico c4ca2e5d14 Introduce MetaAddress::isIn 2022-08-08 13:54:41 +02:00
Ivan Krysak 65d1a016d4 Standardize concept naming across the codebase 2022-08-05 17:27:56 +03:00
Ivan Krysak 257bcb9b3c Make MetaAddress constexpr constructible 2022-06-14 12:40:11 +03:00
Ivan Krysak 42c1461b9f Add MetaAddressType::getLLVMCPUFeatures 2022-05-06 18:51:47 +02:00
Ivan Krysak 2a6a7943f4 Fix a couple of minor typos 2022-05-06 18:51:47 +02:00
Alessandro Di Federico 60cce26768 Support streaming llvm::Errors to Loggers 2022-03-08 15:04:34 +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
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
Alessandro Di Federico fd30d3de42 Import the model's type system
This commit introduces the type system of the model along with several
various other improvements to the model and its users.

* Introduce the type system.
* Introduce possibility to tag certain fields in the model as to be
  optional during YAML serialization.
* All the `Name` fields have been replaced in favor of `CustomName` plus
  a `name` method that will use `CustomName` if available, or an
  automatically generated name otherwise.
* Make TupleTreeReferences behavior more robust: now you either need to
  have a valid pointer to `Root` and a `Path` or be default constructed
  (`nullptr` for `Root` and an empty `Path`). Any other configuration is
  invalid.
* The type system introduces `RawFunctionType`: this superseds the
  previous way in which we were specifying arguments and return
  values. Users of such information have been updated accordingly.
2021-07-21 18:22:58 +02:00
Alessandro Di Federico 1db6e5db5b MetaAddress: handle invalid values in operator+= 2021-03-06 16:59:38 +01:00
Alessandro Di Federico f2c83d2f67 Introduce PlainMetaAddress
This commit extracts a plain `struct` from the `MetaAddress` class. This
enables us to use `MetaAddress` from C and therefore, runtime.

The definition of such `struct`, `PlainMetaAddress`, is in
`PlainMetaAddress.h`, which is included by `early-linked.c`.

A function to print the content of a `PlainMetaAddress` has also been
introduced.

Also, anticipating the linkage of `early-linked.c` triggered a
superflous assertion in `CPUStateAccessAnalysis`. This commit removes
it.
2021-02-19 09:39:49 +01:00
Alessandro Di Federico 7f86530e74 MetaAddress::verify: handle invalid types 2021-02-17 11:44:23 +01:00
Alessandro Di Federico e72bcf796f Simplify MetaAddress::operator== 2021-01-26 18:42:10 +01:00
Alessandro Di Federico 7a560adbfa MetaAddress: drop std::less specialization 2021-01-26 18:42:10 +01:00
Pietro Fezzardi 9869f057b9 Use #pragma once for header include guards 2020-11-13 14:12:18 +01:00
Pietro Fezzardi cd9bc34d9d Enforce new include conventions 2020-11-13 10:00:24 +01:00
Alessandro Di Federico 60fdcbc66a Whitespace changes 2020-10-01 17:40:17 +02:00
Alessandro Di Federico ae3c800109 Implement MetaAddress::{from,to}String 2020-09-02 18:21:07 +02:00
Alessandro Di Federico e62cbb5ceb Implement comparison operators for MetaAddress 2020-09-02 16:55:20 +02:00
Alessandro Di Federico b7660a06c3 [MetaAddress] Fix tie type
The tuple returned by the `tie` method used to have the type of the
`Type` field (`uint16_t`) for the `Address` field (`uint64_t`) and
viceversa.
2020-06-29 23:49:52 +02:00
Alain Carlucci be9bc6ce0a MetaAddress: remove header dependency from IRBuilder 2020-06-25 14:28:07 +02:00
Alessandro Di Federico d10178483d Introduce the new MetaAddress
Unlike the previous iteration of `MetaAddress`, which tried to stuff all
the parts of `MetaAddress` within the existing `PC` CSV, this
implementation adds a set of new CSVs (or marks some existing ones as) to
represent the four portions of the current PC's `MetaAddress`.

* Introduce `ProgramCounterHandler`: a class responsible to maintain the
  PC-related CSVs. This class is also used to manipulate the new
  dispatcher.
* `AdvancedValueInfo`: update for new MetaAddress.
* External jump handler: do not clobber registers.
  When introducing support for dynamic binaries, we didn't realize that
  in x86-64 we were clobbering `r11`. To avoid this, we have to jump to
  an address stored in memory. However, due to the new `MetaAddress`,
  obtaining a *jumpable* address from the PC-related CSVs might require
  some computations (and it does in ARM). Therefore, we introduce a new
  global variable, `jumpablepc`, whose only role is to contain the
  jumpable version of the program counter and then be the target of the
  memory-indirect jump instruction.
* Labels care only about absolute addresses.
* CSAA: mark call site, even if no accesses.
2020-06-02 10:57:02 +02:00
Alessandro Di Federico dc48188f37 Introduce MetaAddress
`MetaAddress` replaces all the `uint64_t` used to represent a virtual
address. Its main features are:

* It has a non-zero representation of invalid addresses.
* It supports tags to represent code that has different interpretations but
  resides at the same address in memory (namely ARM vs Thumb).
* Arithmetic operations cannot overflow.
* It supports epochs, a way we intend to employ to handle self-modifying code
  (i.e., different code at the same address at different times).
* It supports "address spaces", which enable handling architectures with
  multiple address spaces.
* It fits in two 64-bit registers.
2020-05-14 11:58:18 +02:00