Commit Graph

563 Commits

Author SHA1 Message Date
Ivan Krysak 20bb0a2b90 Fix some minor abi::FunctionType issues 2022-03-28 15:37:59 +02:00
Ivan Krysak 5108c3e50f Introduce ABI-based register sorting 2022-03-28 15:37:55 +02:00
Ivan Krysak fbc59747bc STLExtras.h: introduce append 2022-03-28 15:37:02 +02:00
Ivan Krysak a77f648775 Introduce std::ranges::{,sized_}range 2022-03-28 15:36:51 +02:00
Ivan Krysak 522b760a12 Fix a problem with SystemV_x86_64 abi::Trait 2022-03-28 15:34:42 +02:00
Ivan Krysak 326624f517 Fix TupleTreeCompatible linkage problem
Now all the generated `.cpp` include `Binary.h`. This ensures we don't
trigger the wrong concept due to forward declarations.

Also, this commit introduces a couple of `static_assert`s which should
enable us to early identification of similar problems.
2022-03-28 15:33:30 +02:00
Ivan Krysak c6370816f7 Drop the abi::revng namespace 2022-03-28 15:32:06 +02:00
Massimo Fioravanti ce4934f48d Introduce revng-link-for-translation
`revng-link-for-translation` provides a standalone tool needed to
perform the final linking stage of the recompilation.
2022-03-28 12:17:05 +02:00
Massimo Fioravanti f63eefba2c Move LinkForTranslationPipe to lib/Recompile 2022-03-28 12:17:05 +02:00
Massimo Fioravanti c05b5dbb28 Steps now represent the *end* of a step
A special "begin" step has been introduced.
2022-03-28 12:17:05 +02:00
Massimo Fioravanti b362d926ec pipeline: drop implicit rank 0 2022-03-28 12:17:05 +02:00
Massimo Fioravanti d617533563 PipelineC: remove redundant documentation 2022-03-28 12:17:05 +02:00
Massimo Fioravanti c1d97bf8b3 pipeline: make globals serializable 2022-03-28 12:17:05 +02:00
Massimo Fioravanti de665fe03b PipelineC: new API to check if a target is ready 2022-03-28 12:17:05 +02:00
Massimo Fioravanti b1dac5d17b ContainerBase: introduce serialization primitives 2022-03-28 12:17:05 +02:00
Massimo Fioravanti 58768aca42 YAML pipelines: rename pipe "Name" to pass "Type" 2022-03-28 12:17:05 +02:00
Massimo Fioravanti 7eeb9f50c0 pipeline --verbose: print list of commands
`revng pipeline --verbose` will now print a list of equivalent commands
for the current invocation.
2022-03-28 12:17:05 +02:00
Massimo Fioravanti 39e0f0ac96 TupleTreeDiff<Binary>: fix compile errors 2022-03-28 12:17:05 +02:00
Massimo Fioravanti 6bd7f4bced Implement FileContainer::remove 2022-03-28 12:17:05 +02:00
Massimo Fioravanti 7aa57ab3b0 LLVMContainer::mergeBack: fix linking failure
`linkInModule` returns true on error. So the condition for failure is
`link(final, module1) || link(final, module2)`, instead of `&&`.
2022-03-28 12:17:05 +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
Massimo Fioravanti 5bdce4bf36 LoadModelPass: support command-line path
It is now possible to load a model from file instead of the one written
in the module itself:

    revng opt --model-path=<path>
2022-03-28 12:17:05 +02:00
Massimo Fioravanti 602f1e0701 Introduce non-const PipelineManager::context 2022-03-28 12:17:05 +02:00
Alessandro Di Federico af1828e090 DwarfImporter: better support for 0-sized types
We now ignore field of `struct`/`union` that have a 0-sized type.
We now also ignore types containing a an array with 0-sized elements.
2022-03-28 12:17:05 +02:00
Alessandro Di Federico 67706f05b6 Introduce a never-failing Type::trySize 2022-03-28 12:17:05 +02:00
Alvise de Faveri 16b7c61940 Add writeToLog() for types that have dump() 2022-03-17 18:52:18 +01:00
Alvise de Faveri 45784cce8c YAMLTraits: Add serializeToString() 2022-03-17 18:34:09 +01:00
Giacomo Vercesi e237ee75b0 Add custom traceback support 2022-03-17 18:33:59 +01:00
Pietro Fezzardi fb54cc22a2 QualifiedType: new typedef-aware helper methods
This commit reworks the helper methods for model::QualifiedType, to
properly traverse typedefs.

These methods are used to check if a QualifiedType is:
- scalar
- primitive
- float
- void
- pointer
- array

This commit add the methods for checking pointers and arrays (that
weren't available before), reworks all the helpers so that they all
traverse typedefs, and adds comments so that it's clear that they
traverse typedefs.
2022-03-17 17:03:28 +01:00
Pietro Fezzardi 630fee4500 model::Qualifier: add static methods for filtering
This commit adds the static methods:
- model::Qualifier::isConst
- model::Qualifier::isArray
- model::Qualifier::isPointer

These methods replace the old, non-static, methods:
- model::Qualifier::isConst
- model::Qualifier::isArray
- model::Qualifier::isPointer

Having these method static is very helpful for filtering, when
iterating on sequences of qualifiers, such as:

  for (const auto &Q :
       llvm::make_filter_range(Qualifiers, Qualifier::isPointer)) {
    // do stuff with Q
  }

This will be very helpful for defining other helper functions for
model::QualifiedType.

This commit also drops the non-static version of the methods, since they
are redundant, and because they would cause ambiguity and failure of
type inference in the snippet above, making them effectively useless for
the goal they were designed for, which is filtering ranges.
2022-03-17 17:03:22 +01:00
Alessandro Di Federico 3cc138c8d6 Drop cloneMetadata
It was an hack to circumvent a bug in LLVM.
The following LLVM commit properly fixes the problem:

    [Cloning] Clone metadata on function declarations
2022-03-17 16:46:02 +01:00
Alessandro Di Federico 00ce580362 Introduce EnforceABI and PromoteCSV pipes 2022-03-17 14:10:50 +01:00
Alessandro Di Federico 9fb3b647a4 Introduce DropRootPass 2022-03-17 14:10:50 +01:00
Alessandro Di Federico fa3206b26d Rename Lifted tag to Isolated 2022-03-17 14:10:50 +01:00
Alessandro Di Federico ea6383c476 mv {d,registerD}efaultFunctionPrototype 2022-03-17 14:10:50 +01:00
Alessandro Di Federico da7701bd4e Move all executables except revng to libexec/revng
We used to collect all binaries into the `bin/` directory. However this
led to confusions since certain commands where available both as
`revng-command` and `revng command`.

This commit moves all the executables except `revng` into
`libexec/revng`, which, according to FHS, is dedicated to "internal
binaries that are not intended to be executed directly by users or shell
scripts".
2022-03-17 14:10:50 +01: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 60cce26768 Support streaming llvm::Errors to Loggers 2022-03-08 15:04:34 +01:00
Alessandro Di Federico 0a5d2c04a7 Rework LoadModelPass 2022-03-08 15:04:34 +01:00
Alessandro Di Federico 1a57229693 Introduce model::Binary::DefaultPrototype 2022-03-08 15:04:34 +01:00
Alessandro Di Federico b3bfd5c64d Introduce RawBinaryView 2022-03-08 15:04:34 +01:00
Alessandro Di Federico 1d1ae3f7d4 Add model::Binary::ExtraCodeAddresses 2022-03-08 15:04:34 +01:00
Alessandro Di Federico 7a35ef21be Extend model::Register
This is done in order to get rid of `BinaryFile`.
2022-03-08 15:04:29 +01:00
Alessandro Di Federico b65dc65037 Extend model::Architecture
This is done in order to get rid of `BinaryFile`.
2022-03-08 13:06:49 +01:00
Alessandro Di Federico a88a9e52c3 Improve model::Segment 2022-03-08 13:06:47 +01:00
Alessandro Di Federico 97f0941aee Introduce model::Section 2022-03-08 12:26:07 +01:00
Alessandro Di Federico 8570923d64 Introduce model::Relocation 2022-03-08 12:25:59 +01:00
Alessandro Di Federico 39ace7dc56 mv revng{DwarfImporter,ModelImporterDwarf} 2022-03-08 12:25:47 +01:00