2010-05-31 00:21:08 +00:00
|
|
|
class CCodeBlock :
|
|
|
|
private CRecompilerOps
|
2010-05-30 01:54:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-09-25 05:58:06 +00:00
|
|
|
CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos );
|
2010-05-30 01:54:42 +00:00
|
|
|
|
|
|
|
bool Compile ( void );
|
|
|
|
|
|
|
|
inline DWORD VAddrEnter ( void ) const { return m_VAddrEnter; }
|
|
|
|
inline DWORD VAddrFirst ( void ) const { return m_VAddrFirst; }
|
|
|
|
inline DWORD VAddrLast ( void ) const { return m_VAddrLast; }
|
|
|
|
inline BYTE * CompiledLocation ( void ) const { return m_CompiledLocation; }
|
|
|
|
inline int NoOfSections ( void ) const { return m_NoOfSections; }
|
2012-10-14 01:05:52 +00:00
|
|
|
inline const CCodeSection & EnterSection ( void ) const { return *m_EnterSection; }
|
2010-06-16 07:31:47 +00:00
|
|
|
inline const MD5Digest & Hash ( void ) const { return m_Hash; }
|
2010-05-30 01:54:42 +00:00
|
|
|
|
|
|
|
inline void SetVAddrFirst ( DWORD VAddr ) { m_VAddrFirst = VAddr; }
|
|
|
|
inline void SetVAddrLast ( DWORD VAddr ) { m_VAddrLast = VAddr; }
|
|
|
|
|
2010-07-23 10:45:35 +00:00
|
|
|
inline void IncSectionCount ( void ) { m_NoOfSections += 1; }
|
|
|
|
|
2012-10-14 01:05:52 +00:00
|
|
|
CCodeSection * ExistingSection ( DWORD Addr ) { return m_EnterSection->ExistingSection(Addr,NextTest()); }
|
|
|
|
bool SectionAccessible ( DWORD m_SectionID ) { return m_EnterSection->SectionAccessible(m_SectionID,NextTest()); }
|
2010-07-23 10:45:35 +00:00
|
|
|
|
2012-09-24 22:07:51 +00:00
|
|
|
inline QWORD MemContents(int i) const { return m_MemContents[i]; }
|
|
|
|
inline QWORD * MemLocation(int i) const { return m_MemLocation[i]; }
|
|
|
|
|
2010-05-30 01:54:42 +00:00
|
|
|
EXIT_LIST m_ExitInfo;
|
2010-10-23 18:53:01 +00:00
|
|
|
DWORD NextTest ( void );
|
2010-05-30 01:54:42 +00:00
|
|
|
|
|
|
|
private:
|
2010-07-23 10:45:35 +00:00
|
|
|
bool AnalyseBlock ( void );
|
2010-06-04 06:25:07 +00:00
|
|
|
void CompileExitCode ( void );
|
2010-05-30 01:54:42 +00:00
|
|
|
|
2012-10-14 01:05:52 +00:00
|
|
|
bool CreateBlockLinkage ( CCodeSection * EnterSection ) ;
|
|
|
|
void DetermineLoops ( void ) ;
|
|
|
|
void LogSectionInfo ( void ) ;
|
|
|
|
bool SetSection ( CCodeSection * & Section, CCodeSection * CurrentSection, DWORD TargetPC, bool LinkAllowed, DWORD CurrentPC );
|
|
|
|
bool SetJumpInfo ( CCodeSection * & Section, DWORD TargetPC, DWORD CurrentPC );
|
|
|
|
bool AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & ContinuePC, bool & LikelyBranch, bool & IncludeDelaySlot, bool & EndBlock );
|
|
|
|
|
2010-05-30 01:54:42 +00:00
|
|
|
DWORD m_VAddrEnter;
|
|
|
|
DWORD m_VAddrFirst; // the address of the first opcode in the block
|
|
|
|
DWORD m_VAddrLast; // the address of the first opcode in the block
|
|
|
|
BYTE * m_CompiledLocation; // What address is this compiled at
|
|
|
|
int m_NoOfSections; // The number of sections this block uses
|
2012-10-14 01:05:52 +00:00
|
|
|
|
|
|
|
typedef std::map<DWORD,CCodeSection *> SectionMap;
|
|
|
|
typedef std::list<CCodeSection *> SectionList;
|
|
|
|
|
|
|
|
SectionMap m_SectionMap;
|
|
|
|
SectionList m_Sections;
|
|
|
|
CCodeSection * m_EnterSection;
|
|
|
|
long m_Test;
|
2010-06-16 07:31:47 +00:00
|
|
|
MD5Digest m_Hash;
|
2012-09-24 22:07:51 +00:00
|
|
|
QWORD m_MemContents[2];
|
|
|
|
QWORD * m_MemLocation[2];
|
2010-05-30 01:54:42 +00:00
|
|
|
};
|