> What changes can I apply to the _code_ to reduce compile time/make it> possible to compile the file?

* Split the function into smaller ones
Most compilers optimize a function at a time. Since they use algorithms
with complexity order N^2 or even N^3, a smaller function will be compiled
quicker.

* Generate switch statements with fewer cases (same as above)

* Generate fewer if statements
Dense control flow will slow down dataflow analysis.

* Generate less dead code
Eventhough the compiler can/will optimize it away, it might slow it
down or inadvertently block other optimizations.

* Use local variables
Global variables generate much more (intermediate) code. It is often
best to copy global variables on function entry, and write them back
before returning. This reduces the strain on alias analysis a lot,
and generates better code.

I suppose PC is #defined as R[15]? Then I don't understand why you
do the PC increment at the start, and skip the weird PC correction
step in the first if statement. Note that the compiler will be unable
to optimize the redundant PC != (oldPC +4) check due to the call to
rot_imm (unless you define rot_imm in the same file _and_ are brave
enough to compile with O3...). And why not write:

if (PC != oldPC) break; PC += 4;

Also, since most instructions take a single cycle, you could increment
the cycle counter with the cycle count minus one. This normally means
you don't have to increment it. When the real cycle count is needed,
simply add the instruction count.