From patchwork Mon Sep 5 23:55:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 113464 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2F203B6F7C for ; Tue, 6 Sep 2011 11:17:32 +1000 (EST) Received: from localhost ([::1]:46035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0j27-0004WV-VY for incoming@patchwork.ozlabs.org; Mon, 05 Sep 2011 19:56:55 -0400 Received: from eggs.gnu.org ([140.186.70.92]:36863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0j1K-0003Cc-EY for qemu-devel@nongnu.org; Mon, 05 Sep 2011 19:56:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0j1E-0003IM-U6 for qemu-devel@nongnu.org; Mon, 05 Sep 2011 19:56:05 -0400 Received: from [188.134.19.124] (port=53313 helo=octofox.metropolis) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0j1E-0003Hh-FP for qemu-devel@nongnu.org; Mon, 05 Sep 2011 19:56:00 -0400 Received: from octofox.metropolis (localhost [127.0.0.1]) by octofox.metropolis (8.14.5/8.14.5) with ESMTP id p85Nu93x023060; Tue, 6 Sep 2011 03:56:09 +0400 Received: (from jcmvbkbc@localhost) by octofox.metropolis (8.14.5/8.14.5/Submit) id p85Nu9Ah023059; Tue, 6 Sep 2011 03:56:09 +0400 From: Max Filippov To: qemu-devel@nongnu.org Date: Tue, 6 Sep 2011 03:55:36 +0400 Message-Id: <1315266957-22979-13-git-send-email-jcmvbkbc@gmail.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1315266957-22979-1-git-send-email-jcmvbkbc@gmail.com> References: <1315266957-22979-1-git-send-email-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 188.134.19.124 Cc: jcmvbkbc@gmail.com Subject: [Qemu-devel] [PATCH v5 12/33] target-xtensa: implement LSAI group 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org - base + offset load/store operations for 1/2/4 byte values; - cache operations (not implemented); - multiprocessor synchronization operations. Signed-off-by: Max Filippov --- target-xtensa/cpu.h | 1 + target-xtensa/translate.c | 89 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 0 deletions(-) diff --git a/target-xtensa/cpu.h b/target-xtensa/cpu.h index f756b43..ac9bbb4 100644 --- a/target-xtensa/cpu.h +++ b/target-xtensa/cpu.h @@ -107,6 +107,7 @@ enum { enum { SAR = 3, + SCOMPARE1 = 12, }; typedef struct XtensaConfig { diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c index fd18950..dd89017 100644 --- a/target-xtensa/translate.c +++ b/target-xtensa/translate.c @@ -64,6 +64,7 @@ static TCGv_i32 cpu_UR[256]; static const char * const sregnames[256] = { [SAR] = "SAR", + [SCOMPARE1] = "SCOMPARE1", }; static const char * const uregnames[256] = { @@ -860,7 +861,95 @@ static void disas_xtensa_insn(DisasContext *dc) break; case 2: /*LSAI*/ +#define gen_load_store(type, shift) do { \ + TCGv_i32 addr = tcg_temp_new_i32(); \ + tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << shift); \ + tcg_gen_qemu_##type(cpu_R[RRI8_T], addr, 0); \ + tcg_temp_free(addr); \ + } while (0) + + switch (RRI8_R) { + case 0: /*L8UI*/ + gen_load_store(ld8u, 0); + break; + + case 1: /*L16UI*/ + gen_load_store(ld16u, 1); + break; + + case 2: /*L32I*/ + gen_load_store(ld32u, 2); + break; + + case 4: /*S8I*/ + gen_load_store(st8, 0); + break; + + case 5: /*S16I*/ + gen_load_store(st16, 1); + break; + + case 6: /*S32I*/ + gen_load_store(st32, 2); + break; + + case 7: /*CACHEc*/ + break; + + case 9: /*L16SI*/ + gen_load_store(ld16s, 1); + break; + + case 10: /*MOVI*/ + tcg_gen_movi_i32(cpu_R[RRI8_T], + RRI8_IMM8 | (RRI8_S << 8) | + ((RRI8_S & 0x8) ? 0xfffff000 : 0)); + break; + + case 11: /*L32AIy*/ + HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO); + gen_load_store(ld32u, 2); /*TODO acquire?*/ + break; + + case 12: /*ADDI*/ + tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE); + break; + + case 13: /*ADDMI*/ + tcg_gen_addi_i32(cpu_R[RRI8_T], cpu_R[RRI8_S], RRI8_IMM8_SE << 8); + break; + + case 14: /*S32C1Iy*/ + HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO); + { + int label = gen_new_label(); + TCGv_i32 tmp = tcg_temp_local_new_i32(); + TCGv_i32 addr = tcg_temp_local_new_i32(); + + tcg_gen_mov_i32(tmp, cpu_R[RRI8_T]); + tcg_gen_addi_i32(addr, cpu_R[RRI8_S], RRI8_IMM8 << 2); + tcg_gen_qemu_ld32u(cpu_R[RRI8_T], addr, 0); + tcg_gen_brcond_i32(TCG_COND_NE, cpu_R[RRI8_T], + cpu_SR[SCOMPARE1], label); + + tcg_gen_qemu_st32(tmp, addr, 0); + + gen_set_label(label); + tcg_temp_free(addr); + tcg_temp_free(tmp); + } + break; + + case 15: /*S32RIy*/ + HAS_OPTION(XTENSA_OPTION_MP_SYNCHRO); + gen_load_store(st32, 2); /*TODO release?*/ + break; + + default: /*reserved*/ + break; + } break; +#undef gen_load_store case 3: /*LSCIp*/ HAS_OPTION(XTENSA_OPTION_COPROCESSOR);