Changeset 253 in dev for trunk/abdev/BasicCompiler_Common/include
- Timestamp:
- Jul 30, 2007, 4:12:54 PM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r252 r253 12 12 void ReallocNativeCodeBuffer(); 13 13 14 //Goto未知ラベル15 class GotoLabelSchedule16 {17 std::string name;18 int line;19 int nativeCodePos;20 int sourceCodePos;21 public:22 GotoLabelSchedule( const std::string &name, int nativeCodePos, int sourceCodePos )23 : name( name )24 , line( -1 )25 , nativeCodePos( nativeCodePos )26 , sourceCodePos( sourceCodePos )27 {28 }29 GotoLabelSchedule( int line, int nativeCodePos, int sourceCodePos )30 : line( line )31 , nativeCodePos( nativeCodePos )32 , sourceCodePos( sourceCodePos )33 {34 }35 const std::string &GetName() const36 {37 return name;38 }39 int GetLineNum() const40 {41 return line;42 }43 int GetNativeCodePos() const44 {45 return nativeCodePos;46 }47 int GetSourceCodePos() const48 {49 return sourceCodePos;50 }51 };52 53 14 // コード生成時の部分的なスケジューリング 54 15 class PertialSchedule … … 85 46 typedef std::vector<const PertialSchedule *> PertialSchedules; 86 47 48 //Goto未知ラベル 49 class GotoLabelSchedule : public PertialSchedule 50 { 51 std::string name; 52 int line; 53 int sourceCodePos; 54 public: 55 GotoLabelSchedule( const std::string &name, int nativeCodePos, int sourceCodePos ) 56 : PertialSchedule( nativeCodePos, sizeof(long) ) 57 , name( name ) 58 , line( -1 ) 59 , sourceCodePos( sourceCodePos ) 60 { 61 } 62 GotoLabelSchedule( int line, int nativeCodePos, int sourceCodePos ) 63 : PertialSchedule( nativeCodePos, sizeof(long) ) 64 , line( line ) 65 , sourceCodePos( sourceCodePos ) 66 { 67 } 68 const std::string &GetName() const 69 { 70 return name; 71 } 72 int GetLineNum() const 73 { 74 return line; 75 } 76 int GetSourceCodePos() const 77 { 78 return sourceCodePos; 79 } 80 }; 81 typedef std::vector<const GotoLabelSchedule *> GotoLabelSchedules; 82 87 83 class LexicalScope 88 84 { … … 186 182 public: 187 183 184 // ローカル変数用スケジュールの管理 185 PertialSchedules localVarPertialSchedules; 186 188 187 // Exit Subスケジュールの管理 189 188 std::vector<long> exitSubCodePositions; … … 191 190 192 191 // Gotoスケジュールの管理 193 std::vector<GotoLabelSchedule>gotoLabelSchedules;192 GotoLabelSchedules gotoLabelSchedules; 194 193 195 194 // レキシカルスコープの管理 … … 256 255 257 256 void opfix( const PertialSchedule *pPertialSchedule, long newValue ); 257 void opfix_offset( const PertialSchedule *pPertialSchedule, long offset ); 258 258 void opfix_JmpPertialSchedule( const PertialSchedule *pPertialSchedule ); 259 259 … … 279 279 void op_jmp_continue(); 280 280 void op_jmp_exitsub(); 281 void op_jmp_goto_schedule( const GotoLabelSchedule &gotoLabelSchedule);281 void op_jmp_goto_schedule( const std::string &name, int lineNum, int sourceCodePos ); 282 282 283 283 … … 370 370 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 ); 371 371 public: 372 void op_mov_MV ( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, long value, Schedule::Type valueScheduleType = Schedule::None );373 void op_mov_RV (int reg,long offset, Schedule::Type scheduleType = Schedule::None );374 void op_mov_RR (int reg1,int reg2);375 void op_mov_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );376 void op_mov_RM_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None );377 void op_mov_MR (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );378 void op_mov_MR_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None );379 void op_movsx_R32R16 (int reg32,int reg16 = REG_NON);380 void op_movsx_R32R8 (int reg32,int reg8 = REG_NON);381 void op_movsx_R16R8 (int reg16,int reg8 = REG_NON);382 void op_lea_RM ( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType = Schedule::None );383 void op_inc (int reg);384 void op_dec (int reg);385 void op_add_RV8 (int reg,char cValue);386 void op_add_RV ( int reg, long offset, Schedule::Type scheduleType = Schedule::None );387 void op_add_RR ( int reg1, int reg2 );388 void op_add_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None );372 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 ); 373 void op_mov_RV ( int reg,long offset, Schedule::Type scheduleType = Schedule::None ); 374 void op_mov_RR ( int reg1,int reg2); 375 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 ); 376 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 ); 377 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 ); 378 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 ); 379 void op_movsx_R32R16 ( int reg32,int reg16 = REG_NON); 380 void op_movsx_R32R8 ( int reg32,int reg8 = REG_NON); 381 void op_movsx_R16R8 ( int reg16,int reg8 = REG_NON); 382 const PertialSchedule *op_lea_RM ( int reg, int base_reg, long offset, char mod, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 383 void op_inc (int reg); 384 void op_dec (int reg); 385 void op_add_RV8 (int reg,char cValue); 386 const PertialSchedule *op_add_RV ( int reg, long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 387 void op_add_RR ( int reg1, int reg2 ); 388 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 ); 389 389 void op_adc_RV8 (int reg,char cValue); 390 390 void op_adc_RR ( int reg1, int reg2 ); … … 413 413 void op_pop(int reg = REG_NON); 414 414 void op_add_esp(long num); 415 void op_sub_esp(long num);415 const PertialSchedule *op_sub_esp( long num, bool isPertialSchedule = false ); 416 416 void op_cmp_RR( int reg1, int reg2 ); 417 417 void op_cmp_value(int op_size,int reg,char byte_data); … … 421 421 void op_fld_ptr_esp(int type); 422 422 void op_fld_basereg (int type,int base_reg); 423 void op_fld_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None );424 void op_fld_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None);423 const PertialSchedule *op_fld_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 424 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 ); 425 425 void op_fstp_basereg (int type,int base_reg); 426 void op_fstp_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None);427 void op_fstp_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None);426 const PertialSchedule *op_fstp_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None, bool isPertialSchedule = false ); 427 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 ); 428 428 void op_fistp_ptr_esp ( int typeSize ); 429 429 void op_fstp_push ( Type &type ); … … 452 452 pNativeCode->Put( nativeCode ); 453 453 } 454 void PutOld( char c ) 455 { 456 pNativeCode->Put( c ); 457 } 454 458 void PutOld( char c1, char c2 ) 455 459 { -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r252 r253 7 7 #include <BoostSerializationSupport.h> 8 8 9 void AddLocalVarAddrSchedule();10 9 void ObpPlus( int step = 1 ); 11 10 … … 19 18 None = 10000, 20 19 GlobalVar, // グローバル変数スケジュール 21 LocalVar, // ローカル変数スケジュール22 20 DataTable, // データテーブル スケジュール 23 21 Relocation, // リロケーション情報スケジュール … … 172 170 } 173 171 172 long GetLong( int codePos ) const 173 { 174 return *(long *)(this->codeBuffer+codePos); 175 } 176 long _GetLong_ObpOld( int _obpOld ) const 177 { 178 extern char *OpBuffer; 179 return *(long *)(OpBuffer+_obpOld); 180 } 181 174 182 void Overwrite( int codePos, char c ) 175 183 { … … 236 244 pobj_GlobalVarSchedule->add(); 237 245 break; 238 case Schedule::LocalVar:239 AddLocalVarAddrSchedule();240 break;241 246 case Schedule::DataTable: 242 247 extern CSchedule *pobj_DataTableSchedule;
Note:
See TracChangeset
for help on using the changeset viewer.