src/Emu/Utility/CommonOpInfo.h

説明を見る。
00001 // 
00002 // Copyright (c) 2005-2008 Kenichi Watanabe.
00003 // Copyright (c) 2005-2008 Yasuhiro Watari.
00004 // Copyright (c) 2005-2008 Hironori Ichibayashi.
00005 // Copyright (c) 2008-2009 Kazuo Horio.
00006 // Copyright (c) 2009-2013 Naruki Kurata.
00007 // Copyright (c) 2005-2013 Ryota Shioya.
00008 // Copyright (c) 2005-2013 Masahiro Goshima.
00009 // 
00010 // This software is provided 'as-is', without any express or implied
00011 // warranty. In no event will the authors be held liable for any damages
00012 // arising from the use of this software.
00013 // 
00014 // Permission is granted to anyone to use this software for any purpose,
00015 // including commercial applications, and to alter it and redistribute it
00016 // freely, subject to the following restrictions:
00017 // 
00018 // 1. The origin of this software must not be misrepresented; you must not
00019 // claim that you wrote the original software. If you use this software
00020 // in a product, an acknowledgment in the product documentation would be
00021 // appreciated but is not required.
00022 // 
00023 // 2. Altered source versions must be plainly marked as such, and must not be
00024 // misrepresented as being the original software.
00025 // 
00026 // 3. This notice may not be removed or altered from any source
00027 // distribution.
00028 // 
00029 // 
00030 
00031 
00032 #ifndef EMU_UTILITY_COMMON_OP_INFO_H
00033 #define EMU_UTILITY_COMMON_OP_INFO_H
00034 
00035 #include "Utility/RuntimeError.h"
00036 #include "Interface/OpInfo.h"
00037 #include "Interface/OpStateIF.h"
00038 #include "Interface/ExtraOpDecoderIF.h"
00039 #include "Interface/OpClass.h"
00040 
00041 
00042 namespace Onikiri 
00043 {
00044     namespace EmulatorUtility 
00045     {
00046 
00047         class OpEmulationState;
00048 
00049 
00050         template<class TISAInfo>
00051         class CommonOpInfo : public OpInfo
00052         {
00053         public:
00054             static const int MaxSrcRegCount = TISAInfo::MaxSrcRegCount;
00055             static const int MaxDstRegCount = TISAInfo::MaxDstRegCount;
00056             static const int MaxImmCount = TISAInfo::MaxImmCount;
00057             static const int MaxSrcCount = MaxSrcRegCount + MaxImmCount;
00058             static const int MaxDstCount = MaxDstRegCount;
00059             enum OperandType { NONE, REG, IMM, ZERO };  // ZERO  dstp
00060             typedef void (*EmulationFunc)(OpEmulationState*);
00061 
00062             explicit CommonOpInfo(OpClass opClass) : 
00063                 m_opClass(opClass),
00064                 m_emulationFunc(0), 
00065                 m_srcRegNum(0), 
00066                 m_dstRegNum(0), 
00067                 m_srcOpNum(0), 
00068                 m_dstOpNum(0),
00069                 m_immNum(0), 
00070                 m_microOpNum(0), 
00071                 m_microOpIndex(0), 
00072                 m_mnemonic("")
00073             {
00074                 std::fill(m_srcReg.begin(), m_srcReg.end(), -1);
00075                 std::fill(m_dstReg.begin(), m_dstReg.end(), -1);
00076                 std::fill(m_imm.begin(), m_imm.end(), -1);
00077 
00078                 std::fill(m_srcRegOpMap.begin(), m_srcRegOpMap.end(), -1);
00079                 std::fill(m_dstRegOpMap.begin(), m_dstRegOpMap.end(), -1);
00080                 std::fill(m_immOpMap.begin(), m_immOpMap.end(), -1);
00081             }
00082             virtual ~CommonOpInfo()
00083             {
00084             }
00085 
00086             int GetSrcReg(int index) { return m_srcReg[index]; }
00087             void SetSrcReg(int index, int value) 
00088             {
00089                 assert( index < MaxSrcRegCount );   // For avoiding gcc's warning.
00090                 m_srcReg[index] = value; 
00091             }
00092 
00093             int GetDstReg(int index) { return m_dstReg[index]; }
00094             void SetDstReg(int index, int value) 
00095             {
00096                 assert( index < MaxDstRegCount );   // For avoiding gcc's warning.
00097                 m_dstReg[index] = value; 
00098             }
00099 
00100             s64 GetImm(int index) { return m_imm[index]; }
00101             void SetImm(int index, s64 value)
00102             {
00103                 assert( index < MaxImmCount );  // For avoiding gcc's warning.
00104                 m_imm[index] = value; 
00105             }
00106 
00107             EmulationFunc GetEmulationFunc() const { return m_emulationFunc; }
00108             void SetEmulationFunc(EmulationFunc func) { m_emulationFunc = func; }
00109 
00110             //  
00111             void SetSrcRegOpMap(int index, int value)
00112             {
00113                 assert( index < MaxSrcCount );  // For avoiding gcc's warning.
00114                 m_srcRegOpMap[index] = value; 
00115             }
00116             int GetSrcRegOpMap(int index) const { return m_srcRegOpMap[index]; }
00117 
00118             void SetImmOpMap(int index, int value) 
00119             {
00120                 assert( index < MaxImmCount );  // For avoiding gcc's warning.
00121                 m_immOpMap[index] = value; 
00122             }
00123             int GetImmOpMap(int index) const { return m_immOpMap[index]; }
00124 
00125             void SetDstRegOpMap(int index, int value) 
00126             {
00127                 assert( index < MaxDstCount );  // For avoiding gcc's warning.
00128                 m_dstRegOpMap[index] = value; 
00129             }
00130             int GetDstRegOpMap(int index) const { return m_dstRegOpMap[index]; }
00131 
00132             // \[XEfXeBl[VEIyh
00133             void SetSrcOpNum(int n) { m_srcOpNum = n; }
00134             int GetSrcOpNum() const { return m_srcOpNum; }
00135             void SetDstOpNum(int n) { m_dstOpNum = n; }
00136             int GetDstOpNum() const { return m_dstOpNum; }
00137 
00138             // l
00139             void SetImmNum(int n) { m_immNum = n; }
00140             int GetImmNum() const { return m_immNum; }
00141 
00142             // \[XEfXeBl[VuWX^v
00143             void SetSrcRegNum(int n) { m_srcRegNum = n; }
00144             void SetDstRegNum(int n) { m_dstRegNum = n; }
00145 
00146             int GetSrcRegNum() const { return m_srcRegNum; }    // non-virtual  GetSrcNum
00147             int GetDstRegNum() const { return m_dstRegNum; }
00148 
00149             // The number of micro-ops for its instruction.
00150             void SetMicroOpNum( int microOpNum )    {   m_microOpNum = microOpNum;      }
00151             void SetMicroOpIndex( int microOpIndex ){   m_microOpIndex = microOpIndex;  }
00152 
00153             // j[jbN (|C^Iw)
00154             void SetMnemonic(const char* mnemonic) { m_mnemonic = mnemonic; }
00155 
00156             // --- Implementation of OpInfo
00157             virtual const OpClass& GetOpClass() const
00158             {
00159                 return m_opClass;
00160             }
00161             virtual int GetSrcOperand(const int index) const
00162             {
00163                 assert(index < MaxSrcRegCount);
00164                 return m_srcReg[index];
00165             }
00166             virtual int GetDstOperand(const int index) const
00167             {
00168                 assert(index < MaxDstRegCount);
00169                 return m_dstReg[index];
00170             }
00171             virtual int GetSrcNum() const
00172             {
00173                 return m_srcRegNum;
00174             }
00175             virtual int GetDstNum() const
00176             {
00177                 return m_dstRegNum;
00178             }
00179 
00180             // The number of micro-ops for its instruction.
00181             virtual int GetMicroOpNum() const
00182             {
00183                 return m_microOpNum;
00184             }
00185 
00186             // The position of this micro op in its instruction.
00187             virtual int GetMicroOpIndex() const
00188             {
00189                 return m_microOpIndex;
00190             }
00191 
00192             virtual const char* GetMnemonic() const
00193             {
00194                 return m_mnemonic;
00195             }
00196 
00197         protected:
00198             OpClass m_opClass;
00199             
00200             // タs
00201             EmulationFunc m_emulationFunc;
00202             // \[XWX^
00203             boost::array<int, MaxSrcRegCount> m_srcReg;
00204             // fXeBl[VWX^
00205             boost::array<int, MaxDstRegCount> m_dstReg;
00206             // l
00207             boost::array<s64, MaxImmCount>    m_imm;
00208             // srcReg
00209             int m_srcRegNum;
00210             // dstReg
00211             int m_dstRegNum;
00212 
00213             // src
00214             int m_srcOpNum;
00215             // dst
00216             int m_dstOpNum;
00217             // imm
00218             int m_immNum;
00219 
00220             int m_microOpNum;   // The number of micro-ops for its instruction.
00221             int m_microOpIndex; // The position of this micro op in its instruction.
00222 
00223             // j[jbN
00224             const char* m_mnemonic;
00225 
00226             // m_srcReg, m_imm, m_dstReg Cm_src, m_dst
00227             // m_srcReg[i]WX^  m_src[ m_srcRegOpMap ] i[Dl
00228             boost::array<int, MaxSrcCount> m_srcRegOpMap;
00229             boost::array<int, MaxDstCount> m_dstRegOpMap;
00230             boost::array<int, MaxImmCount> m_immOpMap;
00231         };
00232 
00233     } // namespace EmulatorUtility
00234 } // namespace Onikiri
00235 
00236 #endif
00237 

Onikiri2に対してTue Jun 18 14:34:20 2013に生成されました。  doxygen 1.4.7