On Fri, Jul 1, 2011 at 2:54 PM, Armin Rigo <[email protected]> wrote: > Hi, > > On Fri, Jul 1, 2011 at 2:41 PM, Zariko Taba <[email protected]> wrote: >> // compute a sqrt using intrinsics >> __builtin_ia32_sqrtss(...); >> // get status register of sse2 fpu >> int mxcsr = __builtin_ia32_stmxcsr(); >> // extract overflow bit : >> overflow = (mxcsr & 0x8); >> // extract ... > > There is a third solution: do exactly the same kind of code, but in > RPython instead of in C. This means using the rffi module. For > example: > > builtin_ia32_sqrtss = rffi.llexternal("__builtin_ia32_sqrtss", [argtypes...], > restype, _nowrapper=True, _callable=emulate_ia32_sqrtss) > > def f(..): > ... > builtin_ia32_sqrtss(..) > ... > > with emulate_ia32_sqrtss() being a pure Python function that is going > to be called only during tests. After translation to C, it will just > turn into the C code that you posted above. For more examples, grep > for "llexternal" in pypy/rlib/.
But it won't become an assembler instruction in the JIT, it'll still be a call. > > > A bientôt, > > Armin. > _______________________________________________ > pypy-dev mailing list > [email protected] > http://mail.python.org/mailman/listinfo/pypy-dev > _______________________________________________ pypy-dev mailing list [email protected] http://mail.python.org/mailman/listinfo/pypy-dev
