Files
Giacomo Vercesi 798af62b87 Introduce helpers declarations
Re-organize the variants of `libtcg-helpers-*.bc` as such:
* `libtcg-helpers-full-$ARCH.bc`: unchanged, contains all helper
  function with their bodies and all CSVs.
* `libtcg-helpers-declarations-only-$ARCH.bc`: all helper
  functions have been turned to declarations. All CSVs (except a couple
  of special ones) have been dropped.
* `libtcg-helpers-to-inline-$ARCH.bc`: only functions with the
  `revng_inline` section retain their body. Only CSVs that are used by
  these functions are present.

Lift now loads only the `declarations-only` variant of helpers, as
their body is not required until `inline-helpers`. In `inline-helpers`
the `to-inline` variant is loaded and linked, which then allows the
helpers to be inlined.
2026-02-05 10:20:45 +01:00

39 lines
985 B
C

#pragma once
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "llvm/IR/Module.h"
#include "revng/Model/FunctionTags.h"
inline bool isSpecialGV(llvm::GlobalVariable &GV) {
llvm::StringRef Name = GV.getName();
return Name == "cpu_loop_exiting" or Name == "arch_cpu_type_beacon";
}
inline bool isHelper(llvm::Function &F) {
return F.getName().starts_with("helper_");
}
inline void tagQEMUGlobalsAndFunctions(llvm::Module &Module) {
// Tag all global objects in HelpersModule as QEMU
for (llvm::GlobalVariable &G : Module.globals())
FunctionTags::QEMU.addTo(&G);
for (llvm::Function &F : Module.functions()) {
if (F.isIntrinsic())
continue;
FunctionTags::QEMU.addTo(&F);
if (F.hasFnAttribute(llvm::Attribute::NoReturn)
or F.getSection() == "revng_exceptional")
FunctionTags::Exceptional.addTo(&F);
if (F.getName().starts_with("helper_"))
FunctionTags::Helper.addTo(&F);
}
}