From patchwork Fri Aug 28 14:19:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 248571 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp1144969ilg; Fri, 28 Aug 2020 07:47:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykxpO/f5a2UxZkaGYIAMMWkar5x9uiAsTnptaF5+8Z6L6kOccF1taQfZ7ehvSAtl7GspS5 X-Received: by 2002:a25:880e:: with SMTP id c14mr2982144ybl.181.1598626021920; Fri, 28 Aug 2020 07:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598626021; cv=none; d=google.com; s=arc-20160816; b=pCcioTsE/DXlH5Nt7iQFxOUsaAJp//XneD8AoaS6Gzsx3LLuXQ6FjbwoB/FIt3+Fl3 jfQ2Atq8xeIgw8Sb2nHCFBz+37ois7Ti/HOBHof5+07c9XK6RdjackpDIoLfxrxA3jrV k1DWsKEkHjSGQ1z0HFNT0l0Q6tG3aHYVtno5SwhIoCljQdWErRHmYIRHtKNiCsewN+4k 7/RDieVskspSsq4+vGEJ+mcu8Nwun2d9D4DsY8ki7nLgbhDCa123Jh/gqaqqoYBpwWYP Fykj3Jo+7jNkkYfYLw0a2QiJwtCp+AbpwL2cyRiRbL/vTbQwIth72ob19QnBzOrffx+d aHlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=y7g+vxFhMw85rMJ1Bmcl22gP9lkhC8wxslY5gGE46W4=; b=jOtZADo6OwfMrbKjFinF6AW+6WXqbut9jMrMyn1OgpWVNGnML/30qfpIFeZ/4brql6 s58YSAnrDfK20mirIH1gHQqPcYMNG/sU4VebMRWFKF3Wpoi9tPkoUw5FdtLRwguDfIXK rZCs4u+8FN4n78NE0ZhofhJk55gzZ5P+BLTIBmu78e1JBnHMJ2PKfhGhPWc6RCn7S/KE R8ua/AiqWHry+cdKVTaRpIDsCtXazw2OfLojpdq/UCDc0x/WZH1Zc6z7i9YOTLzlJCmj 0OhQvAT4mO/O8DB0N7H0XLIqzQc+7H1B++abCvmPm92m2CVcqHFOgn7Cuv2dvPUTMqik vRDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MpqZXVdR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l17si1052473ybm.328.2020.08.28.07.47.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Aug 2020 07:47:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MpqZXVdR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBfef-0003Zu-Bx for patch@linaro.org; Fri, 28 Aug 2020 10:47:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBfFT-0002K1-I2 for qemu-devel@nongnu.org; Fri, 28 Aug 2020 10:20:59 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:42642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kBfFR-0005QZ-C4 for qemu-devel@nongnu.org; Fri, 28 Aug 2020 10:20:59 -0400 Received: by mail-pf1-x430.google.com with SMTP id 17so731158pfw.9 for ; Fri, 28 Aug 2020 07:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y7g+vxFhMw85rMJ1Bmcl22gP9lkhC8wxslY5gGE46W4=; b=MpqZXVdRv1W9+xV3clZrD0rtke4Ef3DzUsgmJfpDv/+wGWwJnmzZykIODF8eVdtpyY nQFz6sAvea9S+KaUWaoNJu3+Ow4aQkUqDx6z7AuY8xAqhYQntNgaDe9wvzSYtPg2tvdq tCe0C8QS5ZKTQKvefOxZ6wsGLqpSYH+sfCDakRyODbzTMa78oc7HO5Mv5fibJAEl3WHC 5X/4MEVfRW1nMrTjD/uHDdjGgllTHdNuQc+HI2Qyax5m6BbrX4OzKYcemahhaREylpYj x9oEU56sJ/H8iaQbcxCFzH/NWcV1iRV4GDgXpuZrMLPFF+oJiGADQumFcETc+xiJ6h9d tRiw== 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=y7g+vxFhMw85rMJ1Bmcl22gP9lkhC8wxslY5gGE46W4=; b=N5SavT7UNtsjw/10cKLoMWkK/Mtzq3yDYkgETRBb9AT9XYNMAb8bI88mznckwncYoq 6bpzncjM35WXrWMSa0wrKlHeKCThDrw0qbE7HUFhiy3whf5hcVNqFNRkOHdz1SOS8Ziv s8HE2H0D6z8u23oQjETkKdh5t6edgkrShOs6h3nSPWxiyYGPdaYW731Bxn+lW9TQTPTx cyZpMiC7igeR8EAgeaCo/qZSoN/ugRkWIkZlLKFqhrFfiUI9xT3GsRdnCgx/NuEdqXSC DuJ+DD/Axa1bfuz65dHQty6WALjKG+b+dw9llXEiqBtJKn/g2BddsCU51OVThnqUZcvP vLsA== X-Gm-Message-State: AOAM531mAmNteA4P8QqhT8fC4TriGz4B+72DbfYQBmjAWFR54eQT+Ugd lUP27cgiemwbAbeMhtHRLp5av9tSqtTILg== X-Received: by 2002:a62:1b0e:: with SMTP id b14mr1494489pfb.281.1598624455699; Fri, 28 Aug 2020 07:20:55 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id j3sm1403080pjw.23.2020.08.28.07.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 07:20:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 66/76] target/microblaze: Convert dec_br to decodetree Date: Fri, 28 Aug 2020 07:19:19 -0700 Message-Id: <20200828141929.77854-67-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200828141929.77854-1-richard.henderson@linaro.org> References: <20200828141929.77854-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: edgar.iglesias@xilinx.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/microblaze/insns.decode | 14 ++++++ target/microblaze/translate.c | 87 +++++++++++++++++++--------------- 2 files changed, 63 insertions(+), 38 deletions(-) -- 2.25.1 diff --git a/target/microblaze/insns.decode b/target/microblaze/insns.decode index 8eba47d90c..340dd999b6 100644 --- a/target/microblaze/insns.decode +++ b/target/microblaze/insns.decode @@ -68,6 +68,20 @@ andi 101001 ..... ..... ................ @typeb andn 100011 ..... ..... ..... 000 0000 0000 @typea andni 101011 ..... ..... ................ @typeb +br 100110 ..... 00000 ..... 000 0000 0000 @typea_br +bra 100110 ..... 01000 ..... 000 0000 0000 @typea_br +brd 100110 ..... 10000 ..... 000 0000 0000 @typea_br +brad 100110 ..... 11000 ..... 000 0000 0000 @typea_br +brld 100110 ..... 10100 ..... 000 0000 0000 @typea_br +brald 100110 ..... 11100 ..... 000 0000 0000 @typea_br + +bri 101110 ..... 00000 ................ @typeb_br +brai 101110 ..... 01000 ................ @typeb_br +brid 101110 ..... 10000 ................ @typeb_br +braid 101110 ..... 11000 ................ @typeb_br +brlid 101110 ..... 10100 ................ @typeb_br +bralid 101110 ..... 11100 ................ @typeb_br + brk 100110 ..... 01100 ..... 000 0000 0000 @typea_br brki 101110 ..... 01100 ................ @typeb_br diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 1545974669..5c6e6e599e 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1048,6 +1048,53 @@ static bool trans_swx(DisasContext *dc, arg_typea *arg) return true; } +static void setup_dslot(DisasContext *dc, bool type_b) +{ + dc->tb_flags_to_set |= D_FLAG; + if (type_b && (dc->tb_flags & IMM_FLAG)) { + dc->tb_flags_to_set |= BIMM_FLAG; + } +} + +static bool do_branch(DisasContext *dc, int dest_rb, int dest_imm, + bool delay, bool abs, int link) +{ + uint32_t add_pc; + + if (delay) { + setup_dslot(dc, dest_rb < 0); + } + + if (link) { + tcg_gen_movi_i32(cpu_R[link], dc->base.pc_next); + } + + /* Store the branch taken destination into btarget. */ + add_pc = abs ? 0 : dc->base.pc_next; + if (dest_rb > 0) { + dc->jmp_dest = -1; + tcg_gen_addi_i32(cpu_btarget, cpu_R[dest_rb], add_pc); + } else { + dc->jmp_dest = add_pc + dest_imm; + tcg_gen_movi_i32(cpu_btarget, dc->jmp_dest); + } + dc->jmp_cond = TCG_COND_ALWAYS; + return true; +} + +#define DO_BR(NAME, NAMEI, DELAY, ABS, LINK) \ + static bool trans_##NAME(DisasContext *dc, arg_typea_br *arg) \ + { return do_branch(dc, arg->rb, 0, DELAY, ABS, LINK ? arg->rd : 0); } \ + static bool trans_##NAMEI(DisasContext *dc, arg_typeb_br *arg) \ + { return do_branch(dc, -1, arg->imm, DELAY, ABS, LINK ? arg->rd : 0); } + +DO_BR(br, bri, false, false, false) +DO_BR(bra, brai, false, true, false) +DO_BR(brd, brid, true, false, false) +DO_BR(brad, braid, true, true, false) +DO_BR(brld, brlid, true, false, true) +DO_BR(brald, bralid, true, true, true) + static bool trans_brk(DisasContext *dc, arg_typea_br *arg) { if (trap_userspace(dc, true)) { @@ -1372,14 +1419,6 @@ static void dec_msr(DisasContext *dc) } } -static void dec_setup_dslot(DisasContext *dc) -{ - dc->tb_flags_to_set |= D_FLAG; - if (dc->type_b && (dc->tb_flags & IMM_FLAG)) { - dc->tb_flags_to_set |= BIMM_FLAG; - } -} - static void dec_bcc(DisasContext *dc) { static const TCGCond mb_to_tcg_cc[] = { @@ -1398,7 +1437,7 @@ static void dec_bcc(DisasContext *dc) dslot = dc->ir & (1 << 25); if (dslot) { - dec_setup_dslot(dc); + setup_dslot(dc, dc->type_b); } dc->jmp_cond = mb_to_tcg_cc[cc]; @@ -1426,33 +1465,6 @@ static void dec_bcc(DisasContext *dc) tcg_temp_free_i32(next); } -static void dec_br(DisasContext *dc) -{ - unsigned int dslot, link, abs; - uint32_t add_pc; - - dslot = dc->ir & (1 << 20); - abs = dc->ir & (1 << 19); - link = dc->ir & (1 << 18); - - if (dslot) { - dec_setup_dslot(dc); - } - if (link && dc->rd) { - tcg_gen_movi_i32(cpu_R[dc->rd], dc->base.pc_next); - } - - add_pc = abs ? 0 : dc->base.pc_next; - if (dc->type_b) { - dc->jmp_dest = add_pc + dec_alu_typeb_imm(dc); - tcg_gen_movi_i32(cpu_btarget, dc->jmp_dest); - } else { - dc->jmp_dest = -1; - tcg_gen_addi_i32(cpu_btarget, cpu_R[dc->rb], add_pc); - } - dc->jmp_cond = TCG_COND_ALWAYS; -} - static inline void do_rti(DisasContext *dc) { TCGv_i32 t0, t1; @@ -1521,7 +1533,7 @@ static void dec_rts(DisasContext *dc) return; } - dec_setup_dslot(dc); + setup_dslot(dc, true); if (i_bit) { dc->tb_flags |= DRTI_FLAG; @@ -1583,7 +1595,6 @@ static struct decoder_info { }; void (*dec)(DisasContext *dc); } decinfo[] = { - {DEC_BR, dec_br}, {DEC_BCC, dec_bcc}, {DEC_RTS, dec_rts}, {DEC_MSR, dec_msr},