3 ms·
I'm surprised the compiler goes straight to assembly, rather than targeting LLVM (most native programming languages) or C- (what GHC does/did)
by octo_t 13y ago
I'm surprised the compiler goes straight to assembly, rather than targeting LLVM (most native programming languages) or C- (what GHC does/did)
- tych0 13y agoWhy? Ocaml was around long before LLVM, and GHC has a mode where you can emit assembly (and one where you can emit LLVM as well).
- deleted 13y ago[deleted]
- omaranto 13y agoMost compilers target LLVM? That doesn't sound right. Maybe most compilers written in the last five years or so.
- rwmj 13y agoThere's an OCaml LLVM backend [1]. The author found a number of issues with LLVM [2] although this could be overcome. The real problem is that the low-level object format is completely different which would break all OCaml extensions written in C (eg. any extension that links to an external C library). Plus the current code generators are really fast and cover all common architectures anyway so there's not much point. [1] https://github.com/colinbenner/ocamlllvm https://github.com/colinbenner/ocamlllvm [2] http://oud.ocaml.org/2012/abstracts/oud2012-paper7.pdf http://oud.ocaml.org/2012/abstracts/oud2012-paper7.pdf
- profquail 13y agoFYI, it's C-- (not C-): https://en.wikipedia.org/wiki/C-- https://en.wikipedia.org/wiki/C--
- masklinn 13y ago> I'm surprised the compiler goes straight to assembly, rather than targeting LLVM (most native programming languages) Most native programming languages historically don't, and OCaml predates LLVM by a good 7 years. > or C- (what GHC does/did) Cmm is an intermediate language specific to GHC before the backend[1], GHC's default backend is a native generator. [1] or more precisely "an other" intermediate language, since there's also Core.
- freyrs3 13y ago> , rather than targeting LLVM (most native programming languages) Native languages targeting LLVM are the exception not the norm. The vast majority of native compilers do emit assembly. [1] http://llvm.org/ProjectsWithLLVM/ http://llvm.org/ProjectsWithLLVM/
- MostAwesomeDude 13y agoYou might be surprised to learn that there are languages that are agnostic in what they target.
- kenko 13y agoWhy? Going to llvm constrains you to do llvm's models. (Also, the timing issue mentioned by a sibling.)