]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Add new predicate Is_Address_Compatible_Type
authorSebastian Poeplau <poeplau@adacore.com>
Tue, 7 Nov 2023 12:28:25 +0000 (13:28 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 28 Nov 2023 09:35:47 +0000 (10:35 +0100)
When emitting code for architectures with tagged pointers, it is useful
to be able to recognize values representing addresses because they
require special handling. This commits adds the predicate
Is_Address_Compatible_Type, which differs from the node attribute
Is_Descendant_Of_Address by also taking Standard_Address into account.

gcc/ada/

* einfo-utils.ads, einfo-utils.adb (Is_Address_Compatible_Type):
New function.

gcc/ada/einfo-utils.adb
gcc/ada/einfo-utils.ads

index 88f4d4be7c835f209359980be0a99a5781c33ee5..46177acc7f837c20267dc4fe81e58f0305b849f6 100644 (file)
@@ -201,6 +201,11 @@ package body Einfo.Utils is
         and then Ekind (Directly_Designated_Type (Id)) = E_Subprogram_Type;
    end Is_Access_Subprogram_Type;
 
+   function Is_Address_Compatible_Type          (Id : E) return B is
+   begin
+      return Is_Descendant_Of_Address (Id) or else Id = Standard_Address;
+   end Is_Address_Compatible_Type;
+
    function Is_Aggregate_Type                   (Id : E) return B is
    begin
       return Ekind (Id) in Aggregate_Kind;
index 742ca2200805d4948fb8ada5e61bb3a45b91b866..5589276e22f5183634ef45245496b860f1aa24d3 100644 (file)
@@ -96,6 +96,8 @@ package Einfo.Utils is
    function Is_Access_Type                      (Id : E) return B with Inline;
    function Is_Access_Protected_Subprogram_Type (Id : E) return B with Inline;
    function Is_Access_Subprogram_Type           (Id : E) return B with Inline;
+   function Is_Address_Compatible_Type          (Id : E) return B with Inline;
+   --  Check whether the type represents an address
    function Is_Aggregate_Type                   (Id : E) return B with Inline;
    function Is_Anonymous_Access_Type            (Id : E) return B with Inline;
    function Is_Array_Type                       (Id : E) return B with Inline;