From patchwork Sat Mar 2 06:39:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshinori Sato X-Patchwork-Id: 1050585 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=users.sourceforge.jp Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44BGrc5wjdz9s4V for ; Sat, 2 Mar 2019 17:40:45 +1100 (AEDT) Received: from localhost ([127.0.0.1]:49313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzyKA-0004BT-L5 for incoming@patchwork.ozlabs.org; Sat, 02 Mar 2019 01:40:42 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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=li "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) + ')' def str_extract(self): - return self.func + '(' + self.base.str_extract() + ')' + if variablewidth: + ctx = 'ctx, ' + else: + ctx = '' + return self.func + '(' + ctx + self.base.str_extract() + ')' def __eq__(self, other): return self.func == other.func and self.base == other.base @@ -454,7 +458,11 @@ class Format(General): return 'extract_' + self.name def output_extract(self): - output('static void ', self.extract_name(), '(', + if variablewidth: + ctx_p = 'DisasContext *ctx, ' + else: + ctx_p = '' + 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, ' = ', 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 = 'DisasContext *ctx, ' + else: + ctx_p = '' 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') def output_code(self, i, extracted, outerbits, outermask): global translate_prefix @@ -479,7 +491,8 @@ class Pattern(General): arg = 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, ' = ', 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 = str_indent(i) + if variablewidth: + ctx = 'ctx, ' + else: + ctx = '' # 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 = True # Attempt to aid the compiler in producing compact switch statements. @@ -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 = ', decode_function, - '_load_bytes(s, insn, {0}, {1});\n' + '_load_bytes(ctx, insn, {0}, {1});\n' .format(extracted / 8, self.width / 8)); extracted = self.width @@ -1048,7 +1066,7 @@ class SizeLeaf: # If we need to load more bytes, do so now. if extracted < self.width: output(ind, 'insn = ', decode_function, - '_load_bytes(s, insn, {0}, {1});\n' + '_load_bytes(ctx, insn, {0}, {1});\n' .format(extracted / 8, self.width / 8)); extracted = self.width output(ind, 'return insn;\n')