65 Commits

Author SHA1 Message Date
Giacomo Vercesi 27f419c8cd Fix and ban namespace clobbering
Fix an instance where the `std` namespace got clobbered into the global
namespace by accident.
2026-02-16 10:34:38 +01:00
Alessandro Di Federico 5820908675 Remove and ban \file 2025-12-16 17:41:55 +01:00
Giacomo Vercesi a834f874c9 Add ProcessAssembly to pypeline 2025-11-18 17:47:54 +01:00
Alessandro Di Federico c883bed765 Drop Logger's StaticEnabled feature 2025-10-31 17:25:03 +01:00
Alessandro Di Federico 1429b526ab Introduce libtcg
This commit drops libptc in favor of its new form libtcg.

It brings several improvements, among which:

* The QEMU version we work on has been upgraded.
* CPUStateAccessAnalysis has been reimplemented in a way that makes it
  easier to debug and solves some limitations (e.g., tracking leaking
  pointers).
* Identification of pieces of the CPU state that are read by each helper
  and fixing access to the CPU state is now performed at build-time.
* We no longer mmap the code we need to translate, dropping all the
  issues related to code that needed to be mapped where something is
  already present.
* We now have two distinct flavors of helper modules: the full one and
  the "slim" one. The latter contains the definition only of functions
  we intend to inline. It is used in most of the pipeline, a good thing
  since we spend less time optimizing code we don't really care about.
  The full module is only used on the re-compilation branch of the
  pipeline.
* We no longer split the `cpu_loop` function.
* We change MetaAddress to rely on architectures from `model::` as
  opposed to the LLVM ones.
* We no longer attach debug info to LLVM IR containing the original
  assembly.
* We now verify that the lifted code only contains code we expect.
2025-10-31 17:25:03 +01:00
Alessandro Di Federico 5b4439f93c DisassemblyHelper: relax rules on delay slots 2025-10-24 18:22:01 +02:00
Alessandro Di Federico 4fb6b5f4e1 Minor changes 2025-10-24 18:20:48 +02:00
Ivan Krysak 6b32faaeb9 Yield: drop obsolete default value handling 2025-10-13 18:33:10 +03:00
Ivan Krysak 97aa3c8247 std::string: use implicit default constructor 2025-07-23 11:38:53 +02:00
Ivan Krysak fa2f243f12 PTML: avoid auto in constexpr string literals 2025-05-08 15:42:00 +02:00
Khaled Ismaeel 9d80594ddc Bump model version to v3 2025-04-30 15:08:45 +02:00
Ivan Krysak 79964eac74 Avoid ' misuse in error messages and comments 2025-04-17 16:41:21 +02:00
Ivan Krysak c6e38cd485 Return to using constant name builders
Because of how name builders used to lazy gather namespaces on the first
requested name, the objects were self mutating. As such only non-const
references could be used to pass them around.

Since that is no longer the case, this restores most of lost const
qualifiers.
2025-04-17 11:19:17 +03:00
Ivan Krysak 57b5eb7f98 NameBuilder: allow different name checkers 2025-04-17 11:19:17 +03:00
Ivan Krysak 645cf7fc2e NameBuilder: sunset deduplication
This reworks NameBuilder to ease the transition to the system where
the model will be guaranteed to never contain any name collisions, both
between user-specified names and the automatic ones.
2025-04-15 16:35:42 +03:00
Ivan Krysak 705e4a5955 auto [...] -> auto &&[...] 2025-02-13 13:10:51 +02:00
Ivan Krysak a67ba96644 Adopt name builder across the model users 2024-11-06 15:43:13 +02:00
Alessandro Di Federico f9fad18cb4 EFA, Yield: handle blockless functions 2024-10-31 17:19:51 +01:00
Ivan Krysak 43f0304cb2 Pipeline: toString -> locationString 2024-10-15 09:12:55 +02:00
Ivan Krysak ec19b26ee9 PTMLBuilder: rename into ptml::MarkupBuilder 2024-10-15 09:12:55 +02:00
Alessandro Di Federico 2cdedc71f4 s/serialize/toString/
We keep serialize for method dealing with streams.
If it returns a `std::string`, let's use `toString`.
2024-09-27 12:07:17 +02:00
Alessandro Di Federico b62bc8df91 s/FunctionMetadata/ControlFlowGraph/g 2024-06-20 10:24:51 +02:00
Alessandro Di Federico 276a6e0efb s|ControlFlowGraph.h|CFGHelpers.h|g 2024-06-20 10:24:51 +02:00
Alessandro Di Federico 6e49fed965 FunctionMetadata::{ControlFlowGraph,Blocks} 2024-06-20 10:24:51 +02:00
Ivan Krysak 44e5328477 Yield: add explicit directive support 2024-03-18 11:40:32 +00:00
Ivan Krysak 77fb7e6e5b Yield: introduce BasicBlockPrefix option 2024-03-18 10:58:55 +00:00
Ivan Krysak e5328290c6 Yield: reorder disassembly processing
This commit moves stuff around to enforce complete information being
present by the time the "Internal" assembly output is ready.

Because of that, the "Internal" format needed to change, now it uses
tag representation close to PTML as opposed to the one close to LLVM's
used before now.
2024-03-18 10:58:52 +00:00
Ivan Krysak 67c4a65122 Minor improvements 2024-03-18 11:58:11 +01:00
Ivan Krysak 2bffccaaf6 Move ImmediateStyle configuration to the model 2024-03-18 11:58:11 +01:00
Ivan Krysak 2827c9d7f7 Move UseATTSyntax configuration to the model 2024-03-18 11:58:11 +01:00
Ivan Krysak d781f3ae79 Yield: make disassembler config-aware 2024-03-18 07:20:41 +00:00
Ivan Krysak 7d235f4fd0 Enforce licence header consistency
Also do some basic cleanup: capitalize first letters, add `.`
at the end of the sentences, and so on.
2023-07-03 15:23:10 +00: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
Ivan Krysak 66fc161f73 Assembly: choose disassembler based on basic block
Before now, it was choosen based on the function, but that led to
problems when disassembling thumb functions calling non-thumb PLTs.
2023-05-25 09:49:13 +02:00
Ivan Krysak c21f2649c9 Assembly: introduce new tags
This also reorders the enum, because when two tags collide (they have
the same `from` and `to` points, they are sorted based on the enum
values.

The new order ensures that the values we are more likely to choose
to preserve are closer to the bottom. Since each token can only have one
type associated with it, we choose the lowest one by default.
2023-05-25 06:36:02 +00:00
Ivan Krysak 560bf16d1f Disassembler: support arbitrarily sized tags 2023-05-25 06:25:07 +00:00
Ivan Krysak 4699c2da72 Assembly: remove ShouldSymbolizeOperands option 2023-05-25 06:25:07 +00:00
Ivan Krysak f9a72125d3 Aseembly: accept relative jump targets
Drops the comment about an attempt to switch to the absolute targets
and sets `setPrintBranchImmAsAddress` to `false` no matter what
immediate style is selected.
2023-05-25 06:25:07 +00:00
Ivan Krysak 83e48bbc3a LLVMDisassemblerInterface: remove unused argument 2023-05-25 06:25:07 +00:00
Ivan Krysak 5b2af637de Minor Changes 2023-05-25 06:25:07 +00:00
Alessandro Di Federico 348ccec09b Adopt new llvm::MCContext constructor 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 171ba353e5 Adopt llvm/{Support,MC}/TargetRegistry.h 2023-04-08 08:42:24 +02:00
Alessandro Di Federico dbcdad0a4d Switch from llvm::Optional to std::optional 2023-04-08 08:42:24 +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
Giacomo Vercesi 0e9431737f YieldAssembly: fix jump addresses
Change the way the jump instructions are outputted in the assembly
output to be PC-relative. This fixes an issue where the addresses in the
output where shifted forward.
2023-02-07 16:54:35 +01:00
Massimo Fioravanti 742e1a0c56 TupleTree: switch from public fields to accessors 2022-12-12 18:36:57 +01:00
Alessandro Di Federico 974dd0c680 yield::Function: do not use efa::BasicBlock
This change introduces some duplication but ensures an important
property of `tuple_tree_generate`d: data structures: all the leaves are
scalars. Previously, yield::Function was using efa::BasicBlock, making
things more difficult under certain conditions.
Specifically, we can rely on the fact that, when generating a visit to
the TupleTree, we know everything about all non-scalars.
2022-12-09 10:11:27 +01:00
Alessandro Di Federico e9db913291 Disassembler: fix iterator invalidation issue
The index of an element of a `SortedVector<yield::Tag>` was saved, but
`SortedVector` behaves like a set.
The issue has been fixed by creating a temporary `Tag` instead of trying
to keep a reference to an existing one.
2022-12-09 09:00:20 +01:00
Ivan Krysak 5190f8f6c8 Yield: move PTML out of assembly namespace
This fixes an old issue: the headers were moved out out of assembly
a while back while cpp files had been forgotten.
2022-09-26 12:11:20 +02:00