1 /* Copyright (C) 2004-2018 Free Software Foundation, Inc.
3 This file is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 3, or (at your option) any
8 This file is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 Under Section 7 of GPL version 3, you are granted additional
14 permissions described in the GCC Runtime Library Exception, version
15 3.1, as published by the Free Software Foundation.
17 You should have received a copy of the GNU General Public License and
18 a copy of the GCC Runtime Library Exception along with this program;
19 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
20 <http://www.gnu.org/licenses/>. */
23 /* Calculate division table for ST40-300 integer division
24 Contributed by Joern Rennecke
25 joern.rennecke@st.com */
34 double q
, r
, err
, max_err
= 0, max_s_err
= 0;
36 puts("/* This table has been generated by divtab-sh4.c. */");
38 for (i
= -128; i
< 128; i
++)
43 /* output some dummy number for 1/0. */
44 puts ("LOCAL(div_table_clz):\n\t.byte\t0");
47 for (j
= i
< 0 ? -i
: i
; j
< 128; j
+= j
)
49 printf ("\t.byte\t%d\n", n
- 7);
52 /* 1/-128 .. 1/127, normalized. There is an implicit leading 1 in bit 32,\n\
53 or in bit 33 for powers of two. */\n\
55 for (i
= -128; i
< 128; i
++)
59 puts ("LOCAL(div_table_inv):\n\t.long\t0x0");
67 printf ("\t.long\t0x%X\n", (unsigned) r
);
75 printf ("\t/* maximum error: %f scaled: %f*/\n", max_err
, max_s_err
);