From patchwork Fri Jan 15 15:35:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 8042781 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 42CC9BEEE5 for ; Fri, 15 Jan 2016 15:35:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 77F2E20453 for ; Fri, 15 Jan 2016 15:35:18 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 5B2372044C for ; Fri, 15 Jan 2016 15:35:17 +0000 (UTC) Received: from localhost ([::1]:47669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK6PE-0004Y8-EN for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 Jan 2016 10:35:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK6P6-0004Xo-6f for qemu-devel@nongnu.org; Fri, 15 Jan 2016 10:35:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK6P5-0003pv-0K for qemu-devel@nongnu.org; Fri, 15 Jan 2016 10:35:08 -0500 Received: from roura.ac.upc.es ([147.83.33.10]:41006) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK6P4-0003po-Jt for qemu-devel@nongnu.org; Fri, 15 Jan 2016 10:35:06 -0500 Received: from gw-3.ac.upc.es (gw-3.ac.upc.es [147.83.30.9]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id u0FDtU08027519; Fri, 15 Jan 2016 14:55:30 +0100 Received: from localhost (unknown [84.88.51.85]) by gw-3.ac.upc.es (Postfix) with ESMTPSA id 50C27EF; Fri, 15 Jan 2016 16:35:05 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Fri, 15 Jan 2016 16:35:05 +0100 Message-Id: <145287210479.25408.17499099590726683703.stgit@localhost> X-Mailer: git-send-email 2.6.4 In-Reply-To: <145287209895.25408.12995870835200275306.stgit@localhost> References: <145287209895.25408.12995870835200275306.stgit@localhost> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id u0FDtU08027519 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Cc: "Edgar E . Iglesias" , rth@twiddle.net, peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH v1 1/2] tcg: Add support for constant value promises X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A TCG constant value promise allows creating TCG code that works with a constant whose value is not known until after the code has been generated (e.g., a count of the instructions in a basic block). Signed-off-by: LluĂ­s Vilanova --- tcg/tcg-op.h | 6 ++++++ tcg/tcg.c | 33 +++++++++++++++++++++++++++++++++ tcg/tcg.h | 12 ++++++++++++ 3 files changed, 51 insertions(+) diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index 4e20dc1..6966672 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -757,6 +757,7 @@ void tcg_gen_goto_tb(unsigned idx); #if TARGET_LONG_BITS == 32 #define TCGv TCGv_i32 +#define TCGv_promise TCGv_promise_i32 #define tcg_temp_new() tcg_temp_new_i32() #define tcg_global_reg_new tcg_global_reg_new_i32 #define tcg_global_mem_new tcg_global_mem_new_i32 @@ -769,6 +770,7 @@ void tcg_gen_goto_tb(unsigned idx); #define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i32 #else #define TCGv TCGv_i64 +#define TCGv_promise TCGv_promise_i64 #define tcg_temp_new() tcg_temp_new_i64() #define tcg_global_reg_new tcg_global_reg_new_i64 #define tcg_global_mem_new tcg_global_mem_new_i64 @@ -914,6 +916,8 @@ static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index) #define tcg_gen_deposit_tl tcg_gen_deposit_i64 #define tcg_const_tl tcg_const_i64 #define tcg_const_local_tl tcg_const_local_i64 +#define tcg_promise_tl tcg_promise_i64 +#define tcg_set_promise_tl tcg_set_promise_i64 #define tcg_gen_movcond_tl tcg_gen_movcond_i64 #define tcg_gen_add2_tl tcg_gen_add2_i64 #define tcg_gen_sub2_tl tcg_gen_sub2_i64 @@ -991,6 +995,8 @@ static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index) #define tcg_gen_deposit_tl tcg_gen_deposit_i32 #define tcg_const_tl tcg_const_i32 #define tcg_const_local_tl tcg_const_local_i32 +#define tcg_promise_tl tcg_promise_i32 +#define tcg_set_promise_tl tcg_set_promise_i32 #define tcg_gen_movcond_tl tcg_gen_movcond_i32 #define tcg_gen_add2_tl tcg_gen_add2_i32 #define tcg_gen_sub2_tl tcg_gen_sub2_i32 diff --git a/tcg/tcg.c b/tcg/tcg.c index a163541..ea5426d 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -691,6 +691,39 @@ TCGv_i64 tcg_const_local_i64(int64_t val) return t0; } +TCGv_i32 tcg_promise_i32(TCGv_promise_i32 *promise) +{ + int pi = tcg_ctx.gen_next_parm_idx; + *promise = (TCGv_promise_i32)&tcg_ctx.gen_opparam_buf[pi]; + return tcg_const_i32(0xdeadcafe); +} + +TCGv_i64 tcg_promise_i64(TCGv_promise_i64 *promise) +{ + int pi = tcg_ctx.gen_next_parm_idx; + *promise = (TCGv_promise_i64)&tcg_ctx.gen_opparam_buf[pi]; + return tcg_const_i64(0xdeadcafe); +} + +void tcg_set_promise_i32(TCGv_promise_i32 promise, int32_t val) +{ + TCGArg *args = (TCGArg *)promise; + /* parameter as set by tcg_gen_op2() from tcg_gen_movi_i32() */ + args[1] = val; +} + +void tcg_set_promise_i64(TCGv_promise_i64 promise, int64_t val) +{ + TCGArg *args = (TCGArg *)promise; + /* parameter as set by tcg_gen_op2() from tcg_gen_movi_i64() */ +#if TCG_TARGET_REG_BITS == 32 + args[1] = (int32_t)val; + args[3] = (int32_t)(val >> 32); +#else + args[1] = val; +#endif +} + #if defined(CONFIG_DEBUG_TCG) void tcg_clear_temp_count(void) { diff --git a/tcg/tcg.h b/tcg/tcg.h index a696922..79e83c8 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -308,6 +308,9 @@ typedef tcg_target_ulong TCGArg; typedef struct TCGv_i32_d *TCGv_i32; typedef struct TCGv_i64_d *TCGv_i64; typedef struct TCGv_ptr_d *TCGv_ptr; +typedef struct TCGv_promise_i32_d *TCGv_promise_i32; +typedef struct TCGv_promise_i64_d *TCGv_promise_i64; +typedef struct TCGv_promise_ptr_d *TCGv_promise_ptr; static inline TCGv_i32 QEMU_ARTIFICIAL MAKE_TCGV_I32(intptr_t i) { @@ -746,6 +749,8 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs); #define TCGV_PTR_TO_NAT(n) MAKE_TCGV_I32(GET_TCGV_PTR(n)) #define tcg_const_ptr(V) TCGV_NAT_TO_PTR(tcg_const_i32((intptr_t)(V))) +#define tcg_promise_ptr(V) TCGV_NAT_TO_PTR(tcg_promise_i32((intptr_t)(V))) +#define tcg_set_promise_ptr(V) TCGV_NAT_TO_PTR(tcg_set_promise_i32((intptr_t)(V))) #define tcg_global_reg_new_ptr(R, N) \ TCGV_NAT_TO_PTR(tcg_global_reg_new_i32((R), (N))) #define tcg_global_mem_new_ptr(R, O, N) \ @@ -757,6 +762,8 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs); #define TCGV_PTR_TO_NAT(n) MAKE_TCGV_I64(GET_TCGV_PTR(n)) #define tcg_const_ptr(V) TCGV_NAT_TO_PTR(tcg_const_i64((intptr_t)(V))) +#define tcg_promise_ptr(V) TCGV_NAT_TO_PTR(tcg_promise_i64((intptr_t)(V))) +#define tcg_set_promise_ptr(P, V) tcg_set_promise_i64(P, (intptr_t)(V))) #define tcg_global_reg_new_ptr(R, N) \ TCGV_NAT_TO_PTR(tcg_global_reg_new_i64((R), (N))) #define tcg_global_mem_new_ptr(R, O, N) \ @@ -780,6 +787,11 @@ TCGv_i64 tcg_const_i64(int64_t val); TCGv_i32 tcg_const_local_i32(int32_t val); TCGv_i64 tcg_const_local_i64(int64_t val); +TCGv_i32 tcg_promise_i32(TCGv_promise_i32 *promise); +TCGv_i64 tcg_promise_i64(TCGv_promise_i64 *promise); +void tcg_set_promise_i32(TCGv_promise_i32 promise, int32_t val); +void tcg_set_promise_i64(TCGv_promise_i64 promise, int64_t val); + TCGLabel *gen_new_label(void); /**