# New Ticket Created by Leopold Toetsch # Please include the string: [perl #18745] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=18745 >
This config test looks if the fucomip instruction is available. Question is, should this test be in auto/jit, or do we want some more general config structure for checking the availibility of various processor features? leo -- attachment 1 ------------------------------------------------------ url: http://rt.perl.org/rt2/attach/43191/34483/8ef188/LEO.diff
--- parrot/config/auto/jit.pl Wed Oct 23 11:35:49 2002 +++ parrot-leo/config/auto/jit.pl Fri Nov 29 11:02:11 2002 @@ -83,6 +83,17 @@ jit_h => '$(INC)/jit.h', jit_o => 'jit$(O) jit_cpu$(O)' ); + + # test for some instructions + if ($jitcpuarch eq 'i386') { + cc_gen('config/auto/jit/test_c.in'); + eval { cc_build(); }; + unless ($@ || cc_run() !~ /ok/) { + Configure::Data->set( + jit_i386 => 'fcomip' + ); + } + } } else { Configure::Data->set( --- parrot/config/auto/jit/test_c.in Fri Nov 29 11:06:35 2002 +++ parrot-leo/config/auto/jit/test_c.in Fri Nov 29 10:59:52 2002 @@ -0,0 +1,41 @@ +#include <stdio.h> +/* + * test for the fcomip float instruction + */ + +/* + * c equiv: + int t(int i, int j) { + return (double)i == (double)j; +} +*/ + +/* this code leaves one op on the fp stack, but this shouldn't harm */ + +char code[] = { + 0x55, /* pushl %ebp */ + 0x89,0xE5, /* movl %esp,%ebp */ + 0x83,0xEC,0x18, /* subl $24,%esp */ + 0xDB,0x45,0x08, /* fildl 8(%ebp) */ + 0xDB,0x45,0x0C, /* fildl 12(%ebp)*/ + 0xDF,0xE9, /* fucomip */ + 0x0F,0x94,0xC0, /* sete %al */ + 0x31,0xD2, /* xorl %edx,%edx */ + 0x88,0xC2, /* movb %al,%dl */ + 0x89,0xD0, /* movl %edx,%eax */ + 0x89,0xEC, /* movl %ebp,%esp */ + 0x5D, /* popl %ebp */ + 0xC3 /* ret */ +}; + +typedef int (*pf)(int, int); +int main() +{ + pf t = (pf) code; + if (t(10,10) && !t(10,20)) + puts("ok"); + else + return 1; + return 0; +} +