📄 instruction_subset.h
字号:
/**
* Copyright (c) 2005 Zhejiang University, P.R.China
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//=============================================================================
/**
* \class PPC_Instruction_Subset
*
* \brief Inherit from Core::Instruction
*
* \author Chenfeng Zhou <ini_autumn@163.com>
*
* Created : <2005-02-10 14:09:33 by Cheney Chow>
* Last update: <2005-03-10 20:47:17 by Cheney Chow>
*
* $Id: Instruction_Subset.h,v 1.1 2005/06/16 06:01:46 qilj Exp $
*/
//=============================================================================
#ifndef _PPC_INSTRUCTION_SUBSET_H_
#define _PPC_INSTRUCTION_SUBSET_H_
#include <vector>
#include "Core/Instruction.h"
#include "Types.h"
#include "Utils/Singleton.h"
#include "Utils/Debug.h"
#include "Reg_Utils.h"
#include "Utils/Logger.h"
namespace PPC
{
class PPC_Instruction_Subset : public Core::Instruction
{
protected:
PPC_Instruction_Subset () {}
virtual ~PPC_Instruction_Subset () {}
public:
//! Init from static operation array;
void register_instruction (Core::Instruction *[]);
//! Execute instruction recursively;
virtual void execute (PPC_Instr_T);
protected:
//! Return the extension field (1 - 11 from right to left)
static Core::u32 extract_ext(PPC_Instr_T instr)
{
return (instr >> 1) & 0x3ff;
}
private:
//! Find the corresponding instruction op
virtual Core::Instruction *look_up (PPC_Instr_T) = 0;
private:
//std::vector<Core::Instruction*> ops_;
};
#include "Instruction_Subset_i.h"
class S_Group_1 : public PPC_Instruction_Subset
{
public:
S_Group_1() {}
virtual ~S_Group_1() {}
virtual void execute (PPC_Instr_T instr)
{
PPC_Instruction_Subset::execute(instr);
}
private:
//! Find the corresponding instruction op
virtual Core::Instruction *look_up (PPC_Instr_T);
private:
//! Groups of instruction with same op code
//! within each group(first 6 bits)
//static Core::Instruction* op_table[];
};
typedef PPC_Singleton<S_Group_1> op_group_1;
class S_Group_2 : public PPC_Instruction_Subset
{
private:
enum {TABLE_SIZE = 1015};
public:
S_Group_2();
virtual ~S_Group_2() {}
virtual void execute (PPC_Instr_T instr)
{
PPC_Instruction_Subset::execute(instr);
}
private:
//! Find the corresponding instruction op
virtual Core::Instruction *look_up (PPC_Instr_T);
//! Init op_table;
void init_op_table();
private:
//! Groups of instruction with same op code
//! within each group(first 6 bits)
static Core::Instruction* op_table_[TABLE_SIZE];
};
typedef PPC_Singleton<S_Group_2> op_group_2;
class S_Group_f_1 : public PPC_Instruction_Subset
{
public:
S_Group_f_1() {}
virtual ~S_Group_f_1() {}
virtual void execute (PPC_Instr_T instr)
{
//PPC_Instruction_Subset::execute(instr);
PPC_ERROR("float group not implemented!\n");
}
private:
//! Find the corresponding instruction op
virtual Core::Instruction *look_up (PPC_Instr_T) {return NULL;}
private:
//! Groups of instruction with same op code
//! within each group(first 6 bits)
static Core::Instruction* op_table_[];
};
typedef PPC_Singleton<S_Group_f_1> op_group_f_1;
class S_Group_f_2 : public PPC_Instruction_Subset
{
public:
S_Group_f_2() {}
virtual ~S_Group_f_2() {}
virtual void execute (PPC_Instr_T instr)
{
//PPC_Instruction_Subset::execute(instr);
PPC_ERROR("float group not implemented!\n");
}
private:
//! Find the corresponding instruction op
virtual Core::Instruction *look_up (PPC_Instr_T) {return NULL;}
private:
//! Groups of instruction with same op code
//! within each group(first 6 bits)
static Core::Instruction* op_table_[];
};
typedef PPC_Singleton<S_Group_f_2> op_group_f_2;
} // namespace PPC
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -