[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 | {
|
---|
[597] | 245 | extern int cp;
|
---|
| 246 | pNativeCode->NextSourceLine( currentSourceIndex, cp );
|
---|
[263] | 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 | }
|
---|
[551] | 269 |
|
---|
| 270 | void PutWithSchedule( long l, Schedule::Type scheduleType );
|
---|
| 271 |
|
---|
[247] | 272 | void ResolveExitSubSchedule();
|
---|
[241] | 273 |
|
---|
[237] | 274 | void CheckUnresolveSchedule();
|
---|
| 275 |
|
---|
[357] | 276 | void opfix( const PertialSchedule *pPertialSchedule, _int64 newValue );
|
---|
[253] | 277 | void opfix_offset( const PertialSchedule *pPertialSchedule, long offset );
|
---|
[238] | 278 | void opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule );
|
---|
[237] | 279 |
|
---|
| 280 |
|
---|
| 281 | /////////////////////////////////////////////////////////////////
|
---|
| 282 | // 32bit/64bit共通 機械語生成
|
---|
| 283 | /////////////////////////////////////////////////////////////////
|
---|
| 284 |
|
---|
| 285 | private:
|
---|
[245] | 286 | const PertialSchedule *__jmp_op_format( char opcode, long offset, int op_size, bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
[237] | 287 | public:
|
---|
[250] | 288 | const PertialSchedule *op_jle( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 289 | const PertialSchedule *op_jbe( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 290 | const PertialSchedule *op_jge( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 291 | const PertialSchedule *op_jae( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 292 | const PertialSchedule *op_jl( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 293 | const PertialSchedule *op_jb( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 294 | const PertialSchedule *op_jg( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 295 | const PertialSchedule *op_ja( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 296 | const PertialSchedule *op_jne( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
| 297 | const PertialSchedule *op_je( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
[245] | 298 | const PertialSchedule *op_jmp( long offset, int op_size = sizeof(char), bool isPertialSchedule = false, bool isSelfOpcodeOffset = false );
|
---|
[241] | 299 | void op_jmp_continue();
|
---|
[247] | 300 | void op_jmp_exitsub();
|
---|
[253] | 301 | void op_jmp_goto_schedule( const std::string &name, int lineNum, int sourceCodePos );
|
---|
[435] | 302 | void op_AddNeedFreeTempStructure( int reg );
|
---|
| 303 | void op_FreeTempStructure();
|
---|
[237] | 304 |
|
---|
| 305 |
|
---|
[225] | 306 | #ifdef _AMD64_
|
---|
[228] | 307 | /////////////////////////////////////////////////////////////////
|
---|
[237] | 308 | // 64ビット機械語生成
|
---|
[228] | 309 | /////////////////////////////////////////////////////////////////
|
---|
[226] | 310 | private:
|
---|
| 311 | void set_rex(int op_size,int reg,int index_reg,int base_reg);
|
---|
[254] | 312 | 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 );
|
---|
| 313 | 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] | 314 | public:
|
---|
[357] | 315 | const PertialSchedule *op_mov_RV (int op_size,int reg,long i32data, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 316 | const PertialSchedule *op_mov_RV64 ( int reg, _int64 i64data, bool isPertialSchedule = false );
|
---|
[254] | 317 | 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 );
|
---|
| 318 | 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 );
|
---|
| 319 | 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 );
|
---|
| 320 | 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 );
|
---|
| 321 | const PertialSchedule *op_mov_MV (int op_size,int base_reg,int offset, Schedule::Type offsetScheduleType, bool isPertialSchedule, BOOL bUseOffset,long i32data);
|
---|
[226] | 322 | void op_mov_RR (int reg1,int reg2);
|
---|
| 323 | void op_movsxd (int reg64,int reg32);
|
---|
| 324 | void op_movsx64_FromReg16 (int reg64,int reg16);
|
---|
| 325 | void op_movsx64_FromReg8 (int reg64,int reg8);
|
---|
| 326 | void op_movsx32_FromReg16 (int reg32,int reg16);
|
---|
| 327 | void op_movsx32_FromReg8 (int reg32,int reg8);
|
---|
| 328 | void op_movsx16_FromReg8 (int reg32,int reg8);
|
---|
[228] | 329 | void op_cqo ();
|
---|
[226] | 330 | void op_inc (int reg);
|
---|
| 331 | void op_dec (int reg);
|
---|
[254] | 332 | 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 );
|
---|
| 333 | const PertialSchedule *op_add_RV (int reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[228] | 334 | void op_add_RR (int reg1,int reg2);
|
---|
[226] | 335 | void op_add32_reg (int reg1,int reg2);
|
---|
| 336 | void op_sub_RV (int op_size,int reg,long i32data);
|
---|
| 337 | void op_sub64_reg (int reg1,int reg2);
|
---|
| 338 | void op_sub32_reg (int reg1,int reg2);
|
---|
| 339 | void op_sbb_RR ( int op_size, int reg1, int reg2 );
|
---|
| 340 | void op_imul_RR (int op_size,int reg1,int reg2);
|
---|
| 341 | void op_imul_RV (int op_size,int reg,long i32data);
|
---|
| 342 | void op_div64_reg (int reg);
|
---|
| 343 | void op_idiv64_reg (int reg);
|
---|
| 344 | void op_shl_reg (int op_size,int reg);
|
---|
| 345 | void op_sar_reg (int op_size,int reg);
|
---|
| 346 | void op_shr_reg (int op_size,int reg);
|
---|
| 347 | void op_and_reg (int op_size,int reg1,int reg2);
|
---|
| 348 | void op_and64_value (int reg,long offset);
|
---|
| 349 | void op_and32_value (int reg,long offset);
|
---|
| 350 | void op_or_reg (int op_size,int reg1,int reg2);
|
---|
| 351 | void op_xor_reg (int op_size,int reg1,int reg2);
|
---|
| 352 | void op_not_reg (int op_size,int reg);
|
---|
| 353 | void op_neg ( int reg );
|
---|
| 354 | void op_test (int reg1,int reg2);
|
---|
| 355 | void op_cmp_reg (int op_size,int reg1,int reg2);
|
---|
| 356 | void op_cmp_value (int op_size,int reg,char byte_data);
|
---|
| 357 | void op_setne (int reg);
|
---|
[254] | 358 | const PertialSchedule *op_movlpd_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 359 | const PertialSchedule *op_movlpd_RM (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 360 | void op_movsd_RR (int xmm_reg1,int xmm_reg2);
|
---|
[254] | 361 | const PertialSchedule *op_movsd_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 362 | void op_movss_RR (int xmm_reg1,int xmm_reg2);
|
---|
[254] | 363 | const PertialSchedule *op_movss_RM (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 364 | const PertialSchedule *op_movss_MR (int xmm_reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[226] | 365 | void op_movd_RX (int reg,int xmm_reg);
|
---|
| 366 | void op_cvtsd2ss (int xmm_reg1,int xmm_reg2);
|
---|
| 367 | void op_cvtss2sd (int xmm_reg1,int xmm_reg2);
|
---|
| 368 | void op_cvttsd2si_xmm (int op_size,int reg,int xmm_reg);
|
---|
| 369 | void op_cvttss2si_xmm (int op_size,int reg,int xmm_reg);
|
---|
| 370 | void op_cvtsi2sd_reg (int op_size,int xmm_reg,int reg);
|
---|
| 371 | void op_cvtsi2ss_reg (int op_size,int xmm_reg,int reg);
|
---|
| 372 | void op_comisd (int xmm_reg1,int xmm_reg2);
|
---|
| 373 | void op_comiss (int xmm_reg1,int xmm_reg2);
|
---|
| 374 | void op_rep_movs (int op_size);
|
---|
| 375 | void op_add_rsp(long num);
|
---|
[255] | 376 | const PertialSchedule *op_sub_rsp( long num, bool isPertialSchedule = false );
|
---|
[226] | 377 | void op_fld_ptr_esp(int type);
|
---|
| 378 | void op_zero_reg(int reg);
|
---|
[317] | 379 |
|
---|
[226] | 380 | void op_call( const UserProc *pUserProc );
|
---|
| 381 | void op_call( const DllProc *pDllProc );
|
---|
| 382 | void op_ret();
|
---|
[262] | 383 | void op_addressof( int reg, const UserProc *pUserProc );
|
---|
[370] | 384 | void op_mov_RV_com_vtbl( int reg, const CClass *pClass );
|
---|
[317] | 385 | void op_mov_RV_vtbl( int reg, const CClass *pClass );
|
---|
[226] | 386 |
|
---|
[225] | 387 | #else
|
---|
[228] | 388 | /////////////////////////////////////////////////////////////////
|
---|
[237] | 389 | // 32ビット機械語生成
|
---|
[228] | 390 | /////////////////////////////////////////////////////////////////
|
---|
[225] | 391 | private:
|
---|
[251] | 392 | 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] | 393 | void __op_format(char op_prefix,char opcode,int reg);
|
---|
[251] | 394 | 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] | 395 | public:
|
---|
[253] | 396 | 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] | 397 | const PertialSchedule *op_mov_RV ( int reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[253] | 398 | void op_mov_RR ( int reg1,int reg2);
|
---|
| 399 | 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 );
|
---|
| 400 | 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 );
|
---|
| 401 | 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 );
|
---|
| 402 | 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 );
|
---|
| 403 | void op_movsx_R32R16 ( int reg32,int reg16 = REG_NON);
|
---|
| 404 | void op_movsx_R32R8 ( int reg32,int reg8 = REG_NON);
|
---|
| 405 | void op_movsx_R16R8 ( int reg16,int reg8 = REG_NON);
|
---|
| 406 | const PertialSchedule *op_lea_RM ( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 407 | void op_inc (int reg);
|
---|
| 408 | void op_dec (int reg);
|
---|
| 409 | void op_add_RV8 (int reg,char cValue);
|
---|
| 410 | const PertialSchedule *op_add_RV ( int reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 411 | void op_add_RR ( int reg1, int reg2 );
|
---|
| 412 | 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] | 413 | void op_adc_RV8 (int reg,char cValue);
|
---|
| 414 | void op_adc_RR ( int reg1, int reg2 );
|
---|
| 415 | void op_sub_RV8 (int reg,char cValue);
|
---|
| 416 | void op_sub_RR ( int reg1, int reg2 );
|
---|
| 417 | void op_sbb_RV8 (int reg,char cValue);
|
---|
| 418 | void op_sbb_RR ( int reg1, int reg2 );
|
---|
| 419 | void op_imul_RR (int reg1,int reg2);
|
---|
| 420 | void op_imul_RV (int reg,long i32data);
|
---|
| 421 | void op_imul_RV8 (int reg,char cValue);
|
---|
| 422 | void op_div_R ( int reg );
|
---|
| 423 | void op_idiv_R ( int reg );
|
---|
| 424 | void op_and_RV (int reg,long value);
|
---|
| 425 | void op_and_RR ( int reg1, int reg2 );
|
---|
| 426 | void op_or_RR ( int op_size, int reg1, int reg2 );
|
---|
| 427 | void op_xor_RR ( int reg1, int reg2 = REG_NON );
|
---|
| 428 | void op_neg ( int reg );
|
---|
| 429 | void op_cdq ();
|
---|
| 430 |
|
---|
| 431 | void op_rep_movs (int op_size);
|
---|
| 432 |
|
---|
| 433 | void op_push(int reg);
|
---|
[237] | 434 | void op_push_V( long data, Schedule::Type scheduleType = Schedule::None );
|
---|
[225] | 435 | void op_push_M( int base_reg );
|
---|
[251] | 436 | const PertialSchedule *op_push_M( int base_reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
[225] | 437 | void op_pop(int reg = REG_NON);
|
---|
| 438 | void op_add_esp(long num);
|
---|
[253] | 439 | const PertialSchedule *op_sub_esp( long num, bool isPertialSchedule = false );
|
---|
[225] | 440 | void op_cmp_RR( int reg1, int reg2 );
|
---|
| 441 | void op_cmp_value(int op_size,int reg,char byte_data);
|
---|
| 442 | void op_setne( int reg );
|
---|
| 443 | void op_test(int reg1,int reg2);
|
---|
| 444 | void op_test_ah( char cValue );
|
---|
| 445 | void op_fld_ptr_esp(int type);
|
---|
| 446 | void op_fld_basereg (int type,int base_reg);
|
---|
[253] | 447 | const PertialSchedule *op_fld_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 448 | 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] | 449 | void op_fstp_basereg (int type,int base_reg);
|
---|
[253] | 450 | const PertialSchedule *op_fstp_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false );
|
---|
| 451 | 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] | 452 | void op_fistp_ptr_esp ( int typeSize );
|
---|
| 453 | void op_fstp_push ( Type &type );
|
---|
| 454 | void op_fcompp();
|
---|
| 455 | void op_fnstsw_ax();
|
---|
| 456 | void op_zero_reg(int reg);
|
---|
| 457 | void fpu_cast();
|
---|
| 458 | void fpu_cast_end();
|
---|
| 459 |
|
---|
[235] | 460 | void op_call_R( int reg );
|
---|
[225] | 461 | void op_call(const UserProc *pUserProc);
|
---|
[250] | 462 | void op_call(const DllProc *pDllProc);
|
---|
[225] | 463 | void op_ret();
|
---|
[240] | 464 | void op_ret( short stackFrameSize );
|
---|
[244] | 465 | void op_addressof( int reg, const UserProc *pUserProc );
|
---|
[370] | 466 | void op_mov_RV_com_vtbl( int reg, const CClass *pClass );
|
---|
[282] | 467 | void op_mov_RV_vtbl( int reg, const CClass *pClass );
|
---|
[225] | 468 | #endif
|
---|
| 469 |
|
---|
| 470 |
|
---|
| 471 |
|
---|
[242] | 472 | void PutOld( long l, Schedule::Type scheduleType )
|
---|
| 473 | {
|
---|
[551] | 474 | this->PutWithSchedule( l, scheduleType );
|
---|
[242] | 475 | }
|
---|
[254] | 476 | const PertialSchedule *PutOld( long l, bool isPertialSchedule )
|
---|
| 477 | {
|
---|
| 478 | const PertialSchedule *pPertialSchedule;
|
---|
| 479 | if( isPertialSchedule )
|
---|
| 480 | {
|
---|
| 481 | pertialSchedules.push_back( new PertialSchedule( pNativeCode->GetSize(), sizeof(long) ) );
|
---|
| 482 | pPertialSchedule = pertialSchedules.back();
|
---|
| 483 | }
|
---|
[551] | 484 | pNativeCode->Put( l );
|
---|
[254] | 485 | return pPertialSchedule;
|
---|
| 486 | }
|
---|
[252] | 487 | void PutOld( const NativeCode &nativeCode )
|
---|
| 488 | {
|
---|
[287] | 489 | pNativeCode->PutEx( nativeCode );
|
---|
[252] | 490 | }
|
---|
[253] | 491 | void PutOld( char c )
|
---|
| 492 | {
|
---|
| 493 | pNativeCode->Put( c );
|
---|
| 494 | }
|
---|
[225] | 495 | void PutOld( char c1, char c2 )
|
---|
| 496 | {
|
---|
| 497 | pNativeCode->Put( c1 );
|
---|
| 498 | pNativeCode->Put( c2 );
|
---|
| 499 | }
|
---|
| 500 | void PutOld( char c1, char c2, char c3 )
|
---|
| 501 | {
|
---|
| 502 | pNativeCode->Put( c1 );
|
---|
| 503 | pNativeCode->Put( c2 );
|
---|
| 504 | pNativeCode->Put( c3 );
|
---|
| 505 | }
|
---|
| 506 | void PutOld( char c1, char c2, char c3, char c4 )
|
---|
| 507 | {
|
---|
| 508 | pNativeCode->Put( c1 );
|
---|
| 509 | pNativeCode->Put( c2 );
|
---|
| 510 | pNativeCode->Put( c3 );
|
---|
| 511 | pNativeCode->Put( c4 );
|
---|
| 512 | }
|
---|
[228] | 513 | void PutOld( char c1, char c2, char c3, long l )
|
---|
| 514 | {
|
---|
| 515 | pNativeCode->Put( c1 );
|
---|
| 516 | pNativeCode->Put( c2 );
|
---|
| 517 | pNativeCode->Put( c3 );
|
---|
| 518 | pNativeCode->Put( l );
|
---|
| 519 | }
|
---|
[225] | 520 | void PutOld( char c1, char c2, char c3, char c4, char c5 )
|
---|
| 521 | {
|
---|
| 522 | pNativeCode->Put( c1 );
|
---|
| 523 | pNativeCode->Put( c2 );
|
---|
| 524 | pNativeCode->Put( c3 );
|
---|
| 525 | pNativeCode->Put( c4 );
|
---|
| 526 | pNativeCode->Put( c5 );
|
---|
| 527 | }
|
---|
| 528 | void PutOld( char c1, char c2, char c3, char c4, char c5, char c6 )
|
---|
| 529 | {
|
---|
| 530 | pNativeCode->Put( c1 );
|
---|
| 531 | pNativeCode->Put( c2 );
|
---|
| 532 | pNativeCode->Put( c3 );
|
---|
| 533 | pNativeCode->Put( c4 );
|
---|
| 534 | pNativeCode->Put( c5 );
|
---|
| 535 | pNativeCode->Put( c6 );
|
---|
| 536 | }
|
---|
| 537 | };
|
---|