[184] | 1 | #pragma once
|
---|
| 2 |
|
---|
[225] | 3 | #include <NativeCode.h>
|
---|
[248] | 4 | #include <LexicalScope.h>
|
---|
[225] | 5 |
|
---|
| 6 | #ifdef _AMD64_
|
---|
| 7 | #include "../../BasicCompiler64/MachineFixed.h"
|
---|
| 8 | #else
|
---|
| 9 | #include "../../BasicCompiler32/MachineFixed.h"
|
---|
| 10 | #endif
|
---|
| 11 |
|
---|
[184] | 12 | void ReallocNativeCodeBuffer();
|
---|
[225] | 13 |
|
---|
[248] | 14 | // コード生成時の部分的なスケジューリング
|
---|
| 15 | class PertialSchedule
|
---|
[225] | 16 | {
|
---|
[248] | 17 | int codePos; // バッファ位置
|
---|
| 18 | int typeSize; // 対象サイズ(一般的には8bit/32bit)
|
---|
[225] | 19 |
|
---|
[248] | 20 | int _obpOld; // 未完成
|
---|
[237] | 21 | public:
|
---|
[248] | 22 | PertialSchedule( int codePos, int typeSize )
|
---|
| 23 | : codePos( codePos )
|
---|
| 24 | , typeSize( typeSize )
|
---|
| 25 | {
|
---|
| 26 | extern int obp;
|
---|
| 27 | _obpOld = obp;
|
---|
| 28 | }
|
---|
| 29 | ~PertialSchedule()
|
---|
| 30 | {
|
---|
| 31 | }
|
---|
[238] | 32 |
|
---|
[248] | 33 | int GetCodePos() const
|
---|
[237] | 34 | {
|
---|
[248] | 35 | return codePos;
|
---|
| 36 | }
|
---|
| 37 | int GetTypeSize() const
|
---|
| 38 | {
|
---|
| 39 | return typeSize;
|
---|
| 40 | }
|
---|
| 41 | int GetObpOld() const
|
---|
| 42 | {
|
---|
| 43 | return _obpOld;
|
---|
| 44 | }
|
---|
| 45 | };
|
---|
| 46 | typedef std::vector<const PertialSchedule *> PertialSchedules;
|
---|
[238] | 47 |
|
---|
[253] | 48 | //Goto未知ラベル
|
---|
| 49 | class GotoLabelSchedule : public PertialSchedule
|
---|
| 50 | {
|
---|
| 51 | std::string name;
|
---|
| 52 | int line;
|
---|
| 53 | int sourceCodePos;
|
---|
| 54 | public:
|
---|
| 55 | GotoLabelSchedule( const std::string &name, int nativeCodePos, int sourceCodePos )
|
---|
| 56 | : PertialSchedule( nativeCodePos, sizeof(long) )
|
---|
| 57 | , name( name )
|
---|
| 58 | , line( -1 )
|
---|
| 59 | , sourceCodePos( sourceCodePos )
|
---|
| 60 | {
|
---|
| 61 | }
|
---|
| 62 | GotoLabelSchedule( int line, int nativeCodePos, int sourceCodePos )
|
---|
| 63 | : PertialSchedule( nativeCodePos, sizeof(long) )
|
---|
| 64 | , line( line )
|
---|
| 65 | , sourceCodePos( sourceCodePos )
|
---|
| 66 | {
|
---|
| 67 | }
|
---|
| 68 | const std::string &GetName() const
|
---|
| 69 | {
|
---|
| 70 | return name;
|
---|
| 71 | }
|
---|
| 72 | int GetLineNum() const
|
---|
| 73 | {
|
---|
| 74 | return line;
|
---|
| 75 | }
|
---|
| 76 | int GetSourceCodePos() const
|
---|
| 77 | {
|
---|
| 78 | return sourceCodePos;
|
---|
| 79 | }
|
---|
| 80 | };
|
---|
| 81 | typedef std::vector<const GotoLabelSchedule *> GotoLabelSchedules;
|
---|
| 82 |
|
---|
[261] | 83 | //ラベルアドレス
|
---|
| 84 | class GotoLabel
|
---|
| 85 | {
|
---|
| 86 | public:
|
---|
| 87 | std::string name;
|
---|
| 88 | int line;
|
---|
| 89 | DWORD address;
|
---|
| 90 |
|
---|
| 91 | GotoLabel( const std::string &name, long nativeCodePos )
|
---|
| 92 | : name( name )
|
---|
| 93 | , line( -1 )
|
---|
| 94 | , address( nativeCodePos )
|
---|
| 95 | {
|
---|
| 96 | }
|
---|
| 97 | GotoLabel( int line, long nativeCodePos )
|
---|
| 98 | : name( "" )
|
---|
| 99 | , line( line )
|
---|
| 100 | , address( nativeCodePos )
|
---|
| 101 | {
|
---|
| 102 | }
|
---|
| 103 | };
|
---|
| 104 | typedef std::vector<GotoLabel> GotoLabels;
|
---|
| 105 |
|
---|
[248] | 106 | class LexicalScope
|
---|
| 107 | {
|
---|
| 108 | public:
|
---|
| 109 | enum SCOPE_TYPE{
|
---|
| 110 | //ベース
|
---|
| 111 | SCOPE_TYPE_BASE,
|
---|
[237] | 112 |
|
---|
[248] | 113 | //分岐
|
---|
| 114 | SCOPE_TYPE_IF,
|
---|
| 115 |
|
---|
| 116 | //ループ
|
---|
| 117 | SCOPE_TYPE_DO,
|
---|
| 118 | SCOPE_TYPE_FOR,
|
---|
| 119 | SCOPE_TYPE_WHILE,
|
---|
| 120 |
|
---|
| 121 | //ケース分け
|
---|
| 122 | SCOPE_TYPE_SELECT,
|
---|
[237] | 123 | };
|
---|
| 124 |
|
---|
[225] | 125 | private:
|
---|
[248] | 126 | int level;
|
---|
| 127 | int StartAddress;
|
---|
| 128 | SCOPE_TYPE TypeOfStatement;
|
---|
| 129 |
|
---|
| 130 | PertialSchedules breakPertialSchedules;
|
---|
| 131 |
|
---|
| 132 | public:
|
---|
| 133 | LexicalScope( int level, int addr, SCOPE_TYPE TypeOfStatement )
|
---|
| 134 | : level( level )
|
---|
| 135 | , StartAddress( addr )
|
---|
| 136 | , TypeOfStatement( TypeOfStatement )
|
---|
| 137 | {
|
---|
| 138 | }
|
---|
| 139 | ~LexicalScope()
|
---|
| 140 | {
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | int GetStartAddress()
|
---|
| 144 | {
|
---|
| 145 | return StartAddress;
|
---|
| 146 | }
|
---|
| 147 | SCOPE_TYPE GetTypeOfStatement()
|
---|
| 148 | {
|
---|
| 149 | return TypeOfStatement;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | void Break();
|
---|
| 153 | void RunScheduleOfBreak();
|
---|
| 154 | };
|
---|
| 155 |
|
---|
| 156 | class LexicalScopes
|
---|
| 157 | {
|
---|
| 158 | LexicalScope **ppScopes;
|
---|
| 159 | int level;
|
---|
| 160 |
|
---|
| 161 | public:
|
---|
| 162 |
|
---|
| 163 | LexicalScopes(){
|
---|
| 164 | ppScopes = (LexicalScope **)malloc( 1 );
|
---|
| 165 | level=0;
|
---|
| 166 | }
|
---|
| 167 | ~LexicalScopes(){
|
---|
| 168 | free( ppScopes );
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | //初期化(関数コンパイルの開始時に呼び出される)
|
---|
| 172 | void Init(int addr);
|
---|
| 173 |
|
---|
| 174 | // スコープを開始
|
---|
| 175 | void Start( int addr, LexicalScope::SCOPE_TYPE TypeOfStatement );
|
---|
| 176 |
|
---|
| 177 | // スコープを検索
|
---|
| 178 | LexicalScope *SearchScope( LexicalScope::SCOPE_TYPE TypeOfStatement );
|
---|
| 179 |
|
---|
| 180 | int GetNowLevel(void);
|
---|
| 181 | void SetNowLevel( int level );
|
---|
| 182 | int GetStartAddress(void);
|
---|
| 183 |
|
---|
| 184 | void End();
|
---|
| 185 |
|
---|
| 186 | //スコープ終了時のデストラクタ呼び出し
|
---|
| 187 | void CallDestructorsOfScopeEnd();
|
---|
| 188 |
|
---|
| 189 | //Returnステートメント用のデストラクタ呼び出し
|
---|
| 190 | void CallDestructorsOfReturn( int BaseLevel = 0 );
|
---|
| 191 | };
|
---|
| 192 |
|
---|
| 193 | class CodeGenerator
|
---|
| 194 | {
|
---|
| 195 | NativeCode *pNativeCode;
|
---|
| 196 |
|
---|
| 197 | private:
|
---|
[241] | 198 | // 部分スケジュールの管理
|
---|
[237] | 199 | PertialSchedules pertialSchedules;
|
---|
| 200 |
|
---|
[241] | 201 | // Continue用のコード位置情報の管理
|
---|
| 202 | std::vector<long> continueCodePositions;
|
---|
| 203 | std::vector<long> _continueCodePositions_ObpOld;
|
---|
| 204 |
|
---|
[237] | 205 | public:
|
---|
| 206 |
|
---|
[253] | 207 | // ローカル変数用スケジュールの管理
|
---|
| 208 | PertialSchedules localVarPertialSchedules;
|
---|
| 209 |
|
---|
[247] | 210 | // Exit Subスケジュールの管理
|
---|
| 211 | std::vector<long> exitSubCodePositions;
|
---|
| 212 | std::vector<int> _exitSubCodePositions_ObpOld;
|
---|
| 213 |
|
---|
[246] | 214 | // Gotoスケジュールの管理
|
---|
[261] | 215 | GotoLabels gotoLabels;
|
---|
[253] | 216 | GotoLabelSchedules gotoLabelSchedules;
|
---|
[246] | 217 |
|
---|
[248] | 218 | // レキシカルスコープの管理
|
---|
| 219 | LexicalScopes lexicalScopes;
|
---|
| 220 |
|
---|
[237] | 221 | CodeGenerator()
|
---|
| 222 | : pNativeCode( 0 )
|
---|
[225] | 223 | {
|
---|
| 224 | }
|
---|
[237] | 225 | ~CodeGenerator()
|
---|
| 226 | {
|
---|
| 227 | if( pNativeCode )
|
---|
| 228 | {
|
---|
| 229 | CheckUnresolveSchedule();
|
---|
| 230 | }
|
---|
| 231 | }
|
---|
[225] | 232 |
|
---|
| 233 | void Select( NativeCode &nativeCode )
|
---|
| 234 | {
|
---|
[237] | 235 | if( pNativeCode )
|
---|
| 236 | {
|
---|
| 237 | CheckUnresolveSchedule();
|
---|
| 238 | }
|
---|
[225] | 239 | pNativeCode = &nativeCode;
|
---|
| 240 | }
|
---|
| 241 |
|
---|
[263] | 242 | void NextSourceLine()
|
---|
| 243 | {
|
---|
| 244 | pNativeCode->NextSourceLine();
|
---|
| 245 | }
|
---|
| 246 |
|
---|
[241] | 247 | long GetContinueCodePos() const
|
---|
| 248 | {
|
---|
| 249 | if( continueCodePositions.size() == 0 )
|
---|
| 250 | {
|
---|
| 251 | return -1;
|
---|
| 252 | }
|
---|
| 253 | return continueCodePositions[continueCodePositions.size()-1];
|
---|
| 254 | }
|
---|
| 255 | void ClearContinueArea()
|
---|
| 256 | {
|
---|
| 257 | continueCodePositions.clear();
|
---|
| 258 | _continueCodePositions_ObpOld.clear();
|
---|
| 259 | }
|
---|
| 260 | void ContinueAreaBegin()
|
---|
| 261 | {
|
---|
| 262 | continueCodePositions.push_back( pNativeCode->GetSize() );
|
---|
| 263 |
|
---|
| 264 | extern int obp;
|
---|
| 265 | _continueCodePositions_ObpOld.push_back( obp );
|
---|
| 266 | }
|
---|
| 267 | void ContinueAreaEnd()
|
---|
| 268 | {
|
---|
| 269 | continueCodePositions.pop_back();
|
---|
| 270 | _continueCodePositions_ObpOld.pop_back();
|
---|
| 271 | }
|
---|
| 272 | long GetContinueCodePosOld() const
|
---|
| 273 | {
|
---|
| 274 | if( _continueCodePositions_ObpOld.size() == 0 )
|
---|
| 275 | {
|
---|
| 276 | return -1;
|
---|
| 277 | }
|
---|
| 278 | return _continueCodePositions_ObpOld[_continueCodePositions_ObpOld.size()-1];
|
---|
| 279 | }
|
---|
[247] | 280 |
|
---|
| 281 | void ResolveExitSubSchedule();
|
---|
[241] | 282 |
|
---|
[237] | 283 | void CheckUnresolveSchedule();
|
---|
| 284 |
|
---|
[251] | 285 | void opfix( const PertialSchedule *pPertialSchedule, long newValue );
|
---|
[253] | 286 | void opfix_offset( const PertialSchedule *pPertialSchedule, long offset );
|
---|
[238] | 287 | void opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule );
|
---|
[237] | 288 |
|
---|
| 289 |
|
---|
| 290 | /////////////////////////////////////////////////////////////////
|
---|
| 291 | // 32bit/64bit共通 機械語生成
|
---|
| 292 | /////////////////////////////////////////////////////////////////
|
---|
| 293 |
|
---|
| 294 | private:
|
---|
[245] | 295 | const PertialSchedule *__jmp_op_format( char opcode, long offset, int op_size, bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
[237] | 296 | public:
|
---|
[250] | 297 | const PertialSchedule *op_jle( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 298 | const PertialSchedule *op_jbe( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 299 | const PertialSchedule *op_jge( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 300 | const PertialSchedule *op_jae( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 301 | const PertialSchedule *op_jl( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 302 | const PertialSchedule *op_jb( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 303 | const PertialSchedule *op_jg( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 304 | const PertialSchedule *op_ja( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 305 | const PertialSchedule *op_jne( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 306 | const PertialSchedule *op_je( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
[245] | 307 | const PertialSchedule *op_jmp( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
[241] | 308 | void op_jmp_continue();
|
---|
[247] | 309 | void op_jmp_exitsub();
|
---|
[253] | 310 | void op_jmp_goto_schedule( const std::string &name, int lineNum, int sourceCodePos );
|
---|
[237] | 311 |
|
---|
| 312 |
|
---|
[225] | 313 | #ifdef _AMD64_
|
---|
[228] | 314 | /////////////////////////////////////////////////////////////////
|
---|
[237] | 315 | // 64ビット機械語生成
|
---|
[228] | 316 | /////////////////////////////////////////////////////////////////
|
---|
[226] | 317 | private:
|
---|
| 318 | void set_rex(int op_size,int reg,int index_reg,int base_reg);
|
---|
[254] | 319 | const PertialSchedule *set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 320 | const PertialSchedule *__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 321 | public:
|
---|
[232] | 322 | void op_mov_RV (int op_size,int reg,long i32data, Schedule::Type scheduleType = Schedule::None );
|
---|
[226] | 323 | void op_mov_RV64 (int reg,_int64 i64data);
|
---|
[254] | 324 | const PertialSchedule *op_mov_RM (int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 325 | const PertialSchedule *op_mov_RM_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 326 | const PertialSchedule *op_mov_MR (int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 327 | const PertialSchedule *op_mov_MR_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 328 | const PertialSchedule *op_mov_MV (int op_size,int base_reg,int offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, BOOL bUseOffset,long i32data);
|
---|
[226] | 329 | void op_mov_RR (int reg1,int reg2);
|
---|
| 330 | void op_movsxd (int reg64,int reg32);
|
---|
| 331 | void op_movsx64_FromReg16 (int reg64,int reg16);
|
---|
| 332 | void op_movsx64_FromReg8 (int reg64,int reg8);
|
---|
| 333 | void op_movsx32_FromReg16 (int reg32,int reg16);
|
---|
| 334 | void op_movsx32_FromReg8 (int reg32,int reg8);
|
---|
| 335 | void op_movsx16_FromReg8 (int reg32,int reg8);
|
---|
[228] | 336 | void op_cqo ();
|
---|
[226] | 337 | void op_inc (int reg);
|
---|
| 338 | void op_dec (int reg);
|
---|
[254] | 339 | const PertialSchedule *op_add_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 340 | const PertialSchedule *op_add_RV (int reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[228] | 341 | void op_add_RR (int reg1,int reg2);
|
---|
[226] | 342 | void op_add32_reg (int reg1,int reg2);
|
---|
| 343 | void op_sub_RV (int op_size,int reg,long i32data);
|
---|
| 344 | void op_sub64_reg (int reg1,int reg2);
|
---|
| 345 | void op_sub32_reg (int reg1,int reg2);
|
---|
| 346 | void op_sbb_RR ( int op_size, int reg1, int reg2 );
|
---|
| 347 | void op_imul_RR (int op_size,int reg1,int reg2);
|
---|
| 348 | void op_imul_RV (int op_size,int reg,long i32data);
|
---|
| 349 | void op_div64_reg (int reg);
|
---|
| 350 | void op_idiv64_reg (int reg);
|
---|
| 351 | void op_shl_reg (int op_size,int reg);
|
---|
| 352 | void op_sar_reg (int op_size,int reg);
|
---|
| 353 | void op_shr_reg (int op_size,int reg);
|
---|
| 354 | void op_and_reg (int op_size,int reg1,int reg2);
|
---|
| 355 | void op_and64_value (int reg,long offset);
|
---|
| 356 | void op_and32_value (int reg,long offset);
|
---|
| 357 | void op_or_reg (int op_size,int reg1,int reg2);
|
---|
| 358 | void op_xor_reg (int op_size,int reg1,int reg2);
|
---|
| 359 | void op_not_reg (int op_size,int reg);
|
---|
| 360 | void op_neg ( int reg );
|
---|
| 361 | void op_test (int reg1,int reg2);
|
---|
| 362 | void op_cmp_reg (int op_size,int reg1,int reg2);
|
---|
| 363 | void op_cmp_value (int op_size,int reg,char byte_data);
|
---|
| 364 | void op_setne (int reg);
|
---|
[254] | 365 | const PertialSchedule *op_movlpd_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 366 | const PertialSchedule *op_movlpd_RM (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 367 | void op_movsd_RR (int xmm_reg1,int xmm_reg2);
|
---|
[254] | 368 | const PertialSchedule *op_movsd_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 369 | void op_movss_RR (int xmm_reg1,int xmm_reg2);
|
---|
[254] | 370 | const PertialSchedule *op_movss_RM (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 371 | const PertialSchedule *op_movss_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 372 | void op_movd_RX (int reg,int xmm_reg);
|
---|
| 373 | void op_cvtsd2ss (int xmm_reg1,int xmm_reg2);
|
---|
| 374 | void op_cvtss2sd (int xmm_reg1,int xmm_reg2);
|
---|
| 375 | void op_cvttsd2si_xmm (int op_size,int reg,int xmm_reg);
|
---|
| 376 | void op_cvttss2si_xmm (int op_size,int reg,int xmm_reg);
|
---|
| 377 | void op_cvtsi2sd_reg (int op_size,int xmm_reg,int reg);
|
---|
| 378 | void op_cvtsi2ss_reg (int op_size,int xmm_reg,int reg);
|
---|
| 379 | void op_comisd (int xmm_reg1,int xmm_reg2);
|
---|
| 380 | void op_comiss (int xmm_reg1,int xmm_reg2);
|
---|
| 381 | void op_rep_movs (int op_size);
|
---|
| 382 | void op_add_rsp(long num);
|
---|
[255] | 383 | const PertialSchedule *op_sub_rsp( long num, bool isPertialSchedule = false );
|
---|
[226] | 384 | void op_fld_ptr_esp(int type);
|
---|
| 385 | void op_zero_reg(int reg);
|
---|
| 386 | void op_call( const UserProc *pUserProc );
|
---|
| 387 | void op_call( const DllProc *pDllProc );
|
---|
| 388 | void op_ret();
|
---|
[262] | 389 | void op_addressof( int reg, const UserProc *pUserProc );
|
---|
[226] | 390 |
|
---|
[225] | 391 | #else
|
---|
[228] | 392 | /////////////////////////////////////////////////////////////////
|
---|
[237] | 393 | // 32ビット機械語生成
|
---|
[228] | 394 | /////////////////////////////////////////////////////////////////
|
---|
[225] | 395 | private:
|
---|
[251] | 396 | const PertialSchedule *set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType, bool isPertialSchedule );
|
---|
[225] | 397 | void __op_format(char op_prefix,char opcode,int reg);
|
---|
[251] | 398 | const PertialSchedule *__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[225] | 399 | public:
|
---|
[253] | 400 | const PertialSchedule *op_mov_MV ( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, long value, Schedule::Type valueScheduleType = Schedule::None );
|
---|
| 401 | void op_mov_RV ( int reg,long offset, Schedule::Type scheduleType = Schedule::None );
|
---|
| 402 | void op_mov_RR ( int reg1,int reg2);
|
---|
| 403 | const PertialSchedule *op_mov_RM ( int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 404 | const PertialSchedule *op_mov_RM_ex ( int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 405 | const PertialSchedule *op_mov_MR ( int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 406 | const PertialSchedule *op_mov_MR_ex ( int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 407 | void op_movsx_R32R16 ( int reg32,int reg16 = REG_NON);
|
---|
| 408 | void op_movsx_R32R8 ( int reg32,int reg8 = REG_NON);
|
---|
| 409 | void op_movsx_R16R8 ( int reg16,int reg8 = REG_NON);
|
---|
| 410 | const PertialSchedule *op_lea_RM ( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 411 | void op_inc (int reg);
|
---|
| 412 | void op_dec (int reg);
|
---|
| 413 | void op_add_RV8 (int reg,char cValue);
|
---|
| 414 | const PertialSchedule *op_add_RV ( int reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 415 | void op_add_RR ( int reg1, int reg2 );
|
---|
| 416 | const PertialSchedule *op_add_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[225] | 417 | void op_adc_RV8 (int reg,char cValue);
|
---|
| 418 | void op_adc_RR ( int reg1, int reg2 );
|
---|
| 419 | void op_sub_RV8 (int reg,char cValue);
|
---|
| 420 | void op_sub_RR ( int reg1, int reg2 );
|
---|
| 421 | void op_sbb_RV8 (int reg,char cValue);
|
---|
| 422 | void op_sbb_RR ( int reg1, int reg2 );
|
---|
| 423 | void op_imul_RR (int reg1,int reg2);
|
---|
| 424 | void op_imul_RV (int reg,long i32data);
|
---|
| 425 | void op_imul_RV8 (int reg,char cValue);
|
---|
| 426 | void op_div_R ( int reg );
|
---|
| 427 | void op_idiv_R ( int reg );
|
---|
| 428 | void op_and_RV (int reg,long value);
|
---|
| 429 | void op_and_RR ( int reg1, int reg2 );
|
---|
| 430 | void op_or_RR ( int op_size, int reg1, int reg2 );
|
---|
| 431 | void op_xor_RR ( int reg1, int reg2 = REG_NON );
|
---|
| 432 | void op_neg ( int reg );
|
---|
| 433 | void op_cdq ();
|
---|
| 434 |
|
---|
| 435 | void op_rep_movs (int op_size);
|
---|
| 436 |
|
---|
| 437 | void op_push(int reg);
|
---|
[237] | 438 | void op_push_V( long data, Schedule::Type scheduleType = Schedule::None );
|
---|
[225] | 439 | void op_push_M( int base_reg );
|
---|
[251] | 440 | const PertialSchedule *op_push_M( int base_reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[225] | 441 | void op_pop(int reg = REG_NON);
|
---|
| 442 | void op_add_esp(long num);
|
---|
[253] | 443 | const PertialSchedule *op_sub_esp( long num, bool isPertialSchedule = false );
|
---|
[225] | 444 | void op_cmp_RR( int reg1, int reg2 );
|
---|
| 445 | void op_cmp_value(int op_size,int reg,char byte_data);
|
---|
| 446 | void op_setne( int reg );
|
---|
| 447 | void op_test(int reg1,int reg2);
|
---|
| 448 | void op_test_ah( char cValue );
|
---|
| 449 | void op_fld_ptr_esp(int type);
|
---|
| 450 | void op_fld_basereg (int type,int base_reg);
|
---|
[253] | 451 | const PertialSchedule *op_fld_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 452 | const PertialSchedule *op_fld_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[225] | 453 | void op_fstp_basereg (int type,int base_reg);
|
---|
[253] | 454 | const PertialSchedule *op_fstp_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 455 | const PertialSchedule *op_fstp_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[225] | 456 | void op_fistp_ptr_esp ( int typeSize );
|
---|
| 457 | void op_fstp_push ( Type &type );
|
---|
| 458 | void op_fcompp();
|
---|
| 459 | void op_fnstsw_ax();
|
---|
| 460 | void op_zero_reg(int reg);
|
---|
| 461 | void fpu_cast();
|
---|
| 462 | void fpu_cast_end();
|
---|
| 463 |
|
---|
[235] | 464 | void op_call_R( int reg );
|
---|
[225] | 465 | void op_call(const UserProc *pUserProc);
|
---|
[250] | 466 | void op_call(const DllProc *pDllProc);
|
---|
[225] | 467 | void op_ret();
|
---|
[240] | 468 | void op_ret( short stackFrameSize );
|
---|
[244] | 469 | void op_addressof( int reg, const UserProc *pUserProc );
|
---|
[225] | 470 | #endif
|
---|
| 471 |
|
---|
| 472 |
|
---|
| 473 |
|
---|
[242] | 474 | void PutOld( long l, Schedule::Type scheduleType )
|
---|
| 475 | {
|
---|
| 476 | pNativeCode->Put( l, scheduleType );
|
---|
| 477 | }
|
---|
[254] | 478 | const PertialSchedule *PutOld( long l, bool isPertialSchedule )
|
---|
| 479 | {
|
---|
| 480 | const PertialSchedule *pPertialSchedule;
|
---|
| 481 | if( isPertialSchedule )
|
---|
| 482 | {
|
---|
| 483 | pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
|
---|
| 484 | pPertialSchedule = pertialSchedules.back();
|
---|
| 485 | }
|
---|
| 486 | pNativeCode->Put( l, Schedule::None );
|
---|
| 487 | return pPertialSchedule;
|
---|
| 488 | }
|
---|
[252] | 489 | void PutOld( const NativeCode &nativeCode )
|
---|
| 490 | {
|
---|
[258] | 491 | pNativeCode->Put( nativeCode, true );
|
---|
[252] | 492 | }
|
---|
[253] | 493 | void PutOld( char c )
|
---|
| 494 | {
|
---|
| 495 | pNativeCode->Put( c );
|
---|
| 496 | }
|
---|
[225] | 497 | void PutOld( char c1, char c2 )
|
---|
| 498 | {
|
---|
| 499 | pNativeCode->Put( c1 );
|
---|
| 500 | pNativeCode->Put( c2 );
|
---|
| 501 | }
|
---|
| 502 | void PutOld( char c1, char c2, char c3 )
|
---|
| 503 | {
|
---|
| 504 | pNativeCode->Put( c1 );
|
---|
| 505 | pNativeCode->Put( c2 );
|
---|
| 506 | pNativeCode->Put( c3 );
|
---|
| 507 | }
|
---|
| 508 | void PutOld( char c1, char c2, char c3, char c4 )
|
---|
| 509 | {
|
---|
| 510 | pNativeCode->Put( c1 );
|
---|
| 511 | pNativeCode->Put( c2 );
|
---|
| 512 | pNativeCode->Put( c3 );
|
---|
| 513 | pNativeCode->Put( c4 );
|
---|
| 514 | }
|
---|
[228] | 515 | void PutOld( char c1, char c2, char c3, long l )
|
---|
| 516 | {
|
---|
| 517 | pNativeCode->Put( c1 );
|
---|
| 518 | pNativeCode->Put( c2 );
|
---|
| 519 | pNativeCode->Put( c3 );
|
---|
| 520 | pNativeCode->Put( l );
|
---|
| 521 | }
|
---|
[225] | 522 | void PutOld( char c1, char c2, char c3, char c4, char c5 )
|
---|
| 523 | {
|
---|
| 524 | pNativeCode->Put( c1 );
|
---|
| 525 | pNativeCode->Put( c2 );
|
---|
| 526 | pNativeCode->Put( c3 );
|
---|
| 527 | pNativeCode->Put( c4 );
|
---|
| 528 | pNativeCode->Put( c5 );
|
---|
| 529 | }
|
---|
| 530 | void PutOld( char c1, char c2, char c3, char c4, char c5, char c6 )
|
---|
| 531 | {
|
---|
| 532 | pNativeCode->Put( c1 );
|
---|
| 533 | pNativeCode->Put( c2 );
|
---|
| 534 | pNativeCode->Put( c3 );
|
---|
| 535 | pNativeCode->Put( c4 );
|
---|
| 536 | pNativeCode->Put( c5 );
|
---|
| 537 | pNativeCode->Put( c6 );
|
---|
| 538 | }
|
---|
| 539 | };
|
---|