aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Dos Reis <gdr@integrable-solutions.net>2002-08-27 09:38:05 +0000
committerGabriel Dos Reis <gdr@gcc.gnu.org>2002-08-27 09:38:05 +0000
commit35885eab33068a4497dd809704be29ec241baf41 (patch)
treeb643a71ed2bf8c628bac297990e0dd2b52c5eadc
parentb0c6c224e23387e0e5a21e75098bd68f06c32c2b (diff)
downloadgcc-35885eab33068a4497dd809704be29ec241baf41.zip
gcc-35885eab33068a4497dd809704be29ec241baf41.tar.gz
gcc-35885eab33068a4497dd809704be29ec241baf41.tar.bz2
c-common.c (cpp_define_data_format): New function.
* c-common.c (cpp_define_data_format): New function. (cb_register_builtins): Call it. * doc/cpp.texi (Common Predefined Macros): Document __TARGET_BITS_ORDER__, __TARGET_BYTES_ORDER__, __TARGET_INT_WORDS_ORDER__, __TARGET_FLOAT_WORDS_ORDER__, __TARGET_FLOAT_FORMAT__, __TARGET_USES_VAX_F_FLOAT__, __TARGET_USES_VAX_D_FLOAT__, __TARGET_USES_VAX_G_FLOAT__, __TARGET_USES_VAX_H_FLOAT__. From-SVN: r56597
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/c-common.c93
-rw-r--r--gcc/doc/cpp.texi42
3 files changed, 147 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4783fea..4add4da 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2002-08-27 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ * c-common.c (cpp_define_data_format): New function.
+ (cb_register_builtins): Call it.
+
+ * doc/cpp.texi (Common Predefined Macros): Document
+ __TARGET_BITS_ORDER__, __TARGET_BYTES_ORDER__,
+ __TARGET_INT_WORDS_ORDER__, __TARGET_FLOAT_WORDS_ORDER__,
+ __TARGET_FLOAT_FORMAT__, __TARGET_USES_VAX_F_FLOAT__,
+ __TARGET_USES_VAX_D_FLOAT__, __TARGET_USES_VAX_G_FLOAT__,
+ __TARGET_USES_VAX_H_FLOAT__.
+
2002-08-26 Ziemowit Laski <zlaski@apple.com>
* objc/objc-act.c (get_super_receiver): If inside a class method
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 74224af..9e9e409 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -749,6 +749,7 @@ void builtin_define_std PARAMS ((const char *));
static void builtin_define_with_value PARAMS ((const char *, const char *,
int));
static void builtin_define_type_max PARAMS ((const char *, tree, int));
+static void cpp_define_data_format PARAMS ((cpp_reader *));
/* Table of machine-independent attributes common to all C-like languages. */
const struct attribute_spec c_common_attribute_table[] =
@@ -4661,6 +4662,96 @@ boolean_increment (code, arg)
return val;
}
+/* Define macros necessary to describe fundamental data type formats. */
+static void
+cpp_define_data_format (pfile)
+ cpp_reader *pfile;
+{
+ const char *format;
+ /* Define endianness enumeration values. */
+ cpp_define (pfile, "__GCC_LITTLE_ENDIAN__=0");
+ cpp_define (pfile, "__GCC_BIG_ENDIAN__=1");
+
+ /* Define supported floating-point format enumeration values. */
+ cpp_define (pfile, "__UNKNOWN_FORMAT__=0");
+ cpp_define (pfile, "__IEEE_FORMAT__=1");
+ cpp_define (pfile, "__IBM_FORMAT__=2");
+ cpp_define (pfile, "__C4X_FORMAT__=3");
+ cpp_define (pfile, "__VAX_FORMAT__=4");
+
+ /* Define target endianness:
+ - bit order
+ - byte order
+ - word order in an integer that spans a multi-word
+ - word order in a floating-poing that spans a multi-word */
+ if (BITS_BIG_ENDIAN)
+ cpp_define (pfile, "__TARGET_BITS_ORDER__=__GCC_BIG_ENDIAN__");
+ else
+ cpp_define (pfile, "__TARGET_BITS_ORDER__=__GCC_BIG_ENDIAN__");
+ if (BYTES_BIG_ENDIAN)
+ cpp_define (pfile, "__TARGET_BYTES_ORDER__=__GCC_BIG_ENDIAN__");
+ else
+ cpp_define (pfile, "__TARGET_BYTES_ORDER__=__GCC_LITTLE_ENDIAN__");
+ /* Define words order in a multi-word integer. */
+ if (WORDS_BIG_ENDIAN)
+ cpp_define (pfile, "__TARGET_INT_WORDS_ORDER__=__GCC_BIG_ENDIAN__");
+ else
+ cpp_define (pfile, "__TARGET_INT_WORDS_ORDER__=__GCC_LITTLE_ENDIAN__");
+ /* Define words order in a multi-word floating point. */
+ if (FLOAT_WORDS_BIG_ENDIAN)
+ cpp_define (pfile, "__TARGET_FLOAT_WORDS_ORDER__=__GCC_BIG_ENDIAN__");
+ else
+ cpp_define (pfile, "__TARGET_FLOAT_WORDS_ORDER__=__GCC_LITTLE_ENDIAN__");
+
+ switch (TARGET_FLOAT_FORMAT)
+ {
+ case UNKNOWN_FLOAT_FORMAT:
+ format = "__UNKNOWN_FORMAT__";
+ break;
+
+ case IEEE_FLOAT_FORMAT:
+ format = "__IEEE_FORMAT__";
+ break;
+
+ case VAX_FLOAT_FORMAT:
+ format = "__VAX_FORMAT__";
+ cpp_define (pfile, "__TARGET_USES_VAX_F_FLOAT__=1");
+#ifdef TARGET_G_FLOAT
+ if (TARGET_G_FLOAT)
+ {
+ cpp_define (pfile, "__TARGET_USES_VAX_D_FLOAT__=0");
+ cpp_define (pfile, "__TARGET_USES_VAX_G_FLOAT__=1");
+ }
+ else
+ {
+ cpp_define (pfile, "__TARGET_USES_VAX_D_FLOAT__=1");
+ cpp_define (pfile, "__TARGET_USES_VAX_G_FLOAT__=0");
+ }
+#endif
+ cpp_define (pfile, "__TARGET_USES_VAX_H_FLOAT__=1");
+ break;
+
+ case IBM_FLOAT_FORMAT:
+ format = "__IBM_FORMAT__";
+ break;
+
+ case C4X_FLOAT_FORMAT:
+ format = "__C4X_FORMAT__";
+ break;
+
+ default:
+ abort();
+ }
+ if (TARGET_FLOAT_FORMAT != VAX_FLOAT_FORMAT)
+ {
+ cpp_define (pfile, "__TARGET_USES_VAX_F_FLOAT__=0");
+ cpp_define (pfile, "__TARGET_USES_VAX_D_FLOAT__=0");
+ cpp_define (pfile, "__TARGET_USES_VAX_G_FLOAT__=0");
+ cpp_define (pfile, "__TARGET_USES_VAX_H_FLOAT__=0");
+ }
+ builtin_define_with_value ("__GCC_FLOAT_FORMAT__", format, 0);
+}
+
/* Hook that registers front end and target-specific built-ins. */
void
cb_register_builtins (pfile)
@@ -4745,6 +4836,8 @@ cb_register_builtins (pfile)
if (!flag_signed_char)
cpp_define (pfile, "__CHAR_UNSIGNED__");
+ cpp_define_data_format (pfile);
+
/* Make the choice of ObjC runtime visible to source code. */
if (flag_objc && flag_next_runtime)
cpp_define (pfile, "__NEXT_RUNTIME__");
diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index 71f0d87..66edaab 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -2012,6 +2012,48 @@ This macro is defined, with value 1, when the NeXT runtime
(as in @option{-fnext-runtime}) is in use for Objective-C.
@end table
+@item __TARGET_BITS_ORDER__
+This macro describes the target's bits order in a byte. Its value is
+@code{__GCC_LITTLE_ENDIAN__} or @code{__GCC_BIG_ENDIAN__}.
+
+@item __TARGET_BYTES_ORDER__
+This macro is defined with value @code{__GCC_LITTLE_ENDIAN__} or
+@code{__GCC_BIG_ENDIAN__} if the target's bytes order within a word
+is little-endian or big-endian, respectively.
+
+@item __TARGET_INT_WORDS_ORDER__
+This macro is defined with value @code{__GCC_LITTLE_ENDIAN__} or
+@code{__GCC_BIG_ENDIAN__} if the target's words order within a
+multi-word integer datum is little-endian or big-endian, respectively.
+
+@item __TARGET_FLOAT_WORDS_ORDER__
+This macro is defined with value @code{__GCC_LITTLE_ENDIAN__} or
+@code{__GCC_BIG_ENDIAN__} if the target's words order within a
+multi-word floating-point datum is little-endian or big-endian, respectively.
+
+@item __TARGET_FLOAT_FORMAT__
+This macro is defined to describe the floating-point format used by the
+target. It has value in the set comprised of:
+@code{__UNKNOWN_FORMAT__}, @code{__IEEE_FORMAT__},
+@code{__IBM_FORMAT__}, @code{__C4X_FORMAT__} and @code{__VAX_FORMAT__}.
+
+@item __TARGET_USES_VAX_F_FLOAT__
+This macro is defined with value 1 if the target uses the VAX F-format
+for the single precision floating-point data type; else if has value 0.
+
+@item __TARGET_USES_VAX_D_FLOAT__
+@item __TARGET_USES_VAX_G_FLOAT__
+These macros are always defined, with values 0 or 1. If
+@code{__TARGET_FLOAT_FORMAT__} is @code{__VAX_FORMAT__} then they have
+mutually exclusive values; else both have value 0. Non-zero
+@code{__TARGET_USES_VAX_D_FLOAT__} means the target uses the VAX
+D-format for the double precision floating-point data type; non-zero
+@code{__TARGET_USES_VAX_G_FLOAT__} means the VAX G-format is used.
+
+@item __TARGET_USES_VAX_H_FLOAT__
+When non-zero, the target uses the VAX H-format for the extended
+precision floating-point data type.
+
@node System-specific Predefined Macros
@subsection System-specific Predefined Macros