2016-12-15 22:26:14 +03:00
|
|
|
/*
|
|
|
|
* HPPA emulation cpu translation for qemu.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016 Richard Henderson <rth@twiddle.net>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2020-10-23 15:33:53 +03:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2016-12-15 22:26:14 +03:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "disas/disas.h"
|
|
|
|
#include "qemu/host-utils.h"
|
|
|
|
#include "exec/exec-all.h"
|
2023-12-06 22:27:32 +03:00
|
|
|
#include "exec/page-protection.h"
|
2020-01-01 14:23:00 +03:00
|
|
|
#include "tcg/tcg-op.h"
|
2023-09-20 14:50:01 +03:00
|
|
|
#include "tcg/tcg-op-gvec.h"
|
2016-12-15 22:26:14 +03:00
|
|
|
#include "exec/helper-proto.h"
|
|
|
|
#include "exec/helper-gen.h"
|
2017-07-15 09:56:35 +03:00
|
|
|
#include "exec/translator.h"
|
2016-12-15 22:26:14 +03:00
|
|
|
#include "exec/log.h"
|
|
|
|
|
2023-03-31 20:37:04 +03:00
|
|
|
#define HELPER_H "helper.h"
|
|
|
|
#include "exec/helper-info.c.inc"
|
|
|
|
#undef HELPER_H
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
/* Choose to use explicit sizes within this file. */
|
|
|
|
#undef tcg_temp_new
|
2023-03-31 20:37:04 +03:00
|
|
|
|
2016-12-15 22:26:14 +03:00
|
|
|
typedef struct DisasCond {
|
|
|
|
TCGCond c;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 a0, a1;
|
2016-12-15 22:26:14 +03:00
|
|
|
} DisasCond;
|
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
typedef struct DisasIAQE {
|
|
|
|
/* IASQ; may be null for no change from TB. */
|
|
|
|
TCGv_i64 space;
|
2024-03-22 05:47:14 +03:00
|
|
|
/* IAOQ base; may be null for relative address. */
|
2024-03-22 02:56:44 +03:00
|
|
|
TCGv_i64 base;
|
2024-03-22 05:47:14 +03:00
|
|
|
/* IAOQ addend; if base is null, relative to ctx->iaoq_first. */
|
2024-03-22 02:56:44 +03:00
|
|
|
int64_t disp;
|
|
|
|
} DisasIAQE;
|
|
|
|
|
2016-12-15 22:26:14 +03:00
|
|
|
typedef struct DisasContext {
|
2017-07-15 10:00:32 +03:00
|
|
|
DisasContextBase base;
|
2016-12-15 22:26:14 +03:00
|
|
|
CPUState *cs;
|
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
/* IAQ_Front, IAQ_Back. */
|
|
|
|
DisasIAQE iaq_f, iaq_b;
|
|
|
|
/* IAQ_Next, for jumps, otherwise null for simple advance. */
|
|
|
|
DisasIAQE iaq_j, *iaq_n;
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2024-03-22 05:47:14 +03:00
|
|
|
/* IAOQ_Front at entry to TB. */
|
|
|
|
uint64_t iaoq_first;
|
|
|
|
|
2016-12-15 22:26:14 +03:00
|
|
|
DisasCond null_cond;
|
|
|
|
TCGLabel *null_lab;
|
|
|
|
|
2023-10-18 20:24:33 +03:00
|
|
|
TCGv_i64 zero;
|
|
|
|
|
2017-10-11 23:19:11 +03:00
|
|
|
uint32_t insn;
|
2017-11-06 23:10:33 +03:00
|
|
|
uint32_t tb_flags;
|
2017-10-09 20:17:24 +03:00
|
|
|
int mmu_idx;
|
|
|
|
int privilege;
|
2016-12-15 22:26:14 +03:00
|
|
|
bool psw_n_nonzero;
|
2023-09-18 01:31:47 +03:00
|
|
|
bool is_pa20;
|
2024-04-06 23:59:02 +03:00
|
|
|
bool insn_start_updated;
|
2021-12-27 18:01:26 +03:00
|
|
|
|
|
|
|
#ifdef CONFIG_USER_ONLY
|
|
|
|
MemOp unalign;
|
|
|
|
#endif
|
2016-12-15 22:26:14 +03:00
|
|
|
} DisasContext;
|
|
|
|
|
2021-12-27 18:01:26 +03:00
|
|
|
#ifdef CONFIG_USER_ONLY
|
2023-11-07 22:33:45 +03:00
|
|
|
#define UNALIGN(C) (C)->unalign
|
|
|
|
#define MMU_DISABLED(C) false
|
2021-12-27 18:01:26 +03:00
|
|
|
#else
|
2023-11-07 22:33:45 +03:00
|
|
|
#define UNALIGN(C) MO_ALIGN
|
|
|
|
#define MMU_DISABLED(C) MMU_IDX_MMU_DISABLED((C)->mmu_idx)
|
2021-12-27 18:01:26 +03:00
|
|
|
#endif
|
|
|
|
|
2018-02-12 05:45:01 +03:00
|
|
|
/* Note that ssm/rsm instructions number PSW_W and PSW_E differently. */
|
2019-03-21 05:21:31 +03:00
|
|
|
static int expand_sm_imm(DisasContext *ctx, int val)
|
2018-02-12 05:45:01 +03:00
|
|
|
{
|
2023-11-08 00:32:36 +03:00
|
|
|
/* Keep unimplemented bits disabled -- see cpu_hppa_put_psw. */
|
|
|
|
if (ctx->is_pa20) {
|
|
|
|
if (val & PSW_SM_W) {
|
|
|
|
val |= PSW_W;
|
|
|
|
}
|
|
|
|
val &= ~(PSW_SM_W | PSW_SM_E | PSW_G);
|
|
|
|
} else {
|
|
|
|
val &= ~(PSW_SM_W | PSW_SM_E | PSW_O);
|
2018-02-12 05:45:01 +03:00
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
/* Inverted space register indicates 0 means sr0 not inferred from base. */
|
2019-03-21 05:21:31 +03:00
|
|
|
static int expand_sr3x(DisasContext *ctx, int val)
|
2018-02-12 07:39:25 +03:00
|
|
|
{
|
|
|
|
return ~val;
|
|
|
|
}
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
/* Convert the M:A bits within a memory insn to the tri-state value
|
|
|
|
we use for the final M. */
|
2019-03-21 05:21:31 +03:00
|
|
|
static int ma_to_m(DisasContext *ctx, int val)
|
2018-02-12 09:48:03 +03:00
|
|
|
{
|
|
|
|
return val & 2 ? (val & 1 ? -1 : 1) : 0;
|
|
|
|
}
|
|
|
|
|
2018-02-13 02:54:33 +03:00
|
|
|
/* Convert the sign of the displacement to a pre or post-modify. */
|
2019-03-21 05:21:31 +03:00
|
|
|
static int pos_to_m(DisasContext *ctx, int val)
|
2018-02-13 02:54:33 +03:00
|
|
|
{
|
|
|
|
return val ? 1 : -1;
|
|
|
|
}
|
|
|
|
|
2019-03-21 05:21:31 +03:00
|
|
|
static int neg_to_m(DisasContext *ctx, int val)
|
2018-02-13 02:54:33 +03:00
|
|
|
{
|
|
|
|
return val ? -1 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Used for branch targets and fp memory ops. */
|
2019-03-21 05:21:31 +03:00
|
|
|
static int expand_shl2(DisasContext *ctx, int val)
|
2018-02-12 10:33:50 +03:00
|
|
|
{
|
|
|
|
return val << 2;
|
|
|
|
}
|
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
/* Used for assemble_21. */
|
2019-03-21 05:21:31 +03:00
|
|
|
static int expand_shl11(DisasContext *ctx, int val)
|
2018-02-13 02:34:12 +03:00
|
|
|
{
|
|
|
|
return val << 11;
|
|
|
|
}
|
|
|
|
|
2023-09-20 12:44:17 +03:00
|
|
|
static int assemble_6(DisasContext *ctx, int val)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Officially, 32 * x + 32 - y.
|
|
|
|
* Here, x is already in bit 5, and y is [4:0].
|
|
|
|
* Since -y = ~y + 1, in 5 bits 32 - y => y ^ 31 + 1,
|
|
|
|
* with the overflow from bit 4 summing with x.
|
|
|
|
*/
|
|
|
|
return (val ^ 31) + 1;
|
|
|
|
}
|
|
|
|
|
2024-03-03 04:38:17 +03:00
|
|
|
/* Expander for assemble_16a(s,cat(im10a,0),i). */
|
|
|
|
static int expand_11a(DisasContext *ctx, int val)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* @val is bit 0 and bits [4:15].
|
|
|
|
* Swizzle thing around depending on PSW.W.
|
|
|
|
*/
|
|
|
|
int im10a = extract32(val, 1, 10);
|
|
|
|
int s = extract32(val, 11, 2);
|
|
|
|
int i = (-(val & 1) << 13) | (im10a << 3);
|
|
|
|
|
|
|
|
if (ctx->tb_flags & PSW_W) {
|
|
|
|
i ^= s << 13;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2024-03-03 04:48:48 +03:00
|
|
|
/* Expander for assemble_16a(s,im11a,i). */
|
|
|
|
static int expand_12a(DisasContext *ctx, int val)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* @val is bit 0 and bits [3:15].
|
|
|
|
* Swizzle thing around depending on PSW.W.
|
|
|
|
*/
|
|
|
|
int im11a = extract32(val, 1, 11);
|
|
|
|
int s = extract32(val, 12, 2);
|
|
|
|
int i = (-(val & 1) << 13) | (im11a << 2);
|
|
|
|
|
|
|
|
if (ctx->tb_flags & PSW_W) {
|
|
|
|
i ^= s << 13;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2024-03-03 04:10:00 +03:00
|
|
|
/* Expander for assemble_16(s,im14). */
|
|
|
|
static int expand_16(DisasContext *ctx, int val)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* @val is bits [0:15], containing both im14 and s.
|
|
|
|
* Swizzle thing around depending on PSW.W.
|
|
|
|
*/
|
|
|
|
int s = extract32(val, 14, 2);
|
|
|
|
int i = (-(val & 1) << 13) | extract32(val, 1, 13);
|
|
|
|
|
|
|
|
if (ctx->tb_flags & PSW_W) {
|
|
|
|
i ^= s << 13;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The sp field is only present with !PSW_W. */
|
|
|
|
static int sp0_if_wide(DisasContext *ctx, int sp)
|
|
|
|
{
|
|
|
|
return ctx->tb_flags & PSW_W ? 0 : sp;
|
|
|
|
}
|
|
|
|
|
2023-09-17 08:06:04 +03:00
|
|
|
/* Translate CMPI doubleword conditions to standard. */
|
|
|
|
static int cmpbid_c(DisasContext *ctx, int val)
|
|
|
|
{
|
|
|
|
return val ? val : 4; /* 0 == "*<<" */
|
|
|
|
}
|
|
|
|
|
2024-03-26 05:33:50 +03:00
|
|
|
/*
|
|
|
|
* In many places pa1.x did not decode the bit that later became
|
|
|
|
* the pa2.0 D bit. Suppress D unless the cpu is pa2.0.
|
|
|
|
*/
|
|
|
|
static int pa20_d(DisasContext *ctx, int val)
|
|
|
|
{
|
|
|
|
return ctx->is_pa20 & val;
|
|
|
|
}
|
2018-02-12 10:33:50 +03:00
|
|
|
|
2018-02-12 04:14:10 +03:00
|
|
|
/* Include the auto-generated decoder. */
|
2020-08-07 13:10:23 +03:00
|
|
|
#include "decode-insns.c.inc"
|
2018-02-12 04:14:10 +03:00
|
|
|
|
2017-07-15 09:56:35 +03:00
|
|
|
/* We are not using a goto_tb (for whatever reason), but have updated
|
|
|
|
the iaq (for whatever reason), so don't do it again on exit. */
|
|
|
|
#define DISAS_IAQ_N_UPDATED DISAS_TARGET_0
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2017-07-15 09:56:35 +03:00
|
|
|
/* We are exiting the TB, but have neither emitted a goto_tb, nor
|
|
|
|
updated the iaq for the next instruction to be executed. */
|
|
|
|
#define DISAS_IAQ_N_STALE DISAS_TARGET_1
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2017-10-09 17:44:30 +03:00
|
|
|
/* Similarly, but we want to return to the main loop immediately
|
|
|
|
to recognize unmasked interrupts. */
|
|
|
|
#define DISAS_IAQ_N_STALE_EXIT DISAS_TARGET_2
|
2019-03-13 01:24:38 +03:00
|
|
|
#define DISAS_EXIT DISAS_TARGET_3
|
2017-10-09 17:44:30 +03:00
|
|
|
|
2016-12-15 22:26:14 +03:00
|
|
|
/* global register indexes */
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 cpu_gr[32];
|
2017-10-10 08:54:12 +03:00
|
|
|
static TCGv_i64 cpu_sr[4];
|
2017-11-06 23:10:33 +03:00
|
|
|
static TCGv_i64 cpu_srH;
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 cpu_iaoq_f;
|
|
|
|
static TCGv_i64 cpu_iaoq_b;
|
2017-10-22 08:53:35 +03:00
|
|
|
static TCGv_i64 cpu_iasq_f;
|
|
|
|
static TCGv_i64 cpu_iasq_b;
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 cpu_sar;
|
|
|
|
static TCGv_i64 cpu_psw_n;
|
|
|
|
static TCGv_i64 cpu_psw_v;
|
|
|
|
static TCGv_i64 cpu_psw_cb;
|
|
|
|
static TCGv_i64 cpu_psw_cb_msb;
|
2016-12-15 22:26:14 +03:00
|
|
|
|
|
|
|
void hppa_translate_init(void)
|
|
|
|
{
|
|
|
|
#define DEF_VAR(V) { &cpu_##V, #V, offsetof(CPUHPPAState, V) }
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
typedef struct { TCGv_i64 *var; const char *name; int ofs; } GlobalVar;
|
2016-12-15 22:26:14 +03:00
|
|
|
static const GlobalVar vars[] = {
|
2017-10-11 07:19:34 +03:00
|
|
|
{ &cpu_sar, "sar", offsetof(CPUHPPAState, cr[CR_SAR]) },
|
2016-12-15 22:26:14 +03:00
|
|
|
DEF_VAR(psw_n),
|
|
|
|
DEF_VAR(psw_v),
|
|
|
|
DEF_VAR(psw_cb),
|
|
|
|
DEF_VAR(psw_cb_msb),
|
|
|
|
DEF_VAR(iaoq_f),
|
|
|
|
DEF_VAR(iaoq_b),
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef DEF_VAR
|
|
|
|
|
|
|
|
/* Use the symbolic register names that match the disassembler. */
|
|
|
|
static const char gr_names[32][4] = {
|
|
|
|
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
|
|
|
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
|
|
|
|
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
|
|
|
|
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31"
|
|
|
|
};
|
2017-10-10 08:54:12 +03:00
|
|
|
/* SR[4-7] are not global registers so that we can index them. */
|
2017-11-06 23:10:33 +03:00
|
|
|
static const char sr_names[5][4] = {
|
|
|
|
"sr0", "sr1", "sr2", "sr3", "srH"
|
2017-10-10 08:54:12 +03:00
|
|
|
};
|
2016-12-15 22:26:14 +03:00
|
|
|
|
|
|
|
int i;
|
|
|
|
|
2017-11-02 14:47:37 +03:00
|
|
|
cpu_gr[0] = NULL;
|
2016-12-15 22:26:14 +03:00
|
|
|
for (i = 1; i < 32; i++) {
|
2023-09-14 02:37:36 +03:00
|
|
|
cpu_gr[i] = tcg_global_mem_new(tcg_env,
|
2016-12-15 22:26:14 +03:00
|
|
|
offsetof(CPUHPPAState, gr[i]),
|
|
|
|
gr_names[i]);
|
|
|
|
}
|
2017-10-10 08:54:12 +03:00
|
|
|
for (i = 0; i < 4; i++) {
|
2023-09-14 02:37:36 +03:00
|
|
|
cpu_sr[i] = tcg_global_mem_new_i64(tcg_env,
|
2017-10-10 08:54:12 +03:00
|
|
|
offsetof(CPUHPPAState, sr[i]),
|
|
|
|
sr_names[i]);
|
|
|
|
}
|
2023-09-14 02:37:36 +03:00
|
|
|
cpu_srH = tcg_global_mem_new_i64(tcg_env,
|
2017-11-06 23:10:33 +03:00
|
|
|
offsetof(CPUHPPAState, sr[4]),
|
|
|
|
sr_names[4]);
|
2016-12-15 22:26:14 +03:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(vars); ++i) {
|
|
|
|
const GlobalVar *v = &vars[i];
|
2023-09-14 02:37:36 +03:00
|
|
|
*v->var = tcg_global_mem_new(tcg_env, v->ofs, v->name);
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
2017-10-22 08:53:35 +03:00
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
cpu_iasq_f = tcg_global_mem_new_i64(tcg_env,
|
2017-10-22 08:53:35 +03:00
|
|
|
offsetof(CPUHPPAState, iasq_f),
|
|
|
|
"iasq_f");
|
2023-09-14 02:37:36 +03:00
|
|
|
cpu_iasq_b = tcg_global_mem_new_i64(tcg_env,
|
2017-10-22 08:53:35 +03:00
|
|
|
offsetof(CPUHPPAState, iasq_b),
|
|
|
|
"iasq_b");
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
|
|
|
|
2023-10-27 12:46:44 +03:00
|
|
|
static void set_insn_breg(DisasContext *ctx, int breg)
|
|
|
|
{
|
2024-04-06 23:59:02 +03:00
|
|
|
assert(!ctx->insn_start_updated);
|
|
|
|
ctx->insn_start_updated = true;
|
|
|
|
tcg_set_insn_start_param(ctx->base.insn_start, 2, breg);
|
2023-10-27 12:46:44 +03:00
|
|
|
}
|
|
|
|
|
2016-12-15 22:58:17 +03:00
|
|
|
static DisasCond cond_make_f(void)
|
|
|
|
{
|
2017-11-02 14:47:37 +03:00
|
|
|
return (DisasCond){
|
|
|
|
.c = TCG_COND_NEVER,
|
|
|
|
.a0 = NULL,
|
|
|
|
.a1 = NULL,
|
|
|
|
};
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
|
2019-02-12 03:40:27 +03:00
|
|
|
static DisasCond cond_make_t(void)
|
|
|
|
{
|
|
|
|
return (DisasCond){
|
|
|
|
.c = TCG_COND_ALWAYS,
|
|
|
|
.a0 = NULL,
|
|
|
|
.a1 = NULL,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-15 22:58:17 +03:00
|
|
|
static DisasCond cond_make_n(void)
|
|
|
|
{
|
2017-11-02 14:47:37 +03:00
|
|
|
return (DisasCond){
|
|
|
|
.c = TCG_COND_NE,
|
|
|
|
.a0 = cpu_psw_n,
|
2023-10-18 07:31:08 +03:00
|
|
|
.a1 = tcg_constant_i64(0)
|
2017-11-02 14:47:37 +03:00
|
|
|
};
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
|
2024-03-25 20:30:19 +03:00
|
|
|
static DisasCond cond_make_tt(TCGCond c, TCGv_i64 a0, TCGv_i64 a1)
|
2016-12-15 22:58:17 +03:00
|
|
|
{
|
|
|
|
assert (c != TCG_COND_NEVER && c != TCG_COND_ALWAYS);
|
2023-09-17 05:28:12 +03:00
|
|
|
return (DisasCond){ .c = c, .a0 = a0, .a1 = a1 };
|
|
|
|
}
|
|
|
|
|
2024-03-25 20:30:19 +03:00
|
|
|
static DisasCond cond_make_ti(TCGCond c, TCGv_i64 a0, uint64_t imm)
|
2023-09-17 05:28:12 +03:00
|
|
|
{
|
2024-03-25 20:30:19 +03:00
|
|
|
return cond_make_tt(c, a0, tcg_constant_i64(imm));
|
2019-02-12 04:12:54 +03:00
|
|
|
}
|
2016-12-15 22:58:17 +03:00
|
|
|
|
2024-03-25 20:30:19 +03:00
|
|
|
static DisasCond cond_make_vi(TCGCond c, TCGv_i64 a0, uint64_t imm)
|
2019-02-12 04:12:54 +03:00
|
|
|
{
|
2023-10-18 07:47:02 +03:00
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_mov_i64(tmp, a0);
|
2024-03-25 20:30:19 +03:00
|
|
|
return cond_make_ti(c, tmp, imm);
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
|
2024-03-25 20:30:19 +03:00
|
|
|
static DisasCond cond_make_vv(TCGCond c, TCGv_i64 a0, TCGv_i64 a1)
|
2016-12-15 22:58:17 +03:00
|
|
|
{
|
2023-10-18 07:47:02 +03:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
2016-12-15 22:58:17 +03:00
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_mov_i64(t0, a0);
|
|
|
|
tcg_gen_mov_i64(t1, a1);
|
2024-03-25 20:30:19 +03:00
|
|
|
return cond_make_tt(c, t0, t1);
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cond_free(DisasCond *cond)
|
|
|
|
{
|
|
|
|
switch (cond->c) {
|
|
|
|
default:
|
2017-11-02 14:47:37 +03:00
|
|
|
cond->a0 = NULL;
|
|
|
|
cond->a1 = NULL;
|
2016-12-15 22:58:17 +03:00
|
|
|
/* fallthru */
|
|
|
|
case TCG_COND_ALWAYS:
|
|
|
|
cond->c = TCG_COND_NEVER;
|
|
|
|
break;
|
|
|
|
case TCG_COND_NEVER:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 load_gpr(DisasContext *ctx, unsigned reg)
|
2016-12-15 22:26:14 +03:00
|
|
|
{
|
|
|
|
if (reg == 0) {
|
2023-10-18 20:34:13 +03:00
|
|
|
return ctx->zero;
|
2016-12-15 22:26:14 +03:00
|
|
|
} else {
|
|
|
|
return cpu_gr[reg];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 dest_gpr(DisasContext *ctx, unsigned reg)
|
2016-12-15 22:26:14 +03:00
|
|
|
{
|
2016-12-15 22:58:17 +03:00
|
|
|
if (reg == 0 || ctx->null_cond.c != TCG_COND_NEVER) {
|
2023-10-18 07:47:02 +03:00
|
|
|
return tcg_temp_new_i64();
|
2016-12-15 22:26:14 +03:00
|
|
|
} else {
|
|
|
|
return cpu_gr[reg];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static void save_or_nullify(DisasContext *ctx, TCGv_i64 dest, TCGv_i64 t)
|
2016-12-15 22:58:17 +03:00
|
|
|
{
|
|
|
|
if (ctx->null_cond.c != TCG_COND_NEVER) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movcond_i64(ctx->null_cond.c, dest, ctx->null_cond.a0,
|
2021-07-08 23:54:36 +03:00
|
|
|
ctx->null_cond.a1, dest, t);
|
2016-12-15 22:58:17 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_mov_i64(dest, t);
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static void save_gpr(DisasContext *ctx, unsigned reg, TCGv_i64 t)
|
2016-12-15 22:58:17 +03:00
|
|
|
{
|
|
|
|
if (reg != 0) {
|
|
|
|
save_or_nullify(ctx, cpu_gr[reg], t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 18:57:17 +03:00
|
|
|
#if HOST_BIG_ENDIAN
|
2016-12-16 01:54:51 +03:00
|
|
|
# define HI_OFS 0
|
|
|
|
# define LO_OFS 4
|
|
|
|
#else
|
|
|
|
# define HI_OFS 4
|
|
|
|
# define LO_OFS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static TCGv_i32 load_frw_i32(unsigned rt)
|
|
|
|
{
|
|
|
|
TCGv_i32 ret = tcg_temp_new_i32();
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_gen_ld_i32(ret, tcg_env,
|
2016-12-16 01:54:51 +03:00
|
|
|
offsetof(CPUHPPAState, fr[rt & 31])
|
|
|
|
+ (rt & 32 ? LO_OFS : HI_OFS));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-12-16 02:04:19 +03:00
|
|
|
static TCGv_i32 load_frw0_i32(unsigned rt)
|
|
|
|
{
|
|
|
|
if (rt == 0) {
|
2023-02-26 02:05:46 +03:00
|
|
|
TCGv_i32 ret = tcg_temp_new_i32();
|
|
|
|
tcg_gen_movi_i32(ret, 0);
|
|
|
|
return ret;
|
2016-12-16 02:04:19 +03:00
|
|
|
} else {
|
|
|
|
return load_frw_i32(rt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static TCGv_i64 load_frw0_i64(unsigned rt)
|
|
|
|
{
|
2023-02-26 02:05:46 +03:00
|
|
|
TCGv_i64 ret = tcg_temp_new_i64();
|
2016-12-16 02:04:19 +03:00
|
|
|
if (rt == 0) {
|
2023-02-26 02:05:46 +03:00
|
|
|
tcg_gen_movi_i64(ret, 0);
|
2016-12-16 02:04:19 +03:00
|
|
|
} else {
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_gen_ld32u_i64(ret, tcg_env,
|
2016-12-16 02:04:19 +03:00
|
|
|
offsetof(CPUHPPAState, fr[rt & 31])
|
|
|
|
+ (rt & 32 ? LO_OFS : HI_OFS));
|
|
|
|
}
|
2023-02-26 02:05:46 +03:00
|
|
|
return ret;
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2016-12-16 01:54:51 +03:00
|
|
|
static void save_frw_i32(unsigned rt, TCGv_i32 val)
|
|
|
|
{
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_gen_st_i32(val, tcg_env,
|
2016-12-16 01:54:51 +03:00
|
|
|
offsetof(CPUHPPAState, fr[rt & 31])
|
|
|
|
+ (rt & 32 ? LO_OFS : HI_OFS));
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef HI_OFS
|
|
|
|
#undef LO_OFS
|
|
|
|
|
|
|
|
static TCGv_i64 load_frd(unsigned rt)
|
|
|
|
{
|
|
|
|
TCGv_i64 ret = tcg_temp_new_i64();
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_gen_ld_i64(ret, tcg_env, offsetof(CPUHPPAState, fr[rt]));
|
2016-12-16 01:54:51 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-12-16 02:04:19 +03:00
|
|
|
static TCGv_i64 load_frd0(unsigned rt)
|
|
|
|
{
|
|
|
|
if (rt == 0) {
|
2023-02-26 02:05:46 +03:00
|
|
|
TCGv_i64 ret = tcg_temp_new_i64();
|
|
|
|
tcg_gen_movi_i64(ret, 0);
|
|
|
|
return ret;
|
2016-12-16 02:04:19 +03:00
|
|
|
} else {
|
|
|
|
return load_frd(rt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-16 01:54:51 +03:00
|
|
|
static void save_frd(unsigned rt, TCGv_i64 val)
|
|
|
|
{
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_gen_st_i64(val, tcg_env, offsetof(CPUHPPAState, fr[rt]));
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2017-10-10 08:54:12 +03:00
|
|
|
static void load_spr(DisasContext *ctx, TCGv_i64 dest, unsigned reg)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_USER_ONLY
|
|
|
|
tcg_gen_movi_i64(dest, 0);
|
|
|
|
#else
|
|
|
|
if (reg < 4) {
|
|
|
|
tcg_gen_mov_i64(dest, cpu_sr[reg]);
|
2017-11-06 23:10:33 +03:00
|
|
|
} else if (ctx->tb_flags & TB_FLAG_SR_SAME) {
|
|
|
|
tcg_gen_mov_i64(dest, cpu_srH);
|
2017-10-10 08:54:12 +03:00
|
|
|
} else {
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_gen_ld_i64(dest, tcg_env, offsetof(CPUHPPAState, sr[reg]));
|
2017-10-10 08:54:12 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-12-15 22:58:17 +03:00
|
|
|
/* Skip over the implementation of an insn that has been nullified.
|
|
|
|
Use this when the insn is too complex for a conditional move. */
|
|
|
|
static void nullify_over(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (ctx->null_cond.c != TCG_COND_NEVER) {
|
|
|
|
/* The always condition should have been handled in the main loop. */
|
|
|
|
assert(ctx->null_cond.c != TCG_COND_ALWAYS);
|
|
|
|
|
|
|
|
ctx->null_lab = gen_new_label();
|
|
|
|
|
|
|
|
/* If we're using PSW[N], copy it to a temp because... */
|
2021-07-08 23:54:36 +03:00
|
|
|
if (ctx->null_cond.a0 == cpu_psw_n) {
|
2023-10-18 07:47:02 +03:00
|
|
|
ctx->null_cond.a0 = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_mov_i64(ctx->null_cond.a0, cpu_psw_n);
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
/* ... we clear it before branching over the implementation,
|
|
|
|
so that (1) it's clear after nullifying this insn and
|
|
|
|
(2) if this insn nullifies the next, PSW[N] is valid. */
|
|
|
|
if (ctx->psw_n_nonzero) {
|
|
|
|
ctx->psw_n_nonzero = false;
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(cpu_psw_n, 0);
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_brcond_i64(ctx->null_cond.c, ctx->null_cond.a0,
|
2021-07-08 23:54:36 +03:00
|
|
|
ctx->null_cond.a1, ctx->null_lab);
|
2016-12-15 22:58:17 +03:00
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the current nullification state to PSW[N]. */
|
|
|
|
static void nullify_save(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
if (ctx->null_cond.c == TCG_COND_NEVER) {
|
|
|
|
if (ctx->psw_n_nonzero) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(cpu_psw_n, 0);
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2021-07-08 23:54:36 +03:00
|
|
|
if (ctx->null_cond.a0 != cpu_psw_n) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_setcond_i64(ctx->null_cond.c, cpu_psw_n,
|
2021-07-08 23:54:36 +03:00
|
|
|
ctx->null_cond.a0, ctx->null_cond.a1);
|
2016-12-15 22:58:17 +03:00
|
|
|
ctx->psw_n_nonzero = true;
|
|
|
|
}
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set a PSW[N] to X. The intention is that this is used immediately
|
|
|
|
before a goto_tb/exit_tb, so that there is no fallthru path to other
|
|
|
|
code within the TB. Therefore we do not update psw_n_nonzero. */
|
|
|
|
static void nullify_set(DisasContext *ctx, bool x)
|
|
|
|
{
|
|
|
|
if (ctx->psw_n_nonzero || x) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(cpu_psw_n, x);
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mark the end of an instruction that may have been nullified.
|
2018-02-12 04:14:10 +03:00
|
|
|
This is the pair to nullify_over. Always returns true so that
|
|
|
|
it may be tail-called from a translate function. */
|
2018-02-12 04:09:30 +03:00
|
|
|
static bool nullify_end(DisasContext *ctx)
|
2016-12-15 22:58:17 +03:00
|
|
|
{
|
|
|
|
TCGLabel *null_lab = ctx->null_lab;
|
2018-02-12 04:09:30 +03:00
|
|
|
DisasJumpType status = ctx->base.is_jmp;
|
2016-12-15 22:58:17 +03:00
|
|
|
|
2017-10-11 18:54:49 +03:00
|
|
|
/* For NEXT, NORETURN, STALE, we can easily continue (or exit).
|
|
|
|
For UPDATED, we cannot update on the nullified path. */
|
|
|
|
assert(status != DISAS_IAQ_N_UPDATED);
|
|
|
|
|
2016-12-15 22:58:17 +03:00
|
|
|
if (likely(null_lab == NULL)) {
|
|
|
|
/* The current insn wasn't conditional or handled the condition
|
|
|
|
applied to it without a branch, so the (new) setting of
|
|
|
|
NULL_COND can be applied directly to the next insn. */
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
ctx->null_lab = NULL;
|
|
|
|
|
|
|
|
if (likely(ctx->null_cond.c == TCG_COND_NEVER)) {
|
|
|
|
/* The next instruction will be unconditional,
|
|
|
|
and NULL_COND already reflects that. */
|
|
|
|
gen_set_label(null_lab);
|
|
|
|
} else {
|
|
|
|
/* The insn that we just executed is itself nullifying the next
|
|
|
|
instruction. Store the condition in the PSW[N] global.
|
|
|
|
We asserted PSW[N] = 0 in nullify_over, so that after the
|
|
|
|
label we have the proper value in place. */
|
|
|
|
nullify_save(ctx);
|
|
|
|
gen_set_label(null_lab);
|
|
|
|
ctx->null_cond = cond_make_n();
|
|
|
|
}
|
2017-07-15 09:56:35 +03:00
|
|
|
if (status == DISAS_NORETURN) {
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NEXT;
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
static bool iaqe_variable(const DisasIAQE *e)
|
|
|
|
{
|
|
|
|
return e->base || e->space;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DisasIAQE iaqe_incr(const DisasIAQE *e, int64_t disp)
|
|
|
|
{
|
|
|
|
return (DisasIAQE){
|
|
|
|
.space = e->space,
|
|
|
|
.base = e->base,
|
|
|
|
.disp = e->disp + disp,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static DisasIAQE iaqe_branchi(DisasContext *ctx, int64_t disp)
|
|
|
|
{
|
|
|
|
return (DisasIAQE){
|
|
|
|
.space = ctx->iaq_b.space,
|
|
|
|
.disp = ctx->iaq_f.disp + 8 + disp,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static DisasIAQE iaqe_next_absv(DisasContext *ctx, TCGv_i64 var)
|
|
|
|
{
|
|
|
|
return (DisasIAQE){
|
|
|
|
.space = ctx->iaq_b.space,
|
|
|
|
.base = var,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static void copy_iaoq_entry(DisasContext *ctx, TCGv_i64 dest,
|
2024-03-22 02:56:44 +03:00
|
|
|
const DisasIAQE *src)
|
2016-12-15 22:26:14 +03:00
|
|
|
{
|
2024-03-24 11:09:43 +03:00
|
|
|
uint64_t mask = gva_offset_mask(ctx->tb_flags);
|
2023-10-27 05:03:34 +03:00
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
if (src->base == NULL) {
|
2024-03-22 05:47:14 +03:00
|
|
|
tcg_gen_movi_i64(dest, (ctx->iaoq_first + src->disp) & mask);
|
2024-03-22 02:56:44 +03:00
|
|
|
} else if (src->disp == 0) {
|
|
|
|
tcg_gen_andi_i64(dest, src->base, mask);
|
2016-12-15 22:26:14 +03:00
|
|
|
} else {
|
2024-03-22 02:56:44 +03:00
|
|
|
tcg_gen_addi_i64(dest, src->base, src->disp);
|
|
|
|
tcg_gen_andi_i64(dest, dest, mask);
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
static void install_iaq_entries(DisasContext *ctx, const DisasIAQE *f,
|
|
|
|
const DisasIAQE *b)
|
2024-03-22 07:40:54 +03:00
|
|
|
{
|
2024-03-22 02:56:44 +03:00
|
|
|
DisasIAQE b_next;
|
2024-03-22 07:40:54 +03:00
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
if (b == NULL) {
|
|
|
|
b_next = iaqe_incr(f, 4);
|
|
|
|
b = &b_next;
|
2024-03-22 07:40:54 +03:00
|
|
|
}
|
2024-03-22 02:56:44 +03:00
|
|
|
copy_iaoq_entry(ctx, cpu_iaoq_f, f);
|
|
|
|
copy_iaoq_entry(ctx, cpu_iaoq_b, b);
|
|
|
|
if (f->space) {
|
|
|
|
tcg_gen_mov_i64(cpu_iasq_f, f->space);
|
2024-03-23 10:04:24 +03:00
|
|
|
}
|
2024-03-22 02:56:44 +03:00
|
|
|
if (b->space || f->space) {
|
|
|
|
tcg_gen_mov_i64(cpu_iasq_b, b->space ? : f->space);
|
2024-03-23 10:04:24 +03:00
|
|
|
}
|
2024-03-22 07:40:54 +03:00
|
|
|
}
|
|
|
|
|
2024-03-22 09:30:12 +03:00
|
|
|
static void install_link(DisasContext *ctx, unsigned link, bool with_sr0)
|
|
|
|
{
|
|
|
|
tcg_debug_assert(ctx->null_cond.c == TCG_COND_NEVER);
|
|
|
|
if (!link) {
|
|
|
|
return;
|
|
|
|
}
|
2024-03-22 05:47:14 +03:00
|
|
|
DisasIAQE next = iaqe_incr(&ctx->iaq_b, 4);
|
|
|
|
copy_iaoq_entry(ctx, cpu_gr[link], &next);
|
2024-03-22 09:30:12 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
if (with_sr0) {
|
|
|
|
tcg_gen_mov_i64(cpu_sr[0], cpu_iasq_b);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-12-15 22:26:14 +03:00
|
|
|
static void gen_excp_1(int exception)
|
|
|
|
{
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_excp(tcg_env, tcg_constant_i32(exception));
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
static void gen_excp(DisasContext *ctx, int exception)
|
2016-12-15 22:26:14 +03:00
|
|
|
{
|
2024-03-22 02:56:44 +03:00
|
|
|
install_iaq_entries(ctx, &ctx->iaq_f, &ctx->iaq_b);
|
2016-12-15 22:58:17 +03:00
|
|
|
nullify_save(ctx);
|
2016-12-15 22:26:14 +03:00
|
|
|
gen_excp_1(exception);
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
static bool gen_excp_iir(DisasContext *ctx, int exc)
|
2017-10-11 23:19:11 +03:00
|
|
|
{
|
2018-02-12 04:09:30 +03:00
|
|
|
nullify_over(ctx);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_st_i64(tcg_constant_i64(ctx->insn),
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_env, offsetof(CPUHPPAState, cr[CR_IIR]));
|
2018-02-12 04:09:30 +03:00
|
|
|
gen_excp(ctx, exc);
|
|
|
|
return nullify_end(ctx);
|
2017-10-11 23:19:11 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
static bool gen_illegal(DisasContext *ctx)
|
2016-12-15 22:26:14 +03:00
|
|
|
{
|
2018-02-12 04:09:30 +03:00
|
|
|
return gen_excp_iir(ctx, EXCP_ILL);
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 04:14:10 +03:00
|
|
|
#ifdef CONFIG_USER_ONLY
|
|
|
|
#define CHECK_MOST_PRIVILEGED(EXCP) \
|
|
|
|
return gen_excp_iir(ctx, EXCP)
|
|
|
|
#else
|
|
|
|
#define CHECK_MOST_PRIVILEGED(EXCP) \
|
2018-02-12 04:09:30 +03:00
|
|
|
do { \
|
|
|
|
if (ctx->privilege != 0) { \
|
|
|
|
return gen_excp_iir(ctx, EXCP); \
|
|
|
|
} \
|
2017-10-09 17:44:30 +03:00
|
|
|
} while (0)
|
2018-02-12 04:14:10 +03:00
|
|
|
#endif
|
2017-10-09 17:44:30 +03:00
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
static bool use_goto_tb(DisasContext *ctx, const DisasIAQE *f,
|
|
|
|
const DisasIAQE *b)
|
2016-12-15 22:26:14 +03:00
|
|
|
{
|
2024-03-22 02:56:44 +03:00
|
|
|
return (!iaqe_variable(f) &&
|
|
|
|
(b == NULL || !iaqe_variable(b)) &&
|
2024-03-22 05:47:14 +03:00
|
|
|
translator_use_goto_tb(&ctx->base, ctx->iaoq_first + f->disp));
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
|
|
|
|
2016-12-15 22:58:17 +03:00
|
|
|
/* If the next insn is to be nullified, and it's on the same page,
|
|
|
|
and we're not attempting to set a breakpoint on it, then we can
|
|
|
|
totally skip the nullified insn. This avoids creating and
|
|
|
|
executing a TB that merely branches to the next TB. */
|
|
|
|
static bool use_nullify_skip(DisasContext *ctx)
|
|
|
|
{
|
2024-03-22 05:59:40 +03:00
|
|
|
return (!(tb_cflags(ctx->base.tb) & CF_BP_PAGE)
|
2024-03-22 02:56:44 +03:00
|
|
|
&& !iaqe_variable(&ctx->iaq_b)
|
2024-03-22 05:47:14 +03:00
|
|
|
&& (((ctx->iaoq_first + ctx->iaq_b.disp) ^ ctx->iaoq_first)
|
|
|
|
& TARGET_PAGE_MASK) == 0);
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
|
|
|
|
2016-12-15 22:26:14 +03:00
|
|
|
static void gen_goto_tb(DisasContext *ctx, int which,
|
2024-03-22 02:56:44 +03:00
|
|
|
const DisasIAQE *f, const DisasIAQE *b)
|
2016-12-15 22:26:14 +03:00
|
|
|
{
|
2024-03-22 02:56:44 +03:00
|
|
|
if (use_goto_tb(ctx, f, b)) {
|
2016-12-15 22:26:14 +03:00
|
|
|
tcg_gen_goto_tb(which);
|
2024-03-22 02:56:44 +03:00
|
|
|
install_iaq_entries(ctx, f, b);
|
2018-05-31 04:06:23 +03:00
|
|
|
tcg_gen_exit_tb(ctx->base.tb, which);
|
2016-12-15 22:26:14 +03:00
|
|
|
} else {
|
2024-03-22 02:56:44 +03:00
|
|
|
install_iaq_entries(ctx, f, b);
|
2021-07-19 10:19:26 +03:00
|
|
|
tcg_gen_lookup_and_goto_ptr();
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-12 04:12:54 +03:00
|
|
|
static bool cond_need_sv(int c)
|
|
|
|
{
|
|
|
|
return c == 2 || c == 3 || c == 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool cond_need_cb(int c)
|
|
|
|
{
|
|
|
|
return c == 4 || c == 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute conditional for arithmetic. See Page 5-3, Table 5-1, of
|
|
|
|
* the Parisc 1.1 Architecture Reference Manual for details.
|
|
|
|
*/
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-09-17 05:26:15 +03:00
|
|
|
static DisasCond do_cond(DisasContext *ctx, unsigned cf, bool d,
|
2024-03-26 06:06:03 +03:00
|
|
|
TCGv_i64 res, TCGv_i64 uv, TCGv_i64 sv)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2024-03-25 23:27:12 +03:00
|
|
|
TCGCond sign_cond, zero_cond;
|
|
|
|
uint64_t sign_imm, zero_imm;
|
2016-12-16 00:37:23 +03:00
|
|
|
DisasCond cond;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tmp;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2024-03-25 23:27:12 +03:00
|
|
|
if (d) {
|
|
|
|
/* 64-bit condition. */
|
|
|
|
sign_imm = 0;
|
|
|
|
sign_cond = TCG_COND_LT;
|
|
|
|
zero_imm = 0;
|
|
|
|
zero_cond = TCG_COND_EQ;
|
|
|
|
} else {
|
|
|
|
/* 32-bit condition. */
|
|
|
|
sign_imm = 1ull << 31;
|
|
|
|
sign_cond = TCG_COND_TSTNE;
|
|
|
|
zero_imm = UINT32_MAX;
|
|
|
|
zero_cond = TCG_COND_TSTEQ;
|
|
|
|
}
|
|
|
|
|
2016-12-16 00:37:23 +03:00
|
|
|
switch (cf >> 1) {
|
2019-02-12 04:12:54 +03:00
|
|
|
case 0: /* Never / TR (0 / 1) */
|
2016-12-16 00:37:23 +03:00
|
|
|
cond = cond_make_f();
|
|
|
|
break;
|
|
|
|
case 1: /* = / <> (Z / !Z) */
|
2024-03-25 23:27:12 +03:00
|
|
|
cond = cond_make_vi(zero_cond, res, zero_imm);
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
2019-02-12 04:12:54 +03:00
|
|
|
case 2: /* < / >= (N ^ V / !(N ^ V) */
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_xor_i64(tmp, res, sv);
|
2024-03-25 23:27:12 +03:00
|
|
|
cond = cond_make_ti(sign_cond, tmp, sign_imm);
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
2019-02-12 04:12:54 +03:00
|
|
|
case 3: /* <= / > (N ^ V) | Z / !((N ^ V) | Z) */
|
|
|
|
/*
|
|
|
|
* Simplify:
|
|
|
|
* (N ^ V) | Z
|
|
|
|
* ((res < 0) ^ (sv < 0)) | !res
|
|
|
|
* ((res ^ sv) < 0) | !res
|
2024-03-25 23:27:12 +03:00
|
|
|
* ((res ^ sv) < 0 ? 1 : !res)
|
|
|
|
* !((res ^ sv) < 0 ? 0 : res)
|
2019-02-12 04:12:54 +03:00
|
|
|
*/
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2024-03-25 23:27:12 +03:00
|
|
|
tcg_gen_xor_i64(tmp, res, sv);
|
|
|
|
tcg_gen_movcond_i64(sign_cond, tmp,
|
|
|
|
tmp, tcg_constant_i64(sign_imm),
|
|
|
|
ctx->zero, res);
|
|
|
|
cond = cond_make_ti(zero_cond, tmp, zero_imm);
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
2024-03-26 06:06:03 +03:00
|
|
|
case 4: /* NUV / UV (!UV / UV) */
|
2024-03-25 20:30:19 +03:00
|
|
|
cond = cond_make_vi(TCG_COND_EQ, uv, 0);
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
2024-03-26 06:06:03 +03:00
|
|
|
case 5: /* ZNV / VNZ (!UV | Z / UV & !Z) */
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2024-03-26 06:06:03 +03:00
|
|
|
tcg_gen_movcond_i64(TCG_COND_EQ, tmp, uv, ctx->zero, ctx->zero, res);
|
2024-03-25 23:27:12 +03:00
|
|
|
cond = cond_make_ti(zero_cond, tmp, zero_imm);
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
|
|
|
case 6: /* SV / NSV (V / !V) */
|
2024-03-25 23:27:12 +03:00
|
|
|
cond = cond_make_vi(sign_cond, sv, sign_imm);
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
|
|
|
case 7: /* OD / EV */
|
2024-03-25 23:27:12 +03:00
|
|
|
cond = cond_make_vi(TCG_COND_TSTNE, res, 1);
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
if (cf & 1) {
|
|
|
|
cond.c = tcg_invert_cond(cond.c);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cond;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Similar, but for the special case of subtraction without borrow, we
|
|
|
|
can use the inputs directly. This can allow other computation to be
|
|
|
|
deleted as unused. */
|
|
|
|
|
2023-09-17 05:28:12 +03:00
|
|
|
static DisasCond do_sub_cond(DisasContext *ctx, unsigned cf, bool d,
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 res, TCGv_i64 in1,
|
|
|
|
TCGv_i64 in2, TCGv_i64 sv)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-09-17 05:28:12 +03:00
|
|
|
TCGCond tc;
|
|
|
|
bool ext_uns;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
switch (cf >> 1) {
|
|
|
|
case 1: /* = / <> */
|
2023-09-17 05:28:12 +03:00
|
|
|
tc = TCG_COND_EQ;
|
|
|
|
ext_uns = true;
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
|
|
|
case 2: /* < / >= */
|
2023-09-17 05:28:12 +03:00
|
|
|
tc = TCG_COND_LT;
|
|
|
|
ext_uns = false;
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
|
|
|
case 3: /* <= / > */
|
2023-09-17 05:28:12 +03:00
|
|
|
tc = TCG_COND_LE;
|
|
|
|
ext_uns = false;
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
|
|
|
case 4: /* << / >>= */
|
2023-09-17 05:28:12 +03:00
|
|
|
tc = TCG_COND_LTU;
|
|
|
|
ext_uns = true;
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
|
|
|
case 5: /* <<= / >> */
|
2023-09-17 05:28:12 +03:00
|
|
|
tc = TCG_COND_LEU;
|
|
|
|
ext_uns = true;
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
|
|
|
default:
|
2023-09-17 05:26:15 +03:00
|
|
|
return do_cond(ctx, cf, d, res, NULL, sv);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
2023-09-17 05:28:12 +03:00
|
|
|
|
2016-12-16 00:37:23 +03:00
|
|
|
if (cf & 1) {
|
2023-09-17 05:28:12 +03:00
|
|
|
tc = tcg_invert_cond(tc);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
2024-03-26 05:33:50 +03:00
|
|
|
if (!d) {
|
2023-10-18 07:47:02 +03:00
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t2 = tcg_temp_new_i64();
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-09-17 05:28:12 +03:00
|
|
|
if (ext_uns) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ext32u_i64(t1, in1);
|
|
|
|
tcg_gen_ext32u_i64(t2, in2);
|
2023-09-17 05:28:12 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ext32s_i64(t1, in1);
|
|
|
|
tcg_gen_ext32s_i64(t2, in2);
|
2023-09-17 05:28:12 +03:00
|
|
|
}
|
2024-03-25 20:30:19 +03:00
|
|
|
return cond_make_tt(tc, t1, t2);
|
2023-09-17 05:28:12 +03:00
|
|
|
}
|
2024-03-25 20:30:19 +03:00
|
|
|
return cond_make_vv(tc, in1, in2);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2019-02-12 03:40:27 +03:00
|
|
|
/*
|
|
|
|
* Similar, but for logicals, where the carry and overflow bits are not
|
|
|
|
* computed, and use of them is undefined.
|
|
|
|
*
|
|
|
|
* Undefined or not, hardware does not trap. It seems reasonable to
|
|
|
|
* assume hardware treats cases c={4,5,6} as if C=0 & V=0, since that's
|
|
|
|
* how cases c={2,3} are treated.
|
|
|
|
*/
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-09-17 05:30:10 +03:00
|
|
|
static DisasCond do_log_cond(DisasContext *ctx, unsigned cf, bool d,
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 res)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-09-17 05:30:10 +03:00
|
|
|
TCGCond tc;
|
2024-03-26 00:00:36 +03:00
|
|
|
uint64_t imm;
|
2019-02-12 03:40:27 +03:00
|
|
|
|
2024-03-26 00:00:36 +03:00
|
|
|
switch (cf >> 1) {
|
|
|
|
case 0: /* never / always */
|
|
|
|
case 4: /* undef, C */
|
|
|
|
case 5: /* undef, C & !Z */
|
|
|
|
case 6: /* undef, V */
|
|
|
|
return cf & 1 ? cond_make_t() : cond_make_f();
|
|
|
|
case 1: /* == / <> */
|
|
|
|
tc = d ? TCG_COND_EQ : TCG_COND_TSTEQ;
|
|
|
|
imm = d ? 0 : UINT32_MAX;
|
2023-09-17 05:30:10 +03:00
|
|
|
break;
|
2024-03-26 00:00:36 +03:00
|
|
|
case 2: /* < / >= */
|
|
|
|
tc = d ? TCG_COND_LT : TCG_COND_TSTNE;
|
|
|
|
imm = d ? 0 : 1ull << 31;
|
2023-09-17 05:30:10 +03:00
|
|
|
break;
|
2024-03-26 00:00:36 +03:00
|
|
|
case 3: /* <= / > */
|
|
|
|
tc = cf & 1 ? TCG_COND_GT : TCG_COND_LE;
|
|
|
|
if (!d) {
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
|
|
|
tcg_gen_ext32s_i64(tmp, res);
|
|
|
|
return cond_make_ti(tc, tmp, 0);
|
|
|
|
}
|
|
|
|
return cond_make_vi(tc, res, 0);
|
|
|
|
case 7: /* OD / EV */
|
|
|
|
tc = TCG_COND_TSTNE;
|
|
|
|
imm = 1;
|
2023-09-17 05:30:10 +03:00
|
|
|
break;
|
2019-02-12 03:40:27 +03:00
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
2024-03-26 00:00:36 +03:00
|
|
|
if (cf & 1) {
|
|
|
|
tc = tcg_invert_cond(tc);
|
2023-09-17 05:30:10 +03:00
|
|
|
}
|
2024-03-26 00:00:36 +03:00
|
|
|
return cond_make_vi(tc, res, imm);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2016-12-16 00:50:28 +03:00
|
|
|
/* Similar, but for shift/extract/deposit conditions. */
|
|
|
|
|
2023-09-17 05:34:39 +03:00
|
|
|
static DisasCond do_sed_cond(DisasContext *ctx, unsigned orig, bool d,
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 res)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
|
|
|
unsigned c, f;
|
|
|
|
|
|
|
|
/* Convert the compressed condition codes to standard.
|
|
|
|
0-2 are the same as logicals (nv,<,<=), while 3 is OD.
|
|
|
|
4-7 are the reverse of 0-3. */
|
|
|
|
c = orig & 3;
|
|
|
|
if (c == 3) {
|
|
|
|
c = 7;
|
|
|
|
}
|
|
|
|
f = (orig & 4) / 4;
|
|
|
|
|
2023-09-17 05:30:10 +03:00
|
|
|
return do_log_cond(ctx, c * 2 + f, d, res);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2024-03-25 04:59:37 +03:00
|
|
|
/* Similar, but for unit zero conditions. */
|
|
|
|
static DisasCond do_unit_zero_cond(unsigned cf, bool d, TCGv_i64 res)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2024-03-25 04:59:37 +03:00
|
|
|
TCGv_i64 tmp;
|
2023-10-18 07:11:19 +03:00
|
|
|
uint64_t d_repl = d ? 0x0000000100000001ull : 1;
|
2024-03-25 04:59:37 +03:00
|
|
|
uint64_t ones = 0, sgns = 0;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
switch (cf >> 1) {
|
2024-03-21 21:42:26 +03:00
|
|
|
case 1: /* SBW / NBW */
|
|
|
|
if (d) {
|
2024-03-25 04:59:37 +03:00
|
|
|
ones = d_repl;
|
|
|
|
sgns = d_repl << 31;
|
2024-03-21 21:42:26 +03:00
|
|
|
}
|
|
|
|
break;
|
2016-12-16 00:37:23 +03:00
|
|
|
case 2: /* SBZ / NBZ */
|
2024-03-25 04:59:37 +03:00
|
|
|
ones = d_repl * 0x01010101u;
|
|
|
|
sgns = ones << 7;
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
|
|
|
case 3: /* SHZ / NHZ */
|
2024-03-25 04:59:37 +03:00
|
|
|
ones = d_repl * 0x00010001u;
|
|
|
|
sgns = ones << 15;
|
2016-12-16 00:37:23 +03:00
|
|
|
break;
|
|
|
|
}
|
2024-03-25 04:59:37 +03:00
|
|
|
if (ones == 0) {
|
|
|
|
/* Undefined, or 0/1 (never/always). */
|
|
|
|
return cf & 1 ? cond_make_t() : cond_make_f();
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2024-03-25 04:59:37 +03:00
|
|
|
/*
|
|
|
|
* See hasless(v,1) from
|
|
|
|
* https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord
|
|
|
|
*/
|
|
|
|
tmp = tcg_temp_new_i64();
|
|
|
|
tcg_gen_subi_i64(tmp, res, ones);
|
|
|
|
tcg_gen_andc_i64(tmp, tmp, res);
|
|
|
|
tcg_gen_andi_i64(tmp, tmp, sgns);
|
|
|
|
|
2024-03-25 20:30:19 +03:00
|
|
|
return cond_make_ti(cf & 1 ? TCG_COND_EQ : TCG_COND_NE, tmp, 0);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 get_carry(DisasContext *ctx, bool d,
|
|
|
|
TCGv_i64 cb, TCGv_i64 cb_msb)
|
2023-09-17 02:28:23 +03:00
|
|
|
{
|
2024-03-26 05:33:50 +03:00
|
|
|
if (!d) {
|
2023-10-18 07:47:02 +03:00
|
|
|
TCGv_i64 t = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_extract_i64(t, cb, 32, 1);
|
2023-09-17 02:28:23 +03:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
return cb_msb;
|
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 get_psw_carry(DisasContext *ctx, bool d)
|
2023-09-17 02:28:23 +03:00
|
|
|
{
|
|
|
|
return get_carry(ctx, d, cpu_psw_cb, cpu_psw_cb_msb);
|
|
|
|
}
|
|
|
|
|
2016-12-16 00:37:23 +03:00
|
|
|
/* Compute signed overflow for addition. */
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 do_add_sv(DisasContext *ctx, TCGv_i64 res,
|
2024-03-26 09:33:16 +03:00
|
|
|
TCGv_i64 in1, TCGv_i64 in2,
|
|
|
|
TCGv_i64 orig_in1, int shift, bool d)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:47:02 +03:00
|
|
|
TCGv_i64 sv = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_xor_i64(sv, res, in1);
|
|
|
|
tcg_gen_xor_i64(tmp, in1, in2);
|
|
|
|
tcg_gen_andc_i64(sv, sv, tmp);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2024-03-26 09:33:16 +03:00
|
|
|
switch (shift) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
/* Shift left by one and compare the sign. */
|
|
|
|
tcg_gen_add_i64(tmp, orig_in1, orig_in1);
|
|
|
|
tcg_gen_xor_i64(tmp, tmp, orig_in1);
|
|
|
|
/* Incorporate into the overflow. */
|
|
|
|
tcg_gen_or_i64(sv, sv, tmp);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
int sign_bit = d ? 63 : 31;
|
|
|
|
|
|
|
|
/* Compare the sign against all lower bits. */
|
|
|
|
tcg_gen_sextract_i64(tmp, orig_in1, sign_bit, 1);
|
|
|
|
tcg_gen_xor_i64(tmp, tmp, orig_in1);
|
|
|
|
/*
|
|
|
|
* If one of the bits shifting into or through the sign
|
|
|
|
* differs, then we have overflow.
|
|
|
|
*/
|
|
|
|
tcg_gen_extract_i64(tmp, tmp, sign_bit - shift, shift);
|
|
|
|
tcg_gen_movcond_i64(TCG_COND_NE, sv, tmp, ctx->zero,
|
|
|
|
tcg_constant_i64(-1), sv);
|
|
|
|
}
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
return sv;
|
|
|
|
}
|
|
|
|
|
2024-03-26 09:33:16 +03:00
|
|
|
/* Compute unsigned overflow for addition. */
|
|
|
|
static TCGv_i64 do_add_uv(DisasContext *ctx, TCGv_i64 cb, TCGv_i64 cb_msb,
|
|
|
|
TCGv_i64 in1, int shift, bool d)
|
|
|
|
{
|
|
|
|
if (shift == 0) {
|
|
|
|
return get_carry(ctx, d, cb, cb_msb);
|
|
|
|
} else {
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
|
|
|
tcg_gen_extract_i64(tmp, in1, (d ? 63 : 31) - shift, shift);
|
|
|
|
tcg_gen_or_i64(tmp, tmp, get_carry(ctx, d, cb, cb_msb));
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-16 00:37:23 +03:00
|
|
|
/* Compute signed overflow for subtraction. */
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 do_sub_sv(DisasContext *ctx, TCGv_i64 res,
|
|
|
|
TCGv_i64 in1, TCGv_i64 in2)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:47:02 +03:00
|
|
|
TCGv_i64 sv = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_xor_i64(sv, res, in1);
|
|
|
|
tcg_gen_xor_i64(tmp, in1, in2);
|
|
|
|
tcg_gen_and_i64(sv, sv, tmp);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
return sv;
|
|
|
|
}
|
|
|
|
|
2024-03-26 09:33:16 +03:00
|
|
|
static void do_add(DisasContext *ctx, unsigned rt, TCGv_i64 orig_in1,
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 in2, unsigned shift, bool is_l,
|
2023-09-17 06:51:13 +03:00
|
|
|
bool is_tsv, bool is_tc, bool is_c, unsigned cf, bool d)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2024-03-26 09:33:16 +03:00
|
|
|
TCGv_i64 dest, cb, cb_msb, in1, uv, sv, tmp;
|
2016-12-16 00:37:23 +03:00
|
|
|
unsigned c = cf >> 1;
|
|
|
|
DisasCond cond;
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
dest = tcg_temp_new_i64();
|
2017-11-02 14:47:37 +03:00
|
|
|
cb = NULL;
|
|
|
|
cb_msb = NULL;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2024-03-26 09:33:16 +03:00
|
|
|
in1 = orig_in1;
|
2016-12-16 00:37:23 +03:00
|
|
|
if (shift) {
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_shli_i64(tmp, in1, shift);
|
2016-12-16 00:37:23 +03:00
|
|
|
in1 = tmp;
|
|
|
|
}
|
|
|
|
|
2019-02-12 04:12:54 +03:00
|
|
|
if (!is_l || cond_need_cb(c)) {
|
2023-10-18 07:47:02 +03:00
|
|
|
cb_msb = tcg_temp_new_i64();
|
|
|
|
cb = tcg_temp_new_i64();
|
2023-10-18 02:16:03 +03:00
|
|
|
|
2023-10-18 20:24:33 +03:00
|
|
|
tcg_gen_add2_i64(dest, cb_msb, in1, ctx->zero, in2, ctx->zero);
|
2016-12-16 00:37:23 +03:00
|
|
|
if (is_c) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_add2_i64(dest, cb_msb, dest, cb_msb,
|
2023-10-18 20:24:33 +03:00
|
|
|
get_psw_carry(ctx, d), ctx->zero);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_xor_i64(cb, in1, in2);
|
|
|
|
tcg_gen_xor_i64(cb, cb, dest);
|
2016-12-16 00:37:23 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_add_i64(dest, in1, in2);
|
2016-12-16 00:37:23 +03:00
|
|
|
if (is_c) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_add_i64(dest, dest, get_psw_carry(ctx, d));
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute signed overflow if required. */
|
2017-11-02 14:47:37 +03:00
|
|
|
sv = NULL;
|
2019-02-12 04:12:54 +03:00
|
|
|
if (is_tsv || cond_need_sv(c)) {
|
2024-03-26 09:33:16 +03:00
|
|
|
sv = do_add_sv(ctx, dest, in1, in2, orig_in1, shift, d);
|
2016-12-16 00:37:23 +03:00
|
|
|
if (is_tsv) {
|
2024-03-21 21:42:27 +03:00
|
|
|
if (!d) {
|
|
|
|
tcg_gen_ext32s_i64(sv, sv);
|
|
|
|
}
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_tsv(tcg_env, sv);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-26 09:33:16 +03:00
|
|
|
/* Compute unsigned overflow if required. */
|
|
|
|
uv = NULL;
|
|
|
|
if (cond_need_cb(c)) {
|
|
|
|
uv = do_add_uv(ctx, cb, cb_msb, orig_in1, shift, d);
|
|
|
|
}
|
|
|
|
|
2016-12-16 00:37:23 +03:00
|
|
|
/* Emit any conditional trap before any writeback. */
|
2024-03-26 09:33:16 +03:00
|
|
|
cond = do_cond(ctx, cf, d, dest, uv, sv);
|
2016-12-16 00:37:23 +03:00
|
|
|
if (is_tc) {
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_setcond_i64(cond.c, tmp, cond.a0, cond.a1);
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_tcond(tcg_env, tmp);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write back the result. */
|
|
|
|
if (!is_l) {
|
|
|
|
save_or_nullify(ctx, cpu_psw_cb, cb);
|
|
|
|
save_or_nullify(ctx, cpu_psw_cb_msb, cb_msb);
|
|
|
|
}
|
|
|
|
save_gpr(ctx, rt, dest);
|
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
ctx->null_cond = cond;
|
|
|
|
}
|
|
|
|
|
2023-09-17 06:51:13 +03:00
|
|
|
static bool do_add_reg(DisasContext *ctx, arg_rrr_cf_d_sh *a,
|
2018-02-12 08:44:41 +03:00
|
|
|
bool is_l, bool is_tsv, bool is_tc, bool is_c)
|
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_r1, tcg_r2;
|
2018-02-12 08:44:41 +03:00
|
|
|
|
|
|
|
if (a->cf) {
|
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
|
|
|
tcg_r1 = load_gpr(ctx, a->r1);
|
|
|
|
tcg_r2 = load_gpr(ctx, a->r2);
|
2023-09-17 06:51:13 +03:00
|
|
|
do_add(ctx, a->t, tcg_r1, tcg_r2, a->sh, is_l,
|
|
|
|
is_tsv, is_tc, is_c, a->cf, a->d);
|
2018-02-12 08:44:41 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool do_add_imm(DisasContext *ctx, arg_rri_cf *a,
|
|
|
|
bool is_tsv, bool is_tc)
|
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_im, tcg_r2;
|
2018-02-13 02:34:12 +03:00
|
|
|
|
|
|
|
if (a->cf) {
|
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_im = tcg_constant_i64(a->i);
|
2018-02-13 02:34:12 +03:00
|
|
|
tcg_r2 = load_gpr(ctx, a->r);
|
2023-09-17 06:51:13 +03:00
|
|
|
/* All ADDI conditions are 32-bit. */
|
|
|
|
do_add(ctx, a->t, tcg_im, tcg_r2, 0, 0, is_tsv, is_tc, 0, a->cf, false);
|
2018-02-13 02:34:12 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static void do_sub(DisasContext *ctx, unsigned rt, TCGv_i64 in1,
|
|
|
|
TCGv_i64 in2, bool is_tsv, bool is_b,
|
2023-09-17 07:25:44 +03:00
|
|
|
bool is_tc, unsigned cf, bool d)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 20:24:33 +03:00
|
|
|
TCGv_i64 dest, sv, cb, cb_msb, tmp;
|
2016-12-16 00:37:23 +03:00
|
|
|
unsigned c = cf >> 1;
|
|
|
|
DisasCond cond;
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
dest = tcg_temp_new_i64();
|
|
|
|
cb = tcg_temp_new_i64();
|
|
|
|
cb_msb = tcg_temp_new_i64();
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
if (is_b) {
|
|
|
|
/* DEST,C = IN1 + ~IN2 + C. */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_not_i64(cb, in2);
|
2023-10-18 20:24:33 +03:00
|
|
|
tcg_gen_add2_i64(dest, cb_msb, in1, ctx->zero,
|
|
|
|
get_psw_carry(ctx, d), ctx->zero);
|
|
|
|
tcg_gen_add2_i64(dest, cb_msb, dest, cb_msb, cb, ctx->zero);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_xor_i64(cb, cb, in1);
|
|
|
|
tcg_gen_xor_i64(cb, cb, dest);
|
2016-12-16 00:37:23 +03:00
|
|
|
} else {
|
2023-10-18 02:16:03 +03:00
|
|
|
/*
|
|
|
|
* DEST,C = IN1 + ~IN2 + 1. We can produce the same result in fewer
|
|
|
|
* operations by seeding the high word with 1 and subtracting.
|
|
|
|
*/
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 one = tcg_constant_i64(1);
|
2023-10-18 20:24:33 +03:00
|
|
|
tcg_gen_sub2_i64(dest, cb_msb, in1, one, in2, ctx->zero);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_eqv_i64(cb, in1, in2);
|
|
|
|
tcg_gen_xor_i64(cb, cb, dest);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute signed overflow if required. */
|
2017-11-02 14:47:37 +03:00
|
|
|
sv = NULL;
|
2019-02-12 04:12:54 +03:00
|
|
|
if (is_tsv || cond_need_sv(c)) {
|
2016-12-16 00:37:23 +03:00
|
|
|
sv = do_sub_sv(ctx, dest, in1, in2);
|
|
|
|
if (is_tsv) {
|
2024-03-21 21:42:27 +03:00
|
|
|
if (!d) {
|
|
|
|
tcg_gen_ext32s_i64(sv, sv);
|
|
|
|
}
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_tsv(tcg_env, sv);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute the condition. We cannot use the special case for borrow. */
|
|
|
|
if (!is_b) {
|
2023-09-17 05:28:12 +03:00
|
|
|
cond = do_sub_cond(ctx, cf, d, dest, in1, in2, sv);
|
2016-12-16 00:37:23 +03:00
|
|
|
} else {
|
2023-09-17 05:26:15 +03:00
|
|
|
cond = do_cond(ctx, cf, d, dest, get_carry(ctx, d, cb, cb_msb), sv);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Emit any conditional trap before any writeback. */
|
|
|
|
if (is_tc) {
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_setcond_i64(cond.c, tmp, cond.a0, cond.a1);
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_tcond(tcg_env, tmp);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write back the result. */
|
|
|
|
save_or_nullify(ctx, cpu_psw_cb, cb);
|
|
|
|
save_or_nullify(ctx, cpu_psw_cb_msb, cb_msb);
|
|
|
|
save_gpr(ctx, rt, dest);
|
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
ctx->null_cond = cond;
|
|
|
|
}
|
|
|
|
|
2023-09-17 07:25:44 +03:00
|
|
|
static bool do_sub_reg(DisasContext *ctx, arg_rrr_cf_d *a,
|
2018-02-12 08:44:41 +03:00
|
|
|
bool is_tsv, bool is_b, bool is_tc)
|
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_r1, tcg_r2;
|
2018-02-12 08:44:41 +03:00
|
|
|
|
|
|
|
if (a->cf) {
|
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
|
|
|
tcg_r1 = load_gpr(ctx, a->r1);
|
|
|
|
tcg_r2 = load_gpr(ctx, a->r2);
|
2023-09-17 07:25:44 +03:00
|
|
|
do_sub(ctx, a->t, tcg_r1, tcg_r2, is_tsv, is_b, is_tc, a->cf, a->d);
|
2018-02-12 08:44:41 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool do_sub_imm(DisasContext *ctx, arg_rri_cf *a, bool is_tsv)
|
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_im, tcg_r2;
|
2018-02-13 02:34:12 +03:00
|
|
|
|
|
|
|
if (a->cf) {
|
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_im = tcg_constant_i64(a->i);
|
2018-02-13 02:34:12 +03:00
|
|
|
tcg_r2 = load_gpr(ctx, a->r);
|
2023-09-17 07:25:44 +03:00
|
|
|
/* All SUBI conditions are 32-bit. */
|
|
|
|
do_sub(ctx, a->t, tcg_im, tcg_r2, is_tsv, 0, 0, a->cf, false);
|
2018-02-13 02:34:12 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static void do_cmpclr(DisasContext *ctx, unsigned rt, TCGv_i64 in1,
|
|
|
|
TCGv_i64 in2, unsigned cf, bool d)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest, sv;
|
2016-12-16 00:37:23 +03:00
|
|
|
DisasCond cond;
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
dest = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_sub_i64(dest, in1, in2);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
/* Compute signed overflow if required. */
|
2017-11-02 14:47:37 +03:00
|
|
|
sv = NULL;
|
2019-02-12 04:12:54 +03:00
|
|
|
if (cond_need_sv(cf >> 1)) {
|
2016-12-16 00:37:23 +03:00
|
|
|
sv = do_sub_sv(ctx, dest, in1, in2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Form the condition for the compare. */
|
2023-09-17 05:28:12 +03:00
|
|
|
cond = do_sub_cond(ctx, cf, d, dest, in1, in2, sv);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
/* Clear. */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(dest, 0);
|
2016-12-16 00:37:23 +03:00
|
|
|
save_gpr(ctx, rt, dest);
|
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
ctx->null_cond = cond;
|
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static void do_log(DisasContext *ctx, unsigned rt, TCGv_i64 in1,
|
|
|
|
TCGv_i64 in2, unsigned cf, bool d,
|
|
|
|
void (*fn)(TCGv_i64, TCGv_i64, TCGv_i64))
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest = dest_gpr(ctx, rt);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
/* Perform the operation, and writeback. */
|
|
|
|
fn(dest, in1, in2);
|
|
|
|
save_gpr(ctx, rt, dest);
|
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
if (cf) {
|
2023-09-17 05:30:10 +03:00
|
|
|
ctx->null_cond = do_log_cond(ctx, cf, d, dest);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-17 06:21:14 +03:00
|
|
|
static bool do_log_reg(DisasContext *ctx, arg_rrr_cf_d *a,
|
2023-10-18 07:31:08 +03:00
|
|
|
void (*fn)(TCGv_i64, TCGv_i64, TCGv_i64))
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_r1, tcg_r2;
|
2018-02-12 08:44:41 +03:00
|
|
|
|
|
|
|
if (a->cf) {
|
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
|
|
|
tcg_r1 = load_gpr(ctx, a->r1);
|
|
|
|
tcg_r2 = load_gpr(ctx, a->r2);
|
2023-09-17 06:21:14 +03:00
|
|
|
do_log(ctx, a->t, tcg_r1, tcg_r2, a->cf, a->d, fn);
|
2018-02-12 08:44:41 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2024-03-25 04:59:37 +03:00
|
|
|
static void do_unit_addsub(DisasContext *ctx, unsigned rt, TCGv_i64 in1,
|
|
|
|
TCGv_i64 in2, unsigned cf, bool d,
|
|
|
|
bool is_tc, bool is_add)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2024-03-25 04:59:37 +03:00
|
|
|
TCGv_i64 dest = tcg_temp_new_i64();
|
|
|
|
uint64_t test_cb = 0;
|
2016-12-16 00:37:23 +03:00
|
|
|
DisasCond cond;
|
|
|
|
|
2024-03-25 04:59:37 +03:00
|
|
|
/* Select which carry-out bits to test. */
|
|
|
|
switch (cf >> 1) {
|
|
|
|
case 4: /* NDC / SDC -- 4-bit carries */
|
|
|
|
test_cb = dup_const(MO_8, 0x88);
|
|
|
|
break;
|
|
|
|
case 5: /* NWC / SWC -- 32-bit carries */
|
|
|
|
if (d) {
|
|
|
|
test_cb = dup_const(MO_32, INT32_MIN);
|
|
|
|
} else {
|
|
|
|
cf &= 1; /* undefined -- map to never/always */
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6: /* NBC / SBC -- 8-bit carries */
|
|
|
|
test_cb = dup_const(MO_8, INT8_MIN);
|
|
|
|
break;
|
|
|
|
case 7: /* NHC / SHC -- 16-bit carries */
|
|
|
|
test_cb = dup_const(MO_16, INT16_MIN);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!d) {
|
|
|
|
test_cb = (uint32_t)test_cb;
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2024-03-25 04:59:37 +03:00
|
|
|
if (!test_cb) {
|
|
|
|
/* No need to compute carries if we don't need to test them. */
|
|
|
|
if (is_add) {
|
|
|
|
tcg_gen_add_i64(dest, in1, in2);
|
|
|
|
} else {
|
|
|
|
tcg_gen_sub_i64(dest, in1, in2);
|
|
|
|
}
|
|
|
|
cond = do_unit_zero_cond(cf, d, dest);
|
|
|
|
} else {
|
|
|
|
TCGv_i64 cb = tcg_temp_new_i64();
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2024-03-25 04:59:37 +03:00
|
|
|
if (d) {
|
|
|
|
TCGv_i64 cb_msb = tcg_temp_new_i64();
|
|
|
|
if (is_add) {
|
|
|
|
tcg_gen_add2_i64(dest, cb_msb, in1, ctx->zero, in2, ctx->zero);
|
|
|
|
tcg_gen_xor_i64(cb, in1, in2);
|
|
|
|
} else {
|
|
|
|
/* See do_sub, !is_b. */
|
|
|
|
TCGv_i64 one = tcg_constant_i64(1);
|
|
|
|
tcg_gen_sub2_i64(dest, cb_msb, in1, one, in2, ctx->zero);
|
|
|
|
tcg_gen_eqv_i64(cb, in1, in2);
|
|
|
|
}
|
|
|
|
tcg_gen_xor_i64(cb, cb, dest);
|
|
|
|
tcg_gen_extract2_i64(cb, cb, cb_msb, 1);
|
|
|
|
} else {
|
|
|
|
if (is_add) {
|
|
|
|
tcg_gen_add_i64(dest, in1, in2);
|
|
|
|
tcg_gen_xor_i64(cb, in1, in2);
|
|
|
|
} else {
|
|
|
|
tcg_gen_sub_i64(dest, in1, in2);
|
|
|
|
tcg_gen_eqv_i64(cb, in1, in2);
|
|
|
|
}
|
|
|
|
tcg_gen_xor_i64(cb, cb, dest);
|
|
|
|
tcg_gen_shri_i64(cb, cb, 1);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2024-03-25 04:59:37 +03:00
|
|
|
tcg_gen_andi_i64(cb, cb, test_cb);
|
2024-03-25 20:30:19 +03:00
|
|
|
cond = cond_make_ti(cf & 1 ? TCG_COND_EQ : TCG_COND_NE, cb, 0);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
2024-03-25 04:59:37 +03:00
|
|
|
|
|
|
|
if (is_tc) {
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
|
|
|
tcg_gen_setcond_i64(cond.c, tmp, cond.a0, cond.a1);
|
|
|
|
gen_helper_tcond(tcg_env, tmp);
|
|
|
|
}
|
|
|
|
save_gpr(ctx, rt, dest);
|
|
|
|
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
ctx->null_cond = cond;
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2017-12-28 23:38:46 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2017-10-27 17:26:36 +03:00
|
|
|
/* The "normal" usage is SP >= 0, wherein SP == 0 selects the space
|
|
|
|
from the top 2 bits of the base register. There are a few system
|
|
|
|
instructions that have a 3-bit space specifier, for which SR0 is
|
|
|
|
not special. To handle this, pass ~SP. */
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 space_select(DisasContext *ctx, int sp, TCGv_i64 base)
|
2017-12-28 23:38:46 +03:00
|
|
|
{
|
|
|
|
TCGv_ptr ptr;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tmp;
|
2017-12-28 23:38:46 +03:00
|
|
|
TCGv_i64 spc;
|
|
|
|
|
|
|
|
if (sp != 0) {
|
2017-10-27 17:26:36 +03:00
|
|
|
if (sp < 0) {
|
|
|
|
sp = ~sp;
|
|
|
|
}
|
2023-10-18 07:31:08 +03:00
|
|
|
spc = tcg_temp_new_i64();
|
2017-10-27 17:26:36 +03:00
|
|
|
load_spr(ctx, spc, sp);
|
|
|
|
return spc;
|
2017-12-28 23:38:46 +03:00
|
|
|
}
|
2017-11-06 23:10:33 +03:00
|
|
|
if (ctx->tb_flags & TB_FLAG_SR_SAME) {
|
|
|
|
return cpu_srH;
|
|
|
|
}
|
2017-12-28 23:38:46 +03:00
|
|
|
|
|
|
|
ptr = tcg_temp_new_ptr();
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
spc = tcg_temp_new_i64();
|
2017-12-28 23:38:46 +03:00
|
|
|
|
2023-09-17 02:52:51 +03:00
|
|
|
/* Extract top 2 bits of the address, shift left 3 for uint64_t index. */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_shri_i64(tmp, base, (ctx->tb_flags & PSW_W ? 64 : 32) - 5);
|
|
|
|
tcg_gen_andi_i64(tmp, tmp, 030);
|
|
|
|
tcg_gen_trunc_i64_ptr(ptr, tmp);
|
2017-12-28 23:38:46 +03:00
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_gen_add_ptr(ptr, ptr, tcg_env);
|
2017-12-28 23:38:46 +03:00
|
|
|
tcg_gen_ld_i64(spc, ptr, offsetof(CPUHPPAState, sr[4]));
|
|
|
|
|
|
|
|
return spc;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static void form_gva(DisasContext *ctx, TCGv_i64 *pgva, TCGv_i64 *pofs,
|
2023-10-18 07:11:19 +03:00
|
|
|
unsigned rb, unsigned rx, int scale, int64_t disp,
|
2017-12-28 23:38:46 +03:00
|
|
|
unsigned sp, int modify, bool is_phys)
|
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 base = load_gpr(ctx, rb);
|
|
|
|
TCGv_i64 ofs;
|
|
|
|
TCGv_i64 addr;
|
2017-12-28 23:38:46 +03:00
|
|
|
|
2023-10-27 12:46:44 +03:00
|
|
|
set_insn_breg(ctx, rb);
|
|
|
|
|
2017-12-28 23:38:46 +03:00
|
|
|
/* Note that RX is mutually exclusive with DISP. */
|
|
|
|
if (rx) {
|
2023-10-18 07:47:02 +03:00
|
|
|
ofs = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_shli_i64(ofs, cpu_gr[rx], scale);
|
|
|
|
tcg_gen_add_i64(ofs, ofs, base);
|
2017-12-28 23:38:46 +03:00
|
|
|
} else if (disp || modify) {
|
2023-10-18 07:47:02 +03:00
|
|
|
ofs = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_addi_i64(ofs, base, disp);
|
2017-12-28 23:38:46 +03:00
|
|
|
} else {
|
|
|
|
ofs = base;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pofs = ofs;
|
2023-10-18 07:31:08 +03:00
|
|
|
*pgva = addr = tcg_temp_new_i64();
|
2024-03-24 11:09:43 +03:00
|
|
|
tcg_gen_andi_i64(addr, modify <= 0 ? ofs : base,
|
|
|
|
gva_offset_mask(ctx->tb_flags));
|
2023-09-17 02:52:51 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2017-12-28 23:38:46 +03:00
|
|
|
if (!is_phys) {
|
2023-10-18 07:49:54 +03:00
|
|
|
tcg_gen_or_i64(addr, addr, space_select(ctx, sp, base));
|
2017-12-28 23:38:46 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-12-16 01:54:51 +03:00
|
|
|
/* Emit a memory load. The modify parameter should be
|
|
|
|
* < 0 for pre-modify,
|
|
|
|
* > 0 for post-modify,
|
|
|
|
* = 0 for no base register update.
|
|
|
|
*/
|
|
|
|
static void do_load_32(DisasContext *ctx, TCGv_i32 dest, unsigned rb,
|
2023-10-18 07:11:19 +03:00
|
|
|
unsigned rx, int scale, int64_t disp,
|
2019-08-23 21:10:58 +03:00
|
|
|
unsigned sp, int modify, MemOp mop)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 ofs;
|
|
|
|
TCGv_i64 addr;
|
2016-12-16 01:54:51 +03:00
|
|
|
|
|
|
|
/* Caller uses nullify_over/nullify_end. */
|
|
|
|
assert(ctx->null_cond.c == TCG_COND_NEVER);
|
|
|
|
|
2017-12-28 23:38:46 +03:00
|
|
|
form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify,
|
2023-11-07 22:33:45 +03:00
|
|
|
MMU_DISABLED(ctx));
|
2023-09-17 02:20:28 +03:00
|
|
|
tcg_gen_qemu_ld_i32(dest, addr, ctx->mmu_idx, mop | UNALIGN(ctx));
|
2017-12-28 23:38:46 +03:00
|
|
|
if (modify) {
|
|
|
|
save_gpr(ctx, rb, ofs);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_load_64(DisasContext *ctx, TCGv_i64 dest, unsigned rb,
|
2023-10-18 07:11:19 +03:00
|
|
|
unsigned rx, int scale, int64_t disp,
|
2019-08-23 21:10:58 +03:00
|
|
|
unsigned sp, int modify, MemOp mop)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 ofs;
|
|
|
|
TCGv_i64 addr;
|
2016-12-16 01:54:51 +03:00
|
|
|
|
|
|
|
/* Caller uses nullify_over/nullify_end. */
|
|
|
|
assert(ctx->null_cond.c == TCG_COND_NEVER);
|
|
|
|
|
2017-12-28 23:38:46 +03:00
|
|
|
form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify,
|
2023-11-07 22:33:45 +03:00
|
|
|
MMU_DISABLED(ctx));
|
2021-12-27 18:01:26 +03:00
|
|
|
tcg_gen_qemu_ld_i64(dest, addr, ctx->mmu_idx, mop | UNALIGN(ctx));
|
2017-12-28 23:38:46 +03:00
|
|
|
if (modify) {
|
|
|
|
save_gpr(ctx, rb, ofs);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_store_32(DisasContext *ctx, TCGv_i32 src, unsigned rb,
|
2023-10-18 07:11:19 +03:00
|
|
|
unsigned rx, int scale, int64_t disp,
|
2019-08-23 21:10:58 +03:00
|
|
|
unsigned sp, int modify, MemOp mop)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 ofs;
|
|
|
|
TCGv_i64 addr;
|
2016-12-16 01:54:51 +03:00
|
|
|
|
|
|
|
/* Caller uses nullify_over/nullify_end. */
|
|
|
|
assert(ctx->null_cond.c == TCG_COND_NEVER);
|
|
|
|
|
2017-12-28 23:38:46 +03:00
|
|
|
form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify,
|
2023-11-07 22:33:45 +03:00
|
|
|
MMU_DISABLED(ctx));
|
2021-12-27 18:01:26 +03:00
|
|
|
tcg_gen_qemu_st_i32(src, addr, ctx->mmu_idx, mop | UNALIGN(ctx));
|
2017-12-28 23:38:46 +03:00
|
|
|
if (modify) {
|
|
|
|
save_gpr(ctx, rb, ofs);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_store_64(DisasContext *ctx, TCGv_i64 src, unsigned rb,
|
2023-10-18 07:11:19 +03:00
|
|
|
unsigned rx, int scale, int64_t disp,
|
2019-08-23 21:10:58 +03:00
|
|
|
unsigned sp, int modify, MemOp mop)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 ofs;
|
|
|
|
TCGv_i64 addr;
|
2016-12-16 01:54:51 +03:00
|
|
|
|
|
|
|
/* Caller uses nullify_over/nullify_end. */
|
|
|
|
assert(ctx->null_cond.c == TCG_COND_NEVER);
|
|
|
|
|
2017-12-28 23:38:46 +03:00
|
|
|
form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify,
|
2023-11-07 22:33:45 +03:00
|
|
|
MMU_DISABLED(ctx));
|
2021-12-27 18:01:26 +03:00
|
|
|
tcg_gen_qemu_st_i64(src, addr, ctx->mmu_idx, mop | UNALIGN(ctx));
|
2017-12-28 23:38:46 +03:00
|
|
|
if (modify) {
|
|
|
|
save_gpr(ctx, rb, ofs);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
static bool do_load(DisasContext *ctx, unsigned rt, unsigned rb,
|
2023-10-18 07:11:19 +03:00
|
|
|
unsigned rx, int scale, int64_t disp,
|
2019-08-23 21:10:58 +03:00
|
|
|
unsigned sp, int modify, MemOp mop)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest;
|
2016-12-16 01:54:51 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
if (modify == 0) {
|
|
|
|
/* No base register update. */
|
|
|
|
dest = dest_gpr(ctx, rt);
|
|
|
|
} else {
|
|
|
|
/* Make sure if RT == RB, we see the result of the load. */
|
2023-10-18 07:47:02 +03:00
|
|
|
dest = tcg_temp_new_i64();
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
2023-10-18 07:31:08 +03:00
|
|
|
do_load_64(ctx, dest, rb, rx, scale, disp, sp, modify, mop);
|
2016-12-16 01:54:51 +03:00
|
|
|
save_gpr(ctx, rt, dest);
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:54:33 +03:00
|
|
|
static bool do_floadw(DisasContext *ctx, unsigned rt, unsigned rb,
|
2023-10-18 07:11:19 +03:00
|
|
|
unsigned rx, int scale, int64_t disp,
|
2018-02-12 04:09:30 +03:00
|
|
|
unsigned sp, int modify)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 tmp;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
tmp = tcg_temp_new_i32();
|
2017-12-28 23:38:46 +03:00
|
|
|
do_load_32(ctx, tmp, rb, rx, scale, disp, sp, modify, MO_TEUL);
|
2016-12-16 01:54:51 +03:00
|
|
|
save_frw_i32(rt, tmp);
|
|
|
|
|
|
|
|
if (rt == 0) {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_loaded_fr0(tcg_env);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:54:33 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fldw(DisasContext *ctx, arg_ldst *a)
|
|
|
|
{
|
|
|
|
return do_floadw(ctx, a->t, a->b, a->x, a->scale ? 2 : 0,
|
|
|
|
a->disp, a->sp, a->m);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:54:33 +03:00
|
|
|
static bool do_floadd(DisasContext *ctx, unsigned rt, unsigned rb,
|
2023-10-18 07:11:19 +03:00
|
|
|
unsigned rx, int scale, int64_t disp,
|
2018-02-12 04:09:30 +03:00
|
|
|
unsigned sp, int modify)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
|
|
|
TCGv_i64 tmp;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
tmp = tcg_temp_new_i64();
|
2022-01-07 00:00:51 +03:00
|
|
|
do_load_64(ctx, tmp, rb, rx, scale, disp, sp, modify, MO_TEUQ);
|
2016-12-16 01:54:51 +03:00
|
|
|
save_frd(rt, tmp);
|
|
|
|
|
|
|
|
if (rt == 0) {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_loaded_fr0(tcg_env);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:54:33 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fldd(DisasContext *ctx, arg_ldst *a)
|
|
|
|
{
|
|
|
|
return do_floadd(ctx, a->t, a->b, a->x, a->scale ? 3 : 0,
|
|
|
|
a->disp, a->sp, a->m);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
static bool do_store(DisasContext *ctx, unsigned rt, unsigned rb,
|
2023-10-18 07:11:19 +03:00
|
|
|
int64_t disp, unsigned sp,
|
2019-08-23 21:10:58 +03:00
|
|
|
int modify, MemOp mop)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
|
|
|
nullify_over(ctx);
|
2023-10-18 07:31:08 +03:00
|
|
|
do_store_64(ctx, load_gpr(ctx, rt), rb, 0, 0, disp, sp, modify, mop);
|
2018-02-12 09:48:03 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:54:33 +03:00
|
|
|
static bool do_fstorew(DisasContext *ctx, unsigned rt, unsigned rb,
|
2023-10-18 07:11:19 +03:00
|
|
|
unsigned rx, int scale, int64_t disp,
|
2018-02-12 04:09:30 +03:00
|
|
|
unsigned sp, int modify)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 tmp;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
tmp = load_frw_i32(rt);
|
2017-12-28 23:38:46 +03:00
|
|
|
do_store_32(ctx, tmp, rb, rx, scale, disp, sp, modify, MO_TEUL);
|
2016-12-16 01:54:51 +03:00
|
|
|
|
2018-02-13 02:54:33 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fstw(DisasContext *ctx, arg_ldst *a)
|
|
|
|
{
|
|
|
|
return do_fstorew(ctx, a->t, a->b, a->x, a->scale ? 2 : 0,
|
|
|
|
a->disp, a->sp, a->m);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:54:33 +03:00
|
|
|
static bool do_fstored(DisasContext *ctx, unsigned rt, unsigned rb,
|
2023-10-18 07:11:19 +03:00
|
|
|
unsigned rx, int scale, int64_t disp,
|
2018-02-12 04:09:30 +03:00
|
|
|
unsigned sp, int modify)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
|
|
|
TCGv_i64 tmp;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
tmp = load_frd(rt);
|
2022-01-07 00:00:51 +03:00
|
|
|
do_store_64(ctx, tmp, rb, rx, scale, disp, sp, modify, MO_TEUQ);
|
2016-12-16 01:54:51 +03:00
|
|
|
|
2018-02-13 02:54:33 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fstd(DisasContext *ctx, arg_ldst *a)
|
|
|
|
{
|
|
|
|
return do_fstored(ctx, a->t, a->b, a->x, a->scale ? 3 : 0,
|
|
|
|
a->disp, a->sp, a->m);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool do_fop_wew(DisasContext *ctx, unsigned rt, unsigned ra,
|
2018-02-12 04:09:30 +03:00
|
|
|
void (*func)(TCGv_i32, TCGv_env, TCGv_i32))
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 tmp;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
tmp = load_frw0_i32(ra);
|
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
func(tmp, tcg_env, tmp);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
save_frw_i32(rt, tmp);
|
2018-02-13 10:01:47 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool do_fop_wed(DisasContext *ctx, unsigned rt, unsigned ra,
|
2018-02-12 04:09:30 +03:00
|
|
|
void (*func)(TCGv_i32, TCGv_env, TCGv_i64))
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 dst;
|
|
|
|
TCGv_i64 src;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
src = load_frd(ra);
|
|
|
|
dst = tcg_temp_new_i32();
|
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
func(dst, tcg_env, src);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
save_frw_i32(rt, dst);
|
2018-02-13 10:01:47 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool do_fop_ded(DisasContext *ctx, unsigned rt, unsigned ra,
|
2018-02-12 04:09:30 +03:00
|
|
|
void (*func)(TCGv_i64, TCGv_env, TCGv_i64))
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
|
|
|
TCGv_i64 tmp;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
tmp = load_frd0(ra);
|
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
func(tmp, tcg_env, tmp);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
save_frd(rt, tmp);
|
2018-02-13 10:01:47 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool do_fop_dew(DisasContext *ctx, unsigned rt, unsigned ra,
|
2018-02-12 04:09:30 +03:00
|
|
|
void (*func)(TCGv_i64, TCGv_env, TCGv_i32))
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 src;
|
|
|
|
TCGv_i64 dst;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
src = load_frw0_i32(ra);
|
|
|
|
dst = tcg_temp_new_i64();
|
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
func(dst, tcg_env, src);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
save_frd(rt, dst);
|
2018-02-13 10:01:47 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool do_fop_weww(DisasContext *ctx, unsigned rt,
|
2018-02-12 04:09:30 +03:00
|
|
|
unsigned ra, unsigned rb,
|
|
|
|
void (*func)(TCGv_i32, TCGv_env, TCGv_i32, TCGv_i32))
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 a, b;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
a = load_frw0_i32(ra);
|
|
|
|
b = load_frw0_i32(rb);
|
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
func(a, tcg_env, a, b);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
save_frw_i32(rt, a);
|
2018-02-13 10:01:47 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool do_fop_dedd(DisasContext *ctx, unsigned rt,
|
2018-02-12 04:09:30 +03:00
|
|
|
unsigned ra, unsigned rb,
|
|
|
|
void (*func)(TCGv_i64, TCGv_env, TCGv_i64, TCGv_i64))
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
|
|
|
TCGv_i64 a, b;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
a = load_frd0(ra);
|
|
|
|
b = load_frd0(rb);
|
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
func(a, tcg_env, a, b);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
save_frd(rt, a);
|
2018-02-13 10:01:47 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2016-12-16 00:50:28 +03:00
|
|
|
/* Emit an unconditional branch to a direct target, which may or may not
|
|
|
|
have already had nullification handled. */
|
2024-03-21 09:02:42 +03:00
|
|
|
static bool do_dbranch(DisasContext *ctx, int64_t disp,
|
2018-02-12 04:09:30 +03:00
|
|
|
unsigned link, bool is_n)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2024-03-22 02:56:44 +03:00
|
|
|
ctx->iaq_j = iaqe_branchi(ctx, disp);
|
2024-03-21 09:02:42 +03:00
|
|
|
|
2016-12-16 00:50:28 +03:00
|
|
|
if (ctx->null_cond.c == TCG_COND_NEVER && ctx->null_lab == NULL) {
|
2024-03-22 09:30:12 +03:00
|
|
|
install_link(ctx, link, false);
|
2016-12-16 00:50:28 +03:00
|
|
|
if (is_n) {
|
2024-04-13 23:07:06 +03:00
|
|
|
if (use_nullify_skip(ctx)) {
|
|
|
|
nullify_set(ctx, 0);
|
2024-03-22 02:56:44 +03:00
|
|
|
gen_goto_tb(ctx, 0, &ctx->iaq_j, NULL);
|
2024-04-13 23:07:06 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
return true;
|
|
|
|
}
|
2016-12-16 00:50:28 +03:00
|
|
|
ctx->null_cond.c = TCG_COND_ALWAYS;
|
|
|
|
}
|
2024-03-22 02:56:44 +03:00
|
|
|
ctx->iaq_n = &ctx->iaq_j;
|
2016-12-16 00:50:28 +03:00
|
|
|
} else {
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2024-03-22 09:30:12 +03:00
|
|
|
install_link(ctx, link, false);
|
2016-12-16 00:50:28 +03:00
|
|
|
if (is_n && use_nullify_skip(ctx)) {
|
|
|
|
nullify_set(ctx, 0);
|
2024-03-22 02:56:44 +03:00
|
|
|
gen_goto_tb(ctx, 0, &ctx->iaq_j, NULL);
|
2016-12-16 00:50:28 +03:00
|
|
|
} else {
|
|
|
|
nullify_set(ctx, is_n);
|
2024-03-22 02:56:44 +03:00
|
|
|
gen_goto_tb(ctx, 0, &ctx->iaq_b, &ctx->iaq_j);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
nullify_end(ctx);
|
2016-12-16 00:50:28 +03:00
|
|
|
|
|
|
|
nullify_set(ctx, 0);
|
2024-03-22 02:56:44 +03:00
|
|
|
gen_goto_tb(ctx, 1, &ctx->iaq_b, NULL);
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
2018-02-12 10:33:50 +03:00
|
|
|
return true;
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Emit a conditional branch to a direct target. If the branch itself
|
|
|
|
is nullified, we should have already used nullify_over. */
|
2023-10-18 07:11:19 +03:00
|
|
|
static bool do_cbranch(DisasContext *ctx, int64_t disp, bool is_n,
|
2018-02-12 04:09:30 +03:00
|
|
|
DisasCond *cond)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2024-03-22 02:56:44 +03:00
|
|
|
DisasIAQE next;
|
2016-12-16 00:50:28 +03:00
|
|
|
TCGLabel *taken = NULL;
|
|
|
|
TCGCond c = cond->c;
|
|
|
|
bool n;
|
|
|
|
|
|
|
|
assert(ctx->null_cond.c == TCG_COND_NEVER);
|
|
|
|
|
|
|
|
/* Handle TRUE and NEVER as direct branches. */
|
|
|
|
if (c == TCG_COND_ALWAYS) {
|
2024-03-21 09:02:42 +03:00
|
|
|
return do_dbranch(ctx, disp, 0, is_n && disp >= 0);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
taken = gen_new_label();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_brcond_i64(c, cond->a0, cond->a1, taken);
|
2016-12-16 00:50:28 +03:00
|
|
|
cond_free(cond);
|
|
|
|
|
|
|
|
/* Not taken: Condition not satisfied; nullify on backward branches. */
|
|
|
|
n = is_n && disp < 0;
|
|
|
|
if (n && use_nullify_skip(ctx)) {
|
|
|
|
nullify_set(ctx, 0);
|
2024-03-22 02:56:44 +03:00
|
|
|
next = iaqe_incr(&ctx->iaq_b, 4);
|
|
|
|
gen_goto_tb(ctx, 0, &next, NULL);
|
2016-12-16 00:50:28 +03:00
|
|
|
} else {
|
|
|
|
if (!n && ctx->null_lab) {
|
|
|
|
gen_set_label(ctx->null_lab);
|
|
|
|
ctx->null_lab = NULL;
|
|
|
|
}
|
|
|
|
nullify_set(ctx, n);
|
2024-03-22 02:56:44 +03:00
|
|
|
gen_goto_tb(ctx, 0, &ctx->iaq_b, NULL);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
gen_set_label(taken);
|
|
|
|
|
|
|
|
/* Taken: Condition satisfied; nullify on forward branches. */
|
|
|
|
n = is_n && disp >= 0;
|
2024-03-22 02:56:44 +03:00
|
|
|
|
|
|
|
next = iaqe_branchi(ctx, disp);
|
2016-12-16 00:50:28 +03:00
|
|
|
if (n && use_nullify_skip(ctx)) {
|
|
|
|
nullify_set(ctx, 0);
|
2024-03-22 02:56:44 +03:00
|
|
|
gen_goto_tb(ctx, 1, &next, NULL);
|
2016-12-16 00:50:28 +03:00
|
|
|
} else {
|
|
|
|
nullify_set(ctx, n);
|
2024-03-22 02:56:44 +03:00
|
|
|
gen_goto_tb(ctx, 1, &ctx->iaq_b, &next);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Not taken: the branch itself was nullified. */
|
|
|
|
if (ctx->null_lab) {
|
|
|
|
gen_set_label(ctx->null_lab);
|
|
|
|
ctx->null_lab = NULL;
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE;
|
2016-12-16 00:50:28 +03:00
|
|
|
} else {
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
2018-02-12 10:33:50 +03:00
|
|
|
return true;
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
/*
|
|
|
|
* Emit an unconditional branch to an indirect target, in ctx->iaq_j.
|
|
|
|
* This handles nullification of the branch itself.
|
|
|
|
*/
|
|
|
|
static bool do_ibranch(DisasContext *ctx, unsigned link,
|
|
|
|
bool with_sr0, bool is_n)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2024-03-22 03:33:28 +03:00
|
|
|
if (ctx->null_cond.c == TCG_COND_NEVER && ctx->null_lab == NULL) {
|
2024-03-23 10:29:47 +03:00
|
|
|
install_link(ctx, link, with_sr0);
|
2016-12-16 00:50:28 +03:00
|
|
|
if (is_n) {
|
2017-10-22 08:53:35 +03:00
|
|
|
if (use_nullify_skip(ctx)) {
|
2024-03-22 02:56:44 +03:00
|
|
|
install_iaq_entries(ctx, &ctx->iaq_j, NULL);
|
2017-10-22 08:53:35 +03:00
|
|
|
nullify_set(ctx, 0);
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_UPDATED;
|
2018-02-12 10:33:50 +03:00
|
|
|
return true;
|
2017-10-22 08:53:35 +03:00
|
|
|
}
|
2016-12-16 00:50:28 +03:00
|
|
|
ctx->null_cond.c = TCG_COND_ALWAYS;
|
|
|
|
}
|
2024-03-22 02:56:44 +03:00
|
|
|
ctx->iaq_n = &ctx->iaq_j;
|
2024-03-22 03:33:28 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2024-03-23 10:29:47 +03:00
|
|
|
install_link(ctx, link, with_sr0);
|
2024-03-22 03:33:28 +03:00
|
|
|
if (is_n && use_nullify_skip(ctx)) {
|
2024-03-22 02:56:44 +03:00
|
|
|
install_iaq_entries(ctx, &ctx->iaq_j, NULL);
|
2024-03-22 03:33:28 +03:00
|
|
|
nullify_set(ctx, 0);
|
2016-12-16 00:50:28 +03:00
|
|
|
} else {
|
2024-03-22 02:56:44 +03:00
|
|
|
install_iaq_entries(ctx, &ctx->iaq_b, &ctx->iaq_j);
|
2024-03-22 03:33:28 +03:00
|
|
|
nullify_set(ctx, is_n);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
2024-03-22 03:33:28 +03:00
|
|
|
|
|
|
|
tcg_gen_lookup_and_goto_ptr();
|
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
return nullify_end(ctx);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2017-10-09 21:25:12 +03:00
|
|
|
/* Implement
|
|
|
|
* if (IAOQ_Front{30..31} < GR[b]{30..31})
|
|
|
|
* IAOQ_Next{30..31} ← GR[b]{30..31};
|
|
|
|
* else
|
|
|
|
* IAOQ_Next{30..31} ← IAOQ_Front{30..31};
|
|
|
|
* which keeps the privilege level from being increased.
|
|
|
|
*/
|
2023-10-18 07:31:08 +03:00
|
|
|
static TCGv_i64 do_ibranch_priv(DisasContext *ctx, TCGv_i64 offset)
|
2017-10-09 21:25:12 +03:00
|
|
|
{
|
2024-03-28 01:50:07 +03:00
|
|
|
TCGv_i64 dest = tcg_temp_new_i64();
|
2017-10-09 21:25:12 +03:00
|
|
|
switch (ctx->privilege) {
|
|
|
|
case 0:
|
|
|
|
/* Privilege 0 is maximum and is allowed to decrease. */
|
2024-03-28 01:50:07 +03:00
|
|
|
tcg_gen_mov_i64(dest, offset);
|
|
|
|
break;
|
2017-10-09 21:25:12 +03:00
|
|
|
case 3:
|
2019-02-22 01:01:07 +03:00
|
|
|
/* Privilege 3 is minimum and is never allowed to increase. */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ori_i64(dest, offset, 3);
|
2017-10-09 21:25:12 +03:00
|
|
|
break;
|
|
|
|
default:
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(dest, offset, -4);
|
|
|
|
tcg_gen_ori_i64(dest, dest, ctx->privilege);
|
2024-03-28 01:53:06 +03:00
|
|
|
tcg_gen_umax_i64(dest, dest, offset);
|
2017-10-09 21:25:12 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
2017-10-09 19:51:30 +03:00
|
|
|
#ifdef CONFIG_USER_ONLY
|
2016-12-16 00:55:46 +03:00
|
|
|
/* On Linux, page zero is normally marked execute only + gateway.
|
|
|
|
Therefore normal read or write is supposed to fail, but specific
|
|
|
|
offsets have kernel code mapped to raise permissions to implement
|
|
|
|
system calls. Handling this via an explicit check here, rather
|
|
|
|
in than the "be disp(sr2,r0)" instruction that probably sent us
|
|
|
|
here, is the easiest way to handle the branch delay slot on the
|
|
|
|
aforementioned BE. */
|
2018-02-12 04:09:30 +03:00
|
|
|
static void do_page_zero(DisasContext *ctx)
|
2016-12-16 00:55:46 +03:00
|
|
|
{
|
2024-03-22 05:47:14 +03:00
|
|
|
assert(ctx->iaq_f.disp == 0);
|
|
|
|
|
2016-12-16 00:55:46 +03:00
|
|
|
/* If by some means we get here with PSW[N]=1, that implies that
|
|
|
|
the B,GATE instruction would be skipped, and we'd fault on the
|
2023-07-14 14:23:51 +03:00
|
|
|
next insn within the privileged page. */
|
2016-12-16 00:55:46 +03:00
|
|
|
switch (ctx->null_cond.c) {
|
|
|
|
case TCG_COND_NEVER:
|
|
|
|
break;
|
|
|
|
case TCG_COND_ALWAYS:
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(cpu_psw_n, 0);
|
2016-12-16 00:55:46 +03:00
|
|
|
goto do_sigill;
|
|
|
|
default:
|
|
|
|
/* Since this is always the first (and only) insn within the
|
|
|
|
TB, we should know the state of PSW[N] from TB->FLAGS. */
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that we didn't arrive here via some means that allowed
|
|
|
|
non-sequential instruction execution. Normally the PSW[B] bit
|
|
|
|
detects this by disallowing the B,GATE instruction to execute
|
|
|
|
under such conditions. */
|
2024-03-22 05:47:14 +03:00
|
|
|
if (iaqe_variable(&ctx->iaq_b) || ctx->iaq_b.disp != 4) {
|
2016-12-16 00:55:46 +03:00
|
|
|
goto do_sigill;
|
|
|
|
}
|
|
|
|
|
2024-03-22 05:47:14 +03:00
|
|
|
switch (ctx->base.pc_first) {
|
2016-12-16 00:55:46 +03:00
|
|
|
case 0x00: /* Null pointer call */
|
2017-10-11 20:03:02 +03:00
|
|
|
gen_excp_1(EXCP_IMP);
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
break;
|
2016-12-16 00:55:46 +03:00
|
|
|
|
|
|
|
case 0xb0: /* LWS */
|
|
|
|
gen_excp_1(EXCP_SYSCALL_LWS);
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
break;
|
2016-12-16 00:55:46 +03:00
|
|
|
|
|
|
|
case 0xe0: /* SET_THREAD_POINTER */
|
2024-03-22 02:56:44 +03:00
|
|
|
{
|
|
|
|
DisasIAQE next = { .base = tcg_temp_new_i64() };
|
|
|
|
|
|
|
|
tcg_gen_st_i64(cpu_gr[26], tcg_env,
|
|
|
|
offsetof(CPUHPPAState, cr[27]));
|
|
|
|
tcg_gen_ori_i64(next.base, cpu_gr[31], 3);
|
|
|
|
install_iaq_entries(ctx, &next, NULL);
|
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_UPDATED;
|
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
break;
|
2016-12-16 00:55:46 +03:00
|
|
|
|
|
|
|
case 0x100: /* SYSCALL */
|
|
|
|
gen_excp_1(EXCP_SYSCALL);
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
break;
|
2016-12-16 00:55:46 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
do_sigill:
|
2017-10-11 20:03:02 +03:00
|
|
|
gen_excp_1(EXCP_ILL);
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
break;
|
2016-12-16 00:55:46 +03:00
|
|
|
}
|
|
|
|
}
|
2017-10-09 19:51:30 +03:00
|
|
|
#endif
|
2016-12-16 00:55:46 +03:00
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
static bool trans_nop(DisasContext *ctx, arg_nop *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 04:14:10 +03:00
|
|
|
static bool trans_break(DisasContext *ctx, arg_break *a)
|
2016-12-16 01:59:03 +03:00
|
|
|
{
|
2018-02-12 04:09:30 +03:00
|
|
|
return gen_excp_iir(ctx, EXCP_BREAK);
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:45:01 +03:00
|
|
|
static bool trans_sync(DisasContext *ctx, arg_sync *a)
|
2016-12-16 01:59:03 +03:00
|
|
|
{
|
|
|
|
/* No point in nullifying the memory barrier. */
|
|
|
|
tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL);
|
|
|
|
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:22:38 +03:00
|
|
|
static bool trans_mfia(DisasContext *ctx, arg_mfia *a)
|
2016-12-16 01:59:03 +03:00
|
|
|
{
|
2024-03-22 02:56:44 +03:00
|
|
|
TCGv_i64 dest = dest_gpr(ctx, a->t);
|
2016-12-16 01:59:03 +03:00
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
copy_iaoq_entry(ctx, dest, &ctx->iaq_f);
|
|
|
|
tcg_gen_andi_i64(dest, dest, -4);
|
|
|
|
|
|
|
|
save_gpr(ctx, a->t, dest);
|
2016-12-16 01:59:03 +03:00
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:22:38 +03:00
|
|
|
static bool trans_mfsp(DisasContext *ctx, arg_mfsp *a)
|
2016-12-16 01:59:03 +03:00
|
|
|
{
|
2018-02-12 05:22:38 +03:00
|
|
|
unsigned rt = a->t;
|
|
|
|
unsigned rs = a->sp;
|
2017-10-10 08:54:12 +03:00
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
2016-12-16 01:59:03 +03:00
|
|
|
|
2017-10-10 08:54:12 +03:00
|
|
|
load_spr(ctx, t0, rs);
|
|
|
|
tcg_gen_shri_i64(t0, t0, 32);
|
|
|
|
|
2023-10-18 07:42:55 +03:00
|
|
|
save_gpr(ctx, rt, t0);
|
2016-12-16 01:59:03 +03:00
|
|
|
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:22:38 +03:00
|
|
|
static bool trans_mfctl(DisasContext *ctx, arg_mfctl *a)
|
2016-12-16 01:59:03 +03:00
|
|
|
{
|
2018-02-12 05:22:38 +03:00
|
|
|
unsigned rt = a->t;
|
|
|
|
unsigned ctl = a->r;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tmp;
|
2016-12-16 01:59:03 +03:00
|
|
|
|
|
|
|
switch (ctl) {
|
2017-10-11 07:19:34 +03:00
|
|
|
case CR_SAR:
|
2018-02-12 05:22:38 +03:00
|
|
|
if (a->e == 0) {
|
2016-12-16 01:59:03 +03:00
|
|
|
/* MFSAR without ,W masks low 5 bits. */
|
|
|
|
tmp = dest_gpr(ctx, rt);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(tmp, cpu_sar, 31);
|
2016-12-16 01:59:03 +03:00
|
|
|
save_gpr(ctx, rt, tmp);
|
2017-10-11 07:19:34 +03:00
|
|
|
goto done;
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
save_gpr(ctx, rt, cpu_sar);
|
2017-10-11 07:19:34 +03:00
|
|
|
goto done;
|
|
|
|
case CR_IT: /* Interval Timer */
|
|
|
|
/* FIXME: Respect PSW_S bit. */
|
|
|
|
nullify_over(ctx);
|
2016-12-16 01:59:03 +03:00
|
|
|
tmp = dest_gpr(ctx, rt);
|
2023-05-23 09:08:01 +03:00
|
|
|
if (translator_io_start(&ctx->base)) {
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE;
|
2017-12-29 04:50:14 +03:00
|
|
|
}
|
2024-03-23 03:22:51 +03:00
|
|
|
gen_helper_read_interval_timer(tmp);
|
2016-12-16 01:59:03 +03:00
|
|
|
save_gpr(ctx, rt, tmp);
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:59:03 +03:00
|
|
|
case 26:
|
|
|
|
case 27:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* All other control registers are privileged. */
|
2017-10-11 07:19:34 +03:00
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_REG);
|
|
|
|
break;
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, cr[ctl]));
|
2017-10-11 07:19:34 +03:00
|
|
|
save_gpr(ctx, rt, tmp);
|
|
|
|
|
|
|
|
done:
|
2016-12-16 01:59:03 +03:00
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:22:38 +03:00
|
|
|
static bool trans_mtsp(DisasContext *ctx, arg_mtsp *a)
|
2017-10-10 08:54:12 +03:00
|
|
|
{
|
2018-02-12 05:22:38 +03:00
|
|
|
unsigned rr = a->r;
|
|
|
|
unsigned rs = a->sp;
|
2023-10-18 07:42:55 +03:00
|
|
|
TCGv_i64 tmp;
|
2017-10-10 08:54:12 +03:00
|
|
|
|
|
|
|
if (rs >= 5) {
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_REG);
|
|
|
|
}
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2023-10-18 07:42:55 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
|
|
|
tcg_gen_shli_i64(tmp, load_gpr(ctx, rr), 32);
|
2017-10-10 08:54:12 +03:00
|
|
|
|
|
|
|
if (rs >= 4) {
|
2023-10-18 07:42:55 +03:00
|
|
|
tcg_gen_st_i64(tmp, tcg_env, offsetof(CPUHPPAState, sr[rs]));
|
2017-11-06 23:10:33 +03:00
|
|
|
ctx->tb_flags &= ~TB_FLAG_SR_SAME;
|
2017-10-10 08:54:12 +03:00
|
|
|
} else {
|
2023-10-18 07:42:55 +03:00
|
|
|
tcg_gen_mov_i64(cpu_sr[rs], tmp);
|
2017-10-10 08:54:12 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2017-10-10 08:54:12 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:22:38 +03:00
|
|
|
static bool trans_mtctl(DisasContext *ctx, arg_mtctl *a)
|
2016-12-16 01:59:03 +03:00
|
|
|
{
|
2018-02-12 05:22:38 +03:00
|
|
|
unsigned ctl = a->t;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 reg;
|
|
|
|
TCGv_i64 tmp;
|
2016-12-16 01:59:03 +03:00
|
|
|
|
2017-10-11 07:19:34 +03:00
|
|
|
if (ctl == CR_SAR) {
|
2019-09-13 13:17:13 +03:00
|
|
|
reg = load_gpr(ctx, a->r);
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(tmp, reg, ctx->is_pa20 ? 63 : 31);
|
2016-12-16 01:59:03 +03:00
|
|
|
save_or_nullify(ctx, cpu_sar, tmp);
|
2017-10-11 07:19:34 +03:00
|
|
|
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2017-10-11 07:19:34 +03:00
|
|
|
/* All other control registers are privileged or read-only. */
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_REG);
|
|
|
|
|
2018-02-12 05:22:38 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2017-10-11 07:19:34 +03:00
|
|
|
nullify_over(ctx);
|
2023-10-27 07:49:48 +03:00
|
|
|
|
|
|
|
if (ctx->is_pa20) {
|
|
|
|
reg = load_gpr(ctx, a->r);
|
|
|
|
} else {
|
|
|
|
reg = tcg_temp_new_i64();
|
|
|
|
tcg_gen_ext32u_i64(reg, load_gpr(ctx, a->r));
|
|
|
|
}
|
2019-09-13 13:17:13 +03:00
|
|
|
|
2017-10-11 07:19:34 +03:00
|
|
|
switch (ctl) {
|
|
|
|
case CR_IT:
|
2024-03-23 03:21:52 +03:00
|
|
|
if (translator_io_start(&ctx->base)) {
|
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE;
|
|
|
|
}
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_write_interval_timer(tcg_env, reg);
|
2017-10-11 07:19:34 +03:00
|
|
|
break;
|
2017-12-29 04:36:45 +03:00
|
|
|
case CR_EIRR:
|
2024-03-23 03:45:06 +03:00
|
|
|
/* Helper modifies interrupt lines and is therefore IO. */
|
|
|
|
translator_io_start(&ctx->base);
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_write_eirr(tcg_env, reg);
|
2024-03-23 03:45:06 +03:00
|
|
|
/* Exit to re-evaluate interrupts in the main loop. */
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE_EXIT;
|
2017-12-29 04:36:45 +03:00
|
|
|
break;
|
|
|
|
|
2017-10-11 07:19:34 +03:00
|
|
|
case CR_IIASQ:
|
|
|
|
case CR_IIAOQ:
|
|
|
|
/* FIXME: Respect PSW_Q bit */
|
|
|
|
/* The write advances the queue and stores to the back element. */
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ld_i64(tmp, tcg_env,
|
2017-10-11 07:19:34 +03:00
|
|
|
offsetof(CPUHPPAState, cr_back[ctl - CR_IIASQ]));
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_st_i64(tmp, tcg_env, offsetof(CPUHPPAState, cr[ctl]));
|
|
|
|
tcg_gen_st_i64(reg, tcg_env,
|
2017-10-11 07:19:34 +03:00
|
|
|
offsetof(CPUHPPAState, cr_back[ctl - CR_IIASQ]));
|
|
|
|
break;
|
|
|
|
|
2019-03-11 22:16:00 +03:00
|
|
|
case CR_PID1:
|
|
|
|
case CR_PID2:
|
|
|
|
case CR_PID3:
|
|
|
|
case CR_PID4:
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_st_i64(reg, tcg_env, offsetof(CPUHPPAState, cr[ctl]));
|
2019-03-11 22:16:00 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_change_prot_id(tcg_env);
|
2019-03-11 22:16:00 +03:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
2024-03-23 03:45:06 +03:00
|
|
|
case CR_EIEM:
|
|
|
|
/* Exit to re-evaluate interrupts in the main loop. */
|
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE_EXIT;
|
|
|
|
/* FALLTHRU */
|
2017-10-11 07:19:34 +03:00
|
|
|
default:
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_st_i64(reg, tcg_env, offsetof(CPUHPPAState, cr[ctl]));
|
2017-10-11 07:19:34 +03:00
|
|
|
break;
|
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2017-12-29 04:36:45 +03:00
|
|
|
#endif
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:22:38 +03:00
|
|
|
static bool trans_mtsarcm(DisasContext *ctx, arg_mtsarcm *a)
|
2016-12-16 01:59:03 +03:00
|
|
|
{
|
2023-10-18 07:47:02 +03:00
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
2016-12-16 01:59:03 +03:00
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_not_i64(tmp, load_gpr(ctx, a->r));
|
|
|
|
tcg_gen_andi_i64(tmp, tmp, ctx->is_pa20 ? 63 : 31);
|
2016-12-16 01:59:03 +03:00
|
|
|
save_or_nullify(ctx, cpu_sar, tmp);
|
|
|
|
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:45:01 +03:00
|
|
|
static bool trans_ldsid(DisasContext *ctx, arg_ldsid *a)
|
2016-12-16 01:59:03 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest = dest_gpr(ctx, a->t);
|
2016-12-16 01:59:03 +03:00
|
|
|
|
2018-01-02 23:31:45 +03:00
|
|
|
#ifdef CONFIG_USER_ONLY
|
|
|
|
/* We don't implement space registers in user mode. */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(dest, 0);
|
2018-01-02 23:31:45 +03:00
|
|
|
#else
|
2023-10-18 07:42:55 +03:00
|
|
|
tcg_gen_mov_i64(dest, space_select(ctx, a->sp, load_gpr(ctx, a->b)));
|
|
|
|
tcg_gen_shri_i64(dest, dest, 32);
|
2018-01-02 23:31:45 +03:00
|
|
|
#endif
|
2018-02-12 05:45:01 +03:00
|
|
|
save_gpr(ctx, a->t, dest);
|
2016-12-16 01:59:03 +03:00
|
|
|
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:45:01 +03:00
|
|
|
static bool trans_rsm(DisasContext *ctx, arg_rsm *a)
|
2017-10-09 17:44:30 +03:00
|
|
|
{
|
2024-02-07 02:49:28 +03:00
|
|
|
#ifdef CONFIG_USER_ONLY
|
2018-02-12 05:45:01 +03:00
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
2024-02-07 02:49:28 +03:00
|
|
|
#else
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tmp;
|
2017-10-09 17:44:30 +03:00
|
|
|
|
2024-02-07 02:49:28 +03:00
|
|
|
/* HP-UX 11i and HP ODE use rsm for read-access to PSW */
|
|
|
|
if (a->i) {
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
}
|
|
|
|
|
2017-10-09 17:44:30 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
|
|
|
|
tcg_gen_andi_i64(tmp, tmp, ~a->i);
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_swap_system_mask(tmp, tcg_env, tmp);
|
2018-02-12 05:45:01 +03:00
|
|
|
save_gpr(ctx, a->t, tmp);
|
2017-10-09 17:44:30 +03:00
|
|
|
|
|
|
|
/* Exit the TB to recognize new interrupts, e.g. PSW_M. */
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE_EXIT;
|
|
|
|
return nullify_end(ctx);
|
2018-02-12 05:45:01 +03:00
|
|
|
#endif
|
2017-10-09 17:44:30 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:45:01 +03:00
|
|
|
static bool trans_ssm(DisasContext *ctx, arg_ssm *a)
|
2017-10-09 17:44:30 +03:00
|
|
|
{
|
2018-02-12 05:45:01 +03:00
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tmp;
|
2017-10-09 17:44:30 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
|
|
|
|
tcg_gen_ori_i64(tmp, tmp, a->i);
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_swap_system_mask(tmp, tcg_env, tmp);
|
2018-02-12 05:45:01 +03:00
|
|
|
save_gpr(ctx, a->t, tmp);
|
2017-10-09 17:44:30 +03:00
|
|
|
|
|
|
|
/* Exit the TB to recognize new interrupts, e.g. PSW_I. */
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE_EXIT;
|
|
|
|
return nullify_end(ctx);
|
2018-02-12 05:45:01 +03:00
|
|
|
#endif
|
2017-10-09 17:44:30 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 05:22:38 +03:00
|
|
|
static bool trans_mtsm(DisasContext *ctx, arg_mtsm *a)
|
2017-10-09 17:44:30 +03:00
|
|
|
{
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
2018-02-12 05:22:38 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tmp, reg;
|
2017-10-09 17:44:30 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 05:22:38 +03:00
|
|
|
reg = load_gpr(ctx, a->r);
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_swap_system_mask(tmp, tcg_env, reg);
|
2017-10-09 17:44:30 +03:00
|
|
|
|
|
|
|
/* Exit the TB to recognize new interrupts. */
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE_EXIT;
|
|
|
|
return nullify_end(ctx);
|
2018-02-12 05:22:38 +03:00
|
|
|
#endif
|
2017-10-09 17:44:30 +03:00
|
|
|
}
|
2017-10-11 18:54:49 +03:00
|
|
|
|
2018-02-12 05:45:01 +03:00
|
|
|
static bool do_rfi(DisasContext *ctx, bool rfi_r)
|
2017-10-11 18:54:49 +03:00
|
|
|
{
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
2018-02-12 05:45:01 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2017-10-11 18:54:49 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 05:45:01 +03:00
|
|
|
if (rfi_r) {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_rfi_r(tcg_env);
|
2017-10-11 18:54:49 +03:00
|
|
|
} else {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_rfi(tcg_env);
|
2017-10-11 18:54:49 +03:00
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
/* Exit the TB to recognize new interrupts. */
|
2021-07-19 10:19:26 +03:00
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
2017-10-11 18:54:49 +03:00
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2018-02-12 05:45:01 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_rfi(DisasContext *ctx, arg_rfi *a)
|
|
|
|
{
|
|
|
|
return do_rfi(ctx, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_rfi_r(DisasContext *ctx, arg_rfi_r *a)
|
|
|
|
{
|
|
|
|
return do_rfi(ctx, true);
|
2017-10-11 18:54:49 +03:00
|
|
|
}
|
2017-12-29 09:04:57 +03:00
|
|
|
|
2018-02-13 06:46:08 +03:00
|
|
|
static bool trans_halt(DisasContext *ctx, arg_halt *a)
|
|
|
|
{
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
2018-02-12 05:45:01 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2018-02-13 06:46:08 +03:00
|
|
|
nullify_over(ctx);
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_halt(tcg_env);
|
2018-02-13 06:46:08 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
return nullify_end(ctx);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_reset(DisasContext *ctx, arg_reset *a)
|
2017-12-29 09:04:57 +03:00
|
|
|
{
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
2018-02-13 06:46:08 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2017-12-29 09:04:57 +03:00
|
|
|
nullify_over(ctx);
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_reset(tcg_env);
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
return nullify_end(ctx);
|
2018-02-13 06:46:08 +03:00
|
|
|
#endif
|
2017-12-29 09:04:57 +03:00
|
|
|
}
|
2017-10-09 17:44:30 +03:00
|
|
|
|
2024-03-26 19:53:35 +03:00
|
|
|
static bool do_getshadowregs(DisasContext *ctx)
|
2022-01-06 01:09:04 +03:00
|
|
|
{
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
nullify_over(ctx);
|
2024-03-26 19:53:35 +03:00
|
|
|
tcg_gen_ld_i64(cpu_gr[1], tcg_env, offsetof(CPUHPPAState, shadow[0]));
|
|
|
|
tcg_gen_ld_i64(cpu_gr[8], tcg_env, offsetof(CPUHPPAState, shadow[1]));
|
|
|
|
tcg_gen_ld_i64(cpu_gr[9], tcg_env, offsetof(CPUHPPAState, shadow[2]));
|
|
|
|
tcg_gen_ld_i64(cpu_gr[16], tcg_env, offsetof(CPUHPPAState, shadow[3]));
|
|
|
|
tcg_gen_ld_i64(cpu_gr[17], tcg_env, offsetof(CPUHPPAState, shadow[4]));
|
|
|
|
tcg_gen_ld_i64(cpu_gr[24], tcg_env, offsetof(CPUHPPAState, shadow[5]));
|
|
|
|
tcg_gen_ld_i64(cpu_gr[25], tcg_env, offsetof(CPUHPPAState, shadow[6]));
|
2022-01-06 01:09:04 +03:00
|
|
|
return nullify_end(ctx);
|
2024-03-26 19:53:35 +03:00
|
|
|
}
|
|
|
|
|
2024-03-26 20:39:40 +03:00
|
|
|
static bool do_putshadowregs(DisasContext *ctx)
|
|
|
|
{
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
nullify_over(ctx);
|
|
|
|
tcg_gen_st_i64(cpu_gr[1], tcg_env, offsetof(CPUHPPAState, shadow[0]));
|
|
|
|
tcg_gen_st_i64(cpu_gr[8], tcg_env, offsetof(CPUHPPAState, shadow[1]));
|
|
|
|
tcg_gen_st_i64(cpu_gr[9], tcg_env, offsetof(CPUHPPAState, shadow[2]));
|
|
|
|
tcg_gen_st_i64(cpu_gr[16], tcg_env, offsetof(CPUHPPAState, shadow[3]));
|
|
|
|
tcg_gen_st_i64(cpu_gr[17], tcg_env, offsetof(CPUHPPAState, shadow[4]));
|
|
|
|
tcg_gen_st_i64(cpu_gr[24], tcg_env, offsetof(CPUHPPAState, shadow[5]));
|
|
|
|
tcg_gen_st_i64(cpu_gr[25], tcg_env, offsetof(CPUHPPAState, shadow[6]));
|
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2024-03-26 19:53:35 +03:00
|
|
|
static bool trans_getshadowregs(DisasContext *ctx, arg_getshadowregs *a)
|
|
|
|
{
|
|
|
|
return do_getshadowregs(ctx);
|
2022-01-06 01:09:04 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
static bool trans_nop_addrx(DisasContext *ctx, arg_ldst *a)
|
2016-12-16 01:59:03 +03:00
|
|
|
{
|
2018-02-12 07:39:25 +03:00
|
|
|
if (a->m) {
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest = dest_gpr(ctx, a->b);
|
|
|
|
TCGv_i64 src1 = load_gpr(ctx, a->b);
|
|
|
|
TCGv_i64 src2 = load_gpr(ctx, a->x);
|
2016-12-16 01:59:03 +03:00
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
/* The only thing we need to do is the base register modification. */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_add_i64(dest, src1, src2);
|
2018-02-12 07:39:25 +03:00
|
|
|
save_gpr(ctx, a->b, dest);
|
|
|
|
}
|
2016-12-16 01:59:03 +03:00
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2024-03-19 19:19:19 +03:00
|
|
|
static bool trans_fic(DisasContext *ctx, arg_ldst *a)
|
|
|
|
{
|
|
|
|
/* End TB for flush instruction cache, so we pick up new insns. */
|
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE;
|
|
|
|
return trans_nop_addrx(ctx, a);
|
|
|
|
}
|
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
static bool trans_probe(DisasContext *ctx, arg_probe *a)
|
2016-12-16 01:59:03 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest, ofs;
|
2018-01-25 02:03:25 +03:00
|
|
|
TCGv_i32 level, want;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 addr;
|
2016-12-16 01:59:03 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
dest = dest_gpr(ctx, a->t);
|
|
|
|
form_gva(ctx, &addr, &ofs, a->b, 0, 0, 0, a->sp, 0, false);
|
2018-01-25 02:03:25 +03:00
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
if (a->imm) {
|
2023-11-08 00:31:20 +03:00
|
|
|
level = tcg_constant_i32(a->ri & 3);
|
2016-12-16 01:59:03 +03:00
|
|
|
} else {
|
2018-01-25 02:03:25 +03:00
|
|
|
level = tcg_temp_new_i32();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_extrl_i64_i32(level, load_gpr(ctx, a->ri));
|
2018-01-25 02:03:25 +03:00
|
|
|
tcg_gen_andi_i32(level, level, 3);
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
2021-07-08 22:41:29 +03:00
|
|
|
want = tcg_constant_i32(a->write ? PAGE_WRITE : PAGE_READ);
|
2018-01-25 02:03:25 +03:00
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_probe(dest, tcg_env, addr, level, want);
|
2018-01-25 02:03:25 +03:00
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
save_gpr(ctx, a->t, dest);
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:59:03 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
static bool trans_ixtlbx(DisasContext *ctx, arg_ixtlbx *a)
|
2017-10-27 17:26:36 +03:00
|
|
|
{
|
2023-10-13 03:55:12 +03:00
|
|
|
if (ctx->is_pa20) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-12 07:39:25 +03:00
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 addr;
|
|
|
|
TCGv_i64 ofs, reg;
|
2017-10-27 17:26:36 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
form_gva(ctx, &addr, &ofs, a->b, 0, 0, 0, a->sp, 0, false);
|
|
|
|
reg = load_gpr(ctx, a->r);
|
|
|
|
if (a->addr) {
|
2023-10-13 03:55:12 +03:00
|
|
|
gen_helper_itlba_pa11(tcg_env, addr, reg);
|
2017-10-27 17:26:36 +03:00
|
|
|
} else {
|
2023-10-13 03:55:12 +03:00
|
|
|
gen_helper_itlbp_pa11(tcg_env, addr, reg);
|
2017-10-27 17:26:36 +03:00
|
|
|
}
|
|
|
|
|
2019-03-11 22:16:01 +03:00
|
|
|
/* Exit TB for TLB change if mmu is enabled. */
|
|
|
|
if (ctx->tb_flags & PSW_C) {
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE;
|
|
|
|
}
|
|
|
|
return nullify_end(ctx);
|
2018-02-12 07:39:25 +03:00
|
|
|
#endif
|
2017-10-27 17:26:36 +03:00
|
|
|
}
|
2017-10-27 19:33:23 +03:00
|
|
|
|
2023-10-27 07:41:41 +03:00
|
|
|
static bool do_pxtlb(DisasContext *ctx, arg_ldst *a, bool local)
|
2017-10-27 19:33:23 +03:00
|
|
|
{
|
2018-02-12 07:39:25 +03:00
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 addr;
|
|
|
|
TCGv_i64 ofs;
|
2017-10-27 19:33:23 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
form_gva(ctx, &addr, &ofs, a->b, a->x, 0, 0, a->sp, a->m, false);
|
2023-10-27 07:41:41 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Page align now, rather than later, so that we can add in the
|
|
|
|
* page_size field from pa2.0 from the low 4 bits of GR[b].
|
|
|
|
*/
|
|
|
|
tcg_gen_andi_i64(addr, addr, TARGET_PAGE_MASK);
|
|
|
|
if (ctx->is_pa20) {
|
|
|
|
tcg_gen_deposit_i64(addr, addr, load_gpr(ctx, a->b), 0, 4);
|
2017-10-27 19:33:23 +03:00
|
|
|
}
|
2023-10-27 07:41:41 +03:00
|
|
|
|
|
|
|
if (local) {
|
|
|
|
gen_helper_ptlb_l(tcg_env, addr);
|
2017-10-27 19:33:23 +03:00
|
|
|
} else {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_ptlb(tcg_env, addr);
|
2017-10-27 19:33:23 +03:00
|
|
|
}
|
|
|
|
|
2023-10-27 07:41:41 +03:00
|
|
|
if (a->m) {
|
|
|
|
save_gpr(ctx, a->b, ofs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Exit TB for TLB change if mmu is enabled. */
|
|
|
|
if (ctx->tb_flags & PSW_C) {
|
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE;
|
|
|
|
}
|
|
|
|
return nullify_end(ctx);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_pxtlb(DisasContext *ctx, arg_ldst *a)
|
|
|
|
{
|
|
|
|
return do_pxtlb(ctx, a, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_pxtlb_l(DisasContext *ctx, arg_ldst *a)
|
|
|
|
{
|
|
|
|
return ctx->is_pa20 && do_pxtlb(ctx, a, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_pxtlbe(DisasContext *ctx, arg_ldst *a)
|
|
|
|
{
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
trans_nop_addrx(ctx, a);
|
|
|
|
gen_helper_ptlbe(tcg_env);
|
|
|
|
|
2017-10-27 19:33:23 +03:00
|
|
|
/* Exit TB for TLB change if mmu is enabled. */
|
2019-04-23 09:36:20 +03:00
|
|
|
if (ctx->tb_flags & PSW_C) {
|
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE;
|
|
|
|
}
|
|
|
|
return nullify_end(ctx);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Implement the pcxl and pcxl2 Fast TLB Insert instructions.
|
|
|
|
* See
|
|
|
|
* https://parisc.wiki.kernel.org/images-parisc/a/a9/Pcxl2_ers.pdf
|
|
|
|
* page 13-9 (195/206)
|
|
|
|
*/
|
|
|
|
static bool trans_ixtlbxf(DisasContext *ctx, arg_ixtlbxf *a)
|
|
|
|
{
|
2023-10-13 03:55:12 +03:00
|
|
|
if (ctx->is_pa20) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-04-23 09:36:20 +03:00
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 addr, atl, stl;
|
|
|
|
TCGv_i64 reg;
|
2019-04-23 09:36:20 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME:
|
|
|
|
* if (not (pcxl or pcxl2))
|
|
|
|
* return gen_illegal(ctx);
|
|
|
|
*/
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
atl = tcg_temp_new_i64();
|
|
|
|
stl = tcg_temp_new_i64();
|
|
|
|
addr = tcg_temp_new_i64();
|
2019-04-23 09:36:20 +03:00
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_gen_ld32u_i64(stl, tcg_env,
|
2019-04-23 09:36:20 +03:00
|
|
|
a->data ? offsetof(CPUHPPAState, cr[CR_ISR])
|
|
|
|
: offsetof(CPUHPPAState, cr[CR_IIASQ]));
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_gen_ld32u_i64(atl, tcg_env,
|
2019-04-23 09:36:20 +03:00
|
|
|
a->data ? offsetof(CPUHPPAState, cr[CR_IOR])
|
|
|
|
: offsetof(CPUHPPAState, cr[CR_IIAOQ]));
|
|
|
|
tcg_gen_shli_i64(stl, stl, 32);
|
2023-10-18 07:49:54 +03:00
|
|
|
tcg_gen_or_i64(addr, atl, stl);
|
2019-04-23 09:36:20 +03:00
|
|
|
|
|
|
|
reg = load_gpr(ctx, a->r);
|
|
|
|
if (a->addr) {
|
2023-10-13 03:55:12 +03:00
|
|
|
gen_helper_itlba_pa11(tcg_env, addr, reg);
|
2019-04-23 09:36:20 +03:00
|
|
|
} else {
|
2023-10-13 03:55:12 +03:00
|
|
|
gen_helper_itlbp_pa11(tcg_env, addr, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Exit TB for TLB change if mmu is enabled. */
|
|
|
|
if (ctx->tb_flags & PSW_C) {
|
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE;
|
2019-04-23 09:36:20 +03:00
|
|
|
}
|
2023-10-13 03:55:12 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
#endif
|
|
|
|
}
|
2019-04-23 09:36:20 +03:00
|
|
|
|
2023-10-13 03:55:12 +03:00
|
|
|
static bool trans_ixtlbt(DisasContext *ctx, arg_ixtlbt *a)
|
|
|
|
{
|
|
|
|
if (!ctx->is_pa20) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
nullify_over(ctx);
|
|
|
|
{
|
|
|
|
TCGv_i64 src1 = load_gpr(ctx, a->r1);
|
|
|
|
TCGv_i64 src2 = load_gpr(ctx, a->r2);
|
|
|
|
|
|
|
|
if (a->data) {
|
|
|
|
gen_helper_idtlbt_pa20(tcg_env, src1, src2);
|
|
|
|
} else {
|
|
|
|
gen_helper_iitlbt_pa20(tcg_env, src1, src2);
|
|
|
|
}
|
|
|
|
}
|
2019-04-23 09:36:20 +03:00
|
|
|
/* Exit TB for TLB change if mmu is enabled. */
|
2019-03-11 22:16:01 +03:00
|
|
|
if (ctx->tb_flags & PSW_C) {
|
2018-02-12 04:09:30 +03:00
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE;
|
|
|
|
}
|
|
|
|
return nullify_end(ctx);
|
2018-02-12 07:39:25 +03:00
|
|
|
#endif
|
2017-10-27 19:33:23 +03:00
|
|
|
}
|
2017-11-05 12:50:47 +03:00
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
static bool trans_lpa(DisasContext *ctx, arg_ldst *a)
|
2017-11-05 12:50:47 +03:00
|
|
|
{
|
2018-02-12 07:39:25 +03:00
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 vaddr;
|
|
|
|
TCGv_i64 ofs, paddr;
|
2017-11-05 12:50:47 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
form_gva(ctx, &vaddr, &ofs, a->b, a->x, 0, 0, a->sp, a->m, false);
|
2017-11-05 12:50:47 +03:00
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
paddr = tcg_temp_new_i64();
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_lpa(paddr, tcg_env, vaddr);
|
2017-11-05 12:50:47 +03:00
|
|
|
|
|
|
|
/* Note that physical address result overrides base modification. */
|
2018-02-12 07:39:25 +03:00
|
|
|
if (a->m) {
|
|
|
|
save_gpr(ctx, a->b, ofs);
|
2017-11-05 12:50:47 +03:00
|
|
|
}
|
2018-02-12 07:39:25 +03:00
|
|
|
save_gpr(ctx, a->t, paddr);
|
2017-11-05 12:50:47 +03:00
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2018-02-12 07:39:25 +03:00
|
|
|
#endif
|
2017-11-05 12:50:47 +03:00
|
|
|
}
|
2017-11-05 13:02:40 +03:00
|
|
|
|
2018-02-12 07:39:25 +03:00
|
|
|
static bool trans_lci(DisasContext *ctx, arg_lci *a)
|
2017-11-05 13:02:40 +03:00
|
|
|
{
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
|
|
|
|
/* The Coherence Index is an implementation-defined function of the
|
|
|
|
physical address. Two addresses with the same CI have a coherent
|
|
|
|
view of the cache. Our implementation is to return 0 for all,
|
|
|
|
since the entire address space is coherent. */
|
2023-10-18 20:24:33 +03:00
|
|
|
save_gpr(ctx, a->t, ctx->zero);
|
2017-11-05 13:02:40 +03:00
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
return true;
|
2017-11-05 13:02:40 +03:00
|
|
|
}
|
2016-12-16 01:59:03 +03:00
|
|
|
|
2023-09-17 06:51:13 +03:00
|
|
|
static bool trans_add(DisasContext *ctx, arg_rrr_cf_d_sh *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2018-02-12 08:44:41 +03:00
|
|
|
return do_add_reg(ctx, a, false, false, false, false);
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-09-17 06:51:13 +03:00
|
|
|
static bool trans_add_l(DisasContext *ctx, arg_rrr_cf_d_sh *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_add_reg(ctx, a, true, false, false, false);
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-09-17 06:51:13 +03:00
|
|
|
static bool trans_add_tsv(DisasContext *ctx, arg_rrr_cf_d_sh *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_add_reg(ctx, a, false, true, false, false);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 06:51:13 +03:00
|
|
|
static bool trans_add_c(DisasContext *ctx, arg_rrr_cf_d_sh *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2018-02-12 08:44:41 +03:00
|
|
|
return do_add_reg(ctx, a, false, false, false, true);
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-09-17 06:51:13 +03:00
|
|
|
static bool trans_add_c_tsv(DisasContext *ctx, arg_rrr_cf_d_sh *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_add_reg(ctx, a, false, true, false, true);
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-09-17 07:25:44 +03:00
|
|
|
static bool trans_sub(DisasContext *ctx, arg_rrr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_sub_reg(ctx, a, false, false, false);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 07:25:44 +03:00
|
|
|
static bool trans_sub_tsv(DisasContext *ctx, arg_rrr_cf_d *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2018-02-12 08:44:41 +03:00
|
|
|
return do_sub_reg(ctx, a, true, false, false);
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-09-17 07:25:44 +03:00
|
|
|
static bool trans_sub_tc(DisasContext *ctx, arg_rrr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_sub_reg(ctx, a, false, false, true);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 07:25:44 +03:00
|
|
|
static bool trans_sub_tsv_tc(DisasContext *ctx, arg_rrr_cf_d *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2018-02-12 08:44:41 +03:00
|
|
|
return do_sub_reg(ctx, a, true, false, true);
|
|
|
|
}
|
|
|
|
|
2023-09-17 07:25:44 +03:00
|
|
|
static bool trans_sub_b(DisasContext *ctx, arg_rrr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_sub_reg(ctx, a, false, true, false);
|
|
|
|
}
|
|
|
|
|
2023-09-17 07:25:44 +03:00
|
|
|
static bool trans_sub_b_tsv(DisasContext *ctx, arg_rrr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_sub_reg(ctx, a, true, true, false);
|
|
|
|
}
|
|
|
|
|
2023-09-17 06:21:14 +03:00
|
|
|
static bool trans_andcm(DisasContext *ctx, arg_rrr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
return do_log_reg(ctx, a, tcg_gen_andc_i64);
|
2018-02-12 08:44:41 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 06:21:14 +03:00
|
|
|
static bool trans_and(DisasContext *ctx, arg_rrr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
return do_log_reg(ctx, a, tcg_gen_and_i64);
|
2018-02-12 08:44:41 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 06:21:14 +03:00
|
|
|
static bool trans_or(DisasContext *ctx, arg_rrr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
if (a->cf == 0) {
|
|
|
|
unsigned r2 = a->r2;
|
|
|
|
unsigned r1 = a->r1;
|
|
|
|
unsigned rt = a->t;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2018-02-12 06:02:24 +03:00
|
|
|
if (rt == 0) { /* NOP */
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (r2 == 0) { /* COPY */
|
|
|
|
if (r1 == 0) {
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest = dest_gpr(ctx, rt);
|
|
|
|
tcg_gen_movi_i64(dest, 0);
|
2018-02-12 06:02:24 +03:00
|
|
|
save_gpr(ctx, rt, dest);
|
|
|
|
} else {
|
|
|
|
save_gpr(ctx, rt, cpu_gr[r1]);
|
|
|
|
}
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
/* These are QEMU extensions and are nops in the real architecture:
|
|
|
|
*
|
|
|
|
* or %r10,%r10,%r10 -- idle loop; wait for interrupt
|
|
|
|
* or %r31,%r31,%r31 -- death loop; offline cpu
|
|
|
|
* currently implemented as idle.
|
|
|
|
*/
|
|
|
|
if ((rt == 10 || rt == 31) && r1 == rt && r2 == rt) { /* PAUSE */
|
|
|
|
/* No need to check for supervisor, as userland can only pause
|
|
|
|
until the next timer interrupt. */
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
/* Advance the instruction queue. */
|
2024-03-22 02:56:44 +03:00
|
|
|
install_iaq_entries(ctx, &ctx->iaq_b, NULL);
|
2018-02-12 06:02:24 +03:00
|
|
|
nullify_set(ctx, 0);
|
|
|
|
|
|
|
|
/* Tell the qemu main loop to halt until this cpu has work. */
|
2023-09-14 02:37:36 +03:00
|
|
|
tcg_gen_st_i32(tcg_constant_i32(1), tcg_env,
|
2021-07-08 22:41:29 +03:00
|
|
|
offsetof(CPUState, halted) - offsetof(HPPACPU, env));
|
2018-02-12 06:02:24 +03:00
|
|
|
gen_excp_1(EXCP_HALTED);
|
|
|
|
ctx->base.is_jmp = DISAS_NORETURN;
|
|
|
|
|
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
#endif
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
2023-10-18 07:31:08 +03:00
|
|
|
return do_log_reg(ctx, a, tcg_gen_or_i64);
|
2018-02-12 08:44:41 +03:00
|
|
|
}
|
2018-02-12 06:02:24 +03:00
|
|
|
|
2023-09-17 06:21:14 +03:00
|
|
|
static bool trans_xor(DisasContext *ctx, arg_rrr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
return do_log_reg(ctx, a, tcg_gen_xor_i64);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 06:40:23 +03:00
|
|
|
static bool trans_cmpclr(DisasContext *ctx, arg_rrr_cf_d *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_r1, tcg_r2;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2018-02-12 08:44:41 +03:00
|
|
|
if (a->cf) {
|
2016-12-16 00:37:23 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
2018-02-12 08:44:41 +03:00
|
|
|
tcg_r1 = load_gpr(ctx, a->r1);
|
|
|
|
tcg_r2 = load_gpr(ctx, a->r2);
|
2023-09-17 06:40:23 +03:00
|
|
|
do_cmpclr(ctx, a->t, tcg_r1, tcg_r2, a->cf, a->d);
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 06:32:37 +03:00
|
|
|
static bool trans_uxor(DisasContext *ctx, arg_rrr_cf_d *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2024-03-25 04:59:37 +03:00
|
|
|
TCGv_i64 tcg_r1, tcg_r2, dest;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2018-02-12 08:44:41 +03:00
|
|
|
if (a->cf) {
|
2016-12-16 00:37:23 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
2024-03-25 04:59:37 +03:00
|
|
|
|
2018-02-12 08:44:41 +03:00
|
|
|
tcg_r1 = load_gpr(ctx, a->r1);
|
|
|
|
tcg_r2 = load_gpr(ctx, a->r2);
|
2024-03-25 04:59:37 +03:00
|
|
|
dest = dest_gpr(ctx, a->t);
|
|
|
|
|
|
|
|
tcg_gen_xor_i64(dest, tcg_r1, tcg_r2);
|
|
|
|
save_gpr(ctx, a->t, dest);
|
|
|
|
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
if (a->cf) {
|
|
|
|
ctx->null_cond = do_unit_zero_cond(a->cf, a->d, dest);
|
|
|
|
}
|
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 06:32:37 +03:00
|
|
|
static bool do_uaddcm(DisasContext *ctx, arg_rrr_cf_d *a, bool is_tc)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_r1, tcg_r2, tmp;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2024-03-25 05:26:41 +03:00
|
|
|
if (a->cf == 0) {
|
|
|
|
tcg_r2 = load_gpr(ctx, a->r2);
|
|
|
|
tmp = dest_gpr(ctx, a->t);
|
|
|
|
|
|
|
|
if (a->r1 == 0) {
|
|
|
|
/* UADDCM r0,src,dst is the common idiom for dst = ~src. */
|
|
|
|
tcg_gen_not_i64(tmp, tcg_r2);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Recall that r1 - r2 == r1 + ~r2 + 1.
|
|
|
|
* Thus r1 + ~r2 == r1 - r2 - 1,
|
|
|
|
* which does not require an extra temporary.
|
|
|
|
*/
|
|
|
|
tcg_r1 = load_gpr(ctx, a->r1);
|
|
|
|
tcg_gen_sub_i64(tmp, tcg_r1, tcg_r2);
|
|
|
|
tcg_gen_subi_i64(tmp, tmp, 1);
|
|
|
|
}
|
|
|
|
save_gpr(ctx, a->t, tmp);
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
return true;
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
2024-03-25 05:26:41 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
2018-02-12 08:44:41 +03:00
|
|
|
tcg_r1 = load_gpr(ctx, a->r1);
|
|
|
|
tcg_r2 = load_gpr(ctx, a->r2);
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_not_i64(tmp, tcg_r2);
|
2024-03-25 04:59:37 +03:00
|
|
|
do_unit_addsub(ctx, a->t, tcg_r1, tmp, a->cf, a->d, is_tc, true);
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 06:32:37 +03:00
|
|
|
static bool trans_uaddcm(DisasContext *ctx, arg_rrr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_uaddcm(ctx, a, false);
|
|
|
|
}
|
|
|
|
|
2023-09-17 06:32:37 +03:00
|
|
|
static bool trans_uaddcm_tc(DisasContext *ctx, arg_rrr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_uaddcm(ctx, a, true);
|
|
|
|
}
|
|
|
|
|
2023-09-17 06:32:37 +03:00
|
|
|
static bool do_dcor(DisasContext *ctx, arg_rr_cf_d *a, bool is_i)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tmp;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2024-03-25 03:03:05 +03:00
|
|
|
tcg_gen_extract2_i64(tmp, cpu_psw_cb, cpu_psw_cb_msb, 4);
|
2016-12-16 00:37:23 +03:00
|
|
|
if (!is_i) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_not_i64(tmp, tmp);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(tmp, tmp, (uint64_t)0x1111111111111111ull);
|
|
|
|
tcg_gen_muli_i64(tmp, tmp, 6);
|
2024-03-25 04:59:37 +03:00
|
|
|
do_unit_addsub(ctx, a->t, load_gpr(ctx, a->r), tmp,
|
|
|
|
a->cf, a->d, false, is_i);
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 06:32:37 +03:00
|
|
|
static bool trans_dcor(DisasContext *ctx, arg_rr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_dcor(ctx, a, false);
|
|
|
|
}
|
|
|
|
|
2023-09-17 06:32:37 +03:00
|
|
|
static bool trans_dcor_i(DisasContext *ctx, arg_rr_cf_d *a)
|
2018-02-12 08:44:41 +03:00
|
|
|
{
|
|
|
|
return do_dcor(ctx, a, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_ds(DisasContext *ctx, arg_rrr_cf *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 20:24:33 +03:00
|
|
|
TCGv_i64 dest, add1, add2, addc, in1, in2;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 08:44:41 +03:00
|
|
|
in1 = load_gpr(ctx, a->r1);
|
|
|
|
in2 = load_gpr(ctx, a->r2);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
add1 = tcg_temp_new_i64();
|
|
|
|
add2 = tcg_temp_new_i64();
|
|
|
|
addc = tcg_temp_new_i64();
|
|
|
|
dest = tcg_temp_new_i64();
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
/* Form R1 << 1 | PSW[CB]{8}. */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_add_i64(add1, in1, in1);
|
|
|
|
tcg_gen_add_i64(add1, add1, get_psw_carry(ctx, false));
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-09-17 02:28:23 +03:00
|
|
|
/*
|
|
|
|
* Add or subtract R2, depending on PSW[V]. Proper computation of
|
|
|
|
* carry requires that we subtract via + ~R2 + 1, as described in
|
|
|
|
* the manual. By extracting and masking V, we can produce the
|
|
|
|
* proper inputs to the addition without movcond.
|
|
|
|
*/
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_sextract_i64(addc, cpu_psw_v, 31, 1);
|
|
|
|
tcg_gen_xor_i64(add2, in2, addc);
|
|
|
|
tcg_gen_andi_i64(addc, addc, 1);
|
2023-09-17 02:28:23 +03:00
|
|
|
|
2023-10-18 20:24:33 +03:00
|
|
|
tcg_gen_add2_i64(dest, cpu_psw_cb_msb, add1, ctx->zero, add2, ctx->zero);
|
|
|
|
tcg_gen_add2_i64(dest, cpu_psw_cb_msb, dest, cpu_psw_cb_msb,
|
|
|
|
addc, ctx->zero);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
/* Write back the result register. */
|
2018-02-12 08:44:41 +03:00
|
|
|
save_gpr(ctx, a->t, dest);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
/* Write back PSW[CB]. */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_xor_i64(cpu_psw_cb, add1, add2);
|
|
|
|
tcg_gen_xor_i64(cpu_psw_cb, cpu_psw_cb, dest);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2024-03-26 09:33:16 +03:00
|
|
|
/*
|
|
|
|
* Write back PSW[V] for the division step.
|
|
|
|
* Shift cb{8} from where it lives in bit 32 to bit 31,
|
|
|
|
* so that it overlaps r2{32} in bit 31.
|
|
|
|
*/
|
|
|
|
tcg_gen_shri_i64(cpu_psw_v, cpu_psw_cb, 1);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_xor_i64(cpu_psw_v, cpu_psw_v, in2);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
/* Install the new nullification. */
|
2018-02-12 08:44:41 +03:00
|
|
|
if (a->cf) {
|
2024-03-26 09:33:16 +03:00
|
|
|
TCGv_i64 sv = NULL, uv = NULL;
|
2019-02-12 04:12:54 +03:00
|
|
|
if (cond_need_sv(a->cf >> 1)) {
|
2024-03-26 09:33:16 +03:00
|
|
|
sv = do_add_sv(ctx, dest, add1, add2, in1, 1, false);
|
|
|
|
} else if (cond_need_cb(a->cf >> 1)) {
|
|
|
|
uv = do_add_uv(ctx, cpu_psw_cb, NULL, in1, 1, false);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
2024-03-26 09:33:16 +03:00
|
|
|
ctx->null_cond = do_cond(ctx, a->cf, false, dest, uv, sv);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool trans_addi(DisasContext *ctx, arg_rri_cf *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2018-02-13 02:34:12 +03:00
|
|
|
return do_add_imm(ctx, a, false, false);
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool trans_addi_tsv(DisasContext *ctx, arg_rri_cf *a)
|
|
|
|
{
|
|
|
|
return do_add_imm(ctx, a, true, false);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool trans_addi_tc(DisasContext *ctx, arg_rri_cf *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2018-02-13 02:34:12 +03:00
|
|
|
return do_add_imm(ctx, a, false, true);
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool trans_addi_tc_tsv(DisasContext *ctx, arg_rri_cf *a)
|
|
|
|
{
|
|
|
|
return do_add_imm(ctx, a, true, true);
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool trans_subi(DisasContext *ctx, arg_rri_cf *a)
|
|
|
|
{
|
|
|
|
return do_sub_imm(ctx, a, false);
|
|
|
|
}
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool trans_subi_tsv(DisasContext *ctx, arg_rri_cf *a)
|
|
|
|
{
|
|
|
|
return do_sub_imm(ctx, a, true);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 06:40:23 +03:00
|
|
|
static bool trans_cmpiclr(DisasContext *ctx, arg_rri_cf_d *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_im, tcg_r2;
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
if (a->cf) {
|
2016-12-16 00:37:23 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_im = tcg_constant_i64(a->i);
|
2018-02-13 02:34:12 +03:00
|
|
|
tcg_r2 = load_gpr(ctx, a->r);
|
2023-09-17 06:40:23 +03:00
|
|
|
do_cmpclr(ctx, a->t, tcg_im, tcg_r2, a->cf, a->d);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:50:01 +03:00
|
|
|
static bool do_multimedia(DisasContext *ctx, arg_rrr *a,
|
|
|
|
void (*fn)(TCGv_i64, TCGv_i64, TCGv_i64))
|
|
|
|
{
|
|
|
|
TCGv_i64 r1, r2, dest;
|
|
|
|
|
|
|
|
if (!ctx->is_pa20) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
r1 = load_gpr(ctx, a->r1);
|
|
|
|
r2 = load_gpr(ctx, a->r2);
|
|
|
|
dest = dest_gpr(ctx, a->t);
|
|
|
|
|
|
|
|
fn(dest, r1, r2);
|
|
|
|
save_gpr(ctx, a->t, dest);
|
|
|
|
|
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2023-09-21 09:56:04 +03:00
|
|
|
static bool do_multimedia_sh(DisasContext *ctx, arg_rri *a,
|
|
|
|
void (*fn)(TCGv_i64, TCGv_i64, int64_t))
|
|
|
|
{
|
|
|
|
TCGv_i64 r, dest;
|
|
|
|
|
|
|
|
if (!ctx->is_pa20) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
r = load_gpr(ctx, a->r);
|
|
|
|
dest = dest_gpr(ctx, a->t);
|
|
|
|
|
|
|
|
fn(dest, r, a->i);
|
|
|
|
save_gpr(ctx, a->t, dest);
|
|
|
|
|
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2023-09-21 10:15:25 +03:00
|
|
|
static bool do_multimedia_shadd(DisasContext *ctx, arg_rrr_sh *a,
|
|
|
|
void (*fn)(TCGv_i64, TCGv_i64,
|
|
|
|
TCGv_i64, TCGv_i32))
|
|
|
|
{
|
|
|
|
TCGv_i64 r1, r2, dest;
|
|
|
|
|
|
|
|
if (!ctx->is_pa20) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
r1 = load_gpr(ctx, a->r1);
|
|
|
|
r2 = load_gpr(ctx, a->r2);
|
|
|
|
dest = dest_gpr(ctx, a->t);
|
|
|
|
|
|
|
|
fn(dest, r1, r2, tcg_constant_i32(a->sh));
|
|
|
|
save_gpr(ctx, a->t, dest);
|
|
|
|
|
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2023-09-20 14:50:01 +03:00
|
|
|
static bool trans_hadd(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, tcg_gen_vec_add16_i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hadd_ss(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, gen_helper_hadd_ss);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hadd_us(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, gen_helper_hadd_us);
|
|
|
|
}
|
|
|
|
|
2023-09-20 18:11:06 +03:00
|
|
|
static bool trans_havg(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, gen_helper_havg);
|
|
|
|
}
|
|
|
|
|
2023-09-21 09:56:04 +03:00
|
|
|
static bool trans_hshl(DisasContext *ctx, arg_rri *a)
|
|
|
|
{
|
|
|
|
return do_multimedia_sh(ctx, a, tcg_gen_vec_shl16i_i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hshr_s(DisasContext *ctx, arg_rri *a)
|
|
|
|
{
|
|
|
|
return do_multimedia_sh(ctx, a, tcg_gen_vec_sar16i_i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hshr_u(DisasContext *ctx, arg_rri *a)
|
|
|
|
{
|
|
|
|
return do_multimedia_sh(ctx, a, tcg_gen_vec_shr16i_i64);
|
|
|
|
}
|
|
|
|
|
2023-09-21 10:15:25 +03:00
|
|
|
static bool trans_hshladd(DisasContext *ctx, arg_rrr_sh *a)
|
|
|
|
{
|
|
|
|
return do_multimedia_shadd(ctx, a, gen_helper_hshladd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hshradd(DisasContext *ctx, arg_rrr_sh *a)
|
|
|
|
{
|
|
|
|
return do_multimedia_shadd(ctx, a, gen_helper_hshradd);
|
|
|
|
}
|
|
|
|
|
2023-09-20 17:30:41 +03:00
|
|
|
static bool trans_hsub(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, tcg_gen_vec_sub16_i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hsub_ss(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, gen_helper_hsub_ss);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_hsub_us(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, gen_helper_hsub_us);
|
|
|
|
}
|
|
|
|
|
2023-09-21 10:37:10 +03:00
|
|
|
static void gen_mixh_l(TCGv_i64 dst, TCGv_i64 r1, TCGv_i64 r2)
|
|
|
|
{
|
|
|
|
uint64_t mask = 0xffff0000ffff0000ull;
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_andi_i64(tmp, r2, mask);
|
|
|
|
tcg_gen_andi_i64(dst, r1, mask);
|
|
|
|
tcg_gen_shri_i64(tmp, tmp, 16);
|
|
|
|
tcg_gen_or_i64(dst, dst, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_mixh_l(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, gen_mixh_l);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_mixh_r(TCGv_i64 dst, TCGv_i64 r1, TCGv_i64 r2)
|
|
|
|
{
|
|
|
|
uint64_t mask = 0x0000ffff0000ffffull;
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_andi_i64(tmp, r1, mask);
|
|
|
|
tcg_gen_andi_i64(dst, r2, mask);
|
|
|
|
tcg_gen_shli_i64(tmp, tmp, 16);
|
|
|
|
tcg_gen_or_i64(dst, dst, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_mixh_r(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, gen_mixh_r);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_mixw_l(TCGv_i64 dst, TCGv_i64 r1, TCGv_i64 r2)
|
|
|
|
{
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_shri_i64(tmp, r2, 32);
|
|
|
|
tcg_gen_deposit_i64(dst, r1, tmp, 0, 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_mixw_l(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, gen_mixw_l);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_mixw_r(TCGv_i64 dst, TCGv_i64 r1, TCGv_i64 r2)
|
|
|
|
{
|
|
|
|
tcg_gen_deposit_i64(dst, r2, r1, 32, 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_mixw_r(DisasContext *ctx, arg_rrr *a)
|
|
|
|
{
|
|
|
|
return do_multimedia(ctx, a, gen_mixw_r);
|
|
|
|
}
|
|
|
|
|
2023-09-21 13:07:22 +03:00
|
|
|
static bool trans_permh(DisasContext *ctx, arg_permh *a)
|
|
|
|
{
|
|
|
|
TCGv_i64 r, t0, t1, t2, t3;
|
|
|
|
|
|
|
|
if (!ctx->is_pa20) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
r = load_gpr(ctx, a->r1);
|
|
|
|
t0 = tcg_temp_new_i64();
|
|
|
|
t1 = tcg_temp_new_i64();
|
|
|
|
t2 = tcg_temp_new_i64();
|
|
|
|
t3 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_extract_i64(t0, r, (3 - a->c0) * 16, 16);
|
|
|
|
tcg_gen_extract_i64(t1, r, (3 - a->c1) * 16, 16);
|
|
|
|
tcg_gen_extract_i64(t2, r, (3 - a->c2) * 16, 16);
|
|
|
|
tcg_gen_extract_i64(t3, r, (3 - a->c3) * 16, 16);
|
|
|
|
|
|
|
|
tcg_gen_deposit_i64(t0, t1, t0, 16, 48);
|
|
|
|
tcg_gen_deposit_i64(t2, t3, t2, 16, 48);
|
|
|
|
tcg_gen_deposit_i64(t0, t2, t0, 32, 32);
|
|
|
|
|
|
|
|
save_gpr(ctx, a->t, t0);
|
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
static bool trans_ld(DisasContext *ctx, arg_ldst *a)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
2023-10-27 06:46:13 +03:00
|
|
|
if (ctx->is_pa20) {
|
|
|
|
/*
|
|
|
|
* With pa20, LDB, LDH, LDW, LDD to %g0 are prefetches.
|
|
|
|
* Any base modification still occurs.
|
|
|
|
*/
|
|
|
|
if (a->t == 0) {
|
|
|
|
return trans_nop_addrx(ctx, a);
|
|
|
|
}
|
|
|
|
} else if (a->size > MO_32) {
|
2022-09-28 21:49:13 +03:00
|
|
|
return gen_illegal(ctx);
|
|
|
|
}
|
2023-10-18 07:11:19 +03:00
|
|
|
return do_load(ctx, a->t, a->b, a->x, a->scale ? a->size : 0,
|
|
|
|
a->disp, a->sp, a->m, a->size | MO_TE);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
static bool trans_st(DisasContext *ctx, arg_ldst *a)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
2018-02-12 09:48:03 +03:00
|
|
|
assert(a->x == 0 && a->scale == 0);
|
2023-10-18 07:11:19 +03:00
|
|
|
if (!ctx->is_pa20 && a->size > MO_32) {
|
2022-09-28 21:49:13 +03:00
|
|
|
return gen_illegal(ctx);
|
|
|
|
}
|
2023-10-18 07:11:19 +03:00
|
|
|
return do_store(ctx, a->t, a->b, a->disp, a->sp, a->m, a->size | MO_TE);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
static bool trans_ldc(DisasContext *ctx, arg_ldst *a)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
2020-01-17 04:46:38 +03:00
|
|
|
MemOp mop = MO_TE | MO_ALIGN | a->size;
|
2023-10-18 20:24:33 +03:00
|
|
|
TCGv_i64 dest, ofs;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 addr;
|
2016-12-16 01:54:51 +03:00
|
|
|
|
2023-10-18 07:11:19 +03:00
|
|
|
if (!ctx->is_pa20 && a->size > MO_32) {
|
2023-09-17 09:47:42 +03:00
|
|
|
return gen_illegal(ctx);
|
|
|
|
}
|
|
|
|
|
2016-12-16 01:54:51 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
if (a->m) {
|
2017-12-28 23:38:46 +03:00
|
|
|
/* Base register modification. Make sure if RT == RB,
|
|
|
|
we see the result of the load. */
|
2023-10-18 07:47:02 +03:00
|
|
|
dest = tcg_temp_new_i64();
|
2016-12-16 01:54:51 +03:00
|
|
|
} else {
|
2018-02-12 09:48:03 +03:00
|
|
|
dest = dest_gpr(ctx, a->t);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2024-03-19 19:19:16 +03:00
|
|
|
form_gva(ctx, &addr, &ofs, a->b, a->x, a->scale ? 3 : 0,
|
2023-11-07 22:33:45 +03:00
|
|
|
a->disp, a->sp, a->m, MMU_DISABLED(ctx));
|
2020-01-17 04:46:38 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For hppa1.1, LDCW is undefined unless aligned mod 16.
|
|
|
|
* However actual hardware succeeds with aligned mod 4.
|
|
|
|
* Detect this case and log a GUEST_ERROR.
|
|
|
|
*
|
|
|
|
* TODO: HPPA64 relaxes the over-alignment requirement
|
|
|
|
* with the ,co completer.
|
|
|
|
*/
|
|
|
|
gen_helper_ldc_check(addr);
|
|
|
|
|
2023-10-18 20:24:33 +03:00
|
|
|
tcg_gen_atomic_xchg_i64(dest, addr, ctx->zero, ctx->mmu_idx, mop);
|
2020-01-17 04:46:38 +03:00
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
if (a->m) {
|
|
|
|
save_gpr(ctx, a->b, ofs);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
2018-02-12 09:48:03 +03:00
|
|
|
save_gpr(ctx, a->t, dest);
|
2016-12-16 01:54:51 +03:00
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
static bool trans_stby(DisasContext *ctx, arg_stby *a)
|
2016-12-16 01:54:51 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 ofs, val;
|
|
|
|
TCGv_i64 addr;
|
2016-12-16 01:54:51 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
form_gva(ctx, &addr, &ofs, a->b, 0, 0, a->disp, a->sp, a->m,
|
2023-11-07 22:33:45 +03:00
|
|
|
MMU_DISABLED(ctx));
|
2018-02-12 09:48:03 +03:00
|
|
|
val = load_gpr(ctx, a->r);
|
|
|
|
if (a->a) {
|
2017-07-15 01:29:47 +03:00
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_stby_e_parallel(tcg_env, addr, val);
|
2017-07-15 01:29:47 +03:00
|
|
|
} else {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_stby_e(tcg_env, addr, val);
|
2017-07-15 01:29:47 +03:00
|
|
|
}
|
2016-12-16 01:54:51 +03:00
|
|
|
} else {
|
2017-07-15 01:29:47 +03:00
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_stby_b_parallel(tcg_env, addr, val);
|
2017-07-15 01:29:47 +03:00
|
|
|
} else {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_stby_b(tcg_env, addr, val);
|
2017-07-15 01:29:47 +03:00
|
|
|
}
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
2018-02-12 09:48:03 +03:00
|
|
|
if (a->m) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(ofs, ofs, ~3);
|
2018-02-12 09:48:03 +03:00
|
|
|
save_gpr(ctx, a->b, ofs);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:54:51 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 18:00:23 +03:00
|
|
|
static bool trans_stdby(DisasContext *ctx, arg_stby *a)
|
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 ofs, val;
|
|
|
|
TCGv_i64 addr;
|
2023-09-20 18:00:23 +03:00
|
|
|
|
|
|
|
if (!ctx->is_pa20) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
form_gva(ctx, &addr, &ofs, a->b, 0, 0, a->disp, a->sp, a->m,
|
2023-11-07 22:33:45 +03:00
|
|
|
MMU_DISABLED(ctx));
|
2023-09-20 18:00:23 +03:00
|
|
|
val = load_gpr(ctx, a->r);
|
|
|
|
if (a->a) {
|
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
|
|
|
gen_helper_stdby_e_parallel(tcg_env, addr, val);
|
|
|
|
} else {
|
|
|
|
gen_helper_stdby_e(tcg_env, addr, val);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (tb_cflags(ctx->base.tb) & CF_PARALLEL) {
|
|
|
|
gen_helper_stdby_b_parallel(tcg_env, addr, val);
|
|
|
|
} else {
|
|
|
|
gen_helper_stdby_b(tcg_env, addr, val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (a->m) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(ofs, ofs, ~7);
|
2023-09-20 18:00:23 +03:00
|
|
|
save_gpr(ctx, a->b, ofs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
static bool trans_lda(DisasContext *ctx, arg_ldst *a)
|
2017-11-05 12:23:48 +03:00
|
|
|
{
|
|
|
|
int hold_mmu_idx = ctx->mmu_idx;
|
|
|
|
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
2023-11-07 23:13:17 +03:00
|
|
|
ctx->mmu_idx = ctx->tb_flags & PSW_W ? MMU_ABS_W_IDX : MMU_ABS_IDX;
|
2018-02-12 09:48:03 +03:00
|
|
|
trans_ld(ctx, a);
|
2017-11-05 12:23:48 +03:00
|
|
|
ctx->mmu_idx = hold_mmu_idx;
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2017-11-05 12:23:48 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 09:48:03 +03:00
|
|
|
static bool trans_sta(DisasContext *ctx, arg_ldst *a)
|
2017-11-05 12:23:48 +03:00
|
|
|
{
|
|
|
|
int hold_mmu_idx = ctx->mmu_idx;
|
|
|
|
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
2023-11-07 23:13:17 +03:00
|
|
|
ctx->mmu_idx = ctx->tb_flags & PSW_W ? MMU_ABS_W_IDX : MMU_ABS_IDX;
|
2018-02-12 09:48:03 +03:00
|
|
|
trans_st(ctx, a);
|
2017-11-05 12:23:48 +03:00
|
|
|
ctx->mmu_idx = hold_mmu_idx;
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2017-11-05 12:23:48 +03:00
|
|
|
}
|
2018-01-07 02:30:45 +03:00
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool trans_ldil(DisasContext *ctx, arg_ldil *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_rt = dest_gpr(ctx, a->t);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(tcg_rt, a->i);
|
2018-02-13 02:34:12 +03:00
|
|
|
save_gpr(ctx, a->t, tcg_rt);
|
2016-12-16 00:37:23 +03:00
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool trans_addil(DisasContext *ctx, arg_addil *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_rt = load_gpr(ctx, a->r);
|
|
|
|
TCGv_i64 tcg_r1 = dest_gpr(ctx, 1);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_addi_i64(tcg_r1, tcg_rt, a->i);
|
2016-12-16 00:37:23 +03:00
|
|
|
save_gpr(ctx, 1, tcg_r1);
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:34:12 +03:00
|
|
|
static bool trans_ldo(DisasContext *ctx, arg_ldo *a)
|
2016-12-16 00:37:23 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tcg_rt = dest_gpr(ctx, a->t);
|
2016-12-16 00:37:23 +03:00
|
|
|
|
|
|
|
/* Special case rb == 0, for the LDI pseudo-op.
|
2023-10-18 07:49:54 +03:00
|
|
|
The COPY pseudo-op is handled for free within tcg_gen_addi_i64. */
|
2018-02-13 02:34:12 +03:00
|
|
|
if (a->b == 0) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(tcg_rt, a->i);
|
2016-12-16 00:37:23 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_addi_i64(tcg_rt, cpu_gr[a->b], a->i);
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
2018-02-13 02:34:12 +03:00
|
|
|
save_gpr(ctx, a->t, tcg_rt);
|
2016-12-16 00:37:23 +03:00
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 04:09:30 +03:00
|
|
|
return true;
|
2016-12-16 00:37:23 +03:00
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static bool do_cmpb(DisasContext *ctx, unsigned r, TCGv_i64 in1,
|
2023-09-17 07:56:39 +03:00
|
|
|
unsigned c, unsigned f, bool d, unsigned n, int disp)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest, in2, sv;
|
2016-12-16 00:50:28 +03:00
|
|
|
DisasCond cond;
|
|
|
|
|
|
|
|
in2 = load_gpr(ctx, r);
|
2023-10-18 07:47:02 +03:00
|
|
|
dest = tcg_temp_new_i64();
|
2016-12-16 00:50:28 +03:00
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_sub_i64(dest, in1, in2);
|
2016-12-16 00:50:28 +03:00
|
|
|
|
2017-11-02 14:47:37 +03:00
|
|
|
sv = NULL;
|
2019-02-12 04:12:54 +03:00
|
|
|
if (cond_need_sv(c)) {
|
2016-12-16 00:50:28 +03:00
|
|
|
sv = do_sub_sv(ctx, dest, in1, in2);
|
|
|
|
}
|
|
|
|
|
2023-09-17 05:28:12 +03:00
|
|
|
cond = do_sub_cond(ctx, c * 2 + f, d, dest, in1, in2, sv);
|
2018-02-12 10:33:50 +03:00
|
|
|
return do_cbranch(ctx, disp, n, &cond);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 10:33:50 +03:00
|
|
|
static bool trans_cmpb(DisasContext *ctx, arg_cmpb *a)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2023-09-17 07:56:39 +03:00
|
|
|
if (!ctx->is_pa20 && a->d) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-12 10:33:50 +03:00
|
|
|
nullify_over(ctx);
|
2023-09-17 07:56:39 +03:00
|
|
|
return do_cmpb(ctx, a->r2, load_gpr(ctx, a->r1),
|
|
|
|
a->c, a->f, a->d, a->n, a->disp);
|
2018-02-12 10:33:50 +03:00
|
|
|
}
|
2016-12-16 00:50:28 +03:00
|
|
|
|
2018-02-12 10:33:50 +03:00
|
|
|
static bool trans_cmpbi(DisasContext *ctx, arg_cmpbi *a)
|
|
|
|
{
|
2023-09-17 08:06:04 +03:00
|
|
|
if (!ctx->is_pa20 && a->d) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-16 00:50:28 +03:00
|
|
|
nullify_over(ctx);
|
2023-10-18 07:31:08 +03:00
|
|
|
return do_cmpb(ctx, a->r, tcg_constant_i64(a->i),
|
2023-09-17 08:06:04 +03:00
|
|
|
a->c, a->f, a->d, a->n, a->disp);
|
2018-02-12 10:33:50 +03:00
|
|
|
}
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
static bool do_addb(DisasContext *ctx, unsigned r, TCGv_i64 in1,
|
2018-02-12 10:33:50 +03:00
|
|
|
unsigned c, unsigned f, unsigned n, int disp)
|
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest, in2, sv, cb_cond;
|
2018-02-12 10:33:50 +03:00
|
|
|
DisasCond cond;
|
2023-10-18 02:16:03 +03:00
|
|
|
bool d = false;
|
2016-12-16 00:50:28 +03:00
|
|
|
|
2023-09-17 08:25:30 +03:00
|
|
|
/*
|
|
|
|
* For hppa64, the ADDB conditions change with PSW.W,
|
|
|
|
* dropping ZNV, SV, OD in favor of double-word EQ, LT, LE.
|
|
|
|
*/
|
|
|
|
if (ctx->tb_flags & PSW_W) {
|
|
|
|
d = c >= 5;
|
|
|
|
if (d) {
|
|
|
|
c &= 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-16 00:50:28 +03:00
|
|
|
in2 = load_gpr(ctx, r);
|
2023-10-18 07:47:02 +03:00
|
|
|
dest = tcg_temp_new_i64();
|
2017-11-02 14:47:37 +03:00
|
|
|
sv = NULL;
|
2023-10-18 02:16:03 +03:00
|
|
|
cb_cond = NULL;
|
2016-12-16 00:50:28 +03:00
|
|
|
|
2019-02-12 04:12:54 +03:00
|
|
|
if (cond_need_cb(c)) {
|
2023-10-18 07:47:02 +03:00
|
|
|
TCGv_i64 cb = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 cb_msb = tcg_temp_new_i64();
|
2023-10-18 02:16:03 +03:00
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(cb_msb, 0);
|
|
|
|
tcg_gen_add2_i64(dest, cb_msb, in1, cb_msb, in2, cb_msb);
|
|
|
|
tcg_gen_xor_i64(cb, in1, in2);
|
|
|
|
tcg_gen_xor_i64(cb, cb, dest);
|
2023-10-18 02:16:03 +03:00
|
|
|
cb_cond = get_carry(ctx, d, cb, cb_msb);
|
2019-02-12 04:12:54 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_add_i64(dest, in1, in2);
|
2019-02-12 04:12:54 +03:00
|
|
|
}
|
|
|
|
if (cond_need_sv(c)) {
|
2024-03-26 09:33:16 +03:00
|
|
|
sv = do_add_sv(ctx, dest, in1, in2, in1, 0, d);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 05:26:15 +03:00
|
|
|
cond = do_cond(ctx, c * 2 + f, d, dest, cb_cond, sv);
|
2019-03-11 22:15:52 +03:00
|
|
|
save_gpr(ctx, r, dest);
|
2018-02-12 10:33:50 +03:00
|
|
|
return do_cbranch(ctx, disp, n, &cond);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 10:33:50 +03:00
|
|
|
static bool trans_addb(DisasContext *ctx, arg_addb *a)
|
|
|
|
{
|
|
|
|
nullify_over(ctx);
|
|
|
|
return do_addb(ctx, a->r2, load_gpr(ctx, a->r1), a->c, a->f, a->n, a->disp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_addbi(DisasContext *ctx, arg_addbi *a)
|
|
|
|
{
|
|
|
|
nullify_over(ctx);
|
2023-10-18 07:31:08 +03:00
|
|
|
return do_addb(ctx, a->r, tcg_constant_i64(a->i), a->c, a->f, a->n, a->disp);
|
2018-02-12 10:33:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_bb_sar(DisasContext *ctx, arg_bb_sar *a)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tmp, tcg_r;
|
2016-12-16 00:50:28 +03:00
|
|
|
DisasCond cond;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2018-02-12 10:33:50 +03:00
|
|
|
tcg_r = load_gpr(ctx, a->r);
|
2024-03-26 05:33:50 +03:00
|
|
|
if (a->d) {
|
|
|
|
tcg_gen_shl_i64(tmp, tcg_r, cpu_sar);
|
|
|
|
} else {
|
2023-10-18 02:39:47 +03:00
|
|
|
/* Force shift into [32,63] */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ori_i64(tmp, cpu_sar, 32);
|
|
|
|
tcg_gen_shl_i64(tmp, tcg_r, tmp);
|
2023-10-18 02:39:47 +03:00
|
|
|
}
|
2016-12-16 00:50:28 +03:00
|
|
|
|
2024-03-25 20:30:19 +03:00
|
|
|
cond = cond_make_ti(a->c ? TCG_COND_GE : TCG_COND_LT, tmp, 0);
|
2018-02-12 10:33:50 +03:00
|
|
|
return do_cbranch(ctx, a->disp, a->n, &cond);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 10:33:50 +03:00
|
|
|
static bool trans_bb_imm(DisasContext *ctx, arg_bb_imm *a)
|
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tmp, tcg_r;
|
2018-02-12 10:33:50 +03:00
|
|
|
DisasCond cond;
|
2023-10-18 02:39:47 +03:00
|
|
|
int p;
|
2018-02-12 10:33:50 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2018-02-12 10:33:50 +03:00
|
|
|
tcg_r = load_gpr(ctx, a->r);
|
2024-03-26 05:33:50 +03:00
|
|
|
p = a->p | (a->d ? 0 : 32);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_shli_i64(tmp, tcg_r, p);
|
2018-02-12 10:33:50 +03:00
|
|
|
|
2024-03-25 20:30:19 +03:00
|
|
|
cond = cond_make_ti(a->c ? TCG_COND_GE : TCG_COND_LT, tmp, 0);
|
2018-02-12 10:33:50 +03:00
|
|
|
return do_cbranch(ctx, a->disp, a->n, &cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_movb(DisasContext *ctx, arg_movb *a)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest;
|
2016-12-16 00:50:28 +03:00
|
|
|
DisasCond cond;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 10:33:50 +03:00
|
|
|
dest = dest_gpr(ctx, a->r2);
|
|
|
|
if (a->r1 == 0) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(dest, 0);
|
2016-12-16 00:50:28 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_mov_i64(dest, cpu_gr[a->r1]);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2023-09-17 05:34:39 +03:00
|
|
|
/* All MOVB conditions are 32-bit. */
|
|
|
|
cond = do_sed_cond(ctx, a->c, false, dest);
|
2018-02-12 10:33:50 +03:00
|
|
|
return do_cbranch(ctx, a->disp, a->n, &cond);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_movbi(DisasContext *ctx, arg_movbi *a)
|
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest;
|
2018-02-12 10:33:50 +03:00
|
|
|
DisasCond cond;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
dest = dest_gpr(ctx, a->r);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(dest, a->i);
|
2018-02-12 10:33:50 +03:00
|
|
|
|
2023-09-17 05:34:39 +03:00
|
|
|
/* All MOVBI conditions are 32-bit. */
|
|
|
|
cond = do_sed_cond(ctx, a->c, false, dest);
|
2018-02-12 10:33:50 +03:00
|
|
|
return do_cbranch(ctx, a->disp, a->n, &cond);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 13:44:23 +03:00
|
|
|
static bool trans_shrp_sar(DisasContext *ctx, arg_shrp_sar *a)
|
2016-12-16 01:04:13 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest, src2;
|
2016-12-16 01:04:13 +03:00
|
|
|
|
2023-09-20 13:44:23 +03:00
|
|
|
if (!ctx->is_pa20 && a->d) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2016-12-16 01:04:13 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:26:48 +03:00
|
|
|
dest = dest_gpr(ctx, a->t);
|
2023-09-20 13:44:23 +03:00
|
|
|
src2 = load_gpr(ctx, a->r2);
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->r1 == 0) {
|
2023-09-20 13:44:23 +03:00
|
|
|
if (a->d) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_shr_i64(dest, src2, cpu_sar);
|
2023-09-20 13:44:23 +03:00
|
|
|
} else {
|
2023-10-18 07:47:02 +03:00
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
2023-09-17 02:22:14 +03:00
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ext32u_i64(dest, src2);
|
|
|
|
tcg_gen_andi_i64(tmp, cpu_sar, 31);
|
|
|
|
tcg_gen_shr_i64(dest, dest, tmp);
|
2023-09-20 13:44:23 +03:00
|
|
|
}
|
|
|
|
} else if (a->r1 == a->r2) {
|
|
|
|
if (a->d) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_rotr_i64(dest, src2, cpu_sar);
|
2023-09-20 13:44:23 +03:00
|
|
|
} else {
|
|
|
|
TCGv_i32 t32 = tcg_temp_new_i32();
|
|
|
|
TCGv_i32 s32 = tcg_temp_new_i32();
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_extrl_i64_i32(t32, src2);
|
|
|
|
tcg_gen_extrl_i64_i32(s32, cpu_sar);
|
2023-09-20 13:44:23 +03:00
|
|
|
tcg_gen_andi_i32(s32, s32, 31);
|
|
|
|
tcg_gen_rotr_i32(t32, t32, s32);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_extu_i32_i64(dest, t32);
|
2023-09-20 13:44:23 +03:00
|
|
|
}
|
2016-12-16 01:04:13 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 src1 = load_gpr(ctx, a->r1);
|
2023-09-20 13:44:23 +03:00
|
|
|
|
|
|
|
if (a->d) {
|
2023-10-18 07:47:02 +03:00
|
|
|
TCGv_i64 t = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 n = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
|
|
|
|
tcg_gen_xori_i64(n, cpu_sar, 63);
|
2023-11-17 13:02:39 +03:00
|
|
|
tcg_gen_shl_i64(t, src1, n);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_shli_i64(t, t, 1);
|
2023-11-17 13:02:39 +03:00
|
|
|
tcg_gen_shr_i64(dest, src2, cpu_sar);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_or_i64(dest, dest, t);
|
2023-09-20 13:44:23 +03:00
|
|
|
} else {
|
|
|
|
TCGv_i64 t = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 s = tcg_temp_new_i64();
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_concat32_i64(t, src2, src1);
|
2023-10-18 07:42:55 +03:00
|
|
|
tcg_gen_andi_i64(s, cpu_sar, 31);
|
|
|
|
tcg_gen_shr_i64(dest, t, s);
|
2023-09-20 13:44:23 +03:00
|
|
|
}
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
save_gpr(ctx, a->t, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2024-03-19 19:19:17 +03:00
|
|
|
ctx->null_cond = do_sed_cond(ctx, a->c, a->d, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 13:44:23 +03:00
|
|
|
static bool trans_shrp_imm(DisasContext *ctx, arg_shrp_imm *a)
|
2016-12-16 01:04:13 +03:00
|
|
|
{
|
2023-09-20 13:44:23 +03:00
|
|
|
unsigned width, sa;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest, t2;
|
2016-12-16 01:04:13 +03:00
|
|
|
|
2023-09-20 13:44:23 +03:00
|
|
|
if (!ctx->is_pa20 && a->d) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2016-12-16 01:04:13 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
|
|
|
|
2023-09-20 13:44:23 +03:00
|
|
|
width = a->d ? 64 : 32;
|
|
|
|
sa = width - 1 - a->cpos;
|
|
|
|
|
2018-02-12 11:26:48 +03:00
|
|
|
dest = dest_gpr(ctx, a->t);
|
|
|
|
t2 = load_gpr(ctx, a->r2);
|
2021-12-13 20:38:38 +03:00
|
|
|
if (a->r1 == 0) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_extract_i64(dest, t2, sa, width - sa);
|
2023-10-18 07:11:19 +03:00
|
|
|
} else if (width == TARGET_LONG_BITS) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_extract2_i64(dest, t2, cpu_gr[a->r1], sa);
|
2016-12-16 01:04:13 +03:00
|
|
|
} else {
|
2023-09-20 13:44:23 +03:00
|
|
|
assert(!a->d);
|
|
|
|
if (a->r1 == a->r2) {
|
|
|
|
TCGv_i32 t32 = tcg_temp_new_i32();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_extrl_i64_i32(t32, t2);
|
2023-09-20 13:44:23 +03:00
|
|
|
tcg_gen_rotri_i32(t32, t32, sa);
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_extu_i32_i64(dest, t32);
|
2023-09-20 13:44:23 +03:00
|
|
|
} else {
|
2023-10-18 07:42:55 +03:00
|
|
|
tcg_gen_concat32_i64(dest, t2, cpu_gr[a->r1]);
|
|
|
|
tcg_gen_extract_i64(dest, dest, sa, 32);
|
2023-09-20 13:44:23 +03:00
|
|
|
}
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
save_gpr(ctx, a->t, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2024-03-19 19:19:17 +03:00
|
|
|
ctx->null_cond = do_sed_cond(ctx, a->c, a->d, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 13:04:29 +03:00
|
|
|
static bool trans_extr_sar(DisasContext *ctx, arg_extr_sar *a)
|
2016-12-16 01:04:13 +03:00
|
|
|
{
|
2023-09-20 13:04:29 +03:00
|
|
|
unsigned widthm1 = a->d ? 63 : 31;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest, src, tmp;
|
2016-12-16 01:04:13 +03:00
|
|
|
|
2023-09-20 13:04:29 +03:00
|
|
|
if (!ctx->is_pa20 && a->d) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2016-12-16 01:04:13 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:26:48 +03:00
|
|
|
dest = dest_gpr(ctx, a->t);
|
|
|
|
src = load_gpr(ctx, a->r);
|
2023-10-18 07:47:02 +03:00
|
|
|
tmp = tcg_temp_new_i64();
|
2016-12-16 01:04:13 +03:00
|
|
|
|
|
|
|
/* Recall that SAR is using big-endian bit numbering. */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(tmp, cpu_sar, widthm1);
|
|
|
|
tcg_gen_xori_i64(tmp, tmp, widthm1);
|
2023-09-19 17:07:14 +03:00
|
|
|
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->se) {
|
2023-09-20 13:04:29 +03:00
|
|
|
if (!a->d) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ext32s_i64(dest, src);
|
2023-09-20 13:04:29 +03:00
|
|
|
src = dest;
|
|
|
|
}
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_sar_i64(dest, src, tmp);
|
|
|
|
tcg_gen_sextract_i64(dest, dest, 0, a->len);
|
2016-12-16 01:04:13 +03:00
|
|
|
} else {
|
2023-09-20 13:04:29 +03:00
|
|
|
if (!a->d) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ext32u_i64(dest, src);
|
2023-09-20 13:04:29 +03:00
|
|
|
src = dest;
|
|
|
|
}
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_shr_i64(dest, src, tmp);
|
|
|
|
tcg_gen_extract_i64(dest, dest, 0, a->len);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
save_gpr(ctx, a->t, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2023-09-20 13:04:29 +03:00
|
|
|
ctx->null_cond = do_sed_cond(ctx, a->c, a->d, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 13:04:29 +03:00
|
|
|
static bool trans_extr_imm(DisasContext *ctx, arg_extr_imm *a)
|
2016-12-16 01:04:13 +03:00
|
|
|
{
|
2023-09-20 13:04:29 +03:00
|
|
|
unsigned len, cpos, width;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest, src;
|
2016-12-16 01:04:13 +03:00
|
|
|
|
2023-09-20 13:04:29 +03:00
|
|
|
if (!ctx->is_pa20 && a->d) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2016-12-16 01:04:13 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
|
|
|
|
2023-09-20 13:04:29 +03:00
|
|
|
len = a->len;
|
|
|
|
width = a->d ? 64 : 32;
|
|
|
|
cpos = width - 1 - a->pos;
|
|
|
|
if (cpos + len > width) {
|
|
|
|
len = width - cpos;
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:26:48 +03:00
|
|
|
dest = dest_gpr(ctx, a->t);
|
|
|
|
src = load_gpr(ctx, a->r);
|
|
|
|
if (a->se) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_sextract_i64(dest, src, cpos, len);
|
2016-12-16 01:04:13 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_extract_i64(dest, src, cpos, len);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
save_gpr(ctx, a->t, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2023-09-20 13:04:29 +03:00
|
|
|
ctx->null_cond = do_sed_cond(ctx, a->c, a->d, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 12:44:17 +03:00
|
|
|
static bool trans_depi_imm(DisasContext *ctx, arg_depi_imm *a)
|
2016-12-16 01:04:13 +03:00
|
|
|
{
|
2023-09-20 12:44:17 +03:00
|
|
|
unsigned len, width;
|
2023-10-18 07:11:19 +03:00
|
|
|
uint64_t mask0, mask1;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest;
|
2016-12-16 01:04:13 +03:00
|
|
|
|
2023-09-20 12:44:17 +03:00
|
|
|
if (!ctx->is_pa20 && a->d) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2016-12-16 01:04:13 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
2023-09-20 12:44:17 +03:00
|
|
|
|
|
|
|
len = a->len;
|
|
|
|
width = a->d ? 64 : 32;
|
|
|
|
if (a->cpos + len > width) {
|
|
|
|
len = width - a->cpos;
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 11:26:48 +03:00
|
|
|
dest = dest_gpr(ctx, a->t);
|
|
|
|
mask0 = deposit64(0, a->cpos, len, a->i);
|
|
|
|
mask1 = deposit64(-1, a->cpos, len, a->i);
|
2016-12-16 01:04:13 +03:00
|
|
|
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->nz) {
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 src = load_gpr(ctx, a->t);
|
|
|
|
tcg_gen_andi_i64(dest, src, mask1);
|
|
|
|
tcg_gen_ori_i64(dest, dest, mask0);
|
2016-12-16 01:04:13 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(dest, mask0);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
save_gpr(ctx, a->t, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2023-09-20 12:44:17 +03:00
|
|
|
ctx->null_cond = do_sed_cond(ctx, a->c, a->d, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 12:44:17 +03:00
|
|
|
static bool trans_dep_imm(DisasContext *ctx, arg_dep_imm *a)
|
2016-12-16 01:04:13 +03:00
|
|
|
{
|
2018-02-12 11:26:48 +03:00
|
|
|
unsigned rs = a->nz ? a->t : 0;
|
2023-09-20 12:44:17 +03:00
|
|
|
unsigned len, width;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest, val;
|
2016-12-16 01:04:13 +03:00
|
|
|
|
2023-09-20 12:44:17 +03:00
|
|
|
if (!ctx->is_pa20 && a->d) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2016-12-16 01:04:13 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
2023-09-20 12:44:17 +03:00
|
|
|
|
|
|
|
len = a->len;
|
|
|
|
width = a->d ? 64 : 32;
|
|
|
|
if (a->cpos + len > width) {
|
|
|
|
len = width - a->cpos;
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 11:26:48 +03:00
|
|
|
dest = dest_gpr(ctx, a->t);
|
|
|
|
val = load_gpr(ctx, a->r);
|
2016-12-16 01:04:13 +03:00
|
|
|
if (rs == 0) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_deposit_z_i64(dest, val, a->cpos, len);
|
2016-12-16 01:04:13 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_deposit_i64(dest, cpu_gr[rs], val, a->cpos, len);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 11:26:48 +03:00
|
|
|
save_gpr(ctx, a->t, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
2018-02-12 11:26:48 +03:00
|
|
|
if (a->c) {
|
2023-09-20 12:44:17 +03:00
|
|
|
ctx->null_cond = do_sed_cond(ctx, a->c, a->d, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 12:44:17 +03:00
|
|
|
static bool do_dep_sar(DisasContext *ctx, unsigned rt, unsigned c,
|
2023-10-18 07:31:08 +03:00
|
|
|
bool d, bool nz, unsigned len, TCGv_i64 val)
|
2016-12-16 01:04:13 +03:00
|
|
|
{
|
|
|
|
unsigned rs = nz ? rt : 0;
|
2023-09-20 12:44:17 +03:00
|
|
|
unsigned widthm1 = d ? 63 : 31;
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 mask, tmp, shift, dest;
|
2023-10-18 07:11:19 +03:00
|
|
|
uint64_t msb = 1ULL << (len - 1);
|
2016-12-16 01:04:13 +03:00
|
|
|
|
|
|
|
dest = dest_gpr(ctx, rt);
|
2023-10-18 07:47:02 +03:00
|
|
|
shift = tcg_temp_new_i64();
|
|
|
|
tmp = tcg_temp_new_i64();
|
2016-12-16 01:04:13 +03:00
|
|
|
|
|
|
|
/* Convert big-endian bit numbering in SAR to left-shift. */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(shift, cpu_sar, widthm1);
|
|
|
|
tcg_gen_xori_i64(shift, shift, widthm1);
|
2016-12-16 01:04:13 +03:00
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
mask = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_movi_i64(mask, msb + (msb - 1));
|
|
|
|
tcg_gen_and_i64(tmp, val, mask);
|
2016-12-16 01:04:13 +03:00
|
|
|
if (rs) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_shl_i64(mask, mask, shift);
|
|
|
|
tcg_gen_shl_i64(tmp, tmp, shift);
|
|
|
|
tcg_gen_andc_i64(dest, cpu_gr[rs], mask);
|
|
|
|
tcg_gen_or_i64(dest, dest, tmp);
|
2016-12-16 01:04:13 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_shl_i64(dest, tmp, shift);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
|
|
|
save_gpr(ctx, rt, dest);
|
|
|
|
|
|
|
|
/* Install the new nullification. */
|
|
|
|
cond_free(&ctx->null_cond);
|
|
|
|
if (c) {
|
2023-09-20 12:44:17 +03:00
|
|
|
ctx->null_cond = do_sed_cond(ctx, c, d, dest);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 01:04:13 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 12:44:17 +03:00
|
|
|
static bool trans_dep_sar(DisasContext *ctx, arg_dep_sar *a)
|
2018-02-12 11:26:48 +03:00
|
|
|
{
|
2023-09-20 12:44:17 +03:00
|
|
|
if (!ctx->is_pa20 && a->d) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-13 13:17:14 +03:00
|
|
|
if (a->c) {
|
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
2023-09-20 12:44:17 +03:00
|
|
|
return do_dep_sar(ctx, a->t, a->c, a->d, a->nz, a->len,
|
|
|
|
load_gpr(ctx, a->r));
|
2018-02-12 11:26:48 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 12:44:17 +03:00
|
|
|
static bool trans_depi_sar(DisasContext *ctx, arg_depi_sar *a)
|
2018-02-12 11:26:48 +03:00
|
|
|
{
|
2023-09-20 12:44:17 +03:00
|
|
|
if (!ctx->is_pa20 && a->d) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-13 13:17:14 +03:00
|
|
|
if (a->c) {
|
|
|
|
nullify_over(ctx);
|
|
|
|
}
|
2023-09-20 12:44:17 +03:00
|
|
|
return do_dep_sar(ctx, a->t, a->c, a->d, a->nz, a->len,
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_constant_i64(a->i));
|
2018-02-12 11:26:48 +03:00
|
|
|
}
|
2016-12-16 01:04:13 +03:00
|
|
|
|
2018-02-12 20:36:07 +03:00
|
|
|
static bool trans_be(DisasContext *ctx, arg_be *a)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2024-03-23 10:29:47 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2024-03-22 02:56:44 +03:00
|
|
|
ctx->iaq_j.space = tcg_temp_new_i64();
|
|
|
|
load_spr(ctx, ctx->iaq_j.space, a->sp);
|
2017-10-22 08:53:35 +03:00
|
|
|
#endif
|
2024-03-23 10:29:47 +03:00
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
ctx->iaq_j.base = tcg_temp_new_i64();
|
|
|
|
ctx->iaq_j.disp = 0;
|
|
|
|
|
|
|
|
tcg_gen_addi_i64(ctx->iaq_j.base, load_gpr(ctx, a->b), a->disp);
|
|
|
|
ctx->iaq_j.base = do_ibranch_priv(ctx, ctx->iaq_j.base);
|
|
|
|
|
|
|
|
return do_ibranch(ctx, a->l, true, a->n);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 20:36:07 +03:00
|
|
|
static bool trans_bl(DisasContext *ctx, arg_bl *a)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2024-03-21 09:02:42 +03:00
|
|
|
return do_dbranch(ctx, a->disp, a->l, a->n);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 20:36:07 +03:00
|
|
|
static bool trans_b_gate(DisasContext *ctx, arg_b_gate *a)
|
2017-12-15 23:37:26 +03:00
|
|
|
{
|
2024-03-22 02:56:44 +03:00
|
|
|
int64_t disp = a->disp;
|
2017-12-15 23:37:26 +03:00
|
|
|
|
2019-03-11 22:15:58 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
|
2017-12-15 23:37:26 +03:00
|
|
|
/* Make sure the caller hasn't done something weird with the queue.
|
|
|
|
* ??? This is not quite the same as the PSW[B] bit, which would be
|
|
|
|
* expensive to track. Real hardware will trap for
|
|
|
|
* b gateway
|
|
|
|
* b gateway+4 (in delay slot of first branch)
|
|
|
|
* However, checking for a non-sequential instruction queue *will*
|
|
|
|
* diagnose the security hole
|
|
|
|
* b gateway
|
|
|
|
* b evil
|
|
|
|
* in which instructions at evil would run with increased privs.
|
|
|
|
*/
|
2024-03-22 02:56:44 +03:00
|
|
|
if (iaqe_variable(&ctx->iaq_b) || ctx->iaq_b.disp != ctx->iaq_f.disp + 4) {
|
2017-12-15 23:37:26 +03:00
|
|
|
return gen_illegal(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
if (ctx->tb_flags & PSW_C) {
|
2024-01-29 19:44:46 +03:00
|
|
|
int type = hppa_artype_for_page(cpu_env(ctx->cs), ctx->base.pc_next);
|
2017-12-15 23:37:26 +03:00
|
|
|
/* If we could not find a TLB entry, then we need to generate an
|
|
|
|
ITLB miss exception so the kernel will provide it.
|
|
|
|
The resulting TLB fill operation will invalidate this TB and
|
|
|
|
we will re-translate, at which point we *will* be able to find
|
|
|
|
the TLB entry and determine if this is in fact a gateway page. */
|
|
|
|
if (type < 0) {
|
2018-02-12 04:09:30 +03:00
|
|
|
gen_excp(ctx, EXCP_ITLB_MISS);
|
|
|
|
return true;
|
2017-12-15 23:37:26 +03:00
|
|
|
}
|
|
|
|
/* No change for non-gateway pages or for priv decrease. */
|
|
|
|
if (type >= 4 && type - 4 < ctx->privilege) {
|
2024-03-22 02:56:44 +03:00
|
|
|
disp -= ctx->privilege;
|
|
|
|
disp += type - 4;
|
2017-12-15 23:37:26 +03:00
|
|
|
}
|
|
|
|
} else {
|
2024-03-22 02:56:44 +03:00
|
|
|
disp -= ctx->privilege; /* priv = 0 */
|
2017-12-15 23:37:26 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-03-11 22:15:58 +03:00
|
|
|
if (a->l) {
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 tmp = dest_gpr(ctx, a->l);
|
2019-03-11 22:15:58 +03:00
|
|
|
if (ctx->privilege < 3) {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(tmp, tmp, -4);
|
2019-03-11 22:15:58 +03:00
|
|
|
}
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ori_i64(tmp, tmp, ctx->privilege);
|
2019-03-11 22:15:58 +03:00
|
|
|
save_gpr(ctx, a->l, tmp);
|
|
|
|
}
|
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
return do_dbranch(ctx, disp, 0, a->n);
|
2017-12-15 23:37:26 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 20:36:07 +03:00
|
|
|
static bool trans_blr(DisasContext *ctx, arg_blr *a)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2019-02-22 02:29:39 +03:00
|
|
|
if (a->x) {
|
2024-03-22 02:56:44 +03:00
|
|
|
DisasIAQE next = iaqe_incr(&ctx->iaq_f, 8);
|
|
|
|
TCGv_i64 t0 = tcg_temp_new_i64();
|
|
|
|
TCGv_i64 t1 = tcg_temp_new_i64();
|
|
|
|
|
2019-02-22 02:29:39 +03:00
|
|
|
/* The computation here never changes privilege level. */
|
2024-03-22 02:56:44 +03:00
|
|
|
copy_iaoq_entry(ctx, t0, &next);
|
|
|
|
tcg_gen_shli_i64(t1, load_gpr(ctx, a->x), 3);
|
|
|
|
tcg_gen_add_i64(t0, t0, t1);
|
|
|
|
|
|
|
|
ctx->iaq_j = iaqe_next_absv(ctx, t0);
|
|
|
|
return do_ibranch(ctx, a->l, false, a->n);
|
2019-02-22 02:29:39 +03:00
|
|
|
} else {
|
|
|
|
/* BLR R0,RX is a good way to load PC+8 into RX. */
|
2024-03-21 09:02:42 +03:00
|
|
|
return do_dbranch(ctx, 0, a->l, a->n);
|
2019-02-22 02:29:39 +03:00
|
|
|
}
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 20:36:07 +03:00
|
|
|
static bool trans_bv(DisasContext *ctx, arg_bv *a)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 dest;
|
2016-12-16 00:50:28 +03:00
|
|
|
|
2018-02-12 20:36:07 +03:00
|
|
|
if (a->x == 0) {
|
|
|
|
dest = load_gpr(ctx, a->b);
|
2016-12-16 00:50:28 +03:00
|
|
|
} else {
|
2023-10-18 07:47:02 +03:00
|
|
|
dest = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_shli_i64(dest, load_gpr(ctx, a->x), 3);
|
|
|
|
tcg_gen_add_i64(dest, dest, load_gpr(ctx, a->b));
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
2017-10-09 21:25:12 +03:00
|
|
|
dest = do_ibranch_priv(ctx, dest);
|
2024-03-22 02:56:44 +03:00
|
|
|
ctx->iaq_j = iaqe_next_absv(ctx, dest);
|
|
|
|
|
|
|
|
return do_ibranch(ctx, 0, false, a->n);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 20:36:07 +03:00
|
|
|
static bool trans_bve(DisasContext *ctx, arg_bve *a)
|
2016-12-16 00:50:28 +03:00
|
|
|
{
|
2024-03-23 10:29:47 +03:00
|
|
|
TCGv_i64 b = load_gpr(ctx, a->b);
|
2017-10-22 08:53:35 +03:00
|
|
|
|
2024-03-23 10:29:47 +03:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2024-03-22 02:56:44 +03:00
|
|
|
ctx->iaq_j.space = space_select(ctx, 0, b);
|
2017-10-22 08:53:35 +03:00
|
|
|
#endif
|
2024-03-22 02:56:44 +03:00
|
|
|
ctx->iaq_j.base = do_ibranch_priv(ctx, b);
|
|
|
|
ctx->iaq_j.disp = 0;
|
2024-03-23 10:29:47 +03:00
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
return do_ibranch(ctx, a->l, false, a->n);
|
2016-12-16 00:50:28 +03:00
|
|
|
}
|
|
|
|
|
2023-09-20 14:11:27 +03:00
|
|
|
static bool trans_nopbts(DisasContext *ctx, arg_nopbts *a)
|
|
|
|
{
|
|
|
|
/* All branch target stack instructions implement as nop. */
|
|
|
|
return ctx->is_pa20;
|
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
/*
|
|
|
|
* Float class 0
|
|
|
|
*/
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static void gen_fcpy_f(TCGv_i32 dst, TCGv_env unused, TCGv_i32 src)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
tcg_gen_mov_i32(dst, src);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2022-10-27 20:03:05 +03:00
|
|
|
static bool trans_fid_f(DisasContext *ctx, arg_fid_f *a)
|
|
|
|
{
|
2023-02-26 02:01:12 +03:00
|
|
|
uint64_t ret;
|
|
|
|
|
2023-10-18 07:11:19 +03:00
|
|
|
if (ctx->is_pa20) {
|
2023-02-26 02:01:12 +03:00
|
|
|
ret = 0x13080000000000ULL; /* PA8700 (PCX-W2) */
|
|
|
|
} else {
|
|
|
|
ret = 0x0f080000000000ULL; /* PA7300LC (PCX-L2) */
|
|
|
|
}
|
|
|
|
|
2022-10-27 20:03:05 +03:00
|
|
|
nullify_over(ctx);
|
2023-02-26 02:01:12 +03:00
|
|
|
save_frd(0, tcg_constant_i64(ret));
|
2022-10-27 20:03:05 +03:00
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fcpy_f(DisasContext *ctx, arg_fclass01 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_fcpy_f);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static void gen_fcpy_d(TCGv_i64 dst, TCGv_env unused, TCGv_i64 src)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
tcg_gen_mov_i64(dst, src);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fcpy_d(DisasContext *ctx, arg_fclass01 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_fcpy_d);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static void gen_fabs_f(TCGv_i32 dst, TCGv_env unused, TCGv_i32 src)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
tcg_gen_andi_i32(dst, src, INT32_MAX);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fabs_f(DisasContext *ctx, arg_fclass01 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_fabs_f);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static void gen_fabs_d(TCGv_i64 dst, TCGv_env unused, TCGv_i64 src)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
tcg_gen_andi_i64(dst, src, INT64_MAX);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fabs_d(DisasContext *ctx, arg_fclass01 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_fabs_d);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fsqrt_f(DisasContext *ctx, arg_fclass01 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_helper_fsqrt_s);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fsqrt_d(DisasContext *ctx, arg_fclass01 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_helper_fsqrt_d);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_frnd_f(DisasContext *ctx, arg_fclass01 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_helper_frnd_s);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_frnd_d(DisasContext *ctx, arg_fclass01 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_helper_frnd_d);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static void gen_fneg_f(TCGv_i32 dst, TCGv_env unused, TCGv_i32 src)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
tcg_gen_xori_i32(dst, src, INT32_MIN);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fneg_f(DisasContext *ctx, arg_fclass01 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_fneg_f);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_fneg_d(TCGv_i64 dst, TCGv_env unused, TCGv_i64 src)
|
|
|
|
{
|
|
|
|
tcg_gen_xori_i64(dst, src, INT64_MIN);
|
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fneg_d(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_fneg_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_fnegabs_f(TCGv_i32 dst, TCGv_env unused, TCGv_i32 src)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
|
|
|
tcg_gen_ori_i32(dst, src, INT32_MIN);
|
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fnegabs_f(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_fnegabs_f);
|
|
|
|
}
|
|
|
|
|
2016-12-16 02:04:19 +03:00
|
|
|
static void gen_fnegabs_d(TCGv_i64 dst, TCGv_env unused, TCGv_i64 src)
|
|
|
|
{
|
|
|
|
tcg_gen_ori_i64(dst, src, INT64_MIN);
|
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fnegabs_d(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_fnegabs_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Float class 1
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool trans_fcnv_d_f(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wed(ctx, a->t, a->r, gen_helper_fcnv_d_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_f_d(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dew(ctx, a->t, a->r, gen_helper_fcnv_s_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_w_f(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_helper_fcnv_w_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_q_f(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wed(ctx, a->t, a->r, gen_helper_fcnv_dw_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_w_d(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dew(ctx, a->t, a->r, gen_helper_fcnv_w_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_q_d(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_helper_fcnv_dw_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_f_w(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_helper_fcnv_s_w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_d_w(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wed(ctx, a->t, a->r, gen_helper_fcnv_d_w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_f_q(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dew(ctx, a->t, a->r, gen_helper_fcnv_s_dw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_d_q(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_helper_fcnv_d_dw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_t_f_w(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_helper_fcnv_t_s_w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_t_d_w(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wed(ctx, a->t, a->r, gen_helper_fcnv_t_d_w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_t_f_q(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dew(ctx, a->t, a->r, gen_helper_fcnv_t_s_dw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_t_d_q(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_helper_fcnv_t_d_dw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_uw_f(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_helper_fcnv_uw_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_uq_f(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wed(ctx, a->t, a->r, gen_helper_fcnv_udw_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_uw_d(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dew(ctx, a->t, a->r, gen_helper_fcnv_uw_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_uq_d(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_helper_fcnv_udw_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_f_uw(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_helper_fcnv_s_uw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_d_uw(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wed(ctx, a->t, a->r, gen_helper_fcnv_d_uw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_f_uq(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dew(ctx, a->t, a->r, gen_helper_fcnv_s_udw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_d_uq(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_helper_fcnv_d_udw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_t_f_uw(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wew(ctx, a->t, a->r, gen_helper_fcnv_t_s_uw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_t_d_uw(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_wed(ctx, a->t, a->r, gen_helper_fcnv_t_d_uw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_t_f_uq(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dew(ctx, a->t, a->r, gen_helper_fcnv_t_s_udw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fcnv_t_d_uq(DisasContext *ctx, arg_fclass01 *a)
|
|
|
|
{
|
|
|
|
return do_fop_ded(ctx, a->t, a->r, gen_helper_fcnv_t_d_udw);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Float class 2
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool trans_fcmp_f(DisasContext *ctx, arg_fclass2 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
|
|
|
TCGv_i32 ta, tb, tc, ty;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
ta = load_frw0_i32(a->r1);
|
|
|
|
tb = load_frw0_i32(a->r2);
|
2021-07-08 22:41:29 +03:00
|
|
|
ty = tcg_constant_i32(a->y);
|
|
|
|
tc = tcg_constant_i32(a->c);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_fcmp_s(tcg_env, ta, tb, ty, tc);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fcmp_d(DisasContext *ctx, arg_fclass2 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
|
|
|
TCGv_i64 ta, tb;
|
|
|
|
TCGv_i32 tc, ty;
|
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
ta = load_frd0(a->r1);
|
|
|
|
tb = load_frd0(a->r2);
|
2021-07-08 22:41:29 +03:00
|
|
|
ty = tcg_constant_i32(a->y);
|
|
|
|
tc = tcg_constant_i32(a->c);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_fcmp_d(tcg_env, ta, tb, ty, tc);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_ftest(DisasContext *ctx, arg_ftest *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 t;
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2023-10-18 07:47:02 +03:00
|
|
|
t = tcg_temp_new_i64();
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_ld32u_i64(t, tcg_env, offsetof(CPUHPPAState, fr0_shadow));
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
if (a->y == 1) {
|
|
|
|
int mask;
|
|
|
|
bool inv = false;
|
|
|
|
|
|
|
|
switch (a->c) {
|
|
|
|
case 0: /* simple */
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(t, t, 0x4000000);
|
2024-03-25 20:30:19 +03:00
|
|
|
ctx->null_cond = cond_make_ti(TCG_COND_NE, t, 0);
|
2018-02-13 10:01:47 +03:00
|
|
|
goto done;
|
|
|
|
case 2: /* rej */
|
|
|
|
inv = true;
|
|
|
|
/* fallthru */
|
|
|
|
case 1: /* acc */
|
|
|
|
mask = 0x43ff800;
|
|
|
|
break;
|
|
|
|
case 6: /* rej8 */
|
|
|
|
inv = true;
|
|
|
|
/* fallthru */
|
|
|
|
case 5: /* acc8 */
|
|
|
|
mask = 0x43f8000;
|
|
|
|
break;
|
|
|
|
case 9: /* acc6 */
|
|
|
|
mask = 0x43e0000;
|
|
|
|
break;
|
|
|
|
case 13: /* acc4 */
|
|
|
|
mask = 0x4380000;
|
|
|
|
break;
|
|
|
|
case 17: /* acc2 */
|
|
|
|
mask = 0x4200000;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gen_illegal(ctx);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (inv) {
|
2023-10-18 07:31:08 +03:00
|
|
|
TCGv_i64 c = tcg_constant_i64(mask);
|
|
|
|
tcg_gen_or_i64(t, t, c);
|
2024-03-25 20:30:19 +03:00
|
|
|
ctx->null_cond = cond_make_tt(TCG_COND_EQ, t, c);
|
2018-02-13 10:01:47 +03:00
|
|
|
} else {
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_andi_i64(t, t, mask);
|
2024-03-25 20:30:19 +03:00
|
|
|
ctx->null_cond = cond_make_ti(TCG_COND_EQ, t, 0);
|
2018-02-13 10:01:47 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
unsigned cbit = (a->y ^ 1) - 1;
|
|
|
|
|
2023-10-18 07:31:08 +03:00
|
|
|
tcg_gen_extract_i64(t, t, 21 - cbit, 1);
|
2024-03-25 20:30:19 +03:00
|
|
|
ctx->null_cond = cond_make_ti(TCG_COND_NE, t, 0);
|
2018-02-13 10:01:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
/*
|
|
|
|
* Float class 2
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool trans_fadd_f(DisasContext *ctx, arg_fclass3 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_weww(ctx, a->t, a->r1, a->r2, gen_helper_fadd_s);
|
|
|
|
}
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fadd_d(DisasContext *ctx, arg_fclass3 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dedd(ctx, a->t, a->r1, a->r2, gen_helper_fadd_d);
|
|
|
|
}
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fsub_f(DisasContext *ctx, arg_fclass3 *a)
|
|
|
|
{
|
|
|
|
return do_fop_weww(ctx, a->t, a->r1, a->r2, gen_helper_fsub_s);
|
|
|
|
}
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fsub_d(DisasContext *ctx, arg_fclass3 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dedd(ctx, a->t, a->r1, a->r2, gen_helper_fsub_d);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
static bool trans_fmpy_f(DisasContext *ctx, arg_fclass3 *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 10:01:47 +03:00
|
|
|
return do_fop_weww(ctx, a->t, a->r1, a->r2, gen_helper_fmpy_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fmpy_d(DisasContext *ctx, arg_fclass3 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dedd(ctx, a->t, a->r1, a->r2, gen_helper_fmpy_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fdiv_f(DisasContext *ctx, arg_fclass3 *a)
|
|
|
|
{
|
|
|
|
return do_fop_weww(ctx, a->t, a->r1, a->r2, gen_helper_fdiv_s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fdiv_d(DisasContext *ctx, arg_fclass3 *a)
|
|
|
|
{
|
|
|
|
return do_fop_dedd(ctx, a->t, a->r1, a->r2, gen_helper_fdiv_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_xmpyu(DisasContext *ctx, arg_xmpyu *a)
|
|
|
|
{
|
|
|
|
TCGv_i64 x, y;
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-13 10:01:47 +03:00
|
|
|
x = load_frw0_i64(a->r1);
|
|
|
|
y = load_frw0_i64(a->r2);
|
|
|
|
tcg_gen_mul_i64(x, x, y);
|
|
|
|
save_frd(a->t, x);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert the fmpyadd single-precision register encodings to standard. */
|
|
|
|
static inline int fmpyadd_s_reg(unsigned r)
|
|
|
|
{
|
|
|
|
return (r & 16) * 2 + 16 + (r & 15);
|
|
|
|
}
|
|
|
|
|
2018-02-12 10:23:54 +03:00
|
|
|
static bool do_fmpyadd_s(DisasContext *ctx, arg_mpyadd *a, bool is_sub)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-12 10:23:54 +03:00
|
|
|
int tm = fmpyadd_s_reg(a->tm);
|
|
|
|
int ra = fmpyadd_s_reg(a->ra);
|
|
|
|
int ta = fmpyadd_s_reg(a->ta);
|
|
|
|
int rm2 = fmpyadd_s_reg(a->rm2);
|
|
|
|
int rm1 = fmpyadd_s_reg(a->rm1);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
2018-02-12 10:23:54 +03:00
|
|
|
do_fop_weww(ctx, tm, rm1, rm2, gen_helper_fmpy_s);
|
|
|
|
do_fop_weww(ctx, ta, ta, ra,
|
|
|
|
is_sub ? gen_helper_fsub_s : gen_helper_fadd_s);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-12 10:23:54 +03:00
|
|
|
static bool trans_fmpyadd_f(DisasContext *ctx, arg_mpyadd *a)
|
|
|
|
{
|
|
|
|
return do_fmpyadd_s(ctx, a, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fmpysub_f(DisasContext *ctx, arg_mpyadd *a)
|
|
|
|
{
|
|
|
|
return do_fmpyadd_s(ctx, a, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool do_fmpyadd_d(DisasContext *ctx, arg_mpyadd *a, bool is_sub)
|
|
|
|
{
|
|
|
|
nullify_over(ctx);
|
|
|
|
|
|
|
|
do_fop_dedd(ctx, a->tm, a->rm1, a->rm2, gen_helper_fmpy_d);
|
|
|
|
do_fop_dedd(ctx, a->ta, a->ta, a->ra,
|
|
|
|
is_sub ? gen_helper_fsub_d : gen_helper_fadd_d);
|
|
|
|
|
|
|
|
return nullify_end(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fmpyadd_d(DisasContext *ctx, arg_mpyadd *a)
|
|
|
|
{
|
|
|
|
return do_fmpyadd_d(ctx, a, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_fmpysub_d(DisasContext *ctx, arg_mpyadd *a)
|
|
|
|
{
|
|
|
|
return do_fmpyadd_d(ctx, a, true);
|
|
|
|
}
|
|
|
|
|
2018-02-13 07:08:51 +03:00
|
|
|
static bool trans_fmpyfadd_f(DisasContext *ctx, arg_fmpyfadd_f *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 07:08:51 +03:00
|
|
|
TCGv_i32 x, y, z;
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
2018-02-13 07:08:51 +03:00
|
|
|
x = load_frw0_i32(a->rm1);
|
|
|
|
y = load_frw0_i32(a->rm2);
|
|
|
|
z = load_frw0_i32(a->ra3);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-13 07:08:51 +03:00
|
|
|
if (a->neg) {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_fmpynfadd_s(x, tcg_env, x, y, z);
|
2016-12-16 02:04:19 +03:00
|
|
|
} else {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_fmpyfadd_s(x, tcg_env, x, y, z);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 07:08:51 +03:00
|
|
|
save_frw_i32(a->t, x);
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 07:08:51 +03:00
|
|
|
static bool trans_fmpyfadd_d(DisasContext *ctx, arg_fmpyfadd_d *a)
|
2016-12-16 02:04:19 +03:00
|
|
|
{
|
2018-02-13 07:08:51 +03:00
|
|
|
TCGv_i64 x, y, z;
|
2016-12-16 02:04:19 +03:00
|
|
|
|
|
|
|
nullify_over(ctx);
|
2018-02-13 07:08:51 +03:00
|
|
|
x = load_frd0(a->rm1);
|
|
|
|
y = load_frd0(a->rm2);
|
|
|
|
z = load_frd0(a->ra3);
|
2016-12-16 02:04:19 +03:00
|
|
|
|
2018-02-13 07:08:51 +03:00
|
|
|
if (a->neg) {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_fmpynfadd_d(x, tcg_env, x, y, z);
|
2016-12-16 02:04:19 +03:00
|
|
|
} else {
|
2023-09-14 02:37:36 +03:00
|
|
|
gen_helper_fmpyfadd_d(x, tcg_env, x, y, z);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2018-02-13 07:08:51 +03:00
|
|
|
save_frd(a->t, x);
|
2018-02-12 04:09:30 +03:00
|
|
|
return nullify_end(ctx);
|
2016-12-16 02:04:19 +03:00
|
|
|
}
|
|
|
|
|
2024-03-26 20:08:53 +03:00
|
|
|
/* Emulate PDC BTLB, called by SeaBIOS-hppa */
|
|
|
|
static bool trans_diag_btlb(DisasContext *ctx, arg_diag_btlb *a)
|
2019-03-11 22:15:57 +03:00
|
|
|
{
|
2023-09-13 12:25:09 +03:00
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
2024-03-26 20:08:53 +03:00
|
|
|
nullify_over(ctx);
|
|
|
|
gen_helper_diag_btlb(tcg_env);
|
|
|
|
return nullify_end(ctx);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print char in %r26 to first serial console, used by SeaBIOS-hppa */
|
|
|
|
static bool trans_diag_cout(DisasContext *ctx, arg_diag_cout *a)
|
|
|
|
{
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
|
|
|
#ifndef CONFIG_USER_ONLY
|
|
|
|
nullify_over(ctx);
|
|
|
|
gen_helper_diag_console_output(tcg_env);
|
|
|
|
return nullify_end(ctx);
|
2023-09-14 02:37:36 +03:00
|
|
|
#endif
|
2024-03-26 20:08:53 +03:00
|
|
|
}
|
|
|
|
|
2024-03-26 20:39:40 +03:00
|
|
|
static bool trans_diag_getshadowregs_pa1(DisasContext *ctx, arg_empty *a)
|
|
|
|
{
|
|
|
|
return !ctx->is_pa20 && do_getshadowregs(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_diag_getshadowregs_pa2(DisasContext *ctx, arg_empty *a)
|
|
|
|
{
|
|
|
|
return ctx->is_pa20 && do_getshadowregs(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_diag_putshadowregs_pa1(DisasContext *ctx, arg_empty *a)
|
|
|
|
{
|
|
|
|
return !ctx->is_pa20 && do_putshadowregs(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool trans_diag_putshadowregs_pa2(DisasContext *ctx, arg_empty *a)
|
|
|
|
{
|
|
|
|
return ctx->is_pa20 && do_putshadowregs(ctx);
|
|
|
|
}
|
|
|
|
|
2024-03-26 20:08:53 +03:00
|
|
|
static bool trans_diag_unimp(DisasContext *ctx, arg_diag_unimp *a)
|
|
|
|
{
|
|
|
|
CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
|
2023-09-14 02:37:36 +03:00
|
|
|
qemu_log_mask(LOG_UNIMP, "DIAG opcode 0x%04x ignored\n", a->i);
|
|
|
|
return true;
|
2019-03-11 22:15:57 +03:00
|
|
|
}
|
|
|
|
|
2018-02-20 04:51:58 +03:00
|
|
|
static void hppa_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
|
2016-12-15 22:26:14 +03:00
|
|
|
{
|
2017-07-15 11:25:35 +03:00
|
|
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
2017-11-02 14:47:37 +03:00
|
|
|
int bound;
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2017-07-15 11:25:35 +03:00
|
|
|
ctx->cs = cs;
|
2017-11-06 23:10:33 +03:00
|
|
|
ctx->tb_flags = ctx->base.tb->flags;
|
2023-09-18 01:31:47 +03:00
|
|
|
ctx->is_pa20 = hppa_is_pa20(cpu_env(cs));
|
2017-10-09 20:17:24 +03:00
|
|
|
|
|
|
|
#ifdef CONFIG_USER_ONLY
|
2023-08-07 12:32:09 +03:00
|
|
|
ctx->privilege = MMU_IDX_TO_PRIV(MMU_USER_IDX);
|
2017-10-09 20:17:24 +03:00
|
|
|
ctx->mmu_idx = MMU_USER_IDX;
|
2024-03-22 05:47:14 +03:00
|
|
|
ctx->iaoq_first = ctx->base.pc_first | ctx->privilege;
|
|
|
|
ctx->iaq_b.disp = ctx->base.tb->cs_base - ctx->base.pc_first;
|
2021-12-27 18:01:26 +03:00
|
|
|
ctx->unalign = (ctx->tb_flags & TB_FLAG_UNALIGN ? MO_UNALN : MO_ALIGN);
|
2017-10-09 20:17:24 +03:00
|
|
|
#else
|
2017-11-06 23:10:33 +03:00
|
|
|
ctx->privilege = (ctx->tb_flags >> TB_FLAG_PRIV_SHIFT) & 3;
|
2023-11-02 01:17:04 +03:00
|
|
|
ctx->mmu_idx = (ctx->tb_flags & PSW_D
|
|
|
|
? PRIV_P_TO_MMU_IDX(ctx->privilege, ctx->tb_flags & PSW_P)
|
2023-11-07 23:13:17 +03:00
|
|
|
: ctx->tb_flags & PSW_W ? MMU_ABS_W_IDX : MMU_ABS_IDX);
|
2017-10-09 20:17:24 +03:00
|
|
|
|
2017-10-22 08:53:35 +03:00
|
|
|
/* Recover the IAOQ values from the GVA + PRIV. */
|
|
|
|
uint64_t cs_base = ctx->base.tb->cs_base;
|
|
|
|
uint64_t iasq_f = cs_base & ~0xffffffffull;
|
|
|
|
int32_t diff = cs_base;
|
|
|
|
|
2024-03-22 05:47:14 +03:00
|
|
|
ctx->iaoq_first = (ctx->base.pc_first & ~iasq_f) + ctx->privilege;
|
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
if (diff) {
|
2024-03-22 05:47:14 +03:00
|
|
|
ctx->iaq_b.disp = diff;
|
2024-03-22 02:56:44 +03:00
|
|
|
} else {
|
|
|
|
ctx->iaq_b.base = cpu_iaoq_b;
|
|
|
|
ctx->iaq_b.space = cpu_iasq_b;
|
|
|
|
}
|
2017-10-22 08:53:35 +03:00
|
|
|
#endif
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2023-10-18 20:24:33 +03:00
|
|
|
ctx->zero = tcg_constant_i64(0);
|
|
|
|
|
2017-10-09 20:17:24 +03:00
|
|
|
/* Bound the number of instructions by those left on the page. */
|
|
|
|
bound = -(ctx->base.pc_first | TARGET_PAGE_MASK) / 4;
|
2018-02-20 04:51:58 +03:00
|
|
|
ctx->base.max_insns = MIN(ctx->base.max_insns, bound);
|
2017-07-15 11:25:35 +03:00
|
|
|
}
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2017-07-15 11:25:35 +03:00
|
|
|
static void hppa_tr_tb_start(DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2017-10-09 20:17:24 +03:00
|
|
|
/* Seed the nullification status from PSW[N], as saved in TB->FLAGS. */
|
2017-07-15 11:25:35 +03:00
|
|
|
ctx->null_cond = cond_make_f();
|
|
|
|
ctx->psw_n_nonzero = false;
|
2017-11-06 23:10:33 +03:00
|
|
|
if (ctx->tb_flags & PSW_N) {
|
2017-07-15 11:25:35 +03:00
|
|
|
ctx->null_cond.c = TCG_COND_ALWAYS;
|
|
|
|
ctx->psw_n_nonzero = true;
|
2016-12-15 22:58:17 +03:00
|
|
|
}
|
2017-07-15 11:25:35 +03:00
|
|
|
ctx->null_lab = NULL;
|
|
|
|
}
|
2016-12-15 22:58:17 +03:00
|
|
|
|
2017-07-15 11:25:35 +03:00
|
|
|
static void hppa_tr_insn_start(DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
tcg_debug_assert(!iaqe_variable(&ctx->iaq_f));
|
2024-03-22 05:47:14 +03:00
|
|
|
tcg_gen_insn_start(ctx->iaoq_first + ctx->iaq_f.disp,
|
|
|
|
(iaqe_variable(&ctx->iaq_b) ? -1 :
|
|
|
|
ctx->iaoq_first + ctx->iaq_b.disp), 0);
|
2024-04-06 23:59:02 +03:00
|
|
|
ctx->insn_start_updated = false;
|
2017-07-15 11:25:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void hppa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
2023-09-14 03:22:49 +03:00
|
|
|
CPUHPPAState *env = cpu_env(cs);
|
2017-07-15 11:25:35 +03:00
|
|
|
DisasJumpType ret;
|
|
|
|
|
|
|
|
/* Execute one insn. */
|
2017-10-09 19:51:30 +03:00
|
|
|
#ifdef CONFIG_USER_ONLY
|
2017-10-22 08:53:35 +03:00
|
|
|
if (ctx->base.pc_next < TARGET_PAGE_SIZE) {
|
2018-02-12 04:09:30 +03:00
|
|
|
do_page_zero(ctx);
|
|
|
|
ret = ctx->base.is_jmp;
|
2017-07-15 11:25:35 +03:00
|
|
|
assert(ret != DISAS_NEXT);
|
2017-10-09 19:51:30 +03:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
2017-07-15 11:25:35 +03:00
|
|
|
/* Always fetch the insn, even if nullified, so that we check
|
|
|
|
the page permissions for execute. */
|
2021-08-10 01:32:59 +03:00
|
|
|
uint32_t insn = translator_ldl(env, &ctx->base, ctx->base.pc_next);
|
2017-07-15 11:25:35 +03:00
|
|
|
|
2024-03-22 02:56:44 +03:00
|
|
|
/*
|
|
|
|
* Set up the IA queue for the next insn.
|
|
|
|
* This will be overwritten by a branch.
|
|
|
|
*/
|
|
|
|
ctx->iaq_n = NULL;
|
|
|
|
memset(&ctx->iaq_j, 0, sizeof(ctx->iaq_j));
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2017-07-15 11:25:35 +03:00
|
|
|
if (unlikely(ctx->null_cond.c == TCG_COND_ALWAYS)) {
|
|
|
|
ctx->null_cond.c = TCG_COND_NEVER;
|
|
|
|
ret = DISAS_NEXT;
|
|
|
|
} else {
|
2017-10-11 23:19:11 +03:00
|
|
|
ctx->insn = insn;
|
2018-02-17 23:11:32 +03:00
|
|
|
if (!decode(ctx, insn)) {
|
|
|
|
gen_illegal(ctx);
|
|
|
|
}
|
2018-02-12 04:09:30 +03:00
|
|
|
ret = ctx->base.is_jmp;
|
2017-07-15 11:25:35 +03:00
|
|
|
assert(ctx->null_lab == NULL);
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
2017-07-15 11:25:35 +03:00
|
|
|
}
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2024-03-23 09:13:40 +03:00
|
|
|
/* If the TranslationBlock must end, do so. */
|
|
|
|
ctx->base.pc_next += 4;
|
|
|
|
if (ret != DISAS_NEXT) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Note this also detects a priority change. */
|
2024-03-22 02:56:44 +03:00
|
|
|
if (iaqe_variable(&ctx->iaq_b)
|
|
|
|
|| ctx->iaq_b.disp != ctx->iaq_f.disp + 4) {
|
2024-03-23 09:13:40 +03:00
|
|
|
ctx->base.is_jmp = DISAS_IAQ_N_STALE;
|
|
|
|
return;
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
2024-03-23 09:13:40 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Advance the insn queue.
|
|
|
|
* The only exit now is DISAS_TOO_MANY from the translator loop.
|
|
|
|
*/
|
2024-03-22 02:56:44 +03:00
|
|
|
ctx->iaq_f.disp = ctx->iaq_b.disp;
|
|
|
|
if (!ctx->iaq_n) {
|
|
|
|
ctx->iaq_b.disp += 4;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If IAQ_Next is variable in any way, we need to copy into the
|
|
|
|
* IAQ_Back globals, in case the next insn raises an exception.
|
|
|
|
*/
|
|
|
|
if (ctx->iaq_n->base) {
|
|
|
|
copy_iaoq_entry(ctx, cpu_iaoq_b, ctx->iaq_n);
|
|
|
|
ctx->iaq_b.base = cpu_iaoq_b;
|
|
|
|
ctx->iaq_b.disp = 0;
|
|
|
|
} else {
|
|
|
|
ctx->iaq_b.disp = ctx->iaq_n->disp;
|
2017-07-15 11:25:35 +03:00
|
|
|
}
|
2024-03-22 02:56:44 +03:00
|
|
|
if (ctx->iaq_n->space) {
|
|
|
|
tcg_gen_mov_i64(cpu_iasq_b, ctx->iaq_n->space);
|
|
|
|
ctx->iaq_b.space = cpu_iasq_b;
|
2024-03-23 09:45:21 +03:00
|
|
|
}
|
2017-07-15 11:25:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void hppa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
|
|
|
|
{
|
|
|
|
DisasContext *ctx = container_of(dcbase, DisasContext, base);
|
2017-10-09 17:44:30 +03:00
|
|
|
DisasJumpType is_jmp = ctx->base.is_jmp;
|
2024-03-23 09:13:40 +03:00
|
|
|
/* Assume the insn queue has not been advanced. */
|
2024-03-22 02:56:44 +03:00
|
|
|
DisasIAQE *f = &ctx->iaq_b;
|
|
|
|
DisasIAQE *b = ctx->iaq_n;
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2017-10-09 17:44:30 +03:00
|
|
|
switch (is_jmp) {
|
2017-07-15 09:56:35 +03:00
|
|
|
case DISAS_NORETURN:
|
2016-12-15 22:26:14 +03:00
|
|
|
break;
|
2017-07-15 11:25:35 +03:00
|
|
|
case DISAS_TOO_MANY:
|
2024-03-23 09:13:40 +03:00
|
|
|
/* The insn queue has not been advanced. */
|
2024-03-22 02:56:44 +03:00
|
|
|
f = &ctx->iaq_f;
|
|
|
|
b = &ctx->iaq_b;
|
2024-03-23 09:13:40 +03:00
|
|
|
/* FALLTHRU */
|
2017-07-15 09:56:35 +03:00
|
|
|
case DISAS_IAQ_N_STALE:
|
2024-03-22 02:56:44 +03:00
|
|
|
if (use_goto_tb(ctx, f, b)
|
2024-03-23 09:13:40 +03:00
|
|
|
&& (ctx->null_cond.c == TCG_COND_NEVER
|
|
|
|
|| ctx->null_cond.c == TCG_COND_ALWAYS)) {
|
|
|
|
nullify_set(ctx, ctx->null_cond.c == TCG_COND_ALWAYS);
|
2024-03-22 02:56:44 +03:00
|
|
|
gen_goto_tb(ctx, 0, f, b);
|
2024-03-23 09:13:40 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* FALLTHRU */
|
2017-10-09 17:44:30 +03:00
|
|
|
case DISAS_IAQ_N_STALE_EXIT:
|
2024-03-22 02:56:44 +03:00
|
|
|
install_iaq_entries(ctx, f, b);
|
2017-07-15 11:25:35 +03:00
|
|
|
nullify_save(ctx);
|
2024-03-23 09:13:40 +03:00
|
|
|
if (is_jmp == DISAS_IAQ_N_STALE_EXIT) {
|
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2021-07-19 10:19:26 +03:00
|
|
|
break;
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
2019-03-13 01:24:38 +03:00
|
|
|
/* FALLTHRU */
|
2024-03-23 09:13:40 +03:00
|
|
|
case DISAS_IAQ_N_UPDATED:
|
|
|
|
tcg_gen_lookup_and_goto_ptr();
|
|
|
|
break;
|
2019-03-13 01:24:38 +03:00
|
|
|
case DISAS_EXIT:
|
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2016-12-15 22:26:14 +03:00
|
|
|
break;
|
|
|
|
default:
|
2017-07-15 11:25:35 +03:00
|
|
|
g_assert_not_reached();
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
2017-07-15 11:25:35 +03:00
|
|
|
}
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2022-04-17 21:29:52 +03:00
|
|
|
static void hppa_tr_disas_log(const DisasContextBase *dcbase,
|
|
|
|
CPUState *cs, FILE *logfile)
|
2017-07-15 11:25:35 +03:00
|
|
|
{
|
2017-10-22 08:53:35 +03:00
|
|
|
target_ulong pc = dcbase->pc_first;
|
2016-12-15 22:26:14 +03:00
|
|
|
|
2017-10-09 19:51:30 +03:00
|
|
|
#ifdef CONFIG_USER_ONLY
|
|
|
|
switch (pc) {
|
2017-07-15 11:25:35 +03:00
|
|
|
case 0x00:
|
2022-04-17 21:29:52 +03:00
|
|
|
fprintf(logfile, "IN:\n0x00000000: (null)\n");
|
2017-10-09 19:51:30 +03:00
|
|
|
return;
|
2017-07-15 11:25:35 +03:00
|
|
|
case 0xb0:
|
2022-04-17 21:29:52 +03:00
|
|
|
fprintf(logfile, "IN:\n0x000000b0: light-weight-syscall\n");
|
2017-10-09 19:51:30 +03:00
|
|
|
return;
|
2017-07-15 11:25:35 +03:00
|
|
|
case 0xe0:
|
2022-04-17 21:29:52 +03:00
|
|
|
fprintf(logfile, "IN:\n0x000000e0: set-thread-pointer-syscall\n");
|
2017-10-09 19:51:30 +03:00
|
|
|
return;
|
2017-07-15 11:25:35 +03:00
|
|
|
case 0x100:
|
2022-04-17 21:29:52 +03:00
|
|
|
fprintf(logfile, "IN:\n0x00000100: syscall\n");
|
2017-10-09 19:51:30 +03:00
|
|
|
return;
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|
2017-10-09 19:51:30 +03:00
|
|
|
#endif
|
|
|
|
|
2022-04-17 21:29:52 +03:00
|
|
|
fprintf(logfile, "IN: %s\n", lookup_symbol(pc));
|
|
|
|
target_disas(logfile, cs, pc, dcbase->tb->size);
|
2017-07-15 11:25:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static const TranslatorOps hppa_tr_ops = {
|
|
|
|
.init_disas_context = hppa_tr_init_disas_context,
|
|
|
|
.tb_start = hppa_tr_tb_start,
|
|
|
|
.insn_start = hppa_tr_insn_start,
|
|
|
|
.translate_insn = hppa_tr_translate_insn,
|
|
|
|
.tb_stop = hppa_tr_tb_stop,
|
|
|
|
.disas_log = hppa_tr_disas_log,
|
|
|
|
};
|
|
|
|
|
2023-01-29 04:19:22 +03:00
|
|
|
void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns,
|
2024-01-19 17:39:58 +03:00
|
|
|
vaddr pc, void *host_pc)
|
2017-07-15 11:25:35 +03:00
|
|
|
{
|
2024-03-22 02:56:44 +03:00
|
|
|
DisasContext ctx = { };
|
2022-08-11 23:48:03 +03:00
|
|
|
translator_loop(cs, tb, max_insns, pc, host_pc, &hppa_tr_ops, &ctx.base);
|
2016-12-15 22:26:14 +03:00
|
|
|
}
|