From patchwork Sat Feb 6 00:09:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 8240661 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 4954ABEEE5 for ; Sat, 6 Feb 2016 00:12:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52868203C0 for ; Sat, 6 Feb 2016 00:12:22 +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 53F60203B4 for ; Sat, 6 Feb 2016 00:12:21 +0000 (UTC) Received: from localhost ([::1]:50979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqU8-0002cL-K0 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 05 Feb 2016 19:12:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqS9-0007nX-Md for qemu-devel@nongnu.org; Fri, 05 Feb 2016 19:10:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRqS8-0006sW-54 for qemu-devel@nongnu.org; Fri, 05 Feb 2016 19:10:17 -0500 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:35307) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRqS8-0006sS-07 for qemu-devel@nongnu.org; Fri, 05 Feb 2016 19:10:16 -0500 Received: by mail-qk0-x22c.google.com with SMTP id o6so40839223qkc.2 for ; Fri, 05 Feb 2016 16:10:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wrGZgJHoyEn555WAaHw14g6w2kj5bIOlva4sPRP9GDI=; b=bt+NeAID89IZgbVSe94OS+Br4ajXFKG16yndTQV7pytIdZx7Kv1gJlfwPUpiUgWyZB FdZFQHe/ub8nVCzPkxvFrrXuV9u+/VlTd9I5CrDRJITW+tqLj8agAw+MSzqZB+Yj2+eR qMFMe9YXXWv26O3zxg/YbZm08hmD+uDPim/d1L2f69tqZojdj5I2M6ieAlcTGUU6gjhS 7+H6Jomq88uypdgP8OZYMUK7CpVIS79XlpVQE2O/2HwPV9Aaa9cU3UcIqnyGMl8rbMrJ tmddTCHJXqn5c75Psv2HCFWbp8Le/0MEZDUUEFsrSpQxvaY7wGkLI1Ec+MCXXkT3xHKx dMXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=wrGZgJHoyEn555WAaHw14g6w2kj5bIOlva4sPRP9GDI=; b=ULQeMzkPgZh15BE9PTqi3G4sawVXyMA42PoPdVpbt7kQ9tHoshOpWSJXzdZ3ukpBdu erxIyvq1/wk3caV5ogwX9uHLSEp2WUPa0zSf6mWeyOBX7O421jyt148DBpkn/tWG0box z8q9UyI8eJMCcx5Qh731pp8pUTjSTfbDF7inGY8Ok3e25vy/m6NGVEzj6m1eh1gFvudA Hxr/bwQbfEb+7amlBegHfcA0Itu6dBNN1Q08cNEXXxaolsfvKI1hI3ZR//9IPaEIoB/i owW2EM87AeLwJR9zeNF4blbx7TXO0jcRY+X17RC69Zj/NudF1t1B74W3lHrYhI2T7YRv cVMQ== X-Gm-Message-State: AG10YORdFLhNDtknGcAyAp0ajZ6j16P7Oj/xWmrrKCkcyu5tCZP4qGQ/RGjSNVq+8rb1fg== X-Received: by 10.55.71.66 with SMTP id u63mr19863517qka.67.1454717415741; Fri, 05 Feb 2016 16:10:15 -0800 (PST) Received: from bigtime.com ([1.129.57.172]) by smtp.gmail.com with ESMTPSA id w66sm9079564qhc.15.2016.02.05.16.10.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Feb 2016 16:10:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 6 Feb 2016 11:09:22 +1100 Message-Id: <1454717370-17516-5-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454717370-17516-1-git-send-email-rth@twiddle.net> References: <1454717370-17516-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::22c Cc: peter.maydell@linaro.org Subject: [Qemu-devel] [PULL 04/12] tcg: Change ts->mem_reg to ts->mem_base 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 Chain the temporaries together via pointers intstead of indices. The mem_reg value is now mem_base->reg. This will be important later. This does require that the frame pointer have a global temporary allocated for it. This is simple bar the existing reserved_regs check. Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson --- tcg/tcg.c | 65 +++++++++++++++++++++++++++++++++++---------------------------- tcg/tcg.h | 4 ++-- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index a66a1b3..ae59f60 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -403,13 +403,6 @@ void tcg_prologue_init(TCGContext *s) #endif } -void tcg_set_frame(TCGContext *s, int reg, intptr_t start, intptr_t size) -{ - s->frame_start = start; - s->frame_end = start + size; - s->frame_reg = reg; -} - void tcg_func_start(TCGContext *s) { tcg_pool_reset(s); @@ -439,19 +432,15 @@ static inline void tcg_temp_alloc(TCGContext *s, int n) tcg_abort(); } -static inline int tcg_global_reg_new_internal(TCGType type, int reg, - const char *name) +static int tcg_global_reg_new_internal(TCGContext *s, TCGType type, + int reg, const char *name) { - TCGContext *s = &tcg_ctx; TCGTemp *ts; int idx; -#if TCG_TARGET_REG_BITS == 32 - if (type != TCG_TYPE_I32) - tcg_abort(); -#endif - if (tcg_regset_test_reg(s->reserved_regs, reg)) + if (TCG_TARGET_REG_BITS == 32 && type != TCG_TYPE_I32) { tcg_abort(); + } idx = s->nb_globals; tcg_temp_alloc(s, s->nb_globals + 1); ts = &s->temps[s->nb_globals]; @@ -465,19 +454,36 @@ static inline int tcg_global_reg_new_internal(TCGType type, int reg, return idx; } +void tcg_set_frame(TCGContext *s, int reg, intptr_t start, intptr_t size) +{ + int idx; + s->frame_start = start; + s->frame_end = start + size; + idx = tcg_global_reg_new_internal(s, TCG_TYPE_PTR, reg, "_frame"); + s->frame_temp = &s->temps[idx]; +} + TCGv_i32 tcg_global_reg_new_i32(int reg, const char *name) { + TCGContext *s = &tcg_ctx; int idx; - idx = tcg_global_reg_new_internal(TCG_TYPE_I32, reg, name); + if (tcg_regset_test_reg(s->reserved_regs, reg)) { + tcg_abort(); + } + idx = tcg_global_reg_new_internal(s, TCG_TYPE_I32, reg, name); return MAKE_TCGV_I32(idx); } TCGv_i64 tcg_global_reg_new_i64(int reg, const char *name) { + TCGContext *s = &tcg_ctx; int idx; - idx = tcg_global_reg_new_internal(TCG_TYPE_I64, reg, name); + if (tcg_regset_test_reg(s->reserved_regs, reg)) { + tcg_abort(); + } + idx = tcg_global_reg_new_internal(s, TCG_TYPE_I64, reg, name); return MAKE_TCGV_I64(idx); } @@ -486,7 +492,7 @@ int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, { TCGContext *s = &tcg_ctx; TCGTemp *ts, *base_ts = &s->temps[GET_TCGV_PTR(base)]; - int idx, reg = base_ts->reg; + int idx; idx = s->nb_globals; #if TCG_TARGET_REG_BITS == 32 @@ -498,7 +504,7 @@ int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, ts->type = TCG_TYPE_I32; ts->fixed_reg = 0; ts->mem_allocated = 1; - ts->mem_reg = reg; + ts->mem_base = base_ts; #ifdef HOST_WORDS_BIGENDIAN ts->mem_offset = offset + 4; #else @@ -513,7 +519,7 @@ int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, ts->type = TCG_TYPE_I32; ts->fixed_reg = 0; ts->mem_allocated = 1; - ts->mem_reg = reg; + ts->mem_base = base_ts; #ifdef HOST_WORDS_BIGENDIAN ts->mem_offset = offset; #else @@ -533,7 +539,7 @@ int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, ts->type = type; ts->fixed_reg = 0; ts->mem_allocated = 1; - ts->mem_reg = reg; + ts->mem_base = base_ts; ts->mem_offset = offset; ts->name = name; s->nb_globals++; @@ -1587,7 +1593,8 @@ static void dump_regs(TCGContext *s) printf("%s", tcg_target_reg_names[ts->reg]); break; case TEMP_VAL_MEM: - printf("%d(%s)", (int)ts->mem_offset, tcg_target_reg_names[ts->mem_reg]); + printf("%d(%s)", (int)ts->mem_offset, + tcg_target_reg_names[ts->mem_base->reg]); break; case TEMP_VAL_CONST: printf("$0x%" TCG_PRIlx, ts->val); @@ -1660,7 +1667,7 @@ static void temp_allocate_frame(TCGContext *s, int temp) tcg_abort(); } ts->mem_offset = s->current_frame_offset; - ts->mem_reg = s->frame_reg; + ts->mem_base = s->frame_temp; ts->mem_allocated = 1; s->current_frame_offset += sizeof(tcg_target_long); } @@ -1678,7 +1685,7 @@ static inline void tcg_reg_sync(TCGContext *s, int reg) if (!ts->mem_allocated) { temp_allocate_frame(s, temp); } - tcg_out_st(s, ts->type, reg, ts->mem_reg, ts->mem_offset); + tcg_out_st(s, ts->type, reg, ts->mem_base->reg, ts->mem_offset); } ts->mem_coherent = 1; } @@ -1894,7 +1901,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def, ts->reg = tcg_reg_alloc(s, tcg_target_available_regs[itype], allocated_regs); if (ts->val_type == TEMP_VAL_MEM) { - tcg_out_ld(s, itype, ts->reg, ts->mem_reg, ts->mem_offset); + tcg_out_ld(s, itype, ts->reg, ts->mem_base->reg, ts->mem_offset); ts->mem_coherent = 1; } else if (ts->val_type == TEMP_VAL_CONST) { tcg_out_movi(s, itype, ts->reg, ts->val); @@ -1913,7 +1920,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def, if (!ots->mem_allocated) { temp_allocate_frame(s, args[0]); } - tcg_out_st(s, otype, ts->reg, ots->mem_reg, ots->mem_offset); + tcg_out_st(s, otype, ts->reg, ots->mem_base->reg, ots->mem_offset); if (IS_DEAD_ARG(1)) { temp_dead(s, args[1]); } @@ -1988,7 +1995,7 @@ static void tcg_reg_alloc_op(TCGContext *s, ts = &s->temps[arg]; if (ts->val_type == TEMP_VAL_MEM) { reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs); - tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset); + tcg_out_ld(s, ts->type, reg, ts->mem_base->reg, ts->mem_offset); ts->val_type = TEMP_VAL_REG; ts->reg = reg; ts->mem_coherent = 1; @@ -2182,7 +2189,7 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, reg = tcg_reg_alloc(s, tcg_target_available_regs[ts->type], s->reserved_regs); /* XXX: not correct if reading values from the stack */ - tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset); + tcg_out_ld(s, ts->type, reg, ts->mem_base->reg, ts->mem_offset); tcg_out_st(s, ts->type, reg, TCG_REG_CALL_STACK, stack_offset); } else if (ts->val_type == TEMP_VAL_CONST) { reg = tcg_reg_alloc(s, tcg_target_available_regs[ts->type], @@ -2212,7 +2219,7 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, tcg_out_mov(s, ts->type, reg, ts->reg); } } else if (ts->val_type == TEMP_VAL_MEM) { - tcg_out_ld(s, ts->type, reg, ts->mem_reg, ts->mem_offset); + tcg_out_ld(s, ts->type, reg, ts->mem_base->reg, ts->mem_offset); } else if (ts->val_type == TEMP_VAL_CONST) { /* XXX: sign extend ? */ tcg_out_movi(s, ts->type, reg, ts->val); diff --git a/tcg/tcg.h b/tcg/tcg.h index e528b07..8b7efed 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -449,7 +449,6 @@ typedef enum TCGTempVal { typedef struct TCGTemp { unsigned int reg:8; - unsigned int mem_reg:8; TCGTempVal val_type:8; TCGType base_type:8; TCGType type:8; @@ -462,6 +461,7 @@ typedef struct TCGTemp { unsigned int temp_allocated:1; /* never used for code gen */ tcg_target_long val; + struct TCGTemp *mem_base; intptr_t mem_offset; const char *name; } TCGTemp; @@ -515,7 +515,7 @@ struct TCGContext { intptr_t current_frame_offset; intptr_t frame_start; intptr_t frame_end; - int frame_reg; + TCGTemp *frame_temp; tcg_insn_unit *code_ptr;