From patchwork Sat Aug 10 04:12:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 11088205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFC62112C for ; Sat, 10 Aug 2019 04:21:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB6BD223A6 for ; Sat, 10 Aug 2019 04:21:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C2C42228E; Sat, 10 Aug 2019 04:21:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 459302228E for ; Sat, 10 Aug 2019 04:21:31 +0000 (UTC) Received: from localhost ([::1]:34902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hwIsk-0000Dj-Ly for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Aug 2019 00:21:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34780) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hwIku-0005iE-LW for qemu-devel@nongnu.org; Sat, 10 Aug 2019 00:13:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hwIkt-0004M8-Ik for qemu-devel@nongnu.org; Sat, 10 Aug 2019 00:13:24 -0400 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:34631) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hwIkt-0004M1-Dn for qemu-devel@nongnu.org; Sat, 10 Aug 2019 00:13:23 -0400 Received: by mail-ot1-x341.google.com with SMTP id n5so140564862otk.1 for ; Fri, 09 Aug 2019 21:13:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D3geIlGl84SmXsN7QLZGdQ5xDPB0CYHN009O2rh5GH0=; b=g8o5cMtwLH/3rlUo8P0+TXPoJMsUmbiNrTLPhapYZKgJ9YLvLE/krKeaimB9bxNRud 7qyfG6ZUadnCZFUzG/9zl/nasFliH9J3XKCRTZ1U/PdN53+5u7zgz7mP37XWb7XLKQBc PE2hM4tXyYncpdPzYznvAjVz8anHu+i43d5/Q1ZNLK+uD+MVwlpS5sVZkFDrh9Gzi7lX KV6GFOQfN68xYdtOpsU/yfyVVymYT4aWwdFuxNzh9JcUounXIIQSh0Uax6B6SP+ABLRq p4J/nOaPVDkr22G1J28QLEDEtxceb2Axru8G6iIvUgIFWbBuX317o6rc0Cyc3zPrUkpd YW/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D3geIlGl84SmXsN7QLZGdQ5xDPB0CYHN009O2rh5GH0=; b=rkHSNF2W+EvP4khV4IhJSyd1QkHoOOTIDROv77Gv1Ob9dJpzTBJF0FmSnVs/ZWDiXN anbJlKLS2QN6oDhIZGgW0VhjBtSX1ZnYqUq9MxXalj6J9HXy9Csi0SE6FqHvSBo63DRv HaAxr1BXE0CRChk1q2JLGXJSwDgJEZYtamfRnIbT3Q0lif3DKADzI6XZFuzbOEY+BYfu WjAzO7qgf1oe72xnrd4satTmpd0VR0ekU1mNrfaMdPv5c0ZbaRl99HiUdfLhsms2ycPr gZVvvJvoaLmgZAJAL6LZeX1P8jvt1h8JYjsAVeh7gTyTULhdtnVK1s6mREbwkC5PFf1i 1HuA== X-Gm-Message-State: APjAAAXtocdKeQ96A4Vr9tcnzl0em9ph19SnB6hdSww1NzXuDOLz2Xej g6aKIdNY5rA4s5hXgvPxNmVe2Yxo X-Google-Smtp-Source: APXvYqzScN9WhUzRUZVxpJv+A+dva6x4oQEDJ5m46Z6y3Od7aRZ5I6cYiApdcyI27ne1MxFaijcMBQ== X-Received: by 2002:a9d:77d5:: with SMTP id w21mr18680189otl.330.1565410402661; Fri, 09 Aug 2019 21:13:22 -0700 (PDT) Received: from dionysus.attlocal.net (69-222-133-165.lightspeed.tukrga.sbcglobal.net. [69.222.133.165]) by smtp.gmail.com with ESMTPSA id f84sm33383540oig.43.2019.08.09.21.13.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 09 Aug 2019 21:13:22 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Sat, 10 Aug 2019 00:12:32 -0400 Message-Id: <20190810041255.6820-17-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190810041255.6820-1-jan.bobek@gmail.com> References: <20190810041255.6820-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::341 Subject: [Qemu-devel] [RFC PATCH v2 16/39] target/i386: introduce instruction operand infrastructure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP insnop_t and the init, prepare and finalize functions form the basis of instruction operand decoding. Introduce macros for defining a generic instruction operand; use cases for operand decoding will be introduced later with instruction translators. Signed-off-by: Jan Bobek --- target/i386/translate.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/target/i386/translate.c b/target/i386/translate.c index 508d584584..109e4922eb 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -4545,6 +4545,47 @@ static int ck_cpuid(CPUX86State *env, DisasContext *s, int ck_cpuid_feat) } } +/* + * Core instruction operand infrastructure + */ +#define insnop_t(opT) insnop_ ## opT ## _t +#define insnop_init(opT) insnop_ ## opT ## _init +#define insnop_prepare(opT) insnop_ ## opT ## _prepare +#define insnop_finalize(opT) insnop_ ## opT ## _finalize + +#define TYPEDEF_INSNOP_T(opT, type) \ + typedef type insnop_t(opT); +#define INSNOP_INIT(opT, init_stmt) \ + static int insnop_init(opT)(CPUX86State *env, DisasContext *s, \ + int modrm, insnop_t(opT) *op) \ + { \ + init_stmt; \ + } +#define INSNOP_PREPARE(opT, prepare_stmt) \ + static void insnop_prepare(opT)(CPUX86State *env, DisasContext *s, \ + int modrm, insnop_t(opT) *op) \ + { \ + prepare_stmt; \ + } +#define INSNOP_FINALIZE(opT, finalize_stmt) \ + static void insnop_finalize(opT)(CPUX86State *env, DisasContext *s, \ + int modrm, insnop_t(opT) *op) \ + { \ + finalize_stmt; \ + } +#define INSNOP(opT, type, init_stmt, prepare_stmt, finalize_stmt) \ + TYPEDEF_INSNOP_T(opT, type) \ + INSNOP_INIT(opT, init_stmt) \ + INSNOP_PREPARE(opT, prepare_stmt) \ + INSNOP_FINALIZE(opT, finalize_stmt) + +#define INSNOP_INIT_FAIL return 1 +#define INSNOP_INIT_OK(x) return ((*(op) = (x)), 0) +#define INSNOP_PREPARE_NOOP /* no-op */ +#define INSNOP_PREPARE_INVALID g_assert_not_reached() +#define INSNOP_FINALIZE_NOOP /* no-op */ +#define INSNOP_FINALIZE_INVALID g_assert_not_reached() + static void gen_sse_ng(CPUX86State *env, DisasContext *s, int b) { enum {