src/Interface/OpClass.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 //
00033 // NX
00034 // OpClassCode lOpClass C
00035 // C^[tF[Xタ
00036 //
00037 
00038 #ifndef __OPCLASS_H__
00039 #define __OPCLASS_H__
00040 
00041 #include <string>
00042 #include "Types.h"
00043 #include "SysDeps/Inline.h"
00044 #include "Interface/OpClassCode.h"
00045 
00046 namespace Onikiri 
00047 {
00048 
00049     class OpClass
00050     {
00051         OpClassCode::OpClassCode m_code;
00052         int m_opClassBits;
00053 
00054         static const int MASK_BRANCH                = 1 << 0;
00055         static const int MASK_CONDITIONAL_BRANCH    = 1 << 1;
00056         static const int MASK_UNCONDITIONAL_BRANCH  = 1 << 2;
00057         static const int MASK_INDIRECT_JUMP         = 1 << 3;
00058         static const int MASK_CALL                  = 1 << 4;
00059         static const int MASK_RETURN                = 1 << 5;
00060         static const int MASK_SUBROUTINE            = 1 << 6;
00061         static const int MASK_MEM       = 1 << 7;
00062         static const int MASK_LOAD      = 1 << 8;
00063         static const int MASK_STORE     = 1 << 9;
00064         static const int MASK_ADDR      = 1 << 10;
00065         static const int MASK_INT       = 1 << 11;
00066         static const int MASK_FLOAT     = 1 << 12;
00067         static const int MASK_IFCONV    = 1 << 13;
00068         static const int MASK_SYSCALL   = 1 << 14;
00069         static const int MASK_NOP       = 1 << 15;
00070 
00071         INLINE bool BitTest( int mask ) const
00072         {
00073             return m_opClassBits & mask ? true : false;
00074         }
00075 
00076     public:
00077         OpClass( OpClassCode::OpClassCode code ) : m_code(code)
00078         {
00079             m_opClassBits = 0;
00080             m_opClassBits |= OpClassCode::IsBranch( code )              ? MASK_BRANCH : 0;
00081             m_opClassBits |= OpClassCode::IsConditionalBranch( code )   ? MASK_CONDITIONAL_BRANCH : 0;
00082             m_opClassBits |= OpClassCode::IsUnconditionalBranch( code ) ? MASK_UNCONDITIONAL_BRANCH : 0;
00083             m_opClassBits |= OpClassCode::IsIndirectJump( code )        ? MASK_INDIRECT_JUMP : 0;
00084             m_opClassBits |= OpClassCode::IsCall( code )                ? MASK_CALL      : 0;
00085             m_opClassBits |= OpClassCode::IsReturn( code )              ? MASK_RETURN    : 0;
00086             m_opClassBits |= OpClassCode::IsSubroutine( code )          ? MASK_SUBROUTINE : 0;
00087             m_opClassBits |= OpClassCode::IsMem( code )                 ? MASK_MEM      : 0;
00088             m_opClassBits |= OpClassCode::IsLoad( code )                ? MASK_LOAD     : 0;
00089             m_opClassBits |= OpClassCode::IsStore( code )               ? MASK_STORE    : 0;
00090             m_opClassBits |= OpClassCode::IsAddr( code )                ? MASK_ADDR     : 0;
00091             m_opClassBits |= OpClassCode::IsInt( code )                 ? MASK_INT      : 0;
00092             m_opClassBits |= OpClassCode::IsFloat( code )               ? MASK_FLOAT    : 0;
00093             m_opClassBits |= OpClassCode::IsIFConversion( code )        ? MASK_IFCONV   : 0;
00094             m_opClassBits |= OpClassCode::IsSyscall( code )             ? MASK_SYSCALL  : 0;
00095             m_opClassBits |= OpClassCode::IsNop( code )                 ? MASK_NOP      : 0;
00096         }
00097 
00098         ~OpClass() {}
00099 
00100         // A
00101         OpClassCode::OpClassCode GetCode() const
00102         {
00103             return m_code;
00104         }
00105 
00106         // ijumpj
00107         bool IsBranch() const
00108         {   return BitTest( MASK_BRANCH );  }
00109 
00110         // Note: CConditional, IndirectJump, Call r
00111         //       ReturnCall/JumprCConditional Return
00112         // 
00113         bool IsConditionalBranch()  const   
00114         {   return BitTest( MASK_CONDITIONAL_BRANCH );      }
00115         
00116         bool IsUnconditionalBranch() const  
00117         {   return BitTest( MASK_UNCONDITIONAL_BRANCH );    }
00118 
00119         // jump 
00120         bool IsIndirectJump()   const       
00121         {   return BitTest( MASK_INDIRECT_JUMP );           }
00122 
00123         // call
00124         bool IsCall() const 
00125         {   return BitTest( MASK_CALL );        }
00126 
00127         // return
00128         bool IsReturn()     const 
00129         {   return BitTest( MASK_RETURN );      }
00130 
00131         bool IsSubroutine() const
00132         {   return BitTest( MASK_SUBROUTINE );  }
00133 
00134         // 
00135         bool IsMem() const  
00136         {   return BitTest( MASK_MEM );     }
00137 
00138         // [h
00139         bool IsLoad() const
00140         {   return BitTest( MASK_LOAD );    }
00141 
00142         // XgA
00143         bool IsStore() const
00144         {   return BitTest( MASK_STORE );   }
00145 
00146         // [h
00147         bool IsAddr() const
00148         {   return BitTest( MASK_ADDR );    }
00149 
00150         // 
00151         bool IsInt() const 
00152         {   return BitTest( MASK_INT );     }
00153 
00154         // _
00155         bool IsFloat() const 
00156         {   return BitTest( MASK_FLOAT );   }
00157 
00158         //  <-> _
00159         bool IsIFConversion() const 
00160         {   return BitTest( MASK_IFCONV );  }
00161 
00162         // VXeR[PタsBA
00163         // VXeR[タsO^CAA
00164         // VXeR[^CAtFb`
00165         bool IsSyscall() const
00166         {   return BitTest( MASK_SYSCALL ); }
00167 
00168         // NOP
00169         bool IsNop() const  
00170         {   return BitTest( MASK_NOP );     }
00171 
00172 
00173         static int GetMaxCode() 
00174         {
00175             return OpClassCode::Code_MAX;
00176         }
00177 
00178         // fobO
00179         const std::string ToString() const
00180         {
00181             return OpClassCode::ToString( m_code );
00182         }
00183     };
00184 
00185 }; // namespace Onikiri
00186 
00187 #endif // __OPCLASS_H__
00188 

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