• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #include <stdio.h>
3 #include <stdlib.h>
4 
do_fld1(void * p)5 void do_fld1 ( void* p )
6 {
7    asm __volatile__("fninit");
8    asm __volatile__("fld1");
9    asm __volatile__("fstpl (%0)" : : "r" (p) : "memory" );
10 }
11 
do_fldl2t(void * p)12 void do_fldl2t ( void* p )
13 {
14    asm __volatile__("fninit");
15    asm __volatile__("fldl2t");
16    asm __volatile__("fstpl (%0)" : : "r" (p) : "memory" );
17 }
18 
do_fldl2e(void * p)19 void do_fldl2e ( void* p )
20 {
21    asm __volatile__("fninit");
22    asm __volatile__("fldl2e");
23    asm __volatile__("fstpl (%0)" : : "r" (p) : "memory" );
24 }
25 
do_fldpi(void * p)26 void do_fldpi ( void* p )
27 {
28    asm __volatile__("fninit");
29    asm __volatile__("fldpi");
30    asm __volatile__("fstpl (%0)" : : "r" (p) : "memory" );
31 }
32 
do_fldlg2(void * p)33 void do_fldlg2 ( void* p )
34 {
35    asm __volatile__("fninit");
36    asm __volatile__("fldlg2");
37    asm __volatile__("fstpl (%0)" : : "r" (p) : "memory" );
38 }
39 
do_fldln2(void * p)40 void do_fldln2 ( void* p )
41 {
42    asm __volatile__("fninit");
43    asm __volatile__("fldln2");
44    asm __volatile__("fstpl (%0)" : : "r" (p) : "memory" );
45 }
46 
do_fldz(void * p)47 void do_fldz ( void* p )
48 {
49    asm __volatile__("fninit");
50    asm __volatile__("fldz");
51    asm __volatile__("fstpl (%0)" : : "r" (p) : "memory" );
52 }
53 
54 typedef  unsigned char  UChar;
55 
foo(void (* f)(void *),char * name)56 void foo ( void (*f)(void*), char* name )
57 {
58   int i;
59   UChar* b = malloc(8);
60   f(b);
61   printf("%s IRConst_F64i(0x", name);
62   for (i = 7; i >= 0; i--)
63     printf("%02x", (int)b[i]);
64   printf(")\n");
65 }
66 
main(void)67 int main ( void )
68 {
69   foo( do_fld1,   "fld1  ");
70   foo( do_fldl2t, "fldl2t");
71   foo( do_fldl2e, "fldl2e");
72   foo( do_fldpi,  "fldpi ");
73   foo( do_fldlg2, "fldlg2");
74   foo( do_fldln2, "fldln2");
75   foo( do_fldz,   "fldz  ");
76   return 0;
77 }
78