public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk
@ 2004-06-01 19:30 p dot obry at wanadoo dot fr
  2004-06-01 19:36 ` [Bug target/15765] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: p dot obry at wanadoo dot fr @ 2004-06-01 19:30 UTC (permalink / raw)
  To: gcc-bugs

On Windows an stdcall calling convention routine will have an @nn suffix and
an '_' prefix added.

If an stdcall symbol starts with an asterisk the underscore prefix is not added
but the @nn suffix is still added in winnt.c (see gen_fastcall_suffix() and
gen_fastcall_suffix() routines).

Even if this following patch looks long the only real change I have made is
to add in both routines:

  /* A symbol starting with an asterisk means that no prefix or suffix must
     be added to this symbol, just return asmname as-is */
  if (asmname[0] == '*')
    return asmname;

I've taken the opportunity to factorize the code in gen_fastcall_suffix() and
gen_stdcall_suffix() as both procedures were having mostly 90% of code
duplication.

<<
*** winnt.c.orig        Sat May 29 15:15:39 2004
--- winnt.c     Sat May 29 15:31:22 2004
***************
*** 403,419 ****
    DECL_NON_ADDR_CONST_P (decl) = 1;
  }

! /* Return string which is the former assembler name modified with a
!    prefix consisting of FASTCALL_PREFIX and a suffix consisting of an
!    atsign (@) followed by the number of bytes of arguments.  */

  static const char *
! gen_fastcall_suffix (tree decl)
  {
    int total = 0;
    const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    char *newsym;

    if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
      if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
          == void_type_node)
--- 403,424 ----
    DECL_NON_ADDR_CONST_P (decl) = 1;
  }

! /* Return string (using format string) which is the former assembler name
!    modified with a suffix consisting of an atsign (@) followed by the number
!    of bytes of arguments */

  static const char *
! gen_suffix (const char *format, tree decl)
  {
    int total = 0;
    const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
    char *newsym;

+   /* A symbol starting with an asterisk means that no prefix or suffix must
+      be added to this symbol, just return asmname as-is */
+   if (asmname[0] == '*')
+     return asmname;
+
    if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
      if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
          == void_type_node)
***************
*** 438,486 ****

    /* Assume max of 8 base 10 digits in the suffix.  */
    newsym = xmalloc (1 + strlen (asmname) + 1 + 8 + 1);
!   sprintf (newsym, "%c%s@%d", FASTCALL_PREFIX, asmname, total/BITS_PER_UNIT);
    return IDENTIFIER_POINTER (get_identifier (newsym));
  }

  /* Return string which is the former assembler name modified with a
!    suffix consisting of an atsign (@) followed by the number of bytes of
!    arguments */

  static const char *
! gen_stdcall_suffix (tree decl)
  {
!   int 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;

!   if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
!     if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
!         == void_type_node)
!       {
!       tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));

!       /* Quit if we hit an incomplete type.  Error is reported
!          by convert_arguments in c-typeck.c or cp/typeck.c.  */
!       while (TREE_VALUE (formal_type) != void_type_node
!              && COMPLETE_TYPE_P (TREE_VALUE (formal_type)))
!         {
!           int parm_size
!             = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));
!           /* 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;
!           formal_type = TREE_CHAIN (formal_type);
!         }
!       }

!   /* Assume max of 8 base 10 digits in the suffix.  */
!   newsym = xmalloc (strlen (asmname) + 1 + 8 + 1);
!   sprintf (newsym, "%s@%d", asmname, total/BITS_PER_UNIT);
!   return IDENTIFIER_POINTER (get_identifier (newsym));
  }

  void
--- 443,473 ----

    /* Assume max of 8 base 10 digits in the suffix.  */
    newsym = xmalloc (1 + strlen (asmname) + 1 + 8 + 1);
!   sprintf (newsym, format, asmname, total/BITS_PER_UNIT);
    return IDENTIFIER_POINTER (get_identifier (newsym));
  }

  /* Return string which is the former assembler name modified with a
!    prefix consisting of FASTCALL_PREFIX and a suffix consisting of an
!    atsign (@) followed by the number of bytes of arguments.  */

  static const char *
! gen_fastcall_suffix (tree decl)
  {
!   char *format = " %s@%d";
!   format[0] = FASTCALL_PREFIX;

!   return gen_suffix (format, decl);
! }

! /* Return string which is the former assembler name modified with a
!    suffix consisting of an atsign (@) followed by the number of bytes of
!    arguments */

! static const char *
! gen_stdcall_suffix (tree decl)
! {
!   return gen_suffix ("%s@%d", decl);
  }

  void
>>

Pascal.

-- 
           Summary: asmname should be verbatim if starting with an asterisk
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: translation
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: p dot obry at wanadoo dot fr
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: pentium-mingw32msv
  GCC host triplet: pentium-mingw32msv
GCC target triplet: pentium-mingw32msv


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15765


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-09-27  3:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-01 19:30 [Bug translation/15765] New: asmname should be verbatim if starting with an asterisk p dot obry at wanadoo dot fr
2004-06-01 19:36 ` [Bug target/15765] " pinskia at gcc dot gnu dot org
2004-06-02  8:49 ` p dot obry at wanadoo dot fr
2004-06-02 11:39 ` pinskia at gcc dot gnu dot org
2004-06-02 20:07 ` pinskia at gcc dot gnu dot org
2004-09-24  9:18 ` dannysmith at users dot sourceforge dot net
2004-09-27  3:46 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).