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] allow interfacing with most c-common builtins


This is a first shot at allowing interfacing Ada to most builtins
internally at hand, for instance:

    procedure Bltins is

       function Sqrt (F : Float) return Float;
       pragma Import (Intrinsic, Sqrt, "__builtin_sqrtf");

       F : Float := 4.0;
       R : Float;
    begin
       R := Sqrt (F);
    end;

to produce

    _ada_bltins:
    .LFB3:
	    pushq   %rbp
    .LCFI0:
	    movq    %rsp, %rbp
    .LCFI1:
	    movl    $0x40800000, %eax
	    movl    %eax, -8(%rbp)
	    movl    $0x40000000, %eax
	    movl    %eax, -4(%rbp)
	    leave
	    ret

on x86_64-linux-gnu. We're still missing support for the stdio
builtins, which I think is really not a problem.

This is still in rough shape, with pieces "imported" from the C
front-end, and we have two obvious enhancement candidates:

   o Use a more efficient name/decl mapping scheme
   o Devise a middle-end infrastructure to avoid having to copy
     pieces between front-ends.

We decided to move forward and implement this in the current
intermediate shape to let us/users

   gain experience about possible issues in this area (had
   an interesting one with builtin_alloca vs nothrow),

   identify possible language specific needs, non-needs or constraints,
   hence determine what is useful as a common ground,

   develop Ada bindings to builtin families, independently from the
   underlying implementation scheme,

Bootstrapped and regtested x86_64-unknown-linux-gnu.

2008-04-18  Olivier Hainque  <hainque@adacore.com>

ada/
	Access to most C builtins from Ada
	* utils.c: #include "langhooks.h" and define GCC_DIAG_STYLE.
	(handle_pure_attribute, handle_novops_attribute,
	handle_nonnull_attribute, handle_sentinel_attribute,
	handle_noreturn_attribute, handle_malloc_attribute,
	handle_type_generic_attribute): New attribute handlers, from C fe.
	(gnat_internal_attribute_table): Map the new handlers.
	(gnat_init_decl_processing): Move call to gnat_install_builtins to ...
	(init_gigi_decls): ... here.
	(handle_const_attribute, handle_nothrow_attribute, builtin_decl_for):
	Move to a section dedicated to builtins processing.
	(build_void_list_node, builtin_type_for_size): New functions.
	(def_fn_type, get_nonnull_operand): Likewise.
	(install_builtin_elementary_type, install_builtin_function_types,
	install_builtin_attributes): Likewise.
	(fake_attribute_handler): Fake handler for attributes we don't
	support in Ada.
	(def_builtin_1): New function, worker for DEF_BUILTIN.
	(install_builtin_functions): New function.
	(gnat_install_builtins): Move to the builtins processing section.
	Now calling the newly introduced installers.

testsuite/
	* gnat.dg/bltins.adb: New testcase.







Attachment: builtins-trunk.dif
Description: Text document


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