OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [back_end.adb] - Blame information for rev 316

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                            B A C K _ E N D                               --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2009, 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
------------------------------------------------------------------------------
25
 
26
with Atree;     use Atree;
27
with Debug;     use Debug;
28
with Elists;    use Elists;
29
with Lib;       use Lib;
30
with Osint;     use Osint;
31
with Opt;       use Opt;
32
with Osint.C;   use Osint.C;
33
with Namet;     use Namet;
34
with Nlists;    use Nlists;
35
with Stand;     use Stand;
36
with Sinput;    use Sinput;
37
with Stringt;   use Stringt;
38
with Switch;    use Switch;
39
with Switch.C;  use Switch.C;
40
with System;    use System;
41
with Types;     use Types;
42
 
43
package body Back_End is
44
 
45
   -------------------
46
   -- Call_Back_End --
47
   -------------------
48
 
49
   procedure Call_Back_End (Mode : Back_End_Mode_Type) is
50
 
51
      --  The Source_File_Record type has a lot of components that are
52
      --  meaningless to the back end, so a new record type is created
53
      --  here to contain the needed information for each file.
54
 
55
      type File_Info_Type is record
56
         File_Name        : File_Name_Type;
57
         Num_Source_Lines : Nat;
58
      end record;
59
 
60
      File_Info_Array : array (1 .. Last_Source_File) of File_Info_Type;
61
 
62
      procedure gigi
63
        (gnat_root                     : Int;
64
         max_gnat_node                 : Int;
65
         number_name                   : Nat;
66
         nodes_ptr                     : Address;
67
 
68
         next_node_ptr                 : Address;
69
         prev_node_ptr                 : Address;
70
         elists_ptr                    : Address;
71
         elmts_ptr                     : Address;
72
 
73
         strings_ptr                   : Address;
74
         string_chars_ptr              : Address;
75
         list_headers_ptr              : Address;
76
         number_file                   : Nat;
77
 
78
         file_info_ptr                 : Address;
79
         gigi_standard_boolean         : Entity_Id;
80
         gigi_standard_integer         : Entity_Id;
81
         gigi_standard_long_long_float : Entity_Id;
82
         gigi_standard_exception_type  : Entity_Id;
83
         gigi_operating_mode           : Back_End_Mode_Type);
84
 
85
      pragma Import (C, gigi);
86
 
87
   begin
88
      --  Skip call if in -gnatdH mode
89
 
90
      if Debug_Flag_HH then
91
         return;
92
      end if;
93
 
94
      for J in 1 .. Last_Source_File loop
95
         File_Info_Array (J).File_Name        := Full_Debug_Name (J);
96
         File_Info_Array (J).Num_Source_Lines := Num_Source_Lines (J);
97
      end loop;
98
 
99
      gigi
100
        (gnat_root          => Int (Cunit (Main_Unit)),
101
         max_gnat_node      => Int (Last_Node_Id - First_Node_Id + 1),
102
         number_name        => Name_Entries_Count,
103
         nodes_ptr          => Nodes_Address,
104
 
105
         next_node_ptr      => Next_Node_Address,
106
         prev_node_ptr      => Prev_Node_Address,
107
         elists_ptr         => Elists_Address,
108
         elmts_ptr          => Elmts_Address,
109
 
110
         strings_ptr        => Strings_Address,
111
         string_chars_ptr   => String_Chars_Address,
112
         list_headers_ptr   => Lists_Address,
113
         number_file        => Num_Source_Files,
114
 
115
         file_info_ptr                 => File_Info_Array'Address,
116
         gigi_standard_boolean         => Standard_Boolean,
117
         gigi_standard_integer         => Standard_Integer,
118
         gigi_standard_long_long_float => Standard_Long_Long_Float,
119
         gigi_standard_exception_type  => Standard_Exception_Type,
120
         gigi_operating_mode           => Mode);
121
   end Call_Back_End;
122
 
123
   -----------------------------
124
   -- Scan_Compiler_Arguments --
125
   -----------------------------
126
 
127
   procedure Scan_Compiler_Arguments is
128
      Next_Arg : Pos := 1;
129
 
130
      type Arg_Array is array (Nat) of Big_String_Ptr;
131
      type Arg_Array_Ptr is access Arg_Array;
132
 
133
      flag_stack_check : Int;
134
      pragma Import (C, flag_stack_check);
135
      --  Import from toplev.c
136
 
137
      save_argc : Nat;
138
      pragma Import (C, save_argc);
139
      --  Import from toplev.c
140
 
141
      save_argv : Arg_Array_Ptr;
142
      pragma Import (C, save_argv);
143
      --  Import from toplev.c
144
 
145
      Output_File_Name_Seen : Boolean := False;
146
      --  Set to True after having scanned file_name for switch "-gnatO file"
147
 
148
      --  Local functions
149
 
150
      function Len_Arg (Arg : Pos) return Nat;
151
      --  Determine length of argument number Arg on the original command line
152
      --  from gnat1.
153
 
154
      procedure Scan_Back_End_Switches (Switch_Chars : String);
155
      --  Procedure to scan out switches stored in Switch_Chars. The first
156
      --  character is known to be a valid switch character, and there are no
157
      --  blanks or other switch terminator characters in the string, so the
158
      --  entire string should consist of valid switch characters, except that
159
      --  an optional terminating NUL character is allowed.
160
      --
161
      --  Back end switches have already been checked and processed by GCC in
162
      --  toplev.c, so no errors can occur and control will always return. The
163
      --  switches must still be scanned to skip "-o" or internal GCC switches
164
      --  with their argument.
165
 
166
      -------------
167
      -- Len_Arg --
168
      -------------
169
 
170
      function Len_Arg (Arg : Pos) return Nat is
171
      begin
172
         for J in 1 .. Nat'Last loop
173
            if save_argv (Arg).all (Natural (J)) = ASCII.NUL then
174
               return J - 1;
175
            end if;
176
         end loop;
177
 
178
         raise Program_Error;
179
      end Len_Arg;
180
 
181
      ----------------------------
182
      -- Scan_Back_End_Switches --
183
      ----------------------------
184
 
185
      procedure Scan_Back_End_Switches (Switch_Chars : String) is
186
         First : constant Positive := Switch_Chars'First + 1;
187
         Last  : constant Natural  := Switch_Last (Switch_Chars);
188
 
189
      begin
190
         --  Skip -o or internal GCC switches together with their argument
191
 
192
         if Switch_Chars (First .. Last) = "o"
193
           or else Is_Internal_GCC_Switch (Switch_Chars)
194
         then
195
            Next_Arg := Next_Arg + 1;
196
 
197
         --  Do not record -quiet switch
198
 
199
         elsif Switch_Chars (First .. Last) = "quiet" then
200
            null;
201
 
202
         --  Store any other GCC switches
203
 
204
         else
205
            Store_Compilation_Switch (Switch_Chars);
206
 
207
            --  Special check, the back end switch -fno-inline also sets the
208
            --  front end flag to entirely inhibit all inlining.
209
 
210
            if Switch_Chars (First .. Last) = "fno-inline" then
211
               Opt.Suppress_All_Inlining := True;
212
 
213
            --  Another special check, the switch -fpreserve-control-flow
214
            --  which is also a back end switch sets the front end flag
215
            --  that inhibits improper control flow transformations.
216
 
217
            elsif Switch_Chars (First .. Last) = "fpreserve-control-flow" then
218
               Opt.Suppress_Control_Flow_Optimizations := True;
219
            end if;
220
         end if;
221
      end Scan_Back_End_Switches;
222
 
223
   --  Start of processing for Scan_Compiler_Arguments
224
 
225
   begin
226
      --  Acquire stack checking mode directly from GCC
227
 
228
      Opt.Stack_Checking_Enabled := (flag_stack_check /= 0);
229
 
230
      --  Loop through command line arguments, storing them for later access
231
 
232
      while Next_Arg < save_argc loop
233
         Look_At_Arg : declare
234
            Argv_Ptr : constant Big_String_Ptr := save_argv (Next_Arg);
235
            Argv_Len : constant Nat            := Len_Arg (Next_Arg);
236
            Argv     : constant String         :=
237
                         Argv_Ptr (1 .. Natural (Argv_Len));
238
 
239
         begin
240
            --  If the previous switch has set the Output_File_Name_Present
241
            --  flag (that is we have seen a -gnatO), then the next argument
242
            --  is the name of the output object file.
243
 
244
            if Output_File_Name_Present
245
              and then not Output_File_Name_Seen
246
            then
247
               if Is_Switch (Argv) then
248
                  Fail ("Object file name missing after -gnatO");
249
 
250
               else
251
                  Set_Output_Object_File_Name (Argv);
252
                  Output_File_Name_Seen := True;
253
               end if;
254
 
255
            --  If the previous switch has set the Search_Directory_Present
256
            --  flag (that is if we have just seen -I), then the next argument
257
            --  is a search directory path.
258
 
259
            elsif Search_Directory_Present then
260
               if Is_Switch (Argv) then
261
                  Fail ("search directory missing after -I");
262
               else
263
                  Add_Src_Search_Dir (Argv);
264
                  Search_Directory_Present := False;
265
               end if;
266
 
267
            elsif not Is_Switch (Argv) then -- must be a file name
268
               Add_File (Argv);
269
 
270
            --  We must recognize -nostdinc to suppress visibility on the
271
            --  standard GNAT RTL sources. This is also a gcc switch.
272
 
273
            elsif Argv (Argv'First + 1 .. Argv'Last) = "nostdinc" then
274
               Opt.No_Stdinc := True;
275
               Scan_Back_End_Switches (Argv);
276
 
277
            --  We must recognize -nostdlib to suppress visibility on the
278
            --  standard GNAT RTL objects.
279
 
280
            elsif Argv (Argv'First + 1 .. Argv'Last) = "nostdlib" then
281
               Opt.No_Stdlib := True;
282
 
283
            elsif Is_Front_End_Switch (Argv) then
284
               Scan_Front_End_Switches (Argv);
285
 
286
            --  All non-front-end switches are back-end switches
287
 
288
            else
289
               Scan_Back_End_Switches (Argv);
290
            end if;
291
         end Look_At_Arg;
292
 
293
         Next_Arg := Next_Arg + 1;
294
      end loop;
295
   end Scan_Compiler_Arguments;
296
 
297
end Back_End;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.