Skip to content

Commit

Permalink
Fix masked GNUABI build for NOALIAS
Browse files Browse the repository at this point in the history
The previous patch only added support for the unmasked build - masked
symbols also need to sidestep aliases when they are not supported.
  • Loading branch information
joeramsay committed Jul 15, 2024
1 parent 6d2f30e commit 98b7d98
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/libm/mkmasked_gnuabi.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,21 @@ int main(int argc, char **argv) {
switch(funcList[i].funcType) {
case 0: {
printf("EXPORT CONST %s %s(%s a0, vopmask m) { return %s(a0); }\n",
vfpname[fptype], funcname[1], vfpname[fptype], funcname[0]);
vfpname[fptype], funcname[1], vfpname[fptype], funcname[0]);

if (funcList[i].ulp < 20)
printf("EXPORT CONST %s %s(%s, vopmask) __attribute__((weak, alias(\"%s\")));\n",
vfpname[fptype], funcname[3], vfpname[fptype], funcname[1]);
printf("DMASKED_ALIAS_%s(%s, %s)\n", vfpname[fptype], funcname[3], funcname[1]);
else
printf("EXPORT CONST %s %s_u%d(%s, vopmask) __attribute__((weak, alias(\"%s\")));\n",
vfpname[fptype], funcname[3],funcList[i].ulp, vfpname[fptype], funcname[1]);
printf("DMASKED_ALIAS_%s(%s_u%d, %s)\n", vfpname[fptype], funcname[3], funcList[i].ulp, funcname[1]);
break;
}
case 1: {
printf("EXPORT CONST %s %s(%s a0, %s a1, vopmask m) { return %s(a0, a1); }\n",
vfpname[fptype], funcname[1], vfpname[fptype], vfpname[fptype], funcname[0]);
if (funcList[i].ulp < 20)
printf("EXPORT CONST %s %s(%s, %s, vopmask) __attribute__((weak, alias(\"%s\")));\n",
vfpname[fptype], funcname[3], vfpname[fptype], vfpname[fptype], funcname[1]);
printf("DMASKED_ALIAS_%s2(%s, %s)\n", vfpname[fptype], funcname[3], funcname[1]);
else
printf("EXPORT CONST %s %s_u%d(%s, %s, vopmask) __attribute__((weak, alias(\"%s\")));\n",
vfpname[fptype], funcname[3],funcList[i].ulp, vfpname[fptype], vfpname[fptype], funcname[1]);
printf("DMASKED_ALIAS_%s2(%s_u%d, %s)\n", vfpname[fptype], funcname[3], funcList[i].ulp, funcname[1]);
break;
}
case 2:
Expand Down Expand Up @@ -160,13 +156,10 @@ int main(int argc, char **argv) {

printf("EXPORT CONST %s %s(%s a0, %s a1, vopmask m) { return %s(a0, a1); }\n",
vfpname[fptype], funcname[1], vfpname[fptype], ptr_type, funcname[0]);

if (funcList[i].ulp < 20)
printf("EXPORT CONST %s %s(%s, %s, vopmask) __attribute__((weak, alias(\"%s\")));\n",
vfpname[fptype], funcname[3], vfpname[fptype], ptr_type, funcname[1]);
printf("DMASKED_ALIAS_%sp(%s, %s)\n", vfpname[fptype], funcname[3], funcname[1]);
else
printf("EXPORT CONST %s %s_u%d(%s, %s, vopmask) __attribute__((weak, alias(\"%s\")));\n",
vfpname[fptype], funcname[3],funcList[i].ulp, vfpname[fptype], ptr_type, funcname[1]);
printf("DMASKED_ALIAS_%sp(%s_u%d, %s)\n", vfpname[fptype], funcname[3], funcList[i].ulp, funcname[1]);
}
break;
}
Expand Down
11 changes: 11 additions & 0 deletions src/libm/sleefsimddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3745,6 +3745,17 @@ DFINITE_ALIAS_vd_vd(__sqrt_finite, xsqrt)
DFINITE_ALIAS_vd_vd(__tgamma_u1_finite, xtgamma_u1)

#ifdef HEADER_MASKED

#if ENABLE_ALIAS
#define DMASKED_ALIAS_vdouble(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vdouble ALIASEE(vdouble, vopmask) __attribute__((weak, alias(FUNC)));
#define DMASKED_ALIAS_vdouble2(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vdouble ALIASEE(vdouble, vdouble, vopmask) __attribute__((weak, alias(FUNC)));
#define DMASKED_ALIAS_vdoublep(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vdouble ALIASEE(vdouble, vdouble*, vopmask) __attribute__((weak, alias(FUNC)));
#else
#define DMASKED_ALIAS_vdouble(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vdouble ALIASEE(vdouble x, vopmask m) { return TARGET(x, m); }
#define DMASKED_ALIAS_vdouble2(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vdouble ALIASEE(vdouble x, vdouble y, vopmask m) { return TARGET(x, y, m); }
#define DMASKED_ALIAS_vdoublep(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vdouble ALIASEE(vdouble x, double *y, vopmask m) { return TARGET(x, y, m); }
#endif

#include HEADER_MASKED
#endif
#endif /* #ifdef ENABLE_GNUABI */
11 changes: 11 additions & 0 deletions src/libm/sleefsimdsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3695,6 +3695,17 @@ DFINITE_ALIAS_vf_vf(__sqrtf_finite, xsqrtf)
DFINITE_ALIAS_vf_vf(__tgammaf_u1_finite, xtgammaf_u1)

#ifdef HEADER_MASKED

#if ENABLE_ALIAS
#define DMASKED_ALIAS_vfloat(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vfloat ALIASEE(vfloat, vopmask) __attribute__((weak, alias(FUNC)));
#define DMASKED_ALIAS_vfloat2(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vfloat ALIASEE(vfloat, vfloat, vopmask) __attribute__((weak, alias(FUNC)));
#define DMASKED_ALIAS_vfloatp(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vfloat ALIASEE(vfloat, vfloat*, vopmask) __attribute__((weak, alias(FUNC)));
#else
#define DMASKED_ALIAS_vfloat(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vfloat ALIASEE(vfloat x, vopmask m) { return TARGET(x, m); }
#define DMASKED_ALIAS_vfloat2(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vfloat ALIASEE(vfloat x, vfloat y, vopmask m) { return TARGET(x, y, m); }
#define DMASKED_ALIAS_vfloatp(ALIASEE, TARGET) EXPORT CONST VECTOR_CC vfloat ALIASEE(vfloat x, float *y, vopmask m) { return TARGET(x, y, m); }
#endif

#include HEADER_MASKED
#endif
#endif /* #ifdef ENABLE_GNUABI */
Expand Down

0 comments on commit 98b7d98

Please sign in to comment.