2007-12-01 04:08:34 +00:00
|
|
|
#ifndef _BASICBLOCK_H_
|
|
|
|
#define _BASICBLOCK_H_
|
|
|
|
|
|
|
|
#include "MIPS.h"
|
2010-08-11 03:47:19 +00:00
|
|
|
#include "MemoryFunction.h"
|
2012-03-11 20:06:14 +00:00
|
|
|
#include <boost/intrusive_ptr.hpp>
|
2007-12-01 04:08:34 +00:00
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
namespace Jitter
|
|
|
|
{
|
|
|
|
class CJitter;
|
|
|
|
};
|
2009-06-06 15:38:03 +00:00
|
|
|
|
2010-11-17 03:59:29 +00:00
|
|
|
class CBasicBlock;
|
|
|
|
typedef boost::intrusive_ptr<CBasicBlock> BasicBlockPtr;
|
|
|
|
|
2010-11-27 07:15:47 +00:00
|
|
|
static void intrusive_ptr_add_ref(CBasicBlock*);
|
|
|
|
static void intrusive_ptr_release(CBasicBlock*);
|
|
|
|
|
2007-12-01 04:08:34 +00:00
|
|
|
class CBasicBlock
|
|
|
|
{
|
|
|
|
public:
|
2010-08-11 03:47:19 +00:00
|
|
|
CBasicBlock(CMIPS&, uint32, uint32);
|
2012-04-15 22:00:47 +00:00
|
|
|
virtual ~CBasicBlock();
|
|
|
|
unsigned int Execute();
|
|
|
|
void Compile();
|
2010-08-11 03:47:19 +00:00
|
|
|
|
2012-04-15 22:00:47 +00:00
|
|
|
uint32 GetBeginAddress() const;
|
|
|
|
uint32 GetEndAddress() const;
|
|
|
|
bool IsCompiled() const;
|
|
|
|
unsigned int GetSelfLoopCount() const;
|
|
|
|
void SetSelfLoopCount(unsigned int);
|
2007-12-01 04:08:34 +00:00
|
|
|
|
2009-06-06 15:38:03 +00:00
|
|
|
protected:
|
2012-04-15 22:00:47 +00:00
|
|
|
uint32 m_begin;
|
|
|
|
uint32 m_end;
|
|
|
|
CMIPS& m_context;
|
2009-06-06 15:38:03 +00:00
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
virtual void CompileRange(CMipsJitter*);
|
2009-06-06 15:38:03 +00:00
|
|
|
|
|
|
|
private:
|
2010-11-17 03:59:29 +00:00
|
|
|
friend void intrusive_ptr_add_ref(CBasicBlock*);
|
|
|
|
friend void intrusive_ptr_release(CBasicBlock*);
|
|
|
|
|
2010-08-11 03:47:19 +00:00
|
|
|
CMemoryFunction* m_function;
|
2012-04-15 22:00:47 +00:00
|
|
|
unsigned int m_selfLoopCount;
|
2010-11-17 03:59:29 +00:00
|
|
|
|
|
|
|
unsigned int m_refCount;
|
2007-12-01 04:08:34 +00:00
|
|
|
};
|
|
|
|
|
2010-11-17 03:59:29 +00:00
|
|
|
static void intrusive_ptr_add_ref(CBasicBlock* block)
|
|
|
|
{
|
|
|
|
block->m_refCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void intrusive_ptr_release(CBasicBlock* block)
|
|
|
|
{
|
|
|
|
block->m_refCount--;
|
|
|
|
if(block->m_refCount == 0)
|
|
|
|
{
|
|
|
|
delete block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-01 04:08:34 +00:00
|
|
|
#endif
|