From patchwork Fri Mar 1 20:04:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 159510 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp1143394jad; Fri, 1 Mar 2019 12:08:25 -0800 (PST) X-Google-Smtp-Source: APXvYqw6e+XdOQ8eZc4UInNLVfFFbcbsZytAY3+RQFGxIGIDwc4i7ZIwkabP64Krk0428+Z4PgqL X-Received: by 2002:a25:e053:: with SMTP id x80mr5687762ybg.74.1551470904981; Fri, 01 Mar 2019 12:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551470904; cv=none; d=google.com; s=arc-20160816; b=UjnZdmUlt3imik1cL+0Zs07NkDX81g65V+5XOOH8lLKmwshSrguP/65cNUopKvTfft 31qmPs8L6vmhsXDK0gWhSGWA4ksaspmAGxcaooRk/B7v0fgzGyinLl/DbkhkOq+H1Us2 8cP8clq7Z+rpI/4FQlBbG2KVi4+D7XHQAACIVkr5yQ1UjRLO494SzDbm473lSG4aRW/O 14remQonNqszBPek2hnOYuOul6k1y8098t22qlTC4vhzqLrLrRmyubuh96GwycyDwX63 Nbj6FLFQNJ9g7dYYZoh6yDmNRyotfd9+Ni50cdj7nkvhcKDAuor3QbSIpwnwa5fs7KX7 r/fA== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=Kg6P2uEJ+aoxoinkMArLjz3096awj3cjZO5y9GHc4bg=; b=zYfoerWGwcLKk0CA1Podm7ztKW4n9p1HrsvooZX+PdrPo9vI5HP+eL4C9IOGT7hWlP pFiXCZzlTi1XLkMJhKkX98yQZn4MjzLwUP1C7gZD7a9ZmJKtDIpuuOTD/ZCEoroo8DTs Ta4E+xqEpCgtVvmCpmH4XEpRf8hUzpiFTGuLxHkCWnrqg3MT9SqlR37na8jkbjX5XUvh NzrdEqK7nGJZ4tM8qirET3bv9lQD2EFzOYZfjW8/WGNUaJlzS0lha24Kr9de9LVeiK3C 9LwAm3EUtPNBSq5NcJXEO0EqYTPXpAu266Av6zhpee9tJsY8yj1BorExNUrJC2tkjsX/ vRzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=H1PRpSOk; 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=fail (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 11si8945349ywx.197.2019.03.01.12.08.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Mar 2019 12:08:24 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=H1PRpSOk; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:43467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzoSG-000732-Cd for patch@linaro.org; Fri, 01 Mar 2019 15:08:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzoPd-0004kQ-JJ for qemu-devel@nongnu.org; Fri, 01 Mar 2019 15:05:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzoPM-0001qw-5L for qemu-devel@nongnu.org; Fri, 01 Mar 2019 15:05:32 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:36774) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzoPH-0001ha-Ul for qemu-devel@nongnu.org; Fri, 01 Mar 2019 15:05:21 -0500 Received: by mail-pf1-x441.google.com with SMTP id n22so11916355pfa.3 for ; Fri, 01 Mar 2019 12:05:15 -0800 (PST) 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; bh=Kg6P2uEJ+aoxoinkMArLjz3096awj3cjZO5y9GHc4bg=; b=H1PRpSOkIobt+ZnE9Ul00dToONR/GMdaSmAhpm4tfWzp50qUtU77qGP53xcmizjwZF AZQkhw4uGnyIMpqdZszWxnn3WOHIyn+4xxpg2Siua+rsm6As5eaEE1v79U6OMu3YiVVo cMHQ80fBRSlmTwAPM6E7JAIw0it3jLNZYPxVOGR9WuTQYzp/521UxSrkGpRsb1syMqBo zqMgAKlvEUDXTxcB6Zu3oJernUEyk0SYlR2WIDE36a0+4BwqVYgyxJh9SbNZlAQ6Pg83 AOnfASnGhuP6UJLhXgQO6pWEjW3OvA5qyLDka3TgAINwtU5zevxeG2mQsqSPDJOv7l8Z pEWQ== 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; bh=Kg6P2uEJ+aoxoinkMArLjz3096awj3cjZO5y9GHc4bg=; b=TDYCMBgjSHjDUbD9G6+lvNnWPwfkz68AHONS9xipKsHEsytw2AsIjfVH5gSbEjKukn 5ipYvu8jAe9NtD3C9FX04O2Edrj3cAs13JcbGe+1Pu3CErrV57xxq7PcP4nW+g7g/ti3 uYcGE2UIbfvPbAqQZCrV+kJcCMK7/Sk3IDzYMfOjfaAzr+NYxv9L0VcUtfxcMOyRfyX4 yANm8df2qujUQlHIXhTrqQATY5nLpSRF0qQvX1Q5Qinj5Y/GZSKknmFmMX23jCz/06uo H3mov+68LJFTpCmYxMK6bW5GnWCm0f03scA1uHSnboRfYhTAz9Ay3voRyGIdIyXFuiOI AArw== X-Gm-Message-State: APjAAAWVXGpaV6sCCrjUicAuHqDWNMal1TGVqKo/z9k4lhvBmIPGj7BH BVnT9XYS6xC03VVYt1J4savjz92Sekg= X-Received: by 2002:a63:4287:: with SMTP id p129mr6308689pga.84.1551470714585; Fri, 01 Mar 2019 12:05:14 -0800 (PST) Received: from cloudburst.twiddle.net (cpe-72-132-238-51.dc.res.rr.com. [72.132.238.51]) by smtp.gmail.com with ESMTPSA id x8sm31869206pfn.137.2019.03.01.12.05.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Mar 2019 12:05:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Mar 2019 12:04:58 -0800 Message-Id: <20190301200501.16533-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190301200501.16533-1-richard.henderson@linaro.org> References: <20190301200501.16533-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v3 07/10] target/arm: Implement ARMv8.4-CondM 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Tested-by: Laurent Desnogues Signed-off-by: Richard Henderson --- target/arm/cpu.h | 5 ++ linux-user/elfload.c | 1 + target/arm/cpu64.c | 1 + target/arm/translate-a64.c | 97 +++++++++++++++++++++++++++++++++++++- 4 files changed, 103 insertions(+), 1 deletion(-) -- 2.17.2 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c822f94236..fc2909ea6d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3431,6 +3431,11 @@ static inline bool isar_feature_aa64_fhm(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, FHM) != 0; } +static inline bool isar_feature_aa64_condm_4(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TS) != 0; +} + static inline bool isar_feature_aa64_jscvt(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, JSCVT) != 0; diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 6cfebe1446..6e8762b40d 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -605,6 +605,7 @@ static uint32_t get_elf_hwcap(void) GET_FEATURE_ID(aa64_fhm, ARM_HWCAP_A64_ASIMDFHM); GET_FEATURE_ID(aa64_jscvt, ARM_HWCAP_A64_JSCVT); GET_FEATURE_ID(aa64_sb, ARM_HWCAP_A64_SB); + GET_FEATURE_ID(aa64_condm_4, ARM_HWCAP_A64_FLAGM); #undef GET_FEATURE_ID diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 87337b6385..fcf79321e2 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -309,6 +309,7 @@ static void aarch64_max_initfn(Object *obj) t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); + t = FIELD_DP64(t, ID_AA64ISAR0, TS, 1); cpu->isar.id_aa64isar0 = t; t = cpu->isar.id_aa64isar1; diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 12d2649c20..49a09b58e3 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1657,6 +1657,14 @@ static void handle_msr_i(DisasContext *s, uint32_t insn, s->base.is_jmp = DISAS_TOO_MANY; switch (op) { + case 0x00: /* CFINV */ + if (crm != 0 || !dc_isar_feature(aa64_condm_4, s)) { + goto do_unallocated; + } + tcg_gen_xori_i32(cpu_CF, cpu_CF, 1); + s->base.is_jmp = DISAS_NEXT; + break; + case 0x05: /* SPSel */ if (s->current_el == 0) { goto do_unallocated; @@ -1710,7 +1718,6 @@ static void gen_get_nzcv(TCGv_i64 tcg_rt) } static void gen_set_nzcv(TCGv_i64 tcg_rt) - { TCGv_i32 nzcv = tcg_temp_new_i32(); @@ -4529,6 +4536,82 @@ static void disas_adc_sbc(DisasContext *s, uint32_t insn) } } +/* Rotate right into flags + * 31 30 29 21 15 10 5 4 0 + * +--+--+--+-----------------+--------+-----------+------+--+------+ + * |sf|op| S| 1 1 0 1 0 0 0 0 | imm6 | 0 0 0 0 1 | Rn |o2| mask | + * +--+--+--+-----------------+--------+-----------+------+--+------+ + */ +static void disas_rotate_right_into_flags(DisasContext *s, uint32_t insn) +{ + int mask = extract32(insn, 0, 4); + int o2 = extract32(insn, 4, 1); + int rn = extract32(insn, 5, 5); + int imm6 = extract32(insn, 15, 6); + int sf_op_s = extract32(insn, 29, 3); + TCGv_i64 tcg_rn; + TCGv_i32 nzcv; + + if (sf_op_s != 5 || o2 != 0 || !dc_isar_feature(aa64_condm_4, s)) { + unallocated_encoding(s); + return; + } + + tcg_rn = read_cpu_reg(s, rn, 1); + tcg_gen_rotri_i64(tcg_rn, tcg_rn, imm6); + + nzcv = tcg_temp_new_i32(); + tcg_gen_extrl_i64_i32(nzcv, tcg_rn); + + if (mask & 8) { /* N */ + tcg_gen_shli_i32(cpu_NF, nzcv, 31 - 3); + } + if (mask & 4) { /* Z */ + tcg_gen_not_i32(cpu_ZF, nzcv); + tcg_gen_andi_i32(cpu_ZF, cpu_ZF, 4); + } + if (mask & 2) { /* C */ + tcg_gen_extract_i32(cpu_CF, nzcv, 1, 1); + } + if (mask & 1) { /* V */ + tcg_gen_shli_i32(cpu_VF, nzcv, 31 - 0); + } + + tcg_temp_free_i32(nzcv); +} + +/* Evaluate into flags + * 31 30 29 21 15 14 10 5 4 0 + * +--+--+--+-----------------+---------+----+---------+------+--+------+ + * |sf|op| S| 1 1 0 1 0 0 0 0 | opcode2 | sz | 0 0 1 0 | Rn |o3| mask | + * +--+--+--+-----------------+---------+----+---------+------+--+------+ + */ +static void disas_evaluate_into_flags(DisasContext *s, uint32_t insn) +{ + int o3_mask = extract32(insn, 0, 5); + int rn = extract32(insn, 5, 5); + int o2 = extract32(insn, 15, 6); + int sz = extract32(insn, 14, 1); + int sf_op_s = extract32(insn, 29, 3); + TCGv_i32 tmp; + int shift; + + if (sf_op_s != 1 || o2 != 0 || o3_mask != 0xd || + !dc_isar_feature(aa64_condm_4, s)) { + unallocated_encoding(s); + return; + } + shift = sz ? 16 : 24; /* SETF16 or SETF8 */ + + tmp = tcg_temp_new_i32(); + tcg_gen_extrl_i64_i32(tmp, cpu_reg(s, rn)); + tcg_gen_shli_i32(cpu_NF, tmp, shift); + tcg_gen_shli_i32(cpu_VF, tmp, shift - 1); + tcg_gen_mov_i32(cpu_ZF, cpu_NF); + tcg_gen_xor_i32(cpu_VF, cpu_VF, cpu_NF); + tcg_temp_free_i32(tmp); +} + /* Conditional compare (immediate / register) * 31 30 29 28 27 26 25 24 23 22 21 20 16 15 12 11 10 9 5 4 3 0 * +--+--+--+------------------------+--------+------+----+--+------+--+-----+ @@ -5195,6 +5278,18 @@ static void disas_data_proc_reg(DisasContext *s, uint32_t insn) disas_adc_sbc(s, insn); break; + case 0x01: /* Rotate right into flags */ + case 0x21: + disas_rotate_right_into_flags(s, insn); + break; + + case 0x02: /* Evaluate into flags */ + case 0x12: + case 0x22: + case 0x32: + disas_evaluate_into_flags(s, insn); + break; + default: goto do_unallocated; }