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.
This commit is contained in:
Alessandro Di Federico
2025-10-24 15:56:15 +02:00
parent 8f21f3b5e1
commit b1feb5b989
94 changed files with 7135 additions and 6110 deletions
@@ -32,15 +32,16 @@ static void ensureDisassemblersWereInitializedOnce() {
using DI = LLVMDisassemblerInterface;
DI::LLVMDisassemblerInterface(MetaAddressType::Values AddrType,
const model::DisassemblyConfiguration &Config) {
using namespace model::Architecture;
ensureDisassemblersWereInitializedOnce();
auto LLVMArchitecture = MetaAddressType::arch(AddrType);
revng_assert(LLVMArchitecture.has_value(),
auto LLVMArchitecture = toLLVMArchitecture(MetaAddressType::arch(AddrType));
revng_assert(MetaAddressType::arch(AddrType) != Invalid,
"Impossible to create a disassembler for a non-code section");
auto Architecture = llvm::Triple::getArchTypeName(*LLVMArchitecture);
auto Architecture = llvm::Triple::getArchTypeName(LLVMArchitecture);
// Workaround for ARM
if (*LLVMArchitecture == llvm::Triple::ArchType::arm)
if (LLVMArchitecture == llvm::Triple::ArchType::arm)
Architecture = "armv7";
std::string ErrorMessage;
@@ -84,8 +85,8 @@ DI::LLVMDisassemblerInterface(MetaAddressType::Values AddrType,
InstructionInformation.reset(LLVMTarget->createMCInstrInfo());
unsigned AssemblyDialect = 0;
if (*LLVMArchitecture == llvm::Triple::ArchType::x86
|| *LLVMArchitecture == llvm::Triple::ArchType::x86_64) {
if (LLVMArchitecture == llvm::Triple::ArchType::x86
or LLVMArchitecture == llvm::Triple::ArchType::x86_64) {
if (not Config.UseX86ATTSyntax())
AssemblyDialect = 1;
}