[LLVMdev] gerate LLVM IR from an AST output from ANTLR

607 views
Skip to first unread message

emily thomas

unread,
Aug 14, 2013, 3:31:53 PM8/14/13
to llv...@cs.uiuc.edu
Hi,
I am a complete newbie to LLVM. I have an ANTLR parser, that outputs an AST. I want to comvert this AST to a LLVM IR,  Can someone point me some relevant documentation/examples/ etc. on how to go about doing this?
TIA.
 

Eli Friedman

unread,
Aug 14, 2013, 3:36:58 PM8/14/13
to emily thomas, LLVM Developers Mailing List

emily thomas

unread,
Aug 15, 2013, 10:07:55 AM8/15/13
to Eli Friedman, LLVM Developers Mailing List
Thanks. So, in this tutorial, the LLVM IR generation code is embedded in the parser. I already have an AST, and if I dont want to touch the parser code, is there a way to generate the IR? or do I just walk the tree and generate the iR?

Tim Northover

unread,
Aug 15, 2013, 10:25:35 AM8/15/13
to emily thomas, LLVM Developers Mailing List
Hi Emily,

> So, in this tutorial, the LLVM IR generation code is embedded in the parser.

It's embedded in the AST classes, but the parser itself doesn't know
anything about it. It's still a two-stage process: create AST, then
generate code from it.

It looks like ANTLR would allow you to change the AST to one with
similar abilities, but I can see why you might not want to.

> or do I just walk the tree and generate the iR?

That seems like the only option to me. Nothing inside LLVM is going to
know about the intended semantics of your AST.

Cheers.

Tim.
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply all
Reply to author
Forward
0 new messages