mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
ee0b8f44c1
This is a big step to split revng-lift in two parts: one that only writes the model and one that actually lifts to LLVM IR. * Introduce `revng import binary` * Split off `BinaryFile.h` * Drop `revng.h` * `GeneratedCodeBasicInfo`: use model * Reduce role of `GeneratedCodeBasicInfo` in favor of `model::Architecture` and `model::Register` methods * `CodeGenerator`: adopt `RawBinaryView` and model * `JumpTargetManager`: adopt `RawBinaryView` and model * `ExternalJumpsHandler`: adopt model * `InstructionTranslator`: discard `Architecture` in favor of `EndianessMismatch` * Many other changes
52 lines
1.6 KiB
C++
52 lines
1.6 KiB
C++
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
#include "llvm/ADT/GraphTraits.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/ADT/iterator_range.h"
|
|
#include "llvm/IR/BasicBlock.h"
|
|
#include "llvm/IR/Function.h"
|
|
#include "llvm/IR/GlobalVariable.h"
|
|
#include "llvm/IR/Instruction.h"
|
|
#include "llvm/IR/Instructions.h"
|
|
#include "llvm/Support/Casting.h"
|
|
|
|
#include "revng/MFP/MFP.h"
|
|
|
|
#include "Analyses.h"
|
|
|
|
namespace ABIAnalyses::UsedArgumentsOfFunction {
|
|
using namespace llvm;
|
|
using namespace ABIAnalyses;
|
|
|
|
std::map<const GlobalVariable *, State>
|
|
analyze(const BasicBlock *FunctionEntry, const GeneratedCodeBasicInfo &GCBI) {
|
|
using MFI = MFIAnalysis<true, CoreLattice>;
|
|
MFI Instance{ { GCBI } };
|
|
MFI::LatticeElement InitialValue;
|
|
MFI::LatticeElement ExtremalValue(CoreLattice::ExtremalLatticeElement);
|
|
|
|
auto
|
|
Res = MFP::getMaximalFixedPoint<MFI, MFI::GT, MFI::LGT>(Instance,
|
|
FunctionEntry,
|
|
InitialValue,
|
|
ExtremalValue,
|
|
{ FunctionEntry },
|
|
{ FunctionEntry });
|
|
|
|
std::map<const GlobalVariable *, State> RegYes{};
|
|
|
|
for (auto &[BB, Result] : Res) {
|
|
for (auto &[GV, RegState] : Result.OutValue) {
|
|
if (RegState == CoreLattice::Yes) {
|
|
RegYes[GV] = State::Yes;
|
|
}
|
|
}
|
|
}
|
|
|
|
return RegYes;
|
|
}
|
|
} // namespace ABIAnalyses::UsedArgumentsOfFunction
|