[cfe-dev] Objective-C Code Generation
Chris Lattner
clattner at apple.com
Sat Feb 23 11:06:40 PST 2008
On Feb 23, 2008, at 9:55 AM, David Chisnall wrote:
> I'm interested in working on Objective-C code generation for the GNU
> and Étoilé Objective-C runtimes (I've worked on the former and wrote
> the latter).
Great!
> I imagine the easiest way of getting this working is to
> transform the Objective-C AST into a pure-C AST with calls to the
> relevant runtime libraries.
This is the way that GCC works, but I don't think it is really the
best way. I'd much rather have the clang codegen module directly
produce the LLVM IR for the constructs it needs. I don't anticipate
that this will be a problem for metadata or other objc constructs.
This does require an understanding of the LLVM IR, but it is well
documented, and there are lots of examples. If you get stuck, please
ask on this list, we'd be happy to help.
> Presumably someone at Apple will want to add support for their runtime
> libraries as well at some point, so having a clean interface to allow
> easily switching between the three is going to be important (rather
> than the 10,000 lines of runtime-specific, unreadable, code in GCC).
Yes, absolutely :)
> Are there any existing hooks for inserting this abstraction layer? If
> so, can someone point me in the right direction, and if not can
> someone suggest a good place to put them?
At this point, I'd suggest starting with the simple constructs (e.g.
the stand alone objc expressions like @"foo", add pointers to
interfaces, etc) and then move on the metadata. If you do each patch
cleanly and incrementally I don't expect a big problem. When we start
on codegen support for the next runtime, we can generalize the code
and figure out what abstractions are best on a case-by-case basis.
-Chris
More information about the cfe-dev
mailing list