Subversion Repositories tendra.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 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 dec_alpha	*/
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, 64);
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(
107
	computed_nat(#"No extended floats on current implementation"),
108
	0, 0, 0)
109
  )
110
);
111
 
112
 
113
Tokdef .~rep_fv_width = [n:NAT] NAT
114
NAT ? ( NATTEST [n, ==, 1],
115
  32,
116
  NAT ? ( NATTEST [n, ==, 2],
117
    64,
118
 
119
    )
120
);
121
 
122
 
123
Tokdef .~rep_fv_radix = [n:NAT] NAT
124
2;
125
 
126
 
127
Tokdef .~rep_fv_mantissa = [n:NAT] NAT
128
NAT ? ( NATTEST [n, ==, 1],
129
  24,
130
  53
131
);
132
 
133
 
134
Tokdef .~rep_fv_min_exp = [n:NAT] NAT
135
NAT ? ( NATTEST [n, ==, 1],
136
  149,
137
  1074
138
);
139
 
140
 
141
Tokdef .~rep_fv_max_exp = [n:NAT] NAT
142
NAT ? ( NATTEST [n, ==, 1],
143
  127,
144
  1023
145
);
146
 
147
 
148
Tokdef .~rep_fv_epsilon = [n:NAT] EXP
149
EXP ? ( NATTEST [n, ==, 1],
150
  (2r1.0 E -23 (.~rep_fv[n])),
151
  (2r1.0 E -52 (.~rep_fv[n]))
152
);
153
 
154
 
155
Tokdef .~rep_fv_min_val = [n:NAT] EXP
156
EXP ? ( NATTEST [n, ==, 1],
157
  (2r1.0 E -149 (.~rep_fv[n])),
158
  (2r1.0 E -1074 (.~rep_fv[n]))
159
);
160
 
161
 
162
Tokdef .~rep_fv_max_val = [n:NAT] EXP
163
EXP ? ( NATTEST [n, ==, 1],
164
  (8r3.77777774 E 42
165
    (.~rep_fv[n])),
166
  (8r1.777777777777777774 E 341
167
      (.~rep_fv[n]))
168
);
169
 
170
 
171
 
172
 
173
	/* NON-NUMERIC REPRESENTATIONS */
174
 
175
 
176
Tokdef .~ptr_width = [] NAT
177
64;
178
 
179
 
180
Tokdef .~best_div = [] NAT
181
2;
182
 
183
 
184
Tokdef .~little_endian = [] BOOL
185
true;
186
 
187
 
188
 
189
 
190
	/* COMMON CONVERSION ROUTINES */
191
 
192
 
193
Tokdef .~ptr_to_ptr = [a1:ALIGNMENT, a2:ALIGNMENT, p:EXP] EXP
194
PUN [ pointer(a1), pointer(a2), p ];
195
 
196
 
197
Tokdef .~ptr_to_int = [a:ALIGNMENT, v:VARIETY, p:EXP] EXP
198
([v] PUN [ pointer(a), integer(PTR_V), p ]);
199
 
200
 
201
Tokdef .~int_to_ptr = [v:VARIETY, a:ALIGNMENT, i:EXP] EXP
202
PUN [ integer(PTR_V), pointer(a), [PTR_V] i ];
203
 
204
 
205
Tokdef .~f_to_ptr = [a:ALIGNMENT, fn:EXP] EXP
206
PUN [ proc, pointer(a), fn ];
207
 
208
 
209
Tokdef .~ptr_to_f = [a:ALIGNMENT, p:EXP] EXP
210
PUN [ pointer(a), proc, p ];
211
 
212
 
213
 
214
 
215
Keep (
216
.~rep_var_width, .~rep_atomic_width,
217
.~rep_fv, .~rep_fv_width, .~rep_fv_radix, .~rep_fv_mantissa, .~rep_fv_min_exp, 
218
.~rep_fv_max_exp, .~rep_fv_epsilon, .~rep_fv_min_val, .~rep_fv_max_val,
219
.~ptr_width, .~best_div, .~little_endian,
220
.~ptr_to_ptr, .~ptr_to_int, .~int_to_ptr, .~f_to_ptr, .~ptr_to_f
221
)