   What to export for a hobby compiler?
  So, I want to play around building a mini-hobby compiler. The parser I can handle (though I might favor a library for that! suggestions?) however, what to export? Machine code? Sounds difficult and inflexible. ASM code? Is okay, but would limit myself to certain CPU families (unless I export multiple kinds of ASM, depending the demand...but it's only a hobby compiler :O). C code? Could do, but I rather would like to dive a little deeper and not be limited to C.Is there anything in between C and ASM I could export? Something like an intermediate file? What is it anyways? Or is ASM my best bet?Thanks!   
  * llvm intermediate code* high level assembler (though that's machine dependent again)   ;  Target a virual machine like LLVM, Java VM, Parrot, .NET CLR,...   ;  Okay thanks.I do want to get a system dependent executable in the end of course, but that I would get after compiling the LLVM sources on a specific platform?   ;  +1 on exporting MSIL and targeting the .NET runtime... make a net .NET language!Potentially useful clickies:MS overviewBF.NET - brainf***k compiler for MSILNice intro to hacking around with MSIL[Edited by - IainC on June 10, 2009 9:09:55 AM];Quote:Original post by DecriusOkay thanks.I do want to get a system dependent executable in the end of course, but that I would get after compiling the LLVM sources on a specific platform?Native code, and tons of optimisations for free. The LLVM machine is, unlike .net or Java VM, not intended to provide full platform independence, but to provide the best optimisations for the target machine, i.e. target machine adaption, lifelong optimization, and (not implemented yet) offline optimization (that means: intense optimisation when the machine is idling). On the other hand, you can use LLVM to provide native performance scripting functionality for your applications. E.g., I plan to use LLVM for a shader system for picogen, a full software ray tracer.One big plus of LLVM is that it only has roughly 30 instructions, afair. Basically, you build an abstract syntax tree, upon which LLVM will do his work. So, compared to Java VM and .net, it's damn easy to implement, plus, as said, you get native performance and a plethora of optimisation passes for free.   ;Quote:Original post by phresnelQuote:Original post by DecriusOkay thanks.I do want to get a system dependent executable in the end of course, but that I would get after compiling the LLVM sources on a specific platform?Native code, and tons of optimisations for free. The LLVM machine is, unlike .net or Java VM, not intended to provide full platform independence, but to provide the best optimisations for the target machine, i.e. target machine adaption, lifelong optimization, and (not implemented yet) offline optimization (that means: intense optimisation when the machine is idling). On the other hand, you can use LLVM to provide native performance scripting functionality for your applications. E.g., I plan to use LLVM for a shader system for picogen, a full software ray tracer.One big plus of LLVM is that it only has roughly 30 instructions, afair. Basically, you build an abstract syntax tree, upon which LLVM will do his work. So, compared to Java VM and .net, it's damn easy to implement, plus, as said, you get native performance and a plethora of optimisation passes for free.Sounds interesting, and with native code you mean an executable specifically for that certain platform? And would it be build by the developer, or do users automatically let it compile for their system (does the developer have to distribute executables for every platform, or just the LLVM script?)?   ;  It can generate native, executable code that runs straight on the metal.  You don't need to distribute llvm with your code to get it to run your code that was compiled with llvm.  On that note, llvm natively handles C and C++.  In other words, if you are looking to make a LANGUAGE, then you need to be concerned with translating into LLVM.  If you're looking to make a COMPILER, then LLVM is kind of redundant, as LLVM is a compiler.If instead you are looking to make a COMPILER PASS, aka an optimization, then LLVM is likely pretty close to spot on what you're looking for [especially considering MS's Pheonix has just been sitting there for about a year].It can also run in a JIT compiled mode, in which case you would have to distribute the LLVM JIT.  It can be used for both purposes.   ;  If you want, think about LLVM as an optimizing assembler. Check this beginners tutorial on LVM, it just uses the online llvm compiler.So you just create llvm assembly, then llvm will optimize it and spit out the relevant x86/whatever optimized assembly, then you can create an executable out of it with GCC/whatever.clang is the name of the llvm C compiler.   ;  Thanks guys, sounds like exactly what I need! ;-) And yes, looking to make a language :)   