aboutsummaryrefslogtreecommitdiff
path: root/gcc/objc/objc-act.c
diff options
context:
space:
mode:
authorIain Sandoe <iains@gcc.gnu.org>2010-10-22 10:28:57 +0000
committerIain Sandoe <iains@gcc.gnu.org>2010-10-22 10:28:57 +0000
commit2670598830de0d9a1a65724d15dd428eae38e6f2 (patch)
tree930cb5a100d0242c1b4f82c25d186b96318cd1a6 /gcc/objc/objc-act.c
parent5e5db3b4b48ede7d0d1815ec2126b669affeda96 (diff)
downloadgcc-2670598830de0d9a1a65724d15dd428eae38e6f2.zip
gcc-2670598830de0d9a1a65724d15dd428eae38e6f2.tar.gz
gcc-2670598830de0d9a1a65724d15dd428eae38e6f2.tar.bz2
CFStrings for Darwin.
gcc: Based on the CFString implementation in FSF apple/trunk branch. * target.def (objc_construct_string): New Hook. * doc/tm.texi (objc_construct_string): Document. * doc/tm.texi.in (TARGET_OBJC_CONSTRUCT_STRING): New. * config/t-darwin: Amend build rules for darwin.o. * config/darwin.opt: Add cfstrings flags. * config/darwin-c.c: Define __CONSTANT_CFSTRINGS__. (darwin_objc_construct_string): New. * config/i386/darwin.h (SUBTARGET_INIT_BUILTINS): Define. * config/i386/i386.c (ix86_init_builtins): Add SUBTARGET_INIT_BUILTINS. * config/darwin-protos.h (darwin_init_cfstring_builtins): New prototype. (darwin_fold_builtin): Likewise. (darwin_build_constant_cfstring): Likewise. (darwin_objc_construct_string): Likewise. (darwin_cfstring_p): Likewise. (darwin_enter_string_into_cfstring_table): Likewise. * config/rs6000/darwin.h (SUBTARGET_INIT_BUILTINS) Update for CFString. * config/darwin.c (darwin_running_cxx): New var. (machopic_select_section): Return cfstring_constant_object_section. (darwin_override_options): Set darwin_running_cxx. (add_builtin_field_decl): New. (darwin_init_cfstring_builtins): New. (darwin_build_constant_cfstring): New. (darwin_fold_builtin): New. (cfstring_hash): New. (cfstring_eq): New. (darwin_enter_string_into_cfstring_table): New. * config/darwin-sections.def (cfstring_constant_object_section): New. * config/darwin.h (TARGET_FOLD_BUILTIN): Define. (TARGET_OBJC_CONSTRUCT_STRING): Define. gcc/objc: Based on the CFString implementation in FSF apple/trunk branch. * objc/objc-act.c (objc_build_string_object): Handle CFStrings. From-SVN: r165820
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r--gcc/objc/objc-act.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index f2ec895..bc07910 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -2576,7 +2576,7 @@ string_eq (const void *ptr1, const void *ptr2)
tree
objc_build_string_object (tree string)
{
- tree constructor = NULL_TREE, constant_string_class;
+ tree constant_string_class;
int length;
tree fields, addr;
struct string_descriptor *desc, key;
@@ -2587,6 +2587,17 @@ objc_build_string_object (tree string)
TREE_SET_CODE (string, STRING_CST);
length = TREE_STRING_LENGTH (string) - 1;
+ /* The target may have different ideas on how to construct an ObjC string
+ literal. On Darwin (Mac OS X), for example, we may wish to obtain a
+ constant CFString reference instead.
+ At present, this is only supported for the NeXT runtime. */
+ if (flag_next_runtime && targetcm.objc_construct_string)
+ {
+ tree constructor = (*targetcm.objc_construct_string) (string);
+ if (constructor)
+ return build1 (NOP_EXPR, objc_object_type, constructor);
+ }
+
/* Check whether the string class being used actually exists and has the
correct ivar layout. */
if (!string_layout_checked)
@@ -2626,7 +2637,7 @@ objc_build_string_object (tree string)
if (!desc)
{
- tree var;
+ tree var, constructor;
VEC(constructor_elt,gc) *v = NULL;
*loc = desc = ggc_alloc_string_descriptor ();
desc->literal = string;