This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: add DOLLARS_IN_ASM_IDENTIFIERS
- From: Sandra Loosemore <sandra at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 06 Jul 2007 07:48:43 -0400
- Subject: PATCH: add DOLLARS_IN_ASM_IDENTIFIERS
MIPS assembly language uses identifiers like "$17" as the names of registers.
This patch makes cpp do the right thing with concatenation, etc, by adding a new
target macro. The existing DOLLARS_IN_IDENTIFIERS applies only to C-like
languages, and conventions for assembly language files may well be different. OK?
-Sandra
2007-07-05 Sandra Loosemore <sandra@codesourcery.com>
Nigel Stephens <nigel@mips.com>
gcc/
* c-opts.c (DOLLARS_IN_ASM_IDENTIFIERS): New.
(c_common_handle_option): Set handling of dollar signs in assembly
language identifiers from DOLLARS_IN_ASM_IDENTIFIERS.
* doc/tm.texi (DOLLARS_IN_ASM_IDENTIFIERS): Document.
* config/mips/mips.h (DOLLARS_IN_ASM_IDENTIFIERS): Define.
* testsuite/gcc.target/mips/dollar-in-asm.S: New.
* testsuite/gcc.target/mips/mips.exp: Add .S files to dg-runtest
glob pattern.
Index: gcc/c-opts.c
===================================================================
*** gcc/c-opts.c (revision 175724)
--- gcc/c-opts.c (working copy)
*************** Software Foundation, 51 Franklin Street,
*** 44,49 ****
--- 44,53 ----
# define DOLLARS_IN_IDENTIFIERS true
#endif
+ #ifndef DOLLARS_IN_ASM_IDENTIFIERS
+ # define DOLLARS_IN_ASM_IDENTIFIERS false
+ #endif
+
#ifndef TARGET_SYSTEM_ROOT
# define TARGET_SYSTEM_ROOT NULL
#endif
*************** c_common_handle_option (size_t scode, co
*** 858,864 ****
case OPT_lang_asm:
cpp_set_lang (parse_in, CLK_ASM);
! cpp_opts->dollars_in_ident = false;
break;
case OPT_lang_fortran:
--- 862,868 ----
case OPT_lang_asm:
cpp_set_lang (parse_in, CLK_ASM);
! cpp_opts->dollars_in_ident = DOLLARS_IN_ASM_IDENTIFIERS;
break;
case OPT_lang_fortran:
Index: gcc/doc/tm.texi
===================================================================
*** gcc/doc/tm.texi (revision 175724)
--- gcc/doc/tm.texi (working copy)
*************** not allowed by default; 1 means it is al
*** 9589,9594 ****
--- 9589,9601 ----
there is no need to define this macro in that case.
@end defmac
+ @defmac DOLLARS_IN_ASM_IDENTIFIERS
+ Define this macro to control use of the character @samp{$} in
+ identifier names in assembly-language files. 0 means @samp{$} is
+ not allowed by default; 1 means it is allowed. 0 is the default;
+ there is no need to define this macro in that case.
+ @end defmac
+
@defmac NO_DOLLAR_IN_LABEL
Define this macro if the assembler does not accept the character
@samp{$} in label names. By default constructors and destructors in
Index: gcc/config/mips/mips.h
===================================================================
*** gcc/config/mips/mips.h (revision 175724)
--- gcc/config/mips/mips.h (working copy)
*************** extern const struct mips_rtx_cost_data *
*** 510,515 ****
--- 510,520 ----
#endif
#endif /* IN_LIBGCC2 */
+ /* The MIPS assembly language uses dollar as part of the register
+ name, so it needs to be treated by CPP as part of a symbol name for
+ concatenation etc to work correctly. */
+ #define DOLLARS_IN_ASM_IDENTIFIERS true
+
#define TARGET_LIBGCC_SDATA_SECTION ".sdata"
#ifndef MULTILIB_ENDIAN_DEFAULT
Index: gcc/testsuite/gcc.target/mips/dollar-in-asm.S
===================================================================
*** gcc/testsuite/gcc.target/mips/dollar-in-asm.S (revision 0)
--- gcc/testsuite/gcc.target/mips/dollar-in-asm.S (revision 0)
***************
*** 0 ****
--- 1,10 ----
+ /* Test for correct handling of dollar-sign in MIPS assembly language by
+ the preprocessor. */
+
+ /* { dg-do preprocess } */
+
+ #define foo(n,m) n##m
+
+ register foo ($, 6)
+
+ /* { dg-final { scan-file dollar-in-asm.i "register \\\$6" } } */
Index: gcc/testsuite/gcc.target/mips/mips.exp
===================================================================
*** gcc/testsuite/gcc.target/mips/mips.exp (revision 175724)
--- gcc/testsuite/gcc.target/mips/mips.exp (working copy)
*************** proc dg-mips-options {args} {
*** 246,250 ****
setup_mips_tests
dg-init
! dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "" ""
dg-finish
--- 246,250 ----
setup_mips_tests
dg-init
! dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" ""
dg-finish