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 |
abstract.pl
|
|
|
32 |
===========
|
|
|
33 |
|
|
|
34 |
This file assumes that the parameters to the functions defined here are
|
|
|
35 |
64-bit integers:
|
|
|
36 |
|
|
|
37 |
Tokdef INT64 = [] SHAPE integer (var_width(true, 64));
|
|
|
38 |
Tokdef UINT64 = [] SHAPE integer (var_width(false, 64));
|
|
|
39 |
|
|
|
40 |
If it required that structures be passed, changing these tokens definitions
|
|
|
41 |
to:
|
|
|
42 |
Tokdef INT64 = [] SHAPE STRUCT_64;
|
|
|
43 |
Tokdef UINT64 = [] SHAPE USTRUCT_64;
|
|
|
44 |
|
|
|
45 |
(and putting them in an appropriate place further down the file) should
|
|
|
46 |
produce the required behaviour.
|
|
|
47 |
|
|
|
48 |
*/
|
|
|
49 |
|
|
|
50 |
/*
|
|
|
51 |
** abstract.pl
|
|
|
52 |
**
|
|
|
53 |
** This file contains PL_TDF token definitions which
|
|
|
54 |
** are declare in the PL_TDF file abstract.ph.
|
|
|
55 |
*/
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
/* Define the generic 32-bit signed and unsigned types */
|
|
|
59 |
|
|
|
60 |
Tokdef ~INT32 = [] VARIETY var_width (true, 32);
|
|
|
61 |
Tokdef INT32 = [] SHAPE integer(~INT32);
|
|
|
62 |
Tokdef ~UINT32 = [] VARIETY var_width (false, 32);
|
|
|
63 |
Tokdef UINT32 = [] SHAPE integer(~UINT32);
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 |
/* Define the new types for 64-bit integers and */
|
|
|
68 |
/* Macros for extracting the high- and low-32 bits */
|
|
|
69 |
|
|
|
70 |
Tokdef INT64 = [] SHAPE integer (var_width(true, 64));
|
|
|
71 |
Tokdef UINT64 = [] SHAPE integer (var_width(false, 64));
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
/* Define the widest floating variety - not possibe in C */
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
/* These are defined in the target-dependent tokens library */
|
|
|
79 |
|
|
|
80 |
Tokdec .~rep_fv : [NAT] FLOATING_VARIETY;
|
|
|
81 |
Tokdec .~rep_fv_width : [NAT] NAT;
|
|
|
82 |
|
|
|
83 |
Tokdec rep_fv : [NAT] FLOATING_VARIETY;
|
|
|
84 |
Tokdef rep_fv = [n:NAT] FLOATING_VARIETY
|
|
|
85 |
FLOATING_VARIETY ? ( ? { ? ((+ .~rep_fv_width [
|
|
|
86 |
computed_nat(1(Int) + (+ n(Int)))] (Int)) == 0(Int));
|
|
|
87 |
1(Int)
|
|
|
88 |
|
|
|
|
89 |
0(Int)
|
|
|
90 |
},
|
|
|
91 |
.~rep_fv [n],
|
|
|
92 |
rep_fv [computed_nat(1(Int) + (+ n(Int)))]
|
|
|
93 |
);
|
|
|
94 |
|
|
|
95 |
Tokdef ~BigFloat = [] FLOATING_VARIETY rep_fv [1];
|
|
|
96 |
Tokdef BigFloat = [] SHAPE floating(~BigFloat);
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
/* Macros for extracting the high- and low-32 bits */
|
|
|
101 |
/* (These necessarily differ from the C equivalents) */
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
/* This is a boolean preserved by the .c files */
|
|
|
105 |
Tokdec BIGEND_INT64 : [] EXP;
|
|
|
106 |
|
|
|
107 |
Tokdef s1 = [] SHAPE SHAPE ? ( BIGEND_INT64, INT32, UINT32 );
|
|
|
108 |
Tokdef s2 = [] SHAPE SHAPE ? ( BIGEND_INT64, UINT32, INT32 );
|
|
|
109 |
|
|
|
110 |
Struct STRUCT_64 (x1 : s1, x2 : s2 );
|
|
|
111 |
Struct STRUCT_U64 (x3 : UINT32, x4 : UINT32 );
|
|
|
112 |
|
|
|
113 |
Tokdef hi_32 = [a:EXP] EXP EXP ? ( BIGEND_INT64, x1[a], x2[a]);
|
|
|
114 |
Tokdef lo_32 = [a:EXP] EXP EXP ? ( BIGEND_INT64, x2[a], x1[a]);
|
|
|
115 |
Tokdef hi_u32 = [a:EXP] EXP EXP ? ( BIGEND_INT64, x3[a], x4[a]);
|
|
|
116 |
Tokdef lo_u32 = [a:EXP] EXP EXP ? ( BIGEND_INT64, x4[a], x3[a]);
|
|
|
117 |
|
|
|
118 |
Tokdef .hi_32 = [] EXP EXP ? ( BIGEND_INT64, .x1, .x2);
|
|
|
119 |
Tokdef .lo_32 = [] EXP EXP ? ( BIGEND_INT64, .x2, .x1);
|
|
|
120 |
Tokdef .hi_u32 = [] EXP EXP ? ( BIGEND_INT64, .x3, .x4);
|
|
|
121 |
Tokdef .lo_u32 = [] EXP EXP ? ( BIGEND_INT64, .x4, .x3);
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
|
125 |
/*
|
|
|
126 |
Struct STRUCT_64 (hi_32 : INT32, lo_32 : UINT32 );
|
|
|
127 |
Struct STRUCT_U64 (hi_u32 : UINT32, lo_u32 : UINT32 );
|
|
|
128 |
*/
|
|
|
129 |
|
|
|
130 |
Struct Union64 ( PARAM : INT64);
|
|
|
131 |
Struct UnionU64 (UPARAM : UINT64);
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
Tokdef TDF_INT64 = [] SHAPE
|
|
|
136 |
compound (shape_offset(INT64) .max. shape_offset(STRUCT_64));
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
/* 64-bit constants used in the implementation */
|
|
|
142 |
|
|
|
143 |
Tokdef const_0 = [] EXP
|
|
|
144 |
Cons [shape_offset(TDF_INT64)] (.lo_32: 0(~UINT32), .hi_32: 0(~INT32));
|
|
|
145 |
|
|
|
146 |
Tokdef const_u0 = [] EXP
|
|
|
147 |
Cons [shape_offset(TDF_INT64)] (.lo_u32: 0(~UINT32), .hi_u32: 0(~INT32));
|
|
|
148 |
|
|
|
149 |
Tokdef const_1 = [] EXP
|
|
|
150 |
Cons [shape_offset(TDF_INT64)] (.lo_32: 1(~UINT32), .hi_32: 0(~INT32));
|
|
|
151 |
|
|
|
152 |
Tokdef const_u1 = [] EXP
|
|
|
153 |
Cons [shape_offset(TDF_INT64)] (.lo_u32: 1(~UINT32), .hi_u32: 0(~INT32));
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
Keep ( ~INT32, ~UINT32, INT32, UINT32, INT64, UINT64, TDF_INT64,
|
|
|
157 |
~BigFloat, BigFloat, PARAM, .PARAM, UPARAM, .UPARAM,
|
|
|
158 |
hi_32, lo_32, hi_u32, lo_u32, .hi_32, .lo_32, .hi_u32, .lo_u32,
|
|
|
159 |
const_0, const_u0, const_1, const_u1)
|