[pypy-dev] Re: [pypy-svn] r15069 - pypy/dist/pypy/translator/llvm2/tool

Christian Tismer tismer at stackless.com
Mon Jul 25 20:06:18 CEST 2005


ericvrp at codespeak.net wrote:

> Wrote simple tool to get an overview of the suggested_primitive functions that
> still need to be implemented in the llvm backend.
> The tool should be run from it's own directory for now!
> This is the current output: (tail is what we want to know)

Nice tool, very useful!

Just a hint for further development:

PyPy tends to avoid source code analysis wherever possible.
And in this tool's case it would bhe quite easy to use
introspecction:


> +    ll_modules_path = '../../../rpython/module'
> +    ll_files = [ll_modules_path + '/' + f for f in os.listdir(ll_modules_path) if f[:3] == 'll_' and f[-3:] == '.py']
> +    ll_function = {}    #XXX better use sets
> +    for ll_file in ll_files:

instead of this,

> +        for s in file(ll_file):
> +            s = s.strip()
> +            if not s.startswith('ll_') or s.find('suggested_primitive') == -1 or s.find('True') == -1:
> +                continue
> +            ll_function[s.split('.')[0]] = True

you could just import the file and inspect its objects.
Then check for
   hasattr(func, 'suggested_primitive')
and check if it is true.

> +
> +    llvm_modules_path = '..'
> +    llvm_files = [llvm_modules_path + '/' + 'extfunction.py']
> +    llvm_function = {}
> +    for llvm_file in llvm_files:
> +        t = 'extfunctions["%'

Same here.
Just import extfunctions from the file and look into it.

This is just more robust about future changes and independent
of formatting. It also survives stuff like programmatically
adding bulks of stuff to extfunctions, which might happen at
some point.

Just my 0.2cent - ciao -- chris

-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
tismerysoft GmbH             :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/



More information about the Pypy-dev mailing list