Whitelips is an online IDE for Whitespace.
As there is no official standard, Whitelips features it's own assembly
language. Care has been taken to make it compatible with others, but
this has never been a goal.
push $n - Push value $n onto the stack.
dup - Duplicate the topmost stack element.
copy $n - copies the $n-th element from stack, where 0 is the topmost
swap - swap two topmost stack elements.
drop - discards the topmost stack value.
slide $n - keeps the topmost element, and deletes the next $n elements.
label $l -
call $l -
jmp $l -
jz $l -
jn $l -
end - Terminate the program.
$n - an integer parameter.
$l - a label.
The main philosophy behind the optimizer is that all Whitespace instructions are
equally slow. This means that all optimizations are made to reduce the number of
instructions. Optimizer guarantees that the number of instructions in the output
is less or equal to the original program.
As a secondary objective, the optimizer tries to reduce the size of the program to
speed up parsing. The optimizer does not guarantee that the output code is smaller
or equal in bytes compared to the initial program.
The optimizer works on the Whitespace instruction level, which means the assembly
programs can not be optimized directly - they have to be compiled into Whitespace.
This is a serious restriction by design.
* Remove unreachable code.
* Inline unconditional jumps, if possible.
* Inline function calls.
* Remove unused and duplicate labels.
* Mimimize label names by usage in the program.