Changeset 225 in dev for trunk/abdev/BasicCompiler_Common/include
- Timestamp:
- Jul 21, 2007, 11:47:40 PM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common/include
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r224 r225 1 1 #pragma once 2 2 3 #include <NativeCode.h> 4 5 #ifdef _AMD64_ 6 #include "../../BasicCompiler64/MachineFixed.h" 7 #else 8 #include "../../BasicCompiler32/MachineFixed.h" 9 #endif 10 11 3 12 void ReallocNativeCodeBuffer(); 13 14 class CodeGenerator 15 { 16 NativeCode *pNativeCode; 17 18 // XMLシリアライズ用 19 private: 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 26 public: 27 28 void Select( NativeCode &nativeCode ) 29 { 30 pNativeCode = &nativeCode; 31 } 32 33 #ifdef _AMD64_ 34 #else 35 private: 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); 39 public: 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 }; -
trunk/abdev/BasicCompiler_Common/include/Compiler.h
r224 r225 5 5 #include <MetaImpl.h> 6 6 #include <DataTable.h> 7 #include <CodeGenerator.h> 7 8 8 9 class Compiler … … 34 35 } 35 36 37 // グローバル領域のネイティブコード 38 NativeCode globalNativeCode; 39 40 // コード生成機構 41 CodeGenerator codeGenerator; 42 36 43 static bool StringToType( const std::string &typeName, Type &type ); 37 44 static const std::string TypeToString( const Type &type ); -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r224 r225 2 2 3 3 #include <vector> 4 5 #include <BoostSerializationSupport.h> 4 6 5 7 class Schedule … … 9 11 { 10 12 None, 13 GlobalVar, // グローバル変数スケジュール 14 LocalVar, // ローカル変数スケジュール 15 Relocation, // リロケーション情報スケジュール 11 16 }; 12 17 … … 123 128 memcpy( this->codeBuffer + this->size, codeBuffer, size ); 124 129 this->size += size; 130 131 // 未完成 132 extern char *OpBuffer; 133 extern int obp; 134 memcpy( OpBuffer, codeBuffer, size ); 135 obp += size; 125 136 } 126 137 void Put( const NativeCode &nativeCode ) … … 132 143 codeBuffer[size++] = c; 133 144 Realloc(); 145 146 147 148 // 未完成 149 extern char *OpBuffer; 150 extern int obp; 151 OpBuffer[obp++]=c; 134 152 } 135 153 void Put( long l, Schedule::Type scheduleType = Schedule::None ) … … 142 160 *((long *)(codeBuffer+size))=l; 143 161 size += sizeof(long); 162 163 164 165 // 未完成 166 extern char *OpBuffer; 167 extern int obp; 168 *((long *)(OpBuffer+obp))=l; 169 obp+=sizeof(long); 144 170 } 145 171 }; -
trunk/abdev/BasicCompiler_Common/include/Procedure.h
r224 r225 11 11 #include <Parameter.h> 12 12 #include <Variable.h> 13 #include < NativeCode.h>13 #include <CodeGenerator.h> 14 14 15 15 class CClass; … … 314 314 } 315 315 316 NativeCode &GetNativeCode() 317 { 318 return nativeCode; 319 } 320 316 321 std::string GetFullName() const; 317 322
Note:
See TracChangeset
for help on using the changeset viewer.