Fix typos in riscv register save/restore.
[official-gcc.git] / gcc / ada / scil_ll.adb
blob151fda3c99373a11416594c53fd1a3f954de6a52
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S C I L _ L L --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2010-2016, 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. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 with Atree; use Atree;
33 with Opt; use Opt;
34 with Sinfo; use Sinfo;
35 with System.HTable; use System.HTable;
37 package body SCIL_LL is
39 procedure Copy_SCIL_Node (Target : Node_Id; Source : Node_Id);
40 -- Copy the SCIL field from Source to Target (it is used as the argument
41 -- for a call to Set_Reporting_Proc in package atree).
43 type Header_Num is range 1 .. 4096;
45 function Hash (N : Node_Id) return Header_Num;
46 -- Hash function for Node_Ids
48 --------------------------
49 -- Internal Hash Tables --
50 --------------------------
52 package Contract_Only_Body_Flag is new Simple_HTable
53 (Header_Num => Header_Num,
54 Element => Boolean,
55 No_Element => False,
56 Key => Node_Id,
57 Hash => Hash,
58 Equal => "=");
59 -- This table records the value of flag Is_Contract_Only_Flag of tree nodes
61 package Contract_Only_Body_Nodes is new Simple_HTable
62 (Header_Num => Header_Num,
63 Element => Node_Id,
64 No_Element => Empty,
65 Key => Node_Id,
66 Hash => Hash,
67 Equal => "=");
68 -- This table records the value of attribute Contract_Only_Body of tree
69 -- nodes.
71 package SCIL_Nodes is new Simple_HTable
72 (Header_Num => Header_Num,
73 Element => Node_Id,
74 No_Element => Empty,
75 Key => Node_Id,
76 Hash => Hash,
77 Equal => "=");
78 -- This table records the value of attribute SCIL_Node of tree nodes
80 --------------------
81 -- Copy_SCIL_Node --
82 --------------------
84 procedure Copy_SCIL_Node (Target : Node_Id; Source : Node_Id) is
85 begin
86 Set_SCIL_Node (Target, Get_SCIL_Node (Source));
87 end Copy_SCIL_Node;
89 ----------------------------
90 -- Get_Contract_Only_Body --
91 ----------------------------
93 function Get_Contract_Only_Body (N : Node_Id) return Node_Id is
94 begin
95 if CodePeer_Mode
96 and then Present (N)
97 then
98 return Contract_Only_Body_Nodes.Get (N);
99 else
100 return Empty;
101 end if;
102 end Get_Contract_Only_Body;
104 -------------------
105 -- Get_SCIL_Node --
106 -------------------
108 function Get_SCIL_Node (N : Node_Id) return Node_Id is
109 begin
110 if Generate_SCIL
111 and then Present (N)
112 then
113 return SCIL_Nodes.Get (N);
114 else
115 return Empty;
116 end if;
117 end Get_SCIL_Node;
119 ----------
120 -- Hash --
121 ----------
123 function Hash (N : Node_Id) return Header_Num is
124 begin
125 return Header_Num (1 + N mod Node_Id (Header_Num'Last));
126 end Hash;
128 ----------------
129 -- Initialize --
130 ----------------
132 procedure Initialize is
133 begin
134 SCIL_Nodes.Reset;
135 Contract_Only_Body_Nodes.Reset;
136 Contract_Only_Body_Flag.Reset;
137 Set_Reporting_Proc (Copy_SCIL_Node'Access);
138 end Initialize;
140 ---------------------------
141 -- Is_Contract_Only_Body --
142 ---------------------------
144 function Is_Contract_Only_Body (E : Entity_Id) return Boolean is
145 begin
146 return Contract_Only_Body_Flag.Get (E);
147 end Is_Contract_Only_Body;
149 ----------------------------
150 -- Set_Contract_Only_Body --
151 ----------------------------
153 procedure Set_Contract_Only_Body (N : Node_Id; Value : Node_Id) is
154 begin
155 pragma Assert (CodePeer_Mode
156 and then Present (N)
157 and then Is_Contract_Only_Body (Value));
159 Contract_Only_Body_Nodes.Set (N, Value);
160 end Set_Contract_Only_Body;
162 -------------------------------
163 -- Set_Is_Contract_Only_Body --
164 -------------------------------
166 procedure Set_Is_Contract_Only_Body (E : Entity_Id) is
167 begin
168 Contract_Only_Body_Flag.Set (E, True);
169 end Set_Is_Contract_Only_Body;
171 -------------------
172 -- Set_SCIL_Node --
173 -------------------
175 procedure Set_SCIL_Node (N : Node_Id; Value : Node_Id) is
176 begin
177 pragma Assert (Generate_SCIL);
179 if Present (Value) then
180 case Nkind (Value) is
181 when N_SCIL_Dispatch_Table_Tag_Init =>
182 pragma Assert (Nkind (N) = N_Object_Declaration);
183 null;
185 when N_SCIL_Dispatching_Call =>
186 pragma Assert (Nkind (N) in N_Subprogram_Call);
187 null;
189 when N_SCIL_Membership_Test =>
190 pragma Assert (Nkind_In (N, N_Identifier,
191 N_And_Then,
192 N_Or_Else,
193 N_Expression_With_Actions));
194 null;
196 when others =>
197 pragma Assert (False);
198 raise Program_Error;
199 end case;
200 end if;
202 SCIL_Nodes.Set (N, Value);
203 end Set_SCIL_Node;
205 end SCIL_LL;