retdec
variables_manager.h
Go to the documentation of this file.
1 
8 #ifndef RETDEC_LLVMIR2HLL_LLVM_LLVMIR2BIR_CONVERTER_VARIABLES_MANAGER_H
9 #define RETDEC_LLVMIR2HLL_LLVM_LLVMIR2BIR_CONVERTER_VARIABLES_MANAGER_H
10 
11 #include <unordered_map>
12 
17 
18 namespace llvm {
19 
20 class Value;
21 
22 } // namespace llvm
23 
24 namespace retdec {
25 namespace llvmir2hll {
26 
27 class Module;
28 class Type;
29 class Variable;
30 
36 public:
38 
39  void reset();
40 
41  void addGlobalValVarPair(llvm::Value *val, ShPtr<Variable> var);
42  ShPtr<Variable> getVarByValue(llvm::Value *val);
43  VarSet getLocalVars() const;
44 
45 private:
46  void assignNameToValue(llvm::Value *val) const;
47  ShPtr<Variable> getGlobalVar(llvm::Value *val);
48  ShPtr<Variable> getOrCreateLocalVar(llvm::Value *val);
49 
51  std::unordered_map<llvm::Value*, ShPtr<Variable>> localVarsMap;
52 
54  std::unordered_map<llvm::Value*, ShPtr<Variable>> globalVarsMap;
55 
58 
61 };
62 
63 } // namespace llvmir2hll
64 } // namespace retdec
65 
66 #endif
Managing of local variables created during conversion of LLVM functions to BIR.
Definition: variables_manager.h:35
void assignNameToValue(llvm::Value *val) const
Assigns new name from generator to LLVM value.
Definition: variables_manager.cpp:67
UPtr< VarNameGen > varNameGen
Variable names generator.
Definition: variables_manager.h:57
ShPtr< Variable > getGlobalVar(llvm::Value *val)
Definition: variables_manager.cpp:73
void addGlobalValVarPair(llvm::Value *val, ShPtr< Variable > var)
Definition: variables_manager.cpp:42
std::unordered_map< llvm::Value *, ShPtr< Variable > > globalVarsMap
Mapping of LLVM functions and globals to existing variables.
Definition: variables_manager.h:54
ShPtr< Module > resModule
The resulting module in BIR.
Definition: variables_manager.h:60
VariablesManager(ShPtr< Module > resModule)
Constructs a new variables manager.
Definition: variables_manager.cpp:29
std::unordered_map< llvm::Value *, ShPtr< Variable > > localVarsMap
Mapping of a LLVM value to an existing variable.
Definition: variables_manager.h:51
VarSet getLocalVars() const
Returns set of all local variables.
Definition: variables_manager.cpp:103
void reset()
Resets local variables in the variables manager.
Definition: variables_manager.cpp:37
ShPtr< Variable > getVarByValue(llvm::Value *val)
Returns the variable representing LLVM value val.
Definition: variables_manager.cpp:52
ShPtr< Variable > getOrCreateLocalVar(llvm::Value *val)
Returns the local variable for val.
Definition: variables_manager.cpp:84
A mixin to make classes non-copyable.
Definition: non_copyable.h:27
Definition: itanium_ast_ctypes_parser.h:12
A library providing API for working with back-end IR.
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
std::unique_ptr< T > UPtr
An alias for a unique pointer.
Definition: smart_ptr.h:26
std::set< ShPtr< Variable > > VarSet
Set of variables.
Definition: types.h:57
Definition: archive_wrapper.h:19
A mixin to make classes non-copyable.
Declarations, aliases, macros, etc. for the use of smart pointers.
Aliases for several useful types.
A base class for all generators of variable names.