@@ -8,6 +8,8 @@ Run with --help or no arguments for possible commands.
8
8
"""
9
9
from __future__ import print_function
10
10
from datetime import datetime
11
+ from multiprocessing import Pool
12
+ from functools import partial
11
13
import argparse
12
14
import json
13
15
import os
@@ -1206,6 +1208,62 @@ class GenTestsCommand(Command):
1206
1208
''' ,
1207
1209
* args , ** kwargs )
1208
1210
1211
+ def process_src_file (test_bin , ppc_as , ppc_objdump , ppc_ld , ppc_nm , src_file ):
1212
+ print ('- %s' % src_file )
1213
+
1214
+ def make_unix_path (p ):
1215
+ """Forces a unix path separator style, as required by binutils.
1216
+ """
1217
+ return p .replace (os .sep , '/' )
1218
+
1219
+ src_name = os .path .splitext (os .path .basename (src_file ))[0 ]
1220
+ obj_file = os .path .join (test_bin , src_name ) + '.o'
1221
+ shell_call ([
1222
+ ppc_as ,
1223
+ '-a32' ,
1224
+ '-be' ,
1225
+ '-mregnames' ,
1226
+ '-mpower7' ,
1227
+ '-maltivec' ,
1228
+ '-mvsx' ,
1229
+ '-mvmx128' ,
1230
+ '-R' ,
1231
+ '-o%s' % (make_unix_path (obj_file )),
1232
+ make_unix_path (src_file ),
1233
+ ])
1234
+ dis_file = os .path .join (test_bin , src_name ) + '.dis'
1235
+ shell_call ([
1236
+ ppc_objdump ,
1237
+ '--adjust-vma=0x100000' ,
1238
+ '-Mpower7' ,
1239
+ '-Mvmx128' ,
1240
+ '-D' ,
1241
+ '-EB' ,
1242
+ make_unix_path (obj_file ),
1243
+ ], stdout_path = dis_file )
1244
+ # Eat the first 4 lines to kill the file path that'll differ across machines.
1245
+ with open (dis_file ) as f :
1246
+ dis_file_lines = f .readlines ()
1247
+ with open (dis_file , 'w' ) as f :
1248
+ f .writelines (dis_file_lines [4 :])
1249
+ shell_call ([
1250
+ ppc_ld ,
1251
+ '-A powerpc:common32' ,
1252
+ '-melf32ppc' ,
1253
+ '-EB' ,
1254
+ '-nostdlib' ,
1255
+ '--oformat=binary' ,
1256
+ '-Ttext=0x80000000' ,
1257
+ '-e0x80000000' ,
1258
+ '-o%s' % (make_unix_path (os .path .join (test_bin , src_name ) + '.bin' )),
1259
+ make_unix_path (obj_file ),
1260
+ ])
1261
+ shell_call ([
1262
+ ppc_nm ,
1263
+ '--numeric-sort' ,
1264
+ make_unix_path (obj_file ),
1265
+ ], stdout_path = os .path .join (test_bin , src_name ) + '.map' )
1266
+
1209
1267
def execute (self , args , pass_args , cwd ):
1210
1268
print ('Generating test binaries...' )
1211
1269
print ('' )
@@ -1229,61 +1287,12 @@ class GenTestsCommand(Command):
1229
1287
if (name .startswith ('instr_' ) or name .startswith ('seq_' ))
1230
1288
and name .endswith (('.s' ))]
1231
1289
1232
- def make_unix_path (p ):
1233
- """Forces a unix path separator style, as required by binutils.
1234
- """
1235
- return p .replace (os .sep , '/' )
1236
-
1237
1290
any_errors = False
1238
- for src_file in src_files :
1239
- print ('- %s' % src_file )
1240
- src_name = os .path .splitext (os .path .basename (src_file ))[0 ]
1241
- obj_file = os .path .join (test_bin , src_name ) + '.o'
1242
- shell_call ([
1243
- ppc_as ,
1244
- '-a32' ,
1245
- '-be' ,
1246
- '-mregnames' ,
1247
- '-mpower7' ,
1248
- '-maltivec' ,
1249
- '-mvsx' ,
1250
- '-mvmx128' ,
1251
- '-R' ,
1252
- '-o%s' % (make_unix_path (obj_file )),
1253
- make_unix_path (src_file ),
1254
- ])
1255
- dis_file = os .path .join (test_bin , src_name ) + '.dis'
1256
- shell_call ([
1257
- ppc_objdump ,
1258
- '--adjust-vma=0x100000' ,
1259
- '-Mpower7' ,
1260
- '-Mvmx128' ,
1261
- '-D' ,
1262
- '-EB' ,
1263
- make_unix_path (obj_file ),
1264
- ], stdout_path = dis_file )
1265
- # Eat the first 4 lines to kill the file path that'll differ across machines.
1266
- with open (dis_file ) as f :
1267
- dis_file_lines = f .readlines ()
1268
- with open (dis_file , 'w' ) as f :
1269
- f .writelines (dis_file_lines [4 :])
1270
- shell_call ([
1271
- ppc_ld ,
1272
- '-A powerpc:common32' ,
1273
- '-melf32ppc' ,
1274
- '-EB' ,
1275
- '-nostdlib' ,
1276
- '--oformat=binary' ,
1277
- '-Ttext=0x80000000' ,
1278
- '-e0x80000000' ,
1279
- '-o%s' % (make_unix_path (os .path .join (test_bin , src_name ) + '.bin' )),
1280
- make_unix_path (obj_file ),
1281
- ])
1282
- shell_call ([
1283
- ppc_nm ,
1284
- '--numeric-sort' ,
1285
- make_unix_path (obj_file ),
1286
- ], stdout_path = os .path .join (test_bin , src_name ) + '.map' )
1291
+
1292
+ pool_func = partial (GenTestsCommand .process_src_file , test_bin , ppc_as , ppc_objdump , ppc_ld , ppc_nm )
1293
+ with Pool () as pool :
1294
+ pool .map (pool_func , src_files )
1295
+
1287
1296
1288
1297
if any_errors :
1289
1298
print ('ERROR: failed to build one or more tests.' )
0 commit comments