[cfe-dev] Extending Clang with new keywords

Richard Smith via cfe-dev cfe-dev at lists.llvm.org
Thu Apr 28 16:08:03 PDT 2016


On Wed, Apr 27, 2016 at 6:08 AM, kuebler via cfe-dev <cfe-dev at lists.llvm.org
> wrote:

> Hi,
> my name is Timo and I am part of a project group at the University of
> Paderborn (Germany). The goal of our pg is to create an approximate cpu. We
> currently trying to extend Clang with some new keywords. Our idea is to
> introduce some keywords, so that Clang produces new LLVM IR Code (our
> approximate instructions).
>
> We tried to add keyword to Tokenkinds.def, but we have not really an idea
> to go on from there?
>
> Where else are changes needed to get an AST Node and transform it later to
> LLVM IR?


The first thing to decide is whether you really need new keywords at all.
We typically expose custom machine instructions as builtin functions, not
with keywords, and doing so is much simpler than adding new keywords,
grammar productions, AST nodes, semantic analysis and so on.

However, if you really do want to add new keywords and syntax, you should
read
http://clang.llvm.org/docs/InternalsManual.html#how-to-add-an-expression-or-statement
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160428/cde97ef4/attachment.html>


More information about the cfe-dev mailing list