Forum Discussion
Altera_Forum
Honored Contributor
15 years agoOne problem with that particular code is that you force an additional memory read (probably through %gp) for almost every access.
Something like:#define uart_pointer ((uart_regs_t *)(AVALON_UART_0_BASE|DATA_CACHE_BYPASS_MASK))will let the compiler generate (and maybe cache) the 32bit constant. If you are trying to squeeze every ounce of performance from the Nios, it is worth placing all the internal memory and io devices in a 64kb range (not necessarily aligned) with %gp set to it's middle - then all accesses to the memory and io devices will be done with %gp relative addressing. (You need my patches to gcc3 for this - don't know about gcc4.) (Actully you can get even better code by making all your data a single structure and defining a global register variable to point into it.)