Commit b0468b84 by Richard Kenner

(sparc_type_code): Revise so it supports non-C types.

From-SVN: r6919
parent ffa969a1
/* Subroutines for insn-output.c for Sun SPARC. /* Subroutines for insn-output.c for Sun SPARC.
Copyright (C) 1987, 1988, 1989, 1992, 1993 Free Software Foundation, Inc. Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com) Contributed by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC. This file is part of GNU CC.
...@@ -2843,6 +2843,10 @@ output_double_int (file, value) ...@@ -2843,6 +2843,10 @@ output_double_int (file, value)
abort (); abort ();
} }
/* Return the value of a code used in the .proc pseudo-op that says
what kind of result this function returns. For non-C types, we pick
the closest C type. */
#ifndef CHAR_TYPE_SIZE #ifndef CHAR_TYPE_SIZE
#define CHAR_TYPE_SIZE BITS_PER_UNIT #define CHAR_TYPE_SIZE BITS_PER_UNIT
#endif #endif
...@@ -2914,6 +2918,7 @@ sparc_type_code (type) ...@@ -2914,6 +2918,7 @@ sparc_type_code (type)
return (qualifiers | 8); return (qualifiers | 8);
case UNION_TYPE: case UNION_TYPE:
case QUAL_UNION_TYPE:
return (qualifiers | 9); return (qualifiers | 9);
case ENUMERAL_TYPE: case ENUMERAL_TYPE:
...@@ -2932,78 +2937,37 @@ sparc_type_code (type) ...@@ -2932,78 +2937,37 @@ sparc_type_code (type)
} }
/* Carefully distinguish all the standard types of C, /* Carefully distinguish all the standard types of C,
without messing up if the language is not C. without messing up if the language is not C. We do this by
Note that we check only for the names that contain spaces; testing TYPE_PRECISION and TREE_UNSIGNED. The old code used to
other names might occur by coincidence in other languages. */ look at both the names and the above fields, but that's redundant.
if (TYPE_NAME (type) != 0 Any type whose size is between two C types will be considered
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL to be the wider of the two types. Also, we do not have a
&& DECL_NAME (TYPE_NAME (type)) != 0 special code to use for "long long", so anything wider than
&& TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE) long is treated the same. Note that we can't distinguish
{ between "int" and "long" in this code if they are the same
char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); size, but that's fine, since neither can the assembler. */
if (!strcmp (name, "unsigned char")) if (TYPE_PRECISION (type) <= CHAR_TYPE_SIZE)
return (qualifiers | 12); return (qualifiers | (TREE_UNSIGNED (type) ? 12 : 2));
if (!strcmp (name, "signed char"))
return (qualifiers | 2);
if (!strcmp (name, "unsigned int"))
return (qualifiers | 14);
if (!strcmp (name, "short int"))
return (qualifiers | 3);
if (!strcmp (name, "short unsigned int"))
return (qualifiers | 13);
if (!strcmp (name, "long int"))
return (qualifiers | 5);
if (!strcmp (name, "long unsigned int"))
return (qualifiers | 15);
if (!strcmp (name, "long long int"))
return (qualifiers | 5); /* Who knows? */
if (!strcmp (name, "long long unsigned int"))
return (qualifiers | 15); /* Who knows? */
}
/* Most integer types will be sorted out above, however, for the
sake of special `array index' integer types, the following code
is also provided. */
if (TYPE_PRECISION (type) == INT_TYPE_SIZE)
return (qualifiers | (TREE_UNSIGNED (type) ? 14 : 4));
if (TYPE_PRECISION (type) == LONG_TYPE_SIZE)
return (qualifiers | (TREE_UNSIGNED (type) ? 15 : 5));
if (TYPE_PRECISION (type) == LONG_LONG_TYPE_SIZE)
return (qualifiers | (TREE_UNSIGNED (type) ? 15 : 5));
if (TYPE_PRECISION (type) == SHORT_TYPE_SIZE) else if (TYPE_PRECISION (type) <= SHORT_TYPE_SIZE)
return (qualifiers | (TREE_UNSIGNED (type) ? 13 : 3)); return (qualifiers | (TREE_UNSIGNED (type) ? 13 : 3));
if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE) else if (TYPE_PRECISION (type) <= INT_TYPE_SIZE)
return (qualifiers | (TREE_UNSIGNED (type) ? 12 : 2)); return (qualifiers | (TREE_UNSIGNED (type) ? 14 : 4));
abort (); else
return (qualifiers | (TREE_UNSIGNED (type) ? 15 : 5));
case REAL_TYPE: case REAL_TYPE:
/* Carefully distinguish all the standard types of C, /* Carefully distinguish all the standard types of C,
without messing up if the language is not C. */ without messing up if the language is not C. */
if (TYPE_NAME (type) != 0
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& DECL_NAME (TYPE_NAME (type)) != 0
&& TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
{
char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
if (!strcmp (name, "long double"))
return (qualifiers | 7); /* Who knows? */
}
if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
return (qualifiers | 7);
if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE) if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
return (qualifiers | 6); return (qualifiers | 6);
if (TYPE_PRECISION (type) == LONG_DOUBLE_TYPE_SIZE)
return (qualifiers | 7); /* Who knows? */ else
abort (); return (qualifiers | 7);
case COMPLEX_TYPE: /* GNU Fortran COMPLEX type. */ case COMPLEX_TYPE: /* GNU Fortran COMPLEX type. */
/* ??? We need to distinguish between double and float complex types, /* ??? We need to distinguish between double and float complex types,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment