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 __OPCLASSCODE_H__ 00033 #define __OPCLASSCODE_H__ 00034 00035 #include "Types.h" 00036 00037 namespace Onikiri { 00038 00039 // 00040 namespace OpClassCode 00041 { 00042 enum OpClassCode 00043 { 00044 CALL = 0, // subroutine call 00045 CALL_JUMP, // indirect subroutine call 00046 RET, // return from subroutine 00047 RETC, // return from subroutine conditional 00048 00049 INT_BEGIN, 00050 iBC = INT_BEGIN, // integer conditional branch 00051 iBU, // integer unconditional branch 00052 iJUMP, // integer unconditional jump 00053 00054 iLD, // integer load 00055 iST, // integer store 00056 iIMM, // integer set immediate 00057 iMOV, // integer move 00058 iALU, // integer Arithmetic/Logic 00059 iSFT, // (integer) shift 00060 iMUL, // integer multiply 00061 iDIV, // integer divide 00062 iBYTE, // (integer) byte ops 00063 INT_END = iBYTE, 00064 00065 FLOAT_BEGIN, 00066 fBC = FLOAT_BEGIN, // FP branch (conditional) 00067 fLD, // FP load 00068 fST, // FP store 00069 fMOV, // FP move 00070 fNEG, // FP negate 00071 fADD, // FP add/sub 00072 fMUL, // FP multiply 00073 fDIV, // FP divide 00074 fCONV, // FP convert 00075 fELEM, // FP elementary functions (SQRT, SIN, COS, etc) 00076 FLOAT_END = fELEM, 00077 00078 ifCONV, // INT <-> FP conversion 00079 00080 syscall, // system call 00081 syscall_branch, // system call with branch 00082 00083 ADDR, // address calculation 00084 00085 // EXEC_END = ADDR, // タsinsncode 00086 00087 iNOP, // NOP 00088 fNOP, // floating NOP 00089 00090 UNDEF, // undefined operation 00091 00092 other, // ??? 00093 00094 Code_MAX = other 00095 }; 00096 00097 // OpClassCode c C 00098 const char* ToString(int c); 00099 00100 // s COpClassCode DOpClassCode O 00101 int FromString(const char *s); 00102 00103 00104 // ijumpj 00105 bool IsBranch( int code ); 00106 00107 // Note: CConditional, IndirectJump, Call r 00108 // ReturnCall/JumprCConditional Return 00109 // 00110 bool IsConditionalBranch( int code ); 00111 bool IsUnconditionalBranch( int code ); 00112 00113 // jump 00114 bool IsIndirectJump( int code ); 00115 00116 // call 00117 bool IsCall( int code ); 00118 00119 // return 00120 bool IsReturn( int code ); 00121 00122 // Tu[` 00123 bool IsSubroutine( int code ); 00124 00125 // 00126 bool IsMem( int code ); 00127 00128 // [h 00129 bool IsLoad( int code ); 00130 00131 // XgA 00132 bool IsStore( int code ); 00133 00134 // Address calculation 00135 bool IsAddr( int code ); 00136 00137 // 00138 bool IsInt( int code ); 00139 00140 // _ 00141 bool IsFloat( int code ); 00142 00143 // <-> _ 00144 bool IsIFConversion( int code ); 00145 00146 // VXeR[PタsBA 00147 // VXeR[タsO^CAA 00148 // VXeR[^CAtFb` 00149 bool IsSyscall( int code ); 00150 00151 // Nop 00152 bool IsNop( int code ); 00153 00154 } 00155 }; // namespace Onikiri 00156 00157 #endif 00158