1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- B A C K E N D _ U T I L S --
9 -- Copyright (C) 2021-2023, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
28 with Switch
; use Switch
;
30 package body Backend_Utils
is
32 ---------------------------------
33 -- Scan_Common_Back_End_Switch --
34 ---------------------------------
36 function Scan_Common_Back_End_Switch
(Switch_Chars
: String) return Boolean
38 First
: constant Positive := Switch_Chars
'First + 1;
39 Last
: constant Natural := Switch_Last
(Switch_Chars
);
42 -- Recognize -gxxx switches
44 if Switch_Chars
(First
) = 'g' then
48 case Switch_Chars
(First
+ 1) is
62 -- Back end switch -fdiagnostics-format=json tells the frontend to
63 -- output its error and warning messages in the same format GCC
64 -- uses when passed -fdiagnostics-format=json.
66 elsif Switch_Chars
(First
.. Last
) = "fdiagnostics-format=json" then
67 Opt
.JSON_Output
:= True;
69 -- Back-end switch -fno-inline also sets the front end flags to entirely
70 -- inhibit all inlining. So we store it and set the appropriate
72 -- For gcc back ends, -fno-inline disables Inline pragmas only,
73 -- not Inline_Always to remain consistent with the always_inline
74 -- attribute behavior.
76 elsif Switch_Chars
(First
.. Last
) = "fno-inline" then
77 Opt
.Disable_FE_Inline
:= True;
79 -- Back end switch -fpreserve-control-flow also sets the front end
80 -- flag that inhibits improper control flow transformations.
82 elsif Switch_Chars
(First
.. Last
) = "fpreserve-control-flow" then
83 Opt
.Suppress_Control_Flow_Optimizations
:= True;
85 elsif Switch_Chars
(First
.. Last
) = "S" then
92 Lib
.Store_Compilation_Switch
(Switch_Chars
);
94 end Scan_Common_Back_End_Switch
;