retdec
Public Member Functions | Private Member Functions | Private Attributes | List of all members
retdec::llvmir2hll::VariablesManager Class Referencefinal

Managing of local variables created during conversion of LLVM functions to BIR. More...

#include <variables_manager.h>

Inheritance diagram for retdec::llvmir2hll::VariablesManager:
Inheritance graph
[legend]
Collaboration diagram for retdec::llvmir2hll::VariablesManager:
Collaboration graph
[legend]

Public Member Functions

 VariablesManager (ShPtr< Module > resModule)
 Constructs a new variables manager. More...
 
void reset ()
 Resets local variables in the variables manager. More...
 
void addGlobalValVarPair (llvm::Value *val, ShPtr< Variable > var)
 
ShPtr< VariablegetVarByValue (llvm::Value *val)
 Returns the variable representing LLVM value val. More...
 
VarSet getLocalVars () const
 Returns set of all local variables. More...
 

Private Member Functions

void assignNameToValue (llvm::Value *val) const
 Assigns new name from generator to LLVM value. More...
 
ShPtr< VariablegetGlobalVar (llvm::Value *val)
 
ShPtr< VariablegetOrCreateLocalVar (llvm::Value *val)
 Returns the local variable for val. More...
 
- Private Member Functions inherited from retdec::utils::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 

Private Attributes

std::unordered_map< llvm::Value *, ShPtr< Variable > > localVarsMap
 Mapping of a LLVM value to an existing variable. More...
 
std::unordered_map< llvm::Value *, ShPtr< Variable > > globalVarsMap
 Mapping of LLVM functions and globals to existing variables. More...
 
UPtr< VarNameGenvarNameGen
 Variable names generator. More...
 
ShPtr< ModuleresModule
 The resulting module in BIR. More...
 

Detailed Description

Managing of local variables created during conversion of LLVM functions to BIR.

Constructor & Destructor Documentation

◆ VariablesManager()

retdec::llvmir2hll::VariablesManager::VariablesManager ( ShPtr< Module resModule)

Constructs a new variables manager.

Member Function Documentation

◆ addGlobalValVarPair()

void retdec::llvmir2hll::VariablesManager::addGlobalValVarPair ( llvm::Value *  val,
ShPtr< Variable var 
)

◆ assignNameToValue()

void retdec::llvmir2hll::VariablesManager::assignNameToValue ( llvm::Value *  val) const
private

Assigns new name from generator to LLVM value.

◆ getGlobalVar()

ShPtr< Variable > retdec::llvmir2hll::VariablesManager::getGlobalVar ( llvm::Value *  val)
private

◆ getLocalVars()

VarSet retdec::llvmir2hll::VariablesManager::getLocalVars ( ) const

Returns set of all local variables.

◆ getOrCreateLocalVar()

ShPtr< Variable > retdec::llvmir2hll::VariablesManager::getOrCreateLocalVar ( llvm::Value *  val)
private

Returns the local variable for val.

If local variable doesn't exist, new one will be created. Type of new created variable is unknown.

◆ getVarByValue()

ShPtr< Variable > retdec::llvmir2hll::VariablesManager::getVarByValue ( llvm::Value *  val)

Returns the variable representing LLVM value val.

If variable doesn't have it's own name, a new one is generated and assigned to it. The reason is, that all variables in BIR have to be named.

◆ reset()

void retdec::llvmir2hll::VariablesManager::reset ( )

Resets local variables in the variables manager.

Also resets generator of new variable names.

Member Data Documentation

◆ globalVarsMap

std::unordered_map<llvm::Value*, ShPtr<Variable> > retdec::llvmir2hll::VariablesManager::globalVarsMap
private

Mapping of LLVM functions and globals to existing variables.

◆ localVarsMap

std::unordered_map<llvm::Value*, ShPtr<Variable> > retdec::llvmir2hll::VariablesManager::localVarsMap
private

Mapping of a LLVM value to an existing variable.

◆ resModule

ShPtr<Module> retdec::llvmir2hll::VariablesManager::resModule
private

The resulting module in BIR.

◆ varNameGen

UPtr<VarNameGen> retdec::llvmir2hll::VariablesManager::varNameGen
private

Variable names generator.


The documentation for this class was generated from the following files: