-
Notifications
You must be signed in to change notification settings - Fork 0
mdwrigh2/tm-optimizer
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An optimizer for TinyMachine assembly with two assumptions: 1) The 0 register always contains 0 2) There are 8 registers (meaning the 8th register contains the current program instruction) USAGE ./ice9 out.tm < in.tm ice9 will read in the tiny machine instructions from stdin, and write them to the file contained in the first argument. Optimizations Performed: - Constant Propagation This will replace all statements where the values are known with a constant load, and all conditional jumps with an unconditional jump or a no-op depending on whether the jump should be made or not. This doesn't actually remove instructions, but it is a reduction in strength and will allow dead code removal to remove a bunch of instructions rendered unnecessary by this . - Dead Code Removal This should be a global optimization. Live analysis is performed globally and then locally to determine what statements are never actually used. I also remove any blocks that can't be reached by looking at the "IN" of the block. - Jump Chaining I follow all jumps and remove intermediate steps that are guaranteed to happen. This doesn't necessarily remove instructions in the file, but it should remove instructions executed. - No-Op Removal Any no-ops such as loading the register into itself, adding 0 to itself and storing it, etc. are removed. The program is then recomposed with new line numbering. - Reduce to Halt This is more a special case than anything, but I thought it interesting. I reduce a program to a single HALT statement if the program does not contain any statements that provide visible side effect such as OUT and IN. - Array Reference Optimization I don't actually have this as its own optimization, but with constant propagation, jump chaining and dead code elimination, I should eliminate large chunks of the code around array references, particularly multi-dimensional arrays.
About
Optimizes TM assembly
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published