summaryrefslogtreecommitdiff
path: root/ortho/debug
diff options
context:
space:
mode:
authorTristan Gingold2014-01-15 06:12:10 +0100
committerTristan Gingold2014-01-15 06:12:10 +0100
commitd68bc3f41ad8a750eda9c50878c6728a84ad3097 (patch)
tree9284690b0797e3ffed8839611d4b8e53ee1d5894 /ortho/debug
parent9b22b46458f2c80d87ffd957aa7df78cb98ee710 (diff)
downloadghdl-d68bc3f41ad8a750eda9c50878c6728a84ad3097.tar.gz
ghdl-d68bc3f41ad8a750eda9c50878c6728a84ad3097.tar.bz2
ghdl-d68bc3f41ad8a750eda9c50878c6728a84ad3097.zip
Add Alignof constant to get the alignment of a type.
Diffstat (limited to 'ortho/debug')
-rw-r--r--ortho/debug/ortho_debug-disp.adb5
-rw-r--r--ortho/debug/ortho_debug.adb14
-rw-r--r--ortho/debug/ortho_debug.private.ads4
3 files changed, 22 insertions, 1 deletions
diff --git a/ortho/debug/ortho_debug-disp.adb b/ortho/debug/ortho_debug-disp.adb
index be75122..60218bf 100644
--- a/ortho/debug/ortho_debug-disp.adb
+++ b/ortho/debug/ortho_debug-disp.adb
@@ -450,6 +450,11 @@ package body Ortho_Debug.Disp is
Put ("'sizeof (");
Disp_Tnode_Name (C.S_Type);
Put (")");
+ when OC_Alignof_Lit =>
+ Disp_Tnode_Name (C.Ctype);
+ Put ("'alignof (");
+ Disp_Tnode_Name (C.S_Type);
+ Put (")");
when OC_Offsetof_Lit =>
Disp_Tnode_Name (C.Ctype);
Put ("'offsetof (");
diff --git a/ortho/debug/ortho_debug.adb b/ortho/debug/ortho_debug.adb
index e2307b9..723fe3c 100644
--- a/ortho/debug/ortho_debug.adb
+++ b/ortho/debug/ortho_debug.adb
@@ -425,6 +425,20 @@ package body Ortho_Debug is
S_Type => Atype);
end New_Sizeof;
+ function New_Alignof (Atype : O_Tnode; Rtype : O_Tnode) return O_Cnode
+ is
+ subtype O_Cnode_Alignof_Type is O_Cnode_Type (OC_Alignof_Lit);
+ begin
+ if Rtype.Kind /= ON_Unsigned_Type then
+ raise Type_Error;
+ end if;
+ Check_Complete_Type (Atype);
+ return new O_Cnode_Alignof_Type'(Kind => OC_Alignof_Lit,
+ Ctype => Rtype,
+ Ref => False,
+ S_Type => Atype);
+ end New_Alignof;
+
function New_Offsetof (Field : O_Fnode; Rtype : O_Tnode) return O_Cnode
is
subtype O_Cnode_Offsetof_Type is O_Cnode_Type (OC_Offsetof_Lit);
diff --git a/ortho/debug/ortho_debug.private.ads b/ortho/debug/ortho_debug.private.ads
index 03489c5..79fd7b3 100644
--- a/ortho/debug/ortho_debug.private.ads
+++ b/ortho/debug/ortho_debug.private.ads
@@ -119,6 +119,7 @@ private
OC_Enum_Lit,
OC_Null_Lit,
OC_Sizeof_Lit,
+ OC_Alignof_Lit,
OC_Offsetof_Lit,
OC_Aggregate,
OC_Aggr_Element,
@@ -148,7 +149,8 @@ private
E_Name : O_Ident;
when OC_Null_Lit =>
null;
- when OC_Sizeof_Lit =>
+ when OC_Sizeof_Lit
+ | OC_Alignof_Lit =>
S_Type : O_Tnode;
when OC_Offsetof_Lit =>
Off_Field : O_Fnode;