2

How is native code generated using llvm?

If it is possible, can it be done using a Haskell binding?

upd: I mean generate code not in memory, I mean how to generate code and for example save it to file.

1 Answer 1

10

LLVM is a compiler infrastructure that generates native code by processing its internal language — produced by compilers as textual source or an in-memory representation — through a wide variety of optimisations and transformations before converting and linking it into the final native code. So, yes, LLVM can generate native code; in fact, that's its primary purpose.

There is a binding to the LLVM library for Haskell. You can produce LLVM bitcode files with writeBitcodeToFile; llvm-ld can then link those into native code.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.