- Timestamp:
- Jul 24, 2007, 11:35:33 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/CodeGenerator.cpp
r225 r229 19 19 #define INDEX_NON 0x04 20 20 21 void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp ){21 void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType ){ 22 22 if(mod==MOD_DISP32){ 23 23 //ModR/Mバイト … … 59 59 else 60 60 { 61 pNativeCode->Put( disp );61 pNativeCode->Put( disp, scheduleType ); 62 62 } 63 63 } … … 75 75 pNativeCode->Put( (char)(opcode|REGISTER_OPERAND(reg)) ); 76 76 } 77 void CodeGenerator::__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod ){77 void CodeGenerator::__op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 78 78 //命令プリフィックス 79 79 if(op_prefix) … … 90 90 91 91 //ModR/M, SIB, disp 92 set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset );92 set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType ); 93 93 } 94 94 … … 99 99 /////////////////// 100 100 101 void CodeGenerator::op_mov_RV(int reg,long offset ){101 void CodeGenerator::op_mov_RV(int reg,long offset, Schedule::Type scheduleType ){ 102 102 //mov reg,value 103 103 … … 106 106 107 107 //DISP32 108 pNativeCode->Put( offset ); 109 } 110 void CodeGenerator::op_mov_RV(int op_size,int reg,int offset){ 111 if(op_size==PTR_SIZE) op_mov_RV(reg,offset); 112 else SetError(300,NULL,cp); 108 pNativeCode->Put( offset, scheduleType ); 113 109 } 114 110 void CodeGenerator::op_mov_RR(int reg1,int reg2){ … … 121 117 pNativeCode->Put( (char)(0xC0| REGISTER_OPERAND(reg1)<<3 | REGISTER_OPERAND(reg2)) ); 122 118 } 123 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,int offset,char mod ){119 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 124 120 //mov reg32,dword ptr[base_reg+offset] 125 121 //mov reg16,word ptr[base_reg+offset] … … 135 131 else opcode=(char)0x8B; 136 132 137 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod );138 } 139 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset ){133 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType ); 134 } 135 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 140 136 //mov reg32,dword ptr[base_reg1+base_reg2+offset] 141 137 //mov reg16,word ptr[base_reg1+base_reg2+offset] … … 167 163 168 164 //オフセット値 169 pNativeCode->Put( offset );165 pNativeCode->Put( offset, scheduleType ); 170 166 } 171 167 else{ … … 181 177 } 182 178 } 183 void CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,int offset,char mod ){179 void CodeGenerator::op_mov_MR(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 184 180 //mov dword ptr[base_reg+offset],reg32 185 181 //mov word ptr[base_reg+offset],reg16 … … 195 191 else opcode=(char)0x89; 196 192 197 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod );198 } 199 void CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset ){193 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType ); 194 } 195 void CodeGenerator::op_mov_MR_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 200 196 //mov dword ptr[base_reg1+base_reg2+offset],reg32 201 197 //mov word ptr[base_reg1+base_reg2+offset],reg16 … … 227 223 228 224 //オフセット値 229 pNativeCode->Put( offset );225 pNativeCode->Put( offset, scheduleType ); 230 226 } 231 227 else{ … … 353 349 __op_format(op_prefix,opcode,0,reg1,reg2,0,MOD_REG); 354 350 } 355 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod ){351 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 356 352 //add reg32,dword ptr[base_reg+offset] 357 353 //add reg16,word ptr[base_reg+offset] … … 367 363 else opcode=(char)0x03; 368 364 369 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod );365 __op_format(op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType ); 370 366 } 371 367 void CodeGenerator::op_adc_RV8(int reg,char cValue){ … … 656 652 __op_format( (char)0xFF, (char)0x30, base_reg ); 657 653 } 654 void CodeGenerator::op_push_M( int base_reg, long offset, Schedule::Type scheduleType ) 655 { 656 if( base_reg == REG_NON ) 657 { 658 // push dword ptr[offset] 659 __op_format( 0, (char)0xFF, 0, /*opcode->*/0x06, 0, offset, MOD_DISP32, scheduleType ); 660 } 661 else 662 { 663 // push dword ptr[base_reg+offset] 664 __op_format( 0, (char)0xFF, 0, /*opcode->*/0x06, base_reg, offset, MOD_BASE_DISP32, scheduleType ); 665 } 666 } 658 667 void CodeGenerator::op_pop(int reg){ 659 668 //pop reg … … 821 830 } 822 831 } 823 void CodeGenerator::op_fld_base_offset(int type,int base_reg,long offset ){832 void CodeGenerator::op_fld_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType ){ 824 833 //fld ptr[reg+offset] 825 834 … … 839 848 840 849 //オフセット値 841 pNativeCode->Put( offset );842 } 843 void CodeGenerator::op_fld_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset ){850 pNativeCode->Put( offset, scheduleType ); 851 } 852 void CodeGenerator::op_fld_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 844 853 //fld ptr[base_reg1+base_reg2+offset] 845 854 … … 868 877 869 878 //オフセット値 870 pNativeCode->Put( offset );879 pNativeCode->Put( offset, scheduleType ); 871 880 } 872 881 else{ … … 902 911 } 903 912 } 904 void CodeGenerator::op_fstp_base_offset(int type,int base_reg,long offset ){913 void CodeGenerator::op_fstp_base_offset(int type,int base_reg,long offset, Schedule::Type scheduleType ){ 905 914 //fstp ptr[reg+offset] 906 915 … … 920 929 921 930 //オフセット値 922 pNativeCode->Put( offset );923 } 924 void CodeGenerator::op_fstp_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset ){931 pNativeCode->Put( offset, scheduleType ); 932 } 933 void CodeGenerator::op_fstp_base_offset_ex(int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 925 934 //fstp ptr[base_reg1+base_reg2+offset] 926 935 … … 949 958 950 959 //オフセット値 951 pNativeCode->Put( offset );960 pNativeCode->Put( offset, scheduleType ); 952 961 } 953 962 else{ -
trunk/abdev/BasicCompiler32/Compile_Calc_PushVar.cpp
r225 r229 10 10 if(pRelativeVar->bOffsetOffset){ 11 11 //fld ptr[ecx+offset] 12 compiler.codeGenerator.op_fld_base_offset(type,REG_ECX,(int)pRelativeVar->offset); 13 obp-=sizeof(long); 14 pobj_GlobalVarSchedule->add(); 15 obp+=sizeof(long); 12 compiler.codeGenerator.op_fld_base_offset(type,REG_ECX,(int)pRelativeVar->offset, Schedule::GlobalVar ); 16 13 } 17 14 else{ 18 15 //mov ecx,offset 19 compiler.codeGenerator.op_mov_RV(REG_ECX,(int)pRelativeVar->offset); 20 obp-=sizeof(long); 21 pobj_GlobalVarSchedule->add(); 22 obp+=sizeof(long); 16 compiler.codeGenerator.op_mov_RV(REG_ECX,(int)pRelativeVar->offset, Schedule::GlobalVar ); 23 17 24 18 //fld ptr[ecx] … … 32 26 if(pRelativeVar->bOffsetOffset){ 33 27 //fld ptr[ebp+ecx+offset] 34 compiler.codeGenerator.op_fld_base_offset_ex(type,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET); 35 obp-=sizeof(long); 36 AddLocalVarAddrSchedule(); 37 obp+=sizeof(long); 28 compiler.codeGenerator.op_fld_base_offset_ex(type,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET, Schedule::LocalVar ); 38 29 } 39 30 else{ 40 31 //fld ptr[ebp+offset] 41 compiler.codeGenerator.op_fld_base_offset(type,REG_EBP,(int)pRelativeVar->offset); 42 obp-=sizeof(long); 43 AddLocalVarAddrSchedule(); 44 obp+=sizeof(long); 32 compiler.codeGenerator.op_fld_base_offset(type,REG_EBP,(int)pRelativeVar->offset, Schedule::LocalVar ); 45 33 } 46 34 } … … 48 36 if(pRelativeVar->bOffsetOffset){ 49 37 //add ecx,qword ptr[ebp+offset] 50 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 51 obp-=sizeof(long); 52 AddLocalVarAddrSchedule(); 53 obp+=sizeof(long); 38 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 54 39 } 55 40 else{ 56 41 //mov ecx,qword ptr[ebp+offset] 57 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 58 obp-=sizeof(long); 59 AddLocalVarAddrSchedule(); 60 obp+=sizeof(long); 42 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 61 43 } 62 44 … … 98 80 if(pRelativeVar->bOffsetOffset){ 99 81 //mov reg, ptr[ecx+offset] 100 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32 );82 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32, Schedule::GlobalVar ); 101 83 } 102 84 else{ 103 85 //mov reg, ptr[offset] 104 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset + offsetOf64Head,MOD_DISP32); 105 } 106 obp-=sizeof(long); 107 pobj_GlobalVarSchedule->add(); 108 obp+=sizeof(long); 86 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset + offsetOf64Head,MOD_DISP32, Schedule::GlobalVar ); 87 } 109 88 } 110 89 else if(pRelativeVar->dwKind==VAR_REFGLOBAL){ 111 90 if(pRelativeVar->bOffsetOffset){ 112 91 //add ecx,qword ptr[offset] 113 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32 );92 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar ); 114 93 } 115 94 else{ 116 95 //mov ecx,qword ptr[offset] 117 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32); 118 } 119 obp-=sizeof(long); 120 pobj_GlobalVarSchedule->add(); 121 obp+=sizeof(long); 96 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar ); 97 } 122 98 123 99 goto directmem; … … 126 102 if(pRelativeVar->bOffsetOffset){ 127 103 //mov reg, ptr[ebp+ecx+offset] 128 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_EBP,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,USE_OFFSET );104 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_EBP,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,USE_OFFSET, Schedule::LocalVar ); 129 105 } 130 106 else{ 131 107 //mov reg, ptr[ebp+offset] 132 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_EBP,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32); 133 } 134 obp-=sizeof(long); 135 AddLocalVarAddrSchedule(); 136 obp+=sizeof(long); 108 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_EBP,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32, Schedule::LocalVar ); 109 } 137 110 } 138 111 else if(pRelativeVar->dwKind==VAR_REFLOCAL){ 139 112 if(pRelativeVar->bOffsetOffset){ 140 113 //add ecx,qword ptr[ebp+offset] 141 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32 );114 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 142 115 } 143 116 else{ 144 117 //mov ecx,qword ptr[ebp+offset] 145 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 146 } 147 obp-=sizeof(long); 148 AddLocalVarAddrSchedule(); 149 obp+=sizeof(long); 118 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 119 } 150 120 151 121 goto directmem; … … 170 140 if(pRelativeVar->bOffsetOffset){ 171 141 //push dword ptr[ecx+offset] 172 OpBuffer[obp++]=(char)0xFF; 173 OpBuffer[obp++]=(char)0xB1; 174 *((long *)(OpBuffer+obp))=pRelativeVar->offset; 175 pobj_GlobalVarSchedule->add(); 176 obp+=sizeof(long); 142 compiler.codeGenerator.op_push_M( REG_ECX, pRelativeVar->offset, Schedule::GlobalVar ); 177 143 } 178 144 else{ 179 145 //push dword ptr[offset] 180 OpBuffer[obp++]=(char)0xFF; 181 OpBuffer[obp++]=(char)0x35; 182 *((long *)(OpBuffer+obp))=pRelativeVar->offset; 183 pobj_GlobalVarSchedule->add(); 184 obp+=sizeof(long); 146 compiler.codeGenerator.op_push_M( REG_NON, pRelativeVar->offset, Schedule::GlobalVar ); 185 147 } 186 148 } 187 149 else if(pRelativeVar->dwKind==VAR_REFGLOBAL){ 188 150 //mov eax,dword ptr[offset] 189 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 ); 190 obp-=sizeof(long); 191 pobj_GlobalVarSchedule->add(); 192 obp+=sizeof(long); 151 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32, Schedule::GlobalVar ); 193 152 194 153 if(pRelativeVar->bOffsetOffset){ -
trunk/abdev/BasicCompiler_Common/gc.cpp
r225 r229 28 28 29 29 //mov ptr[offset],rax/eax 30 compiler.codeGenerator.op_mov_MR(PTR_SIZE,REG_RAX,0,(int)RelativeVar.offset,MOD_DISP32); 31 obp-=sizeof(long); 32 pobj_GlobalVarSchedule->add(); 33 obp+=sizeof(long); 34 30 compiler.codeGenerator.op_mov_MR(PTR_SIZE,REG_RAX,0,(int)RelativeVar.offset,MOD_DISP32, Schedule::GlobalVar ); 35 31 } -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r228 r229 129 129 ///////////////////////////////////////////////////////////////// 130 130 private: 131 void set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp );131 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 ); 132 132 void __op_format(char op_prefix,char opcode,int reg); 133 void __op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod );133 void __op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None ); 134 134 public: 135 void op_mov_RV (int reg,long offset); 136 void op_mov_RV (int op_size,int reg,int offset); 135 void op_mov_RV (int reg,long offset, Schedule::Type scheduleType = Schedule::None ); 137 136 void op_mov_RR (int reg1,int reg2); 138 void op_mov_RM (int op_size,int reg,int base_reg,int offset,char mod );139 void op_mov_RM_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset );140 void op_mov_MR (int op_size,int reg,int base_reg,int offset,char mod );141 void op_mov_MR_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset );137 void op_mov_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None ); 138 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 ); 139 void op_mov_MR (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None ); 140 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 ); 142 141 void op_movsx_R32R16 (int reg32,int reg16 = REG_NON); 143 142 void op_movsx_R32R8 (int reg32,int reg8 = REG_NON); … … 147 146 void op_add_RV8 (int reg,char cValue); 148 147 void op_add_RR ( int reg1, int reg2 ); 149 void op_add_RM (int op_size,int reg,int base_reg,int offset,char mod );148 void op_add_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None ); 150 149 void op_adc_RV8 (int reg,char cValue); 151 150 void op_adc_RR ( int reg1, int reg2 ); … … 171 170 void op_push_V(long data); 172 171 void op_push_M( int base_reg ); 172 void op_push_M( int base_reg, long offset, Schedule::Type scheduleType = Schedule::None ); 173 173 void op_pop(int reg = REG_NON); 174 174 void op_add_esp(long num); … … 181 181 void op_fld_ptr_esp(int type); 182 182 void op_fld_basereg (int type,int base_reg); 183 void op_fld_base_offset (int type,int base_reg,long offset );184 void op_fld_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset );183 void op_fld_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None ); 184 void op_fld_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None); 185 185 void op_fstp_basereg (int type,int base_reg); 186 void op_fstp_base_offset (int type,int base_reg,long offset );187 void op_fstp_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset );186 void op_fstp_base_offset (int type,int base_reg,long offset, Schedule::Type scheduleType = Schedule::None); 187 void op_fstp_base_offset_ex (int type,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType = Schedule::None); 188 188 void op_fistp_ptr_esp ( int typeSize ); 189 189 void op_fstp_push ( Type &type );
Note:
See TracChangeset
for help on using the changeset viewer.