retdec
llvm_constant_converter.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_LLVM_LLVMIR2BIR_CONVERTER_LLVM_CONSTANT_CONVERTER_H
8 #define RETDEC_LLVMIR2HLL_LLVM_LLVMIR2BIR_CONVERTER_LLVM_CONSTANT_CONVERTER_H
9 
12 
13 namespace llvm {
14 
15 class ArrayType;
16 class Constant;
17 class ConstantArray;
18 class ConstantDataArray;
19 class ConstantFP;
20 class ConstantInt;
21 class ConstantPointerNull;
22 class ConstantStruct;
23 class GlobalVariable;
24 class IntegerType;
25 class PointerType;
26 class StructType;
27 class Type;
28 
29 } // namespace llvm
30 
31 namespace retdec {
32 namespace llvmir2hll {
33 
34 class ConstInt;
35 class Expression;
36 class LLVMInstructionConverter;
37 class LLVMTypeConverter;
38 class LLVMValueConverter;
39 
49 public:
52 
53  ShPtr<Expression> convertToExpression(llvm::Constant *constant);
54 
59 
60 private:
61  ShPtr<Expression> convertToExpression(const llvm::ConstantInt *cInt);
62  ShPtr<Expression> convertToExpression(const llvm::ConstantFP *cFloat);
63  ShPtr<Expression> convertToExpression(llvm::ConstantArray *cArray);
64  ShPtr<Expression> convertToExpression(llvm::ConstantDataArray *cArray);
65  ShPtr<Expression> convertToExpression(const llvm::ConstantStruct *cStruct);
66  ShPtr<Expression> convertToExpression(const llvm::ConstantPointerNull *cNullPtr);
67  ShPtr<Expression> convertToExpression(llvm::GlobalVariable *globVar);
68 
69  ShPtr<Expression> convertZeroInitializer(const llvm::Type *type);
70  ShPtr<Expression> convertZeroInitializer(const llvm::IntegerType *type);
71  ShPtr<Expression> convertZeroInitializer(const llvm::ArrayType *type);
72  ShPtr<Expression> convertZeroInitializer(const llvm::StructType *type);
73  ShPtr<Expression> convertZeroInitializer(const llvm::PointerType *type);
74 
75  bool isBool(const llvm::ConstantInt *cInt) const;
76  ShPtr<ConstInt> getNameOfStructElement(unsigned index) const;
77 
79 
82 
85 
88 };
89 
90 } // namespace llvmir2hll
91 } // namespace retdec
92 
93 #endif
A converter from LLVM constant to constant in BIR.
Definition: llvm_constant_converter.h:48
ShPtr< LLVMValueConverter > getConverter()
Returns the LLVMValueConverter.
Definition: llvm_constant_converter.cpp:374
ShPtr< ConstInt > getNameOfStructElement(unsigned index) const
Creates name of structure element with given index index.
Definition: llvm_constant_converter.cpp:367
ShPtr< LLVMInstructionConverter > instConverter
A converter from LLVM instruction to expression in BIR.
Definition: llvm_constant_converter.h:84
ShPtr< Expression > convertToExpression(llvm::Constant *constant)
Converts the given LLVM constant constant into an expression in BIR.
Definition: llvm_constant_converter.cpp:57
WkPtr< LLVMValueConverter > converter
A converter from LLVM values to values in BIR.
Definition: llvm_constant_converter.h:81
void setLLVMValueConverter(ShPtr< LLVMValueConverter > conv)
Sets converter for LLVM values to the given conv.
Definition: llvm_constant_converter.cpp:94
ShPtr< Expression > convertZeroInitializer(const llvm::Type *type)
Converts zero initialization of the given LLVM type type into an expression in BIR.
Definition: llvm_constant_converter.cpp:253
ShPtr< LLVMTypeConverter > typeConverter
A converter from LLVM type to type in BIR.
Definition: llvm_constant_converter.h:87
LLVMConstantConverter(ShPtr< LLVMInstructionConverter > instConverter, ShPtr< LLVMTypeConverter > typeConverter)
Constructs a new converter.
Definition: llvm_constant_converter.cpp:47
bool isBool(const llvm::ConstantInt *cInt) const
Determines if given LLVM integral constant cInt is boolean.
Definition: llvm_constant_converter.cpp:358
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::weak_ptr< T > WkPtr
An alias for a weak pointer.
Definition: smart_ptr.h:22
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
Definition: archive_wrapper.h:19
A mixin to make classes non-copyable.
Declarations, aliases, macros, etc. for the use of smart pointers.