@@ -8,6 +8,8 @@ Run with --help or no arguments for possible commands.
88"""
99from __future__ import print_function
1010from datetime import datetime
11+ from multiprocessing import Pool
12+ from functools import partial
1113import argparse
1214import json
1315import os
@@ -1206,6 +1208,62 @@ class GenTestsCommand(Command):
12061208 ''' ,
12071209 * args , ** kwargs )
12081210
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+
12091267 def execute (self , args , pass_args , cwd ):
12101268 print ('Generating test binaries...' )
12111269 print ('' )
@@ -1229,61 +1287,12 @@ class GenTestsCommand(Command):
12291287 if (name .startswith ('instr_' ) or name .startswith ('seq_' ))
12301288 and name .endswith (('.s' ))]
12311289
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-
12371290 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+
12871296
12881297 if any_errors :
12891298 print ('ERROR: failed to build one or more tests.' )
0 commit comments