开发者

Is there a way to write an LLVM front end compiler in C#? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focus开发者_如何学JAVAes on one problem only by editing this post.

Closed 5 years ago.

Improve this question

Is there a way to write an LLVM front end compiler in C#?


I don't see why not. There is a language reference for LLVM and as long as you are compliant with the language, there is no reason you can't write something in C# which will parse that language and either:

  • Produce output based on the language (like a real-time interpreter)
  • Create an assembly in C# which will execute the LLVM instructions

This isn't to say it will be easy, but it can be done.


There are two ways. You could P/Invoke LLVM's C bindings (more than enough for implementing a compiler backend), or you could write your own wrapper with C++/CLI.

I used Clang-generated XML AST dump for LLVM's C bindings headers to generate .NET bindings for them automatically. But it is not possible to do it any longer, as XML AST printer had been removed from Clang, with no replacement available.


If you are looking to have a LLVM compiler FOR C#, Mono 2.6 can use LLVM

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜