Skip to content

Commit b3560ab

Browse files
committed
split up the prefix parsing
1 parent 898d8bd commit b3560ab

File tree

2 files changed

+43
-37
lines changed

2 files changed

+43
-37
lines changed

src/mono/mono/mini/intrinsics.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2396,20 +2396,22 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
23962396
!strncmp ("System.Runtime.Intrinsics", cmethod_klass_name_space, 25))) {
23972397
const char* cmethod_name = cmethod->name;
23982398

2399-
if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector<System.Runtime.Intrinsics.Vector", 70) == 0) {
2400-
// We want explicitly implemented ISimdVector<TSelf, T> APIs to still be expanded where possible
2401-
// but, they all prefix the qualified name of the interface first, so we'll check for that and
2402-
// skip the prefix before trying to resolve the method.
2403-
2404-
if (strncmp(cmethod_name + 70, "64<T>,T>.", 9) == 0) {
2405-
cmethod_name += 79;
2406-
} else if ((strncmp(cmethod_name + 70, "128<T>,T>.", 10) == 0) ||
2407-
(strncmp(cmethod_name + 70, "256<T>,T>.", 10) == 0) ||
2408-
(strncmp(cmethod_name + 70, "512<T>,T>.", 10) == 0)) {
2409-
cmethod_name += 80;
2410-
}
2411-
} else if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector<System.Numerics.Vector<T>,T>.", 67) == 0) {
2412-
cmethod_name += 67;
2399+
if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector<", 38) == 0) {
2400+
if (strncmp(cmethod_name + 38, "System.Runtime.Intrinsics.Vector", 32) == 0) {
2401+
// We want explicitly implemented ISimdVector<TSelf, T> APIs to still be expanded where possible
2402+
// but, they all prefix the qualified name of the interface first, so we'll check for that and
2403+
// skip the prefix before trying to resolve the method.
2404+
2405+
if (strncmp(cmethod_name + 70, "64<T>,T>.", 9) == 0) {
2406+
cmethod_name += 79;
2407+
} else if ((strncmp(cmethod_name + 70, "128<T>,T>.", 10) == 0) ||
2408+
(strncmp(cmethod_name + 70, "256<T>,T>.", 10) == 0) ||
2409+
(strncmp(cmethod_name + 70, "512<T>,T>.", 10) == 0)) {
2410+
cmethod_name += 80;
2411+
}
2412+
} else if (strncmp(cmethod_name + 38, "System.Numerics.Vector<T>,T>.", 29) == 0) {
2413+
cmethod_name += 67;
2414+
}
24132415
}
24142416

24152417
if (!strcmp (cmethod_name, "get_IsHardwareAccelerated")) {

src/mono/mono/mini/simd-intrinsics.c

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,20 +1906,22 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
19061906
{
19071907
const char *cmethod_name = cmethod->name;
19081908

1909-
if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector<System.Runtime.Intrinsics.Vector", 70) == 0) {
1909+
if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector<", 38) == 0) {
1910+
if (strncmp (cmethod_name + 38, "System.Runtime.Intrinsics.Vector", 32) == 0) {
19101911
// We want explicitly implemented ISimdVector<TSelf, T> APIs to still be expanded where possible
19111912
// but, they all prefix the qualified name of the interface first, so we'll check for that and
19121913
// skip the prefix before trying to resolve the method.
19131914

1914-
if (strncmp(cmethod_name + 70, "64<T>,T>.", 9) == 0) {
1915+
if (strncmp(cmethod_name + 70, "64<T>,T>.", 9) == 0) {
19151916
cmethod_name += 79;
1916-
} else if ((strncmp(cmethod_name + 70, "128<T>,T>.", 10) == 0) ||
1917-
(strncmp(cmethod_name + 70, "256<T>,T>.", 10) == 0) ||
1918-
(strncmp(cmethod_name + 70, "512<T>,T>.", 10) == 0)) {
1919-
cmethod_name += 80;
1917+
} else if ((strncmp(cmethod_name + 70, "128<T>,T>.", 10) == 0) ||
1918+
(strncmp(cmethod_name + 70, "256<T>,T>.", 10) == 0) ||
1919+
(strncmp(cmethod_name + 70, "512<T>,T>.", 10) == 0)) {
1920+
cmethod_name += 80;
1921+
}
1922+
} else if (strncmp(cmethod_name + 38, "System.Numerics.Vector<T>,T>.", 29) == 0) {
1923+
cmethod_name += 67;
19201924
}
1921-
} else if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector<System.Numerics.Vector<T>,T>.", 67) == 0) {
1922-
cmethod_name += 67;
19231925
}
19241926

19251927
int id = lookup_intrins (sri_vector_methods, sizeof (sri_vector_methods), cmethod_name);
@@ -3371,23 +3373,25 @@ emit_sri_vector_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
33713373
const char *cmethod_name = cmethod->name;
33723374
bool explicitly_implemented = false;
33733375

3374-
if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector<System.Runtime.Intrinsics.Vector", 70) == 0) {
3375-
// We want explicitly implemented ISimdVector<TSelf, T> APIs to still be expanded where possible
3376-
// but, they all prefix the qualified name of the interface first, so we'll check for that and
3377-
// skip the prefix before trying to resolve the method.
3378-
3379-
if (strncmp(cmethod_name + 70, "64<T>,T>.", 9) == 0) {
3380-
cmethod_name += 79;
3381-
explicitly_implemented = true;
3382-
} else if ((strncmp(cmethod_name + 70, "128<T>,T>.", 10) == 0) ||
3383-
(strncmp(cmethod_name + 70, "256<T>,T>.", 10) == 0) ||
3384-
(strncmp(cmethod_name + 70, "512<T>,T>.", 10) == 0)) {
3385-
cmethod_name += 80;
3376+
if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector<", 38) == 0) {
3377+
if (strncmp(cmethod_name + 38, "System.Runtime.Intrinsics.Vector", 32) == 0) {
3378+
// We want explicitly implemented ISimdVector<TSelf, T> APIs to still be expanded where possible
3379+
// but, they all prefix the qualified name of the interface first, so we'll check for that and
3380+
// skip the prefix before trying to resolve the method.
3381+
3382+
if (strncmp(cmethod_name + 70, "64<T>,T>.", 9) == 0) {
3383+
cmethod_name += 79;
3384+
explicitly_implemented = true;
3385+
} else if ((strncmp(cmethod_name + 70, "128<T>,T>.", 10) == 0) ||
3386+
(strncmp(cmethod_name + 70, "256<T>,T>.", 10) == 0) ||
3387+
(strncmp(cmethod_name + 70, "512<T>,T>.", 10) == 0)) {
3388+
cmethod_name += 80;
3389+
explicitly_implemented = true;
3390+
}
3391+
} else if (strncmp(cmethod_name + 38, "System.Numerics.Vector<T>,T>.", 29) == 0) {
3392+
cmethod_name += 67;
33863393
explicitly_implemented = true;
33873394
}
3388-
} else if (strncmp(cmethod_name, "System.Runtime.Intrinsics.ISimdVector<System.Numerics.Vector<T>,T>.", 67) == 0) {
3389-
cmethod_name += 67;
3390-
explicitly_implemented = true;
33913395
}
33923396

33933397
int id = lookup_intrins (sri_vector_t_methods, sizeof (sri_vector_t_methods), cmethod_name);

0 commit comments

Comments
 (0)