retdec
lti.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_BIN2LLVMIR_PROVIDERS_LTI_H
8 #define RETDEC_BIN2LLVMIR_PROVIDERS_LTI_H
9 
10 #include <llvm/IR/Module.h>
11 
16 
17 namespace retdec {
18 namespace bin2llvmir {
19 
20 class Lti
21 {
22  public:
23  using FunctionPair = std::pair<
24  llvm::Function*,
25  std::shared_ptr<retdec::ctypes::Function>>;
26 
27  public:
28  Lti(
29  llvm::Module* m,
30  Config* c,
31  const std::shared_ptr<ctypesparser::TypeConfig>& typeConfig,
32  retdec::loader::Image* objf);
33 
34  bool hasLtiFunction(const std::string& name);
35  std::shared_ptr<retdec::ctypes::Function> getLtiFunction(
36  const std::string& name);
37  llvm::FunctionType* getLlvmFunctionType(const std::string& name);
38  FunctionPair getPairFunctionFree(const std::string& name);
39  llvm::Function* getLlvmFunctionFree(const std::string& name);
40  FunctionPair getPairFunction(const std::string& name);
41  llvm::Function* getLlvmFunction(const std::string& name);
42 
43  private:
44  void loadLtiFile(const std::string& filePath);
45  llvm::Type* getLlvmType(std::shared_ptr<retdec::ctypes::Type> type);
46 
47  private:
48  llvm::Module* _module = nullptr;
49  Config* _config = nullptr;
50  std::shared_ptr<ctypesparser::TypeConfig> _typeConfig;
52  std::unique_ptr<retdec::ctypes::Module> _ltiModule;
54 };
55 
57 {
58  public:
59  static Lti* addLti(
60  llvm::Module* m,
61  Config* c,
62  const std::shared_ptr<ctypesparser::TypeConfig>& typeConfig,
63  retdec::loader::Image* objf);
64  static Lti* getLti(llvm::Module* m);
65  static bool getLti(llvm::Module* m, Lti*& lti);
66  static void clear();
67 
68  private:
69  static std::map<llvm::Module*, Lti> _module2lti;
70 };
71 
72 } // namespace bin2llvmir
73 } // namespace retdec
74 
75 #endif
Config DB provider for bin2llvmirl.
Definition: config.h:24
static Lti * getLti(llvm::Module *m)
Definition: lti.cpp:254
static Lti * addLti(llvm::Module *m, Config *c, const std::shared_ptr< ctypesparser::TypeConfig > &typeConfig, retdec::loader::Image *objf)
Definition: lti.cpp:239
static std::map< llvm::Module *, Lti > _module2lti
Definition: lti.h:69
static void clear()
Definition: lti.cpp:266
Definition: lti.h:21
llvm::Function * getLlvmFunctionFree(const std::string &name)
Definition: lti.cpp:188
std::pair< llvm::Function *, std::shared_ptr< retdec::ctypes::Function > > FunctionPair
Definition: lti.h:25
llvm::FunctionType * getLlvmFunctionType(const std::string &name)
Definition: lti.cpp:124
ctypesparser::JSONCTypesParser _ltiParser
Definition: lti.h:53
FunctionPair getPairFunction(const std::string &name)
Definition: lti.cpp:193
retdec::loader::Image * _image
Definition: lti.h:51
llvm::Module * _module
Definition: lti.h:48
void loadLtiFile(const std::string &filePath)
Definition: lti.cpp:94
llvm::Type * getLlvmType(std::shared_ptr< retdec::ctypes::Type > type)
Definition: lti.cpp:224
std::shared_ptr< ctypesparser::TypeConfig > _typeConfig
Definition: lti.h:50
FunctionPair getPairFunctionFree(const std::string &name)
Definition: lti.cpp:145
llvm::Function * getLlvmFunction(const std::string &name)
Definition: lti.cpp:219
bool hasLtiFunction(const std::string &name)
Definition: lti.cpp:108
std::unique_ptr< retdec::ctypes::Module > _ltiModule
Definition: lti.h:52
std::shared_ptr< retdec::ctypes::Function > getLtiFunction(const std::string &name)
Definition: lti.cpp:113
Lti(llvm::Module *m, Config *c, const std::shared_ptr< ctypesparser::TypeConfig > &typeConfig, retdec::loader::Image *objf)
Definition: lti.cpp:34
Config * _config
Definition: lti.h:49
Parser for C-types represented in JSON.
Definition: json_ctypes_parser.h:25
Definition: image.h:22
File image provider for bin2llvmirl.
Parser for C-types from JSON files.
The frontend-end part of the decompiler.
Definition: archive_wrapper.h:19
Defines type widths and singnedness for types that are implementation specific.