diff options
author | Steven Bosscher <steven@gcc.gnu.org> | 2012-06-19 20:44:47 +0000 |
---|---|---|
committer | Steven Bosscher <steven@gcc.gnu.org> | 2012-06-19 20:44:47 +0000 |
commit | 70f42967b3b48d63a8e90bd19b4277a64d6ccd21 (patch) | |
tree | 43b24c99ade8c59d05ac05d4aecbdd6ff2c2f406 /gcc/config/darwin-c.c | |
parent | c85fd25b17ae5b2150c71826b04ffb71045d1b28 (diff) | |
download | gcc-70f42967b3b48d63a8e90bd19b4277a64d6ccd21.zip gcc-70f42967b3b48d63a8e90bd19b4277a64d6ccd21.tar.gz gcc-70f42967b3b48d63a8e90bd19b4277a64d6ccd21.tar.bz2 |
tm.texi.in (TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE, [...]): Add @hooks.
gcc/
* doc/tm.texi.in (TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE,
TARGET_OBJC_DECLARE_CLASS_DEFINITION): Add @hooks.
(ASM_DECLARE_CLASS_REFERENCE, ASM_DECLARE_UNRESOLVED_REFERENCE):
Remove.
* doc/tm.texi: Regenerate.
* config/darwin.h (ASM_OUTPUT_LABELREF): Remove special case for
.objc_class_name_*.
* config/darwin-c.c: Include target.h.
(darwin_objc_declare_unresolved_class_reference): New function.
(darwin_objc_declare_class_definition): New function.
(TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE): Define.
(TARGET_OBJC_DECLARE_CLASS_DEFINITION): Define.
c-family/
* c-target.def (objc_declare_unresolved_class_reference,
objc_declare_class_definition): Add new hooks.
objc/
* objc-next-runtime-abi-01.c: Do not include tm.h and output.h.
Include c-family/c-target.h.
(handle_next_class_ref): Rewrite to emit top-level asm statements.
(handle_next_impent): Likewise.
* objc/Make-lang.in: Fix dependencies for objc-next-runtime-abi-01.o.
From-SVN: r188793
Diffstat (limited to 'gcc/config/darwin-c.c')
-rw-r--r-- | gcc/config/darwin-c.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c index 08de2f8..a642f66 100644 --- a/gcc/config/darwin-c.c +++ b/gcc/config/darwin-c.c @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3. If not see #include "tm.h" #include "cpplib.h" #include "tree.h" +#include "target.h" #include "incpath.h" #include "c-family/c-common.h" #include "c-family/c-pragma.h" @@ -36,6 +37,7 @@ along with GCC; see the file COPYING3. If not see #include "prefix.h" #include "c-family/c-target.h" #include "c-family/c-target-def.h" +#include "cgraph.h" /* Pragmas. */ @@ -711,13 +713,60 @@ EXPORTED_CONST format_kind_info darwin_additional_format_types[] = { } }; -#undef TARGET_HANDLE_C_OPTION + +/* Support routines to dump the class references for NeXT ABI v1, aka + 32-bits ObjC-2.0, as top-level asms. + The following two functions should only be called from + objc/objc-next-runtime-abi-01.c. */ + +static void +darwin_objc_declare_unresolved_class_reference (const char *name) +{ + const char *lazy_reference = ".lazy_reference\t"; + const char *hard_reference = ".reference\t"; + const char *reference = MACHOPIC_INDIRECT ? lazy_reference : hard_reference; + size_t len = strlen (reference) + strlen(name) + 2; + char *buf = (char *) alloca (len); + + gcc_checking_assert (!strncmp (name, ".objc_class_name_", 17)); + + snprintf (buf, len, "%s%s", reference, name); + add_asm_node (build_string (strlen (buf), buf)); +} + +static void +darwin_objc_declare_class_definition (const char *name) +{ + const char *xname = targetm.strip_name_encoding (name); + size_t len = strlen (xname) + 7 + 5; + char *buf = (char *) alloca (len); + + gcc_checking_assert (!strncmp (name, ".objc_class_name_", 17) + || !strncmp (name, "*.objc_category_name_", 21)); + + /* Mimic default_globalize_label. */ + snprintf (buf, len, ".globl\t%s", xname); + add_asm_node (build_string (strlen (buf), buf)); + + snprintf (buf, len, "%s = 0", xname); + add_asm_node (build_string (strlen (buf), buf)); +} + +#undef TARGET_HANDLE_C_OPTION #define TARGET_HANDLE_C_OPTION handle_c_option -#undef TARGET_OBJC_CONSTRUCT_STRING_OBJECT +#undef TARGET_OBJC_CONSTRUCT_STRING_OBJECT #define TARGET_OBJC_CONSTRUCT_STRING_OBJECT darwin_objc_construct_string -#undef TARGET_STRING_OBJECT_REF_TYPE_P +#undef TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE +#define TARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE \ + darwin_objc_declare_unresolved_class_reference + +#undef TARGET_OBJC_DECLARE_CLASS_DEFINITION +#define TARGET_OBJC_DECLARE_CLASS_DEFINITION \ + darwin_objc_declare_class_definition + +#undef TARGET_STRING_OBJECT_REF_TYPE_P #define TARGET_STRING_OBJECT_REF_TYPE_P darwin_cfstring_ref_p #undef TARGET_CHECK_STRING_OBJECT_FORMAT_ARG |