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:
b49fe28
)
oppc/code: fix comparisons
author
Dmitry Selyutin
<ghostmansd@gmail.com>
Sun, 14 Jan 2024 20:48:00 +0000
(23:48 +0300)
committer
Dmitry Selyutin
<ghostmansd@gmail.com>
Tue, 16 Jan 2024 19:10:07 +0000
(22:10 +0300)
src/openpower/oppc/pc_code.py
patch
|
blob
|
history
diff --git
a/src/openpower/oppc/pc_code.py
b/src/openpower/oppc/pc_code.py
index eba5132355e2844a1ef9e606f5a65e11c855536f..170c701113e05a53f798bcafa82491f5775f1c40 100644
(file)
--- a/
src/openpower/oppc/pc_code.py
+++ b/
src/openpower/oppc/pc_code.py
@@
-50,8
+50,10
@@
class CodeVisitor(pc_util.Visitor):
with self.__code[self.__header]:
for decl in self.__decls:
self.__code[self.__header].emit(stmt=f"struct oppc_value {decl};")
with self.__code[self.__header]:
for decl in self.__decls:
self.__code[self.__header].emit(stmt=f"struct oppc_value {decl};")
- self.__code[self.__header].emit()
- for decl in filter(lambda decl: decl in insn.fields, sorted(self.__decls)):
+ decls = sorted(filter(lambda decl: decl in insn.fields, self.__decls))
+ if decls:
+ self.__code[self.__header].emit()
+ for decl in decls:
bits = f"{len(insn.fields[decl])}"
transient = Transient(bits=bits)
symbol = pc_ast.Symbol(decl)
bits = f"{len(insn.fields[decl])}"
transient = Transient(bits=bits)
symbol = pc_ast.Symbol(decl)
@@
-73,7
+75,8
@@
class CodeVisitor(pc_util.Visitor):
for (level, stmt) in self[assign]:
self[self.__header].emit(stmt=stmt, level=level)
self.__code[self.__header].emit()
for (level, stmt) in self[assign]:
self[self.__header].emit(stmt=stmt, level=level)
self.__code[self.__header].emit()
- self.__code[self.__header].emit()
+ if decls:
+ self.__code[self.__header].emit()
self.__code[self.__footer].emit(stmt=f"}}")
def __iter__(self):
self.__code[self.__footer].emit(stmt=f"}}")
def __iter__(self):
@@
-246,12
+249,6
@@
class CodeVisitor(pc_util.Visitor):
if isinstance(node.right, (pc_ast.GPR, pc_ast.FPR)):
self.__regfetch[str(node.right)].append(node.left)
if isinstance(node.right, (pc_ast.GPR, pc_ast.FPR)):
self.__regfetch[str(node.right)].append(node.left)
- comparison = (
- pc_ast.Lt, pc_ast.Le,
- pc_ast.Eq, pc_ast.NotEq,
- pc_ast.Ge, pc_ast.Gt,
- pc_ast.LtU, pc_ast.GtU,
- )
if isinstance(node.left, pc_ast.IfExpr):
self.fixup_ternary(node=node.left)
if isinstance(node.right, pc_ast.IfExpr):
if isinstance(node.left, pc_ast.IfExpr):
self.fixup_ternary(node=node.left)
if isinstance(node.right, pc_ast.IfExpr):
@@
-261,18
+258,21
@@
class CodeVisitor(pc_util.Visitor):
if isinstance(node.right, pc_ast.Attribute):
self.fixup_attr(node=node.right)
if isinstance(node.right, pc_ast.Attribute):
self.fixup_attr(node=node.right)
+ comparison = (
+ pc_ast.Lt, pc_ast.Le,
+ pc_ast.Eq, pc_ast.NotEq,
+ pc_ast.Ge, pc_ast.Gt,
+ pc_ast.LtU, pc_ast.GtU,
+ )
if isinstance(node.op, comparison):
if isinstance(node.op, comparison):
- call = self.call(name=str(self[node.op]), code=[
- self[node.left],
- self[node.right],
- ])
+ transient = self.transient(bits="UINT8_C(1)")
else:
transient = self.transient()
else:
transient = self.transient()
-
call = self.call(name=str(self[node.op]), code=[
-
self[transient],
-
self[node.left],
-
self[node.right],
-
])
+ call = self.call(name=str(self[node.op]), code=[
+ self[transient],
+ self[node.left],
+ self[node.right],
+ ])
with self.pseudocode(node=node):
for (level, stmt) in self[call]:
self[node].emit(stmt=stmt, level=level)
with self.pseudocode(node=node):
for (level, stmt) in self[call]:
self[node].emit(stmt=stmt, level=level)