Subversion Repositories tendra.SVN

Rev

Rev 6 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
	/* **************************************************** */
30
	/*							*/
31
	/* Target Dependency Token Definitions for trans386	*/
32
	/*							*/
33
	/* **************************************************** */
34
 
35
 
36
 
37
 
38
	/* LOCAL TOKENS */
39
 
40
 
41
Tokdef REP_V = [] VARIETY
42
	/* variety for integer widths and float_sequence */
43
var_width (false, 16);
44
 
45
 
46
Tokdef NATTEST = [a:NAT, comp:NTEST, b:NAT] EXP
47
	/* comparison of nats, for static conditionals */
48
? { ?(snat_from_nat(false,a)(REP_V) comp snat_from_nat(false,b)(REP_V));
49
    1(REP_V)
50
  | 0(REP_V)
51
};
52
 
53
 
54
Tokdef PUN = [from_sh:SHAPE, to_sh:SHAPE, val:EXP] EXP
55
	/* representation preserving conversion */
56
component (to_sh,
57
  Cons [ shape_offset(from_sh) .max. shape_offset(to_sh) ] (
58
    offset_zero(alignment(from_sh)) : val
59
  ),
60
  offset_zero(alignment(to_sh))
61
);
62
 
63
 
64
Tokdef PTR_V = [] VARIETY
65
	/* variety for converted pointers */
66
var_width (true, 32);
67
 
68
 
69
 
70
 
71
	/* INTEGER VARIETY REPRESENTATIONS */
72
 
73
 
74
Tokdef .~rep_var_width = [w:NAT] NAT
75
NAT ? ( NATTEST [w, <=, 8],
76
  8,
77
  NAT ? ( NATTEST [w, <=, 16],
78
    16,
79
    NAT ? ( NATTEST [w, <=, 32],
80
      32,
81
      NAT ? ( NATTEST [w, <=, 64],
82
	64,
83
 
84
      )
85
    )
86
  )
87
);
88
 
89
 
90
Tokdef .~rep_atomic_width = [] NAT
91
32;
92
 
93
 
94
 
95
 
96
	/* FLOATING VARIETY REPRESENTATIONS */
97
 
98
/* sequence: 1=single, 2=double, 3=extended */
99
 
100
 
101
Tokdef .~rep_fv = [n:NAT] FLOATING_VARIETY
102
FLOATING_VARIETY ? ( NATTEST [n, ==, 1],
103
  flvar_parms (2, 24, 126, 127),
104
  FLOATING_VARIETY ? ( NATTEST [n, ==, 2],
105
    flvar_parms (2, 53, 1022, 1023),
106
    flvar_parms (2, 64, 16382, 16383)	/* n must be in range */
107
  )
108
);
109
 
110
 
111
Tokdef .~rep_fv_width = [n:NAT] NAT
112
NAT ? ( NATTEST [n, ==, 1],
113
  32,
114
  NAT ? ( NATTEST [n, ==, 2],
115
    64,
116
    NAT ? ( NATTEST [n, ==, 3],
117
      80,	/* 80 bits memory, increased to 96 by ABI */
118
 
119
    )
120
  )
121
);
122
 
123
 
124
Tokdef .~rep_fv_radix = [n:NAT] NAT
125
2;
126
 
127
 
128
Tokdef .~rep_fv_mantissa = [n:NAT] NAT
129
NAT ? ( NATTEST [n, ==, 1],
130
  24,
131
  NAT ? ( NATTEST [n, ==, 2],
132
    53,
133
    64	/* n must be in range */
134
  )
135
);
136
 
137
 
138
Tokdef .~rep_fv_min_exp = [n:NAT] NAT
139
NAT ? ( NATTEST [n, ==, 1],
140
  149,
141
  NAT ? ( NATTEST [n, ==, 2],
142
    1074,
143
    16445	/* n must be in range */
144
  )
145
);
146
 
147
 
148
Tokdef .~rep_fv_max_exp = [n:NAT] NAT
149
NAT ? ( NATTEST [n, ==, 1],
150
  127,
151
  NAT ? ( NATTEST [n, ==, 2],
152
    1023,
153
    16383	/* n must be in range */
154
  )
155
);
156
 
157
 
158
Tokdef .~rep_fv_epsilon = [n:NAT] EXP
159
EXP ? ( NATTEST [n, ==, 1],
160
  (2r1.0 E -23 (.~rep_fv[n])),
161
  EXP ? ( NATTEST [n, ==, 2],
162
    (2r1.0 E -52 (.~rep_fv[n])),
163
    (2r1.0 E -63 (.~rep_fv[n]))	/* n must be in range */
164
  )
165
);
166
 
167
 
168
Tokdef .~rep_fv_min_val = [n:NAT] EXP
169
EXP ? ( NATTEST [n, ==, 1],
170
  (2r1.0 E -149 (.~rep_fv[n])),
171
  EXP ? ( NATTEST [n, ==, 2],
172
    (2r1.0 E -1074 (.~rep_fv[n])),
173
    (2r1.0 E -16445 (.~rep_fv[n]))	/* n must be in range */
174
  )
175
);
176
 
177
 
178
Tokdef .~rep_fv_max_val = [n:NAT] EXP
179
EXP ? ( NATTEST [n, ==, 1],
180
  (8r3.77777774 E 42
181
    (.~rep_fv[n])),
182
  EXP ? ( NATTEST [n, ==, 2],
183
    (8r1.777777777777777774 E 341
184
      (.~rep_fv[n])),
185
    (8r1.777777777777777777777 E 5461
186
      (.~rep_fv[n]))		/* n must be in range */
187
  )
188
);
189
 
190
 
191
 
192
 
193
	/* NON-NUMERIC REPRESENTATIONS */
194
 
195
 
196
Tokdef .~ptr_width = [] NAT
197
32;
198
 
199
 
200
Tokdef .~best_div = [] NAT
201
2;
202
 
203
 
204
Tokdef .~little_endian = [] BOOL
205
true;
206
 
207
 
208
 
209
 
210
	/* COMMON CONVERSION ROUTINES */
211
 
212
 
213
Tokdef .~ptr_to_ptr = [a1:ALIGNMENT, a2:ALIGNMENT, p:EXP] EXP
214
PUN [ pointer(a1), pointer(a2), p ];
215
 
216
 
217
Tokdef .~ptr_to_int = [a:ALIGNMENT, v:VARIETY, p:EXP] EXP
218
([v] PUN [ pointer(a), integer(PTR_V), p ]);
219
 
220
 
221
Tokdef .~int_to_ptr = [v:VARIETY, a:ALIGNMENT, i:EXP] EXP
222
PUN [ integer(PTR_V), pointer(a), [PTR_V] i ];
223
 
224
 
225
Tokdef .~f_to_ptr = [a:ALIGNMENT, fn:EXP] EXP
226
PUN [ proc, pointer(a), fn ];
227
 
228
 
229
Tokdef .~ptr_to_f = [a:ALIGNMENT, p:EXP] EXP
230
PUN [ pointer(a), proc, p ];
231
 
232
 
233
 
234
 
235
Keep (
236
.~rep_var_width, .~rep_atomic_width,
237
.~rep_fv, .~rep_fv_width, .~rep_fv_radix, .~rep_fv_mantissa, .~rep_fv_min_exp, 
238
.~rep_fv_max_exp, .~rep_fv_epsilon, .~rep_fv_min_val, .~rep_fv_max_val,
239
.~ptr_width, .~best_div, .~little_endian,
240
.~ptr_to_ptr, .~ptr_to_int, .~int_to_ptr, .~f_to_ptr, .~ptr_to_f
241
)