Skip to content

Instantly share code, notes, and snippets.

@Blecki
Created May 13, 2012 18:53
Show Gist options
  • Select an option

  • Save Blecki/2689729 to your computer and use it in GitHub Desktop.

Select an option

Save Blecki/2689729 to your computer and use it in GitHub Desktop.
// Peephole optimization definitions
// Simple assign-back
SET A, B / SET B, A => SET A, B;
// Stack assign-back
SET "PUSH", A / SET A, "PEEK" => SET "PUSH", A;
// Preserve-pop
SET "PUSH", A / ADD "SP", "0x0001" => ;
// Register flip add
SET B, A / SET A, "POP" / ADD A, B => ADD A, "POP";
// Push temp
SET "J", A / SET "PUSH", "J" => SET "PUSH", A;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment