testsuite: 32 bit AIX 2 byte wchar
[official-gcc.git] / gcc / ada / backend_utils.adb
blob60715c56fdf25ccc6135ee77fa57320307d9363d
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- B A C K E N D _ U T I L S --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2021-2023, Free Software Foundation, Inc. --
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 Lib;
27 with Opt; use Opt;
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);
40 begin
42 -- Recognize -gxxx switches
44 if Switch_Chars (First) = 'g' then
45 Debugger_Level := 2;
47 if First < Last then
48 case Switch_Chars (First + 1) is
49 when '0' =>
50 Debugger_Level := 0;
51 when '1' =>
52 Debugger_Level := 1;
53 when '2' =>
54 Debugger_Level := 2;
55 when '3' =>
56 Debugger_Level := 3;
57 when others =>
58 null;
59 end case;
60 end if;
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
71 -- flags.
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
86 Generate_Asm := True;
88 else
89 return False;
90 end if;
92 Lib.Store_Compilation_Switch (Switch_Chars);
93 return True;
94 end Scan_Common_Back_End_Switch;
96 end Backend_Utils;