aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2003-07-27 01:48:11 +0000
committerGeoffrey Keating <geoffk@gcc.gnu.org>2003-07-27 01:48:11 +0000
commit18f3e349aa03695bd162d43ac746402aae315096 (patch)
treeb7681d01248c778248685f3ec5dfb7509c7adecf
parent404edd110efdb47f40f0f670d25b4e2aa84d2168 (diff)
downloadgcc-18f3e349aa03695bd162d43ac746402aae315096.zip
gcc-18f3e349aa03695bd162d43ac746402aae315096.tar.gz
gcc-18f3e349aa03695bd162d43ac746402aae315096.tar.bz2
varasm.c (output_constant_def_contents): Use ASM_DECLARE_CONSTANT_NAME if defined.
* varasm.c (output_constant_def_contents): Use ASM_DECLARE_CONSTANT_NAME if defined. * doc/tm.texi (Label Output): Document ASM_DECLARE_CONSTANT_NAME. * config/darwin.h (ASM_DECLARE_OBJECT_NAME): Ensure zero-sized objects get at least one byte to prevent assembler problems. (ASM_DECLARE_CONSTANT_NAME): New. Index: testsuite/ChangeLog * gcc.c-torture/compile/zero-strct-2.c: New test. From-SVN: r69842
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/darwin.h35
-rw-r--r--gcc/doc/tm.texi16
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/zero-strct-2.c2
-rw-r--r--gcc/varasm.c20
6 files changed, 65 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6dcc99e..c0915fa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -44,6 +44,13 @@
2003-07-26 Geoffrey Keating <geoffk@apple.com>
+ * varasm.c (output_constant_def_contents): Use
+ ASM_DECLARE_CONSTANT_NAME if defined.
+ * doc/tm.texi (Label Output): Document ASM_DECLARE_CONSTANT_NAME.
+ * config/darwin.h (ASM_DECLARE_OBJECT_NAME): Ensure zero-sized
+ objects get at least one byte to prevent assembler problems.
+ (ASM_DECLARE_CONSTANT_NAME): New.
+
* Makefile.in (libbackend.o): Remove options_.h.
(mostlyclean): Likewise.
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 4f9b487..64aab06 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -356,18 +356,22 @@ do { text_section (); \
#undef ASM_DECLARE_OBJECT_NAME
#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
do { \
- const char *xname = NAME; \
- if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
- xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
- if ((TREE_STATIC (DECL) \
- && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
- || DECL_INITIAL (DECL)) \
- machopic_define_name (xname); \
- if ((TREE_STATIC (DECL) \
- && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
- || DECL_INITIAL (DECL)) \
+ const char *xname = NAME; \
+ if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
+ xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
+ if ((TREE_STATIC (DECL) \
+ && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
+ || DECL_INITIAL (DECL)) \
+ machopic_define_name (xname); \
+ if ((TREE_STATIC (DECL) \
+ && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
+ || DECL_INITIAL (DECL)) \
(* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
- ASM_OUTPUT_LABEL (FILE, xname); \
+ ASM_OUTPUT_LABEL (FILE, xname); \
+ /* Darwin doesn't support zero-size objects, so give them a \
+ byte. */ \
+ if (tree_low_cst (DECL_SIZE_UNIT (DECL), 1) == 0) \
+ assemble_zeros (1); \
} while (0)
#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
@@ -389,6 +393,15 @@ do { text_section (); \
machopic_output_possible_stub_label (FILE, xname); \
} while (0)
+#define ASM_DECLARE_CONSTANT_NAME(FILE, NAME, EXP, SIZE) \
+ do { \
+ ASM_OUTPUT_LABEL (FILE, NAME); \
+ /* Darwin doesn't support zero-size objects, so give them a \
+ byte. */ \
+ if ((SIZE) == 0) \
+ assemble_zeros (1); \
+ } while (0)
+
/* Wrap new method names in quotes so the assembler doesn't gag.
Make Objective-C internal symbols local. */
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index e3f4afe..3f9dd15 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -6634,6 +6634,22 @@ You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} and/or
@code{ASM_OUTPUT_SIZE_DIRECTIVE} in the definition of this macro.
@end defmac
+@defmac ASM_DECLARE_CONSTANT_NAME (@var{stream}, @var{name}, @var{exp}, @var{size})
+A C statement (sans semicolon) to output to the stdio stream
+@var{stream} any text necessary for declaring the name @var{name} of a
+constant which is being defined. This macro is responsible for
+outputting the label definition (perhaps using
+@code{ASM_OUTPUT_LABEL}). The argument @var{exp} is the
+value of the constant, and @var{size} is the size of the constant
+in bytes. @var{name} will be an internal label.
+
+If this macro is not defined, then the @var{name} is defined in the
+usual manner as a label (by means of @code{ASM_OUTPUT_LABEL}).
+
+You may wish to use @code{ASM_OUTPUT_TYPE_DIRECTIVE} in the definition
+of this macro.
+@end defmac
+
@defmac ASM_DECLARE_REGISTER_GLOBAL (@var{stream}, @var{decl}, @var{regno}, @var{name})
A C statement (sans semicolon) to output to the stdio stream
@var{stream} any text necessary for claiming a register @var{regno}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2f0e153..c06df55 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2003-07-26 Geoffrey Keating <geoffk@apple.com>
+
+ * gcc.c-torture/compile/zero-strct-2.c: New test.
+
2003-07-25 Geoffrey Keating <geoffk@apple.com>
* gcc.dg/intermod-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/zero-strct-2.c b/gcc/testsuite/gcc.c-torture/compile/zero-strct-2.c
new file mode 100644
index 0000000..0f97f7d
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/zero-strct-2.c
@@ -0,0 +1,2 @@
+struct { } foo = { };
+void * bar(void) { return &foo; }
diff --git a/gcc/varasm.c b/gcc/varasm.c
index a8ff36f..c9dae89 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -2547,6 +2547,7 @@ output_constant_def_contents (rtx symbol)
{
tree exp = SYMBOL_REF_DECL (symbol);
const char *label = XSTR (symbol, 0);
+ HOST_WIDE_INT size;
/* Make sure any other constants whose addresses appear in EXP
are assigned label numbers. */
@@ -2571,17 +2572,20 @@ output_constant_def_contents (rtx symbol)
ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
}
- /* Output the label itself. */
+ size = int_size_in_bytes (TREE_TYPE (exp));
+ if (TREE_CODE (exp) == STRING_CST)
+ size = MAX (TREE_STRING_LENGTH (exp), size);
+
+ /* Do any machine/system dependent processing of the constant. */
+#ifdef ASM_DECLARE_CONSTANT_NAME
+ ASM_DECLARE_CONSTANT_NAME (asm_out_file, label, exp, size);
+#else
+ /* Standard thing is just output label for the constant. */
ASM_OUTPUT_LABEL (asm_out_file, label);
+#endif /* ASM_DECLARE_CONSTANT_NAME */
/* Output the value of EXP. */
- output_constant (exp,
- (TREE_CODE (exp) == STRING_CST
- ? MAX (TREE_STRING_LENGTH (exp),
- int_size_in_bytes (TREE_TYPE (exp)))
- : int_size_in_bytes (TREE_TYPE (exp))),
- align);
-
+ output_constant (exp, size, align);
}
/* A constant which was deferred in its original location has been