From c2c6a038e8462d3d0d0e2f5752a05f7c56d7c209 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Fri, 12 Jan 2024 22:28:58 +0300 Subject: [PATCH] oppc/code: support subscript exprs --- src/openpower/oppc/pc_code.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 -- 2.30.2