- Timestamp:
- Jul 23, 2007, 3:24:20 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler64/CodeGenerator.cpp
r226 r228 79 79 #define INDEX_NON 0x04 80 80 81 void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp ){81 void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType ){ 82 82 if(mod==MOD_DISP32){ 83 83 //ModR/Mバイト … … 115 115 if(mod==MOD_BASE_DISP8) pNativeCode->Put( (char)disp ); 116 116 else{ 117 pNativeCode->Put( disp );118 } 119 } 120 121 122 123 void CodeGenerator::__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod ){117 pNativeCode->Put( disp, scheduleType ); 118 } 119 } 120 121 122 123 void CodeGenerator::__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType ){ 124 124 //命令プリフィックス 125 125 if(op_prefix) pNativeCode->Put( op_prefix ); … … 133 133 134 134 //ModR/M, SIB, disp 135 set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset); 135 set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType ); 136 } 137 138 void CodeGenerator::__jmp_op_format( char opcode, long offset, int op_size ) 139 { 140 pNativeCode->Put( opcode ); 141 if( op_size == sizeof(char) ) 142 { 143 pNativeCode->Put( (char)offset ); 144 } 145 else if( op_size == sizeof(long) ) 146 { 147 SetError(); 148 pNativeCode->Put( offset ); 149 } 150 else 151 { 152 SetError(); 153 } 136 154 } 137 155 … … 175 193 pNativeCode->Put( i64data ); 176 194 } 177 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,long offset,char mod ){195 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType ){ 178 196 //mov reg64,qword ptr[base_reg+offset] 179 197 //mov reg32,dword ptr[base_reg+offset] … … 190 208 else opcode=(char)0x8B; 191 209 192 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod );193 } 194 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset ){210 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType); 211 } 212 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 195 213 //mov reg64,qword ptr[base_reg1+base_reg2+offset] 196 214 //mov reg32,dword ptr[base_reg1+base_reg2+offset] … … 226 244 227 245 //オフセット値 228 pNativeCode->Put( offset );246 pNativeCode->Put( offset, scheduleType ); 229 247 } 230 248 else{ … … 561 579 562 580 ////////////////////////////////// 581 // ビット拡張 582 ////////////////////////////////// 583 584 void CodeGenerator::op_cqo() 585 { 586 pNativeCode->Put( (char)0x48 ); 587 pNativeCode->Put( (char)0x99 ); 588 } 589 590 591 592 ////////////////////////////////// 563 593 // インクリメント・デクリメント 564 594 ////////////////////////////////// … … 593 623 ///////////////////// 594 624 595 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod ){625 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 596 626 //add reg64,qword ptr[base_reg+offset] 597 627 //add reg32,dword ptr[base_reg+offset] … … 608 638 else opcode=(char)0x03; 609 639 610 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod );640 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType ); 611 641 } 612 642 … … 638 668 } 639 669 } 640 void CodeGenerator::op_add 64_reg(int reg1,int reg2){670 void CodeGenerator::op_add_RR(int reg1,int reg2){ 641 671 //add reg1,reg2 642 672 char RexByte=-1; … … 1704 1734 1705 1735 ///////////////////////////// 1736 // 分岐 1737 ///////////////////////////// 1738 1739 void CodeGenerator::op_jle( long offset, int op_size ) 1740 { 1741 __jmp_op_format( (char)0x7E, offset, op_size ); 1742 } 1743 void CodeGenerator::op_jbe( long offset, int op_size ) 1744 { 1745 __jmp_op_format( (char)0x76, offset, op_size ); 1746 } 1747 void CodeGenerator::op_jge( long offset, int op_size ) 1748 { 1749 __jmp_op_format( (char)0x7D, offset, op_size ); 1750 } 1751 void CodeGenerator::op_jae( long offset, int op_size ) 1752 { 1753 __jmp_op_format( (char)0x73, offset, op_size ); 1754 } 1755 void CodeGenerator::op_jl( long offset, int op_size ) 1756 { 1757 __jmp_op_format( (char)0x7C, offset, op_size ); 1758 } 1759 void CodeGenerator::op_jb( long offset, int op_size ) 1760 { 1761 __jmp_op_format( (char)0x72, offset, op_size ); 1762 } 1763 void CodeGenerator::op_jg( long offset, int op_size ) 1764 { 1765 __jmp_op_format( (char)0x7F, offset, op_size ); 1766 } 1767 void CodeGenerator::op_ja( long offset, int op_size ) 1768 { 1769 __jmp_op_format( (char)0x77, offset, op_size ); 1770 } 1771 void CodeGenerator::op_jne( long offset, int op_size ) 1772 { 1773 __jmp_op_format( (char)0x75, offset, op_size ); 1774 } 1775 void CodeGenerator::op_je( long offset, int op_size ) 1776 { 1777 __jmp_op_format( (char)0x74, offset, op_size ); 1778 } 1779 void CodeGenerator::op_jmp( long offset, int op_size ) 1780 { 1781 __jmp_op_format( (char)0xEB, offset, op_size ); 1782 } 1783 1784 1785 1786 ///////////////////////////// 1706 1787 // 関数呼び出し 1707 1788 ///////////////////////////// -
trunk/abdev/BasicCompiler64/Compile_Calc_PushVar.cpp
r226 r228 185 185 if(pRelativeVar->bOffsetOffset){ 186 186 //mov reg, ptr[r11+offset] 187 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32); 188 obp-=sizeof(long); 189 pobj_GlobalVarSchedule->add(); 190 obp+=sizeof(long); 187 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::GlobalVar ); 191 188 } 192 189 else{ 193 190 //mov reg, ptr[offset] 194 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32); 195 obp-=sizeof(long); 196 pobj_GlobalVarSchedule->add(); 197 obp+=sizeof(long); 191 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar ); 198 192 } 199 193 } … … 201 195 if(pRelativeVar->bOffsetOffset){ 202 196 //add r11,qword ptr[offset] 203 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32); 204 obp-=sizeof(long); 205 pobj_GlobalVarSchedule->add(); 206 obp+=sizeof(long); 197 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar ); 207 198 } 208 199 else{ 209 200 //mov r11,qword ptr[offset] 210 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32); 211 obp-=sizeof(long); 212 pobj_GlobalVarSchedule->add(); 213 obp+=sizeof(long); 201 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar ); 214 202 } 215 203 … … 219 207 if(pRelativeVar->bOffsetOffset){ 220 208 //mov reg, ptr[rsp+r11+offset] 221 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET); 222 obp-=sizeof(long); 223 AddLocalVarAddrSchedule(); 224 obp+=sizeof(long); 209 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET, Schedule::LocalVar ); 225 210 } 226 211 else{ 227 212 //mov reg, ptr[rsp+offset] 228 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 229 obp-=sizeof(long); 230 AddLocalVarAddrSchedule(); 231 obp+=sizeof(long); 213 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 232 214 } 233 215 } … … 235 217 if(pRelativeVar->bOffsetOffset){ 236 218 //add r11,qword ptr[rsp+offset] 237 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 238 obp-=sizeof(long); 239 AddLocalVarAddrSchedule(); 240 obp+=sizeof(long); 219 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 241 220 } 242 221 else{ 243 222 //mov r11,qword ptr[rsp+offset] 244 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 245 obp-=sizeof(long); 246 AddLocalVarAddrSchedule(); 247 obp+=sizeof(long); 223 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar ); 248 224 } 249 225 -
trunk/abdev/BasicCompiler64/Compile_CallProc.cpp
r226 r228 82 82 83 83 //call rax 84 OpBuffer[obp++]=(char)0xFF; 85 OpBuffer[obp++]=(char)0xD0; 84 compiler.codeGenerator.PutOld( 85 (char)0xFF, 86 (char)0xD0 87 ); 86 88 87 89 … … 361 363 //call qword ptr[r11+func_index] 362 364 if(i2*PTR_SIZE<=0x7F){ 363 OpBuffer[obp++]=(char)0x41; 364 OpBuffer[obp++]=(char)0xFF; 365 OpBuffer[obp++]=(char)0x53; 366 OpBuffer[obp++]=(char)(i2*PTR_SIZE); 365 compiler.codeGenerator.PutOld( 366 (char)0x41, 367 (char)0xFF, 368 (char)0x53, 369 (char)(i2*PTR_SIZE) 370 ); 367 371 } 368 372 else{ 369 OpBuffer[obp++]=(char)0x41; 370 OpBuffer[obp++]=(char)0xFF; 371 OpBuffer[obp++]=(char)0x93; 372 *((long *)(OpBuffer+obp))=i2*PTR_SIZE; 373 obp+=sizeof(long); 373 compiler.codeGenerator.PutOld( 374 (char)0x41, 375 (char)0xFF, 376 (char)0x93, 377 (long)(i2*PTR_SIZE) 378 ); 374 379 } 375 380 } -
trunk/abdev/BasicCompiler64/Compile_Object.cpp
r226 r228 79 79 pobj_sf->pop(REG_RBX); 80 80 81 //add eax,TypeSize 82 OpBuffer[obp++]=(char)0x05; 83 *((long *)(OpBuffer+obp))=ObjectSize; 84 obp+=sizeof(long); 85 86 //sub ebx,1 87 OpBuffer[obp++]=(char)0x83; 88 OpBuffer[obp++]=(char)0xEB; 89 OpBuffer[obp++]=(char)0x01; 81 //add rax,TypeSize 82 compiler.codeGenerator.op_add_RV( REG_RAX, ObjectSize ); 83 84 //sub rbx,1 85 compiler.codeGenerator.op_sub_RV( sizeof(_int64), REG_RBX, 1 ); 90 86 91 87 //jnz ↑ … … 275 271 276 272 //call rdi 277 OpBuffer[obp++]=(char)0xFF; 278 OpBuffer[obp++]=(char)0xD7; 273 compiler.codeGenerator.PutOld( 274 (char)0xFF, 275 (char)0xD7 276 ); 279 277 280 278 //mov rcx,qword ptr[rsp+offset] ※スタックフレームを利用 … … 282 280 283 281 //add rcx,rsi 284 compiler.codeGenerator.op_add 64_reg(REG_RCX,REG_RSI);282 compiler.codeGenerator.op_add_RR(REG_RCX,REG_RSI); 285 283 286 284 //sub rbx,1 -
trunk/abdev/BasicCompiler64/Compile_Set_Var.cpp
r226 r228 178 178 directmem: 179 179 //movsd qword ptr[r11],xmm0 180 OpBuffer[obp++]=(char)0xF2; 181 OpBuffer[obp++]=(char)0x41; 182 OpBuffer[obp++]=(char)0x0F; 183 OpBuffer[obp++]=(char)0x11; 184 OpBuffer[obp++]=(char)0x03; 180 compiler.codeGenerator.op_movsd_MR( REG_XMM0, REG_R11, 0, MOD_BASE ); 185 181 } 186 182 } … … 269 265 directmem: 270 266 //movss dword ptr[r11],xmm0 271 OpBuffer[obp++]=(char)0xF3; 272 OpBuffer[obp++]=(char)0x41; 273 OpBuffer[obp++]=(char)0x0F; 274 OpBuffer[obp++]=(char)0x11; 275 OpBuffer[obp++]=(char)0x03; 267 compiler.codeGenerator.op_movss_MR( REG_XMM0, REG_R11, 0, MOD_BASE ); 276 268 } 277 269 } -
trunk/abdev/BasicCompiler64/Compile_Var.cpp
r226 r228 72 72 73 73 //add r11,reg 74 compiler.codeGenerator.op_add 64_reg(REG_R11,reg);74 compiler.codeGenerator.op_add_RR(REG_R11,reg); 75 75 } 76 76 void SetRelativeOffset( RELATIVE_VAR &relativeVar ){ … … 176 176 177 177 //add r12,reg 178 compiler.codeGenerator.op_add 64_reg(REG_R12,reg);178 compiler.codeGenerator.op_add_RR(REG_R12,reg); 179 179 180 180 HeapDefaultFree(pParm[i]); … … 182 182 183 183 //imul r12,TypeSize 184 OpBuffer[obp++]=(char)0x4D; 185 OpBuffer[obp++]=(char)0x69; 186 OpBuffer[obp++]=(char)0xE4; 187 *((long *)(OpBuffer+obp))=type.GetSize(); 188 obp+=sizeof(long); 184 compiler.codeGenerator.op_imul_RV( sizeof(_int64), REG_R12, type.GetSize() ); 189 185 190 186 //mov r11,qword ptr[rsp+offset] ※スタックフレームを利用 … … 192 188 193 189 //add r11,r12 194 OpBuffer[obp++]=(char)0x4D; 195 OpBuffer[obp++]=(char)0x03; 196 OpBuffer[obp++]=(char)0xDC; 190 compiler.codeGenerator.op_add_RR( REG_R11, REG_R12 ); 197 191 198 192 return true; … … 275 269 if(offset){ 276 270 //add r11,offset 277 OpBuffer[obp++]=(char)0x49; 278 OpBuffer[obp++]=(char)0x81; 279 OpBuffer[obp++]=(char)0xC3; 280 *((long *)(OpBuffer+obp))=offset; 281 obp+=sizeof(long); 271 compiler.codeGenerator.op_add_RV( REG_R11, offset ); 282 272 } 283 273 … … 1279 1269 1280 1270 //add r11,rsp 1281 compiler.codeGenerator.op_add 64_reg(REG_R11,REG_RSP);1271 compiler.codeGenerator.op_add_RR(REG_R11,REG_RSP); 1282 1272 1283 1273 //mov reg,r11 -
trunk/abdev/BasicCompiler64/NumOpe_Arithmetic.cpp
r226 r228 37 37 if(idCalc==CALC_ADDITION){ 38 38 //addsd xmm_reg1,xmm_reg2 39 OpBuffer[obp++]=(char)0xF2; 40 OpBuffer[obp++]=(char)0x0F; 41 OpBuffer[obp++]=(char)0x58; 42 OpBuffer[obp++]=(char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)); 39 compiler.codeGenerator.PutOld( 40 (char)0xF2, 41 (char)0x0F, 42 (char)0x58, 43 (char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)) 44 ); 43 45 } 44 46 else if(idCalc==CALC_SUBTRACTION){ 45 47 //subsd xmm_reg1,xmm_reg2 46 OpBuffer[obp++]=(char)0xF2; 47 OpBuffer[obp++]=(char)0x0F; 48 OpBuffer[obp++]=(char)0x5C; 49 OpBuffer[obp++]=(char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)); 48 compiler.codeGenerator.PutOld( 49 (char)0xF2, 50 (char)0x0F, 51 (char)0x5C, 52 (char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)) 53 ); 50 54 } 51 55 else if(idCalc==CALC_PRODUCT){ 52 56 //mulsd xmm_reg1,xmm_reg2 53 OpBuffer[obp++]=(char)0xF2; 54 OpBuffer[obp++]=(char)0x0F; 55 OpBuffer[obp++]=(char)0x59; 56 OpBuffer[obp++]=(char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)); 57 compiler.codeGenerator.PutOld( 58 (char)0xF2, 59 (char)0x0F, 60 (char)0x59, 61 (char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)) 62 ); 57 63 } 58 64 … … 69 75 if(idCalc==CALC_ADDITION){ 70 76 //addss xmm_reg1,xmm_reg2 71 OpBuffer[obp++]=(char)0xF3; 72 OpBuffer[obp++]=(char)0x0F; 73 OpBuffer[obp++]=(char)0x58; 74 OpBuffer[obp++]=(char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)); 77 compiler.codeGenerator.PutOld( 78 (char)0xF3, 79 (char)0x0F, 80 (char)0x58, 81 (char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)) 82 ); 75 83 } 76 84 else if(idCalc==CALC_SUBTRACTION){ 77 85 //subss xmm_reg1,xmm_reg2 78 OpBuffer[obp++]=(char)0xF3; 79 OpBuffer[obp++]=(char)0x0F; 80 OpBuffer[obp++]=(char)0x5C; 81 OpBuffer[obp++]=(char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)); 86 compiler.codeGenerator.PutOld( 87 (char)0xF3, 88 (char)0x0F, 89 (char)0x5C, 90 (char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)) 91 ); 82 92 } 83 93 else if(idCalc==CALC_PRODUCT){ 84 94 //mulss xmm_reg1,xmm_reg2 85 OpBuffer[obp++]=(char)0xF3; 86 OpBuffer[obp++]=(char)0x0F; 87 OpBuffer[obp++]=(char)0x59; 88 OpBuffer[obp++]=(char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)); 95 compiler.codeGenerator.PutOld( 96 (char)0xF3, 97 (char)0x0F, 98 (char)0x59, 99 (char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)) 100 ); 89 101 } 90 102 … … 104 116 if(idCalc==CALC_ADDITION){ 105 117 //add reg1,reg2 106 compiler.codeGenerator.op_add 64_reg(reg1,reg2);118 compiler.codeGenerator.op_add_RR(reg1,reg2); 107 119 } 108 120 else if(idCalc==CALC_SUBTRACTION){ … … 214 226 215 227 //cqo 216 OpBuffer[obp++]=(char)0x48; 217 OpBuffer[obp++]=(char)0x99; 228 compiler.codeGenerator.op_cqo(); 218 229 } 219 230 else{ … … 294 305 295 306 //divsd xmm_reg1,xmm_reg2 296 OpBuffer[obp++]=(char)0xF2; 297 OpBuffer[obp++]=(char)0x0F; 298 OpBuffer[obp++]=(char)0x5E; 299 OpBuffer[obp++]=(char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)); 307 compiler.codeGenerator.PutOld( 308 (char)0xF2, 309 (char)0x0F, 310 (char)0x5E, 311 (char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)) 312 ); 300 313 301 314 if(xmm_reg1==REG_XMM4){ … … 310 323 311 324 //divss xmm_reg1,xmm_reg2 312 OpBuffer[obp++]=(char)0xF3; 313 OpBuffer[obp++]=(char)0x0F; 314 OpBuffer[obp++]=(char)0x5E; 315 OpBuffer[obp++]=(char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)); 325 compiler.codeGenerator.PutOld( 326 (char)0xF3, 327 (char)0x0F, 328 (char)0x5E, 329 (char)(0xC0 | REGISTER_OPERAND(xmm_reg1)<<3 | REGISTER_OPERAND(xmm_reg2)) 330 ); 316 331 317 332 if(xmm_reg1==REG_XMM4){ … … 390 405 391 406 //cqo 392 OpBuffer[obp++]=(char)0x48; 393 OpBuffer[obp++]=(char)0x99; 407 compiler.codeGenerator.op_cqo(); 394 408 } 395 409 else{ -
trunk/abdev/BasicCompiler64/NumOpe_Relation.cpp
r226 r228 67 67 //////////////////// 68 68 69 int jmpOffset = 5; 70 69 71 if(idCalc==CALC_PE){ 70 72 // reg1 <= reg2 … … 72 74 //符号あり演算 73 75 //jle 74 OpBuffer[obp++]=(char)0x7E;76 compiler.codeGenerator.op_jle( jmpOffset ); 75 77 } 76 78 else{ 77 79 //符号なし演算 78 80 //jbe 79 OpBuffer[obp++]=(char)0x76;81 compiler.codeGenerator.op_jbe( jmpOffset ); 80 82 } 81 83 } … … 85 87 //符号あり演算 86 88 //jge 87 OpBuffer[obp++]=(char)0x7D;89 compiler.codeGenerator.op_jge( jmpOffset ); 88 90 } 89 91 else{ 90 92 //符号なし演算 91 93 //jae 92 OpBuffer[obp++]=(char)0x73;94 compiler.codeGenerator.op_jae( jmpOffset ); 93 95 } 94 96 } … … 98 100 //符号あり演算 99 101 //jl 100 OpBuffer[obp++]=(char)0x7C;102 compiler.codeGenerator.op_jl( jmpOffset ); 101 103 } 102 104 else{ 103 105 //符号なし演算 104 106 //jb 105 OpBuffer[obp++]=(char)0x72;107 compiler.codeGenerator.op_jb( jmpOffset ); 106 108 } 107 109 } … … 111 113 //符号あり演算 112 114 //jg 113 OpBuffer[obp++]=(char)0x7F;115 compiler.codeGenerator.op_jg( jmpOffset ); 114 116 } 115 117 else{ 116 118 //符号なし演算 117 119 //ja 118 OpBuffer[obp++]=(char)0x77;120 compiler.codeGenerator.op_ja( jmpOffset ); 119 121 } 120 122 } … … 123 125 124 126 //jne 125 OpBuffer[obp++]=(char)0x75;127 compiler.codeGenerator.op_jne( jmpOffset ); 126 128 } 127 129 else if(idCalc==CALC_EQUAL){ … … 129 131 130 132 //je 131 OpBuffer[obp++]=(char)0x74;133 compiler.codeGenerator.op_je( jmpOffset ); 132 134 } 133 OpBuffer[obp++]=(char)0x05;134 135 135 136 … … 142 143 143 144 //jmp 7(次のmovを飛び越す) 144 OpBuffer[obp++]=(char)0xEB; 145 OpBuffer[obp++]=(char)0x07; 145 compiler.codeGenerator.op_jge( 7 ); 146 146 147 147 -
trunk/abdev/BasicCompiler64/NumOpe_TypeOperation.cpp
r226 r228 85 85 86 86 //jge 9 87 OpBuffer[obp++]=(char)0x7D; 88 OpBuffer[obp++]=(char)0x09; 87 compiler.codeGenerator.op_jge( 9 ); 89 88 90 89 //addsd xmm_reg,qword ptr[offset] ※offset value:43f0000000000000 … … 144 143 145 144 //jge 9 146 OpBuffer[obp++]=(char)0x7D; 147 OpBuffer[obp++]=(char)0x09; 145 compiler.codeGenerator.op_jge( 9 ); 148 146 149 147 //addss xmm_reg,dword ptr[offset] ※offset value:5f800000 … … 315 313 if(type[sp-1]==DEF_DOUBLE){ 316 314 //movsd xmm5,xmm_reg 317 OpBuffer[obp++]=(char)0xF2; 318 OpBuffer[obp++]=(char)0x0F; 319 OpBuffer[obp++]=(char)0x10; 320 OpBuffer[obp++]=(char)(0xE8 | REGISTER_OPERAND(xmm_reg2)); 315 compiler.codeGenerator.op_movsd_RR( REG_XMM5, xmm_reg2 ); 321 316 } 322 317 if(type[sp-1]==DEF_SINGLE){ 323 318 //movss xmm5,xmm_reg 324 OpBuffer[obp++]=(char)0xF3; 325 OpBuffer[obp++]=(char)0x0F; 326 OpBuffer[obp++]=(char)0x10; 327 OpBuffer[obp++]=(char)(0xE8 | REGISTER_OPERAND(xmm_reg2)); 319 compiler.codeGenerator.op_movss_RR( REG_XMM5, xmm_reg2 ); 328 320 } 329 321 -
trunk/abdev/BasicCompiler64/stack_frame.cpp
r226 r228 80 80 if(varSize==sizeof(float)){ 81 81 //movss dword ptr[rsp+offset],xmm_reg 82 OpBuffer[obp++]=(char)0xF3; 83 OpBuffer[obp++]=(char)0x0F; 84 OpBuffer[obp++]=(char)0x11; 85 OpBuffer[obp++]=(char)(0x84| REGISTER_OPERAND(xmm_reg)<<3 ); 86 OpBuffer[obp++]=(char)0x24; 87 *((long *)(OpBuffer+obp))=now_sp; 88 obp+=sizeof(long); 82 compiler.codeGenerator.op_movss_MR( xmm_reg, REG_RSP, now_sp, MOD_BASE_DISP32 ); 89 83 } 90 84 … … 113 107 if(varSize==sizeof(float)){ 114 108 //movss xmm_reg,dword ptr[rsp+offset] 115 OpBuffer[obp++]=(char)0xF3; 116 OpBuffer[obp++]=(char)0x0F; 117 OpBuffer[obp++]=(char)0x10; 118 OpBuffer[obp++]=(char)(0x84| REGISTER_OPERAND(xmm_reg)<<3 ); 119 OpBuffer[obp++]=(char)0x24; 120 *((long *)(OpBuffer+obp))=now_sp; 121 obp+=sizeof(long); 109 compiler.codeGenerator.op_movss_MR( xmm_reg, REG_RSP, now_sp, MOD_BASE_DISP32 ); 122 110 } 123 111 -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r226 r228 32 32 33 33 #ifdef _AMD64_ 34 ///////////////////////////////////////////////////////////////// 35 // 64ビット 36 ///////////////////////////////////////////////////////////////// 34 37 private: 35 38 void set_rex(int op_size,int reg,int index_reg,int base_reg); 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(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod); 39 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 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 ); 38 42 public: 39 43 void op_mov_RV (int op_size,int reg,long i32data); 40 44 void op_mov_RV64 (int reg,_int64 i64data); 41 void op_mov_RM (int op_size,int reg,int base_reg,long offset,char mod );42 void op_mov_RM_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset );45 void op_mov_RM (int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType = Schedule::None ); 46 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 ); 43 47 void op_mov_MR (int op_size,int reg,int base_reg,long offset,char mod); 44 48 void op_mov_MR_ex (int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset); … … 53 57 void op_movsx32_FromReg8 (int reg32,int reg8); 54 58 void op_movsx16_FromReg8 (int reg32,int reg8); 59 void op_cqo (); 55 60 void op_inc (int reg); 56 61 void op_dec (int reg); 57 void op_add_RM (int op_size,int reg,int base_reg,int offset,char mod );62 void op_add_RM (int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None ); 58 63 void op_add_RV (int reg,long offset); 59 void op_add 64_reg(int reg1,int reg2);64 void op_add_RR (int reg1,int reg2); 60 65 void op_add32_reg (int reg1,int reg2); 61 66 void op_sub_RV (int op_size,int reg,long i32data); … … 104 109 void op_fld_ptr_esp(int type); 105 110 void op_zero_reg(int reg); 111 void op_jle( long offset, int op_size = sizeof(char) ); 112 void op_jbe( long offset, int op_size = sizeof(char) ); 113 void op_jge( long offset, int op_size = sizeof(char) ); 114 void op_jae( long offset, int op_size = sizeof(char) ); 115 void op_jl( long offset, int op_size = sizeof(char) ); 116 void op_jb( long offset, int op_size = sizeof(char) ); 117 void op_jg( long offset, int op_size = sizeof(char) ); 118 void op_ja( long offset, int op_size = sizeof(char) ); 119 void op_jne( long offset, int op_size = sizeof(char) ); 120 void op_je( long offset, int op_size = sizeof(char) ); 121 void op_jmp( long offset, int op_size = sizeof(char) ); 106 122 void op_call( const UserProc *pUserProc ); 107 123 void op_call( const DllProc *pDllProc ); … … 109 125 110 126 #else 127 ///////////////////////////////////////////////////////////////// 128 // 32ビット 129 ///////////////////////////////////////////////////////////////// 111 130 private: 112 131 void set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp); … … 200 219 pNativeCode->Put( c4 ); 201 220 } 221 void PutOld( char c1, char c2, char c3, long l ) 222 { 223 pNativeCode->Put( c1 ); 224 pNativeCode->Put( c2 ); 225 pNativeCode->Put( c3 ); 226 pNativeCode->Put( l ); 227 } 202 228 void PutOld( char c1, char c2, char c3, char c4, char c5 ) 203 229 { -
trunk/abdev/BasicCompiler_Common/include/NativeCode.h
r226 r228 3 3 #include <vector> 4 4 5 #include <jenga/include/common/Exception.h> 6 5 7 #include <BoostSerializationSupport.h> 8 9 void AddLocalVarAddrSchedule(); 6 10 7 11 class Schedule … … 156 160 157 161 // 未完成 162 switch( scheduleType ) 163 { 164 case Schedule::None: 165 break; 166 case Schedule::GlobalVar: 167 extern CSchedule *pobj_GlobalVarSchedule; 168 pobj_GlobalVarSchedule->add(); 169 break; 170 case Schedule::LocalVar: 171 AddLocalVarAddrSchedule(); 172 break; 173 case Schedule::Relocation: 174 break; 175 default: 176 Jenga::Throw( "scheduleTypeが無効な値を保持している" ); 177 break; 178 } 158 179 extern char *OpBuffer; 159 180 extern int obp;
Note:
See TracChangeset
for help on using the changeset viewer.