Reduced Instruction Set Computers Pipelining: (RISC)
Reduced Instruction Set Computers Pipelining: (RISC)
Solutions include:
— Multiple Pipeline streams
— Prefetching the branch target
— Using a Loop Buffer
— Branch Prediction
— Delayed Branch
— Reordering of Instructions
— Multiple Copies of Registers (backups)
Recall Key Features of RISC
• Software contribution
— Require compiler to allocate registers
– Allocate based on most used variables in a given time
+ Requires sophisticated program analysis
• Hardware contribution
— Have more registers
– Thus more variables will be in registers
Register uses
Observations:
• Typically only a few Local & Pass parameters
• Typically limited range of depth of calls
Implications:
If we Partition register set
• We can use multiple small sets of registers per context
• Let Calls switch to a new set of registers
• Let Returns switch back to the previously used set of registers
Using “Register Windows”
• Then:
— Temporary registers from one set overlap parameter
registers from the next
• And:
— This provides parameter passing without moving data (just
move one pointer)
Overlapping “Register Windows”
Basis:
• Assuming relatively small number of registers (16-32)
• Optimizing the use is given to the compiler
• HLL programs have no explicit references to registers
Then:
• Assign symbolic, or virtual, register to each candidate variable
• Map (unlimited) symbolic registers to (limited) real registers
• Symbolic registers that are not used at the same time can
share real registers
• If you run out of real registers some variables will use memory
Graph Coloring Algorithm
for Register Assignment
Given:
• A graph of nodes and edges
• Nodes represent symbolic registers
• Two symbolic registers that are used in the same program
fragment are joined by an edge
Then:
• Assign a color to each node
• Adjacent nodes must have different colors (connected by
an edge)
• Assign a minimum number of colors
And then:
• Try to color the graph with n colors, where n is the
number of real registers
• Nodes that can not be colored must be placed in memory
Graph Coloring Algorithm
Example
RISC Features Again
• Key features
— Large number of general purpose registers
(and use of compiler technology to optimize register use)
(Allows 2 memory accesses per stage) (E1 register read, E2 execute & register write
Particularly beneficial if E phase is long)
Optimization of RISC Pipelining
• Delayed branch
— Leverages branch that does not take effect until
after execution of following instruction