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

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

#include <llvm_constant_converter.h>

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

Public Member Functions

 LLVMConstantConverter (ShPtr< LLVMInstructionConverter > instConverter, ShPtr< LLVMTypeConverter > typeConverter)
 Constructs a new converter. More...
 
ShPtr< ExpressionconvertToExpression (llvm::Constant *constant)
 Converts the given LLVM constant constant into an expression in BIR. More...
 
Options
void setLLVMValueConverter (ShPtr< LLVMValueConverter > conv)
 Sets converter for LLVM values to the given conv. More...
 

Private Member Functions

ShPtr< ExpressionconvertToExpression (const llvm::ConstantInt *cInt)
 Converts the given LLVM boolean or integer constant cInt into an expression in BIR. More...
 
ShPtr< ExpressionconvertToExpression (const llvm::ConstantFP *cFloat)
 Converts the given LLVM floating point constant cFloat into an expression in BIR. More...
 
ShPtr< ExpressionconvertToExpression (llvm::ConstantArray *cArray)
 Converts the given LLVM constant array cArray into an expression in BIR. More...
 
ShPtr< ExpressionconvertToExpression (llvm::ConstantDataArray *cArray)
 Converts the given LLVM constant data array cArray into an expression in BIR. More...
 
ShPtr< ExpressionconvertToExpression (const llvm::ConstantStruct *cStruct)
 Converts the given LLVM constant struct cStruct into an expression in BIR. More...
 
ShPtr< ExpressionconvertToExpression (const llvm::ConstantPointerNull *cNullPtr)
 Converts the given LLVM null pointer constant cNullPtr into an expression in BIR. More...
 
ShPtr< ExpressionconvertToExpression (llvm::GlobalVariable *globVar)
 Converts the given LLVM global value globVar into an expression in BIR. More...
 
ShPtr< ExpressionconvertZeroInitializer (const llvm::Type *type)
 Converts zero initialization of the given LLVM type type into an expression in BIR. More...
 
ShPtr< ExpressionconvertZeroInitializer (const llvm::IntegerType *type)
 Converts zero initialization of the given LLVM integer type type into an expression in BIR. More...
 
ShPtr< ExpressionconvertZeroInitializer (const llvm::ArrayType *type)
 Converts zero initialization of the given LLVM array type type into an expression in BIR. More...
 
ShPtr< ExpressionconvertZeroInitializer (const llvm::StructType *type)
 Converts zero initialization of the given LLVM struct type type into an expression in BIR. More...
 
ShPtr< ExpressionconvertZeroInitializer (const llvm::PointerType *type)
 Converts zero initialization of the given LLVM pointer type type into an expression in BIR. It created null pointer. More...
 
bool isBool (const llvm::ConstantInt *cInt) const
 Determines if given LLVM integral constant cInt is boolean. More...
 
ShPtr< ConstIntgetNameOfStructElement (unsigned index) const
 Creates name of structure element with given index index. More...
 
ShPtr< LLVMValueConvertergetConverter ()
 Returns the LLVMValueConverter. More...
 
- Private Member Functions inherited from retdec::utils::NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable ()=default
 
 ~NonCopyable ()=default
 

Private Attributes

WkPtr< LLVMValueConverterconverter
 A converter from LLVM values to values in BIR. More...
 
ShPtr< LLVMInstructionConverterinstConverter
 A converter from LLVM instruction to expression in BIR. More...
 
ShPtr< LLVMTypeConvertertypeConverter
 A converter from LLVM type to type in BIR. More...
 

Detailed Description

A converter from LLVM constant to constant in BIR.

This converter handles only constant values, not constant expressions.

Preconditions

Constructor & Destructor Documentation

◆ LLVMConstantConverter()

retdec::llvmir2hll::LLVMConstantConverter::LLVMConstantConverter ( ShPtr< LLVMInstructionConverter instConverter,
ShPtr< LLVMTypeConverter typeConverter 
)

Constructs a new converter.

Member Function Documentation

◆ convertToExpression() [1/8]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertToExpression ( const llvm::ConstantFP *  cFloat)
private

Converts the given LLVM floating point constant cFloat into an expression in BIR.

Preconditions
  • cFloat is non-null

◆ convertToExpression() [2/8]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertToExpression ( const llvm::ConstantInt *  cInt)
private

Converts the given LLVM boolean or integer constant cInt into an expression in BIR.

Preconditions
  • cInt is non-null

◆ convertToExpression() [3/8]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertToExpression ( const llvm::ConstantPointerNull *  cNullPtr)
private

Converts the given LLVM null pointer constant cNullPtr into an expression in BIR.

Preconditions
  • cNullPtr is non-null

◆ convertToExpression() [4/8]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertToExpression ( const llvm::ConstantStruct *  cStruct)
private

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

Preconditions
  • cStruct is non-null

◆ convertToExpression() [5/8]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertToExpression ( llvm::Constant *  constant)

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

Preconditions
  • constant is non-null

◆ convertToExpression() [6/8]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertToExpression ( llvm::ConstantArray *  cArray)
private

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

Constant array consists of any type of constants, but for some specific constant arrays can be created LLVM types llvm::ConstantDataArray or llvm::ConstantAggregateZero. llvm::ConstantDataArray is created for array of simple constants like integers or floats and llvm::ConstantAggregateZero is created for zero initialized constant arrays.

Preconditions
  • cArray is non-null

◆ convertToExpression() [7/8]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertToExpression ( llvm::ConstantDataArray *  cArray)
private

Converts the given LLVM constant data array cArray into an expression in BIR.

Constant data array consists only of a simple elements, which means integer or floating point constants.

Preconditions
  • cArray is non-null

◆ convertToExpression() [8/8]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertToExpression ( llvm::GlobalVariable *  globVar)
private

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

Preconditions
  • globVar is non-null

◆ convertZeroInitializer() [1/5]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertZeroInitializer ( const llvm::ArrayType *  type)
private

Converts zero initialization of the given LLVM array type type into an expression in BIR.

Zero initialized array means that all values inside it are initialized to zeros.

Preconditions
  • type is non-null

◆ convertZeroInitializer() [2/5]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertZeroInitializer ( const llvm::IntegerType *  type)
private

Converts zero initialization of the given LLVM integer type type into an expression in BIR.

Preconditions
  • type is non-null

◆ convertZeroInitializer() [3/5]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertZeroInitializer ( const llvm::PointerType *  type)
private

Converts zero initialization of the given LLVM pointer type type into an expression in BIR. It created null pointer.

Preconditions
  • type is non-null

◆ convertZeroInitializer() [4/5]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertZeroInitializer ( const llvm::StructType *  type)
private

Converts zero initialization of the given LLVM struct type type into an expression in BIR.

Zero initialized struct means that all values inside it are initialized to zeros.

Preconditions
  • type is non-null

◆ convertZeroInitializer() [5/5]

ShPtr< Expression > retdec::llvmir2hll::LLVMConstantConverter::convertZeroInitializer ( const llvm::Type *  type)
private

Converts zero initialization of the given LLVM type type into an expression in BIR.

Zero initialization means that value is zero (for scalar types) or all values inside composite type are zeros.

Preconditions
  • type is non-null

◆ getConverter()

ShPtr< LLVMValueConverter > retdec::llvmir2hll::LLVMConstantConverter::getConverter ( )
private

Returns the LLVMValueConverter.

◆ getNameOfStructElement()

ShPtr< ConstInt > retdec::llvmir2hll::LLVMConstantConverter::getNameOfStructElement ( unsigned  index) const
private

Creates name of structure element with given index index.

◆ isBool()

bool retdec::llvmir2hll::LLVMConstantConverter::isBool ( const llvm::ConstantInt *  cInt) const
private

Determines if given LLVM integral constant cInt is boolean.

Preconditions
  • cInt is non-null

◆ setLLVMValueConverter()

void retdec::llvmir2hll::LLVMConstantConverter::setLLVMValueConverter ( ShPtr< LLVMValueConverter conv)

Sets converter for LLVM values to the given conv.

Preconditions
  • conv is non-null

Member Data Documentation

◆ converter

WkPtr<LLVMValueConverter> retdec::llvmir2hll::LLVMConstantConverter::converter
private

A converter from LLVM values to values in BIR.

◆ instConverter

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

A converter from LLVM instruction to expression in BIR.

◆ typeConverter

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

A converter from LLVM type to type in BIR.


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