aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho/mcode/ortho_code-consts.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-07-24 18:31:11 +0200
committerTristan Gingold <tgingold@free.fr>2020-07-25 11:28:49 +0200
commit04cd83fb46bee1e7a7b37be95bee73449af9c8b8 (patch)
tree3fe35d0bc6d4b1be8d81ad44df685057c221d2dc /src/ortho/mcode/ortho_code-consts.adb
parent4033dd795927a4953879bdc92d395788893a5468 (diff)
downloadghdl-04cd83fb46bee1e7a7b37be95bee73449af9c8b8.tar.gz
ghdl-04cd83fb46bee1e7a7b37be95bee73449af9c8b8.tar.bz2
ghdl-04cd83fb46bee1e7a7b37be95bee73449af9c8b8.zip
ortho: add unbounded records, rework array subtypes.
Diffstat (limited to 'src/ortho/mcode/ortho_code-consts.adb')
-rw-r--r--src/ortho/mcode/ortho_code-consts.adb43
1 files changed, 31 insertions, 12 deletions
diff --git a/src/ortho/mcode/ortho_code-consts.adb b/src/ortho/mcode/ortho_code-consts.adb
index dcb9c13be..c83b98459 100644
--- a/src/ortho/mcode/ortho_code-consts.adb
+++ b/src/ortho/mcode/ortho_code-consts.adb
@@ -507,11 +507,11 @@ package body Ortho_Code.Consts is
return To_Cnode_Union (Cnodes.Table (Cst + 1)).El;
end Get_Const_Union_Value;
+ function To_Cnode_Common is new Ada.Unchecked_Conversion
+ (Source => Cnode_Sizeof, Target => Cnode_Common);
+
function New_Sizeof (Atype : O_Tnode; Rtype : O_Tnode) return O_Cnode
is
- function To_Cnode_Common is new Ada.Unchecked_Conversion
- (Source => Cnode_Sizeof, Target => Cnode_Common);
-
Res : O_Cnode;
begin
if Debug.Flag_Debug_Hli then
@@ -527,6 +527,24 @@ package body Ortho_Code.Consts is
end if;
end New_Sizeof;
+ function New_Record_Sizeof
+ (Atype : O_Tnode; Rtype : O_Tnode) return O_Cnode
+ is
+ Res : O_Cnode;
+ begin
+ if Debug.Flag_Debug_Hli then
+ Cnodes.Append (Cnode_Common'(Kind => OC_Record_Sizeof,
+ Lit_Type => Rtype));
+ Res := Cnodes.Last;
+ Cnodes.Append (To_Cnode_Common (Cnode_Sizeof'(Atype => Atype,
+ Pad => 0)));
+ return Res;
+ else
+ return New_Unsigned_Literal
+ (Rtype, Unsigned_64 (Get_Type_Record_Size (Atype)));
+ end if;
+ end New_Record_Sizeof;
+
function Get_Sizeof_Type (Cst : O_Cnode) return O_Tnode
is
function To_Cnode_Sizeof is new Ada.Unchecked_Conversion
@@ -645,8 +663,8 @@ package body Ortho_Code.Consts is
begin
case Get_Const_Kind (Cst) is
when OC_Signed
- | OC_Unsigned
- | OC_Float =>
+ | OC_Unsigned
+ | OC_Float =>
H := Get_Const_High (Cst);
L := Get_Const_Low (Cst);
when OC_Null =>
@@ -656,13 +674,14 @@ package body Ortho_Code.Consts is
H := 0;
L := To_Cnode_Enum (Cnodes.Table (Cst + 1)).Val;
when OC_Array
- | OC_Record
- | OC_Union
- | OC_Sizeof
- | OC_Alignof
- | OC_Address
- | OC_Subprg_Address
- | OC_Zero =>
+ | OC_Record
+ | OC_Union
+ | OC_Sizeof
+ | OC_Record_Sizeof
+ | OC_Alignof
+ | OC_Address
+ | OC_Subprg_Address
+ | OC_Zero =>
raise Syntax_Error;
end case;
end Get_Const_Bytes;