Changeset 237 in dev
- Timestamp:
- Jul 26, 2007, 3:58:18 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 9 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/BasicCompiler.vcproj
r232 r237 843 843 </Filter> 844 844 <Filter 845 Name=" Compile"845 Name="x86Compiler" 846 846 > 847 847 <File … … 1117 1117 > 1118 1118 <File 1119 RelativePath=".\CodeGenerator.cpp"1120 >1121 <FileConfiguration1122 Name="Debug|Win32"1123 >1124 <Tool1125 Name="VCCLCompilerTool"1126 ObjectFile="$(IntDir)\$(InputName)1.obj"1127 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"1128 />1129 </FileConfiguration>1130 <FileConfiguration1131 Name="Release|Win32"1132 >1133 <Tool1134 Name="VCCLCompilerTool"1135 ObjectFile="$(IntDir)\$(InputName)1.obj"1136 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"1137 />1138 </FileConfiguration>1139 </File>1140 <File1141 1119 RelativePath="op32_main.cpp" 1142 1120 > … … 1157 1135 /> 1158 1136 </FileConfiguration> 1137 </File> 1138 <File 1139 RelativePath=".\x86CodeGenerator.cpp" 1140 > 1159 1141 </File> 1160 1142 </Filter> … … 1265 1247 </Filter> 1266 1248 <Filter 1267 Name="Langauge Classes"1268 >1269 <File1270 RelativePath="..\BasicCompiler_Common\src\Class.cpp"1271 >1272 </File>1273 <File1274 RelativePath="..\BasicCompiler_Common\src\CodeGenerator.cpp"1275 >1276 </File>1277 <File1278 RelativePath="..\BasicCompiler_Common\src\Compiler.cpp"1279 >1280 </File>1281 <File1282 RelativePath="..\BasicCompiler_Common\src\Const.cpp"1283 >1284 </File>1285 <File1286 RelativePath="..\BasicCompiler_Common\src\DataTable.cpp"1287 >1288 </File>1289 <File1290 RelativePath="..\BasicCompiler_Common\src\Exception.cpp"1291 >1292 </File>1293 <File1294 RelativePath="..\BasicCompiler_Common\src\LexicalScopingImpl.cpp"1295 >1296 </File>1297 <File1298 RelativePath="..\BasicCompiler_Common\src\Method.cpp"1299 >1300 </File>1301 <File1302 RelativePath="..\BasicCompiler_Common\src\Namespace.cpp"1303 >1304 </File>1305 <File1306 RelativePath="..\BasicCompiler_Common\src\NamespaceSupporter.cpp"1307 >1308 </File>1309 <File1310 RelativePath="..\BasicCompiler_Common\src\NativeCode.cpp"1311 >1312 </File>1313 <File1314 RelativePath="..\BasicCompiler_Common\src\Procedure.cpp"1315 >1316 </File>1317 <File1318 RelativePath="..\BasicCompiler_Common\src\Program.cpp"1319 >1320 </File>1321 <File1322 RelativePath="..\BasicCompiler_Common\src\SmoothieImpl.cpp"1323 >1324 </File>1325 <File1326 RelativePath="..\BasicCompiler_Common\src\Symbol.cpp"1327 >1328 </File>1329 <File1330 RelativePath="..\BasicCompiler_Common\src\Type.cpp"1331 >1332 </File>1333 <File1334 RelativePath="..\BasicCompiler_Common\src\TypeDef.cpp"1335 >1336 </File>1337 <File1338 RelativePath="..\BasicCompiler_Common\src\Variable.cpp"1339 >1340 </File>1341 </Filter>1342 <Filter1343 1249 Name="Common Classes" 1344 1250 > … … 1347 1253 > 1348 1254 </File> 1255 <Filter 1256 Name="Langauge Classes" 1257 > 1258 <File 1259 RelativePath="..\BasicCompiler_Common\src\Class.cpp" 1260 > 1261 </File> 1262 <File 1263 RelativePath="..\BasicCompiler_Common\src\CodeGenerator.cpp" 1264 > 1265 </File> 1266 <File 1267 RelativePath="..\BasicCompiler_Common\src\Compiler.cpp" 1268 > 1269 </File> 1270 <File 1271 RelativePath="..\BasicCompiler_Common\src\Const.cpp" 1272 > 1273 </File> 1274 <File 1275 RelativePath="..\BasicCompiler_Common\src\DataTable.cpp" 1276 > 1277 </File> 1278 <File 1279 RelativePath="..\BasicCompiler_Common\src\Exception.cpp" 1280 > 1281 </File> 1282 <File 1283 RelativePath="..\BasicCompiler_Common\src\LexicalScopingImpl.cpp" 1284 > 1285 </File> 1286 <File 1287 RelativePath="..\BasicCompiler_Common\src\Method.cpp" 1288 > 1289 </File> 1290 <File 1291 RelativePath="..\BasicCompiler_Common\src\Namespace.cpp" 1292 > 1293 </File> 1294 <File 1295 RelativePath="..\BasicCompiler_Common\src\NamespaceSupporter.cpp" 1296 > 1297 </File> 1298 <File 1299 RelativePath="..\BasicCompiler_Common\src\NativeCode.cpp" 1300 > 1301 </File> 1302 <File 1303 RelativePath="..\BasicCompiler_Common\src\Procedure.cpp" 1304 > 1305 </File> 1306 <File 1307 RelativePath="..\BasicCompiler_Common\src\Program.cpp" 1308 > 1309 </File> 1310 <File 1311 RelativePath="..\BasicCompiler_Common\src\SmoothieImpl.cpp" 1312 > 1313 </File> 1314 <File 1315 RelativePath="..\BasicCompiler_Common\src\Symbol.cpp" 1316 > 1317 </File> 1318 <File 1319 RelativePath="..\BasicCompiler_Common\src\Type.cpp" 1320 > 1321 </File> 1322 <File 1323 RelativePath="..\BasicCompiler_Common\src\TypeDef.cpp" 1324 > 1325 </File> 1326 <File 1327 RelativePath="..\BasicCompiler_Common\src\Variable.cpp" 1328 > 1329 </File> 1330 </Filter> 1331 <Filter 1332 Name="CoreClasses" 1333 > 1334 <File 1335 RelativePath="..\BasicCompiler_Common\src\CommonCodeGenerator.cpp" 1336 > 1337 </File> 1338 </Filter> 1349 1339 </Filter> 1350 1340 </Filter> -
trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp
r235 r237 532 532 533 533 //mov eax,offset 534 OpBuffer[obp++]=(char)0xB8; 535 *((long *)(OpBuffer+obp))=offset; 536 pobj_DataTableSchedule->add(); 537 obp+=sizeof(long); 534 compiler.codeGenerator.op_mov_RV( REG_EAX, offset, Schedule::DataTable ); 538 535 539 536 //Thisポインタをecxにコピー -
trunk/abdev/BasicCompiler32/Compile_Var.cpp
r236 r237 845 845 846 846 //mov eax,DataPos 847 OpBuffer[obp++]=(char)0xB8; 848 *((long *)(OpBuffer+obp))=(long)i2; 849 pobj_DataTableSchedule->add(); 850 obp+=sizeof(long); 847 compiler.codeGenerator.op_mov_RV( REG_EAX, i2, Schedule::DataTable ); 851 848 852 849 //mov dword ptr[offset],eax … … 978 975 979 976 //mov dword ptr[ebp+offset],eax 980 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, Schedule::LocalVar );977 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::LocalVar ); 981 978 } 982 979 else if( type.IsSingle() ){ … … 1001 998 1002 999 //mov dword ptr[ebp+offset],eax 1003 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, Schedule::LocalVar );1000 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::LocalVar ); 1004 1001 } 1005 1002 else if( type.IsDWord() || type.IsLong() || type.IsPointer() ){ … … 1013 1010 1014 1011 //mov eax,DataPos 1015 OpBuffer[obp++]=(char)0xB8; 1016 *((long *)(OpBuffer+obp))=(long)i2; 1017 pobj_DataTableSchedule->add(); 1018 obp+=sizeof(long); 1012 compiler.codeGenerator.op_mov_RV( REG_EAX, i2, Schedule::DataTable ); 1019 1013 } 1020 1014 else{ -
trunk/abdev/BasicCompiler32/MachineFixed.h
r226 r237 34 34 #define MOD_BASE_DISP8 (char)0x40 35 35 #define MOD_BASE_DISP32 (char)0x80 36 #define MOD_REG 36 #define MOD_REG (char)0xC0 37 37 38 38 #define USE_OFFSET 1 -
trunk/abdev/BasicCompiler32/NumOpe.cpp
r225 r237 595 595 596 596 //mov eax,i2 597 compiler.codeGenerator.op_mov_RV(REG_EAX,i2); 598 obp-=sizeof(long); 599 pobj_DataTableSchedule->add(); 600 obp+=sizeof(long); 597 compiler.codeGenerator.op_mov_RV(REG_EAX,i2, Schedule::DataTable ); 601 598 602 599 free( buffer ); … … 753 750 754 751 //push DataSize 755 OpBuffer[obp++]=(char)0x68; 756 *((long *)(OpBuffer+obp))=i2; 757 pobj_DataTableSchedule->add(); 758 obp+=sizeof(long); 752 compiler.codeGenerator.op_push_V( i2, Schedule::DataTable ); 759 753 } 760 754 else if((term[0]=='e'||term[0]=='E')&& -
trunk/abdev/BasicCompiler32/NumOpe_Relation.cpp
r227 r237 560 560 561 561 //test ah,01h 562 compiler.codeGenerator.op_test_ah( (char)0x 41 );562 compiler.codeGenerator.op_test_ah( (char)0x01 ); 563 563 564 564 //jne 2 565 565 OpBuffer[obp++]=(char)0x75; 566 OpBuffer[obp++]=(char)0x0 5;566 OpBuffer[obp++]=(char)0x02; 567 567 568 568 //xor ecx,ecx … … 1185 1185 // 64ビット整数演算 1186 1186 //////////////////// 1187 int FalseSchedule1, 1188 FalseSchedule2; 1187 int FalseSchedule1; 1189 1188 1190 1189 // 第1項 == 第2項 … … 1205 1204 compiler.codeGenerator.op_cmp_RR( REG_EDX, REG_ECX ); 1206 1205 1207 //jnz FalseSchedule2(偽へジャンプ) 1208 OpBuffer[obp++]=(char)0x75; 1209 FalseSchedule2=obp; 1210 obp++; 1206 //jne FalseSchedule2(偽へジャンプ) 1207 CodeGenerator::PertialSchedule *pFalsePertialSchedule = compiler.codeGenerator.op_jne( 0, sizeof(char), true ); 1211 1208 1212 1209 //mov eax,1 … … 1219 1216 //FalseScheduleのジャンプ先の設定 1220 1217 OpBuffer[FalseSchedule1]=obp-(FalseSchedule1+1); 1221 OpBuffer[FalseSchedule2]=obp-(FalseSchedule2+1);1218 compiler.codeGenerator.opfix_JmpPertialSchedule( pFalsePertialSchedule ); 1222 1219 1223 1220 //xor eax,eax(eaxを0にする) -
trunk/abdev/BasicCompiler32/x86CodeGenerator.cpp
r236 r237 20 20 21 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 23 // エラーチェック 24 if( ! ( mod == MOD_BASE 25 || mod == MOD_DISP32 26 || mod == MOD_BASE_DISP8 27 || mod == MOD_BASE_DISP32 28 || mod == MOD_REG ) ) 29 { 30 SetError(); 31 } 32 22 33 if(mod==MOD_DISP32){ 23 34 //ModR/Mバイト … … 695 706 __op_format(0,(char)0x50,reg); 696 707 } 697 void CodeGenerator::op_push_V(long data ){708 void CodeGenerator::op_push_V(long data, Schedule::Type scheduleType ){ 698 709 //スタックにリテラル値をプッシュ 699 if(-128<=data&&data<=127 ){710 if(-128<=data&&data<=127 && scheduleType == Schedule::None ){ 700 711 //push 8ビット値 701 712 pNativeCode->Put( (char)0x6A ); … … 705 716 //push 32ビット値 706 717 pNativeCode->Put( (char)0x68 ); 707 pNativeCode->Put( data );718 pNativeCode->Put( data, scheduleType ); 708 719 } 709 720 } -
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; -
trunk/abdev/BasicCompiler_Common/src/NativeCode.cpp
r232 r237 1 1 #include "stdafx.h" 2 2 3 #define BREAK_EIP(checkEip) (obp+0x00401000 <=checkEip)3 #define BREAK_EIP(checkEip) (obp+0x00401000>=checkEip) 4 4 5 5 void ObpPlus( int step ) … … 9 9 10 10 // 例:epi=0x00401999 11 if( BREAK_EIP(0x004 01999) )11 if( BREAK_EIP(0x00433FD7) ) 12 12 { 13 13 int test=0;
Note:
See TracChangeset
for help on using the changeset viewer.