aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/ada/get_targ.adb
blob: 661f95b5ab3f685b3532d10c65a33686813c9993 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
------------------------------------------------------------------------------
--                                                                          --
--                         GNAT COMPILER COMPONENTS                         --
--                                                                          --
--                             G E T _ T A R G                              --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
--          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
--                                                                          --
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
-- for  more details.  You should have  received  a copy of the GNU General --
-- Public License  distributed with GNAT; see file COPYING3.  If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license.          --
--                                                                          --
-- GNAT was originally developed  by the GNAT team at  New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
--                                                                          --
------------------------------------------------------------------------------

--  Version for use with gcc

package body Get_Targ is

   --  Functions returning individual runtime. For the standard (GCC) back
   --  end these come from C interface functions (one for each value).

   -----------------------
   -- Get_Bits_Per_Unit --
   -----------------------

   function Get_Bits_Per_Unit return Pos is
      function C_Get_Bits_Per_Unit return Pos;
      pragma Import (C, C_Get_Bits_Per_Unit,
                        "get_target_bits_per_unit");
   begin
      return C_Get_Bits_Per_Unit;
   end Get_Bits_Per_Unit;

   -----------------------
   -- Get_Bits_Per_Word --
   -----------------------

   function Get_Bits_Per_Word return Pos is
      function C_Get_Bits_Per_Word return Pos;
      pragma Import (C, C_Get_Bits_Per_Word,
                        "get_target_bits_per_word");
   begin
      return C_Get_Bits_Per_Word;
   end Get_Bits_Per_Word;

   -------------------
   -- Get_Char_Size --
   -------------------

   function Get_Char_Size return Pos is
      function C_Get_Char_Size return Pos;
      pragma Import (C, C_Get_Char_Size,
                        "get_target_char_size");
   begin
      return C_Get_Char_Size;
   end Get_Char_Size;

   ----------------------
   -- Get_Wchar_T_Size --
   ----------------------

   function Get_Wchar_T_Size return Pos is
      function C_Get_Wchar_T_Size return Pos;
      pragma Import (C, C_Get_Wchar_T_Size,
                        "get_target_wchar_t_size");
   begin
      return C_Get_Wchar_T_Size;
   end Get_Wchar_T_Size;

   --------------------
   -- Get_Short_Size --
   --------------------

   function Get_Short_Size return Pos is
      function C_Get_Short_Size return Pos;
      pragma Import (C, C_Get_Short_Size,
                        "get_target_short_size");
   begin
      return C_Get_Short_Size;
   end Get_Short_Size;

   ------------------
   -- Get_Int_Size --
   ------------------

   function Get_Int_Size return Pos is
      function C_Get_Int_Size return Pos;
      pragma Import (C, C_Get_Int_Size,
                        "get_target_int_size");
   begin
      return C_Get_Int_Size;
   end Get_Int_Size;

   -------------------
   -- Get_Long_Size --
   -------------------

   function Get_Long_Size return Pos is
      function C_Get_Long_Size return Pos;
      pragma Import (C, C_Get_Long_Size,
                        "get_target_long_size");
   begin
      return C_Get_Long_Size;
   end Get_Long_Size;

   ------------------------
   -- Get_Long_Long_Size --
   ------------------------

   function Get_Long_Long_Size return Pos is
      function C_Get_Long_Long_Size return Pos;
      pragma Import (C, C_Get_Long_Long_Size,
                        "get_target_long_long_size");
   begin
      return C_Get_Long_Long_Size;
   end Get_Long_Long_Size;

   --------------------
   -- Get_Float_Size --
   --------------------

   function Get_Float_Size return Pos is
      function C_Get_Float_Size return Pos;
      pragma Import (C, C_Get_Float_Size,
                        "get_target_float_size");
   begin
      return C_Get_Float_Size;
   end Get_Float_Size;

   ---------------------
   -- Get_Double_Size --
   ---------------------

   function Get_Double_Size return Pos is
      function C_Get_Double_Size return Pos;
      pragma Import (C, C_Get_Double_Size,
                        "get_target_double_size");
   begin
      return C_Get_Double_Size;
   end Get_Double_Size;

   --------------------------
   -- Get_Long_Double_Size --
   --------------------------

   function Get_Long_Double_Size return Pos is
      function C_Get_Long_Double_Size return Pos;
      pragma Import (C, C_Get_Long_Double_Size,
                        "get_target_long_double_size");
   begin
      return C_Get_Long_Double_Size;
   end Get_Long_Double_Size;

   ----------------------
   -- Get_Pointer_Size --
   ----------------------

   function Get_Pointer_Size return Pos is
      function C_Get_Pointer_Size return Pos;
      pragma Import (C, C_Get_Pointer_Size,
                        "get_target_pointer_size");
   begin
      return C_Get_Pointer_Size;
   end Get_Pointer_Size;

   ---------------------------
   -- Get_Maximum_Alignment --
   ---------------------------

   function Get_Maximum_Alignment return Pos is
      function C_Get_Maximum_Alignment return Pos;
      pragma Import (C, C_Get_Maximum_Alignment,
                        "get_target_maximum_alignment");
   begin
      return C_Get_Maximum_Alignment;
   end Get_Maximum_Alignment;

   ------------------------
   -- Get_Float_Words_BE --
   ------------------------

   function Get_Float_Words_BE return Nat is
      function C_Get_Float_Words_BE return Nat;
      pragma Import (C, C_Get_Float_Words_BE,
                        "get_float_words_be");
   begin
      return C_Get_Float_Words_BE;
   end Get_Float_Words_BE;

   ------------------
   -- Get_Words_BE --
   ------------------

   function Get_Words_BE return Nat is
      function C_Get_Words_BE return Nat;
      pragma Import (C, C_Get_Words_BE,
                        "get_words_be");
   begin
      return C_Get_Words_BE;
   end Get_Words_BE;

   ------------------
   -- Get_Bytes_BE --
   ------------------

   function Get_Bytes_BE return Nat is
      function C_Get_Bytes_BE return Nat;
      pragma Import (C, C_Get_Bytes_BE,
                        "get_bytes_be");
   begin
      return C_Get_Bytes_BE;
   end Get_Bytes_BE;

   -----------------
   -- Get_Bits_BE --
   -----------------

   function Get_Bits_BE return Nat is
      function C_Get_Bits_BE return Nat;
      pragma Import (C, C_Get_Bits_BE,
                        "get_bits_be");
   begin
      return C_Get_Bits_BE;
   end Get_Bits_BE;

   ---------------------
   -- Get_Short_Enums --
   ---------------------

   function Get_Short_Enums return Int is
      flag_short_enums : Int;
      pragma Import (C, flag_short_enums);
   begin
      return flag_short_enums;
   end Get_Short_Enums;

   --------------------------
   -- Get_Strict_Alignment --
   --------------------------

   function Get_Strict_Alignment return Nat is
      function C_Get_Strict_Alignment return Nat;
      pragma Import (C, C_Get_Strict_Alignment,
                        "get_target_strict_alignment");
   begin
      return C_Get_Strict_Alignment;
   end Get_Strict_Alignment;

   ------------------------------------
   -- Get_System_Allocator_Alignment --
   ------------------------------------

   function Get_System_Allocator_Alignment return Nat is
      function C_Get_System_Allocator_Alignment return Nat;
      pragma Import (C, C_Get_System_Allocator_Alignment,
                        "get_target_system_allocator_alignment");
   begin
      return C_Get_System_Allocator_Alignment;
   end Get_System_Allocator_Alignment;

   --------------------------------
   -- Get_Double_Float_Alignment --
   --------------------------------

   function Get_Double_Float_Alignment return Nat is
      function C_Get_Double_Float_Alignment return Nat;
      pragma Import (C, C_Get_Double_Float_Alignment,
                        "get_target_double_float_alignment");
   begin
      return C_Get_Double_Float_Alignment;
   end Get_Double_Float_Alignment;

   ---------------------------------
   -- Get_Double_Scalar_Alignment --
   ---------------------------------

   function Get_Double_Scalar_Alignment return Nat is
      function C_Get_Double_Scalar_Alignment return Nat;
      pragma Import (C, C_Get_Double_Scalar_Alignment,
                        "get_target_double_scalar_alignment");
   begin
      return C_Get_Double_Scalar_Alignment;
   end Get_Double_Scalar_Alignment;

   ----------------------
   -- Digits_From_Size --
   ----------------------

   function Digits_From_Size (Size : Pos) return Pos is
   begin
      if    Size =  32 then
         return  6;
      elsif Size =  48 then
         return  9;
      elsif Size =  64 then
         return 15;
      elsif Size =  96 then
         return 18;
      elsif Size = 128 then
         return 18;
      else
         raise Program_Error;
      end if;
   end Digits_From_Size;

   -----------------------------
   -- Get_Max_Unaligned_Field --
   -----------------------------

   function Get_Max_Unaligned_Field return Pos is
   begin
      return 64;  -- Can be different on some targets (e.g., AAMP)
   end Get_Max_Unaligned_Field;

   -----------------------------
   -- Register_Back_End_Types --
   -----------------------------

   procedure Register_Back_End_Types (Call_Back : Register_Type_Proc) is
      procedure Enumerate_Modes (Call_Back : Register_Type_Proc);
      pragma Import (C, Enumerate_Modes, "enumerate_modes");
   begin
      Enumerate_Modes (Call_Back);
   end Register_Back_End_Types;

   ---------------------
   -- Width_From_Size --
   ---------------------

   function Width_From_Size  (Size : Pos) return Pos is
   begin
      if    Size =  8 then
         return  4;
      elsif Size = 16 then
         return  6;
      elsif Size = 32 then
         return 11;
      elsif Size = 64 then
         return 21;
      else
         raise Program_Error;
      end if;
   end Width_From_Size;

end Get_Targ;