2021-02-08 08:45:54 +03:00
|
|
|
/*
|
2023-03-07 05:58:28 +03:00
|
|
|
* Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
2021-02-08 08:45:54 +03:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HEXAGON_CPU_H
|
|
|
|
#define HEXAGON_CPU_H
|
|
|
|
|
|
|
|
#include "fpu/softfloat-types.h"
|
|
|
|
|
|
|
|
#include "exec/cpu-defs.h"
|
|
|
|
#include "hex_regs.h"
|
2021-03-17 19:48:57 +03:00
|
|
|
#include "mmvec/mmvec.h"
|
2022-02-11 06:30:34 +03:00
|
|
|
#include "qom/object.h"
|
2022-02-14 19:16:34 +03:00
|
|
|
#include "hw/core/cpu.h"
|
2022-11-10 20:49:35 +03:00
|
|
|
#include "hw/registerfields.h"
|
2021-02-08 08:45:54 +03:00
|
|
|
|
|
|
|
#define NUM_PREGS 4
|
|
|
|
#define TOTAL_PER_THREAD_REGS 64
|
|
|
|
|
|
|
|
#define SLOTS_MAX 4
|
|
|
|
#define STORES_MAX 2
|
|
|
|
#define REG_WRITES_MAX 32
|
|
|
|
#define PRED_WRITES_MAX 5 /* 4 insns + endloop */
|
2021-03-17 19:48:57 +03:00
|
|
|
#define VSTORES_MAX 2
|
2021-02-08 08:45:54 +03:00
|
|
|
|
|
|
|
#define TYPE_HEXAGON_CPU "hexagon-cpu"
|
|
|
|
|
|
|
|
#define HEXAGON_CPU_TYPE_SUFFIX "-" TYPE_HEXAGON_CPU
|
|
|
|
#define HEXAGON_CPU_TYPE_NAME(name) (name HEXAGON_CPU_TYPE_SUFFIX)
|
|
|
|
#define CPU_RESOLVING_TYPE TYPE_HEXAGON_CPU
|
|
|
|
|
|
|
|
#define TYPE_HEXAGON_CPU_V67 HEXAGON_CPU_TYPE_NAME("v67")
|
2023-04-28 01:40:49 +03:00
|
|
|
#define TYPE_HEXAGON_CPU_V68 HEXAGON_CPU_TYPE_NAME("v68")
|
|
|
|
#define TYPE_HEXAGON_CPU_V69 HEXAGON_CPU_TYPE_NAME("v69")
|
|
|
|
#define TYPE_HEXAGON_CPU_V71 HEXAGON_CPU_TYPE_NAME("v71")
|
|
|
|
#define TYPE_HEXAGON_CPU_V73 HEXAGON_CPU_TYPE_NAME("v73")
|
2021-02-08 08:45:54 +03:00
|
|
|
|
|
|
|
#define MMU_USER_IDX 0
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
target_ulong va;
|
|
|
|
uint8_t width;
|
|
|
|
uint32_t data32;
|
|
|
|
uint64_t data64;
|
|
|
|
} MemLog;
|
|
|
|
|
2021-03-17 19:48:57 +03:00
|
|
|
typedef struct {
|
|
|
|
target_ulong va;
|
|
|
|
int size;
|
|
|
|
DECLARE_BITMAP(mask, MAX_VEC_SIZE_BYTES) QEMU_ALIGNED(16);
|
|
|
|
MMVector data QEMU_ALIGNED(16);
|
|
|
|
} VStoreLog;
|
|
|
|
|
2021-02-08 08:45:54 +03:00
|
|
|
#define EXEC_STATUS_OK 0x0000
|
|
|
|
#define EXEC_STATUS_STOP 0x0002
|
|
|
|
#define EXEC_STATUS_REPLAY 0x0010
|
|
|
|
#define EXEC_STATUS_LOCKED 0x0020
|
|
|
|
#define EXEC_STATUS_EXCEPTION 0x0100
|
|
|
|
|
|
|
|
|
|
|
|
#define EXCEPTION_DETECTED (env->status & EXEC_STATUS_EXCEPTION)
|
|
|
|
#define REPLAY_DETECTED (env->status & EXEC_STATUS_REPLAY)
|
|
|
|
#define CLEAR_EXCEPTION (env->status &= (~EXEC_STATUS_EXCEPTION))
|
|
|
|
#define SET_EXCEPTION (env->status |= EXEC_STATUS_EXCEPTION)
|
|
|
|
|
2021-03-17 19:48:57 +03:00
|
|
|
/* Maximum number of vector temps in a packet */
|
|
|
|
#define VECTOR_TEMPS_MAX 4
|
|
|
|
|
2022-02-07 15:35:58 +03:00
|
|
|
typedef struct CPUArchState {
|
2021-02-08 08:45:54 +03:00
|
|
|
target_ulong gpr[TOTAL_PER_THREAD_REGS];
|
|
|
|
target_ulong pred[NUM_PREGS];
|
|
|
|
target_ulong branch_taken;
|
|
|
|
|
|
|
|
/* For comparing with LLDB on target - see adjust_stack_ptrs function */
|
|
|
|
target_ulong last_pc_dumped;
|
|
|
|
target_ulong stack_start;
|
|
|
|
|
|
|
|
uint8_t slot_cancelled;
|
|
|
|
target_ulong new_value[TOTAL_PER_THREAD_REGS];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only used when HEX_DEBUG is on, but unconditionally included
|
|
|
|
* to reduce recompile time when turning HEX_DEBUG on/off.
|
|
|
|
*/
|
|
|
|
target_ulong this_PC;
|
|
|
|
target_ulong reg_written[TOTAL_PER_THREAD_REGS];
|
|
|
|
|
|
|
|
target_ulong new_pred_value[NUM_PREGS];
|
|
|
|
target_ulong pred_written;
|
|
|
|
|
|
|
|
MemLog mem_log_stores[STORES_MAX];
|
|
|
|
target_ulong pkt_has_store_s1;
|
|
|
|
target_ulong dczero_addr;
|
|
|
|
|
|
|
|
float_status fp_status;
|
|
|
|
|
|
|
|
target_ulong llsc_addr;
|
|
|
|
target_ulong llsc_val;
|
|
|
|
uint64_t llsc_val_i64;
|
|
|
|
|
2021-03-17 19:48:57 +03:00
|
|
|
MMVector VRegs[NUM_VREGS] QEMU_ALIGNED(16);
|
|
|
|
MMVector future_VRegs[VECTOR_TEMPS_MAX] QEMU_ALIGNED(16);
|
|
|
|
MMVector tmp_VRegs[VECTOR_TEMPS_MAX] QEMU_ALIGNED(16);
|
|
|
|
|
|
|
|
MMQReg QRegs[NUM_QREGS] QEMU_ALIGNED(16);
|
|
|
|
MMQReg future_QRegs[NUM_QREGS] QEMU_ALIGNED(16);
|
|
|
|
|
|
|
|
/* Temporaries used within instructions */
|
|
|
|
MMVectorPair VuuV QEMU_ALIGNED(16);
|
|
|
|
MMVectorPair VvvV QEMU_ALIGNED(16);
|
|
|
|
MMVectorPair VxxV QEMU_ALIGNED(16);
|
|
|
|
MMVector vtmp QEMU_ALIGNED(16);
|
|
|
|
MMQReg qtmp QEMU_ALIGNED(16);
|
|
|
|
|
|
|
|
VStoreLog vstore[VSTORES_MAX];
|
|
|
|
target_ulong vstore_pending[VSTORES_MAX];
|
|
|
|
bool vtcm_pending;
|
|
|
|
VTCMStoreLog vtcm_log;
|
2022-02-07 15:35:58 +03:00
|
|
|
} CPUHexagonState;
|
2021-02-08 08:45:54 +03:00
|
|
|
|
2022-02-14 19:08:40 +03:00
|
|
|
OBJECT_DECLARE_CPU_TYPE(HexagonCPU, HexagonCPUClass, HEXAGON_CPU)
|
2021-02-08 08:45:54 +03:00
|
|
|
|
|
|
|
typedef struct HexagonCPUClass {
|
|
|
|
/*< private >*/
|
|
|
|
CPUClass parent_class;
|
|
|
|
/*< public >*/
|
|
|
|
DeviceRealize parent_realize;
|
2022-11-24 14:50:08 +03:00
|
|
|
ResettablePhases parent_phases;
|
2021-02-08 08:45:54 +03:00
|
|
|
} HexagonCPUClass;
|
|
|
|
|
2022-02-14 19:15:16 +03:00
|
|
|
struct ArchCPU {
|
2021-02-08 08:45:54 +03:00
|
|
|
/*< private >*/
|
|
|
|
CPUState parent_obj;
|
|
|
|
/*< public >*/
|
|
|
|
CPUNegativeOffsetState neg;
|
|
|
|
CPUHexagonState env;
|
|
|
|
|
|
|
|
bool lldb_compat;
|
|
|
|
target_ulong lldb_stack_adjust;
|
Hexagon (target/hexagon) Short-circuit packet register writes
In certain cases, we can avoid the overhead of writing to hex_new_value
and write directly to hex_gpr. We add need_commit field to DisasContext
indicating if the end-of-packet commit is needed. If it is not needed,
get_result_gpr() and get_result_gpr_pair() can return hex_gpr.
We pass the ctx->need_commit to helpers when needed.
Finally, we can early-exit from gen_reg_writes during packet commit.
There are a few instructions whose semantics write to the result before
reading all the inputs. Therefore, the idef-parser generated code is
incompatible with short-circuit. We tell idef-parser to skip them.
For debugging purposes, we add a cpu property to turn off short-circuit.
When the short-circuit property is false, we skip the analysis and force
the end-of-packet commit.
Here's a simple example of the TCG generated for
0x004000b4: 0x7800c020 { R0 = #0x1 }
BEFORE:
---- 004000b4
movi_i32 new_r0,$0x1
mov_i32 r0,new_r0
AFTER:
---- 004000b4
movi_i32 r0,$0x1
This patch reintroduces a use of check_for_attrib, so we remove the
G_GNUC_UNUSED added earlier in this series.
Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Brian Cain <bcain@quicinc.com>
Message-Id: <20230427230012.3800327-12-tsimpson@quicinc.com>
2023-04-28 02:00:02 +03:00
|
|
|
bool short_circuit;
|
2022-02-14 19:08:40 +03:00
|
|
|
};
|
2021-02-08 08:45:54 +03:00
|
|
|
|
|
|
|
#include "cpu_bits.h"
|
|
|
|
|
2022-11-10 20:49:35 +03:00
|
|
|
FIELD(TB_FLAGS, IS_TIGHT_LOOP, 0, 1)
|
|
|
|
|
2021-02-08 08:45:54 +03:00
|
|
|
static inline void cpu_get_tb_cpu_state(CPUHexagonState *env, target_ulong *pc,
|
|
|
|
target_ulong *cs_base, uint32_t *flags)
|
|
|
|
{
|
2022-11-10 20:49:35 +03:00
|
|
|
uint32_t hex_flags = 0;
|
2021-02-08 08:45:54 +03:00
|
|
|
*pc = env->gpr[HEX_REG_PC];
|
|
|
|
*cs_base = 0;
|
2022-11-10 20:49:35 +03:00
|
|
|
if (*pc == env->gpr[HEX_REG_SA0]) {
|
|
|
|
hex_flags = FIELD_DP32(hex_flags, TB_FLAGS, IS_TIGHT_LOOP, 1);
|
|
|
|
}
|
|
|
|
*flags = hex_flags;
|
2021-02-08 08:45:54 +03:00
|
|
|
}
|
|
|
|
|
2021-07-27 19:50:38 +03:00
|
|
|
static inline int cpu_mmu_index(CPUHexagonState *env, bool ifetch)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_USER_ONLY
|
|
|
|
return MMU_USER_IDX;
|
|
|
|
#else
|
|
|
|
#error System mode not supported on Hexagon yet
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-02-08 08:45:54 +03:00
|
|
|
typedef HexagonCPU ArchCPU;
|
|
|
|
|
|
|
|
void hexagon_translate_init(void);
|
|
|
|
|
|
|
|
#include "exec/cpu-all.h"
|
|
|
|
|
|
|
|
#endif /* HEXAGON_CPU_H */
|