Commit cc0ee13f by Jim Stichnoth

Subzero: Add a convenience script for Spec2K. Add the --stats argument.

BUG= none R=jvoung@chromium.org Review URL: https://codereview.chromium.org/559723003
parent 8f07aa88
......@@ -61,6 +61,31 @@ def MatchSymbol(sym, re_include, re_exclude, default_match):
return True
return default_match
def AddOptionalArgs(argparser):
argparser.add_argument('--force', dest='force', action='store_true',
help='Force all re-translations of the pexe')
argparser.add_argument('--include', '-i', default=[], dest='include',
action='append',
help='Subzero symbols to include ' +
'(regex or line range)')
argparser.add_argument('--exclude', '-e', default=[], dest='exclude',
action='append',
help='Subzero symbols to exclude ' +
'(regex or line range)')
argparser.add_argument('--output', '-o', default='a.out', dest='output',
action='store',
help='Output executable. Default %(default)s.')
argparser.add_argument('-O', default='2', dest='optlevel',
choices=['m1', '-1', '0', '1', '2'],
help='Optimization level ' +
'(m1 and -1 are equivalent).' +
' Default %(default)s.')
argparser.add_argument('--verbose', '-v', dest='verbose',
action='store_true',
help='Display some extra debugging output')
argparser.add_argument('--stats', dest='stats', action='store_true',
help='Enable Subzero stats output')
def main():
"""Create a hybrid translation from Subzero and llc.
......@@ -104,38 +129,20 @@ def main():
argparser = argparse.ArgumentParser(
description=' ' + main.__doc__,
formatter_class=argparse.RawTextHelpFormatter)
AddOptionalArgs(argparser)
argparser.add_argument('pexe', help='Finalized pexe to translate')
argparser.add_argument('--force', dest='force', action='store_true',
help='Force all re-translations of the pexe')
argparser.add_argument('--include', '-i', default=[], dest='include',
action='append',
help='Subzero symbols to include ' +
'(regex or line range)')
argparser.add_argument('--exclude', '-e', default=[], dest='exclude',
action='append',
help='Subzero symbols to exclude ' +
'(regex or line range)')
argparser.add_argument('--output', '-o', default='a.out', dest='output',
action='store',
help='Output executable. Default %(default)s.')
argparser.add_argument('-O', default='2', dest='optlevel',
choices=['m1', '-1', '0', '1', '2'],
help='Optimization level ' +
'(m1 and -1 are equivalent).' +
' Default %(default)s.')
argparser.add_argument('--verbose', '-v', dest='verbose',
action='store_true',
help='Display some extra debugging output')
args = argparser.parse_args()
pexe = args.pexe
exe = args.output
ProcessPexe(args, pexe, exe)
def ProcessPexe(args, pexe, exe):
[pexe_base, ext] = os.path.splitext(pexe)
if ext != '.pexe':
pexe_base = pexe
pexe_base_unescaped = pexe_base
pexe_base = pipes.quote(pexe_base)
pexe = pipes.quote(pexe)
exe = args.output
nacl_root = FindBaseNaCl()
os.environ['PATH'] = (
......@@ -181,7 +188,8 @@ def main():
NewerThanOrNotThere(llvm2ice, obj_sz):
shellcmd((
'{l2i} -O{level} -bitcode-format=pnacl -disable-globals ' +
'-externalize -ffunction-sections {pexe} -o {asm}'
'-externalize -ffunction-sections {pexe} -o {asm}' +
(' --stats' if args.stats else '')
).format(l2i=llvm2ice, level=opt_level, pexe=pexe, asm=asm_sz),
echo=args.verbose)
shellcmd((
......
#!/usr/bin/env python2
import argparse
import os
import sys
import szbuild
from utils import FindBaseNaCl
def main():
"""Build native gcc-style executables for one or all Spec2K components.
Afterwards, the executables can be run from the
native_client/tests/spec2k/ directory as:
'./run_all.sh RunBenchmarks SetupGccX8632Opt {train|ref} ...'
"""
nacl_root = FindBaseNaCl()
components = [ '164.gzip', '175.vpr', '176.gcc', '177.mesa', '179.art',
'181.mcf', '183.equake', '186.crafty', '188.ammp',
'197.parser', '252.eon', '253.perlbmk', '254.gap',
'255.vortex', '256.bzip2', '300.twolf' ]
argparser = argparse.ArgumentParser(description=main.__doc__)
szbuild.AddOptionalArgs(argparser)
argparser.add_argument('comps', nargs='*', default=components)
args = argparser.parse_args()
bad = set(args.comps) - set(components)
if bad:
print 'Unknown component{s}: '.format(s='s' if len(bad) > 1 else '') + \
' '.join(x for x in bad)
sys.exit(1)
for comp in args.comps:
name = os.path.splitext(comp)[1] or comp
if name[0] == '.':
name = name[1:]
szbuild.ProcessPexe(args,
('{root}/tests/spec2k/{comp}/' +
'{name}.opt.stripped.pexe'
).format(root=nacl_root, comp=comp, name=name),
('{root}/tests/spec2k/{comp}/' +
'{name}.gcc.opt.x8632'
).format(root=nacl_root, comp=comp, name=name))
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment