[cfe-dev] Advice for front-end design?

Russell Wallace via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 18 16:34:51 PDT 2015

Doing something a bit different and still figuring all this out myself, but
thus far I've reached the following front-end-relevant conclusions:

http://llvm.org/docs/ProgrammersManual.html is a good starting point; it
discusses a number of useful facilities and guidelines.

Read source files with MemoryBuffer::getFileOrSTDIN(Filename)

Write a recursive descent parser for your language by hand; in my
experience, other ways of doing parsers are not worth the added complexity.

The clang way of reporting error messages is nice from the user's
perspective, and probably worth trying to pick up. Not sure how to do that
yet but http://clang.llvm.org/doxygen/classclang_1_1SourceLocation.html
seems potentially relevant.

In my opinion, an automatic formatting tool is an essential productivity
tool nowadays. If the syntax of your language is at all similar to the C
family, consider forking clang-format.

For how to run optimisation passes, ignore what the tutorial says about
that and look instead at opt.cpp

On Fri, Sep 18, 2015 at 6:36 AM, Joachim Durchholz via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi all,
> I'm starting work on a new language (not going to make excuses for that),
> and my initial plan was to use LLVM as backend.
> Looking at the Kaleidoscope tutorial, I found that LLVM-as-backend makes
> no attempt at supporting the frontend side (d'oh); in particular, it
> doesn't offern patterns or best practices for organizing things like input
> stream handling, line/column number bookkeeping, or error message
> generation.
> Would it make sense to turn to clang for that?
> If yes, where should I start reading?
> Regards,
> Jo
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150919/56c82f50/attachment.html>

More information about the cfe-dev mailing list