Skip to content

Commit 9e082b9

Browse files
badnikhilthewilsonator
authored andcommitted
use predefined Id:: identifiers for comparison hooks
1 parent 04f48e8 commit 9e082b9

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

dmd/id.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,10 @@ immutable Msgtable[] msgtable =
596596
{ "dcompute" },
597597
{ "dcPointer", "Pointer" },
598598
{ "dcReflect", "__dcompute_reflect" },
599+
// dcompute array comparison/equality lowering hooks
600+
{ "comparison" },
601+
{ "equality" },
602+
{ "dstrcmp" },
599603
{ "RTInfoImpl" },
600604
{ "opencl" },
601605

dmd/id.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ struct Id
4545
static Identifier *dcPointer;
4646
static Identifier *object;
4747
static Identifier *core;
48+
static Identifier *internal;
49+
static Identifier *array;
50+
static Identifier *string;
4851
static Identifier *etc;
4952
static Identifier *std;
5053
static Identifier *ensure;
@@ -77,6 +80,10 @@ struct Id
7780
static Identifier *LDC_extern_weak;
7881
static Identifier *LDC_profile_instr;
7982
static Identifier *dcReflect;
83+
// dcompute array comparison/equality hooks (see isDeviceArrayComparisonHook)
84+
static Identifier *comparison;
85+
static Identifier *equality;
86+
static Identifier *dstrcmp;
8087
static Identifier *opencl;
8188
static Identifier *criticalenter;
8289
static Identifier *criticalexit;

gen/uda.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -665,21 +665,17 @@ bool isDeviceArrayComparisonHook(Dsymbol *sym) {
665665
// These druntime modules are host-only, but their templates (`__cmp`,
666666
// `__equals` and helpers like `isEqual`/`at`) are the lowering hooks emitted
667667
// for array `<`/`==` in device code, so they must not be skipped.
668-
Identifier *const internal = Identifier::idPool("internal");
669668
if (md->packages.length == 3 && md->packages.ptr[0] == Id::core &&
670-
md->packages.ptr[1] == internal &&
671-
md->packages.ptr[2] == Identifier::idPool("array") &&
672-
(md->id == Identifier::idPool("comparison") ||
673-
md->id == Identifier::idPool("equality")))
669+
md->packages.ptr[1] == Id::internal && md->packages.ptr[2] == Id::array &&
670+
(md->id == Id::comparison || md->id == Id::equality))
674671
return true;
675672
// From core.internal.string only `dstrcmp` is a device-legal hook helper (the
676673
// `char`/string `__cmp` specialization calls it). The rest of that module
677674
// (e.g. signedToTempString) contains device-illegal code, so don't exempt the
678675
// whole module.
679676
if (md->packages.length == 2 && md->packages.ptr[0] == Id::core &&
680-
md->packages.ptr[1] == internal &&
681-
md->id == Identifier::idPool("string"))
682-
return sym->ident == Identifier::idPool("dstrcmp");
677+
md->packages.ptr[1] == Id::internal && md->id == Id::string)
678+
return sym->ident == Id::dstrcmp;
683679
return false;
684680
}
685681

0 commit comments

Comments
 (0)