Commit Graph

6113 Commits

Author SHA1 Message Date
Pietro Fezzardi f7eed33dac DLA Backend: only emit valid model::PrimitiveTypes
Before this commit, DLA didn't do any checks on the validity of the
model::PrimitiveTypes that it generated.
This could cause invalid PrimitiveTypes to be generated, with weird
sizes not supported by the Model.
This commit fixes this problem, generating empty model::StructTypes with
the proper sizes instead.
2024-02-04 16:07:31 +01:00
Pietro Fezzardi 11be91caaf DLA: drop unused Logger 2024-02-04 16:07:30 +01:00
Pietro Fezzardi f367eafad2 DLA: store node neighbours in increasing ID order 2024-02-04 16:07:30 +01:00
Pietro Fezzardi d07e661ab5 DLA: rework initialization of string literals
Before this commit, DLA's frontend was representing information about
string literals in a way that had a bad outcome: very often, all (or
most) places in the binary that were using string literals ended up
collapsed on the DLA graph on the same node, causing all their types to
be a weird struct.

This was wrong, and it was the result of an aggressive creation of
equality edges.

This commit avoids to emit equality edges, and replaces them with
instance edges, that represent the fact that a call to StringLiteral
actually returns a type that represents a pointer to char.
2024-02-04 15:21:27 +01:00
Alessandro Di Federico 664d86f642 Merge branch 'feature/alignment-fixes' 2024-02-01 11:40:09 +01:00
Ivan Krysak be385fdfe8 model-to-header: avoid raw primitive arguments
After updating the function type conversion to be extra strict about
type alignment, the model-to-header tests for all these primitive
types no longer pass: it's no longer valid for a CFT to use any
primitives ABI is not aware of as part of the prototype.

As a simple workaround, this commit replaces all the primitives
used by said prototypes with pointers.
2024-02-01 11:38:57 +01:00
Ivan Krysak a331dcc878 ToCFT: improve naming 2024-01-29 11:57:54 +02:00
Ivan Krysak 82c2162d7d ABI: add an explicit void distribution helper 2024-01-29 11:57:54 +02:00
Ivan Krysak 78510010f8 ABI: rename isIncompatibleWith
The new name is `isPreliminarilyCompatibleWith`.
2024-01-29 11:57:54 +02:00
Ivan Krysak e7c456afd2 ABI: improve register state deduction docs 2024-01-29 11:57:54 +02:00
Ivan Krysak 81d365a24b ABI: assert on broken alignment calculation result 2024-01-29 11:57:54 +02:00
Ivan Krysak 4cb38a722c ABI: disallow ABI flags to be optional 2024-01-29 11:57:54 +02:00
Ivan Krysak 79d68dcafc ABI: allow reusing the stack struct
When there's a single struct argument (as in, all we see is a nested
struct) and all the sizes match, just use the inner struct instead of
creating a new one.
2024-01-29 11:57:54 +02:00
Ivan Krysak d0b3777db4 ToCFT: use structs as a fallback
When a stack argument cannot be converted "as is",
use a struct instead to try and overcome the limitation.
2024-01-29 11:57:54 +02:00
Ivan Krysak 093cacdb6f ValueDistributor: enable working on model::Type 2024-01-29 11:57:54 +02:00
Ivan Krysak 35326b29ec ABI: streamline position-based argument handling 2024-01-29 11:57:54 +02:00
Ivan Krysak 4093cd30c4 ABI: provide alignment computation for model::Type 2024-01-29 11:57:54 +02:00
Ivan Krysak ce0ada6027 ToCFT: fix a invalid iterator access
Because of a mistake in the previous iteration, an invalid iteration was
dereferenced when a struct had non-zero size but no fields (padding only
struct).
2024-01-29 11:57:54 +02:00
Ivan Krysak 89b5cacc3b ToCFT: introduce more complete result verification 2024-01-29 11:57:54 +02:00
Ivan Krysak 39532658f9 ToCFT: improve alignment verification logger 2024-01-29 11:57:54 +02:00
Ivan Krysak 039efcfee8 ToCFT: use adjusted alignment for verification
Adjusted alignment means alignment when it's bigger than the pointer
size and pointer size otherwise.
2024-01-29 11:57:54 +02:00
Ivan Krysak 83bb28023c ToCFT: turn verifyAlignment into a free function 2024-01-29 11:57:54 +02:00
Ivan Krysak 7041d5ab4e ABI: expose argument distribution API
This allows external code to peek inside a layout and to tell how
a specific argument would be treated based on its type.
2024-01-29 11:57:54 +02:00
Ivan Krysak 11b1214896 ABI: avoid mentioning TrackingSortedVector
Use `decltype` to dynamically detect the type instead.
2024-01-29 11:57:54 +02:00
Ivan Krysak 386cb26f6d ABI: introduce a new ABI configuration option
It's called `AllowUnnaturallyAlignedTypesInRegisters` and explicitly
allows weirdly aligned structs in registers.
2024-01-29 11:57:54 +02:00
Ivan Krysak 16dc85cb0f ABI: improve unnatural alignment support 2024-01-29 11:57:54 +02:00
Ivan Krysak 54ffd723e6 ABI: decouple alignment from model::VerifyHelper 2024-01-29 11:57:54 +02:00
Ivan Krysak e97ce16240 ToRFT: rename DistributedArgument
The new name is `DistributedValue`, the change is warranted because it's
used for return values as well.
2024-01-29 11:57:54 +02:00
Ivan Krysak 75d0ba700c ToRFT: work on a single argument at a time 2024-01-29 11:57:54 +02:00
Ivan Krysak 7fae2e4522 STLExtras: introduce takeAsTuple
It's a useful shorthand for the cases where one only cares about
a constant number of top values in a range (i.e. first three elements of
a vector) and wants them as named variables. It can be used as:
`auto [First, Second, Third] = takeAsTuple<3>(MyVector)`.
2024-01-29 11:57:54 +02:00
Ivan Krysak 3068cd219e compile_time: add a tuple repeat overload
Based on the passed `Callable`, it either behaves as previously,
or returns a `std::tie`'d version of all the values returned by it.
2024-01-29 11:57:54 +02:00
Ivan Krysak 7f1d14e149 ToCFT: streamline logger output 2024-01-29 11:57:54 +02:00
Ivan Krysak a52243037b Model: add basic unit tests for TypeBucket 2024-01-29 11:57:54 +02:00
Ivan Krysak a2ef041cb2 Move TypeBucket to the model 2024-01-29 11:57:54 +02:00
Ivan Krysak 77b1acaf00 Prefer uint64_t to size_t wherever relevant 2024-01-29 11:57:54 +02:00
Ivan Krysak f67030214f STLExtras: add to_underlying 2024-01-29 11:57:54 +02:00
Ivan Krysak b25a32de2a Stop using std:: prefix for std::size_t 2024-01-29 11:57:54 +02:00
Ivan Krysak 15be26f9fa Minor Improvements 2024-01-29 11:57:54 +02:00
Alessandro Di Federico 81b3f5c5bd Merge branch 'feature/edit-types' 2024-01-26 19:14:06 +01:00
Alessandro Di Federico 32d7976469 Merge branch 'feature/edit-types' 2024-01-26 19:14:03 +01:00
Giacomo Vercesi 456817eaf8 HeaderToModel: fix CustomName being wrong
This commit fixes a couple of corner cases in HeaderToModel where the
`CustomName` was erroneously assigned even though the name was the
default one.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi 293c0c9e25 tupletree.ts: Reference.resolve is now nullable
Allow `Reference.resolve` to return undefined if the reference's path
does not exist on the target object.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi 7f8a83c34a ModelToHeader: add DisableTypeInlining option
When running ModelToHeader in HeaderToModel, all types need to be
defined in the header for clang to successfully parse the file. Add an
option to `ModelToHeaderOptions` that forces all types to be printed
regardless of stack or inlining rules.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi 92e90d554c PTML/Constants.h: add editType action 2024-01-26 19:13:58 +01:00
Giacomo Vercesi ed1ad5e040 Add type.h artifact
Add the required container and pipes to produce `type.h`, a type-wise
file that shows the definition of a Model type in plain C.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi fc4c91e333 Introduce PopulateTargetListContainer
This commit adds the `TargetListContainer` container that allows storing
a list of target for a fixed Kind. Moreover the
`PopulateTargetListContainer` pipe has been added that allows adding all
targets to a `TargetListContainer` from a `Kind` via the
`appendAllTargets` method.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi a09a4ab2bf Adapt switch to detail::GenericStringMap
This commit adapts the changes introduced in revng that generalize
`FunctionStringMap`.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi 11938e40da Introduce TypeStringMap
Building upon the previous commit, introduce `TypeStringMap` which is a
container for type-wise strings.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi 5f8143207d Generalize FunctionStringMap
Generalize `FunctionStringMap` into `detail::GenericStringMap`, which
supports any `Depth=1` rank. `FunctionStringMap` remains as an `using`
with `Rank = ranks::Function`.
2024-01-26 19:13:58 +01:00
Giacomo Vercesi d4532ab512 revng daemon: print debug log to stderr
When printing the current workdir, use stderr instead of stdout.
2024-01-26 19:13:58 +01:00