public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Improve handling of valuetypes and delegates from the CIL compiler
@ 2009-11-30 13:46 Arnaud Charlet
  2009-11-30 23:06 ` Laurent GUERBY
  0 siblings, 1 reply; 3+ messages in thread
From: Arnaud Charlet @ 2009-11-30 13:46 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jérôme Lambourg

[-- Attachment #1: Type: text/plain, Size: 587 bytes --]

This is for the benefit of the cil GNAT back-end

Tested on x86_64-pc-linux-gnu, committed on trunk

2009-11-30  Jerome Lambourg  <lambourg@adacore.com>

	* exp_ch3.adb (Make_Predefined_Primitive_Specs): Take care of CIL
	ValueTypes.
	* exp_ch7.adb (Needs_Finalization): Do not finalize CIL valuetypes.
	* sem_util.adb (Is_Value_Type): Protect against invalid calls to Chars
	(Is_Delegate): New method used for CIL.
	* sem_util.ads (Is_Delegate): New method for CIL handling.
	(Is_Value_Type): Improve documentation.

	Improve handling of valuetypes and delegates from the CIL compiler.

[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 4065 bytes --]

Index: exp_ch7.adb
===================================================================
--- exp_ch7.adb	(revision 154755)
+++ exp_ch7.adb	(working copy)
@@ -3294,7 +3294,8 @@ package body Exp_Ch7 is
 
       return (Is_Class_Wide_Type (T)
                 and then not In_Finalization_Root (T)
-                and then not Restriction_Active (No_Finalization))
+                and then not Restriction_Active (No_Finalization)
+                and then not Is_Value_Type (Etype (T)))
         or else Is_Controlled (T)
         or else Has_Some_Controlled_Component (T)
         or else (Is_Concurrent_Type (T)
Index: sem_util.adb
===================================================================
--- sem_util.adb	(revision 154791)
+++ sem_util.adb	(working copy)
@@ -7040,11 +7040,55 @@ package body Sem_Util is
    function Is_Value_Type (T : Entity_Id) return Boolean is
    begin
       return VM_Target = CLI_Target
+        and then Nkind (T) in N_Has_Chars
         and then Chars (T) /= No_Name
         and then Get_Name_String (Chars (T)) = "valuetype";
    end Is_Value_Type;
 
    -----------------
+   -- Is_Delegate --
+   -----------------
+
+   function Is_Delegate (T : Entity_Id) return Boolean is
+      Desig_Type : Entity_Id;
+   begin
+      if VM_Target /= CLI_Target then
+         return False;
+      end if;
+
+      --  Access-to-subprograms are delegates in CIL
+      if Ekind (T) = E_Access_Subprogram_Type then
+         return True;
+      end if;
+
+      if Ekind (T) not in Access_Kind then
+         --  a delegate is a managed pointer. If no designated type is defined
+         --  it means that it's not a delegate.
+         return False;
+      end if;
+
+      Desig_Type := Etype (Directly_Designated_Type (T));
+
+      if not Is_Tagged_Type (Desig_Type) then
+         return False;
+      end if;
+
+      --  Test if the type is inherited from [mscorlib]System.Delegate
+      while Etype (Desig_Type) /= Desig_Type loop
+         if Chars (Scope (Desig_Type)) /= No_Name
+           and then Is_Imported (Scope (Desig_Type))
+           and then Get_Name_String (Chars (Scope (Desig_Type))) = "delegate"
+         then
+            return True;
+         end if;
+
+         Desig_Type := Etype (Desig_Type);
+      end loop;
+
+      return False;
+   end Is_Delegate;
+
+   -----------------
    -- Is_Variable --
    -----------------
 
Index: sem_util.ads
===================================================================
--- sem_util.ads	(revision 154791)
+++ sem_util.ads	(working copy)
@@ -800,8 +800,14 @@ package Sem_Util is
    function Is_Value_Type (T : Entity_Id) return Boolean;
    --  Returns true if type T represents a value type. This is only relevant to
    --  CIL, will always return false for other targets.
-   --  What is a "value type", since this is not an Ada term, it should be
-   --  defined here ???
+   --  A value type is a CIL object that is accessed directly, as opposed to
+   --  the other CIL objects that are accessed through managed pointers.
+
+   function Is_Delegate (T : Entity_Id) return Boolean;
+   --  Returns true if type T represents a delegate. A Delegate is the CIL
+   --  object used to represent access-to-subprogram types.
+   --  This is only relevant to CIL, will always return false for other
+   --  targets.
 
    function Is_Variable (N : Node_Id) return Boolean;
    --  Determines if the tree referenced by N represents a variable, i.e.
Index: exp_ch3.adb
===================================================================
--- exp_ch3.adb	(revision 154755)
+++ exp_ch3.adb	(working copy)
@@ -8121,7 +8121,9 @@ package body Exp_Ch3 is
                   and then not Is_Limited_Interface (Tag_Typ)
                   and then Is_Limited_Interface (Etype (Tag_Typ)))
       then
-         if not Is_Limited_Type (Tag_Typ) then
+         if not Is_Limited_Type (Tag_Typ)
+           and then not Is_Value_Type (Tag_Typ)
+         then
             Append_To (Res,
               Predef_Deep_Spec (Loc, Tag_Typ, TSS_Deep_Adjust));
          end if;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Ada] Improve handling of valuetypes and delegates from the  CIL compiler
  2009-11-30 13:46 [Ada] Improve handling of valuetypes and delegates from the CIL compiler Arnaud Charlet
@ 2009-11-30 23:06 ` Laurent GUERBY
  2009-12-01  8:25   ` Arnaud Charlet
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent GUERBY @ 2009-11-30 23:06 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: gcc-patches, Jérôme Lambourg

On Mon, 2009-11-30 at 14:46 +0100, Arnaud Charlet wrote:
> This is for the benefit of the cil GNAT back-end
> 
> Tested on x86_64-pc-linux-gnu, committed on trunk

Hi, 

Is there a public SVN for the CIL(/JVM) back-end or plans to have one or
integrate it into GCC? IIRC the runtime collection was not complete
(sockets, etc...) and this is something that could be done through the
community.

The only source release I know about is gnatvm-gpl-2009-src.tgz
from libre.adacore.com, may be I missed something.

Thanks in advance,

Laurent



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Ada] Improve handling of valuetypes and delegates from the  CIL compiler
  2009-11-30 23:06 ` Laurent GUERBY
@ 2009-12-01  8:25   ` Arnaud Charlet
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaud Charlet @ 2009-12-01  8:25 UTC (permalink / raw)
  To: Laurent GUERBY; +Cc: gcc-patches, Jérôme Lambourg

> Is there a public SVN for the CIL(/JVM) back-end or plans to have one or
> integrate it into GCC? IIRC the runtime collection was not complete
> (sockets, etc...) and this is something that could be done through the
> community.
> 
> The only source release I know about is gnatvm-gpl-2009-src.tgz
> from libre.adacore.com, may be I missed something.

Right, that's the reference currently, and we do receive some contributions
on this technology from time to time, so do not hesitate to submit patches
via the libre site.

Arno

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-01  8:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-30 13:46 [Ada] Improve handling of valuetypes and delegates from the CIL compiler Arnaud Charlet
2009-11-30 23:06 ` Laurent GUERBY
2009-12-01  8:25   ` Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).