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

A converter from LLVM values to values in BIR. More...

#include <llvm_value_converter.h>

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

Public Member Functions

Value conversion
ShPtr< ExpressionconvertValueToDerefExpression (llvm::Value *value)
 Converts the given LLVM value value into a dereference expression in BIR. More...
 
ShPtr< ExpressionconvertValueToExpression (llvm::Value *value)
 Converts the given LLVM value value into an expression in BIR. More...
 
ShPtr< ExpressionconvertValueToExpressionDirectly (llvm::Value *value)
 Converts the given LLVM value value into an expression in BIR. More...
 
ShPtr< VariableconvertValueToVariable (llvm::Value *value)
 Converts the given LLVM value value into a variable in BIR. More...
 
Type conversion
ShPtr< TypeconvertType (const llvm::Type *type)
 Converts the given LLVM type type into a type in BIR. More...
 
Constant conversion
bool storesStringLiteral (const llvm::GlobalVariable &globVar) const
 Determines whether the given LLVM global variable globVar stores string literal. More...
 
ShPtr< ExpressionconvertConstantToExpression (llvm::Constant *constant)
 Converts the given LLVM constant constant into an expression in BIR. More...
 
Instruction conversion
ShPtr< ExpressionconvertInstructionToExpression (llvm::Instruction *inst)
 Converts the given LLVM instruction inst into an expression in BIR. More...
 
ShPtr< CallExprconvertCallInstToCallExpr (llvm::CallInst &inst)
 Converts the given LLVM call instruction inst into an expression in BIR. More...
 
ShPtr< ExpressiongenerateAccessToAggregateType (llvm::CompositeType *type, ShPtr< Expression > base, llvm::ArrayRef< unsigned > indices)
 Generates access to aggregate type as a part of conversion of LLVM instruction insertvalue or extractvalue. More...
 
Options
void setOptionStrictFPUSemantics (bool strict=true)
 Enables/disables the use of strict FPU semantics. More...
 

Static Public Member Functions

static ShPtr< LLVMValueConvertercreate (ShPtr< Module > resModule, ShPtr< VariablesManager > varManager)
 Creates a new converter. More...
 

Private Member Functions

 LLVMValueConverter (ShPtr< Module > resModule, ShPtr< VariablesManager > varManager)
 Constructs a new converter. More...
 
bool isConsideredAsPointer (const llvm::Value *value) const
 Determines whether the given LLVM value is considered as pointer variable. More...
 
bool shouldBeConvertedAsConst (const llvm::Constant *constant) const
 Determines whether the given LLVM constant constant should be converted into BIR as constant. More...
 
bool shouldBeConvertedAsInst (const llvm::Instruction *inst) const
 Determines whether the given LLVM instruction inst should be converted into BIR as instruction. More...
 
ShPtr< TypedetermineVariableType (llvm::Value *value)
 Determines the correct type of the given LLVM value value. More...
 
- Private Member Functions inherited from retdec::utils::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 

Private Attributes

ShPtr< LLVMTypeConvertertypeConverter
 A converter from LLVM type to type in BIR. More...
 
ShPtr< LLVMInstructionConverterinstConverter
 A converter from LLVM instruction to expression in BIR. More...
 
UPtr< LLVMConstantConverterconstConverter
 A converter from LLVM constant to constant in BIR. More...
 
ShPtr< VariablesManagervariablesManager
 Variables manager. More...
 
ShPtr< ModuleresModule
 The resulting module in BIR. More...
 

Detailed Description

A converter from LLVM values to values in BIR.

Constructor & Destructor Documentation

◆ LLVMValueConverter()

retdec::llvmir2hll::LLVMValueConverter::LLVMValueConverter ( ShPtr< Module resModule,
ShPtr< VariablesManager varManager 
)
private

Constructs a new converter.

Parameters
[in]resModuleThe resulting module in BIR.
[in]varManagerVariable manager managing local variables of currently converted function.

Member Function Documentation

◆ convertCallInstToCallExpr()

ShPtr< CallExpr > retdec::llvmir2hll::LLVMValueConverter::convertCallInstToCallExpr ( llvm::CallInst &  inst)

Converts the given LLVM call instruction inst into an expression in BIR.

◆ convertConstantToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMValueConverter::convertConstantToExpression ( llvm::Constant *  constant)

Converts the given LLVM constant constant into an expression in BIR.

Preconditions
  • constant is non-null

◆ convertInstructionToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMValueConverter::convertInstructionToExpression ( llvm::Instruction *  inst)

Converts the given LLVM instruction inst into an expression in BIR.

Preconditions
  • inst is non-null

◆ convertType()

ShPtr< Type > retdec::llvmir2hll::LLVMValueConverter::convertType ( const llvm::Type *  type)

Converts the given LLVM type type into a type in BIR.

Preconditions
  • type is non-null

◆ convertValueToDerefExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMValueConverter::convertValueToDerefExpression ( llvm::Value *  value)

Converts the given LLVM value value into a dereference expression in BIR.

If converted value value is not considered as pointer, it returns value converted into an expression in BIR as is (value is not converted into dereference expression).

Preconditions
  • value is non-null

◆ convertValueToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMValueConverter::convertValueToExpression ( llvm::Value *  value)

Converts the given LLVM value value into an expression in BIR.

If converted value value is not considered as pointer, it returns address operand of value converted to an expression in BIR (pointer to value must be created).

Preconditions
  • value is non-null

◆ convertValueToExpressionDirectly()

ShPtr< Expression > retdec::llvmir2hll::LLVMValueConverter::convertValueToExpressionDirectly ( llvm::Value *  value)

Converts the given LLVM value value into an expression in BIR.

Preconditions
  • value is non-null

◆ convertValueToVariable()

ShPtr< Variable > retdec::llvmir2hll::LLVMValueConverter::convertValueToVariable ( llvm::Value *  value)

Converts the given LLVM value value into a variable in BIR.

Preconditions
  • value is non-null

◆ create()

ShPtr< LLVMValueConverter > retdec::llvmir2hll::LLVMValueConverter::create ( ShPtr< Module resModule,
ShPtr< VariablesManager varManager 
)
static

Creates a new converter.

Parameters
[in]resModuleThe resulting module in BIR.
[in]varManagerVariable manager managing local variables of currently converted function.

◆ determineVariableType()

ShPtr< Type > retdec::llvmir2hll::LLVMValueConverter::determineVariableType ( llvm::Value *  value)
private

Determines the correct type of the given LLVM value value.

Preconditions
  • value is non-null

◆ generateAccessToAggregateType()

ShPtr< Expression > retdec::llvmir2hll::LLVMValueConverter::generateAccessToAggregateType ( llvm::CompositeType *  type,
ShPtr< Expression base,
llvm::ArrayRef< unsigned >  indices 
)

Generates access to aggregate type as a part of conversion of LLVM instruction insertvalue or extractvalue.

Parameters
[in]typeType of aggregate type.
[in]baseBase expression.
[in]indicesArray of indices.

◆ isConsideredAsPointer()

bool retdec::llvmir2hll::LLVMValueConverter::isConsideredAsPointer ( const llvm::Value *  value) const
private

Determines whether the given LLVM value is considered as pointer variable.

Preconditions
  • value is non-null

◆ setOptionStrictFPUSemantics()

void retdec::llvmir2hll::LLVMValueConverter::setOptionStrictFPUSemantics ( bool  strict = true)

Enables/disables the use of strict FPU semantics.

Parameters
[in]strictIf true, enables the use of strict FPU semantics. If false, disables the use of strict FPU semantics.

◆ shouldBeConvertedAsConst()

bool retdec::llvmir2hll::LLVMValueConverter::shouldBeConvertedAsConst ( const llvm::Constant *  constant) const
private

Determines whether the given LLVM constant constant should be converted into BIR as constant.

Preconditions
  • constant is non-null

◆ shouldBeConvertedAsInst()

bool retdec::llvmir2hll::LLVMValueConverter::shouldBeConvertedAsInst ( const llvm::Instruction *  inst) const
private

Determines whether the given LLVM instruction inst should be converted into BIR as instruction.

This means that we don't want into convert all LLVM instruction into BIR instructions. Some instruction may be converted e.g. into variables.

Preconditions
  • inst is non-null

◆ storesStringLiteral()

bool retdec::llvmir2hll::LLVMValueConverter::storesStringLiteral ( const llvm::GlobalVariable &  globVar) const

Determines whether the given LLVM global variable globVar stores string literal.

Member Data Documentation

◆ constConverter

UPtr<LLVMConstantConverter> retdec::llvmir2hll::LLVMValueConverter::constConverter
private

A converter from LLVM constant to constant in BIR.

◆ instConverter

ShPtr<LLVMInstructionConverter> retdec::llvmir2hll::LLVMValueConverter::instConverter
private

A converter from LLVM instruction to expression in BIR.

◆ resModule

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

The resulting module in BIR.

◆ typeConverter

ShPtr<LLVMTypeConverter> retdec::llvmir2hll::LLVMValueConverter::typeConverter
private

A converter from LLVM type to type in BIR.

◆ variablesManager

ShPtr<VariablesManager> retdec::llvmir2hll::LLVMValueConverter::variablesManager
private

Variables manager.


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