This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Add direct support for GCC intrinsics


Tested on x86-linux, committed on mainline.

This patch implements a new scheme for handling intrinsics which allows pragma
Import (Intrinsic) to be used to obtain access to the gcc builtins. The
approach is to have the front end ignore pragma Import Intrinsic if an
external name is given. Any calls to the corresponding subprogram are left
unexpanded to be handled by the back end. The idea is that the external name
will match one of the names of built ins handled by the back end, and gigi
will recognize the name and replace the call with an appropriate use
of the back end intrinsic.

In addition, a subprogram that contains exception handlers cannot be inlined. If
the subprogram uses the secondary stack, a cleanup procedure will be
generated and called within an at_end handler. Depending on the target
and the exception model, this handler may be converted into a regular
exception handler. The code that rejects the pragma now checks for the
presence of both an explicit handler and an at_end handler, to make
the corresponding warning target-independent.

--
procedure try is
   function f (x : integer) return integer is
      S : constant String := integer'image (X);
   begin
      return s'last; 
   end;
   pragma inline (f);
begin
   if f (5) /= 1 then null; end if;
end;

2004-12-07  Robert Dewar  <dewar@adacore.com>
	    Ed Schonberg  <schonberg@adacore.com>

	* exp_ch6.adb (Expand_Call): Add comment on handling of back end
	intrinsic

	* exp_intr.adb (Expand_Intrinsic_Call): Ignore unrecognized intrinsic,
	leaving call unchanged.
	This deals with the case where the pragma Import specified
	an external name, to be handled by the back end.

	* sem_prag.adb (Process_Import_Or_Interface): Do not check validity of
	subprogram which is Imported with convention Intrinsic if an
	External_Name argument is specified.
	(Process_Import_Or_Interface): Properly diagnose link name argument.
	(Inlining_Not_Possible): New name for Cannot_Inline, to avoid confusion
	with Sem_Ch6.Cannot_Inline.
	(Process_Inline): Provide separate warning for inapplicable inline
	pragma.
	(Cannot_Inline): Reject subprograms that have an at_end handler, so that
	treatment is uniform on different targets.

Attachment: difs.10
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]