Debian Codegraph @

gcc/testsuite/gm2/base-lang/pass/SYSTEM.def

raw
1 (* SYSTEM.def provides access to the SYSTEM dependent module.
2
3 Copyright (C) 2001-2025 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <[email protected]>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
21
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
26
27 DEFINITION MODULE SYSTEM ;
28
29 EXPORT QUALIFIED BITSPERBYTE, BYTESPERWORD,
30 ADDRESS, WORD, BYTE, CSIZE_T, CSSIZE_T, (* @SYSTEM_DATATYPES@ *)
31 ADR, TSIZE, ROTATE, SHIFT, THROW, TBITSIZE ;
32 (* SIZE is also exported if -fpim2 is used. *)
33
34 CONST
35 BITSPERBYTE = __ATTRIBUTE__ __BUILTIN__ ((BITS_PER_UNIT)) ;
36 BYTESPERWORD = __ATTRIBUTE__ __BUILTIN__ ((UNITS_PER_WORD)) ;
37
38 (* Note that the full list of system and sized datatypes include:
39 LOC, WORD, BYTE, ADDRESS,
40
41 (and the non language standard target types)
42
43 INTEGER8, INTEGER16, INTEGER32, INTEGER64,
44 CARDINAL8, CARDINAL16, CARDINAL32, CARDINAL64,
45 WORD16, WORD32, WORD64, BITSET8, BITSET16,
46 BITSET32, REAL32, REAL64, REAL128, COMPLEX32,
47 COMPLEX64, COMPLEX128, CSIZE_T, CSSIZE_T.
48
49 Also note that the non-standard data types will
50 move into another module in the future. *)
51
52
53 (* The following types are supported on this target:
54 TYPE
55 @SYSTEM_TYPES@
56 *)
57
58
59 (*
60 all the functions below are declared internally to gm2
61 ======================================================
62
63 PROCEDURE ADR (VAR v: <anytype>): ADDRESS;
64 (* Returns the address of variable v. *)
65
66 PROCEDURE SIZE (v: <type>) : ZType;
67 (* Returns the number of BYTES used to store a v of
68 any specified <type>. Only available if -fpim2 is used.
69 *)
70
71 PROCEDURE TSIZE (<type>) : CARDINAL;
72 (* Returns the number of BYTES used to store a value of the
73 specified <type>.
74 *)
75
76 PROCEDURE ROTATE (val: <a set type>;
77 num: INTEGER): <type of first parameter>;
78 (* Returns a bit sequence obtained from val by rotating up/right
79 or down/right by the absolute value of num. The direction is
80 down/right if the sign of num is negative, otherwise the direction
81 is up/left.
82 *)
83
84 PROCEDURE SHIFT (val: <a set type>;
85 num: INTEGER): <type of first parameter>;
86 (* Returns a bit sequence obtained from val by shifting up/left
87 or down/right by the absolute value of num, introducing
88 zeros as necessary. The direction is down/right if the sign of
89 num is negative, otherwise the direction is up/left.
90 *)
91
92 PROCEDURE THROW (i: INTEGER) <* noreturn *> ;
93 (*
94 THROW is a GNU extension and was not part of the PIM or ISO
95 standards. It throws an exception which will be caught by the
96 EXCEPT block (assuming it exists). This is a compiler builtin
97 function which interfaces to the GCC exception handling runtime
98 system.
99 GCC uses the term throw, hence the naming distinction between
100 the GCC builtin and the Modula-2 runtime library procedure Raise.
101 The later library procedure Raise will call SYSTEM.THROW after
102 performing various housekeeping activities.
103 *)
104
105 PROCEDURE TBITSIZE (<type>) : CARDINAL ;
106 (* Returns the minimum number of bits necessary to represent
107 <type>. This procedure function is only useful for determining
108 the number of bits used for any type field within a packed RECORD.
109 It is not particularly useful elsewhere since <type> might be
110 optimized for speed, for example a BOOLEAN could occupy a WORD.
111 *)
112 *)
113
114 (* The following procedures are invoked by GNU Modula-2 to
115 shift non word sized set types. They are not strictly part
116 of the core PIM Modula-2, however they are used
117 to implement the SHIFT procedure defined above,
118 which are in turn used by the Logitech compatible libraries.
119
120 Users will access these procedures by using the procedure
121 SHIFT above and GNU Modula-2 will map SHIFT onto one of
122 the following procedures.
123 *)
124
125 (*
126 ShiftVal - is a runtime procedure whose job is to implement
127 the SHIFT procedure of ISO SYSTEM. GNU Modula-2 will
128 inline a SHIFT of a single WORD sized set and will only
129 call this routine for larger sets.
130 *)
131
132 PROCEDURE ShiftVal (VAR s, d: ARRAY OF BITSET;
133 SetSizeInBits: CARDINAL;
134 ShiftCount: INTEGER) ;
135
136
137 (*
138 ShiftLeft - performs the shift left for a multi word set.
139 This procedure might be called by the back end of
140 GNU Modula-2 depending whether amount is known at
141 compile time.
142 *)
143
144 PROCEDURE ShiftLeft (VAR s, d: ARRAY OF BITSET;
145 SetSizeInBits: CARDINAL;
146 ShiftCount: CARDINAL) ;
147
148 (*
149 ShiftRight - performs the shift left for a multi word set.
150 This procedure might be called by the back end of
151 GNU Modula-2 depending whether amount is known at
152 compile time.
153 *)
154
155 PROCEDURE ShiftRight (VAR s, d: ARRAY OF BITSET;
156 SetSizeInBits: CARDINAL;
157 ShiftCount: CARDINAL) ;
158
159
160 (*
161 RotateVal - is a runtime procedure whose job is to implement
162 the ROTATE procedure of ISO SYSTEM. GNU Modula-2 will
163 inline a ROTATE of a single WORD (or less)
164 sized set and will only call this routine for larger
165 sets.
166 *)
167
168 PROCEDURE RotateVal (VAR s, d: ARRAY OF BITSET;
169 SetSizeInBits: CARDINAL;
170 RotateCount: INTEGER) ;
171
172
173 (*
174 RotateLeft - performs the rotate left for a multi word set.
175 This procedure might be called by the back end of
176 GNU Modula-2 depending whether amount is known at
177 compile time.
178 *)
179
180 PROCEDURE RotateLeft (VAR s, d: ARRAY OF BITSET;
181 SetSizeInBits: CARDINAL;
182 RotateCount: CARDINAL) ;
183
184
185 (*
186 RotateRight - performs the rotate right for a multi word set.
187 This procedure might be called by the back end of
188 GNU Modula-2 depending whether amount is known at
189 compile time.
190 *)
191
192 PROCEDURE RotateRight (VAR s, d: ARRAY OF BITSET;
193 SetSizeInBits: CARDINAL;
194 RotateCount: CARDINAL) ;
195
196
197 END SYSTEM.