writing llvm ir not in c++

Is it possible to write LLVM IR but not using C++?

I’m exceedingly terrible at C++.

I was thinking, isn’t it possible to write the IR using Java? I effectively have emit some sort of binary op codes to be passed into llvm right?

The same thing for if I wanted to integrate a GC? Could the interfacing be done in any other language?

Is it possible to write LLVM IR but not using C++?

I'm exceedingly terrible at C++.

I was thinking, isn't it possible to write the IR using Java?

You can use llvmpy (Python bindings to LLVM) to create LLVM IR modules, if
you'd like. [http://www.llvmpy.org/]

I effectively have emit some sort of binary op codes to be passed into
llvm right?

Not sure what you're asking here, can you clarify?

Eli

You can write LLVM IR by hand as far as that is concerned …

If you mean generating IR automatically from a program written in some language you need to use a compiler frontend based on LLVM and emit IR instead of going further with the compilation.
Most of the frontends for LLVM target C like languages, but with Dragonegg you could use some of the GCC frontends to start from something else.

I know that Dragonegg supports Go and not so complex java programs

Marcello

Got it. That’s much better than C++!

I think you answered my question by pointing to llvmpy about the opcode part.

Thanks!

Is it possible to write LLVM IR but not using C++?

I'm exceedingly terrible at C++.

I was thinking, isn't it possible to write the IR using Java?

You can use llvmpy (Python bindings to LLVM) to create LLVM IR modules, if
you'd like. [http://www.llvmpy.org/]

LLVM also has C bindings. I'm not aware of a tutorial specifically for these
bindings, but a great reference for things along the line of "how do use LLVM as
my language's backend" is the Kaleidoscope tutorial:
http://llvm.org/docs/tutorial/ (which has guides for both OCaml and C++).

Cheers,

Jon

Ah ok. I should check that out.

My first time implementing something like this, so apologies if this is an obvious question – but why is that JIT and GC go hand-in-hand? I’m trying to think what is the relationship between converting source code to LLVM IR, that if I want it be like Java or even more dynamic typing sorts – what is the rationale that a GC is required. And that somehow JIT and GC are related in this.

Would love to know if I could pick up these concepts somewhere.

Ah ok. I should check that out.

My first time implementing something like this, so apologies if this is an
obvious question -- but why is that JIT and GC go hand-in-hand? I'm trying
to think what is the relationship between converting source code to LLVM
IR, that if I want it be like Java or even more dynamic typing sorts --
what is the rationale that a GC is required. And that somehow JIT and GC
are related in this.

It depends on the features of the language you're trying to implement. GC is
needed when the language has automatic memory management (i.e. you don't see
delete/free in java/python/lisp, but you do see them in C++/C), whereas JIT is
desired in places where the compiler can do a better job if you give it more
information at runtime (things that are not available statically at compile
time).... You'll often see JIT and GC together because languages happen to
have features that make having both desirable, but that does not imply that one
/necessitates/ the other.

Would love to know if I could pick up these concepts somewhere.

Hmm. Can't think of one single reference off the top of my head.

Cheers,

Jon