Skip to content

Commit 48d7ffa

Browse files
committed
Add license and README
1 parent 81d758e commit 48d7ffa

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Noam Raz
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Spidir
2+
3+
WIP JIT library written in Rust with the following goals:
4+
5+
- Embeddability: Spidir is completely freestanding and requires only a memory allocator
6+
- Simple C API: The intended way to embed/consume Spidir, though the unstable internal Rust APIs can be used as well
7+
- Reasonable optimization quality: Higher-level language runtimes using Spidir as a backend should eventually be able to expect decent codegen
8+
9+
Spidir was originally created for use in [TomatoDotNet](https://github.com/TomatOrg/TomatoDotNet/), so feature development is guided primarily by the needs of that project.
10+
11+
## Using Spidir
12+
13+
See the `c-api-tests` directory for example programs embedding the C API.
14+
15+
All important functionality is exposed via the CLI binary `spidirtool`, which can be used to:
16+
17+
- Graph the IR using graphviz
18+
- Inspect internal state
19+
- Generate/execute code for a given IR module
20+
21+
See
22+
23+
```
24+
cargo run -p spidirtool help
25+
```
26+
27+
for more information.
28+
29+
## IR
30+
31+
Spidir uses two intermediate representations internally:
32+
33+
- Spidir: target-independent IR for high-level optimizations
34+
- SSA-based sea-of-nodes representation
35+
- Uses phi nodes to model dataflow merges (easier to integrate in a sea-of-nodes setup)
36+
- LIR (linear IR): target-dependent IR used after instruction selection
37+
- Flat list of instructions with CFG information stored separately
38+
- Still in SSA form, but uses block parameters instead of phi nodes (more elegant for block-based IRs)
39+
- Used by register allocator and final code emission
40+
41+
These are abstracted away by the C construction API, which provides a simple block-based facade over the sea-of-nodes graph.
42+
43+
## Implementation Status
44+
45+
### Implemented
46+
47+
- Miscellaneous:
48+
49+
- C bindings: IR construction/dumping/optimization/codegen
50+
- IR text format/parser for testing and debugging
51+
- IR verifier
52+
53+
- IR features:
54+
55+
- Basic integer arithmetic/bitwise instructions
56+
- Loads/stores
57+
- Basic control flow (conditional branches)
58+
- Internal/external/indirect calls
59+
- External functions
60+
- Stack slots
61+
62+
- Codegen:
63+
64+
- Basic x64 backend
65+
- Hopefully-intelligent register allocator
66+
- Live range splitting
67+
- Rematerialization
68+
- Symbolic verifier
69+
70+
- Optimization:
71+
72+
- Global code motion
73+
- Simple canonicalization/GVN
74+
75+
### Planned
76+
77+
- IR:
78+
79+
- Memory operations (`memset`, `memcpy`, etc.)
80+
- Bit-counting operations
81+
- External globals
82+
- Cold block annotation
83+
- Floating point support
84+
- Unwinding support
85+
- Jump tables
86+
- Static branch/patchpoint support
87+
88+
- Codegen:
89+
90+
- Improved x64 instruction selection
91+
- Minor register allocator improvements
92+
- Use 3-address instructions instead of copies where possible
93+
- Improved redundant copy elimination?
94+
95+
- Optimization:
96+
- Improved local block scheduling
97+
- SROA
98+
- SCCP
99+
- Jump threading
100+
- Range check elimination
101+
102+
## Projects Using Spidir
103+
104+
- [TomatoDotNet](https://github.com/TomatOrg/TomatoDotNet/), a freestanding C# runtime (original project motivation)
105+
- [spidir-wasm](https://github.com/Itay2805/spidir-wasm/), a small WASM implementation showcasing the C API

0 commit comments

Comments
 (0)