If you have a need for lots of registers, due to complex calculations or large functions, GCC tends not to generate the best code. However, it can be improved by enabling "soft registers". These are memory locations, accessed in the direct addressing mode, which appear to GCC as registers.
GCC6809 can use up to 8 soft registers; the memory locations are
named *m0 through *m7. Use the -msoft-reg-count option to
enable their usage when compiling a file.
Most of the passes of GCC expect to have a large number of registers. When it runs out, any remaining values must be "spilled" to the stack. This creates several problems in embedded environments. First, stack load/store instructions can be slow, because it requires indexed addressing. Second, systems may have little RAM. Third, in multiprocessing systems which need to save/ restore the stack, keeping the stack smaller will produce faster code.
Soft registers help in all of these areas. Direct mode accesses are shorter in both length and execution time. Because they are global, and not relative to the stack frame, less overall memory is used. Finally, because GCC is unaware that these registers are actually in memory, it can still perform some optimizations on values in these locations which aren't possible once values are spilled to the stack (just because of the way GCC is written).
Note that all soft registers are considered call-clobbered. GCC6809 will not save/restore any soft registers in the function prologue/epilogue, as it would be too slow. Consequently, values can't be kept in soft registers across a function call.
You do not need to declare the memory locations for the soft registers. They will be generated for you. They are part of the GCC runtime library.