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