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
+9 -6
View File
@@ -2,6 +2,7 @@
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "clang/AST/Decl.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/TextDiagnostic.h"
@@ -606,8 +607,8 @@ bool DeclVisitor::VisitFunctionDecl(const clang::FunctionDecl *FD) {
return false;
}
auto Location = model::Register::fromCSVName(*Register,
Model->Architecture());
auto Location = model::Register::fromRegisterName(*Register,
Model->Architecture());
if (Location == model::Register::Invalid) {
Errors.emplace_back("import-from-c: While parsing the return value:\n");
Errors.emplace_back("import-from-c failed: Unknown register: `"
@@ -682,9 +683,10 @@ bool DeclVisitor::VisitFunctionDecl(const clang::FunctionDecl *FD) {
return false;
}
auto Location = model::Register::fromCSVName(*Register,
Model->Architecture());
if (Location == model::Register::Invalid) {
using namespace model;
auto Location = Register::fromRegisterName(*Register,
Model->Architecture());
if (Location == Register::Invalid) {
Errors.emplace_back("import-from-c: While parsing argument #"
+ std::to_string(I) + ":\n");
Errors.emplace_back("import-from-c failed: Unknown register: `"
@@ -906,7 +908,8 @@ bool DeclVisitor::handleStructType(const clang::RecordDecl *RD) {
return false;
}
Location = model::Register::fromCSVName(*Register, Model->Architecture());
Location = model::Register::fromRegisterName(*Register,
Model->Architecture());
if (Location == model::Register::Invalid) {
Errors.emplace_back("import-from-c: While parsing return value #"
+ std::to_string(Struct->Fields().size()) + ":\n");