Hello,
I ask this for a future direction of the Cosmos project.
I wonder =>
Why don't you use clang / LLVM-IR as intermediate code.
eg.
https://llvm.org/docs/BitCodeFormat.html#encoding-of-llvm-ir,
https://llvm.org/docs/tutorial/LangImpl03.html
https://github.com/dotnet/corert/blob/master/Documentation/intro-to-corert.md
Benefits:
support groups/ tools.
ARM processor
Related topics: https://github.com/CosmosOS/Cosmos/issues/316
we would not use clang as we use managed languages and a Small bit of X# and ASM
I mean
C# => Roslyn-to-cpp/clang => LLVM-IR => ASM.
or
C# => MSIL => LLVM-IR => ASM.
The compilation is IL -> ASM, so the only option would be the second one, but we would need to write a MSIL -> LLVM IR compiler, and we would have to run unmanaged code to compile LLVM IR to assembly, or write our own compiler, and both options are bad.
C# => MSIL => LLVM-IR => ASM.
MSIL => LLVM-IR
I think there are some tools that can convert from IL to LLVM-IR.
LLVM IR is a text file.
It has a nice lang reference.
so => a pure C# program to convert IL to _that_ text file is not too hard.
(like you convert IL to NASM code).
LLVM-IR => ASM
Yes, this _last_ step need to run an unmanaged program.
but this step is similar to using NASM to convert .asm to real ASM ?
From an IL standpoint, LLVM only complicates our toolchain. While LLVM can compile byte code etc, its really more suited to lexical languages. Many of its features make no sense when compiling byte code. It also would severely limit and complicate our future plans.
Does .NET use LLVM to compile IL? Not that I know of... and likely for the same reason.
LLVM-IR => ASM
Yes, this _last_ step need to run an unmanaged program.
But weighting between 'good' and 'bad', I think we have a good list more than a bad list.
a good list => eg...
1) Support tools/ dev groups.
2) Code optimization. =>like those C app
3) Cross platform. => esp run on ARM, Cosmos runs an Iot :)
Does .NET use LLVM to compile IL? Not that I know of... and likely for the same reason.
similar project from MS =>https://github.com/dotnet/llilc
The .NET compiler does not use LLVM that I know of. Just because it CAN be done doesn't mean its a good choice and MS has chosen not to use LLVM likely for similar reasons.
And it won't help with the native code that will still be needed. IL is designed to be just a step above assembly for easy and fast translation.
Adding LLVM into this step is like buying an airline ticket to go get bread.
OK.
And what about
2) Code optimization and
3) Cross platform
What do you think about it?
Code optimization of course is on our list, but at this stage as we are still developing so many core bases that we are building a refspec which outputs clear, easy to debug code. We have already done tests years ago and can output code that runs even faster than .NET on Windows or other because we can alter the calling and other conventions at will.
Cross Platform is easy - its just a matter of resources. We have limited resources and have more urgent tasks.
Thank you for your information :)
I will ask you later if I have more questions
Most helpful comment
Code optimization of course is on our list, but at this stage as we are still developing so many core bases that we are building a refspec which outputs clear, easy to debug code. We have already done tests years ago and can output code that runs even faster than .NET on Windows or other because we can alter the calling and other conventions at will.
Cross Platform is easy - its just a matter of resources. We have limited resources and have more urgent tasks.