TYPE_MODE() returns wrong mode for POINTER_TYPE nodes
Uros Bizjak
uros@kss-loka.si
Thu Apr 8 11:55:00 GMT 2004
Hello!
In tree.h, comment about TREE_TYPE says:
/* In all nodes that are expressions, this is the data type of the
expression.
In POINTER_TYPE nodes, this is the type that the pointer points to.
In ARRAY_TYPE nodes, this is the type of the elements.
In VECTOR_TYPE nodes, this is the type of the elements. */
#define TREE_TYPE(NODE) ((NODE)->common.type)
however, for pointers to DFmode variables, I always get SImode (which is
mode of pointer, I guess).
The problem arises with sincos() builtin, which is defined as
(builtins.def):
BUILT_IN_SINCOS, "sincos", BT_FN_VOID_DOUBLE_DOUBLEPTR_DOUBLEPTR,
ATTR_MATHFN_FPROUNDING_STORE)
(This is equal to 'void sincos (double, double *, double *)'.)
In builtins.c file, I would like to process this with (changed)
expand_math_builtin_3() function. Argument list [tree arglist =
TREE_OPERAND (exp, 1)] is validated with 'validate_arglist (arglist,
REAL_TYPE, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))' comman and it passes
validation without problems.
Analyzing arguments with this code:
arg = TREE_VALUE (arglist);
targ0_p = TREE_VALUE (arglist = TREE_CHAIN (arglist));
targ1_p = TREE_VALUE (TREE_CHAIN (arglist));
printf("EXP MODE: %i\n", (int) (TYPE_MODE (TREE_TYPE (exp))));
printf("ARG MODE: %i\n", (int) (TYPE_MODE (TREE_TYPE (arg))));
printf("TARG0_P MODE: %i\n", (int) TYPE_MODE (TREE_TYPE (targ0_p)));
printf("TARG1_P 1 MODE: %i\n", (int) TYPE_MODE (TREE_TYPE (targ1_p)));
returns:
EXP MODE: 0
ARG MODE: 16
TARG0_P MODE: 12
TARG1_P MODE: 12
According to autogenerated insn-modes.h, this means:
EXP MODE: VOIDmode
ARG MODE: DFmode
TARG0_P MODE: SImode
TARG1_P MODE: SImode
If I understand above comment for TREE_TYPE correcty, TYPE_MODE of
TARG0_P and TARG1_P should be DFmode, because their tree type is
POINTER_TYPE, and mode of _target_ is DFmode.
Uros.
More information about the Gcc
mailing list