Changeset 237 in dev for trunk/abdev/BasicCompiler_Common/include
- Timestamp:
- Jul 26, 2007, 3:58:18 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r235 r237 16 16 NativeCode *pNativeCode; 17 17 18 // XMLシリアライズ用 18 public: 19 class PertialSchedule 20 { 21 int codePos; 22 int typeSize; 23 24 int _obpOld; 25 public: 26 PertialSchedule( int codePos, int typeSize ) 27 : codePos( codePos ) 28 , typeSize( typeSize ) 29 { 30 extern int obp; 31 _obpOld = obp-typeSize; 32 } 33 ~PertialSchedule() 34 { 35 } 36 37 int GetCodePos() const 38 { 39 return codePos; 40 } 41 int GetTypeSize() const 42 { 43 return typeSize; 44 } 45 int GetObpOld() const 46 { 47 return _obpOld; 48 } 49 }; 50 19 51 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: 52 typedef std::vector<PertialSchedule> PertialSchedules; 53 PertialSchedules pertialSchedules; 54 55 public: 56 57 CodeGenerator() 58 : pNativeCode( 0 ) 59 { 60 } 61 ~CodeGenerator() 62 { 63 if( pNativeCode ) 64 { 65 CheckUnresolveSchedule(); 66 } 67 } 27 68 28 69 void Select( NativeCode &nativeCode ) 29 70 { 71 if( pNativeCode ) 72 { 73 CheckUnresolveSchedule(); 74 } 30 75 pNativeCode = &nativeCode; 31 76 } 32 77 78 void CheckUnresolveSchedule(); 79 80 void opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule ) 81 { 82 PertialSchedules::iterator it = pertialSchedules.begin(); 83 while( it != pertialSchedules.end() ) 84 { 85 if( &(*it) == pPertialSchedule ) 86 { 87 pNativeCode->Overwrite( pPertialSchedule->GetCodePos(), (char)(pNativeCode->GetSize() - pPertialSchedule->GetCodePos()) ); 88 89 // 未完成 90 extern int obp; 91 pNativeCode->OverwriteOld( pPertialSchedule->GetObpOld(), obp-pPertialSchedule->GetObpOld() ); 92 93 pertialSchedules.erase( it ); 94 } 95 else 96 { 97 it++; 98 } 99 } 100 } 101 102 103 ///////////////////////////////////////////////////////////////// 104 // 32bit/64bit共通 機械語生成 105 ///////////////////////////////////////////////////////////////// 106 107 private: 108 PertialSchedule *__jmp_op_format( char opcode, long offset, int op_size, bool isPertialSchedule = false ); 109 public: 110 void op_jle( long offset, int op_size = sizeof(char) ); 111 void op_jbe( long offset, int op_size = sizeof(char) ); 112 void op_jge( long offset, int op_size = sizeof(char) ); 113 void op_jae( long offset, int op_size = sizeof(char) ); 114 void op_jl( long offset, int op_size = sizeof(char) ); 115 void op_jb( long offset, int op_size = sizeof(char) ); 116 void op_jg( long offset, int op_size = sizeof(char) ); 117 PertialSchedule *op_ja( long offset, int op_size = sizeof(char), bool isPertialSchedule = false ); 118 PertialSchedule *op_jne( long offset, int op_size = sizeof(char), bool isPertialSchedule = false ); 119 void op_je( long offset, int op_size = sizeof(char) ); 120 void op_jmp( long offset, int op_size = sizeof(char) ); 121 122 33 123 #ifdef _AMD64_ 34 124 ///////////////////////////////////////////////////////////////// 35 // 64ビット 125 // 64ビット機械語生成 36 126 ///////////////////////////////////////////////////////////////// 37 127 private: … … 39 129 void set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType = Schedule::None ); 40 130 void __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 ); 41 void __jmp_op_format( char opcode, long offset, int op_size );42 131 public: 43 132 void op_mov_RV (int op_size,int reg,long i32data, Schedule::Type scheduleType = Schedule::None ); … … 107 196 void op_fld_ptr_esp(int type); 108 197 void op_zero_reg(int reg); 109 void op_jle( long offset, int op_size = sizeof(char) );110 void op_jbe( long offset, int op_size = sizeof(char) );111 void op_jge( long offset, int op_size = sizeof(char) );112 void op_jae( long offset, int op_size = sizeof(char) );113 void op_jl( long offset, int op_size = sizeof(char) );114 void op_jb( long offset, int op_size = sizeof(char) );115 void op_jg( long offset, int op_size = sizeof(char) );116 void op_ja( long offset, int op_size = sizeof(char) );117 void op_jne( long offset, int op_size = sizeof(char) );118 void op_je( long offset, int op_size = sizeof(char) );119 void op_jmp( long offset, int op_size = sizeof(char) );120 198 void op_call( const UserProc *pUserProc ); 121 199 void op_call( const DllProc *pDllProc ); … … 124 202 #else 125 203 ///////////////////////////////////////////////////////////////// 126 // 32ビット 204 // 32ビット機械語生成 127 205 ///////////////////////////////////////////////////////////////// 128 206 private: … … 169 247 170 248 void op_push(int reg); 171 void op_push_V( long data);249 void op_push_V( long data, Schedule::Type scheduleType = Schedule::None ); 172 250 void op_push_M( int base_reg ); 173 251 void op_push_M( int base_reg, long offset, Schedule::Type scheduleType = Schedule::None ); -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r232 r237 15 15 enum Type 16 16 { 17 None ,17 None = 10000, 18 18 GlobalVar, // グローバル変数スケジュール 19 19 LocalVar, // ローカル変数スケジュール 20 DataTable, // データテーブル スケジュール 20 21 Relocation, // リロケーション情報スケジュール 21 22 }; … … 127 128 } 128 129 130 int GetSize() const 131 { 132 return size; 133 } 134 135 void Overwrite( int codePos, char c ) 136 { 137 codeBuffer[codePos] = c; 138 } 139 void OverwriteOld( int _obpOld, char c ) 140 { 141 // 未完成 142 extern char *OpBuffer; 143 extern int obp; 144 OpBuffer[_obpOld] = c; 145 } 146 129 147 void Put( const char *codeBuffer, int size ) 130 148 { … … 172 190 AddLocalVarAddrSchedule(); 173 191 break; 192 case Schedule::DataTable: 193 extern CSchedule *pobj_DataTableSchedule; 194 pobj_DataTableSchedule->add(); 195 break; 174 196 case Schedule::Relocation: 175 197 break;
Note:
See TracChangeset
for help on using the changeset viewer.