Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

llvm

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

like image 339
Alon Gubkin Avatar asked Aug 24 '10 17:08

Alon Gubkin


People also ask

Is LLVM written in C?

LLVM is written in C++ and is designed for compile-time, link-time, run-time, and "idle-time" optimization.

Does C compile to LLVM?

C-like languages use the Clang front end. This component compiles C, C++, Objective C, and Objective C++ code into LLVM bitcode – and from there into object files, using LLVM.

Can GCC compile LLVM?

The llvm-gcc command is the LLVM C front end. It is a modified version of gcc that compiles C/ObjC programs into native objects, LLVM bitcode or LLVM assembly language, depending upon the options. By default, llvm-gcc compiles to native objects just like GCC does.

Does Clang support C?

If you are looking for source analysis or source-to-source transformation tools, Clang is probably a great solution for you. Clang supports C++11, C++14 and C++17, please see the C++ status page for more information.


1 Answers

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.

like image 151
casperOne Avatar answered Oct 11 '22 11:10

casperOne