gcc/
authorjbeulich <jbeulich@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Feb 2008 14:47:35 +0000 (14:47 +0000)
committerjbeulich <jbeulich@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Feb 2008 14:47:35 +0000 (14:47 +0000)
2008-02-25  Jan Beulich  <jbeulich@novell.com>

* Makefile.in: Also prefix uses of crt0.o and mcrt0.o with
$(T).
* config/i386/netware-libgcc.exp: Add __bswap?i2,
__emultls_get_address, __emultls_register_common,
__floatundi?f, and _Unwind_GetIPInfo.
* config/i386/netware.c (gen_stdcall_or_fastcall_decoration):
Sync with config/i386/winnt.c:gen_stdcall_or_fastcall_suffix().
(gen_regparm_prefix): Likewise.
(i386_nlm_encode_section_info): Sync with
config/i386/winnt.c:i386_pe_encode_section_info().
(i386_nlm_maybe_mangle_decl_assembler_name): New.
i386_nlm_mangle_decl_assembler_name): New.
(netware_override_options): New.
* config/i386/netware.h (netware_override_options): Declare.
(OVERRIDE_OPTIONS): Re-define to netware_override_options.
(i386_nlm_mangle_decl_assembler_name): Declare.
(TARGET_MANGLE_DECL_ASSEMBLER_NAME): Define.

gcc/testsuite/
2008-02-25  Jan Beulich  <jbeulich@novell.com>

* gcc.dg/20020426-2.c: Remove bogus workaround.
* g++.old-deja/g++.other/store-expr1.C: Likewise.
* gcc.target/i386/movq-2.c: Also permit use of movzbl.

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

gcc/ChangeLog
gcc/Makefile.in
gcc/config/i386/netware-libgcc.exp
gcc/config/i386/netware.c
gcc/config/i386/netware.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/store-expr1.C
gcc/testsuite/gcc.dg/20020426-2.c
gcc/testsuite/gcc.target/i386/movq-2.c

index 5143fd7..13ca11e 100644 (file)
@@ -1,3 +1,23 @@
+2008-02-25  Jan Beulich  <jbeulich@novell.com>
+
+       * Makefile.in: Also prefix uses of crt0.o and mcrt0.o with
+       $(T).
+       * config/i386/netware-libgcc.exp: Add __bswap?i2,
+       __emultls_get_address, __emultls_register_common,
+       __floatundi?f, and _Unwind_GetIPInfo.
+       * config/i386/netware.c (gen_stdcall_or_fastcall_decoration):
+       Sync with config/i386/winnt.c:gen_stdcall_or_fastcall_suffix().
+       (gen_regparm_prefix): Likewise.
+       (i386_nlm_encode_section_info): Sync with
+       config/i386/winnt.c:i386_pe_encode_section_info().
+       (i386_nlm_maybe_mangle_decl_assembler_name): New.
+       i386_nlm_mangle_decl_assembler_name): New.
+       (netware_override_options): New.
+       * config/i386/netware.h (netware_override_options): Declare.
+       (OVERRIDE_OPTIONS): Re-define to netware_override_options.
+       (i386_nlm_mangle_decl_assembler_name): Declare.
+       (TARGET_MANGLE_DECL_ASSEMBLER_NAME): Define.
+
 2008-02-25  Ben Elliston  <bje@au.ibm.com>
 
        PR other/32948
index a87e3bb..486a811 100644 (file)
@@ -1697,14 +1697,14 @@ $(T)crtbeginT.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \
 
 # Compile the start modules crt0.o and mcrt0.o that are linked with
 # every program
-crt0.o: s-crt0 ; @true
-mcrt0.o: s-crt0; @true
+$(T)crt0.o: s-crt0 ; @true
+$(T)mcrt0.o: s-crt0; @true
 
 s-crt0:        $(CRT0_S) $(MCRT0_S) $(GCC_PASSES) $(CONFIG_H)
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(CRT0STUFF_T_CFLAGS) \
-         -o crt0.o -c $(CRT0_S)
+         -o $(T)crt0.o -c $(CRT0_S)
        $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(CRT0STUFF_T_CFLAGS) \
-         -o mcrt0.o -c $(MCRT0_S)
+         -o $(T)mcrt0.o -c $(MCRT0_S)
        $(STAMP) s-crt0
 #\f
 # Compiling object files from source files.
index a3498c0..309cf75 100644 (file)
@@ -6,6 +6,8 @@
        __addvsi3,
 #      __ashldi3,
 #      __ashrdi3,
+       __bswapdi2,
+       __bswapsi2,
        __clzdi2,
        __clzsi2,
        __ctzdi2,
        __divsc3,
 #      __divtc3,
        __divxc3,
+       __emutls_get_address,
+       __emutls_register_common,
        __ffsdi2,
        __ffssi2,
        __fixunsdfdi,
        __fixunssfdi,
 #      __fixunstfdi,
        __fixunsxfdi,
+       __floatundisf,
+       __floatundidf,
+#      __floatunditf,
+       __floatundixf,
        __gcc_bcmp,
        __gcc_personality_v0,
 #      __lshrdi3,
@@ -64,6 +72,7 @@
        _Unwind_GetDataRelBase,
        _Unwind_GetGR,
        _Unwind_GetIP,
+       _Unwind_GetIPInfo,
        _Unwind_GetLanguageSpecificData,
        _Unwind_GetRegionStart,
        _Unwind_GetTextRelBase,
index 0357baf..63c26cc 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines for insn-output.c for NetWare.
    Contributed by Jan Beulich (jbeulich@novell.com)
-   Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -32,28 +32,25 @@ along with GCC; see the file COPYING3.  If not see
 #include "toplev.h"
 #include "ggc.h"
 
-
-/* Return string which is the former assembler name modified with an 
-   underscore prefix and a suffix consisting of an atsign (@) followed
-   by the number of bytes of arguments */
+/* Return string which is the function name, identified by ID, modified
+   with PREFIX and a suffix consisting of an atsign (@) followed by the
+   number of bytes of arguments.  If ID is NULL use the DECL_NAME as base.
+   Return NULL if no change required.  */
 
 static tree
-gen_stdcall_or_fastcall_decoration (tree decl, char prefix)
+gen_stdcall_or_fastcall_decoration (tree decl, tree id, char prefix)
 {
-  unsigned total = 0;
-  /* ??? This probably should use XSTR (XEXP (DECL_RTL (decl), 0), 0) instead
-     of DECL_ASSEMBLER_NAME.  */
-  const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-  char *newsym;
+  unsigned HOST_WIDE_INT total = 0;
+  const char *old_str = IDENTIFIER_POINTER (id != NULL_TREE ? id : DECL_NAME (decl));
+  char *new_str;
   tree type = TREE_TYPE (decl);
-  tree arg;
-  function_args_iterator args_iter;
 
   if (prototype_p (type))
     {
-      /* These attributes are ignored for variadic functions in
-        i386.c:ix86_return_pops_args. For compatibility with MS
-        compiler do not add @0 suffix here.  */ 
+      tree arg;
+      function_args_iterator args_iter;
+
+      /* This attribute is ignored for variadic functions.  */ 
       if (stdarg_p (type))
        return NULL_TREE;
 
@@ -61,50 +58,50 @@ gen_stdcall_or_fastcall_decoration (tree decl, char prefix)
         by convert_arguments in c-typeck.c or cp/typeck.c.  */
       FOREACH_FUNCTION_ARGS(type, arg, args_iter)
        {
-         unsigned parm_size;
+         HOST_WIDE_INT parm_size;
+         unsigned HOST_WIDE_INT parm_boundary_bytes;
 
          if (! COMPLETE_TYPE_P (arg))
            break;
 
-         parm_size = int_size_in_bytes (TYPE_SIZE (arg));
+         parm_size = int_size_in_bytes (arg);
          if (parm_size < 0)
            break;
 
+         parm_boundary_bytes = PARM_BOUNDARY / BITS_PER_UNIT;
+
          /* Must round up to include padding.  This is done the same
             way as in store_one_arg.  */
-         parm_size = ((parm_size + PARM_BOUNDARY - 1)
-                      / PARM_BOUNDARY * PARM_BOUNDARY);
-         total += parm_size;
+         total += (parm_size + parm_boundary_bytes - 1)
+                  / parm_boundary_bytes * parm_boundary_bytes;
        }
     }
 
-  newsym = alloca (1 + strlen (asmname) + 1 + 10 + 1);
-  return get_identifier_with_length (newsym,
-                                    sprintf (newsym,
-                                             "%c%s@%u",
-                                             prefix,
-                                             asmname,
-                                             total / BITS_PER_UNIT));
+  new_str = alloca (1 + strlen (old_str) + 1 + 10 + 1);
+  sprintf (new_str, "%c%s@" HOST_WIDE_INT_PRINT_UNSIGNED,
+          prefix, old_str, total);
+
+  return get_identifier (new_str);
 }
 
-/* Return string which is the former assembler name modified with an 
-   _n@ prefix where n represents the number of arguments passed in
-   registers */
+/* Return string which is the function name, identified by ID, modified
+   with an _n@ prefix (where n represents the number of arguments passed in
+   registers).  If ID is NULL use the DECL_NAME as base.
+   Return NULL if no change required.  */
 
 static tree
-gen_regparm_prefix (tree decl, unsigned nregs)
+gen_regparm_prefix (tree decl, tree id, unsigned int nregs)
 {
-  unsigned total = 0;
-  /* ??? This probably should use XSTR (XEXP (DECL_RTL (decl), 0), 0) instead
-     of DECL_ASSEMBLER_NAME.  */
-  const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-  char *newsym;
+  unsigned HOST_WIDE_INT total = 0;
+  const char *old_str = IDENTIFIER_POINTER (id != NULL_TREE ? id : DECL_NAME (decl));
+  char *new_str;
   tree type = TREE_TYPE (decl);
-  tree arg;
-  function_args_iterator args_iter;
 
   if (prototype_p (type))
     {
+      tree arg;
+      function_args_iterator args_iter;
+
       /* This attribute is ignored for variadic functions.  */ 
       if (stdarg_p (type))
        return NULL_TREE;
@@ -113,7 +110,8 @@ gen_regparm_prefix (tree decl, unsigned nregs)
         by convert_arguments in c-typeck.c or cp/typeck.c.  */
       FOREACH_FUNCTION_ARGS(type, arg, args_iter)
        {
-         unsigned parm_size;
+         HOST_WIDE_INT parm_size;
+         unsigned HOST_WIDE_INT parm_boundary_bytes;
 
          if (! COMPLETE_TYPE_P (arg))
            break;
@@ -122,21 +120,58 @@ gen_regparm_prefix (tree decl, unsigned nregs)
          if (parm_size < 0)
            break;
 
-         parm_size = ((parm_size + PARM_BOUNDARY - 1)
-                      / PARM_BOUNDARY * PARM_BOUNDARY);
-         total += parm_size;
+         parm_boundary_bytes = PARM_BOUNDARY / BITS_PER_UNIT;
+
+         /* Must round up to include padding.  This is done the same
+            way as in store_one_arg.  */
+         total += (parm_size + parm_boundary_bytes - 1)
+                  / parm_boundary_bytes * parm_boundary_bytes;
        }
     }
 
-  if (nregs > total / BITS_PER_WORD)
-    nregs = total / BITS_PER_WORD;
+  if (nregs > total / UNITS_PER_WORD)
+    nregs = total / UNITS_PER_WORD;
   gcc_assert (nregs <= 9);
-  newsym = alloca (3 + strlen (asmname) + 1);
-  return get_identifier_with_length (newsym,
-                                    sprintf (newsym,
-                                             "_%u@%s",
-                                             nregs,
-                                             asmname));
+  new_str = alloca (3 + strlen (old_str) + 1);
+  sprintf (new_str, "_%u@%s", nregs, old_str);
+
+  return get_identifier (new_str);
+}
+
+/* Maybe decorate and get a new identifier for the DECL of a stdcall or
+   fastcall function. The original identifier is supplied in ID. */
+
+static tree
+i386_nlm_maybe_mangle_decl_assembler_name (tree decl, tree id)
+{
+  tree type_attributes = TYPE_ATTRIBUTES (TREE_TYPE (decl));
+  tree new_id;
+
+  if (lookup_attribute ("stdcall", type_attributes))
+    new_id = gen_stdcall_or_fastcall_decoration (decl, id, '_');
+  else if (lookup_attribute ("fastcall", type_attributes))
+    new_id = gen_stdcall_or_fastcall_decoration (decl, id, FASTCALL_PREFIX);
+  else if ((new_id = lookup_attribute ("regparm", type_attributes)))
+    new_id = gen_regparm_prefix (decl, id,
+                 TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (new_id))));
+  else
+    new_id = NULL_TREE;
+
+  return new_id;
+}
+
+/* This is used as a target hook to modify the DECL_ASSEMBLER_NAME
+   in the language-independent default hook
+   langhooks.c:lhd_set_decl_assembler_name ()
+   and in cp/mangle.c:mangle_decl ().  */
+tree
+i386_nlm_mangle_decl_assembler_name (tree decl, tree id)
+{
+  tree new_id = TREE_CODE (decl) == FUNCTION_DECL
+               ? i386_nlm_maybe_mangle_decl_assembler_name (decl, id)
+               : NULL_TREE;
+
+  return (new_id ? new_id : id);
 }
 
 void
@@ -146,31 +181,28 @@ i386_nlm_encode_section_info (tree decl, rtx rtl, int first)
 
   if (first
       && TREE_CODE (decl) == FUNCTION_DECL
+      /* Do not change the identifier if a verbatim asmspec
+        or if stdcall suffix already added.  */
       && *IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)) != '*'
       && !strchr (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), '@'))
     {
-      tree type_attributes = TYPE_ATTRIBUTES (TREE_TYPE (decl));
-      tree newid;
-
-      if (lookup_attribute ("stdcall", type_attributes))
-       newid = gen_stdcall_or_fastcall_decoration (decl, '_');
-      else if (lookup_attribute ("fastcall", type_attributes))
-       newid = gen_stdcall_or_fastcall_decoration (decl, FASTCALL_PREFIX);
-      else if ((newid = lookup_attribute ("regparm", type_attributes)) != NULL_TREE)
-       newid = gen_regparm_prefix (decl,
-                     TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (newid))));
-      if (newid != NULL_TREE)  
-       {
-         rtx rtlname = XEXP (rtl, 0);
+      /* FIXME: In Ada, and perhaps other language frontends,
+        imported stdcall names may not yet have been modified.
+        Check and do it know.  */
+      rtx symbol = XEXP (rtl, 0);
+      tree new_id;
+      tree old_id = DECL_ASSEMBLER_NAME (decl);
+
+      gcc_assert (GET_CODE (symbol) == SYMBOL_REF);
 
-         if (GET_CODE (rtlname) == MEM)
-           rtlname = XEXP (rtlname, 0);
-         XSTR (rtlname, 0) = IDENTIFIER_POINTER (newid);
+      if ((new_id = i386_nlm_maybe_mangle_decl_assembler_name (decl, old_id)))
+       {
          /* These attributes must be present on first declaration,
             change_decl_assembler_name will warn if they are added
             later and the decl has been referenced, but duplicate_decls
-            should catch the mismatch before this is called.  */ 
-         change_decl_assembler_name (decl, newid);
+            should catch the mismatch first.  */
+         change_decl_assembler_name (decl, new_id);
+         XSTR (symbol, 0) = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
        }
     }
 }
@@ -201,3 +233,24 @@ i386_nlm_strip_name_encoding (const char *str)
     }
   return name;
 }
+
+/* Sometimes certain combinations of command options do not make
+   sense on a particular target machine.  You can define a macro
+   `OVERRIDE_OPTIONS' to take account of this.  This macro, if
+   defined, is executed once just after all the command options have
+   been parsed.
+
+   Don't use this macro to turn on various extra optimizations for
+   `-O'.  That is what `OPTIMIZATION_OPTIONS' is for.  */
+
+void
+netware_override_options (void)
+{
+  override_options ();
+
+  if (flag_pic)
+    {
+      error ("-fPIC and -fpic are not supported for this target");
+      flag_pic = 0;
+    }
+}
index e7459a2..d4f31e0 100644 (file)
@@ -72,6 +72,18 @@ along with GCC; see the file COPYING3.  If not see
 #define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP | \
        MASK_FLOAT_RETURNS | MASK_ALIGN_DOUBLE | MASK_MS_BITFIELD_LAYOUT)
 
+/* Sometimes certain combinations of command options do not make
+   sense on a particular target machine.  You can define a macro
+   `OVERRIDE_OPTIONS' to take account of this.  This macro, if
+   defined, is executed once just after all the command options have
+   been parsed.
+
+   Don't use this macro to turn on various extra optimizations for
+   `-O'.  That is what `OPTIMIZATION_OPTIONS' is for.  */
+#undef  OVERRIDE_OPTIONS
+extern void netware_override_options (void);
+#define OVERRIDE_OPTIONS netware_override_options ()
+
 #undef MATH_LIBRARY
 #define MATH_LIBRARY ""
 
@@ -142,13 +154,15 @@ along with GCC; see the file COPYING3.  If not see
    function named by the symbol (such as what section it is in).
 
    On i386 running NetWare, modify the assembler name with an underscore (_)
-   prefix and a suffix consisting of an atsign (@) followed by a string of
-   digits that represents the number of bytes of arguments passed to the
-   function, if it has the attribute STDCALL. Alternatively, if it has the 
-   REGPARM attribute, prefix it with an underscore (_), a digit representing
-   the number of registers used, and an atsign (@). */
+   or atsign (@) prefix and a suffix consisting of an atsign (@) followed by
+   a string of digits that represents the number of bytes of arguments passed
+   to the function, if it has the attribute STDCALL. Alternatively, if it has
+   the REGPARM attribute, prefix it with an underscore (_), a digit
+   representing the number of registers used, and an atsign (@). */
 void i386_nlm_encode_section_info (tree, rtx, int);
+extern tree i386_nlm_mangle_decl_assembler_name (tree, tree);
 const char *i386_nlm_strip_name_encoding (const char *);
 #define SUBTARGET_ENCODE_SECTION_INFO  i386_nlm_encode_section_info
+#define TARGET_MANGLE_DECL_ASSEMBLER_NAME i386_nlm_mangle_decl_assembler_name
 #undef  TARGET_STRIP_NAME_ENCODING
 #define TARGET_STRIP_NAME_ENCODING  i386_nlm_strip_name_encoding
index 0d11e69..cc2d87c 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-25  Jan Beulich  <jbeulich@novell.com>
+
+       * gcc.dg/20020426-2.c: Remove bogus workaround.
+       * g++.old-deja/g++.other/store-expr1.C: Likewise.
+       * gcc.target/i386/movq-2.c: Also permit use of movzbl.
+
 2008-02-25  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        * gfortran.dg/large_real_kind_3.F90: Xfail on ppc-darwin.
index 5eb0d38..72d30eb 100644 (file)
@@ -2,7 +2,6 @@
 // { dg-require-effective-target ilp32 }
 // { dg-require-effective-target fpic }
 // { dg-options "-mtune=i686 -O2 -fpic" }
-// { dg-bogus "\[Uu\]nresolved symbol .(_GLOBAL_OFFSET_TABLE_|\[_.A-Za-z\]\[_.0-9A-Za-z\]*@(PLT|GOT|GOTOFF))|\[Bb\]ad fixup at .DATA.:" "PIC unsupported" { xfail *-*-netware* } 0 }
 class G {};
 
 struct N {
index 5ddb348..3a892ed 100644 (file)
@@ -3,7 +3,6 @@
 /* { dg-do run } */
 /* { dg-options "-O2" } */
 /* { dg-options "-O2 -frename-registers -fomit-frame-pointer -fPIC -mtune=i686" { target { { i?86-*-* x86_64-*-* } && { ilp32 && fpic } } } } */
-/* { dg-bogus "\[Uu\]nresolved symbol .(_GLOBAL_OFFSET_TABLE_|\[_.A-Za-z\]\[_.0-9A-Za-z\]*@(PLT|GOT|GOTOFF))" "PIC unsupported" { xfail *-*-netware* } 0 } */
 
 extern void exit (int);
 
index 9897964..4a1accb 100644 (file)
@@ -23,4 +23,4 @@ foo (struct S *x)
 
 /* { dg-final { scan-assembler-not "movl\[ \t\]*123" } } */
 /* { dg-final { scan-assembler "movzbl\[ \t\]*123" } } */
-/* { dg-final { scan-assembler "movl\[ \t\]*120" } } */
+/* { dg-final { scan-assembler "mov(zb)?l\[ \t\]*120" } } */