PATCH: Fix ObjC @"string" machinery

Ziemowit Laski zlaski@apple.com
Tue Jun 28 01:47:00 GMT 2005


On 27 Jun 2005, at 12.46, Richard Henderson wrote:

> On Mon, Jun 27, 2005 at 12:35:33PM -0700, Ziemowit Laski wrote:
>> At this point, I'm leaning toward using a lang_hook (as Stan and David
>> Ayers have suggested).  Would that approach be acceptable, or do you
>> have other ideas?
>
> I guess I don't understand the problem then.  Lemme see your solution.

Basically, I'd like to add a couple of target hooks as shown below.  
After
a patch like this goes in, 'flag_next_runtime' shall be renamed 
throughout
to refer to 'targetm.objc.next_runtime' (with c.opt mods as necessary).
And after that, I'll reintroduce the patch first proposed here

    http://gcc.gnu.org/ml/gcc-patches/2005-06/msg01751.html

except that 'flag_next_runtime' will now be replaced with 
'targetm.objc.next_runtime',
so that non-C-ish front-ends will work.

How does this sound?

--Zem


Index: gcc/target-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.127
diff -u -3 -p -r1.127 target-def.h
--- gcc/target-def.h    27 Jun 2005 07:41:03 -0000      1.127
+++ gcc/target-def.h    28 Jun 2005 01:26:59 -0000
@@ -509,6 +509,21 @@ Foundation, 51 Franklin Street, Fifth Fl
      TARGET_CXX_USE_AEABI_ATEXIT                        \
    }

+/* Specific to Objective-C and Objective-C++.  */
+#ifndef TARGET_OBJC_BUILD_STRING_LITERAL
+#define TARGET_OBJC_BUILD_STRING_LITERAL 0
+#endif
+
+#ifndef TARGET_OBJC_NEXT_RUNTIME
+#define TARGET_OBJC_NEXT_RUNTIME 0
+#endif
+
+#define TARGET_OBJC                            \
+  {                                            \
+    TARGET_OBJC_BUILD_STRING_LITERAL,          \
+    TARGET_OBJC_NEXT_RUNTIME                   \
+  }
+
  /* The whole shebang.  */
  #define TARGET_INITIALIZER                     \
  {                                              \
@@ -572,6 +587,7 @@ Foundation, 51 Franklin Street, Fifth Fl
    TARGET_INVALID_WITHIN_DOLOOP,                        \
    TARGET_CALLS,                                        \
    TARGET_CXX,                                  \
+  TARGET_OBJC,                                 \
    TARGET_HAVE_NAMED_SECTIONS,                  \
    TARGET_HAVE_CTORS_DTORS,                     \
    TARGET_HAVE_TLS,                             \
Index: gcc/target.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target.h,v
retrieving revision 1.139
diff -u -3 -p -r1.139 target.h
--- gcc/target.h        27 Jun 2005 07:41:04 -0000      1.139
+++ gcc/target.h        28 Jun 2005 01:26:59 -0000
@@ -635,6 +635,20 @@ struct gcc_target
      bool (*use_aeabi_atexit) (void);
    } cxx;

+  /* Target hooks specific to Objective-C and Objective-C++.  */
+  struct objc
+  {
+    /* Given a STRING_CST, return a reference to an Objective-C
+       @"string" literal.  If this function returns NULL, the
+       default Objective-C string construction methodology will
+       be used instead.  */
+    tree (*build_string_literal) (tree);
+
+    /* If true, generate code for the NeXT (Apple) runtime instead
+       of the GNU runtime.  */
+    bool next_runtime;
+  } objc;
+
    /* Leave the boolean fields at the end.  */

    /* True if arbitrary sections are supported.  */

--------------------------------------------------------------
Ziemowit Laski                 1 Infinite Loop, MS 301-2K
Mac OS X Compiler Group        Cupertino, CA USA  95014-2083
Apple Computer, Inc.           +1.408.974.6229  Fax .5477



More information about the Gcc-patches mailing list