Changeset 242 in dev
- Timestamp:
- Jul 27, 2007, 3:40:33 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler64/BasicCompiler.vcproj
r232 r242 1074 1074 </Filter> 1075 1075 <Filter 1076 Name="Language Classes"1077 >1078 <File1079 RelativePath="..\BasicCompiler_Common\src\Class.cpp"1080 >1081 </File>1082 <File1083 RelativePath="..\BasicCompiler_Common\src\CodeGenerator.cpp"1084 >1085 </File>1086 <File1087 RelativePath="..\BasicCompiler_Common\src\Compiler.cpp"1088 >1089 </File>1090 <File1091 RelativePath="..\BasicCompiler_Common\src\Const.cpp"1092 >1093 </File>1094 <File1095 RelativePath="..\BasicCompiler_Common\src\DataTable.cpp"1096 >1097 </File>1098 <File1099 RelativePath="..\BasicCompiler_Common\src\Exception.cpp"1100 >1101 </File>1102 <File1103 RelativePath="..\BasicCompiler_Common\src\LexicalScopingImpl.cpp"1104 >1105 </File>1106 <File1107 RelativePath="..\BasicCompiler_Common\src\Method.cpp"1108 >1109 </File>1110 <File1111 RelativePath="..\BasicCompiler_Common\src\Namespace.cpp"1112 >1113 </File>1114 <File1115 RelativePath="..\BasicCompiler_Common\src\NamespaceSupporter.cpp"1116 >1117 </File>1118 <File1119 RelativePath="..\BasicCompiler_Common\src\NativeCode.cpp"1120 >1121 </File>1122 <File1123 RelativePath="..\BasicCompiler_Common\src\Procedure.cpp"1124 >1125 </File>1126 <File1127 RelativePath="..\BasicCompiler_Common\src\Program.cpp"1128 >1129 </File>1130 <File1131 RelativePath="..\BasicCompiler_Common\src\SmoothieImpl.cpp"1132 >1133 </File>1134 <File1135 RelativePath="..\BasicCompiler_Common\src\Symbol.cpp"1136 >1137 </File>1138 <File1139 RelativePath="..\BasicCompiler_Common\src\Type.cpp"1140 >1141 </File>1142 <File1143 RelativePath="..\BasicCompiler_Common\src\TypeDef.cpp"1144 >1145 </File>1146 <File1147 RelativePath="..\BasicCompiler_Common\src\Variable.cpp"1148 >1149 </File>1150 </Filter>1151 <Filter1152 1076 Name="Common Classes" 1153 1077 > … … 1172 1096 </FileConfiguration> 1173 1097 </File> 1098 <Filter 1099 Name="Language Classes" 1100 > 1101 <File 1102 RelativePath="..\BasicCompiler_Common\src\Class.cpp" 1103 > 1104 </File> 1105 <File 1106 RelativePath="..\BasicCompiler_Common\src\CodeGenerator.cpp" 1107 > 1108 </File> 1109 <File 1110 RelativePath="..\BasicCompiler_Common\src\Compiler.cpp" 1111 > 1112 </File> 1113 <File 1114 RelativePath="..\BasicCompiler_Common\src\Const.cpp" 1115 > 1116 </File> 1117 <File 1118 RelativePath="..\BasicCompiler_Common\src\DataTable.cpp" 1119 > 1120 </File> 1121 <File 1122 RelativePath="..\BasicCompiler_Common\src\Exception.cpp" 1123 > 1124 </File> 1125 <File 1126 RelativePath="..\BasicCompiler_Common\src\LexicalScopingImpl.cpp" 1127 > 1128 </File> 1129 <File 1130 RelativePath="..\BasicCompiler_Common\src\Method.cpp" 1131 > 1132 </File> 1133 <File 1134 RelativePath="..\BasicCompiler_Common\src\Namespace.cpp" 1135 > 1136 </File> 1137 <File 1138 RelativePath="..\BasicCompiler_Common\src\NamespaceSupporter.cpp" 1139 > 1140 </File> 1141 <File 1142 RelativePath="..\BasicCompiler_Common\src\NativeCode.cpp" 1143 > 1144 </File> 1145 <File 1146 RelativePath="..\BasicCompiler_Common\src\Procedure.cpp" 1147 > 1148 </File> 1149 <File 1150 RelativePath="..\BasicCompiler_Common\src\Program.cpp" 1151 > 1152 </File> 1153 <File 1154 RelativePath="..\BasicCompiler_Common\src\SmoothieImpl.cpp" 1155 > 1156 </File> 1157 <File 1158 RelativePath="..\BasicCompiler_Common\src\Symbol.cpp" 1159 > 1160 </File> 1161 <File 1162 RelativePath="..\BasicCompiler_Common\src\Type.cpp" 1163 > 1164 </File> 1165 <File 1166 RelativePath="..\BasicCompiler_Common\src\TypeDef.cpp" 1167 > 1168 </File> 1169 <File 1170 RelativePath="..\BasicCompiler_Common\src\Variable.cpp" 1171 > 1172 </File> 1173 </Filter> 1174 <Filter 1175 Name="Core Classes" 1176 > 1177 <File 1178 RelativePath="..\BasicCompiler_Common\src\CommonCodeGenerator.cpp" 1179 > 1180 </File> 1181 </Filter> 1174 1182 </Filter> 1175 1183 </Filter> -
trunk/abdev/BasicCompiler64/CodeGenerator.cpp
r232 r242 136 136 } 137 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 else151 {152 SetError();153 }154 }155 156 138 157 139 … … 1690 1672 1691 1673 ///////////////////////////// 1692 // 分岐1693 /////////////////////////////1694 1695 void CodeGenerator::op_jle( long offset, int op_size )1696 {1697 __jmp_op_format( (char)0x7E, offset, op_size );1698 }1699 void CodeGenerator::op_jbe( long offset, int op_size )1700 {1701 __jmp_op_format( (char)0x76, offset, op_size );1702 }1703 void CodeGenerator::op_jge( long offset, int op_size )1704 {1705 __jmp_op_format( (char)0x7D, offset, op_size );1706 }1707 void CodeGenerator::op_jae( long offset, int op_size )1708 {1709 __jmp_op_format( (char)0x73, offset, op_size );1710 }1711 void CodeGenerator::op_jl( long offset, int op_size )1712 {1713 __jmp_op_format( (char)0x7C, offset, op_size );1714 }1715 void CodeGenerator::op_jb( long offset, int op_size )1716 {1717 __jmp_op_format( (char)0x72, offset, op_size );1718 }1719 void CodeGenerator::op_jg( long offset, int op_size )1720 {1721 __jmp_op_format( (char)0x7F, offset, op_size );1722 }1723 void CodeGenerator::op_ja( long offset, int op_size )1724 {1725 __jmp_op_format( (char)0x77, offset, op_size );1726 }1727 void CodeGenerator::op_jne( long offset, int op_size )1728 {1729 __jmp_op_format( (char)0x75, offset, op_size );1730 }1731 void CodeGenerator::op_je( long offset, int op_size )1732 {1733 __jmp_op_format( (char)0x74, offset, op_size );1734 }1735 void CodeGenerator::op_jmp( long offset, int op_size )1736 {1737 __jmp_op_format( (char)0xEB, offset, op_size );1738 }1739 1740 1741 1742 /////////////////////////////1743 1674 // 関数呼び出し 1744 1675 ///////////////////////////// -
trunk/abdev/BasicCompiler64/Compile_Calc_PushVar.cpp
r232 r242 24 24 if(pRelativeVar->bOffsetOffset){ 25 25 //movlpd xmm_reg,qword ptr[rsp+r11+offset] 26 OpBuffer[obp++]=(char)0x66; 27 OpBuffer[obp++]=(char)0x42; 28 OpBuffer[obp++]=(char)0x0F; 29 OpBuffer[obp++]=(char)0x12; 30 OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3); 31 OpBuffer[obp++]=(char)0x1C; 32 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset; 33 AddLocalVarAddrSchedule(); 34 obp+=sizeof(long); 26 compiler.codeGenerator.PutOld( 27 (char)0x66, 28 (char)0x42, 29 (char)0x0F, 30 (char)0x12, 31 (char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3), 32 (char)0x1C 33 ); 34 compiler.codeGenerator.PutOld( 35 (long)pRelativeVar->offset, 36 Schedule::LocalVar 37 ); 35 38 } 36 39 else{ … … 74 77 if(pRelativeVar->bOffsetOffset){ 75 78 //movss xmm_reg,dword ptr[rsp+r11+offset] 76 OpBuffer[obp++]=(char)0xF3; 77 OpBuffer[obp++]=(char)0x42; 78 OpBuffer[obp++]=(char)0x0F; 79 OpBuffer[obp++]=(char)0x10; 80 OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3); 81 OpBuffer[obp++]=(char)0x1C; 82 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset; 83 AddLocalVarAddrSchedule(); 84 obp+=sizeof(long); 79 compiler.codeGenerator.PutOld( 80 (char)0xF3, 81 (char)0x42, 82 (char)0x0F, 83 (char)0x10, 84 (char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3), 85 (char)0x1C 86 ); 87 compiler.codeGenerator.PutOld( 88 (long)pRelativeVar->offset, 89 Schedule::LocalVar 90 ); 85 91 } 86 92 else{ -
trunk/abdev/BasicCompiler64/Compile_ProcOp.cpp
r232 r242 338 338 339 339 //Continueアドレスを初期化 340 extern DWORD dwContinueAddress; 341 dwContinueAddress=-1; 340 compiler.codeGenerator.ClearContinueArea(); 342 341 343 342 //ローカル変数に関する情報 … … 585 584 586 585 //mov rax,offset 587 compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RAX,offset); 588 obp-=sizeof(long); 589 pobj_DataTableSchedule->add(); 590 obp+=sizeof(long); 586 compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RAX,offset, Schedule::DataTable ); 591 587 592 588 //Thisポインタをrcxにコピー -
trunk/abdev/BasicCompiler64/Compile_Set_Var.cpp
r232 r242 118 118 if(pRelative->bOffsetOffset){ 119 119 //movsd qword ptr[rsp+r11+offset],xmm0 120 OpBuffer[obp++]=(char)0xF2; 121 OpBuffer[obp++]=(char)0x42; 122 OpBuffer[obp++]=(char)0x0F; 123 OpBuffer[obp++]=(char)0x11; 124 OpBuffer[obp++]=(char)0x84; 125 OpBuffer[obp++]=(char)0x1C; 126 *((long *)(OpBuffer+obp))=(int)pRelative->offset; 127 AddLocalVarAddrSchedule(); 128 obp+=sizeof(long); 120 compiler.codeGenerator.PutOld( 121 (char)0xF2, 122 (char)0x42, 123 (char)0x0F, 124 (char)0x11, 125 (char)0x84, 126 (char)0x1C 127 ); 128 compiler.codeGenerator.PutOld( 129 (long)pRelative->offset, 130 Schedule::LocalVar 131 ); 129 132 } 130 133 else{ … … 175 178 if(pRelative->bOffsetOffset){ 176 179 //movss dword ptr[rsp+r11+offset],xmm0 177 OpBuffer[obp++]=(char)0xF3; 178 OpBuffer[obp++]=(char)0x42; 179 OpBuffer[obp++]=(char)0x0F; 180 OpBuffer[obp++]=(char)0x11; 181 OpBuffer[obp++]=(char)0x84; 182 OpBuffer[obp++]=(char)0x1C; 183 *((long *)(OpBuffer+obp))=(int)pRelative->offset; 184 AddLocalVarAddrSchedule(); 185 obp+=sizeof(long); 180 compiler.codeGenerator.PutOld( 181 (char)0xF3, 182 (char)0x42, 183 (char)0x0F, 184 (char)0x11, 185 (char)0x84, 186 (char)0x1C 187 ); 188 compiler.codeGenerator.PutOld( 189 (long)pRelative->offset, 190 Schedule::LocalVar 191 ); 186 192 } 187 193 else{ -
trunk/abdev/BasicCompiler64/Compile_Statement.cpp
r226 r242 140 140 141 141 //comisd xmm0,qword ptr[data table offset] 142 OpBuffer[obp++]=(char)0x66; 143 OpBuffer[obp++]=(char)0x0F; 144 OpBuffer[obp++]=(char)0x2F; 145 OpBuffer[obp++]=(char)0x04; 146 OpBuffer[obp++]=(char)0x25; 147 *((long *)(OpBuffer+obp))=offset; 148 pobj_DataTableSchedule->add(); 149 obp+=sizeof(long); 142 compiler.codeGenerator.PutOld( 143 (char)0x66, 144 (char)0x0F, 145 (char)0x2F, 146 (char)0x04, 147 (char)0x25 148 ); 149 compiler.codeGenerator.PutOld( 150 (long)offset, 151 Schedule::DataTable 152 ); 150 153 } 151 154 else if(resultType.IsSingle()){ … … 154 157 155 158 //comiss xmm0,dword ptr[data table offset] 156 OpBuffer[obp++]=(char)0x0F; 157 OpBuffer[obp++]=(char)0x2F; 158 OpBuffer[obp++]=(char)0x04; 159 OpBuffer[obp++]=(char)0x25; 160 *((long *)(OpBuffer+obp))=offset; 161 pobj_DataTableSchedule->add(); 162 obp+=sizeof(long); 159 compiler.codeGenerator.PutOld( 160 (char)0x0F, 161 (char)0x2F, 162 (char)0x04, 163 (char)0x25 164 ); 165 compiler.codeGenerator.PutOld( 166 (long)offset, 167 Schedule::DataTable 168 ); 163 169 } 164 170 else{ … … 171 177 172 178 void OpcodeIf(char *Parameter){ 173 int i,i2,i3; 174 175 for(i=0;;i++){ 179 for(int i=0;;i++){ 176 180 if(Parameter[i]=='\0'){ 177 181 SetError(21,NULL,cp); … … 188 192 189 193 //je (endif、または else まで条件ジャンプ) 190 OpBuffer[obp++]=(char)0x0F; 191 OpBuffer[obp++]=(char)0x84; 192 obp+=sizeof(long); 193 194 //jeの番地 195 i3=obp; 194 CodeGenerator::PertialSchedule *pIfPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true ); 196 195 197 196 … … 203 202 GetLexicalScopes().Start( obp, SCOPE_TYPE_IF ); 204 203 205 i 2=CompileBuffer(ESC_ENDIF,0);204 int i2=CompileBuffer(ESC_ENDIF,0); 206 205 207 206 //レキシカルスコープをレベルダウン … … 211 210 if(i2==ESC_ELSE){ 212 211 //jmp (endifまで) 213 OpBuffer[obp++]=(char)0xE9; 214 obp+=sizeof(long); 215 216 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3; //ifからelseへのジャンプ先のオフセット値 217 218 i3=obp; 212 CodeGenerator::PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true ); 213 214 compiler.codeGenerator.opfix_JmpPertialSchedule( pIfPertialSchedule ); 215 219 216 220 217 … … 232 229 233 230 234 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3; //jmpジャンプ先のオフセット値231 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule ); 235 232 } 236 233 else{ 237 *((long *)(OpBuffer+i3-sizeof(long)))=obp-i3; //jeジャンプ先のオフセット値234 compiler.codeGenerator.opfix_JmpPertialSchedule( pIfPertialSchedule ); 238 235 } 239 236 } … … 304 301 305 302 //Continueアドレスのバックアップとセット 306 extern DWORD dwContinueAddress; 307 DWORD dwTempContinue; 308 dwTempContinue=dwContinueAddress; 309 dwContinueAddress=obp; 310 pobj_TempSchedule->lock((int *)&dwTempContinue); 311 pobj_TempSchedule->lock((int *)&dwContinueAddress); 303 compiler.codeGenerator.ContinueAreaBegin(); 312 304 313 305 if(!Parameter[0]) SetError(10,"While",cp); … … 317 309 318 310 //je (Wend まで) 319 OpBuffer[obp++]=(char)0x0F; 320 OpBuffer[obp++]=(char)0x84; 321 obp+=sizeof(long); 322 323 //実行中の番地 324 int je_schedule=obp; 325 pobj_TempSchedule->lock(&je_schedule); 311 CodeGenerator::PertialSchedule *pWhilePertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true ); 326 312 327 313 //レキシカルスコープをレベルアップ … … 334 320 335 321 //jmp ... 336 OpBuffer[obp++]=(char)0xE9; 337 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long)); 338 obp+=sizeof(long); 339 pobj_TempSchedule->unlock(); 340 pobj_TempSchedule->unlock(); 322 compiler.codeGenerator.op_jmp_continue(); 341 323 342 324 //レキシカルスコープをレベルダウン 343 325 GetLexicalScopes().End(); 344 326 345 *((long *)(OpBuffer+je_schedule-sizeof(long)))=obp-je_schedule; //jeジャンプ先のオフセット値 346 pobj_TempSchedule->unlock(); 327 compiler.codeGenerator.opfix_JmpPertialSchedule( pWhilePertialSchedule ); 347 328 348 329 //Continueアドレスを復元 349 dwContinueAddress=dwTempContinue;330 compiler.codeGenerator.ContinueAreaEnd(); 350 331 } 351 332 … … 354 335 extern HANDLE hHeap; 355 336 Type resultType; 356 int i,i2 ,i3;337 int i,i2; 357 338 char temporary[VN_SIZE],variable[VN_SIZE],JudgeNum[VN_SIZE],StepNum[VN_SIZE]; 358 339 bool isError = false; … … 383 364 384 365 //jmp ... 385 OpBuffer[obp++]=(char)0xE9; 386 i2=obp; 387 obp+=sizeof(long); 366 CodeGenerator::PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true ); 388 367 389 368 //Continueアドレスのバックアップとセット 390 extern DWORD dwContinueAddress; 391 DWORD dwTempContinue; 392 dwTempContinue=dwContinueAddress; 393 dwContinueAddress=obp; 394 pobj_TempSchedule->lock((int *)&dwTempContinue); 395 pobj_TempSchedule->lock((int *)&dwContinueAddress); 369 compiler.codeGenerator.ContinueAreaBegin(); 396 370 397 371 //第2パラメータを取得(to~) … … 409 383 OpcodeCalc(temporary); 410 384 411 *((long *)(OpBuffer+i2))=obp-(i2+sizeof(long));385 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule ); 412 386 413 387 //増加か減少かを区別する … … 424 398 425 399 //je [カウンタ減少の場合の判定] 426 OpBuffer[obp++]=(char)0x0F; 427 OpBuffer[obp++]=(char)0x84; 428 i2=obp; 429 obp+=sizeof(long); 400 pTempPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true ); 430 401 431 402 //判定(カウンタ増加の場合) … … 436 407 437 408 //jmp [カウンタ減少の場合の判定を飛び越す] 438 OpBuffer[obp++]=(char)0xE9; 439 i3=obp; 440 obp+=sizeof(long); 441 442 *((long *)(OpBuffer+i2))=obp-(i2+sizeof(long)); //jeジャンプ先のオフセット値 409 CodeGenerator::PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jmp( 0, sizeof(long), true ); 410 411 //jeジャンプ先のオフセット値 412 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule ); 443 413 444 414 //判定(カウンタ減少の場合) … … 448 418 NumOpe(®,temporary,Type(),resultType); 449 419 450 *((long *)(OpBuffer+i3))=obp-(i3+sizeof(long)); //jmpジャンプ先のオフセット値 420 //jmpジャンプ先のオフセット値 421 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule2 ); 451 422 452 423 //cmp rax,0 … … 456 427 457 428 //je ... 458 OpBuffer[obp++]=(char)0x0F; 459 OpBuffer[obp++]=(char)0x84; 460 int je_schedule=obp; 461 obp+=sizeof(long); 462 pobj_TempSchedule->lock(&je_schedule); 429 pTempPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true ); 463 430 464 431 //レキシカルスコープをレベルアップ … … 477 444 478 445 //jmp ... 479 OpBuffer[obp++]=(char)0xE9; 480 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long)); 481 obp+=sizeof(long); 482 if( isError == false ){ 483 pobj_TempSchedule->unlock(); 484 pobj_TempSchedule->unlock(); 485 } 446 compiler.codeGenerator.op_jmp_continue(); 486 447 487 448 //レキシカルスコープをレベルダウン 488 449 GetLexicalScopes().End(); 489 450 490 *((long *)(OpBuffer+je_schedule))=obp-(je_schedule+sizeof(long));//jeジャンプ先のオフセット値491 pobj_TempSchedule->unlock();451 //jeジャンプ先のオフセット値 452 compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule ); 492 453 493 454 //Continueアドレスを復元 494 dwContinueAddress=dwTempContinue;455 compiler.codeGenerator.ContinueAreaEnd(); 495 456 } 496 457 … … 502 463 503 464 //Continueアドレスのバックアップとセット 504 extern DWORD dwContinueAddress; 505 DWORD dwTempContinue; 506 dwTempContinue=dwContinueAddress; 507 dwContinueAddress=obp; 508 pobj_TempSchedule->lock((int *)&dwTempContinue); 509 pobj_TempSchedule->lock((int *)&dwContinueAddress); 465 compiler.codeGenerator.ContinueAreaBegin(); 510 466 511 467 //レキシカルスコープをレベルアップ … … 516 472 517 473 GetLexicalScopes().CallDestructorsOfScopeEnd(); 474 475 CodeGenerator::PertialSchedule *pDoPertialSchedule = NULL; 518 476 519 477 extern char *basbuf; … … 543 501 544 502 //je 5(ループ終了) 545 OpBuffer[obp++]=(char)0x74; 546 OpBuffer[obp++]=(char)0x05; 503 pDoPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(char), true ); 547 504 } 548 505 else if(basbuf[i3]=='1'){ … … 550 507 551 508 //jne 5(ループ終了) 552 OpBuffer[obp++]=(char)0x75; 553 OpBuffer[obp++]=(char)0x05; 509 pDoPertialSchedule = compiler.codeGenerator.op_jne( 0, sizeof(char), true ); 554 510 } 555 511 break; … … 558 514 559 515 //jmp ... 560 OpBuffer[obp++]=(char)0xE9; 561 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long)); 562 obp+=sizeof(long); 563 pobj_TempSchedule->unlock(); 564 pobj_TempSchedule->unlock(); 516 compiler.codeGenerator.op_jmp_continue(); 517 518 if( pDoPertialSchedule ) 519 { 520 compiler.codeGenerator.opfix_JmpPertialSchedule( pDoPertialSchedule ); 521 } 565 522 566 523 //jmp ... … … 568 525 int je_schedule=obp; 569 526 obp+=sizeof(long); 570 pobj_TempSchedule->lock(&je_schedule);571 527 572 528 //レキシカルスコープをレベルダウン … … 574 530 575 531 *((long *)(OpBuffer+je_schedule))=obp-(je_schedule+sizeof(long)); //jmpジャンプ先のオフセット値 576 pobj_TempSchedule->unlock();577 532 578 533 //Continueアドレスを復元 579 dwContinueAddress=dwTempContinue;534 compiler.codeGenerator.ContinueAreaEnd(); 580 535 } 581 536 void OpcodeContinue(void){ 582 extern DWORD dwContinueAddress;583 584 if(dwContinueAddress==-1){585 SetError(12,"Continue",cp);586 return;587 }588 589 537 //jmp ...(Continue addr) 590 OpBuffer[obp++]=(char)0xE9; 591 592 *((long *)(OpBuffer+obp))=dwContinueAddress-(obp+sizeof(long)); 593 obp+=sizeof(long); 538 compiler.codeGenerator.op_jmp_continue(); 594 539 } 595 540 -
trunk/abdev/BasicCompiler64/Compile_Var.cpp
r232 r242 862 862 863 863 //mov rax,DataPos 864 compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RAX,i2); 865 obp-=sizeof(long); 866 pobj_DataTableSchedule->add(); 867 obp+=sizeof(long); 864 compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RAX,i2, Schedule::DataTable ); 868 865 869 866 //mov qword ptr[offset],rax … … 1017 1014 1018 1015 //mov rax,i2 1019 compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RAX,i2); 1020 obp-=sizeof(long); 1021 pobj_DataTableSchedule->add(); 1022 obp+=sizeof(long); 1016 compiler.codeGenerator.op_mov_RV(sizeof(_int64),REG_RAX,i2, Schedule::DataTable ); 1023 1017 1024 1018 //mov qword ptr[rsp+offset],rax 1025 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32); 1026 obp-=sizeof(long); 1027 AddLocalVarAddrSchedule(); 1028 obp+=sizeof(long); 1019 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::LocalVar ); 1029 1020 } 1030 1021 else{ … … 1034 1025 1035 1026 //mov qword ptr[rsp+offset],rax 1036 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32); 1037 obp-=sizeof(long); 1038 AddLocalVarAddrSchedule(); 1039 obp+=sizeof(long); 1027 compiler.codeGenerator.op_mov_MR(sizeof(_int64),REG_RAX,REG_RSP,offset,MOD_BASE_DISP32, Schedule::LocalVar ); 1040 1028 } 1041 1029 else{ … … 1263 1251 if(pRelativeVar->bOffsetOffset){ 1264 1252 //add r11,qword ptr[rsp+offset] 1265 compiler.codeGenerator.op_add_RM( REG_R11, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar );1253 compiler.codeGenerator.op_add_RM( sizeof(_int64), REG_R11, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar ); 1266 1254 } 1267 1255 else{ -
trunk/abdev/BasicCompiler64/MakePeHdr.cpp
r226 r242 190 190 compiler.GetMeta().GetDllProcs().Iterator_Init(); 191 191 192 192 /* 193 193 if( !compiler.GetMeta().WriteXml( Jenga::Common::Environment::GetAppDir() + "\\meta_test.xml" ) ) 194 194 { … … 200 200 MessageBox(0,"XML読み込みに失敗","test",0); 201 201 } 202 /* 202 203 203 if( !compiler.GetMeta().WriteBinaly( Jenga::Common::Environment::GetAppDir() + "\\meta_test.dat" ) ) 204 204 { … … 218 218 { 219 219 MessageBox(0,"バイナリ読み込みに失敗","test",0); 220 } */221 compiler.GetMeta() = (*pTempMeta); 220 } 221 compiler.GetMeta() = (*pTempMeta);*/ 222 222 223 223 … … 325 325 //リロケーション情報 326 326 pobj_Reloc=new CReloc(); 327 328 //一時スケジューリングポインタ329 pobj_TempSchedule=new CTempSchedule();330 327 331 328 obp_AllocSize=8192*2; … … 384 381 385 382 //Continueアドレスを初期化 386 extern DWORD dwContinueAddress; 387 dwContinueAddress=-1; 383 compiler.codeGenerator.ClearContinueArea(); 388 384 389 385 //スタックフレーム管理用クラスを初期化 … … 1158 1154 } 1159 1155 1160 delete pobj_TempSchedule;1161 1162 1156 1163 1157 -
trunk/abdev/BasicCompiler64/NumOpe.cpp
r232 r242 603 603 604 604 //mov reg,i2 605 compiler.codeGenerator.op_mov_RV(sizeof(_int64),*pReg,i2); 606 obp-=sizeof(long); 607 pobj_DataTableSchedule->add(); 608 obp+=sizeof(long); 605 compiler.codeGenerator.op_mov_RV(sizeof(_int64),*pReg,i2, Schedule::DataTable ); 609 606 610 607 free( buffer ); … … 796 793 797 794 //mov reg,i2 798 compiler.codeGenerator.op_mov_RV(sizeof(_int64),UseReg,i2); 799 obp-=sizeof(long); 800 pobj_DataTableSchedule->add(); 801 obp+=sizeof(long); 795 compiler.codeGenerator.op_mov_RV(sizeof(_int64),UseReg,i2, Schedule::DataTable); 802 796 803 797 if(UseReg==REG_R14){ … … 981 975 982 976 //movlpd xmm_reg,qword ptr[data table offset] 983 OpBuffer[obp++]=(char)0x66; 984 OpBuffer[obp++]=(char)0x0F; 985 OpBuffer[obp++]=(char)0x12; 986 OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(XmmReg)<<3); 987 OpBuffer[obp++]=(char)0x25; 988 *((long *)(OpBuffer+obp))=i3; 989 pobj_DataTableSchedule->add(); 990 obp+=sizeof(long); 977 compiler.codeGenerator.op_movlpd_RM( XmmReg, 0, i3, MOD_DISP32, Schedule::DataTable ); 991 978 } 992 979 } … … 1010 997 1011 998 //movss xmm_reg,dword ptr[data table offset] 1012 OpBuffer[obp++]=(char)0xF3; 1013 OpBuffer[obp++]=(char)0x0F; 1014 OpBuffer[obp++]=(char)0x10; 1015 OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(XmmReg)<<3); 1016 OpBuffer[obp++]=(char)0x25; 1017 *((long *)(OpBuffer+obp))=i3; 1018 pobj_DataTableSchedule->add(); 1019 obp+=sizeof(long); 999 compiler.codeGenerator.op_movss_RM( XmmReg, 0, i3, MOD_DISP32, Schedule::DataTable ); 1020 1000 } 1021 1001 } … … 1149 1129 1150 1130 //movlpd xmm_reg,qword ptr[data table offset] 1151 OpBuffer[obp++]=(char)0x66; 1152 OpBuffer[obp++]=(char)0x0F; 1153 OpBuffer[obp++]=(char)0x12; 1154 OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(XmmReg)<<3); 1155 OpBuffer[obp++]=(char)0x25; 1156 *((long *)(OpBuffer+obp))=i3; 1157 pobj_DataTableSchedule->add(); 1158 obp+=sizeof(long); 1131 compiler.codeGenerator.op_movlpd_RM( XmmReg, 0, i3, MOD_DISP32, Schedule::DataTable ); 1159 1132 } 1160 1133 if(resultType.IsSingle()){ … … 1169 1142 1170 1143 //movss xmm_reg,dword ptr[data table offset] 1171 OpBuffer[obp++]=(char)0xF3; 1172 OpBuffer[obp++]=(char)0x0F; 1173 OpBuffer[obp++]=(char)0x10; 1174 OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(XmmReg)<<3); 1175 OpBuffer[obp++]=(char)0x25; 1176 *((long *)(OpBuffer+obp))=i3; 1177 pobj_DataTableSchedule->add(); 1178 obp+=sizeof(long); 1144 compiler.codeGenerator.op_movss_RM( XmmReg, 0, i3, MOD_DISP32, Schedule::DataTable ); 1179 1145 } 1180 1146 } -
trunk/abdev/BasicCompiler64/NumOpe_Arithmetic.cpp
r228 r242 473 473 474 474 //mulsd xmm_reg,qword ptr[data table offset] ※data = -1 475 OpBuffer[obp++]=(char)0xF2; 476 OpBuffer[obp++]=(char)0x0F; 477 OpBuffer[obp++]=(char)0x59; 478 OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3); 479 OpBuffer[obp++]=(char)0x25; 480 *((long *)(OpBuffer+obp))=i32data; 481 pobj_DataTableSchedule->add(); 482 obp+=sizeof(long); 475 compiler.codeGenerator.PutOld( 476 (char)0xF2, 477 (char)0x0F, 478 (char)0x59, 479 (char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3), 480 (char)0x25 481 ); 482 compiler.codeGenerator.PutOld( 483 (long)i32data, 484 Schedule::DataTable 485 ); 483 486 484 487 if(xmm_reg==REG_XMM4){ … … 495 498 496 499 //mulss xmm_reg,dword ptr[data table offset] ※data = -1 497 OpBuffer[obp++]=(char)0xF3; 498 OpBuffer[obp++]=(char)0x0F; 499 OpBuffer[obp++]=(char)0x59; 500 OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3); 501 OpBuffer[obp++]=(char)0x25; 502 *((long *)(OpBuffer+obp))=i32data; 503 pobj_DataTableSchedule->add(); 504 obp+=sizeof(long); 500 compiler.codeGenerator.PutOld( 501 (char)0xF3, 502 (char)0x0F, 503 (char)0x59, 504 (char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3), 505 (char)0x25 506 ); 507 compiler.codeGenerator.PutOld( 508 (long)i32data, 509 Schedule::DataTable 510 ); 505 511 506 512 if(xmm_reg==REG_XMM4){ -
trunk/abdev/BasicCompiler64/NumOpe_TypeOperation.cpp
r228 r242 88 88 89 89 //addsd xmm_reg,qword ptr[offset] ※offset value:43f0000000000000 90 int temp;91 90 _int64 i64data=0x43f0000000000000; 92 temp=compiler.GetDataTable().Add( i64data ); 93 OpBuffer[obp++]=(char)0xF2; 94 OpBuffer[obp++]=(char)0x0F; 95 OpBuffer[obp++]=(char)0x58; 96 OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3); 97 OpBuffer[obp++]=(char)0x25; 98 *((long *)(OpBuffer+obp))=temp; 99 pobj_DataTableSchedule->add(); 100 obp+=sizeof(long); 91 long temp=compiler.GetDataTable().Add( i64data ); 92 compiler.codeGenerator.PutOld( 93 (char)0xF2, 94 (char)0x0F, 95 (char)0x58, 96 (char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3), 97 (char)0x25 98 ); 99 compiler.codeGenerator.PutOld( 100 temp, 101 Schedule::DataTable 102 ); 101 103 } 102 104 } … … 146 148 147 149 //addss xmm_reg,dword ptr[offset] ※offset value:5f800000 148 int temp;149 150 long i32data=0x5f800000; 150 temp=compiler.GetDataTable().Add( i32data ); 151 OpBuffer[obp++]=(char)0xF3; 152 OpBuffer[obp++]=(char)0x0F; 153 OpBuffer[obp++]=(char)0x58; 154 OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3); 155 OpBuffer[obp++]=(char)0x25; 156 *((long *)(OpBuffer+obp))=temp; 157 pobj_DataTableSchedule->add(); 158 obp+=sizeof(long); 151 long temp=compiler.GetDataTable().Add( i32data ); 152 compiler.codeGenerator.PutOld( 153 (char)0xF3, 154 (char)0x0F, 155 (char)0x58, 156 (char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3), 157 (char)0x25 158 ); 159 compiler.codeGenerator.PutOld( 160 temp, 161 Schedule::DataTable 162 ); 159 163 } 160 164 } -
trunk/abdev/BasicCompiler_Common/PESchedule.cpp
r223 r242 232 232 233 233 CSubAddrSchedule *pobj_SubAddrSchedule; 234 235 236 237 238 /////////////////////////////////////////239 // 一時スケジューリングポインタ240 /////////////////////////////////////////241 CTempSchedule::CTempSchedule(){242 ppObpValues=(int **)HeapAlloc(hHeap,0,1);243 num=0;244 }245 CTempSchedule::~CTempSchedule(){246 HeapDefaultFree(ppObpValues);247 }248 void CTempSchedule::lock(int *pobp){249 ppObpValues=(int **)HeapReAlloc(hHeap,0,ppObpValues,(num+1)*sizeof(int *));250 ppObpValues[num]=pobp;251 num++;252 }253 void CTempSchedule::unlock(){254 if( num <= 0 ){255 //エラー256 SetError(300,NULL,cp);257 }258 num--;259 }260 void CTempSchedule::move(int iStartPos,int iSize,int offset){261 int i;262 for(i=0;i<num;i++){263 if(iStartPos<=*ppObpValues[i] && *ppObpValues[i]<iStartPos+iSize){264 (*ppObpValues[i])+=offset;265 }266 }267 }268 269 CTempSchedule *pobj_TempSchedule;270 271 272 273 -
trunk/abdev/BasicCompiler_Common/PESchedule.h
r223 r242 94 94 95 95 96 /////////////////////////////////////97 // 一時スケジューリングポインタ98 /////////////////////////////////////99 class CTempSchedule{100 int **ppObpValues;101 int num;102 public:103 CTempSchedule();104 ~CTempSchedule();105 106 void lock(int *pobp);107 void unlock();108 void move(int iStartPos,int iSize,int offset);109 };110 extern CTempSchedule *pobj_TempSchedule;111 112 113 96 void NativeBuffer_StaticRelocation(int iStartPos,int iSize,int offset); -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r241 r242 304 304 305 305 306 void PutOld( long l, Schedule::Type scheduleType ) 307 { 308 pNativeCode->Put( l, scheduleType ); 309 } 306 310 307 311 void PutOld( char c1, char c2 )
Note:
See TracChangeset
for help on using the changeset viewer.