📄 instruction_subset.cpp
字号:
/* -*- C++ -*- */
/**
* 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.
*/
///==================================================
/**
* @file Instruction_Subset.cpp
* @brief
* @author Chenfeng Zhou <ini_autumn@163.com>
*
* Created : <2005-02-15 23:35:50 by Cheney Chow>
* Last update: <2005-03-10 20:53:42 by Cheney Chow>
*
* $Id: Instruction_Subset.cpp,v 1.1 2005/06/16 06:01:46 qilj Exp $
*/
///==================================================
#include "Instruction_Subset.h"
#include "Instr_Declare.h"
#include "Utils/Debug.h"
namespace PPC
{
//! Second level execution;
void PPC_Instruction_Subset::execute (PPC_Instr_T instr)
{
look_up (instr)->execute (instr);
}
// Group 1
Core::Instruction *S_Group_1::look_up (PPC_Instr_T instr)
{
Core::u32 ext = extract_ext(instr);
if (ext & 1) {
switch(ext) {
case 33: return op_crnor::instance();
case 129: return op_crandc::instance();
case 193: return op_crxor::instance();
case 225: return op_crnand::instance();
case 257: return op_crand::instance();
case 289: return op_creqv::instance();
case 417: return op_crorc::instance();
case 449: return op_cror::instance();
}
}
else if(ext & (1 << 9)) {
if (ext == 528)
return op_bcctrx::instance();
}
else {
switch(ext) {
case 16: return op_bclrx::instance();
case 0: return op_mcrf::instance();
case 50: return op_rfi::instance();
case 150:return op_isync::instance();
}
}
return op_invalid::instance();
}
// Group 2
//? Really need explicit initialization?
Core::Instruction* S_Group_2::op_table_[TABLE_SIZE] = {};
S_Group_2::S_Group_2 ()
{
init_op_table ();
}
Core::Instruction *S_Group_2::look_up (PPC_Instr_T instr)
{
Core::u32 ext = extract_ext(instr);
if (ext >= TABLE_SIZE) {
PPC_ERROR("Out of table index!\n");
return op_invalid::instance();
}
return op_table_[ext];
}
void S_Group_2::init_op_table ()
{
for (int i = 0; i < TABLE_SIZE; ++i) {
op_table_[i] = op_invalid::instance ();
}
op_table_[0] = op_cmp::instance ();
op_table_[4] = op_tw::instance ();
op_table_[8] = op_subfcx::instance ();
op_table_[10] = op_addcx::instance ();
op_table_[11] = op_mulhwux::instance();
op_table_[19] = op_mfcr::instance();
op_table_[20] = op_lwarx::instance();
op_table_[23] = op_lwzx::instance();
op_table_[24] = op_slwx::instance();
op_table_[26] = op_cntlzwx::instance();
op_table_[28] = op_andx::instance();
op_table_[32] = op_cmpl::instance();
op_table_[40] = op_subfx::instance();
op_table_[54] = op_dcbst::instance();
op_table_[55] = op_lwzux::instance();
op_table_[60] = op_andcx::instance();
op_table_[75] = op_mulhwx::instance();
op_table_[83] = op_mfmsr::instance();
op_table_[86] = op_dcbf::instance();
op_table_[87] = op_lbzx::instance();
op_table_[104] = op_negx::instance();
op_table_[119] = op_lbzux::instance();
op_table_[124] = op_norx::instance();
op_table_[136] = op_subfex::instance();
op_table_[138] = op_addex::instance();
op_table_[144] = op_mtcrf::instance();
op_table_[146] = op_mtmsr::instance();
op_table_[150] = op_stwcx_::instance();
op_table_[151] = op_stwx::instance();
op_table_[183] = op_stwux::instance();
op_table_[200] = op_subfzex::instance();//+
op_table_[202] = op_addzex::instance();//+
op_table_[210] = op_mtsr::instance();
op_table_[215] = op_stbx::instance();
op_table_[232] = op_subfmex::instance();//+
op_table_[234] = op_addmex::instance();
op_table_[235] = op_mullwx::instance();//+
op_table_[242] = op_mtsrin::instance();
op_table_[246] = op_dcbtst::instance();
op_table_[247] = op_stbux::instance();
op_table_[266] = op_addx::instance();//+
op_table_[278] = op_dcbt::instance();
op_table_[279] = op_lhzx::instance();
op_table_[284] = op_eqvx::instance();
op_table_[306] = op_tlbie::instance();
op_table_[310] = op_eciwx::instance();
op_table_[311] = op_lhzux::instance();
op_table_[316] = op_xorx::instance();
op_table_[339] = op_mfspr::instance();
op_table_[343] = op_lhax::instance();
op_table_[370] = op_tlbia::instance();
op_table_[371] = op_mftb::instance();
op_table_[375] = op_lhaux::instance();
op_table_[407] = op_sthx::instance();
op_table_[412] = op_orcx::instance();
op_table_[438] = op_ecowx::instance();
op_table_[439] = op_sthux::instance();
op_table_[444] = op_orx::instance();
op_table_[459] = op_divwux::instance();//+
op_table_[467] = op_mtspr::instance();
op_table_[470] = op_dcbi::instance();
op_table_[476] = op_nandx::instance();
op_table_[491] = op_divwx::instance();//+
op_table_[512] = op_mcrxr::instance();
op_table_[533] = op_lswx::instance();
op_table_[534] = op_lwbrx::instance();
op_table_[535] = op_lfsx::instance();
op_table_[536] = op_srwx::instance();
op_table_[566] = op_tlbsync::instance();
op_table_[567] = op_lfsux::instance();
op_table_[595] = op_mfsr::instance();
op_table_[597] = op_lswi::instance();
op_table_[598] = op_sync::instance();
op_table_[599] = op_lfdx::instance();
op_table_[631] = op_lfdux::instance();
op_table_[659] = op_mfsrin::instance();
op_table_[661] = op_stswx::instance();
op_table_[662] = op_stwbrx::instance();
op_table_[663] = op_stfsx::instance();
op_table_[695] = op_stfsux::instance();
op_table_[725] = op_stswi::instance();
op_table_[727] = op_stfdx::instance();
op_table_[759] = op_stfdux::instance();
op_table_[790] = op_lhbrx::instance();
op_table_[792] = op_srawx::instance();
op_table_[824] = op_srawix::instance();
op_table_[854] = op_eieio::instance();
op_table_[914] = op_tlbsx::instance();
op_table_[918] = op_sthbrx::instance();
op_table_[922] = op_extshx::instance();
op_table_[946] = op_tlbre::instance();
op_table_[954] = op_extsbx::instance();
op_table_[978] = op_tlbwe::instance();
op_table_[982] = op_icbi::instance();
op_table_[983] = op_stfiwx::instance();
op_table_[1014] = op_dcbz::instance();
}
} // namespace PPC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -