From nobody Sun Nov 9 17:50:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551508876995389.68467389151124; Fri, 1 Mar 2019 22:41:16 -0800 (PST) Received: from localhost ([127.0.0.1]:49320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzyKc-0004Yg-NK for importer@patchew.org; Sat, 02 Mar 2019 01:41:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzyJa-00042S-Dc for qemu-devel@nongnu.org; Sat, 02 Mar 2019 01:40:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzyJS-0004Yc-LZ for qemu-devel@nongnu.org; Sat, 02 Mar 2019 01:40:02 -0500 Received: from mail03.asahi-net.or.jp ([202.224.55.15]:38393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzyJI-0004LH-2x for qemu-devel@nongnu.org; Sat, 02 Mar 2019 01:39:49 -0500 Received: from h61-195-96-97.vps.ablenet.jp (h61-195-96-97.vps.ablenet.jp [61.195.96.97]) (Authenticated sender: PQ4Y-STU) by mail03.asahi-net.or.jp (Postfix) with ESMTPA id 559A12F95E; Sat, 2 Mar 2019 15:39:40 +0900 (JST) Received: from ysato.dip.jp (ZM005235.ppp.dion.ne.jp [222.8.5.235]) by h61-195-96-97.vps.ablenet.jp (Postfix) with ESMTPSA id 66706240089; Sat, 2 Mar 2019 15:39:39 +0900 (JST) From: Yoshinori Sato To: qemu-devel@nongnu.org, Richard Henderson Date: Sat, 2 Mar 2019 15:39:26 +0900 Message-Id: <20190302063926.11488-1-ysato@users.sourceforge.jp> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190131210851.9842-1-richard.henderson@linaro.org> References: <20190131210851.9842-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 202.224.55.15 Subject: [Qemu-devel] [PATCH] decodetree: Add DisasContext to function part X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yoshinori Sato Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" OK. RX decoder works fine. Since it is necessary to read additional bytes in the function of the operand, we need to have DisasContext passed as an argument. > %b2_li_2 18:2 !function=3Dli "li" read more extra byte. It use cpu_env in DisasContext. Signed-off-by: Yoshinori Sato --- scripts/decodetree.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/scripts/decodetree.py b/scripts/decodetree.py index e23d43e354..fa9a75ccad 100755 --- a/scripts/decodetree.py +++ b/scripts/decodetree.py @@ -387,7 +387,11 @@ class FunctionField: return self.func + '(' + str(self.base) + ')' =20 def str_extract(self): - return self.func + '(' + self.base.str_extract() + ')' + if variablewidth: + ctx =3D 'ctx, ' + else: + ctx =3D '' + return self.func + '(' + ctx + self.base.str_extract() + ')' =20 def __eq__(self, other): return self.func =3D=3D other.func and self.base =3D=3D other.base @@ -454,7 +458,11 @@ class Format(General): return 'extract_' + self.name =20 def output_extract(self): - output('static void ', self.extract_name(), '(', + if variablewidth: + ctx_p =3D 'DisasContext *ctx, ' + else: + ctx_p =3D '' + output('static void ', self.extract_name(), '(' + ctx_p, self.base.struct_name(), ' *a, ', insntype, ' insn)\n{\n') for n, f in self.fields.items(): output(' a->', n, ' =3D ', f.str_extract(), ';\n') @@ -468,10 +476,14 @@ class Pattern(General): def output_decl(self): global translate_scope global translate_prefix + if variablewidth: + ctx_p =3D 'DisasContext *ctx, ' + else: + ctx_p =3D '' output('typedef ', self.base.base.struct_name(), ' arg_', self.name, ';\n') output(translate_scope, 'bool ', translate_prefix, '_', self.name, - '(DisasContext *ctx, arg_', self.name, ' *a);\n') + '(', ctx_p, 'arg_', self.name, ' *a);\n') =20 def output_code(self, i, extracted, outerbits, outermask): global translate_prefix @@ -479,7 +491,8 @@ class Pattern(General): arg =3D self.base.base.name output(ind, '/* ', self.file, ':', str(self.lineno), ' */\n') if not extracted: - output(ind, self.base.extract_name(), '(&u.f_', arg, ', insn);= \n') + output(ind, self.base.extract_name(), + '(ctx, &u.f_', arg, ', insn);\n') for n, f in self.fields.items(): output(ind, 'u.f_', arg, '.', n, ' =3D ', f.str_extract(), ';\= n') output(ind, 'return ', translate_prefix, '_', self.name, @@ -890,11 +903,16 @@ class Tree: def output_code(self, i, extracted, outerbits, outermask): ind =3D str_indent(i) =20 + if variablewidth: + ctx =3D 'ctx, ' + else: + ctx =3D '' # If we identified all nodes below have the same format, # extract the fields now. if not extracted and self.base: output(ind, self.base.extract_name(), - '(&u.f_', self.base.base.name, ', insn);\n') + '(', ctx, '&u.f_', self.base.base.name, + ', insn);\n') extracted =3D True =20 # Attempt to aid the compiler in producing compact switch statemen= ts. @@ -994,7 +1012,7 @@ class SizeTree: # If we need to load more bytes to test, do so now. if extracted < self.width: output(ind, 'insn =3D ', decode_function, - '_load_bytes(s, insn, {0}, {1});\n' + '_load_bytes(ctx, insn, {0}, {1});\n' .format(extracted / 8, self.width / 8)); extracted =3D self.width =20 @@ -1048,7 +1066,7 @@ class SizeLeaf: # If we need to load more bytes, do so now. if extracted < self.width: output(ind, 'insn =3D ', decode_function, - '_load_bytes(s, insn, {0}, {1});\n' + '_load_bytes(ctx, insn, {0}, {1});\n' .format(extracted / 8, self.width / 8)); extracted =3D self.width output(ind, 'return insn;\n') --=20 2.11.0