don't generate misleading log messages setting unimplemented SPRs to zero programmerjake/remove-f-strings
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 20 Oct 2023 23:00:41 +0000 (16:00 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Fri, 20 Oct 2023 23:00:41 +0000 (16:00 -0700)
turns out they're generated by calling caller.SPR.__getitem__

src/openpower/test/state.py

index d32f4b3efdd00338b1b224698346422310aa3a36..a8483ddaec9b0160c79d16d6b3fe76dbeb869fa6 100644 (file)
@@ -403,7 +403,16 @@ class SimState(State):
                 self.sim.spr['SRR0'] = 0
                 self.sim.spr['SRR1'] = 0
 
-            self.sprs[spr] = self.sim.spr[spr.name]  # setitem converts to int
+            # avoid accessing SPRs that aren't used/implemented
+            # this avoids printing a bunch of messages like:
+            # setting spr TFHAR SelectableInt(value=0x0, bits=64)
+            # setting spr TFIAR SelectableInt(value=0x0, bits=64)
+            # setting spr TEXASR SelectableInt(value=0x0, bits=64)
+            # setting spr TEXASRU SelectableInt(value=0x0, bits=32)
+            if (spr.name in self.sim.spr or spr.value in self.sim.spr
+                    or spr.name in ('HSRR0', 'HSRR1')):
+                # setitem converts to int
+                self.sprs[spr] = self.sim.spr[spr.name]
 
             if clear_srr:
                 self.sim.spr['SRR0'] = old_srr0