* include/cpplib.h (CPP_N_WIDTH_MD, CPP_N_MD_W, CPP_N_MD_Q):
Add new constants.
* expr.c (interpret_float_suffix): Process 'w', 'W', 'q' and 'Q'
suffixes. Return CPP_N_MD_W for 'w' or 'W' suffixes and CPP_N_MD_Q
for 'q' or 'Q' suffixes.
gcc/ChangeLog:
* targhooks.h (default_mode_for_suffix): New function declaration.
* targhooks.c (default_mode_for_suffix): New default target hook.
* target.h (struct c): New structure in the targetm struct.
(mode_for_suffix): New target hook as part of struct c.
target-def.h (TARGET_C_MODE_FOR_SUFFIX): Define as
default_mode_for_suffix.
(TARGET_C): New define.
* c-lex.c: Include "target.h".
(interpret_float): Use targetm.c.mode_for_suffix to determine
the mode for a given non-standard suffix.
Makefile.in (c-lex.o): Depend on $(TARGET_H).
* config/i386/i386.c (ix86_c_mode_for_suffix): New static function.
(TARGET_C_MODE_FOR_SUFFIX): Define to ix86_c_mode_for_suffix.
* doc/extend.texi (Floating Types): New node. Document __float80 and
__float128 types. Document 'w', 'W', 'q' and 'Q' suffixes.
testsuite/ChangeLog:
* gcc.dg/const-float80.c : New test.
* gcc.dg/const-float128.c : New test.
* gcc.dg/const-float80-ped.c : New test.
* gcc.dg/const-float128-ped.c : New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126244
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-07-03 Uros Bizjak <ubizjak@gmail.com>
+
+ * targhooks.h (default_mode_for_suffix): New function declaration.
+ * targhooks.c (default_mode_for_suffix): New default target hook.
+ * target.h (struct c): New structure in the targetm struct.
+ (mode_for_suffix): New target hook as part of struct c.
+ target-def.h (TARGET_C_MODE_FOR_SUFFIX): Define as
+ default_mode_for_suffix.
+ (TARGET_C): New define.
+ * c-lex.c: Include "target.h".
+ (interpret_float): Use targetm.c.mode_for_suffix to determine
+ the mode for a given non-standard suffix.
+ Makefile.in (c-lex.o): Depend on $(TARGET_H).
+
+ * config/i386/i386.c (ix86_c_mode_for_suffix): New static function.
+ (TARGET_C_MODE_FOR_SUFFIX): Define to ix86_c_mode_for_suffix.
+
+ * doc/extend.texi (Floating Types): New node. Document __float80 and
+ __float128 types. Document 'w', 'W', 'q' and 'Q' suffixes.
+
2007-07-03 Kaz Kojima <kkojima@gcc.gnu.org>
PR target/32506
c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(RTL_H) debug.h $(C_TREE_H) $(C_COMMON_H) $(REAL_H) $(SPLAY_TREE_H) \
$(C_PRAGMA_H) input.h intl.h $(FLAGS_H) toplev.h output.h \
- $(CPPLIB_H) $(TIMEVAR_H) $(TM_P_H)
+ $(CPPLIB_H) $(TARGET_H) $(TIMEVAR_H) $(TM_P_H)
c-ppoutput.o : c-ppoutput.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(C_COMMON_H) $(TREE_H) $(CPPLIB_H) $(srcdir)/../libcpp/internal.h \
$(C_PRAGMA_H)
#include "tm_p.h"
#include "splay-tree.h"
#include "debug.h"
+#include "target.h"
/* We may keep statistics about how long which files took to compile. */
static int header_time, body_time;
else
type = dfloat64_type_node;
else
- if ((flags & CPP_N_WIDTH) == CPP_N_LARGE)
+ if (flags & CPP_N_WIDTH_MD)
+ {
+ char suffix;
+ enum machine_mode mode;
+
+ if ((flags & CPP_N_WIDTH_MD) == CPP_N_MD_W)
+ suffix = 'w';
+ else
+ suffix = 'q';
+
+ mode = targetm.c.mode_for_suffix (suffix);
+ if (mode == VOIDmode)
+ {
+ error ("unsupported non-standard suffix on floating constant");
+ errorcount++;
+
+ return error_mark_node;
+ }
+ else if (pedantic)
+ pedwarn ("non-standard suffix on floating constant");
+
+ type = c_common_type_for_mode (mode, 0);
+ gcc_assert (type);
+ }
+ else if ((flags & CPP_N_WIDTH) == CPP_N_LARGE)
type = long_double_type_node;
else if ((flags & CPP_N_WIDTH) == CPP_N_SMALL
|| flag_single_precision_constant)
else
{
if ((flags & CPP_N_WIDTH) != CPP_N_MEDIUM)
- /* Must be an F or L suffix. */
+ /* Must be an F or L or machine defined suffix. */
copylen--;
if (flags & CPP_N_IMAGINARY)
/* I or J suffix. */
return false;
}
+/* Target hook for c_mode_for_suffix. */
+static enum machine_mode
+ix86_c_mode_for_suffix (char suffix)
+{
+ if (TARGET_64BIT && suffix == 'q')
+ return TFmode;
+ if (TARGET_MMX && suffix == 'w')
+ return XFmode;
+
+ return VOIDmode;
+}
+
/* Worker function for TARGET_MD_ASM_CLOBBERS.
We do this in the new i386 backend to maintain source compatibility
#undef TARGET_VECTOR_MODE_SUPPORTED_P
#define TARGET_VECTOR_MODE_SUPPORTED_P ix86_vector_mode_supported_p
+#undef TARGET_C_MODE_FOR_SUFFIX
+#define TARGET_C_MODE_FOR_SUFFIX ix86_c_mode_for_suffix
+
#ifdef HAVE_AS_TLS
#undef TARGET_ASM_OUTPUT_DWARF_DTPREL
#define TARGET_ASM_OUTPUT_DWARF_DTPREL i386_output_dwarf_dtprel
* Conditionals:: Omitting the middle operand of a @samp{?:} expression.
* Long Long:: Double-word integers---@code{long long int}.
* Complex:: Data types for complex numbers.
+* Floating Types:: Additional Floating Types.
* Decimal Float:: Decimal Floating Types.
* Hex Floats:: Hexadecimal floating-point constants.
* Zero Length:: Zero-length arrays.
variables are named @code{foo$real} and @code{foo$imag}. You can
examine and set these two fictitious variables with your debugger.
+@node Floating Types
+@section Additional Floating Types
+@cindex additional floating types
+@cindex @code{__float80} data type
+@cindex @code{__float128} data type
+@cindex @code{w} floating point suffix
+@cindex @code{q} floating point suffix
+@cindex @code{W} floating point suffix
+@cindex @code{Q} floating point suffix
+
+As an extension, the GNU C compiler supports additional floating
+types, @code{__float80} and @code{__float128} to support 80bit
+(@code{XFmode}) and 128 bit (@code{TFmode}) floating types.
+Support for additional types includes the arithmetic operators:
+add, subtract, multiply, divide; unary arithmetic operators;
+relational operators; equality operators; and conversions to and from
+integer and other floating types. Use a suffix @samp{w} or @samp{W}
+in a literal constant of type @code{__float80} and @samp{q} or @samp{Q}
+for @code{_float128}. You can declare complex types using the
+corresponding internal complex type, @code{XCmode} for @code{__float80}
+type and @code{TCmode} for @code{__float128} type:
+
+@smallexample
+typedef _Complex float __attribute__((mode(TC))) _Complex128;
+typedef _Complex float __attribute__((mode(XC))) _Complex80;
+@end smallexample
+
+Not all targets support additional floating point types. @code{__float80}
+is supported on i386, x86_64 and ia64 targets and target @code{__float128}
+is supported on x86_64 and ia64 targets.
+
@node Decimal Float
@section Decimal Floating Types
@cindex decimal floating types
#define TARGET_SECONDARY_RELOAD default_secondary_reload
#endif
+/* C specific. */
+#ifndef TARGET_C_MODE_FOR_SUFFIX
+#define TARGET_C_MODE_FOR_SUFFIX default_mode_for_suffix
+#endif
+
+#define TARGET_C \
+ { \
+ TARGET_C_MODE_FOR_SUFFIX \
+ }
/* C++ specific. */
#ifndef TARGET_CXX_GUARD_TYPE
TARGET_INVALID_UNARY_OP, \
TARGET_INVALID_BINARY_OP, \
TARGET_SECONDARY_RELOAD, \
+ TARGET_C, \
TARGET_CXX, \
- TARGET_EXTRA_LIVE_ON_ENTRY, \
+ TARGET_EXTRA_LIVE_ON_ENTRY, \
TARGET_UNWIND_TABLES_DEFAULT, \
TARGET_HAVE_NAMED_SECTIONS, \
TARGET_HAVE_SWITCHABLE_BSS_SECTIONS, \
enum machine_mode,
struct secondary_reload_info *);
+ /* Functions specific to the C family of frontends. */
+ struct c {
+ /* Return machine mode for non-standard suffix
+ or VOIDmode if non-standard suffixes are unsupported. */
+ enum machine_mode (*mode_for_suffix) (char);
+ } c;
+
/* Functions specific to the C++ frontend. */
struct cxx {
/* Return the integer type used for guard variables. */
return true;
}
+/* Return machine mode for non-standard suffix
+ or VOIDmode if non-standard suffixes are unsupported. */
+enum machine_mode
+default_mode_for_suffix (char suffix ATTRIBUTE_UNUSED)
+{
+ return VOIDmode;
+}
/* The generic C++ ABI specifies this is a 64-bit value. */
tree
extern tree default_external_stack_protect_fail (void);
extern tree default_hidden_stack_protect_fail (void);
+extern enum machine_mode default_mode_for_suffix (char);
+
extern tree default_cxx_guard_type (void);
extern tree default_cxx_get_cookie_size (tree);
+2007-07-03 Uros Bizjak <ubizjak@gmail.com>
+
+ * gcc.dg/const-float80.c : New test.
+ * gcc.dg/const-float128.c : New test.
+ * gcc.dg/const-float80-ped.c : New test.
+ * gcc.dg/const-float128-ped.c : New test.
+
2007-07-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/c99-math.h: Fix typo.
--- /dev/null
+/* Test 'q' suffix with -pedantic on __float128 type constants. */
+/* { dg-do compile { target { ia64-*-* || { { i?86-*-* x86_64-*-*} && lp64 } } } } */
+/* { dg-options "-pedantic" } */
+
+__float128 a = 123.456789q; /* { dg-warning "non-standard suffix on floating constant" } */
--- /dev/null
+/* Test 'q' and 'Q' suffixes on __float128 type constants. */
+/* { dg-do compile { target { ia64-*-* || { { i?86-*-* x86_64-*-*} && lp64 } } } } */
+/* { dg-options "" } */
+
+__float128 a = 123.456789q;
+__float128 b = 123.456789Q;
--- /dev/null
+/* Test 'w' suffix with -pedantic on __float80 type constants. */
+/* { dg-do compile { target i?86-*-* x86_64-*-* ia64-*-* } } */
+/* { dg-options "-pedantic" } */
+/* { dg-options "-mmmx -pedantic" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+__float80 a = 123.456789w; /* { dg-warning "non-standard suffix on floating constant" } */
--- /dev/null
+/* Test 'w' and 'W' suffixes on __float80 type constants. */
+/* { dg-do compile { target i?86-*-* x86_64-*-* ia64-*-* } } */
+/* { dg-options "" } */
+/* { dg-options "-mmmx" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+__float80 a = 123.456789W;
+__float80 b = 123.456789w;
+2007-07-03 Uros Bizjak <ubizjak@gmail.com>
+
+ * include/cpplib.h (CPP_N_WIDTH_MD, CPP_N_MD_W, CPP_N_MD_Q):
+ Add new constants.
+ * expr.c (interpret_float_suffix): Process 'w', 'W', 'q' and 'Q'
+ suffixes. Return CPP_N_MD_W for 'w' or 'W' suffixes and CPP_N_MD_Q
+ for 'q' or 'Q' suffixes.
+
2007-06-17 Danny Smith <dannysmith@users.sourceforge.net
* files.c (open_file): Correct typo.
static unsigned int
interpret_float_suffix (const uchar *s, size_t len)
{
- size_t f = 0, l = 0, i = 0, d = 0;
+ size_t f, l, w, q, i, d;
+
+ f = l = w = q = i = d = 0;
while (len--)
switch (s[len])
return 0;
l++;
break;
+ case 'w': case 'W':
+ if (d > 0)
+ return 0;
+ w++;
+ break;
+ case 'q': case 'Q':
+ if (d > 0)
+ return 0;
+ q++;
+ break;
case 'i': case 'I':
case 'j': case 'J': i++; break;
case 'd': case 'D': d++; break;
return 0;
}
- if (f + l > 1 || i > 1)
+ if (f + l + w + q > 1 || i > 1)
return 0;
/* Allow dd, df, dl suffixes for decimal float constants. */
return ((i ? CPP_N_IMAGINARY : 0)
| (f ? CPP_N_SMALL :
- l ? CPP_N_LARGE : CPP_N_MEDIUM)
+ l ? CPP_N_LARGE :
+ w ? CPP_N_MD_W :
+ q ? CPP_N_MD_Q : CPP_N_MEDIUM)
| (d ? CPP_N_DFLOAT : 0));
}
#define CPP_N_MEDIUM 0x0020 /* long, double. */
#define CPP_N_LARGE 0x0040 /* long long, long double. */
+#define CPP_N_WIDTH_MD 0xF0000 /* machine defined. */
+#define CPP_N_MD_W 0x10000
+#define CPP_N_MD_Q 0x20000
+
#define CPP_N_RADIX 0x0F00
#define CPP_N_DECIMAL 0x0100
#define CPP_N_HEX 0x0200