re PR rtl-optimization/34522 (inefficient code for long long multiply when only low...
[official-gcc.git] / gcc / ada / mlib-tgt.adb
blobe4d0441d55ac3648c0e51f2eda4f4f25e6c0453d
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- M L I B . T G T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2001-2007, AdaCore --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 with MLib.Fil;
27 with Prj.Com;
29 with MLib.Tgt.Specific;
30 pragma Warnings (Off, MLib.Tgt.Specific);
31 -- MLib.Tgt.Specific is with'ed only for elaboration purposes
33 package body MLib.Tgt is
35 ---------------------
36 -- Archive_Builder --
37 ---------------------
39 function Archive_Builder return String is
40 begin
41 return Archive_Builder_Ptr.all;
42 end Archive_Builder;
44 -----------------------------
45 -- Archive_Builder_Default --
46 -----------------------------
48 function Archive_Builder_Default return String is
49 begin
50 return "ar";
51 end Archive_Builder_Default;
53 -----------------------------
54 -- Archive_Builder_Options --
55 -----------------------------
57 function Archive_Builder_Options return String_List_Access is
58 begin
59 return Archive_Builder_Options_Ptr.all;
60 end Archive_Builder_Options;
62 -------------------------------------
63 -- Archive_Builder_Options_Default --
64 -------------------------------------
66 function Archive_Builder_Options_Default return String_List_Access is
67 begin
68 return new String_List'(1 => new String'("cr"));
69 end Archive_Builder_Options_Default;
71 ------------------------------------
72 -- Archive_Builder_Append_Options --
73 ------------------------------------
75 function Archive_Builder_Append_Options return String_List_Access is
76 begin
77 return Archive_Builder_Append_Options_Ptr.all;
78 end Archive_Builder_Append_Options;
80 --------------------------------------------
81 -- Archive_Builder_Append_Options_Default --
82 --------------------------------------------
84 function Archive_Builder_Append_Options_Default return String_List_Access is
85 begin
86 return new String_List'(1 => new String'("q"));
87 end Archive_Builder_Append_Options_Default;
89 -----------------
90 -- Archive_Ext --
91 -----------------
93 function Archive_Ext return String is
94 begin
95 return Archive_Ext_Ptr.all;
96 end Archive_Ext;
98 -------------------------
99 -- Archive_Ext_Default --
100 -------------------------
102 function Archive_Ext_Default return String is
103 begin
104 return "a";
105 end Archive_Ext_Default;
107 ---------------------
108 -- Archive_Indexer --
109 ---------------------
111 function Archive_Indexer return String is
112 begin
113 return Archive_Indexer_Ptr.all;
114 end Archive_Indexer;
116 -----------------------------
117 -- Archive_Indexer_Default --
118 -----------------------------
120 function Archive_Indexer_Default return String is
121 begin
122 return "ranlib";
123 end Archive_Indexer_Default;
125 -----------------------------
126 -- Archive_Indexer_Options --
127 -----------------------------
129 function Archive_Indexer_Options return String_List_Access is
130 begin
131 return Archive_Indexer_Options_Ptr.all;
132 end Archive_Indexer_Options;
134 -------------------------------------
135 -- Archive_Indexer_Options_Default --
136 -------------------------------------
138 function Archive_Indexer_Options_Default return String_List_Access is
139 begin
140 return new String_List (1 .. 0);
141 end Archive_Indexer_Options_Default;
143 ---------------------------
144 -- Build_Dynamic_Library --
145 ---------------------------
147 procedure Build_Dynamic_Library
148 (Ofiles : Argument_List;
149 Options : Argument_List;
150 Interfaces : Argument_List;
151 Lib_Filename : String;
152 Lib_Dir : String;
153 Symbol_Data : Symbol_Record;
154 Driver_Name : Name_Id := No_Name;
155 Lib_Version : String := "";
156 Auto_Init : Boolean := False)
158 begin
159 Build_Dynamic_Library_Ptr
160 (Ofiles,
161 Options,
162 Interfaces,
163 Lib_Filename,
164 Lib_Dir,
165 Symbol_Data,
166 Driver_Name,
167 Lib_Version,
168 Auto_Init);
169 end Build_Dynamic_Library;
171 ------------------------------
172 -- Default_Symbol_File_Name --
173 ------------------------------
175 function Default_Symbol_File_Name return String is
176 begin
177 return Default_Symbol_File_Name_Ptr.all;
178 end Default_Symbol_File_Name;
180 --------------------------------------
181 -- Default_Symbol_File_Name_Default --
182 --------------------------------------
184 function Default_Symbol_File_Name_Default return String is
185 begin
186 return "";
187 end Default_Symbol_File_Name_Default;
189 -------------
190 -- DLL_Ext --
191 -------------
193 function DLL_Ext return String is
194 begin
195 return DLL_Ext_Ptr.all;
196 end DLL_Ext;
198 ---------------------
199 -- DLL_Ext_Default --
200 ---------------------
202 function DLL_Ext_Default return String is
203 begin
204 return "so";
205 end DLL_Ext_Default;
207 ----------------
208 -- DLL_Prefix --
209 ----------------
211 function DLL_Prefix return String is
212 begin
213 return DLL_Prefix_Ptr.all;
214 end DLL_Prefix;
216 ------------------------
217 -- DLL_Prefix_Default --
218 ------------------------
220 function DLL_Prefix_Default return String is
221 begin
222 return "lib";
223 end DLL_Prefix_Default;
225 --------------------
226 -- Dynamic_Option --
227 --------------------
229 function Dynamic_Option return String is
230 begin
231 return Dynamic_Option_Ptr.all;
232 end Dynamic_Option;
234 ----------------------------
235 -- Dynamic_Option_Default --
236 ----------------------------
238 function Dynamic_Option_Default return String is
239 begin
240 return "-shared";
241 end Dynamic_Option_Default;
243 -------------------
244 -- Is_Object_Ext --
245 -------------------
247 function Is_Object_Ext (Ext : String) return Boolean is
248 begin
249 return Is_Object_Ext_Ptr (Ext);
250 end Is_Object_Ext;
252 ---------------------------
253 -- Is_Object_Ext_Default --
254 ---------------------------
256 function Is_Object_Ext_Default (Ext : String) return Boolean is
257 begin
258 return Ext = ".o";
259 end Is_Object_Ext_Default;
261 --------------
262 -- Is_C_Ext --
263 --------------
265 function Is_C_Ext (Ext : String) return Boolean is
266 begin
267 return Is_C_Ext_Ptr (Ext);
268 end Is_C_Ext;
270 ----------------------
271 -- Is_C_Ext_Default --
272 ----------------------
274 function Is_C_Ext_Default (Ext : String) return Boolean is
275 begin
276 return Ext = ".c";
277 end Is_C_Ext_Default;
279 --------------------
280 -- Is_Archive_Ext --
281 --------------------
283 function Is_Archive_Ext (Ext : String) return Boolean is
284 begin
285 return Is_Archive_Ext_Ptr (Ext);
286 end Is_Archive_Ext;
288 ----------------------------
289 -- Is_Archive_Ext_Default --
290 ----------------------------
292 function Is_Archive_Ext_Default (Ext : String) return Boolean is
293 begin
294 return Ext = ".a";
295 end Is_Archive_Ext_Default;
297 -------------
298 -- Libgnat --
299 -------------
301 function Libgnat return String is
302 begin
303 return Libgnat_Ptr.all;
304 end Libgnat;
306 ---------------------
307 -- Libgnat_Default --
308 ---------------------
310 function Libgnat_Default return String is
311 begin
312 return "libgnat.a";
313 end Libgnat_Default;
315 ------------------------
316 -- Library_Exists_For --
317 ------------------------
319 function Library_Exists_For
320 (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
322 begin
323 return Library_Exists_For_Ptr (Project, In_Tree);
324 end Library_Exists_For;
326 --------------------------------
327 -- Library_Exists_For_Default --
328 --------------------------------
330 function Library_Exists_For_Default
331 (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean
333 begin
334 if not In_Tree.Projects.Table (Project).Library then
335 Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " &
336 "for non library project");
337 return False;
339 else
340 declare
341 Lib_Dir : constant String :=
342 Get_Name_String
343 (In_Tree.Projects.Table (Project).Library_Dir);
344 Lib_Name : constant String :=
345 Get_Name_String
346 (In_Tree.Projects.Table (Project).Library_Name);
348 begin
349 if In_Tree.Projects.Table (Project).Library_Kind = Static then
350 return Is_Regular_File
351 (Lib_Dir & Directory_Separator & "lib" &
352 Fil.Append_To (Lib_Name, Archive_Ext));
354 else
355 return Is_Regular_File
356 (Lib_Dir & Directory_Separator & DLL_Prefix &
357 Fil.Append_To (Lib_Name, DLL_Ext));
358 end if;
359 end;
360 end if;
361 end Library_Exists_For_Default;
363 ---------------------------
364 -- Library_File_Name_For --
365 ---------------------------
367 function Library_File_Name_For
368 (Project : Project_Id;
369 In_Tree : Project_Tree_Ref) return File_Name_Type
371 begin
372 return Library_File_Name_For_Ptr (Project, In_Tree);
373 end Library_File_Name_For;
375 -----------------------------------
376 -- Library_File_Name_For_Default --
377 -----------------------------------
379 function Library_File_Name_For_Default
380 (Project : Project_Id;
381 In_Tree : Project_Tree_Ref) return File_Name_Type
383 begin
384 if not In_Tree.Projects.Table (Project).Library then
385 Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " &
386 "for non library project");
387 return No_File;
389 else
390 declare
391 Lib_Name : constant String :=
392 Get_Name_String
393 (In_Tree.Projects.Table (Project).Library_Name);
395 begin
396 if In_Tree.Projects.Table (Project).Library_Kind =
397 Static
398 then
399 Name_Len := 3;
400 Name_Buffer (1 .. Name_Len) := "lib";
401 Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, Archive_Ext));
402 else
403 Name_Len := 0;
404 Add_Str_To_Name_Buffer (DLL_Prefix);
405 Add_Str_To_Name_Buffer (Fil.Append_To (Lib_Name, DLL_Ext));
406 end if;
408 return Name_Find;
409 end;
410 end if;
411 end Library_File_Name_For_Default;
413 --------------------------------------
414 -- Library_Major_Minor_Id_Supported --
415 --------------------------------------
417 function Library_Major_Minor_Id_Supported return Boolean is
418 begin
419 return Library_Major_Minor_Id_Supported_Ptr.all;
420 end Library_Major_Minor_Id_Supported;
422 ----------------------------------------------
423 -- Library_Major_Minor_Id_Supported_Default --
424 ----------------------------------------------
426 function Library_Major_Minor_Id_Supported_Default return Boolean is
427 begin
428 return True;
429 end Library_Major_Minor_Id_Supported_Default;
431 ----------------
432 -- Object_Ext --
433 ----------------
435 function Object_Ext return String is
436 begin
437 return Object_Ext_Ptr.all;
438 end Object_Ext;
440 ------------------------
441 -- Object_Ext_Default --
442 ------------------------
444 function Object_Ext_Default return String is
445 begin
446 return "o";
447 end Object_Ext_Default;
449 ----------------
450 -- PIC_Option --
451 ----------------
453 function PIC_Option return String is
454 begin
455 return PIC_Option_Ptr.all;
456 end PIC_Option;
458 ------------------------
459 -- PIC_Option_Default --
460 ------------------------
462 function PIC_Option_Default return String is
463 begin
464 return "-fPIC";
465 end PIC_Option_Default;
467 -----------------------------------------------
468 -- Standalone_Library_Auto_Init_Is_Supported --
469 -----------------------------------------------
471 function Standalone_Library_Auto_Init_Is_Supported return Boolean is
472 begin
473 return Standalone_Library_Auto_Init_Is_Supported_Ptr.all;
474 end Standalone_Library_Auto_Init_Is_Supported;
476 -------------------------------------------------------
477 -- Standalone_Library_Auto_Init_Is_Supported_Default --
478 -------------------------------------------------------
480 function Standalone_Library_Auto_Init_Is_Supported_Default return Boolean is
481 begin
482 return True;
483 end Standalone_Library_Auto_Init_Is_Supported_Default;
485 ---------------------------
486 -- Support_For_Libraries --
487 ---------------------------
489 function Support_For_Libraries return Library_Support is
490 begin
491 return Support_For_Libraries_Ptr.all;
492 end Support_For_Libraries;
494 -----------------------------------
495 -- Support_For_Libraries_Default --
496 -----------------------------------
498 function Support_For_Libraries_Default return Library_Support is
499 begin
500 return Full;
501 end Support_For_Libraries_Default;
503 end MLib.Tgt;