# note that we can get away with using SPRfull here because the values
# (numerical values) are what is used for lookup.
spr_to_fast = {
- SPR.LR: FastRegsEnum.LR,
- SPR.CTR: FastRegsEnum.CTR,
- SPR.SRR0: FastRegsEnum.SRR0,
- SPR.SRR1: FastRegsEnum.SRR1,
- SPR.HSRR0: FastRegsEnum.HSRR0,
- SPR.HSRR1: FastRegsEnum.HSRR1,
- SPR.SPRG0_priv: FastRegsEnum.SPRG0,
- SPR.SPRG1_priv: FastRegsEnum.SPRG1,
- SPR.SPRG2_priv: FastRegsEnum.SPRG2,
- SPR.SPRG3: FastRegsEnum.SPRG3,
- SPR.HSPRG0: FastRegsEnum.HSPRG0,
- SPR.HSPRG1: FastRegsEnum.HSPRG1,
- SPR.XER: FastRegsEnum.XER,
- SPR.TAR: FastRegsEnum.TAR,
- SPR.SVSRR0: FastRegsEnum.SVSRR0,
- }
-
-spr_to_state = { SPR.DEC: StateRegsEnum.DEC,
- SPR.TB: StateRegsEnum.TB,
- }
+ SPR.LR: FastRegsEnum.LR,
+ SPR.CTR: FastRegsEnum.CTR,
+ SPR.SRR0: FastRegsEnum.SRR0,
+ SPR.SRR1: FastRegsEnum.SRR1,
+ SPR.HSRR0: FastRegsEnum.HSRR0,
+ SPR.HSRR1: FastRegsEnum.HSRR1,
+ SPR.SPRG0_priv: FastRegsEnum.SPRG0,
+ SPR.SPRG1_priv: FastRegsEnum.SPRG1,
+ SPR.SPRG2_priv: FastRegsEnum.SPRG2,
+ SPR.SPRG3: FastRegsEnum.SPRG3,
+ SPR.HSPRG0: FastRegsEnum.HSPRG0,
+ SPR.HSPRG1: FastRegsEnum.HSPRG1,
+ SPR.XER: FastRegsEnum.XER,
+ SPR.TAR: FastRegsEnum.TAR,
+ SPR.SVSRR0: FastRegsEnum.SVSRR0,
+}
+
+spr_to_state = {SPR.DEC: StateRegsEnum.DEC,
+ SPR.TB: StateRegsEnum.TB,
+ }
sprstr_to_state = {}
state_to_spr = {}
sprstr_to_state[k.name] = v
state_to_spr[v] = k
+
def state_reg_to_spr(spr_num):
return state_to_spr[spr_num].value
sprstr_to_fast[k.name] = v
fast_to_spr[v] = k
+
def fast_reg_to_spr(spr_num):
return fast_to_spr[spr_num].value
# TODO: make this a util routine (somewhere)
def mask_extend(x, nbits, repeat):
res = 0
- extended = (1<<repeat)-1
+ extended = (1 << repeat)-1
for i in range(nbits):
- if x & (1<<i):
+ if x & (1 << i):
res |= extended << (i*repeat)
return res
return retval
-
-
def log(*args, kind=LogKind.Default, **kwargs):
"""verbose printing, can be disabled by setting env var "SILENCELOG".
"""