d: Refactor matching and lowering of intrinsic functions.
authorIain Buclaw <ibuclaw@gdcproject.org>
Tue, 14 Jul 2020 16:45:42 +0000 (18:45 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Thu, 30 Jul 2020 10:03:58 +0000 (12:03 +0200)
commit6ee874f1353933b1427b5e2953358eb3424090d5
treed84425d9f58597e1450b5fe7ad27c5090577da23
parent2c558d2655cb22f472c83e8296b5cd2a92365cd3
d: Refactor matching and lowering of intrinsic functions.

Intrinsics are now matched explicitly, rather than through a common
alias where there are multiple overrides for a common intrinsic.
Where there is a corresponding DECL_FUNCTION_CODE, that is now stored in
the D intrinsic array.  All run-time std.math intrinsics have been
removed, as the library implementation already forwards to core.math.

gcc/d/ChangeLog:

* d-tree.h (DEF_D_INTRINSIC): Rename second argument from A to B.
* intrinsics.cc (intrinsic_decl): Add built_in field.
(DEF_D_INTRINSIC): Rename second argument from ALIAS to BUILTIN.
(maybe_set_intrinsic): Handle new intrinsic codes.
(expand_intrinsic_bt): Likewise.
(expand_intrinsic_checkedint): Likewise.
(expand_intrinsic_bswap): Remove.
(expand_intrinsic_sqrt): Remove.
(maybe_expand_intrinsic): Group together intrinsic cases that map
directly to gcc built-ins.
* intrinsics.def (DEF_D_BUILTIN): Rename second argument from A to B.
Update all callers to pass equivalent DECL_FUNCTION_CODE.
(DEF_CTFE_BUILTIN): Likewise.
(STD_COS): Remove intrinsic.
(STD_FABS): Remove intrinsic.
(STD_LDEXP): Remove intrinsic.
(STD_RINT): Remove intrinsic.
(STD_RNDTOL): Remove intrinsic.
(STD_SIN): Remove intrinsic.
(STD_SQRTF): Remove intrinsic.
(STD_SQRT): Remove intrinsic.
(STD_SQRTL): Remove intrinsic.

gcc/testsuite/ChangeLog:

* gdc.dg/intrinsics.d: New test.
gcc/d/d-tree.h
gcc/d/intrinsics.cc
gcc/d/intrinsics.def
gcc/testsuite/gdc.dg/intrinsics.d [new file with mode: 0644]