1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
-- Iir to ortho translator.
-- Copyright (C) 2002 - 2014 Tristan Gingold
--
-- GHDL is free software; you can redistribute it and/or modify it under
-- the terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 2, or (at your option) any later
-- version.
--
-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
-- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-- for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with GCC; see the file COPYING. If not, write to the Free
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
with Errorout; use Errorout;
with Trans.Chap3;
with Trans.Chap6;
procedure Trans.Foreach_Non_Composite (Targ : Mnode;
Targ_Type : Iir;
Data : Data_Type)
is
use Trans.Helpers;
Type_Info : Type_Info_Acc;
begin
Type_Info := Get_Info (Targ_Type);
case Type_Info.Type_Mode is
when Type_Mode_Scalar =>
Do_Non_Composite (Targ, Targ_Type, Data);
when Type_Mode_Fat_Array
| Type_Mode_Array =>
declare
Var_Array : Mnode;
Var_Base : Mnode;
Var_Length : O_Dnode;
Var_I : O_Dnode;
Label : O_Snode;
Sub_Data : Data_Type;
Composite_Data : Composite_Data_Type;
begin
Open_Temp;
Var_Array := Stabilize (Targ);
Var_Length := Create_Temp (Ghdl_Index_Type);
Var_Base := Stabilize (Chap3.Get_Array_Base (Var_Array));
New_Assign_Stmt
(New_Obj (Var_Length),
Chap3.Get_Array_Length (Var_Array, Targ_Type));
Composite_Data :=
Prepare_Data_Array (Var_Array, Targ_Type, Data);
if True then
Var_I := Create_Temp (Ghdl_Index_Type);
else
New_Var_Decl
(Var_I, Wki_I, O_Storage_Local, Ghdl_Index_Type);
end if;
Init_Var (Var_I);
Start_Loop_Stmt (Label);
Gen_Exit_When
(Label, New_Compare_Op (ON_Ge,
New_Value (New_Obj (Var_I)),
New_Value (New_Obj (Var_Length)),
Ghdl_Bool_Type));
Sub_Data := Update_Data_Array
(Composite_Data, Targ_Type, Var_I);
Foreach_Non_Composite
(Chap3.Index_Base (Var_Base, Targ_Type,
New_Value (New_Obj (Var_I))),
Get_Element_Subtype (Targ_Type),
Sub_Data);
Inc_Var (Var_I);
Finish_Loop_Stmt (Label);
Finish_Data_Array (Composite_Data);
Close_Temp;
end;
when Type_Mode_Record =>
declare
Var_Record : Mnode;
Sub_Data : Data_Type;
Composite_Data : Composite_Data_Type;
List : Iir_List;
El : Iir_Element_Declaration;
begin
Open_Temp;
Var_Record := Stabilize (Targ);
Composite_Data :=
Prepare_Data_Record (Var_Record, Targ_Type, Data);
List := Get_Elements_Declaration_List
(Get_Base_Type (Targ_Type));
for I in Natural loop
El := Get_Nth_Element (List, I);
exit when El = Null_Iir;
Sub_Data := Update_Data_Record
(Composite_Data, Targ_Type, El);
Foreach_Non_Composite
(Chap6.Translate_Selected_Element (Var_Record, El),
Get_Type (El),
Sub_Data);
end loop;
Finish_Data_Record (Composite_Data);
Close_Temp;
end;
when others =>
Error_Kind ("foreach_non_composite/"
& Type_Mode_Type'Image (Type_Info.Type_Mode),
Targ_Type);
end case;
end Trans.Foreach_Non_Composite;
|