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

A converter from LLVM instruction to expression in BIR. More...

#include <llvm_instruction_converter.h>

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

Public Member Functions

Constant expression conversion
ShPtr< ExpressionconvertConstExprToExpression (llvm::ConstantExpr *cExpr)
 Converts the given LLVM constant expression cExpr 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, const ShPtr< Expression > &base, const llvm::ArrayRef< unsigned > &indices)
 Generates access to aggregate type as a part of conversion of LLVM instruction insertvalue or extractvalue. More...
 
Options
void setLLVMValueConverter (ShPtr< LLVMValueConverter > conv)
 Sets converter for LLVM values to the given conv. More...
 
void setOptionStrictFPUSemantics (bool strict=true)
 Enables/disables the use of strict FPU semantics. More...
 

Private Member Functions

ShPtr< ExpressionconvertBinaryOpToExpression (llvm::User &inst, unsigned opcode)
 Converts the given LLVM binary operation inst with opcode opcode into an expression in BIR. More...
 
ShPtr< ExpressionconvertICmpInstToExpression (llvm::User &inst, unsigned predicate)
 Converts the given LLVM icmp instruction inst with compare predicate predicate into an expression in BIR. More...
 
ShPtr< ExpressionconvertFCmpInstToExpression (llvm::User &inst, unsigned predicate)
 Converts the given LLVM fcmp instruction inst with compare predicate predicate into an expression in BIR. More...
 
ShPtr< ExpressionconvertSelectInstToExpression (llvm::User &inst)
 Converts the given LLVM select instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionconvertExtCastInstToExpression (llvm::User &inst, ExtCastExpr::Variant variant)
 Converts the given LLVM extension cast instruction inst into an extension cast expression in BIR. More...
 
ShPtr< ExpressionconvertIntToFPInstToExpression (llvm::User &inst, IntToFPCastExpr::Variant variant)
 Converts the given LLVM int to FP cast instruction inst into an int to FP cast expression in BIR. More...
 
ShPtr< ExpressionconvertFPToIntInstToExpression (llvm::User &inst)
 Converts the given LLVM FP to int cast instruction inst into a FP to int cast expression in BIR. More...
 
ShPtr< ExpressionconvertTruncInstToExpression (llvm::User &inst)
 Converts the given LLVM trunc instruction inst into a trunc cast expression in BIR. More...
 
template<class T >
ShPtr< ExpressionconvertCastInstToExpression (llvm::User &inst)
 Converts the given LLVM cast instruction inst into a specified expression in BIR. More...
 
ShPtr< ExpressionconvertGetElementPtrToExpression (llvm::User &inst)
 Converts the given LLVM getelementptr instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionconvertGEPIndices (ShPtr< Expression > base, llvm::gep_type_iterator start, llvm::gep_type_iterator end)
 Converts indices of LLVM getelementptr instruction. 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...
 
LLVMFCmpConverter fcmpConverter
 A converter from LLVM fcmp instruction to expression in BIR. More...
 

Instruction conversion using InstVisitor

class llvm::InstVisitor< LLVMInstructionConverter, ShPtr< Expression > >
 
ShPtr< ExpressionvisitAddrSpaceCastInst (llvm::AddrSpaceCastInst &inst)
 Converts the given LLVM address space cast instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitBinaryOperator (llvm::BinaryOperator &inst)
 Converts the given LLVM binary operation inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitBitCastInst (llvm::BitCastInst &inst)
 Converts the given LLVM bitcast instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitFPExtInst (llvm::FPExtInst &inst)
 Converts the given LLVM fpext instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitSExtInst (llvm::SExtInst &inst)
 Converts the given LLVM sext instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitZExtInst (llvm::ZExtInst &inst)
 Converts the given LLVM zext instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitFPToSIInst (llvm::FPToSIInst &inst)
 Converts the given LLVM fptosi instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitFPToUIInst (llvm::FPToUIInst &inst)
 Converts the given LLVM fptoui instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitTruncInst (llvm::TruncInst &inst)
 Converts the given LLVM trunc instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitFPTruncInst (llvm::FPTruncInst &inst)
 Converts the given LLVM fptrunc instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitIntToPtrInst (llvm::IntToPtrInst &inst)
 Converts the given LLVM inttoptr instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitPtrToIntInst (llvm::PtrToIntInst &inst)
 Converts the given LLVM ptrtoint instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitSIToFPInst (llvm::SIToFPInst &inst)
 Converts the given LLVM sitofp instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitUIToFPInst (llvm::UIToFPInst &inst)
 Converts the given LLVM uitofp instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitICmpInst (llvm::ICmpInst &inst)
 Converts the given LLVM icmp instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitFCmpInst (llvm::FCmpInst &inst)
 Converts the given LLVM fcmp instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitSelectInst (llvm::SelectInst &inst)
 Converts the given LLVM select instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitGetElementPtrInst (llvm::GetElementPtrInst &inst)
 Converts the given LLVM getElementPtr instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitExtractValueInst (llvm::ExtractValueInst &inst)
 Converts the given LLVM extractvalue instruction inst into an expression in BIR. More...
 
ShPtr< ExpressionvisitInstruction (llvm::Instruction &inst)
 Converts the given LLVM instruction inst into an expression in BIR. More...
 

Detailed Description

A converter from LLVM instruction to expression in BIR.

This class converts only inlinable instructions which are converted into expressions.

Preconditions

Member Function Documentation

◆ convertBinaryOpToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertBinaryOpToExpression ( llvm::User &  inst,
unsigned  opcode 
)
private

Converts the given LLVM binary operation inst with opcode opcode into an expression in BIR.

Note that inst type is llvm::User instead of llvm::BinaryOperator because this method can handle also constant binary expressions.

◆ convertCallInstToCallExpr()

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

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

◆ convertCastInstToExpression()

template<class T >
ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertCastInstToExpression ( llvm::User &  inst)
private

Converts the given LLVM cast instruction inst into a specified expression in BIR.

Note that inst type is llvm::User instead of llvm::CastInst because this method can handle also constant cast expressions.

Template Parameters
TClass that represents a cast expression in BIR.

◆ convertConstExprToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertConstExprToExpression ( llvm::ConstantExpr *  cExpr)

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

Preconditions
  • cExpr is non-null

◆ convertExtCastInstToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertExtCastInstToExpression ( llvm::User &  inst,
ExtCastExpr::Variant  variant 
)
private

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

Note that inst type is llvm::User instead of llvm::CastInst because this method can handle also constant cast expressions.

Parameters
[in]instGiven LLVM extension cast instruction.
[in]variantVariant of extension cast expression in BIR.

◆ convertFCmpInstToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertFCmpInstToExpression ( llvm::User &  inst,
unsigned  predicate 
)
private

Converts the given LLVM fcmp instruction inst with compare predicate predicate into an expression in BIR.

Note that inst type is llvm::User instead of llvm::FCmpInst because this method can handle also constant floating-point compare expressions.

◆ convertFPToIntInstToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertFPToIntInstToExpression ( llvm::User &  inst)
private

Converts the given LLVM FP to int cast instruction inst into a FP to int cast expression in BIR.

Note that inst type is llvm::User instead of llvm::CastInst because this method can handle also constant cast expressions.

◆ convertGEPIndices()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertGEPIndices ( ShPtr< Expression base,
llvm::gep_type_iterator  start,
llvm::gep_type_iterator  end 
)
private

Converts indices of LLVM getelementptr instruction.

Parameters
[in]basePointed operand of LLVM getelementptr instruction converted to an expression in BIR.
[in]startFirst index of LLVM getelementptr instruction to be converted.
[in]endEnd of iterator through LLVM getelementptr instruction indices.

◆ convertGetElementPtrToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertGetElementPtrToExpression ( llvm::User &  inst)
private

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

Note that inst type is llvm::User instead of llvm::GetElementPtrInst because this method can handle also constant getelementptr expression.

◆ convertICmpInstToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertICmpInstToExpression ( llvm::User &  inst,
unsigned  predicate 
)
private

Converts the given LLVM icmp instruction inst with compare predicate predicate into an expression in BIR.

Note that inst type is llvm::User instead of llvm::ICmpInst because this method can handle also constant integral compare expressions.

◆ convertInstructionToExpression()

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

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

Preconditions
  • inst is non-null

◆ convertIntToFPInstToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertIntToFPInstToExpression ( llvm::User &  inst,
IntToFPCastExpr::Variant  variant 
)
private

Converts the given LLVM int to FP cast instruction inst into an int to FP cast expression in BIR.

Note that inst type is llvm::User instead of llvm::CastInst because this method can handle also constant cast expressions.

Parameters
[in]instGiven LLVM int to FP cast instruction.
[in]variantVariant of int to FP cast expression in BIR.

◆ convertSelectInstToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertSelectInstToExpression ( llvm::User &  inst)
private

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

Note that inst type is llvm::User instead of llvm::SelectInst because this method can handle also constant select expressions.

◆ convertTruncInstToExpression()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::convertTruncInstToExpression ( llvm::User &  inst)
private

Converts the given LLVM trunc instruction inst into a trunc cast expression in BIR.

Note that inst type is llvm::User instead of llvm::CastInst because this method can handle also constant cast expressions.

◆ generateAccessToAggregateType()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::generateAccessToAggregateType ( llvm::CompositeType *  type,
const ShPtr< Expression > &  base,
const 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.

◆ getConverter()

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

Returns the LLVMValueConverter.

◆ setLLVMValueConverter()

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

Sets converter for LLVM values to the given conv.

Preconditions
  • conv is non-null

◆ setOptionStrictFPUSemantics()

void retdec::llvmir2hll::LLVMInstructionConverter::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.

◆ visitAddrSpaceCastInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitAddrSpaceCastInst ( llvm::AddrSpaceCastInst &  inst)
private

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

◆ visitBinaryOperator()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitBinaryOperator ( llvm::BinaryOperator &  inst)
private

Converts the given LLVM binary operation inst into an expression in BIR.

◆ visitBitCastInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitBitCastInst ( llvm::BitCastInst &  inst)
private

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

◆ visitExtractValueInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitExtractValueInst ( llvm::ExtractValueInst &  inst)
private

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

◆ visitFCmpInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitFCmpInst ( llvm::FCmpInst &  inst)
private

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

◆ visitFPExtInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitFPExtInst ( llvm::FPExtInst &  inst)
private

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

◆ visitFPToSIInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitFPToSIInst ( llvm::FPToSIInst &  inst)
private

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

◆ visitFPToUIInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitFPToUIInst ( llvm::FPToUIInst &  inst)
private

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

◆ visitFPTruncInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitFPTruncInst ( llvm::FPTruncInst &  inst)
private

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

◆ visitGetElementPtrInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitGetElementPtrInst ( llvm::GetElementPtrInst &  inst)
private

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

◆ visitICmpInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitICmpInst ( llvm::ICmpInst &  inst)
private

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

◆ visitInstruction()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitInstruction ( llvm::Instruction &  inst)
private

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

◆ visitIntToPtrInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitIntToPtrInst ( llvm::IntToPtrInst &  inst)
private

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

◆ visitPtrToIntInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitPtrToIntInst ( llvm::PtrToIntInst &  inst)
private

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

◆ visitSelectInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitSelectInst ( llvm::SelectInst &  inst)
private

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

◆ visitSExtInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitSExtInst ( llvm::SExtInst &  inst)
private

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

◆ visitSIToFPInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitSIToFPInst ( llvm::SIToFPInst &  inst)
private

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

◆ visitTruncInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitTruncInst ( llvm::TruncInst &  inst)
private

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

◆ visitUIToFPInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitUIToFPInst ( llvm::UIToFPInst &  inst)
private

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

◆ visitZExtInst()

ShPtr< Expression > retdec::llvmir2hll::LLVMInstructionConverter::visitZExtInst ( llvm::ZExtInst &  inst)
private

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

Friends And Related Function Documentation

◆ llvm::InstVisitor< LLVMInstructionConverter, ShPtr< Expression > >

friend class llvm::InstVisitor< LLVMInstructionConverter, ShPtr< Expression > >
friend

Member Data Documentation

◆ converter

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

A converter from LLVM values to values in BIR.

◆ fcmpConverter

LLVMFCmpConverter retdec::llvmir2hll::LLVMInstructionConverter::fcmpConverter
private

A converter from LLVM fcmp instruction to expression in BIR.


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