OSDN Git Service

* langhooks-def.h (lhd_register_builtin_type): New function.
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 9 Sep 2003 03:35:31 +0000 (03:35 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 9 Sep 2003 03:35:31 +0000 (03:35 +0000)
(LANG_HOOKS_REGISTER_BUILTIN_TYPE): New macro.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Update.
* langhooks.h (lang_hooks_for_types): Add register_builtin_type.
* langhooks.c (lhd_register_builtin_type): New function.
* c-common.h (c_register_builtin_type): Declare.
* c-common.c (c_register_builtin_type): New function.
* c-lang.c (LANG_HOOKS_REGISTER_BUILTIN_TYPE): Define to
c_register_builtin_type.
* config/ia64/hpux.h (TARGET_OS_CPP_BUILTINS): Remove __fpreg,
__float80, and __float128 macros.
* config/ia64/ia64.c (ia64_init_builtins): Create __fpreg,
__float80, and __float128 types.

* cp-lang.c (LANG_HOOKS_REGISTER_BUILTIN_TYPE): Define to
c_register_builtin_type.

* gcc.dg/ia64-types1.c: New test.
* gcc.dg/ia64-types2.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71227 138bc75d-0d04-0410-961f-82ee72b054a4

14 files changed:
gcc/ChangeLog
gcc/c-common.c
gcc/c-common.h
gcc/c-lang.c
gcc/config/ia64/hpux.h
gcc/config/ia64/ia64.c
gcc/cp/ChangeLog
gcc/cp/cp-lang.c
gcc/langhooks-def.h
gcc/langhooks.c
gcc/langhooks.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ia64-types1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/ia64-types2.c [new file with mode: 0644]

index e3895ab..b16092f 100644 (file)
@@ -1,3 +1,19 @@
+2003-09-08  Mark Mitchell  <mark@codesourcery.com>
+
+       * langhooks-def.h (lhd_register_builtin_type): New function.
+       (LANG_HOOKS_REGISTER_BUILTIN_TYPE): New macro.
+       (LANG_HOOKS_FOR_TYPES_INITIALIZER): Update.
+       * langhooks.h (lang_hooks_for_types): Add register_builtin_type.
+       * langhooks.c (lhd_register_builtin_type): New function.
+       * c-common.h (c_register_builtin_type): Declare.
+       * c-common.c (c_register_builtin_type): New function.
+       * c-lang.c (LANG_HOOKS_REGISTER_BUILTIN_TYPE): Define to
+       c_register_builtin_type.
+       * config/ia64/hpux.h (TARGET_OS_CPP_BUILTINS): Remove __fpreg,
+       __float80, and __float128 macros.
+       * config/ia64/ia64.c (ia64_init_builtins): Create __fpreg,
+       __float80, and __float128 types.
+
 2003-09-08  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * builtin-types.def
index 69dd081..4e63749 100644 (file)
@@ -2005,6 +2005,21 @@ c_common_signed_or_unsigned_type (int unsignedp, tree type)
 
   return type;
 }
+
+/* The C version of the register_builtin_type langhook.  */
+
+void
+c_register_builtin_type (tree type, const char* name)
+{
+  tree decl;
+
+  decl = build_decl (TYPE_DECL, get_identifier (name), type);
+  DECL_ARTIFICIAL (decl) = 1;
+  if (!TYPE_NAME (type))
+    TYPE_NAME (type) = decl;
+  pushdecl (decl);
+}
+
 \f
 /* Return the minimum number of bits needed to represent VALUE in a
    signed or unsigned type, UNSIGNEDP says which.  */
index e7dabd3..6ce5661 100644 (file)
@@ -948,6 +948,7 @@ extern bool c_common_init (void);
 extern void c_common_finish (void);
 extern void c_common_parse_file (int);
 extern HOST_WIDE_INT c_common_get_alias_set (tree);
+extern void c_register_builtin_type (tree, const char*);
 extern bool c_promoting_integer_type_p (tree);
 extern int self_promoting_args_p (tree);
 extern tree strip_array_types (tree);
index fb1741d..a6a4ede 100644 (file)
@@ -133,6 +133,8 @@ enum c_language_kind c_language = clk_c;
 #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR c_incomplete_type_error
 #undef LANG_HOOKS_TYPE_PROMOTES_TO
 #define LANG_HOOKS_TYPE_PROMOTES_TO c_type_promotes_to
+#undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
+#define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type
 
 #undef LANG_HOOKS_WRITE_GLOBALS
 #define LANG_HOOKS_WRITE_GLOBALS c_write_global_declarations
index 160ac45..b2b854b 100644 (file)
@@ -26,9 +26,6 @@ Boston, MA 02111-1307, USA.  */
 #define TARGET_VERSION fprintf (stderr, " (IA-64) HP-UX");
 
 /* Target OS builtins.  */
-/* -D__fpreg=long double is needed to compensate for
-   the lack of __fpreg which is a primitive type in
-   HP C but does not exist in GNU C.  */
 #define TARGET_OS_CPP_BUILTINS()                       \
 do {                                                   \
        builtin_assert("system=hpux");                  \
@@ -39,9 +36,6 @@ do {                                                  \
        builtin_define("__IA64__");                     \
        builtin_define("_LONGLONG");                    \
        builtin_define("_UINT128_T");                   \
-       builtin_define("__fpreg=long double");          \
-       builtin_define("__float80=long double");        \
-       builtin_define("__float128=long double");       \
        if (c_dialect_cxx () || !flag_iso)              \
          {                                             \
            builtin_define("_HPUX_SOURCE");             \
index 4561345..a6e5ff6 100644 (file)
@@ -7694,6 +7694,48 @@ ia64_init_builtins (void)
   tree void_ftype_pdi
     = build_function_type_list (void_type_node, pdi_type_node, NULL_TREE);
 
+  tree fpreg_type;
+
+  /* The __fpreg type.  */
+  fpreg_type = make_node (REAL_TYPE);
+  /* ??? Once the IA64 back end supports both 80-bit and 128-bit
+     floating types, this type should have XFmode, not TFmode.
+     TYPE_PRECISION should be 80 bits, not 128.  And, the back end
+     should know to load/save __fpreg variables using the ldf.fill and
+     stf.spill instructions.  */
+  TYPE_PRECISION (fpreg_type) = 128;
+  layout_type (fpreg_type);
+  (*lang_hooks.types.register_builtin_type) (fpreg_type, "__fpreg");
+
+  /* The __float80 type.  */
+  if (INTEL_EXTENDED_IEEE_FORMAT)
+    /* The __float80 type is a synonym for "long double".  */
+    (*lang_hooks.types.register_builtin_type) (long_double_type_node,
+                                              "__float80");
+  else
+    {
+      tree float80_type = make_node (REAL_TYPE);
+      /* ??? Once the IA64 back end supports both 80-bit and 128-bit
+        floating types, this type should have XFmode, not TFmode.
+        TYPE_PRECISION should be 80 bits, not 128.  */
+      TYPE_PRECISION (float80_type) = 128;
+      layout_type (float80_type);
+      (*lang_hooks.types.register_builtin_type) (float80_type, "__float80");
+    }
+
+  /* The __float128 type.  */
+  if (INTEL_EXTENDED_IEEE_FORMAT)
+    {
+      tree float128_type = make_node (REAL_TYPE);
+      TYPE_PRECISION (float128_type) = 128;
+      layout_type (float128_type);
+      (*lang_hooks.types.register_builtin_type) (float128_type, "__float128");
+    }
+  else
+    /* This is a synonym for "long double".  */
+    (*lang_hooks.types.register_builtin_type) (long_double_type_node,
+                                              "__float128");
+
 #define def_builtin(name, type, code) \
   builtin_function ((name), (type), (code), BUILT_IN_MD, NULL, NULL_TREE)
 
index c02e8d1..2fed9f4 100644 (file)
@@ -1,5 +1,8 @@
 2003-09-08  Mark Mitchell  <mark@codesourcery.com>
 
+       * cp-lang.c (LANG_HOOKS_REGISTER_BUILTIN_TYPE): Define to
+       c_register_builtin_type.
+
        PR c++/11786
        * decl2.c (add_function): Do not complain about seeing the same
        non-function twice.
index 4d5ed27..527054c 100644 (file)
@@ -184,6 +184,8 @@ static void cxx_initialize_diagnostics (diagnostic_context *);
 #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR cxx_incomplete_type_error
 #undef LANG_HOOKS_TYPE_PROMOTES_TO
 #define LANG_HOOKS_TYPE_PROMOTES_TO cxx_type_promotes_to
+#undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
+#define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type
 
 /* Each front end provides its own hooks, for toplev.c.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
index f5a83cc..5089fda 100644 (file)
@@ -61,6 +61,7 @@ extern bool lhd_can_use_bit_fields_p (void);
 extern bool lhd_warn_unused_global_decl (tree);
 extern void lhd_incomplete_type_error (tree, tree);
 extern tree lhd_type_promotes_to (tree);
+extern void lhd_register_builtin_type (tree, const char *);
 extern bool lhd_decl_ok_for_sibcall (tree);
 extern tree lhd_expr_size (tree);
 extern bool lhd_decl_uninit (tree);
@@ -213,6 +214,7 @@ extern int lhd_tree_dump_type_quals (tree);
 #define LANG_HOOKS_MAKE_TYPE make_node
 #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR lhd_incomplete_type_error
 #define LANG_HOOKS_TYPE_PROMOTES_TO lhd_type_promotes_to
+#define LANG_HOOKS_REGISTER_BUILTIN_TYPE lhd_register_builtin_type
 
 #define LANG_HOOKS_FOR_TYPES_INITIALIZER { \
   LANG_HOOKS_MAKE_TYPE, \
@@ -222,6 +224,7 @@ extern int lhd_tree_dump_type_quals (tree);
   LANG_HOOKS_SIGNED_TYPE, \
   LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, \
   LANG_HOOKS_TYPE_PROMOTES_TO, \
+  LANG_HOOKS_REGISTER_BUILTIN_TYPE, \
   LANG_HOOKS_INCOMPLETE_TYPE_ERROR \
 }
 
index 622e062..7a003bb 100644 (file)
@@ -208,6 +208,13 @@ lhd_type_promotes_to (tree type ATTRIBUTE_UNUSED)
   abort ();
 }
 
+/* Registration of machine- or os-specific builtin types.  */
+void
+lhd_register_builtin_type (tree type ATTRIBUTE_UNUSED, 
+                          const char* name ATTRIBUTE_UNUSED)
+{
+}
+
 /* Invalid use of an incomplete type.  */
 void
 lhd_incomplete_type_error (tree value ATTRIBUTE_UNUSED, tree type)
index 109dfa1..0d86478 100644 (file)
@@ -136,6 +136,15 @@ struct lang_hooks_for_types
      arguments.  The default hook aborts.  */
   tree (*type_promotes_to) (tree);
 
+  /* Register TYPE as a builtin type with the indicated NAME.  The
+     TYPE is placed in the outermost lexical scope.  The semantics
+     should be analogous to:
+
+       typedef TYPE NAME;
+
+     in C.  The default hook ignores the declaration.  */
+  void (*register_builtin_type) (tree, const char *);
+
   /* This routine is called in tree.c to print an error message for
      invalid use of an incomplete type.  VALUE is the expression that
      was used (or 0 if that isn't known) and TYPE is the type that was
index 62652d1..bc34f5b 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-08  Mark Mitchell  <mark@codesourcery.com>
+
+       * gcc.dg/ia64-types1.c: New test.
+       * gcc.dg/ia64-types2.c: Likewise.
+
 2003-09-08  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/builtins-1.c: Add more _Complex tests.
diff --git a/gcc/testsuite/gcc.dg/ia64-types1.c b/gcc/testsuite/gcc.dg/ia64-types1.c
new file mode 100644 (file)
index 0000000..521588b
--- /dev/null
@@ -0,0 +1,41 @@
+/* { dg-do compile { target ia64*-hp-hpux* } } */
+
+/* Test that __fpreg is distinct from any other builtin type.  */
+
+extern float fr1; /* { dg-error "" } */
+extern __fpreg fr1; /* { dg-error "" } */
+extern double fr2; /* { dg-error "" } */
+extern __fpreg fr2; /* { dg-error "" } */
+extern long double fr3; /* { dg-error "" } */
+extern __fpreg fr3; /* { dg-error "" } */
+extern __float80 fr4; /* { dg-error "" } */
+extern __fpreg fr4; /* { dg-error "" } */
+extern __float128 fr5; /* { dg-error "" } */
+extern __fpreg fr5; /* { dg-error "" } */
+
+/* Test that __float80 is distinct from any other builtin type.  */
+
+extern float f801; /* { dg-error "" } */
+extern __float80 f801; /* { dg-error "" } */
+extern double f802; /* { dg-error "" } */
+extern __float80 f802; /* { dg-error "" } */
+extern long double f803; /* { dg-error "" } */
+extern __float80 f803; /* { dg-error "" } */
+extern __fpreg f804;  /* { dg-error "" } */
+extern __float80 f804; /* { dg-error "" } */
+extern __float128 f805; /* { dg-error "" } */
+extern __float80 f805; /* { dg-error "" } */
+
+/* Test that __float128 is distinct from any other builtin type --
+   except "long double", for which it is a synonym.  */
+
+extern float f1281; /* { dg-error "" } */
+extern __float128 f1281; /* { dg-error "" } */
+extern double f1282; /* { dg-error "" } */
+extern __float128 f1282; /* { dg-error "" } */
+extern long double f1283;
+extern __float128 f1283;
+extern __fpreg f1284; /* { dg-error "" } */
+extern __float128 f1284; /* { dg-error "" } */
+extern __float80 f1285; /* { dg-error "" } */
+extern __float128 f1285; /* { dg-error "" } */
diff --git a/gcc/testsuite/gcc.dg/ia64-types2.c b/gcc/testsuite/gcc.dg/ia64-types2.c
new file mode 100644 (file)
index 0000000..30e4ddb
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do run { target ia64*-hp-hpux* } } */
+/* { dg-options } */
+
+/* Test that the sizes and alignments of the extra floating-point
+   types are correct.  */
+
+int main () {
+  if (sizeof (__fpreg) != 16)
+    return 1;
+  if (__alignof__ (__fpreg) != 16)
+    return 2;
+
+  if (sizeof (__float80) != 16)
+    return 3;
+  if (__alignof__ (__float80) != 16)
+    return 4;
+
+  return 0;
+}
+