www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - LLVM is written in C++ ?

reply Jakob Jenkov <jakob jenkov.com> writes:
Hi,

I have a background in Java, so please forgive me for not knowing 
this:

Is LLVM written in C++ ? If I was to use LLVM e.g. for an LLVM 
based D compiler (you already made one, I know), would my code 
have to be C++ ?

I looked at the LLVM project shortly, and it looks really 
interesting, even though I don't understand it all at this point.

 From what I gather, you can compile any language to the LLVM 
assembly language, and then compile the LLVM assembly language to 
any platform after that (using standard compilers). Is that 
correct?
Dec 16 2015
next sibling parent Stefan Koch <uplink.coder googlemail.com> writes:
On Wednesday, 16 December 2015 at 09:27:54 UTC, Jakob Jenkov 
wrote:
 Hi,

 I have a background in Java, so please forgive me for not 
 knowing this:

 Is LLVM written in C++ ? If I was to use LLVM e.g. for an LLVM 
 based D compiler (you already made one, I know), would my code 
 have to be C++ ?

 I looked at the LLVM project shortly, and it looks really 
 interesting, even though I don't understand it all at this 
 point.

 From what I gather, you can compile any language to the LLVM 
 assembly language, and then compile the LLVM assembly language 
 to any platform after that (using standard compilers). Is that 
 correct?
Yes llvm is wirtten in c++. And yes you can compile any programming language to llvm ir.
Dec 16 2015
prev sibling next sibling parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= writes:
On Wednesday, 16 December 2015 at 09:27:54 UTC, Jakob Jenkov 
wrote:
 Is LLVM written in C++ ? If I was to use LLVM e.g. for an LLVM 
 based D compiler (you already made one, I know), would my code 
 have to be C++ ?
You might want to take a look at: https://github.com/SDC-Developers/SDC
 From what I gather, you can compile any language to the LLVM 
 assembly language, and then compile the LLVM assembly language 
 to any platform after that (using standard compilers). Is that 
 correct?
LLVM is geared towards C-like languages. It has added some adjustments to enable compilation for specific non-C languages, like special calling conventions. But it isn't suitable for all kinds of language semantics, no.
Dec 16 2015
parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Wednesday, 16 December 2015 at 12:22:30 UTC, Ola Fosheim 
Grøstad wrote:
 LLVM is geared towards C-like languages. It has added some 
 adjustments to enable compilation for specific non-C languages, 
 like special calling conventions. But it isn't suitable for all 
 kinds of language semantics, no.
LLVM IR is just like assembly ... If your language compiles to machine code as it must one way or the other you can compile it to llvm-ir
Dec 16 2015
parent Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= writes:
On Wednesday, 16 December 2015 at 12:31:01 UTC, Stefan Koch wrote:
 LLVM IR is just like assembly ... If your language compiles to 
 machine code as it must one way or the other you can compile it 
 to llvm-ir
LLVM IR is not just like assembly. It has builtin semantics geared towards specific languages.
Dec 16 2015
prev sibling parent Kai Nacke <kai redstar.de> writes:
On Wednesday, 16 December 2015 at 09:27:54 UTC, Jakob Jenkov 
wrote:
 Hi,

 I have a background in Java, so please forgive me for not 
 knowing this:

 Is LLVM written in C++ ? If I was to use LLVM e.g. for an LLVM 
 based D compiler (you already made one, I know), would my code 
 have to be C++ ?

 I looked at the LLVM project shortly, and it looks really 
 interesting, even though I don't understand it all at this 
 point.

 From what I gather, you can compile any language to the LLVM 
 assembly language, and then compile the LLVM assembly language 
 to any platform after that (using standard compilers). Is that 
 correct?
Hi! If you are using Java you may have a look at this article: https://theantlrguy.atlassian.net/wiki/display/ANTLR3/LLVM A possibility not yet mentioned is that LLVM also has a C interface. You can create JNI bindings for it. Not sure if somebody has already done it. Regards, Kai
Dec 16 2015