From patchwork Mon Sep 9 17:28:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 826635 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp2130954wrb; Mon, 9 Sep 2024 10:31:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW323XtT/HNqvM7mrX0ir7TpmKJWpZq7tpMYxegiCsGsITOe0QRn9pN2WzZnCXYsTqNGBU0SA==@linaro.org X-Google-Smtp-Source: AGHT+IGOKgU7WKRWN2I1aLLHX9b6hOGEo+3ivipk5EYhElA5KbZj4qODoUX4M3yF8ScX3e99pFtI X-Received: by 2002:a67:f9d6:0:b0:49b:d061:d6f with SMTP id ada2fe7eead31-49bde268077mr11218481137.18.1725903092987; Mon, 09 Sep 2024 10:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725903092; cv=none; d=google.com; s=arc-20240605; b=frYLF0KU66R+IJPGrrIDL6uEq7Sua8O0LyA0k3aRwQfT8MzXZWjI1NpiurYJg07J4F N8cQPFPyk74pUPGmPISq51jP4S3NSPr3uWC1vfrRms1Jc8TQ5DZ1784eenOU/fPy6oUh KsG1WGSsvQepUw0Oy+L5thLe9OuG2waWEI3XGtz/kBduk7ewmmLDk9IiEDnDKP8rauJW jg1nVOhHHAMxmVFnIoeSO7QxYpQWLhlDcvyimSsumbE6faMVy3x6o/bZbRuIEkGgJrVv BOb4VAdNy8LqORwv2vv311uIb2xCzJ9FeG4q/sw4Ynj49xzNjoyDgSFX1IWw1P7Lh5mk QMIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=IVrsW+o3FMgR3VpWI1k5gdQknpFqVu925X71ufmaWs0=; fh=4bMsMJJHDmTQNFavmZaD/iTPOPK/LdH9YFdHoY+StpE=; b=Oi4pDLbpqae/BBD1M6O816Xl7ItsKchIVQIE7fEKlYtaU/aEVBsb5n32WYKghOZUEV iE1GElRQlzScLvehpKI+5+pOpcu9fZQksO4Z8MJOCvsU/xEZ0+UTpiKnV+3zvxVEzZZb lD3rSSEdRicw4hVPxehoCxDNJo5+fOWZBsbI0ZaPjJc4HKFo2LJQDd3wSyF43ODg5Byv xg60k55ReLKnpw8uzxT7FMRUSJjD3ppgvuf5uE0Owv+IxF5jn1udhQb0AN2QLGKJ14lC RcptvzHEzAv+8Wurrj3uRErmRyVXyjhjMwyGEf1atq02J5aCZRDFK+9blTxxJ18FWHm+ qKGw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N2vxc4UU; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-49bf0aa306csi1061901137.710.2024.09.09.10.31.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Sep 2024 10:31:32 -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=N2vxc4UU; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sniC4-0005Mc-Ki; Mon, 09 Sep 2024 13:28:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sniBz-0004zq-Li for qemu-devel@nongnu.org; Mon, 09 Sep 2024 13:28:48 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sniBx-000643-9o for qemu-devel@nongnu.org; Mon, 09 Sep 2024 13:28:47 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-20543fdb7acso31749265ad.1 for ; Mon, 09 Sep 2024 10:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725902924; x=1726507724; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IVrsW+o3FMgR3VpWI1k5gdQknpFqVu925X71ufmaWs0=; b=N2vxc4UUsy+T8XRSG/OH953qawfbJ36AN+SDxOihMj1uEwXqbxz1J4tcii+KrElJgR i3sRFYL4h2WuNGos3lYZLtyijREeuEyYsRcE0x7SGytm/rIz4aNm3p/exGDxC3kHud4c PHov+sSja3kiJ91iAIWS0sphdmYgOl9AYP5tw2EIsAlVhzn0+dxzVVd3+Akx9b24XJ7H 7HLiPwK435rGCIrEKZo9B8nw5aUjyynf+14zuNPJNYX+GABNUJ00e7ydxbNZo58KfAuO 0+pLgtksRUXDjgtmfgaGyrqe0ga5vHZlPXaoTVesCg/DlkXxrkvS+KItTvxE5MmXgrtx 4jgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725902924; x=1726507724; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IVrsW+o3FMgR3VpWI1k5gdQknpFqVu925X71ufmaWs0=; b=wnMfgpOhM/ZGNT3C5VVJekYnhCZFzR3gslyr1UVtblw2DYshHbjBA7ygpHAcNyVRCh epDvWWT4kQbJk4cuXs5AKUii/4ObRM3hq5MahaDMP9yNV9rG9U5loCoIQ9O4fLNtjkvK Fe67knW3UUO2paPgAQ5yCJFVPiWySpKYC07Q3UZqnZyNt3X+GaTd6BdUbuLQDmXAs27F WA2xnNKtHXHeETI0AlcnUwNw/Srznfd4iXnqj1w6d7qn9aXY/gtwsVRjZSOjBERyIg+d 2sNW7+ItiitFv2xmCAxn7PsIlb4HMe5nLh0PNVj9Z9Xpdz+y/mZ5uhwMT8ZGEr9WWSc+ f0Sw== X-Gm-Message-State: AOJu0YxbLfQzORWYLjRJEuPJJMcabH6cMphhrs2mfhi3/XKwedwwLjlj qNn5QL6q+kkrWLVOmAUakbDFEKtbWNJ/3qWImZW0zQ/7xWVOce9oMV0AC+iP8YWyvufYin0W0uX S X-Received: by 2002:a17:903:22d0:b0:206:cbf0:3089 with SMTP id d9443c01a7336-206f062366emr118764175ad.54.1725902924060; Mon, 09 Sep 2024 10:28:44 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710e11e02sm36539875ad.14.2024.09.09.10.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 10:28:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, daniel@0x0f.com Subject: [PATCH v3 21/26] target/m68k: Merge gen_load_fp, gen_load_mode_fp Date: Mon, 9 Sep 2024 10:28:18 -0700 Message-ID: <20240909172823.649837-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240909172823.649837-1-richard.henderson@linaro.org> References: <20240909172823.649837-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This enables the exceptions raised by the actual load to be reflected as a failure. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/m68k/translate.c | 104 ++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index df886ed062..e966d2c929 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -901,53 +901,6 @@ static void gen_fp_move(TCGv_ptr dest, TCGv_ptr src) tcg_gen_st_i64(t64, dest, offsetof(FPReg, l.lower)); } -static void gen_load_fp(DisasContext *s, int opsize, TCGv addr, TCGv_ptr fp, - int index) -{ - TCGv tmp; - TCGv_i64 t64; - - t64 = tcg_temp_new_i64(); - tmp = tcg_temp_new(); - switch (opsize) { - case OS_BYTE: - case OS_WORD: - case OS_LONG: - tcg_gen_qemu_ld_tl(tmp, addr, index, opsize | MO_SIGN | MO_TE); - gen_helper_exts32(tcg_env, fp, tmp); - break; - case OS_SINGLE: - tcg_gen_qemu_ld_tl(tmp, addr, index, MO_TEUL); - gen_helper_extf32(tcg_env, fp, tmp); - break; - case OS_DOUBLE: - tcg_gen_qemu_ld_i64(t64, addr, index, MO_TEUQ); - gen_helper_extf64(tcg_env, fp, t64); - break; - case OS_EXTENDED: - if (m68k_feature(s->env, M68K_FEATURE_CF_FPU)) { - gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP); - break; - } - tcg_gen_qemu_ld_i32(tmp, addr, index, MO_TEUL); - tcg_gen_shri_i32(tmp, tmp, 16); - tcg_gen_st16_i32(tmp, fp, offsetof(FPReg, l.upper)); - tcg_gen_addi_i32(tmp, addr, 4); - tcg_gen_qemu_ld_i64(t64, tmp, index, MO_TEUQ); - tcg_gen_st_i64(t64, fp, offsetof(FPReg, l.lower)); - break; - case OS_PACKED: - /* - * unimplemented data type on 68040/ColdFire - * FIXME if needed for another FPU - */ - gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP); - break; - default: - g_assert_not_reached(); - } -} - static void gen_store_fp(DisasContext *s, int opsize, TCGv addr, TCGv_ptr fp, int index) { @@ -995,8 +948,8 @@ static void gen_store_fp(DisasContext *s, int opsize, TCGv addr, TCGv_ptr fp, } } -static bool gen_load_mode_fp(DisasContext *s, uint16_t insn, int opsize, - TCGv_ptr fp, int index) +static bool gen_load_fp(DisasContext *s, uint16_t insn, int opsize, + TCGv_ptr fp, int index) { int mode = extract32(insn, 3, 3); int reg0 = REG(insn, 0); @@ -1083,10 +1036,55 @@ static bool gen_load_mode_fp(DisasContext *s, uint16_t insn, int opsize, gen_addr_fault(s); return false; } - gen_load_fp(s, opsize, addr, fp, index); - return true; + break; + + default: + g_assert_not_reached(); } - g_assert_not_reached(); + + switch (opsize) { + case OS_BYTE: + case OS_WORD: + case OS_LONG: + tmp = tcg_temp_new(); + tcg_gen_qemu_ld_tl(tmp, addr, index, opsize | MO_SIGN | MO_TE); + gen_helper_exts32(tcg_env, fp, tmp); + break; + case OS_SINGLE: + tmp = tcg_temp_new(); + tcg_gen_qemu_ld_tl(tmp, addr, index, MO_TEUL); + gen_helper_extf32(tcg_env, fp, tmp); + break; + case OS_DOUBLE: + t64 = tcg_temp_new_i64(); + tcg_gen_qemu_ld_i64(t64, addr, index, MO_TEUQ); + gen_helper_extf64(tcg_env, fp, t64); + break; + case OS_EXTENDED: + if (m68k_feature(s->env, M68K_FEATURE_CF_FPU)) { + gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP); + return false; + } + tmp = tcg_temp_new(); + t64 = tcg_temp_new_i64(); + tcg_gen_qemu_ld_i32(tmp, addr, index, MO_TEUL); + tcg_gen_addi_i32(addr, addr, 4); + tcg_gen_qemu_ld_i64(t64, addr, index, MO_TEUQ); + tcg_gen_shri_i32(tmp, tmp, 16); + tcg_gen_st16_i32(tmp, fp, offsetof(FPReg, l.upper)); + tcg_gen_st_i64(t64, fp, offsetof(FPReg, l.lower)); + break; + case OS_PACKED: + /* + * unimplemented data type on 68040/ColdFire + * FIXME if needed for another FPU + */ + gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP); + return false; + default: + g_assert_not_reached(); + } + return true; } static bool gen_store_mode_fp(DisasContext *s, uint16_t insn, int opsize, @@ -4911,7 +4909,7 @@ DISAS_INSN(fpu) /* Source effective address. */ opsize = ext_opsize(ext, 10); cpu_src = gen_fp_result_ptr(); - if (!gen_load_mode_fp(s, insn, opsize, cpu_src, IS_USER(s))) { + if (!gen_load_fp(s, insn, opsize, cpu_src, IS_USER(s))) { return; } } else {