From: Dmitry Selyutin Date: Fri, 12 Jan 2024 19:28:58 +0000 (+0300) Subject: oppc/code: support subscript exprs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c2c6a038e8462d3d0d0e2f5752a05f7c56d7c209;p=openpower-isa.git oppc/code: support subscript exprs --- diff --git a/src/openpower/oppc/pc_code.py b/src/openpower/oppc/pc_code.py index 67d4f42f..78d3ce55 100644 --- a/src/openpower/oppc/pc_code.py +++ b/src/openpower/oppc/pc_code.py @@ -153,6 +153,21 @@ class CodeVisitor(pc_util.Visitor): yield node self[node].emit(f"ctx->XLEN") + @pc_util.Hook(pc_ast.SubscriptExpr) + def SubscriptExpr(self, node): + yield node + index = str(self[node.index]) + subject = str(self[node.subject]) + self[node].emit(f"oppc_subscript({subject}, {index})") + + @pc_util.Hook(pc_ast.RangeSubscriptExpr) + def RangeSubscriptExpr(self, node): + yield node + start = str(self[node.start]) + end = str(self[node.end]) + subject = str(self[node.subject]) + self[node].emit(f"oppc_range_subscript({subject}, {start}, {end})") + @pc_util.Hook(pc_ast.Call.Name) def CallName(self, node): yield node