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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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-ldcan then link those into native code.