Add FOLD rule for FLOAT->NUM->FLOAT conversions.

This commit is contained in:
Mike Pall 2011-04-05 16:31:48 +02:00
parent 48438b9e13
commit 3acd4892e9
2 changed files with 14 additions and 3 deletions

View File

@ -111,13 +111,15 @@ static uint32_t nexttoken(char **pp, int allowlit, int allowany)
if (!strcmp(ircall_names[i], p+7))
return i;
} else if (allowlit && !strncmp(p, "IRCONV_", 7)) {
for (i = 0; irt_names[i]; i++)
if (!strncmp(irt_names[i], p+7, 3) && p[10] == '_') {
for (i = 0; irt_names[i]; i++) {
const char *r = strchr(p+7, '_');
if (r && !strncmp(irt_names[i], p+7, r-(p+7))) {
uint32_t j;
for (j = 0; irt_names[j]; j++)
if (!strncmp(irt_names[j], p+11, 3))
if (!strcmp(irt_names[j], r+1))
return (i << 5) + j;
}
}
} else if (allowlit && *p >= '0' && *p <= '9') {
for (i = 0; *p >= '0' && *p <= '9'; p++)
i = i*10 + (*p - '0');

View File

@ -914,6 +914,15 @@ LJFOLDF(simplify_conv_int_i64)
return NEXTFOLD;
}
LJFOLD(CONV CONV IRCONV_NUM_FLOAT) /* _NUM */
LJFOLDF(simplify_conv_flt_num)
{
PHIBARRIER(fleft);
if ((fleft->op2 & IRCONV_SRCMASK) == IRT_NUM)
return fleft->op1;
return NEXTFOLD;
}
/* Shortcut TOBIT + IRT_NUM <- IRT_INT/IRT_U32 conversion. */
LJFOLD(TOBIT CONV KNUM)
LJFOLDF(simplify_tobit_conv)