Skip to content

Commit

Permalink
Reorganize Redpiler in preparation for LLVM and Cranelift backends.
Browse files Browse the repository at this point in the history
  • Loading branch information
StackDoubleFlow committed Apr 16, 2021
1 parent e5057fc commit d2aaa86
Show file tree
Hide file tree
Showing 9 changed files with 761 additions and 381 deletions.
219 changes: 217 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ regex = "1.4.3"
lazy_static = "1.4.0"
backtrace = "0.3.56"
rusqlite = { version="0.24.2", features=["bundled"] }
# TODO: Put the cranelift stuff behind a feature flag
cranelift = "0.73.0"
cranelift-jit = "0.73.0"
cranelift-module = "0.73.0"
18 changes: 17 additions & 1 deletion docs/Redpiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,20 @@ TODO

## Native Code generation

TODO
Each node will generate 2 functions: update and tick. Each node will have a global memory location holding their state.
Example of generated code in C form:
```c
struct State {
// Information such as powered or output strength
}

struct State n0;

void n0_update() {
// ...
}

void n0_tick() {
// ...
}
```
4 changes: 2 additions & 2 deletions src/plot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ impl Plot {

fn update(&mut self) {
if self.redpiler.is_active {
let changes: Vec<(BlockPos, Block)> = self.redpiler.change_queue.drain(..).collect();
let changes: Vec<(BlockPos, Block)> = self.redpiler.block_changes().drain(..).collect();
for (pos, block) in changes {
self.set_block(pos, block);
}
Expand Down Expand Up @@ -822,10 +822,10 @@ impl Plot {
always_running: bool,
initial_player: Option<Player>,
) {
let mut plot = Plot::load(x, z, rx, tx, priv_rx, always_running);
thread::Builder::new()
.name(format!("p{},{}", x, z))
.spawn(move || {
let mut plot = Plot::load(x, z, rx, tx, priv_rx, always_running);
plot.run(initial_player);
})
.unwrap();
Expand Down
Loading

0 comments on commit d2aaa86

Please sign in to comment.