1 |
gbeauche |
1.1 |
// gb-- stupid hack to insert macros in the generated assembly file |
2 |
|
|
static void fpu_emit_macro_definitions() |
3 |
|
|
{ |
4 |
|
|
# define DEFINE_MACRO(name, value) \ |
5 |
cebix |
1.2 |
__asm__ __volatile__ (#name " = " #value) |
6 |
gbeauche |
1.1 |
DEFINE_MACRO(BSUN, 0x00008000); |
7 |
|
|
DEFINE_MACRO(SNAN, 0x00004000); |
8 |
|
|
DEFINE_MACRO(OPERR, 0x00002000); |
9 |
|
|
DEFINE_MACRO(OVFL, 0x00001000); |
10 |
|
|
DEFINE_MACRO(UNFL, 0x00000800); |
11 |
|
|
DEFINE_MACRO(DZ, 0x00000400); |
12 |
|
|
DEFINE_MACRO(INEX2, 0x00000200); |
13 |
|
|
DEFINE_MACRO(INEX1, 0x00000100); |
14 |
|
|
DEFINE_MACRO(ACCR_IOP, 0x80); |
15 |
|
|
DEFINE_MACRO(ACCR_OVFL, 0x40); |
16 |
|
|
DEFINE_MACRO(ACCR_UNFL, 0x20); |
17 |
|
|
DEFINE_MACRO(ACCR_DZ, 0x10); |
18 |
|
|
DEFINE_MACRO(ACCR_INEX, 0x08); |
19 |
|
|
DEFINE_MACRO(ROUND_CONTROL_MASK, 0x30); |
20 |
|
|
DEFINE_MACRO(ROUND_TO_NEAREST, 0); |
21 |
|
|
DEFINE_MACRO(ROUND_TO_ZERO, 0x10); |
22 |
|
|
DEFINE_MACRO(ROUND_TO_NEGATIVE_INFINITY, 0x20); |
23 |
|
|
DEFINE_MACRO(ROUND_TO_POSITIVE_INFINITY, 0x30); |
24 |
|
|
DEFINE_MACRO(PRECISION_CONTROL_MASK, 0xC0); |
25 |
|
|
DEFINE_MACRO(PRECISION_CONTROL_EXTENDED, 0); |
26 |
|
|
DEFINE_MACRO(PRECISION_CONTROL_DOUBLE, 0x80); |
27 |
|
|
DEFINE_MACRO(PRECISION_CONTROL_SINGLE, 0x40); |
28 |
|
|
DEFINE_MACRO(PRECISION_CONTROL_UNDEFINED, 0xC0); |
29 |
|
|
DEFINE_MACRO(CW_RESET, 0x0040); |
30 |
|
|
DEFINE_MACRO(CW_FINIT, 0x037F); |
31 |
|
|
DEFINE_MACRO(SW_RESET, 0x0000); |
32 |
|
|
DEFINE_MACRO(SW_FINIT, 0x0000); |
33 |
|
|
DEFINE_MACRO(TW_RESET, 0x5555); |
34 |
|
|
DEFINE_MACRO(TW_FINIT, 0x0FFF); |
35 |
|
|
DEFINE_MACRO(CW_X, 0x1000); |
36 |
|
|
DEFINE_MACRO(CW_RC_ZERO, 0x0C00); |
37 |
|
|
DEFINE_MACRO(CW_RC_UP, 0x0800); |
38 |
|
|
DEFINE_MACRO(CW_RC_DOWN, 0x0400); |
39 |
|
|
DEFINE_MACRO(CW_RC_NEAR, 0x0000); |
40 |
|
|
DEFINE_MACRO(CW_PC_EXTENDED, 0x0300); |
41 |
|
|
DEFINE_MACRO(CW_PC_DOUBLE, 0x0200); |
42 |
|
|
DEFINE_MACRO(CW_PC_RESERVED, 0x0100); |
43 |
|
|
DEFINE_MACRO(CW_PC_SINGLE, 0x0000); |
44 |
|
|
DEFINE_MACRO(CW_PM, 0x0020); |
45 |
|
|
DEFINE_MACRO(CW_UM, 0x0010); |
46 |
|
|
DEFINE_MACRO(CW_OM, 0x0008); |
47 |
|
|
DEFINE_MACRO(CW_ZM, 0x0004); |
48 |
|
|
DEFINE_MACRO(CW_DM, 0x0002); |
49 |
|
|
DEFINE_MACRO(CW_IM, 0x0001); |
50 |
|
|
DEFINE_MACRO(SW_B, 0x8000); |
51 |
|
|
DEFINE_MACRO(SW_C3, 0x4000); |
52 |
|
|
DEFINE_MACRO(SW_TOP_7, 0x3800); |
53 |
|
|
DEFINE_MACRO(SW_TOP_6, 0x3000); |
54 |
|
|
DEFINE_MACRO(SW_TOP_5, 0x2800); |
55 |
|
|
DEFINE_MACRO(SW_TOP_4, 0x2000); |
56 |
|
|
DEFINE_MACRO(SW_TOP_3, 0x1800); |
57 |
|
|
DEFINE_MACRO(SW_TOP_2, 0x1000); |
58 |
|
|
DEFINE_MACRO(SW_TOP_1, 0x0800); |
59 |
|
|
DEFINE_MACRO(SW_TOP_0, 0x0000); |
60 |
|
|
DEFINE_MACRO(SW_C2, 0x0400); |
61 |
|
|
DEFINE_MACRO(SW_C1, 0x0200); |
62 |
|
|
DEFINE_MACRO(SW_C0, 0x0100); |
63 |
|
|
DEFINE_MACRO(SW_ES, 0x0080); |
64 |
|
|
DEFINE_MACRO(SW_SF, 0x0040); |
65 |
|
|
DEFINE_MACRO(SW_PE, 0x0020); |
66 |
|
|
DEFINE_MACRO(SW_UE, 0x0010); |
67 |
|
|
DEFINE_MACRO(SW_OE, 0x0008); |
68 |
|
|
DEFINE_MACRO(SW_ZE, 0x0004); |
69 |
|
|
DEFINE_MACRO(SW_DE, 0x0002); |
70 |
|
|
DEFINE_MACRO(SW_IE, 0x0001); |
71 |
|
|
DEFINE_MACRO(X86_ROUND_CONTROL_MASK, 0x0C00); |
72 |
|
|
DEFINE_MACRO(X86_PRECISION_CONTROL_MASK, 0x0300); |
73 |
|
|
# undef DEFINE_MACRO |
74 |
|
|
} |
75 |
|
|
/* |
76 |
|
|
#!/bin/sh |
77 |
|
|
|
78 |
|
|
awk=awk |
79 |
|
|
ifile="fpu_x86.h" |
80 |
|
|
ofile="fpu_x86_asm.h" |
81 |
|
|
|
82 |
|
|
if [ ! -r "$ifile" ]; then |
83 |
|
|
echo "Error: could not open input file ($ifile)" |
84 |
|
|
exit 1 |
85 |
|
|
fi |
86 |
|
|
|
87 |
|
|
touch $ofile |
88 |
|
|
if [ $? -ne 0 ]; then |
89 |
|
|
echo "Error: could not open output file ($ofile)" |
90 |
|
|
exit 1 |
91 |
|
|
fi |
92 |
|
|
|
93 |
|
|
# header |
94 |
|
|
cat > $ofile << EOF |
95 |
|
|
// gb-- stupid hack to insert macros in the generated assembly file |
96 |
|
|
static void fpu_emit_macro_definitions() |
97 |
|
|
{ |
98 |
|
|
# define DEFINE_MACRO(name, value) \\ |
99 |
cebix |
1.2 |
__asm__ __volatile__ (#name " = " #value) |
100 |
gbeauche |
1.1 |
EOF |
101 |
|
|
|
102 |
|
|
# processing with awk |
103 |
|
|
$awk '/#define/ { print " DEFINE_MACRO(" $2 ", " $3 ");"; }' $ifile >> $ofile |
104 |
|
|
|
105 |
|
|
# footer |
106 |
|
|
cat >> $ofile << EOF |
107 |
|
|
# undef DEFINE_MACRO |
108 |
|
|
} |
109 |
|
|
EOF |
110 |
|
|
|
111 |
|
|
# insert this script |
112 |
|
|
echo "/""*" >> $ofile |
113 |
|
|
cat $0 >> $ofile |
114 |
|
|
echo "*""/" >> $ofile |
115 |
|
|
|
116 |
|
|
exit 0 |
117 |
|
|
*/ |