Ignore:
Timestamp:
Jul 21, 2007, 11:47:40 PM (17 years ago)
Author:
dai_9181
Message:

CodeGeneratorクラスのベースを実装

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h

    r224 r225  
    11#pragma once
    22
     3#include <NativeCode.h>
     4
     5#ifdef _AMD64_
     6#include "../../BasicCompiler64/MachineFixed.h"
     7#else
     8#include "../../BasicCompiler32/MachineFixed.h"
     9#endif
     10
     11
    312void ReallocNativeCodeBuffer();
     13
     14class CodeGenerator
     15{
     16    NativeCode *pNativeCode;
     17
     18    // XMLシリアライズ用
     19private:
     20    friend class boost::serialization::access;
     21    template<class Archive> void serialize(Archive& ar, const unsigned int version)
     22    {
     23        ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( NativeCode );
     24    }
     25
     26public:
     27
     28    void Select( NativeCode &nativeCode )
     29    {
     30        pNativeCode = &nativeCode;
     31    }
     32
     33#ifdef _AMD64_
     34#else
     35private:
     36    void set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp);
     37    void __op_format(char op_prefix,char opcode,int reg);
     38    void __op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod);
     39public:
     40    void op_mov_RV          (int reg,long offset);
     41    void op_mov_RV          (int op_size,int reg,int offset);
     42    void op_mov_RR          (int reg1,int reg2);
     43    void op_mov_RM          (int op_size,int reg,int base_reg,int offset,char mod);
     44    void op_mov_RM_ex       (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset);
     45    void op_mov_MR          (int op_size,int reg,int base_reg,int offset,char mod);
     46    void op_mov_MR_ex       (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset);
     47    void op_movsx_R32R16    (int reg32,int reg16 = REG_NON);
     48    void op_movsx_R32R8     (int reg32,int reg8 = REG_NON);
     49    void op_movsx_R16R8     (int reg16,int reg8 = REG_NON);
     50    void op_inc             (int reg);
     51    void op_dec             (int reg);
     52    void op_add_RV8         (int reg,char cValue);
     53    void op_add_RR          ( int reg1, int reg2 );
     54    void op_add_RM          (int op_size,int reg,int base_reg,int offset,char mod);
     55    void op_adc_RV8         (int reg,char cValue);
     56    void op_adc_RR          ( int reg1, int reg2 );
     57    void op_sub_RV8         (int reg,char cValue);
     58    void op_sub_RR          ( int reg1, int reg2 );
     59    void op_sbb_RV8         (int reg,char cValue);
     60    void op_sbb_RR          ( int reg1, int reg2 );
     61    void op_imul_RR         (int reg1,int reg2);
     62    void op_imul_RV         (int reg,long i32data);
     63    void op_imul_RV8        (int reg,char cValue);
     64    void op_div_R           ( int reg );
     65    void op_idiv_R          ( int reg );
     66    void op_and_RV          (int reg,long value);
     67    void op_and_RR          ( int reg1, int reg2 );
     68    void op_or_RR           ( int op_size, int reg1, int reg2 );
     69    void op_xor_RR          ( int reg1, int reg2 = REG_NON );
     70    void op_neg             ( int reg );
     71    void op_cdq             ();
     72
     73    void op_rep_movs        (int op_size);
     74
     75    void op_push(int reg);
     76    void op_push_V(long data);
     77    void op_push_M( int base_reg );
     78    void op_pop(int reg = REG_NON);
     79    void op_add_esp(long num);
     80    void op_sub_esp(long num);
     81    void op_cmp_RR( int reg1, int reg2 );
     82    void op_cmp_value(int op_size,int reg,char byte_data);
     83    void op_setne( int reg );
     84    void op_test(int reg1,int reg2);
     85    void op_test_ah( char cValue );
     86    void op_fld_ptr_esp(int type);
     87    void op_fld_basereg         (int type,int base_reg);
     88    void op_fld_base_offset     (int type,int base_reg,long offset);
     89    void op_fld_base_offset_ex  (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset);
     90    void op_fstp_basereg        (int type,int base_reg);
     91    void op_fstp_base_offset    (int type,int base_reg,long offset);
     92    void op_fstp_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset);
     93    void op_fistp_ptr_esp       ( int typeSize );
     94    void op_fstp_push           ( Type &type );
     95    void op_fcompp();
     96    void op_fnstsw_ax();
     97    void op_zero_reg(int reg);
     98    void fpu_cast();
     99    void fpu_cast_end();
     100
     101    void op_call(const UserProc *pUserProc);
     102    void op_ret();
     103#endif
     104
     105
     106
     107
     108    void PutOld( char c1, char c2 )
     109    {
     110        pNativeCode->Put( c1 );
     111        pNativeCode->Put( c2 );
     112    }
     113    void PutOld( char c1, char c2, char c3 )
     114    {
     115        pNativeCode->Put( c1 );
     116        pNativeCode->Put( c2 );
     117        pNativeCode->Put( c3 );
     118    }
     119    void PutOld( char c1, char c2, char c3, char c4 )
     120    {
     121        pNativeCode->Put( c1 );
     122        pNativeCode->Put( c2 );
     123        pNativeCode->Put( c3 );
     124        pNativeCode->Put( c4 );
     125    }
     126    void PutOld( char c1, char c2, char c3, char c4, char c5 )
     127    {
     128        pNativeCode->Put( c1 );
     129        pNativeCode->Put( c2 );
     130        pNativeCode->Put( c3 );
     131        pNativeCode->Put( c4 );
     132        pNativeCode->Put( c5 );
     133    }
     134    void PutOld( char c1, char c2, char c3, char c4, char c5, char c6 )
     135    {
     136        pNativeCode->Put( c1 );
     137        pNativeCode->Put( c2 );
     138        pNativeCode->Put( c3 );
     139        pNativeCode->Put( c4 );
     140        pNativeCode->Put( c5 );
     141        pNativeCode->Put( c6 );
     142    }
     143};
Note: See TracChangeset for help on using the changeset viewer.