ROSE 0.11.145.192
Public Types | Static Public Member Functions | Protected Member Functions | List of all members
Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder Class Reference

Description

Translates machine instructions to LLVM.

Definition at line 342 of file LlvmSemantics.h.

#include <Rose/BinaryAnalysis/InstructionSemantics/LlvmSemantics.h>

Public Types

using Ptr = TranscoderPtr
 Reference counting pointer.
 

Public Member Functions

int llvmVersion () const
 Property: LLVM version number.
 
void llvmVersion (int version)
 Property: LLVM version number.
 
bool emitFunctionFragements () const
 Property to determine whether function fragments should be emitted.
 
void emitFunctionFragements (bool b)
 Property to determine whether function fragments should be emitted.
 
bool quietErrors () const
 Property to control what happens when a translation exception occurs.
 
void quietErrors (bool b)
 Property to control what happens when a translation exception occurs.
 
void emitFilePrologue (std::ostream &)
 Emit LLVM file prologue.
 
std::string emitFilePrologue ()
 Emit LLVM file prologue.
 
void emitFunctionDeclarations (SgNode *ast, std::ostream &)
 Emit function declarations.
 
std::string emitFunctionDeclarations (SgNode *ast)
 Emit function declarations.
 
void transcodeInstruction (SgAsmInstruction *, std::ostream &)
 Translate a single machine instruction to LLVM instructions.
 
std::string transcodeInstruction (SgAsmInstruction *)
 Translate a single machine instruction to LLVM instructions.
 
size_t transcodeBasicBlock (SgAsmBlock *, std::ostream &)
 Transcode a basic block of machine instructions to LLVM instructions.
 
std::string transcodeBasicBlock (SgAsmBlock *)
 Transcode a basic block of machine instructions to LLVM instructions.
 
size_t transcodeFunction (SgAsmFunction *, std::ostream &)
 Transcode an entire function to LLVM instructions.
 
std::string transcodeFunction (SgAsmFunction *)
 Transcode an entire function to LLVM instructions.
 
void transcodeInterpretation (SgAsmInterpretation *, std::ostream &)
 Transcode an entire binary interpretation.
 
std::string transcodeInterpretation (SgAsmInterpretation *)
 Transcode an entire binary interpretation.
 

Static Public Member Functions

static TranscoderPtr instance (const BaseSemantics::DispatcherPtr &)
 Factory method to create a new transcoder for an arbitrary machine architecture.
 
static TranscoderPtr instanceX86 ()
 Factory method to create a new transcoder for 32-bit X86 instructions.
 

Protected Member Functions

 Transcoder (const BaseSemantics::DispatcherPtr &)
 

Member Typedef Documentation

◆ Ptr

Reference counting pointer.

Definition at line 345 of file LlvmSemantics.h.

Member Function Documentation

◆ instance()

static TranscoderPtr Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::instance ( const BaseSemantics::DispatcherPtr )
static

Factory method to create a new transcoder for an arbitrary machine architecture.

The supplied dispatcher must use an LlvmSemantics::RiscOperators or subclass thereof.

◆ llvmVersion() [1/2]

int Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::llvmVersion ( ) const

Property: LLVM version number.

The version number controls the dialect of assembly to be emitted. Since LLVM assembly is used mostly as an internal representation within LLVM, its syntax changes from version to version in ways that are not backward compatible. The version number set here is a*x^2 + b*x + c where a b and c are the LLVM version triplet "a.b.c" and x is 1000. The value zero is reserved to mean that the version number is unknown.

◆ llvmVersion() [2/2]

void Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::llvmVersion ( int  version)

Property: LLVM version number.

The version number controls the dialect of assembly to be emitted. Since LLVM assembly is used mostly as an internal representation within LLVM, its syntax changes from version to version in ways that are not backward compatible. The version number set here is a*x^2 + b*x + c where a b and c are the LLVM version triplet "a.b.c" and x is 1000. The value zero is reserved to mean that the version number is unknown.

◆ emitFunctionFragements() [1/2]

bool Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::emitFunctionFragements ( ) const
inline

Property to determine whether function fragments should be emitted.

A function fragment is a basic block that belongs to a function but doesn't participate in its control flow graph. These fragments are usually added to ROSE functions when ROSE finds valid instructions but can't figure out how that code is reached. The default is to not emit fragements since their control flow successors might be invalid, resulting in invalid LLVM branches.

Definition at line 383 of file LlvmSemantics.h.

◆ emitFunctionFragements() [2/2]

void Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::emitFunctionFragements ( bool  b)
inline

Property to determine whether function fragments should be emitted.

A function fragment is a basic block that belongs to a function but doesn't participate in its control flow graph. These fragments are usually added to ROSE functions when ROSE finds valid instructions but can't figure out how that code is reached. The default is to not emit fragements since their control flow successors might be invalid, resulting in invalid LLVM branches.

Definition at line 384 of file LlvmSemantics.h.

◆ quietErrors() [1/2]

bool Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::quietErrors ( ) const
inline

Property to control what happens when a translation exception occurs.

If true, then exceptions from ROSE's instruction semantics are caught and emitted as an LLVM comment starting with ";;ERROR: ". This happens when ROSE has no semantics defined for a particular instruction (such as floating point instructions as of Jan 2014).

Definition at line 391 of file LlvmSemantics.h.

◆ quietErrors() [2/2]

void Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::quietErrors ( bool  b)
inline

Property to control what happens when a translation exception occurs.

If true, then exceptions from ROSE's instruction semantics are caught and emitted as an LLVM comment starting with ";;ERROR: ". This happens when ROSE has no semantics defined for a particular instruction (such as floating point instructions as of Jan 2014).

Definition at line 392 of file LlvmSemantics.h.

◆ emitFunctionDeclarations() [1/2]

void Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::emitFunctionDeclarations ( SgNode ast,
std::ostream &   
)

Emit function declarations.

Emits declarations for all functions that appear in the specified AST.

◆ emitFunctionDeclarations() [2/2]

std::string Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::emitFunctionDeclarations ( SgNode ast)

Emit function declarations.

Emits declarations for all functions that appear in the specified AST.

◆ transcodeInstruction() [1/2]

void Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::transcodeInstruction ( SgAsmInstruction ,
std::ostream &   
)

Translate a single machine instruction to LLVM instructions.

LLVM instructions are emitted to the specified stream or returned as a string.

◆ transcodeInstruction() [2/2]

std::string Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::transcodeInstruction ( SgAsmInstruction )

Translate a single machine instruction to LLVM instructions.

LLVM instructions are emitted to the specified stream or returned as a string.

◆ transcodeBasicBlock() [1/2]

size_t Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::transcodeBasicBlock ( SgAsmBlock ,
std::ostream &   
)

Transcode a basic block of machine instructions to LLVM instructions.

LLVM instructions are emitted to the specified stream or returned as a string. When a string isn't returned, the return value is the number of instructions emitted.

◆ transcodeBasicBlock() [2/2]

std::string Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::transcodeBasicBlock ( SgAsmBlock )

Transcode a basic block of machine instructions to LLVM instructions.

LLVM instructions are emitted to the specified stream or returned as a string. When a string isn't returned, the return value is the number of instructions emitted.

◆ transcodeFunction() [1/2]

size_t Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::transcodeFunction ( SgAsmFunction ,
std::ostream &   
)

Transcode an entire function to LLVM instructions.

LLVM instructions are emitted to the specified stream or returned as a string. When a string isn't returned, the return value is the number of basic blocks emitted.

◆ transcodeFunction() [2/2]

std::string Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::transcodeFunction ( SgAsmFunction )

Transcode an entire function to LLVM instructions.

LLVM instructions are emitted to the specified stream or returned as a string. When a string isn't returned, the return value is the number of basic blocks emitted.

◆ transcodeInterpretation() [1/2]

void Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::transcodeInterpretation ( SgAsmInterpretation ,
std::ostream &   
)

Transcode an entire binary interpretation.

Unlike the lower-level transcoder methods, this one also emits register and function declarations.

◆ transcodeInterpretation() [2/2]

std::string Rose::BinaryAnalysis::InstructionSemantics::LlvmSemantics::Transcoder::transcodeInterpretation ( SgAsmInterpretation )

Transcode an entire binary interpretation.

Unlike the lower-level transcoder methods, this one also emits register and function declarations.


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