[cfe-dev] How to extend Internal C representation

steve naroff snaroff at apple.com
Mon Mar 16 18:12:20 PDT 2009


On Mar 16, 2009, at 8:35 PM, André Ferreira Bem Silva wrote:

> Dear Clang developers,
>
> I'm André and I'm a college student from Brazil, UFSC (Santa  
> Catarina Federal University) and in my work of graduation conclusion  
> I pretend to do a C extension for parallelism and game programming.  
> What I would like to know is which classes and documentation would  
> be more suitable to read for accomplishing that, i.e, what tips can  
> you give me if I'm to use Clang as a the base of my implementation.  
> I prefer that rather than using gcc C frontend for obvious reasons  
> (antiquate code and logarithmical learning curve) and the use of an  
> automatic parser generation tool like YACC/FLEX doesn't seem fine  
> since I don't want to do a compiler frontend and backend from  
> scratch. LLVM and Clang seem like my best shot for an innovative and  
> interesting work.
>

Thanks for your interest in using clang for your work. Here are some  
brief comments...

Many language extensions require adding a new type. As a result, it  
might be useful for you to look at existing extensions to the C type  
system. See AST nodes VectorType and ExtVectorType for a couple fairly  
small, self-contained examples.

If you plan on adding new declaration constructs, you can look at the  
"DeclObjC.h" header for many examples. Adding Types/Decls are usually  
more complex than adding Stmts/Exprs.

I also recommend looking at how we added "Blocks" to C. The AST nodes  
are BlockPointerType, BlockDecl, BlockExpr, and BlockDeclRefExpr.

See http://clang.llvm.org/docs/LanguageExtensions.html for more info...

Regards,

snaroff

> Thanks for your atention.
>
> Atentiously,
>
> -- 
> André Ferreira Bem Silva
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list