From: Dmitry Selyutin Date: Fri, 12 Jan 2024 19:24:22 +0000 (+0300) Subject: oppc/code: support simple conditions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7adc4461f1fe26442b7f102373423355b3a47eb1;p=openpower-isa.git oppc/code: support simple conditions --- diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index cb7260ee..616bb6a5 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -71,7 +71,11 @@ class CodeVisitor(pc_util.Visitor): else: right = str(self[node.right]) if isinstance(node.op, (pc_ast.Add, pc_ast.Sub, - pc_ast.Mul, pc_ast.Div, pc_ast.Mod)): + pc_ast.Mul, pc_ast.Div, pc_ast.Mod, + pc_ast.Lt, pc_ast.Le, + pc_ast.Eq, pc_ast.NotEq, + pc_ast.Ge, pc_ast.Gt, + )): op = { pc_ast.Not: "~", pc_ast.Add: "+", @@ -79,6 +83,12 @@ class CodeVisitor(pc_util.Visitor): pc_ast.Mul: "*", pc_ast.Div: "/", pc_ast.Mod: "%", + pc_ast.Lt: "<", + pc_ast.Le: "<=", + pc_ast.Eq: "==", + pc_ast.NotEq: "!=", + pc_ast.Ge: ">=", + pc_ast.Gt: ">", }[node.op.__class__] stmt = " ".join([left, op, right]) self[node].emit(stmt=f"({stmt})") @@ -102,8 +112,13 @@ class CodeVisitor(pc_util.Visitor): else: raise ValueError(node) - @pc_util.Hook(pc_ast.Not, pc_ast.Add, pc_ast.Sub, - pc_ast.Mul, pc_ast.Div, pc_ast.Mod) + @pc_util.Hook( + pc_ast.Not, pc_ast.Add, pc_ast.Sub, + pc_ast.Mul, pc_ast.Div, pc_ast.Mod, + pc_ast.Lt, pc_ast.Le, + pc_ast.Eq, pc_ast.NotEq, + pc_ast.Ge, pc_ast.Gt, + ) def Op(self, node): yield node