From patchwork Tue Jun 5 10:39:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 10448013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20DB560284 for ; Tue, 5 Jun 2018 10:40:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CD2929036 for ; Tue, 5 Jun 2018 10:40:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 016C32903F; Tue, 5 Jun 2018 10:40:52 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8BAD729036 for ; Tue, 5 Jun 2018 10:40:52 +0000 (UTC) Received: from localhost ([::1]:45574 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQ9OV-0006lm-PG for patchwork-qemu-devel@patchwork.kernel.org; Tue, 05 Jun 2018 06:40:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQ9N5-0005OK-Su for qemu-devel@nongnu.org; Tue, 05 Jun 2018 06:39:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQ9N4-00068B-Nv for qemu-devel@nongnu.org; Tue, 05 Jun 2018 06:39:23 -0400 Received: from mail.ispras.ru ([83.149.199.45]:55888) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQ9N4-00067i-B9 for qemu-devel@nongnu.org; Tue, 05 Jun 2018 06:39:22 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 8455054015E; Tue, 5 Jun 2018 13:39:21 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Tue, 05 Jun 2018 13:39:21 +0300 Message-ID: <152819516132.30857.1700667353240369481.stgit@pasha-ThinkPad-T60> In-Reply-To: <152819515565.30857.16834004920507717324.stgit@pasha-ThinkPad-T60> References: <152819515565.30857.16834004920507717324.stgit@pasha-ThinkPad-T60> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [RFC PATCH v2 1/7] tcg: add headers for non-target helpers 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: peter.maydell@linaro.org, maria.klimushenkova@ispras.ru, dovgaluk@ispras.ru, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Pavel Dovgalyuk This patch adds functions and headers for adding the helpers from the modules other than the target translators. Signed-off-by: Pavel Dovgalyuk --- include/exec/helper-register.h | 53 ++++++++++++++++++++++++++++++++++++++++ tcg/tcg.c | 12 +++++++++ tcg/tcg.h | 3 ++ 3 files changed, 68 insertions(+) create mode 100644 include/exec/helper-register.h diff --git a/include/exec/helper-register.h b/include/exec/helper-register.h new file mode 100644 index 0000000..aeface9 --- /dev/null +++ b/include/exec/helper-register.h @@ -0,0 +1,53 @@ +#ifndef HELPER_REGISTER_H +#define HELPER_REGISTER_H + +#include "exec/helper-head.h" + +/* Need one more level of indirection before stringification + to get all the macros expanded first. */ +#define str(s) #s + +#define DEF_HELPER_FLAGS_0(NAME, FLAGS, ret) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, dh_sizemask(ret, 0)); + +#define DEF_HELPER_FLAGS_1(NAME, FLAGS, ret, t1) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1)); + +#define DEF_HELPER_FLAGS_2(NAME, FLAGS, ret, t1, t2) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2)); + +#define DEF_HELPER_FLAGS_3(NAME, FLAGS, ret, t1, t2, t3) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ + | dh_sizemask(t3, 3)); + +#define DEF_HELPER_FLAGS_4(NAME, FLAGS, ret, t1, t2, t3, t4) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ + | dh_sizemask(t3, 3) | dh_sizemask(t4, 4)); + +#define DEF_HELPER_FLAGS_5(NAME, FLAGS, ret, t1, t2, t3, t4, t5) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ + | dh_sizemask(t3, 3) | dh_sizemask(t4, 4) | dh_sizemask(t5, 5)); + +#define DEF_HELPER_FLAGS_6(NAME, FLAGS, ret, t1, t2, t3, t4, t5, t6) \ + tcg_register_helper(HELPER(NAME), str(NAME), FLAGS, \ + dh_sizemask(ret, 0) | dh_sizemask(t1, 1) | dh_sizemask(t2, 2) \ + | dh_sizemask(t3, 3) | dh_sizemask(t4, 4) | dh_sizemask(t5, 5) \ + | dh_sizemask(t6, 6)); + +#include "helper.h" + +#undef str +#undef DEF_HELPER_FLAGS_0 +#undef DEF_HELPER_FLAGS_1 +#undef DEF_HELPER_FLAGS_2 +#undef DEF_HELPER_FLAGS_3 +#undef DEF_HELPER_FLAGS_4 +#undef DEF_HELPER_FLAGS_5 +#undef DEF_HELPER_FLAGS_6 + +#endif /* HELPER_REGISTER_H */ diff --git a/tcg/tcg.c b/tcg/tcg.c index 6eeebe0..8191381 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1623,6 +1623,18 @@ static inline const char *tcg_find_helper(TCGContext *s, uintptr_t val) return ret; } +void tcg_register_helper(void *func, const char *name, + unsigned flags, unsigned sizemask) +{ + TCGHelperInfo *info = g_new0(TCGHelperInfo, 1); + info->func = func; + info->name = name; + info->flags = flags; + info->sizemask = sizemask; + + g_hash_table_insert(helper_table, func, info); +} + static const char * const cond_name[] = { [TCG_COND_NEVER] = "never", diff --git a/tcg/tcg.h b/tcg/tcg.h index 08f8bbf..7a4b750 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -890,6 +890,9 @@ void tcg_register_thread(void); void tcg_prologue_init(TCGContext *s); void tcg_func_start(TCGContext *s); +void tcg_register_helper(void *func, const char *name, + unsigned flags, unsigned sizemask); + int tcg_gen_code(TCGContext *s, TranslationBlock *tb); void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size);