projects
/
openpower-isa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ab4ea92
)
power_enums: better repr for Function enum
author
Dmitry Selyutin
<ghostmansd@gmail.com>
Tue, 2 Aug 2022 11:16:26 +0000
(14:16 +0300)
committer
Dmitry Selyutin
<ghostmansd@gmail.com>
Sun, 14 Aug 2022 19:07:43 +0000
(22:07 +0300)
src/openpower/decoder/power_enums.py
patch
|
blob
|
history
diff --git
a/src/openpower/decoder/power_enums.py
b/src/openpower/decoder/power_enums.py
index 0cd4aab04278de3b41fc92f6d3742b0c12789eb3..e414178c379ded09c7b9b92984612d9682a0056e 100644
(file)
--- a/
src/openpower/decoder/power_enums.py
+++ b/
src/openpower/decoder/power_enums.py
@@
-22,6
+22,7
@@
import csv
import os
from os.path import dirname, join
from collections import namedtuple
+import functools
def find_wiki_dir():
@@
-109,6
+110,20
@@
class Function(Enum):
VL = 1 << 13 # setvl
FPU = 1 << 14 # FPU
+ @functools.lru_cache(maxsize=None)
+ def __repr__(self):
+ counter = 0
+ value = int(self.value)
+ if value != 0:
+ while value != 0:
+ counter += 1
+ value >>= 1
+ counter -= 1
+ desc = f"(1 << {counter})"
+ else:
+ desc = "0"
+ return f"<{self.__class__.__name__}.{self.name}: {desc}>"
+
@unique
class Form(Enum):