• 沒有找到結果。

Chapter 3 Proposed Design

3.4 Modified Register Relabeling

3.4.2 Register Relabeling Method 2

Register relabeling method 1 is program-scoped relabeling, i.e., each relabelabel register

is relabeled to a specific registers consistently for the whole program. However, the relabeling

scope of some registers may be relaxed to be within a procedure, i.e., some registers in

different procedures may be relabeled into a same register to raise the occurrence frequencies

of registers which have less 1s after 4-to-6 SS encoding. Figure 3-7 gives examples to show

the different between program-scope relabeling and procedure-scope relabeling. Figure 3-7 (a)

shows the rank order of each register occurrence frequency. In Figure 3-7 (b), program-scoped

relabeling, after the most occurred registers $8 is relabeled into register $1, register $7 only

can be relabeled into another register $2. While, In Figure 3-7 (c), procedure-scoped

relabeling, if the registers of both two procedures are used independently, registers $8 and

register $7 can all be relabeled into register $1 to raise the occurrence frequencies of register

$1 to gain less 1s in code-words after 4-to-6 SS encoding for more power reduction.

Rank order of register occurrence frequencies

Figure 3-7:Program-scoped relabeling V.S. Procedure-scoped relabeling

Considering register usage convention and no performance degradation, some

relabelabel regsiter must be relabeled consistently for the whole program to keep the

correctness of program execution, while some other relabelable regsiters may be relabeled

independently for each procedure. Therefore, the relabeling scopes of relabelable registers of

register relabeling method 2 are classified into program-scoped and procedure-scoped.

For example, in Table 3-6, MIPS registers, temporary registers of caller-saved registers

and saved registers of callee-saved registers may be further classified as procedure-scoped for

register relabeling. Temporary registers are caller-saved registers in MIPS calling convention.

That is, once a procedure needs to use a temporary register after procedure-call, the procedure

will save the value of the temporary register before procedure-call and restore the value after

procedure-call. Therefore, each procedure can use temporary registers at will. Saved registers

are callee-saved registers in MIPS calling convention. The value of saved registers must be

preserved across procedures. The callee will save the values of saved registers at the

procedure entry and restore at the procedure exit if it needs to use the saved registers.

Therefore, each procedure can use saved registers at will after they are saved at procedure

entry.

The relabeling scope of the remaining relabelable registers of MIPS is program-scope.

Register $1 is reserved for assembler and thus should be relabeled for the whole program.

Registers $26, $27 are reserved for kernel while they may be relabeled in application

stand-alone system. The value of pointer registers, registers $28, $29 can be relabeled for the

whole program since procedures recognize the same register names of pointer registers. The

argument registers, register $4 - $7, which are used for arguments passing for procedures, and

the return value registers, register $2 - $3 , which are used for return value from procedures,

must be keep consistently across procedures; thus, they can be relabeled for the whole

program.

Table 3-6:MIPS relabelabel registers with different relabeling scope

Category Name Number Use

Relabelable

$at $1 Assembler temporary

$k0 - $k1 $26 - $27 Kernel registers

$gp $28 Global pointer

$sp $29 Stack pointer

$v0 - $v1 $2 - $3 Return value

$a0 - $a3 $4 - $7 Argument registers

$t0 - $t9 $8 - $15,

$24 - $25 Temporary registers

$s0 - $s8 $16 - $23,

$30 Saved registers

Program-scope

Procedure-scope

In register relabeling method 2, we consider the relabeling of procedure-scoped registers

and program-scoped registers together for power reduction. For program-scoped registers, the

occurrence frequency of each register is collected by the same way as that mentioned in

register relabeling method 1. As for the procedure-scoped registers, their occurrence

frequencies have to be totaled from all procedures. Instead of summing up the frequencies of

the same register numbers in different procedures, sum up the frequencies of the same rank

order of occurrence frequency of register. Consequently, the relabeling of procedure-scoped

registers and program-scoped registers can be together, and there are more procedure-scoped

registers which may be relabeled into registers with less 1s after 4-to-6 SS encoding for more

power reduction.

Therefore, the frequencies of procedure-scoped registers are gathered in each procedure

separately. Then, sort the frequencies of registers in each procedure, and sum up the

frequencies of the registers with same rank in different procedures. However, in MIPS

registers, saved registers should not mix with temporary registers to avoid other procedures to

use the values of saved registers without saving at procedure entry and restoring at procedure

exit. Hence, saved registers and temporary registers should be relabeled separately.

The steps of register relabeling method 2 are described as follows:

 Gather the occurrence frequency of each register

For procedure-scoped registers, gather the frequencies in each procedure separately. For

program-scoped registers, gather the frequencies from the whole program.

 Sorting and intermediate relabel within a procedure

For temporary registers, from high occurrence frequency to low occurrence frequency,

relabel them to TRn, where n is the rank order according to its frequency. For saved

registers, from high occurrence frequency to low occurrence frequency, relabel them to

SRn, where n is the rank order according to its frequency.

 Sum up the frequencies of the same TRn/SRn of all procedures.

 Sort TR/SR and program-scoped registers by their occurrence frequencies, and relabel

them by the sorted order according to the relabeling register selection sequence.

Figure 3-8 is an example for the relabeling steps of register relabeling method 2.

Suppose that the instruction partition and the corresponding relabeling selection sequence are

shown in Figure 3-4 (b) and Table 3-2, respectively. In Figure 3-8(a), a program has two

procedures, Proc. A and Proc. B, and the occurrence frequencies and categories of registers

are given. Sorting and intermediate relabeling for temporary registers and saved registers

separately in each procedure are shown in Figure 3-8 (b). Then, Figure 3-8 (c) shows the

totals of the occurrence frequencies of the same rank of temporary registers and saved

registers. In Figure 3-8 (d), sort the frequencies of TR/SR and program-scoped registers, and

relabel them by the sorted order according to the register selection sequence. Finally, Figure

3-8 (e) illustrates the program after register relabeling method 2.

TR:Temporary registers

(a) Program before register relabeling

r8:12

(b) Sorting and intermediate relabeling

TR1:22

(c) Sum up the occurrence frequencies of procedure-scoped registers

r29:28

(d) Sort the occurrence frequencies of TR/SR and program-scoped registers, and relabel them

TR1 (r8)→r2

(e) Program after register relabeling

Figure 3-8:An example of register relabeling method 2

相關文件