Skip to content

Commit

Permalink
d: Merge upstream dmd 46133f761, druntime 0fd4364c
Browse files Browse the repository at this point in the history
D front-end changes:

 - Backported built-in function handling from upstream.

 - Added new intrinsic `byteswap(ushort)`.

Druntime changes:

 - Update intrinsic modules core.bitop, core.checkedint, core.simd,
   core.vararg, and core.volatile.

 - Backport platform-specific fixes for runtime modules core.cpuid,
   core.internal.traits, and rt.lifetime.

 - Backport openbsd fixes for core.stdc.stdio.

 - Backport solaris fixes for core.sys.posix.locale, and
   core.thread.osthread (PR98910).

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 46133f761.
	* d-builtins.cc (d_build_builtins_module): Set builtins as BUILTINgcc.
	(maybe_set_builtin_1): Likewise.
	* d-frontend.cc (eval_builtin): Adjust condition for early return.
	* intrinsics.cc (maybe_set_intrinsic): Set intrinsics as BUILTINgcc.
	(maybe_expand_intrinsic): Add case for INTRINSIC_BSWAP16.
	* intrinsics.def (INTRINSIC_BT): Update signature.
	(INTRINSIC_BT64): Likewise.
	(INTRINSIC_BSWAP16): New intrinsic.
	(INTRINSIC_VLOAD8): Update module.
	(INTRINSIC_VLOAD16): Likewise.
	(INTRINSIC_VLOAD32): Likewise.
	(INTRINSIC_VLOAD64): Likewise.
	(INTRINSIC_VSTORE8): Likewise.
	(INTRINSIC_VSTORE16): Likewise.
	(INTRINSIC_VSTORE32): Likewise.
	(INTRINSIC_VSTORE64): Likewise.
	(INTRINSIC_ADDS): Update signature.
	(INTRINSIC_ADDSL): Likewise.
	(INTRINSIC_ADDU): Likewise.
	(INTRINSIC_ADDUL): Likewise.
	(INTRINSIC_SUBS): Likewise.
	(INTRINSIC_SUBSL): Likewise.
	(INTRINSIC_SUBU): Likewise.
	(INTRINSIC_SUBUL): Likewise.
	(INTRINSIC_MULS): Likewise.
	(INTRINSIC_MULSL): Likewise.
	(INTRINSIC_MULU): Likewise.
	(INTRINSIC_MULUI): Likewise.
	(INTRINSIC_MULUL): Likewise.
	(INTRINSIC_NEGS): Likewise.
	(INTRINSIC_NEGSL): Likewise.

libphobos/ChangeLog:

	PR d/98910
	* libdruntime/MERGE: Merge upstream druntime 0fd4364c.
	* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add core/volatile.d.
	* libdruntime/Makefile.in: Regenerate.
	* testsuite/libphobos.allocations/tls_gc_integration.d: Update test.

gcc/testsuite/ChangeLog:

	* gdc.dg/intrinsics.d: Update test.
  • Loading branch information
ibuclaw committed Feb 4, 2021
1 parent ce57204 commit c1d56e6
Show file tree
Hide file tree
Showing 25 changed files with 1,329 additions and 769 deletions.
4 changes: 2 additions & 2 deletions gcc/d/d-builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ d_build_builtins_module (Module *m)
STCextern, tf);
DECL_LANG_SPECIFIC (decl) = build_lang_decl (func);
func->csym = decl;
func->builtin = BUILTINyes;
func->builtin = BUILTINgcc;

members->push (func);
}
Expand Down Expand Up @@ -706,7 +706,7 @@ maybe_set_builtin_1 (Dsymbol *d)
/* Found a match, tell the frontend this is a builtin. */
DECL_LANG_SPECIFIC (t) = build_lang_decl (fd);
fd->csym = t;
fd->builtin = BUILTINyes;
fd->builtin = BUILTINgcc;
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion gcc/d/d-frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ isBuiltin (FuncDeclaration *fd)
Expression *
eval_builtin (Loc loc, FuncDeclaration *fd, Expressions *arguments)
{
if (fd->builtin != BUILTINyes)
if (fd->builtin == BUILTINunimp)
return NULL;

tree decl = get_symbol_decl (fd);
Expand Down
2 changes: 1 addition & 1 deletion gcc/d/dmd/MERGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
5e2a81d9cbcd653d9eed52344d664e72ba1355bc
46133f76172c26c89e2ebf9cd058cd1f1e8807ed

The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
40 changes: 37 additions & 3 deletions gcc/d/dmd/declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,43 @@ enum ILS

enum BUILTIN
{
BUILTINunknown = -1, // not known if this is a builtin
BUILTINno, // this is not a builtin
BUILTINyes // this is a builtin
BUILTINunknown = 255, /// not known if this is a builtin
BUILTINunimp = 0, /// this is not a builtin
BUILTINgcc, /// this is a GCC builtin
BUILTINllvm, /// this is an LLVM builtin
BUILTINsin,
BUILTINcos,
BUILTINtan,
BUILTINsqrt,
BUILTINfabs,
BUILTINldexp,
BUILTINlog,
BUILTINlog2,
BUILTINlog10,
BUILTINexp,
BUILTINexpm1,
BUILTINexp2,
BUILTINround,
BUILTINfloor,
BUILTINceil,
BUILTINtrunc,
BUILTINcopysign,
BUILTINpow,
BUILTINfmin,
BUILTINfmax,
BUILTINfma,
BUILTINisnan,
BUILTINisinfinity,
BUILTINisfinite,
BUILTINbsf,
BUILTINbsr,
BUILTINbswap,
BUILTINpopcnt,
BUILTINyl2x,
BUILTINyl2xp1,
BUILTINtoPrecFloat,
BUILTINtoPrecDouble,
BUILTINtoPrecReal
};

Expression *eval_builtin(Loc loc, FuncDeclaration *fd, Expressions *arguments);
Expand Down
2 changes: 1 addition & 1 deletion gcc/d/dmd/dinterpret.c
Original file line number Diff line number Diff line change
Expand Up @@ -6801,7 +6801,7 @@ Expression *evaluateIfBuiltin(UnionExp *pue, InterState *istate, Loc loc,
size_t nargs = arguments ? arguments->length : 0;
if (!pthis)
{
if (isBuiltin(fd) == BUILTINyes)
if (isBuiltin(fd) != BUILTINunimp)
{
Expressions args;
args.setDim(nargs);
Expand Down
38 changes: 38 additions & 0 deletions gcc/d/dmd/idgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ Msgtable msgtable[] =
{ "entrypoint", "__entrypoint" },

// varargs implementation
{ "stdc", NULL },
{ "stdarg", NULL },
{ "va_start", NULL },

// Builtin functions
Expand All @@ -304,16 +306,52 @@ Msgtable msgtable[] =
{ "_sqrt", "sqrt" },
{ "_pow", "pow" },
{ "atan2", NULL },
{ "rint", NULL },
{ "ldexp", NULL },
{ "rndtol", NULL },
{ "exp", NULL },
{ "expm1", NULL },
{ "exp2", NULL },
{ "yl2x", NULL },
{ "yl2xp1", NULL },
{ "log", NULL },
{ "log2", NULL },
{ "log10", NULL },
{ "round", NULL },
{ "floor", NULL },
{ "trunc", NULL },
{ "fmax", NULL },
{ "fmin", NULL },
{ "fma", NULL },
{ "isnan", NULL },
{ "isInfinity", NULL },
{ "isfinite", NULL },
{ "ceil", NULL },
{ "copysign", NULL },
{ "fabs", NULL },
{ "toPrec", NULL },
{ "simd", NULL },
{ "__prefetch", NULL },
{ "__simd_sto", NULL },
{ "__simd", NULL },
{ "__simd_ib", NULL },
{ "bitop", NULL },
{ "bsf", NULL },
{ "bsr", NULL },
{ "btc", NULL },
{ "btr", NULL },
{ "bts", NULL },
{ "bswap", NULL },
{ "_volatile", "volatile" },
{ "volatileLoad", NULL },
{ "volatileStore", NULL },
{ "_popcnt", NULL },
{ "inp", NULL },
{ "inpl", NULL },
{ "inpw", NULL },
{ "outp", NULL },
{ "outpl", NULL },
{ "outpw", NULL },

// Traits
{ "isAbstractClass", NULL },
Expand Down
18 changes: 18 additions & 0 deletions gcc/d/dmd/root/ctfloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ struct CTFloat
static real_t fabs(real_t x);
static real_t ldexp(real_t n, int exp);

static real_t round(real_t x);
static real_t floor(real_t x);
static real_t ceil(real_t x);
static real_t trunc(real_t x);
static real_t log(real_t x);
static real_t log2(real_t x);
static real_t log10(real_t x);
static real_t pow(real_t x, real_t y);
static real_t exp(real_t x);
static real_t expm1(real_t x);
static real_t exp2(real_t x);

static real_t fmin(real_t x, real_t y);
static real_t fmax(real_t x, real_t y);
static real_t copysign(real_t x, real_t s);

static real_t fma(real_t x, real_t y, real_t z);

static bool isIdentical(real_t a, real_t b);
static bool isNaN(real_t r);
static bool isSNaN(real_t r);
Expand Down
7 changes: 4 additions & 3 deletions gcc/d/intrinsics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ maybe_set_intrinsic (FuncDeclaration *decl)

/* The builtin flag is updated only if we can evaluate the intrinsic
at compile-time. Such as the math or bitop intrinsics. */
decl->builtin = BUILTINno;
decl->builtin = BUILTINunimp;

/* Check if it's a compiler intrinsic. We only require that any
internally recognised intrinsics are declared in a module with
Expand Down Expand Up @@ -177,12 +177,12 @@ maybe_set_intrinsic (FuncDeclaration *decl)
built-in function. It could be `int pow(int, int)'. */
tree rettype = TREE_TYPE (TREE_TYPE (decl->csym));
if (mathfn_built_in (rettype, BUILT_IN_POW) != NULL_TREE)
decl->builtin = BUILTINyes;
decl->builtin = BUILTINgcc;
break;
}

default:
decl->builtin = BUILTINyes;
decl->builtin = BUILTINgcc;
break;
}

Expand Down Expand Up @@ -809,6 +809,7 @@ maybe_expand_intrinsic (tree callexp)
case INTRINSIC_ROR_TIARG:
return expand_intrinsic_rotate (intrinsic, callexp);

case INTRINSIC_BSWAP16:
case INTRINSIC_BSWAP32:
case INTRINSIC_BSWAP64:
case INTRINSIC_CEIL:
Expand Down
53 changes: 28 additions & 25 deletions gcc/d/intrinsics.def
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@ DEF_D_BUILTIN (NONE, NONE, 0, 0, 0)

DEF_D_BUILTIN (BSF, NONE, "bsf", "core.bitop", "FNaNbNiNfkZi")
DEF_D_BUILTIN (BSR, NONE, "bsr", "core.bitop", "FNaNbNiNfkZi")
DEF_D_BUILTIN (BT, NONE, "bt", "core.bitop", "FNaNbNixPkkZi")
DEF_D_BUILTIN (BT, NONE, "bt", "core.bitop", "FNaNbNiMxPkkZi")
DEF_D_BUILTIN (BTC, NONE, "btc", "core.bitop", "FNaNbNiPkkZi")
DEF_D_BUILTIN (BTR, NONE, "btr", "core.bitop", "FNaNbNiPkkZi")
DEF_D_BUILTIN (BTS, NONE, "bts", "core.bitop", "FNaNbNiPkkZi")
DEF_D_BUILTIN (BSF64, NONE, "bsf", "core.bitop", "FNaNbNiNfmZi")
DEF_D_BUILTIN (BSR64, NONE, "bsr", "core.bitop", "FNaNbNiNfmZi")
DEF_D_BUILTIN (BT64, NONE, "bt", "core.bitop", "FNaNbNixPmmZi")
DEF_D_BUILTIN (BT64, NONE, "bt", "core.bitop", "FNaNbNiMxPmmZi")
DEF_D_BUILTIN (BTC64, NONE, "btc", "core.bitop", "FNaNbNiPmmZi")
DEF_D_BUILTIN (BTR64, NONE, "btr", "core.bitop", "FNaNbNiPmmZi")
DEF_D_BUILTIN (BTS64, NONE, "bts", "core.bitop", "FNaNbNiPmmZi")

DEF_D_BUILTIN (BSWAP16, BSWAP16, "byteswap", "core.bitop", "FNaNbNiNftZt")
DEF_D_BUILTIN (BSWAP32, BSWAP32, "bswap", "core.bitop", "FNaNbNiNfkZk")
DEF_D_BUILTIN (BSWAP64, BSWAP64, "bswap", "core.bitop", "FNaNbNiNfmZm")

Expand All @@ -64,32 +65,34 @@ DEF_D_BUILTIN (ROL_TIARG, NONE, "rol", "core.bitop", "FNaI1TZI1T")
DEF_D_BUILTIN (ROR, NONE, "ror", "core.bitop", "FNaI1TkZI1T")
DEF_D_BUILTIN (ROR_TIARG, NONE, "ror", "core.bitop", "FNaI1TZI1T")

DEF_D_BUILTIN (VLOAD8, NONE, "volatileLoad", "core.bitop", "FNbNiNfPhZh")
DEF_D_BUILTIN (VLOAD16, NONE, "volatileLoad", "core.bitop", "FNbNiNfPtZt")
DEF_D_BUILTIN (VLOAD32, NONE, "volatileLoad", "core.bitop", "FNbNiNfPkZk")
DEF_D_BUILTIN (VLOAD64, NONE, "volatileLoad", "core.bitop", "FNbNiNfPmZm")
DEF_D_BUILTIN (VSTORE8, NONE, "volatileStore", "core.bitop", "FNbNiNfPhhZv")
DEF_D_BUILTIN (VSTORE16, NONE, "volatileStore", "core.bitop", "FNbNiNfPttZv")
DEF_D_BUILTIN (VSTORE32, NONE, "volatileStore", "core.bitop", "FNbNiNfPkkZv")
DEF_D_BUILTIN (VSTORE64, NONE, "volatileStore", "core.bitop", "FNbNiNfPmmZv")
/* core.volatile intrinsics. */

DEF_D_BUILTIN (VLOAD8, NONE, "volatileLoad", "core.volatile", "FNbNiNfPhZh")
DEF_D_BUILTIN (VLOAD16, NONE, "volatileLoad", "core.volatile", "FNbNiNfPtZt")
DEF_D_BUILTIN (VLOAD32, NONE, "volatileLoad", "core.volatile", "FNbNiNfPkZk")
DEF_D_BUILTIN (VLOAD64, NONE, "volatileLoad", "core.volatile", "FNbNiNfPmZm")
DEF_D_BUILTIN (VSTORE8, NONE, "volatileStore", "core.volatile", "FNbNiNfPhhZv")
DEF_D_BUILTIN (VSTORE16, NONE, "volatileStore", "core.volatile", "FNbNiNfPttZv")
DEF_D_BUILTIN (VSTORE32, NONE, "volatileStore", "core.volatile", "FNbNiNfPkkZv")
DEF_D_BUILTIN (VSTORE64, NONE, "volatileStore", "core.volatile", "FNbNiNfPmmZv")

/* core.checkedint intrinsics. */

DEF_D_BUILTIN (ADDS, NONE, "adds", "core.checkedint", "FNaNbNiNfiiKbZi")
DEF_D_BUILTIN (ADDSL, NONE, "adds", "core.checkedint", "FNaNbNiNfllKbZl")
DEF_D_BUILTIN (ADDU, NONE, "addu", "core.checkedint", "FNaNbNiNfkkKbZk")
DEF_D_BUILTIN (ADDUL, NONE, "addu", "core.checkedint", "FNaNbNiNfmmKbZm")
DEF_D_BUILTIN (SUBS, NONE, "subs", "core.checkedint", "FNaNbNiNfiiKbZi")
DEF_D_BUILTIN (SUBSL, NONE, "subs", "core.checkedint", "FNaNbNiNfllKbZl")
DEF_D_BUILTIN (SUBU, NONE, "subu", "core.checkedint", "FNaNbNiNfkkKbZk")
DEF_D_BUILTIN (SUBUL, NONE, "subu", "core.checkedint", "FNaNbNiNfmmKbZm")
DEF_D_BUILTIN (MULS, NONE, "muls", "core.checkedint", "FNaNbNiNfiiKbZi")
DEF_D_BUILTIN (MULSL, NONE, "muls", "core.checkedint", "FNaNbNiNfllKbZl")
DEF_D_BUILTIN (MULU, NONE, "mulu", "core.checkedint", "FNaNbNiNfkkKbZk")
DEF_D_BUILTIN (MULUI, NONE, "mulu", "core.checkedint", "FNaNbNiNfmkKbZm")
DEF_D_BUILTIN (MULUL, NONE, "mulu", "core.checkedint", "FNaNbNiNfmmKbZm")
DEF_D_BUILTIN (NEGS, NONE, "negs", "core.checkedint", "FNaNbNiNfiKbZi")
DEF_D_BUILTIN (NEGSL, NONE, "negs", "core.checkedint", "FNaNbNiNflKbZl")
DEF_D_BUILTIN (ADDS, NONE, "adds", "core.checkedint", "FiiKbZi")
DEF_D_BUILTIN (ADDSL, NONE, "adds", "core.checkedint", "FllKbZl")
DEF_D_BUILTIN (ADDU, NONE, "addu", "core.checkedint", "FkkKbZk")
DEF_D_BUILTIN (ADDUL, NONE, "addu", "core.checkedint", "FmmKbZm")
DEF_D_BUILTIN (SUBS, NONE, "subs", "core.checkedint", "FiiKbZi")
DEF_D_BUILTIN (SUBSL, NONE, "subs", "core.checkedint", "FllKbZl")
DEF_D_BUILTIN (SUBU, NONE, "subu", "core.checkedint", "FkkKbZk")
DEF_D_BUILTIN (SUBUL, NONE, "subu", "core.checkedint", "FmmKbZm")
DEF_D_BUILTIN (MULS, NONE, "muls", "core.checkedint", "FiiKbZi")
DEF_D_BUILTIN (MULSL, NONE, "muls", "core.checkedint", "FllKbZl")
DEF_D_BUILTIN (MULU, NONE, "mulu", "core.checkedint", "FkkKbZk")
DEF_D_BUILTIN (MULUI, NONE, "mulu", "core.checkedint", "FmkKbZm")
DEF_D_BUILTIN (MULUL, NONE, "mulu", "core.checkedint", "FmmKbZm")
DEF_D_BUILTIN (NEGS, NONE, "negs", "core.checkedint", "FiKbZi")
DEF_D_BUILTIN (NEGSL, NONE, "negs", "core.checkedint", "FlKbZl")

/* core.math intrinsics. */

Expand Down
3 changes: 3 additions & 0 deletions gcc/testsuite/gdc.dg/intrinsics.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import core.bitop;
import core.checkedint;
import core.math;
import core.volatile;
import core.stdc.stdarg;

//////////////////////////////////////////////////////
Expand All @@ -24,6 +25,8 @@ int test_btc(size_t *a, size_t b) { return btc(a, b); }
int test_btr(size_t *a, size_t b) { return btr(a, b); }
// { dg-final { scan-tree-dump-not " <retval> = bts " "original" } }
int test_bts(size_t *a, size_t b) { return bts(a, b); }
// { dg-final { scan-tree-dump " __builtin_bswap16 " "original" } }
ushort test_byteswap(ushort a) { return byteswap(a); }
// { dg-final { scan-tree-dump " __builtin_bswap32 " "original" } }
uint test_bswap(uint a) { return bswap(a); }
// { dg-final { scan-tree-dump " __builtin_bswap64 " "original" } }
Expand Down
2 changes: 1 addition & 1 deletion libphobos/libdruntime/MERGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
9d0c8364450064d0b6e68da4384f8acd19eb454f
0fd4364c4a4eb2ce0ebb8f613092c5bed7a63bf9

The first line of this file holds the git revision number of the last
merge done from the dlang/druntime repository.
31 changes: 16 additions & 15 deletions libphobos/libdruntime/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,22 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
core/sync/rwmutex.d core/sync/semaphore.d core/thread/context.d \
core/thread/fiber.d core/thread/osthread.d core/thread/package.d \
core/thread/threadbase.d core/thread/threadgroup.d core/thread/types.d \
core/time.d core/vararg.d gc/bits.d gc/config.d gc/gcinterface.d \
gc/impl/conservative/gc.d gc/impl/manual/gc.d gc/os.d gc/pooltable.d \
gc/proxy.d gcc/attribute.d gcc/backtrace.d gcc/builtins.d gcc/deh.d \
gcc/emutls.d gcc/gthread.d gcc/sections/android.d \
gcc/sections/elf_shared.d gcc/sections/osx.d gcc/sections/package.d \
gcc/sections/win32.d gcc/sections/win64.d gcc/unwind/arm.d \
gcc/unwind/arm_common.d gcc/unwind/c6x.d gcc/unwind/generic.d \
gcc/unwind/package.d gcc/unwind/pe.d object.d rt/aApply.d rt/aApplyR.d \
rt/aaA.d rt/adi.d rt/arrayassign.d rt/arraycast.d rt/arraycat.d \
rt/cast_.d rt/config.d rt/critical_.d rt/deh.d rt/dmain2.d \
rt/invariant.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \
rt/obj.d rt/qsort.d rt/sections.d rt/switch_.d rt/tlsgc.d \
rt/util/array.d rt/util/container/array.d rt/util/container/common.d \
rt/util/container/hashtab.d rt/util/container/treap.d rt/util/random.d \
rt/util/typeinfo.d rt/util/utf.d
core/time.d core/vararg.d core/volatile.d gc/bits.d gc/config.d \
gc/gcinterface.d gc/impl/conservative/gc.d gc/impl/manual/gc.d gc/os.d \
gc/pooltable.d gc/proxy.d gcc/attribute.d gcc/backtrace.d \
gcc/builtins.d gcc/deh.d gcc/emutls.d gcc/gthread.d \
gcc/sections/android.d gcc/sections/elf_shared.d gcc/sections/osx.d \
gcc/sections/package.d gcc/sections/win32.d gcc/sections/win64.d \
gcc/unwind/arm.d gcc/unwind/arm_common.d gcc/unwind/c6x.d \
gcc/unwind/generic.d gcc/unwind/package.d gcc/unwind/pe.d object.d \
rt/aApply.d rt/aApplyR.d rt/aaA.d rt/adi.d rt/arrayassign.d \
rt/arraycast.d rt/arraycat.d rt/cast_.d rt/config.d rt/critical_.d \
rt/deh.d rt/dmain2.d rt/invariant.d rt/lifetime.d rt/memory.d \
rt/minfo.d rt/monitor_.d rt/obj.d rt/qsort.d rt/sections.d \
rt/switch_.d rt/tlsgc.d rt/util/array.d rt/util/container/array.d \
rt/util/container/common.d rt/util/container/hashtab.d \
rt/util/container/treap.d rt/util/random.d rt/util/typeinfo.d \
rt/util/utf.d

DRUNTIME_DSOURCES_STDCXX = core/stdcpp/exception.d \
core/stdcpp/typeinfo.d
Expand Down
Loading

0 comments on commit c1d56e6

Please sign in to comment.