-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* switch strop to `split` branch, upgrade mos6502 * break apart huge method in BruteForce * add peephole checker example * a few convenience methods on z80::Insn * experiment on constraining search * remove vestiges * it's better if constraints are able to report why they're firing * move Constrain to the func and subroutine * BruteForce now says how many iterations it's done * Some instructions just can't occur in a function * constraints tweak * better way to get return value out of emulator * add live_out function to SdccCall1GetReturnValue trait * better names for sdcccall(1) param & return value traits * better way to disallow opcodes from sdccall1 functions * clippy & fmt * primitive register pair dataflow * dataflow analysis considers live-out registers to improve runtime * correction to function in opt example * add report example * implement basic peephole optimization * example: more stupid code in static analysis example * generate another function in gen: example * more peephole optimizations and dataflow analysis * the peephole example shows where the peephole is failing * peephole example helps develop the peephole optimizers * more peephole opts * better internal API * tidy up --------- Co-authored-by: Sam M W <you@example.com>
- Loading branch information
1 parent
2fe81c8
commit 6589e8c
Showing
27 changed files
with
1,201 additions
and
878 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use strop::Disassemble; | ||
use strop::StropError; | ||
|
||
fn zero(_nothing: u8) -> Result<u8, StropError> { | ||
Ok(b'0') | ||
} | ||
|
||
fn sdcccall1_search(target_function: fn(u8) -> Result<u8, StropError>) { | ||
use strop::z80::SdccCall1; | ||
|
||
let target_function = target_function as fn(u8) -> Result<u8, StropError>; | ||
|
||
// a bruteforce search for Z80 machine code programs implementing the function | ||
let mut bruteforce = SdccCall1::<u8, u8>::new() | ||
// By specifying that we want a pure function, and that the function is a leaf function, we | ||
// can constrain the search space even further | ||
.pure() | ||
.leaf() | ||
.bruteforce(target_function); | ||
|
||
// let's find the first program that implements the function! | ||
let first = bruteforce.search().unwrap(); | ||
|
||
println!("found first:"); | ||
first.dasm(); | ||
|
||
let mut count = 0usize; | ||
|
||
// let's find more programs that are equivalent. I'm expecting these to have some | ||
// inefficiencies, which will point out deficiencies in the peephole optimizers and dataflow | ||
// analysis. | ||
loop { | ||
let second = bruteforce.search().unwrap(); | ||
|
||
if count == 1 { | ||
println!( | ||
"I've discovered two or more programs that are equivalent. One's going to have dead code" | ||
); | ||
println!("or some other inefficency."); | ||
} | ||
|
||
println!("number {count}:"); | ||
second.dasm(); | ||
count += 1; | ||
} | ||
} | ||
|
||
fn main() { | ||
sdcccall1_search(zero); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.