Search code examples
armcpu-registerscpu-architecture

Why does ARM have 16 registers?


Why does ARM have only 16 registers? Is that the ideal number?

Does distance of registers with more registers also increase the processing time/power ?


Solution

  • As the number of the general-purpose registers becomes smaller, you need to start using the stack for variables. Using the stack requires more instructions, so code size increases. Using the stack also increases the number of memory accesses, which hurts both performance and power usage. The trade off is that to represent more registers you need more bits in your instruction, and you need more room on the chip for the register file, which increases power requirements. You can see how differing register counts affects code size and the frequency of load/store instructions by compiling the same set of code with different numbers of registers. The result of that type of exercise can be seen in table 1 of this paper:

    Extendable Instruction Set Computing

    Register   Program   Load/Store  
    Count      Size      Frequency  
    

    27 100.00 27.90%
    16 101.62 30.22%
    8 114.76 44.45%

    (They used 27 as a base because that is the number of GPRs available on a MIPS processor)

    As you can see, there are only marginal improvements in both programs size and the number of load/stores required as you drop the register count down to 16. The real penalties don't kick in until you drop down to 8 registers. I suspect ARM designers felt that 16 registers was a kind of sweet spot when you were looking for the best performance per watt.