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