From patchwork Mon Sep 9 17:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 826623 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp2130109wrb; Mon, 9 Sep 2024 10:29:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3RwS+2F8FnsbPKwLOkkk9Hgz7C2F7Fb4b+RU69dXuyW/YnW+QZ0Ud+rH2gZZvPUEXddFceg==@linaro.org X-Google-Smtp-Source: AGHT+IGA+tIUOkdLQ2zIu2qUMKb4xXCdE6rr+iKqOjlX2QpnHBQjC5F0CcypYaRbegsmjp1IOHdN X-Received: by 2002:a05:622a:1452:b0:458:2b4e:33d6 with SMTP id d75a77b69052e-4582b4e351amr95078241cf.55.1725902998862; Mon, 09 Sep 2024 10:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725902998; cv=none; d=google.com; s=arc-20240605; b=ZbA9sSi+lMk/jasyyllh5H1l8QoDSyEEmuHFuK4WxfG3bRaIt5KWBNHmrHhZO+FJQl pCl2vVUa1orJOe7ShN9giJMa+J8noW5BCnRIzAHvXpiGLXMTM3MTB7GbZPH427gaFDEJ ULWw1suhtGLoIAy0EW8D2Eawhywq3+ES6BYY9i47UEJuav92rorWM0wrdh2+LjKp0F7W pHbfy4oSC8/N7mpoZVG/ezPjILQZISsWj/ldx41cLa+oV54pdlx1UAkHnlzhTsru8upr U0RN36Qd7CgsvSUjIve8zY0nBXgdJhxlnBnmvUqlc0IJqw/CVhhFtedJEsy6ANAYI1dD usKQ== 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=m7w703O79/DTa7nR13RVyKW4XTiaiYluVn4vLct/9bg=; fh=4bMsMJJHDmTQNFavmZaD/iTPOPK/LdH9YFdHoY+StpE=; b=eE4HRPnTdMQ0/b0VqY49pYbKAxlzWkglsko1C4yTPMD7PU97Lt3csqLKSMHtWqBTBr h47zhAWZOSGI0NmNkBY7oVrcLQru4/ldASTL579qYBMQSVHSAPOm7yUzCj0Ad0yz+ujk XJgMQzVALbSyC8V+IxLkK00ntShySrdbpVUaQLFqpLGbBILbpGIJakkpC+W3VLuF0GgM E+NtzIRgyxCwhljoMKZkwMpM22Id8CBYrW+R7XSIFngSPvkq4bTdyB7w0uZ4lM6e98T3 cqut4E7DlCEjT8KlhpgA0WvHDHzB19QPH1scER1Hbu+19JyKuYz75oaZs/64fW5j48MR hApA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xMaccUGl; 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 d75a77b69052e-45822f82b4dsi59308481cf.437.2024.09.09.10.29.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Sep 2024 10:29:58 -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=xMaccUGl; 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 1sniBn-00046H-9K; Mon, 09 Sep 2024 13:28:35 -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 1sniBi-0003vw-Lg for qemu-devel@nongnu.org; Mon, 09 Sep 2024 13:28:30 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sniBg-00060I-KT for qemu-devel@nongnu.org; Mon, 09 Sep 2024 13:28:30 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2054feabfc3so40719945ad.1 for ; Mon, 09 Sep 2024 10:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725902907; x=1726507707; 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=m7w703O79/DTa7nR13RVyKW4XTiaiYluVn4vLct/9bg=; b=xMaccUGloF3Wcy44le+WHndM1atlQ6a/2zkXGieO0EybkKh2d8jWpRif0i2bQ2v3NE jKkd5zFaZFnR3n3FadrsOkhVu+7AwCyJshQGHQU4c6/RCrtTbHQULp3sQBaJNsUoPbek prXJwlHpcTvl0SRDP8qjzvrtKfaXNNwN38o3A0OFBM4sVyQYxdsY3LQRmtvxl8RbGeve mn+GgJsPyVp+hM71z07dSDYXbUEdlcMUX4owsIEac/gEBICczyHwdUu5rrZQ19Rxmg/m icYGq8Fe95F5T+3Ab9DsG7EZEP+s16iUdU81qufPd9bFf1PE6wwyb/IHbUCZzOQKBa3E 9zWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725902907; x=1726507707; 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=m7w703O79/DTa7nR13RVyKW4XTiaiYluVn4vLct/9bg=; b=UUutE/NhVtc1MuXKxTZS/6ofM6ts0/x2MdEGs0NvBOZGfUas5xiAfvPTQYzNCuIlEY lyAReUuRrVbMrX8vJuFO0TfhvtKYiBCXLMHsr3amIfFgePk7e+nXbNw2WYEzNm+NbZDO WhOurbNUCyI1Y34kbW+M0s3FQ6eHvWSo3nQ+dyOgpDRC3cRceDc+EMJ/T0tWFH24wx2m GRefaRNzuy1x6Mwqn3socP9XPRWr0ibcKrAWzISspH6P+RwqgX8rZ36oOH4SEtwdckPo A2H+vJgDgNGN0EMN/iTIswjGhGfsxdRVMfPuoC7R7FdJr1Hc/yJ9nyj4HXzFezknKvqr ALNA== X-Gm-Message-State: AOJu0YzBcDUuUgUPTtujBdaN8l/ssRhOxz0fFYaOWQgMhkdfJOnClhWn HB/wiasX/LvUTs/Lu4qP2T5xzBUvODsY/YSngUW9+GOX2Hh4v9jj71gIqfviJK8n9C00fWTQwgb p X-Received: by 2002:a17:902:d2c5:b0:206:d8c2:4a94 with SMTP id d9443c01a7336-206f0542c38mr192047795ad.25.1725902907062; Mon, 09 Sep 2024 10:28:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 10:28:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, daniel@0x0f.com Subject: [PATCH v3 02/26] target/m68k: Add FPSR exception bit defines Date: Mon, 9 Sep 2024 10:27:59 -0700 Message-ID: <20240909172823.649837-3-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::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 Signed-off-by: Richard Henderson --- target/m68k/cpu.h | 21 +++++++++++++++++++++ target/m68k/fpu_helper.c | 22 +++++++++++----------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index b5bbeedb7a..e8dd75d242 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -440,6 +440,27 @@ typedef enum { #define FPSR_QT_MASK 0x00ff0000 #define FPSR_QT_SHIFT 16 +/* Exception Status Byte */ + +#define FPSR_EXC_MASK 0xff00 +#define FPSR_EXC_INEX1 0x0100 +#define FPSR_EXC_INEX2 0x0200 +#define FPSR_EXC_DZ 0x0400 +#define FPSR_EXC_UNFL 0x0800 +#define FPSR_EXC_OVFL 0x1000 +#define FPSR_EXC_OPERR 0x2000 +#define FPSR_EXC_SNAN 0x4000 +#define FPSR_EXC_BSUN 0x8000 + +/* Accrued Exception Byte */ + +#define FPSR_AEXC_MASK 0xf8 +#define FPSR_AEXC_INEX 0x08 +#define FPSR_AEXP_DZ 0x10 +#define FPSR_AEXP_UNFL 0x20 +#define FPSR_AEXP_OVFL 0x40 +#define FPSR_AEXP_IOP 0x80 + /* Floating-Point Control Register */ /* Rounding mode */ #define FPCR_RND_MASK 0x0030 diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c index 8314791f50..c6d93b56a0 100644 --- a/target/m68k/fpu_helper.c +++ b/target/m68k/fpu_helper.c @@ -170,19 +170,19 @@ static int cpu_m68k_exceptbits_from_host(int host_bits) int target_bits = 0; if (host_bits & float_flag_invalid) { - target_bits |= 0x80; + target_bits |= FPSR_AEXP_IOP; } if (host_bits & float_flag_overflow) { - target_bits |= 0x40; + target_bits |= FPSR_AEXP_OVFL; } if (host_bits & (float_flag_underflow | float_flag_output_denormal)) { - target_bits |= 0x20; + target_bits |= FPSR_AEXP_UNFL; } if (host_bits & float_flag_divbyzero) { - target_bits |= 0x10; + target_bits |= FPSR_AEXP_DZ; } if (host_bits & float_flag_inexact) { - target_bits |= 0x08; + target_bits |= FPSR_AEXC_INEX; } return target_bits; } @@ -192,19 +192,19 @@ static int cpu_m68k_exceptbits_to_host(int target_bits) { int host_bits = 0; - if (target_bits & 0x80) { + if (target_bits & FPSR_AEXP_IOP) { host_bits |= float_flag_invalid; } - if (target_bits & 0x40) { + if (target_bits & FPSR_AEXP_OVFL) { host_bits |= float_flag_overflow; } - if (target_bits & 0x20) { + if (target_bits & FPSR_AEXP_UNFL) { host_bits |= float_flag_underflow; } - if (target_bits & 0x10) { + if (target_bits & FPSR_AEXP_DZ) { host_bits |= float_flag_divbyzero; } - if (target_bits & 0x08) { + if (target_bits & FPSR_AEXC_INEX) { host_bits |= float_flag_inexact; } return host_bits; @@ -214,7 +214,7 @@ uint32_t cpu_m68k_get_fpsr(CPUM68KState *env) { int host_flags = get_float_exception_flags(&env->fp_status); int target_flags = cpu_m68k_exceptbits_from_host(host_flags); - int except = (env->fpsr & ~(0xf8)) | target_flags; + int except = (env->fpsr & ~FPSR_AEXC_MASK) | target_flags; return except; }