Virgin import of the GCC 2.95.1 compilers

This commit is contained in:
obrien 1999-10-16 07:10:09 +00:00
parent cae8fa8120
commit 874263d914
7 changed files with 228 additions and 123 deletions

View File

@ -278,7 +278,7 @@ __inline static const double pow (const double x, const double y)
{
int i = (int) y;
if (i & 1 == 0) /* even */
if ((i & 1) == 0) /* even */
return exp (y * log (x));
else
return - exp (y * log (x));

View File

@ -59,6 +59,9 @@
#ifdef __v850__
#include "va-v850.h"
#else
#if defined (_TMS320C4x) || defined (_TMS320C3x)
#include <va-c4x.h>
#else
/* Define __gnuc_va_list. */
@ -81,6 +84,9 @@ typedef void *__gnuc_va_list;
#if defined(sysV68)
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short))
#elif defined(_AIX)
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (long) - 1) / sizeof (long)) * sizeof (long))
#else
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
@ -115,6 +121,7 @@ void va_end (__gnuc_va_list); /* Defined in libgcc.a */
#endif /* _STDARG_H */
#endif /* not TMS320C3x or TMS320C4x */
#endif /* not v850 */
#endif /* not mn10200 */
#endif /* not mn10300 */

View File

@ -0,0 +1,34 @@
/* GNU C varargs support for the TMS320C[34]x */
/* C[34]x arguments grow in weird ways (downwards) that the standard
varargs stuff can't handle. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
typedef void *__gnuc_va_list;
#endif /* not __GNUC_VA_LIST */
/* If this is for internal libc use, don't define anything but
__gnuc_va_list. */
#if defined (_STDARG_H) || defined (_VARARGS_H)
#ifdef _STDARG_H /* stdarg.h support */
#define va_start(AP,LASTARG) AP=(__gnuc_va_list) __builtin_next_arg (LASTARG)
#else /* varargs.h support */
#define __va_ellipsis ...
#define va_alist __builtin_va_alist
#define va_dcl int __builtin_va_alist; __va_ellipsis
#define va_start(AP) AP=(__gnuc_va_list) ((int *)&__builtin_va_alist + 1)
#endif /* _STDARG_H */
#define va_end(AP) ((void) 0)
#define va_arg(AP,TYPE) (AP = (__gnuc_va_list) ((char *) (AP) - sizeof(TYPE)), \
*((TYPE *) ((char *) (AP))))
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */

View File

@ -15,7 +15,7 @@ typedef struct
#if defined (_STDARG_H) || defined (_VARARGS_H)
#define va_list __gnuc_va_list
typedef __gnuc_va_list va_list;
#define __va_list __gnuc_va_list /* acc compatibility */
#define _VA_LIST

View File

@ -17,10 +17,10 @@
/* Note that the names in this structure are in the user's namespace, but
that the V.4 abi explicitly states that these names should be used. */
typedef struct __va_list_tag {
char gpr; /* index into the array of 8 GPRs stored in the
unsigned char gpr; /* index into the array of 8 GPRs stored in the
register save area gpr=0 corresponds to r3,
gpr=1 to r4, etc. */
char fpr; /* index into the array of 8 FPRs stored in the
unsigned char fpr; /* index into the array of 8 FPRs stored in the
register save area fpr=0 corresponds to f1,
fpr=1 to f2, etc. */
char *overflow_arg_area; /* location on stack that holds the next
@ -51,42 +51,21 @@ typedef struct {
/* Macros to access the register save area */
/* We cast to void * and then to TYPE * because this avoids
a warning about increasing the alignment requirement. */
#define __VA_FP_REGSAVE(AP,TYPE) \
#define __VA_FP_REGSAVE(AP,OFS,TYPE) \
((TYPE *) (void *) (&(((__va_regsave_t *) \
(AP)->reg_save_area)->__fp_save[(int)(AP)->fpr])))
(AP)->reg_save_area)->__fp_save[OFS])))
#define __VA_GP_REGSAVE(AP,TYPE) \
#define __VA_GP_REGSAVE(AP,OFS,TYPE) \
((TYPE *) (void *) (&(((__va_regsave_t *) \
(AP)->reg_save_area)->__gp_save[(int)(AP)->gpr])))
(AP)->reg_save_area)->__gp_save[OFS])))
/* Common code for va_start for both varargs and stdarg. This depends
on the format of rs6000_args in rs6000.h. The fields used are:
/* Common code for va_start for both varargs and stdarg. We allow all
the work to be done by __builtin_saveregs. It returns a pointer to
a va_list that was constructed on the stack; we must simply copy it
to the user's variable. */
#0 WORDS # words used for GP regs/stack values
#1 FREGNO next available FP register
#2 NARGS_PROTOTYPE # args left in the current prototype
#3 ORIG_NARGS original value of NARGS_PROTOTYPE
#4 VARARGS_OFFSET offset from frame pointer of varargs area */
#define __va_words __builtin_args_info (0)
#define __va_fregno __builtin_args_info (1)
#define __va_nargs __builtin_args_info (2)
#define __va_orig_nargs __builtin_args_info (3)
#define __va_varargs_offset __builtin_args_info (4)
#define __va_start_common(AP, FAKE) \
__extension__ ({ \
register int __words = __va_words - FAKE; \
\
(AP)->gpr = (__words < 8) ? __words : 8; \
(AP)->fpr = __va_fregno - 33; \
(AP)->reg_save_area = (((char *) __builtin_frame_address (0)) \
+ __va_varargs_offset); \
__va_overflow(AP) = ((char *)__builtin_saveregs () \
+ (((__words >= 8) ? __words - 8 : 0) \
* sizeof (long))); \
(void)0; \
})
#define __va_start_common(AP, FAKE) \
__builtin_memcpy ((AP), __builtin_saveregs (), sizeof(__gnuc_va_list))
#ifdef _STDARG_H /* stdarg.h support */
@ -109,60 +88,106 @@ __extension__ ({ \
#define __va_float_p(TYPE) (__builtin_classify_type(*(TYPE *)0) == 8)
#endif
#define __va_longlong_p(TYPE) \
((__builtin_classify_type(*(TYPE *)0) == 1) && (sizeof(TYPE) == 8))
#define __va_aggregate_p(TYPE) (__builtin_classify_type(*(TYPE *)0) >= 12)
#define __va_size(TYPE) ((sizeof(TYPE) + sizeof (long) - 1) / sizeof (long))
#define va_arg(AP,TYPE) \
__extension__ (*({ \
register TYPE *__ptr; \
\
if (__va_float_p (TYPE) && (AP)->fpr < 8) \
{ \
__ptr = __VA_FP_REGSAVE (AP, TYPE); \
(AP)->fpr++; \
} \
\
else if (__va_aggregate_p (TYPE) && (AP)->gpr < 8) \
{ \
__ptr = * __VA_GP_REGSAVE (AP, TYPE *); \
(AP)->gpr++; \
} \
\
else if (!__va_float_p (TYPE) && !__va_aggregate_p (TYPE) \
&& (AP)->gpr + __va_size(TYPE) <= 8 \
&& (!__va_longlong_p(TYPE) \
|| (AP)->gpr + __va_size(TYPE) <= 8)) \
{ \
if (__va_longlong_p(TYPE) && ((AP)->gpr & 1) != 0) \
(AP)->gpr++; \
\
__ptr = __VA_GP_REGSAVE (AP, TYPE); \
(AP)->gpr += __va_size (TYPE); \
} \
\
else if (!__va_float_p (TYPE) && !__va_aggregate_p (TYPE) \
&& (AP)->gpr < 8) \
{ \
(AP)->gpr = 8; \
__ptr = (TYPE *) (void *) (__va_overflow(AP)); \
__va_overflow(AP) += __va_size (TYPE) * sizeof (long); \
} \
\
else if (__va_aggregate_p (TYPE)) \
{ \
__ptr = * (TYPE **) (void *) (__va_overflow(AP)); \
__va_overflow(AP) += sizeof (TYPE *); \
} \
else \
{ \
__ptr = (TYPE *) (void *) (__va_overflow(AP)); \
__va_overflow(AP) += __va_size (TYPE) * sizeof (long); \
} \
\
__ptr; \
/* This symbol isn't defined. It is used to flag type promotion violations
at link time. We can only do this when optimizing. Use __builtin_trap
instead of abort so that we don't require a prototype for abort.
__builtin_trap stuff is not available on the gcc-2.95 branch, so we just
avoid calling it for now. */
#ifdef __OPTIMIZE__
extern void __va_arg_type_violation(void) __attribute__((__noreturn__));
#else
#define __va_arg_type_violation()
#endif
#define va_arg(AP,TYPE) \
__extension__ (*({ \
register TYPE *__ptr; \
\
if (__va_float_p (TYPE) && sizeof (TYPE) < 16) \
{ \
unsigned char __fpr = (AP)->fpr; \
if (__fpr < 8) \
{ \
__ptr = __VA_FP_REGSAVE (AP, __fpr, TYPE); \
(AP)->fpr = __fpr + 1; \
} \
else if (sizeof (TYPE) == 8) \
{ \
unsigned long __addr = (unsigned long) (__va_overflow (AP)); \
__ptr = (TYPE *)((__addr + 7) & -8); \
__va_overflow (AP) = (char *)(__ptr + 1); \
} \
else \
{ \
/* float is promoted to double. */ \
__va_arg_type_violation (); \
} \
} \
\
/* Aggregates and long doubles are passed by reference. */ \
else if (__va_aggregate_p (TYPE) || __va_float_p (TYPE)) \
{ \
unsigned char __gpr = (AP)->gpr; \
if (__gpr < 8) \
{ \
__ptr = * __VA_GP_REGSAVE (AP, __gpr, TYPE *); \
(AP)->gpr = __gpr + 1; \
} \
else \
{ \
TYPE **__pptr = (TYPE **) (__va_overflow (AP)); \
__ptr = * __pptr; \
__va_overflow (AP) = (char *) (__pptr + 1); \
} \
} \
\
/* Only integrals remaining. */ \
else \
{ \
/* longlong is aligned. */ \
if (sizeof (TYPE) == 8) \
{ \
unsigned char __gpr = (AP)->gpr; \
if (__gpr < 7) \
{ \
__gpr += __gpr & 1; \
__ptr = __VA_GP_REGSAVE (AP, __gpr, TYPE); \
(AP)->gpr = __gpr + 2; \
} \
else \
{ \
unsigned long __addr = (unsigned long) (__va_overflow (AP)); \
__ptr = (TYPE *)((__addr + 7) & -8); \
(AP)->gpr = 8; \
__va_overflow (AP) = (char *)(__ptr + 1); \
} \
} \
else if (sizeof (TYPE) == 4) \
{ \
unsigned char __gpr = (AP)->gpr; \
if (__gpr < 8) \
{ \
__ptr = __VA_GP_REGSAVE (AP, __gpr, TYPE); \
(AP)->gpr = __gpr + 1; \
} \
else \
{ \
__ptr = (TYPE *) __va_overflow (AP); \
__va_overflow (AP) = (char *)(__ptr + 1); \
} \
} \
else \
{ \
/* Everything else was promoted to int. */ \
__va_arg_type_violation (); \
} \
} \
__ptr; \
}))
#define va_end(AP) ((void)0)

View File

@ -1,15 +1,18 @@
/* This is just like the default gvarargs.h
except for differences described below. */
/* The ! __SH3E_VARG case is similar to the default gvarargs.h . */
#if (defined (__SH3E__) || defined (__SH4_SINGLE__) || defined (__SH4__) || defined (__SH4_SINGLE_ONLY__)) && ! defined (__HITACHI__)
#define __SH3E_VARG
#endif
/* Define __gnuc_va_list. */
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
#ifdef __SH3E__
#ifdef __SH3E_VARG
typedef long __va_greg;
typedef double __va_freg;
typedef float __va_freg;
typedef struct {
__va_greg * __va_next_o; /* next available register */
@ -33,24 +36,24 @@ typedef void *__gnuc_va_list;
#ifdef _STDARG_H
#ifdef __SH3E__
#ifdef __SH3E_VARG
#define va_start(AP, LASTARG) \
__extension__ \
({ \
AP.__va_next_fp = (__va_freg *) __builtin_saveregs (); \
AP.__va_next_fp_limit = (AP.__va_next_fp + \
(AP).__va_next_fp = (__va_freg *) __builtin_saveregs (); \
(AP).__va_next_fp_limit = ((AP).__va_next_fp + \
(__builtin_args_info (1) < 8 ? 8 - __builtin_args_info (1) : 0)); \
AP.__va_next_o = (__va_greg *) AP.__va_next_fp_limit; \
AP.__va_next_o_limit = (AP.__va_next_o + \
(AP).__va_next_o = (__va_greg *) (AP).__va_next_fp_limit; \
(AP).__va_next_o_limit = ((AP).__va_next_o + \
(__builtin_args_info (0) < 4 ? 4 - __builtin_args_info (0) : 0)); \
AP.__va_next_stack = (__va_greg *) __builtin_next_arg (LASTARG); \
(AP).__va_next_stack = (__va_greg *) __builtin_next_arg (LASTARG); \
})
#else /* ! SH3E */
#define va_start(AP, LASTARG) \
(AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
((AP) = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
#endif /* ! SH3E */
@ -59,24 +62,26 @@ __extension__ \
#define va_alist __builtin_va_alist
#define va_dcl int __builtin_va_alist;...
#ifdef __SH3E__
#ifdef __SH3E_VARG
#define va_start(AP) \
__extension__ \
({ \
AP.__va_next_fp = (__va_freg *) __builtin_saveregs (); \
AP.__va_next_fp_limit = (AP.__va_next_fp + \
(AP).__va_next_fp = (__va_freg *) __builtin_saveregs (); \
(AP).__va_next_fp_limit = ((AP).__va_next_fp + \
(__builtin_args_info (1) < 8 ? 8 - __builtin_args_info (1) : 0)); \
AP.__va_next_o = (__va_greg *) AP.__va_next_fp_limit; \
AP.__va_next_o_limit = (AP.__va_next_o + \
(AP).__va_next_o = (__va_greg *) (AP).__va_next_fp_limit; \
(AP).__va_next_o_limit = ((AP).__va_next_o + \
(__builtin_args_info (0) < 4 ? 4 - __builtin_args_info (0) : 0)); \
AP.__va_next_stack = (__va_greg *) __builtin_next_arg (__builtin_va_alist) \
- (__builtin_args_info (0) >= 4 || __builtin_args_info (1) >= 8 ? 1 : 0); \
(AP).__va_next_stack \
= ((__va_greg *) __builtin_next_arg (__builtin_va_alist) \
- (__builtin_args_info (0) >= 4 || __builtin_args_info (1) >= 8 \
? 1 : 0)); \
})
#else /* ! SH3E */
#define va_start(AP) AP=(char *) &__builtin_va_alist
#define va_start(AP) ((AP) = (char *) &__builtin_va_alist)
#endif /* ! SH3E */
@ -136,53 +141,78 @@ enum __va_type_classes {
We want the MEM_IN_STRUCT_P bit set in the emitted RTL, therefore we
use unions even when it would otherwise be unnecessary. */
/* gcc has an extension that allows to use a casted lvalue as an lvalue,
But it doesn't work in C++ with -pedantic - even in the presence of
__extension__ . We work around this problem by using a reference type. */
#ifdef __cplusplus
#define __VA_REF &
#else
#define __VA_REF
#endif
#define __va_arg_sh1(AP, TYPE) __extension__ \
__extension__ \
({(sizeof (TYPE) == 1 \
? ({union {TYPE t; char c;} __t; \
__asm("" \
: "=r" (__t.c) \
: "0" ((((union { int i, j; } *) (AP))++)->i)); \
: "=r" (__t.c) \
: "0" ((((union { int i, j; } *__VA_REF) (AP))++)->i)); \
__t.t;}) \
: sizeof (TYPE) == 2 \
? ({union {TYPE t; short s;} __t; \
__asm("" \
: "=r" (__t.s) \
: "0" ((((union { int i, j; } *) (AP))++)->i)); \
: "=r" (__t.s) \
: "0" ((((union { int i, j; } *__VA_REF) (AP))++)->i)); \
__t.t;}) \
: sizeof (TYPE) >= 4 || __LITTLE_ENDIAN_P \
? (((union { TYPE t; int i;} *) (AP))++)->t \
: ((union {TYPE t;TYPE u;}*) ((char *)++(int *)(AP) - sizeof (TYPE)))->t);})
? (((union { TYPE t; int i;} *__VA_REF) (AP))++)->t \
: ((union {TYPE t;TYPE u;}*) ((char *)++(int *__VA_REF)(AP) - sizeof (TYPE)))->t);})
#ifdef __SH3E__
#ifdef __SH3E_VARG
#define __PASS_AS_FLOAT(TYPE_CLASS,SIZE) \
(TYPE_CLASS == __real_type_class && SIZE == 4)
#define __TARGET_SH4_P 0
#if defined(__SH4__) || defined(__SH4_SINGLE__)
#undef __PASS_AS_FLOAT
#define __PASS_AS_FLOAT(TYPE_CLASS,SIZE) \
(TYPE_CLASS == __real_type_class && SIZE <= 8 \
|| TYPE_CLASS == __complex_type_class && SIZE <= 16)
#undef __TARGET_SH4_P
#define __TARGET_SH4_P 1
#endif
#define va_arg(pvar,TYPE) \
__extension__ \
({int __type = __builtin_classify_type (* (TYPE *) 0); \
void * __result_p; \
if (__PASS_AS_FLOAT (__type, sizeof(TYPE))) \
{ \
if (pvar.__va_next_fp < pvar.__va_next_fp_limit) \
if ((pvar).__va_next_fp < (pvar).__va_next_fp_limit) \
{ \
__result_p = &pvar.__va_next_fp; \
if (((__type == __real_type_class && sizeof (TYPE) > 4)\
|| sizeof (TYPE) > 8) \
&& (((int) (pvar).__va_next_fp ^ (int) (pvar).__va_next_fp_limit)\
& 4)) \
(pvar).__va_next_fp++; \
__result_p = &(pvar).__va_next_fp; \
} \
else \
__result_p = &pvar.__va_next_stack; \
__result_p = &(pvar).__va_next_stack; \
} \
else \
{ \
if (pvar.__va_next_o + ((sizeof (TYPE) + 3) / 4) \
<= pvar.__va_next_o_limit) \
__result_p = &pvar.__va_next_o; \
if ((pvar).__va_next_o + ((sizeof (TYPE) + 3) / 4) \
<= (pvar).__va_next_o_limit) \
__result_p = &(pvar).__va_next_o; \
else \
{ \
if (sizeof (TYPE) > 4) \
pvar.__va_next_o = pvar.__va_next_o_limit; \
if (! __TARGET_SH4_P) \
(pvar).__va_next_o = (pvar).__va_next_o_limit; \
\
__result_p = &pvar.__va_next_stack; \
__result_p = &(pvar).__va_next_stack; \
} \
} \
__va_arg_sh1(*(void **)__result_p, TYPE);})
@ -194,6 +224,6 @@ __extension__ \
#endif /* SH3E */
/* Copy __gnuc_va_list into another variable of this type. */
#define __va_copy(dest, src) (dest) = (src)
#define __va_copy(dest, src) ((dest) = (src))
#endif /* defined (_STDARG_H) || defined (_VARARGS_H) */

View File

@ -57,6 +57,9 @@
#ifdef __v850__
#include "va-v850.h"
#else
#if defined (_TMS320C4x) || defined (_TMS320C3x)
#include <va-c4x.h>
#else
#ifdef __NeXT__
@ -90,7 +93,9 @@
#define va_alist __builtin_va_alist
/* The ... causes current_function_varargs to be set in cc1. */
#define va_dcl int __builtin_va_alist; __va_ellipsis
/* ??? We don't process attributes correctly in K&R argument context. */
typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
#define va_dcl __builtin_va_alist_t __builtin_va_alist; __va_ellipsis
/* Define __gnuc_va_list, just as in gstdarg.h. */
@ -110,6 +115,9 @@ typedef void *__gnuc_va_list;
#if defined(sysV68)
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short))
#elif defined(_AIX)
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (long) - 1) / sizeof (long)) * sizeof (long))
#else
#define __va_rounded_size(TYPE) \
(((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
@ -132,6 +140,7 @@ typedef void *__gnuc_va_list;
/* Copy __gnuc_va_list into another variable of this type. */
#define __va_copy(dest, src) (dest) = (src)
#endif /* not TMS320C3x or TMS320C4x */
#endif /* not v850 */
#endif /* not mn10200 */
#endif /* not mn10300 */