Comments (9)
Would it make sense ? Any comments ?
Gnulighting is an interesting project. I considered its usage about 2 years ago. IMHO using it would hurt generated code performance significantly. Two compiler optimizations giving the biggest performance gain are register allocation and code selection.
Lighting abstract machine model assumes only 6 general regs (for comparison optimizing compilers assumes infinite number of regs). The small number of general reg is a big constraint for effective using regs for most RISC architectures (usually they have 32 general regs) and even for x86-64 (16 regs).
Lighting insn model is RISC machine model which will hurt performance for x86-64 CISC which, for example, permits using memory for arithmetic insn even with an immediate in the insn.
In general my understanding is that gnu lighting mostly solves machine insn encoding problem and does it in a very fast way. Implementation of this is tedious and time consuming task. Still I managed to port MIR to aarch64 for 2 full weeks. So I don't think that encoding task will be a big obstacle for MIR.
Also another cons for me to use gnulighting were a license and big source code size mostly because of many targets it supports. I don't think some of these targets are important now.
I believe MIR could be used for dynamic recompilation too. For this only RA could be used. By the way I will add optimization levels to vary generation speed vs generated code performance. There is still probably a market niche for gnulighting because I see analogous approach in BPF very hyped these days.
from mir.
Also another cons for me to use gnulighting were a license and big source code size mostly because of many targets it supports. I don't think some of these targets are important now.
One of the greatest assets of MIR is that it is has MIT license, is small and self contained with zero external dependencies, and yet achieves great performance. This combination of features is so unique that I think nothing should be allowed to change it.
from mir.
OK, thanks for the detailed answer.
from mir.
Lighting abstract machine model assumes only 6 general regs (for comparison optimizing compilers assumes infinite number of regs). The small number of general reg is a big constraint for effective using regs for most RISC architectures (usually they have 32 general regs) and even for x86-64 (16 regs).
Lightning gives you at least 6 general regs. Most archs have more.
Lighting insn model is RISC machine model which will hurt performance for x86-64 CISC which, for example, permits using memory for arithmetic insn even with an immediate in the insn.
Yes, that's why you should have optimized code generators for the "important" archs like x86_64 and Aarch64. But for all the archs you're not going to bother writing a backend for, Lightning would be a good idea.
I believe MIR could be used for dynamic recompilation too.
I use Lightning in a dynarec I wrote for Playstation emulators: https://github.com/pcercuei/lightrec. Unless MIR can compile thousands of functions per second on a weak 1 GHz ARM SoC, then no, it cannot be used for dynamic recompilation.
from mir.
Lightning gives you at least 6 general regs. Most archs have more.
Sorry, I probably misread this. So if you use more regs than a target machine permits what will happen? As I understand gnulighting somehow dealing with this situation. Will it reject the program? Or this means that lighting has a RA? It could be primitive one (e.g. putting higher regs on a stack), but still RA.
I use Lightning in a dynarec I wrote for Playstation emulators: https://github.com/pcercuei/lightrec. Unless MIR can compile thousands of functions per second on a weak 1 GHz ARM SoC, then no, it cannot be used for dynamic recompilation.
Thank you for reference for your github project. I probably will work in this direction too although it would be less priority for me. MIR-generator would simplify the code, does RA (I can speed up it considerably decreasing RA quality, no big deal for me as I worked mostly in RA area for last 15 years) and encode the insns. In this pipeline I don't see a big difference with gnulighting so the speed can be close to gnulighting.
from mir.
Paul, sorry for bothering you. Looking at your litrec project, I see a lot of things (e.g. optimizations) you are doing by yourself besides using gnulighting. I am just curious, what % of CPU time gnulighting actually use in all you program work?
from mir.
Sorry, I probably misread this. So if you use more regs than a target machine permits what will happen? As I understand gnulighting somehow dealing with this situation. Will it reject the program? Or this means that lighting has a RA? It could be primitive one (e.g. putting higher regs on a stack), but still RA.
Basically you have between 3 and JIT_R_NUM caller-saved registers, and between 3 and JIT_V_NUM callee-saved registers. Treat them like regular hardware registers of a CPU: you still need a RA.
Paul, sorry for bothering you. Looking at your litrec project, I see a lot of things (e.g. optimizations) you are doing by yourself besides using gnulighting. I am just curious, what % of CPU time gnulighting actually use in all you program work?
I don't have any actual number at hand, but it's neglectible. The API functions listed in the manual are generally tiny wrappers. Lightning doesn't do any optimization whatsoever, which is perfect in my case since I recompile code that has been optimized by GCC in the first place (GCC2, but still).
from mir.
Basically you have between 3 and JIT_R_NUM caller-saved registers, and between 3 and JIT_V_NUM callee-saved registers. Treat them like regular hardware registers of a CPU: you still need a RA.
Thank you. I forgot all this about lighting. I only remember a general impression.
So basically it means lighting can not be used as machine-independent language and its user should treat this as real CPU and does some RA by himself. Or it can be used as machine-independent language but in this case only 6 regs can be used.
from mir.
Yes, exactly.
from mir.
Related Issues (20)
- Assertion failed: (0), function out_op, file mir2c.c, line 65 HOT 8
- Supplying custom allocation/deallocation routines HOT 2
- Building with zig and failing at runtime on `mir_hash_1` HOT 2
- Support for system calls? HOT 11
- Issue 361 test case failed HOT 2
- Shebang support for Mir files? HOT 13
- Awk has a syntax error in the benchmarks HOT 16
- Allow MIR text to be mixed in with C API
- Bug in mir-gen-x86_64.c on bbv branch HOT 3
- Add Apple Silicon CI support HOT 2
- Assertion error in 'process_aggregate_arg' for anonymous struct/union HOT 2
- Assertion error in 'get_uptodate_def_insn' relating to division by `sizeof(char)` HOT 3
- Please implement _Thread_local HOT 1
- CMake build broken with 9b7aa03 HOT 2
- Feature request: add debug info support?
- v1.0.0 Undefined function _MIR_name_char_p when #MIR_NO_SCAN is used HOT 2
- v1.0.0 Fails to compile C code HOT 6
- v1.0.0 causes crashes during execution HOT 30
- Inconsistent MIR_BFS results in interp and gen HOT 2
- Graceful crash handling?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mir.