Hexagon: HMX system
cover Hexagon: HMX system
Add HMX system emulation features and log the HMX opcodes as 'UNIMP' for now.
Brian Cain (8):
target/hexagon: add HMX attrs, state hw/hexagon: add the HMX context device target/hexagon: add per-CPU HMX configuration target/hexagon: import HMX instruction definitions target/hexagon: gate HMX exec on SSR:XE2 hw/hexagon: describe HMX in the device tree hw/hexagon: migrate the HMX state target/hexagon: implement mxclracc
include/hw/hexagon/hexagon.h | 5 + include/hw/hexagon/hexagon_hmx_context.h | 24 ++ target/hexagon/cpu.h | 9 + target/hexagon/gen_tcg_hmx.h | 13 ++ target/hexagon/helper.h | 2 + target/hexagon/hmx_config.h | 17 ++ target/hexagon/hmx_state.h | 92 ++++++++ target/hexagon/insn.h | 1 + target/hexagon/translate.h | 2 + target/hexagon/attribs_def.h.inc | 13 ++ hw/hexagon/hex-board.c | 6 + hw/hexagon/hex-subsys.c | 23 ++ hw/hexagon/hexagon_hmx_context.c | 157 +++++++++++++ target/hexagon/cpu.c | 25 +++ target/hexagon/decode.c | 3 + target/hexagon/genptr.c | 1 + target/hexagon/hmx_config.c | 15 ++ target/hexagon/op_helper.c | 10 + target/hexagon/translate.c | 22 ++ target/hexagon/tag_rev_info.c.inc | 247 +++++++++++++++++++++ hw/hexagon/meson.build | 1 + target/hexagon/hex_common.py | 2 + target/hexagon/imported/allext.idef | 6 + target/hexagon/imported/allextenc.def | 4 + target/hexagon/imported/hmx/encode_ext.def | 149 +++++++++++++ target/hexagon/imported/hmx/ext.idef | 175 +++++++++++++++ target/hexagon/meson.build | 14 +- tests/functional/hexagon/test_systests.py | 3 + 28 files changed, 1035 insertions(+), 6 deletions(-) create mode 100644 include/hw/hexagon/hexagon_hmx_context.h create mode 100644 target/hexagon/gen_tcg_hmx.h create mode 100644 target/hexagon/hmx_config.h create mode 100644 target/hexagon/hmx_state.h create mode 100644 hw/hexagon/hexagon_hmx_context.c create mode 100644 target/hexagon/hmx_config.c create mode 100644 target/hexagon/imported/hmx/encode_ext.def create mode 100644 target/hexagon/imported/hmx/ext.idef
Signature · 1 line
2.34.1
PATCH 1/8 target/hexagon: add HMX attrs, state
Add inst attributes for HMX and state definition.
--- target/hexagon/hmx_state.h | 92 ++++++++++++++++++++++++++++++++ target/hexagon/attribs_def.h.inc | 13 +++++ 2 files changed, 105 insertions(+) create mode 100644 target/hexagon/hmx_state.h
target/hexagon/hmx_state.h new file +92 -0
@@ -0,0 +1,92 @@ +/* +* Hexagon HMX (Matrix eXtensions) State Definitions +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_HMX_STATE_H +#define HEXAGON_HMX_STATE_H + +#define HMX_SPATIAL_DIM_FXP 64 +#define HMX_SPATIAL_DIM_FP 32 +#define HMX_OUTPUT_CHANNELS 32 +#define HMX_NUM_ACC_SETS 2 +#define HMX_NUM_CVT_AGES 3 +#define HMX_NUM_BIAS_SETS 4 + +#define HMX_ACT_CROUTON_SIZE 2048 +#define HMX_ACT_CACHE_SIZE (2 * HMX_ACT_CROUTON_SIZE) + +typedef struct HmxAccFxp { +int32_t data[HMX_SPATIAL_DIM_FXP ][HMX_OUTPUT_CHANNELS ]; +}HmxAccFxp ; + +/* FP accumulator cell storage: IEEE binary64 bit patterns */ +typedef struct HmxAccFp { +uint64_t data[HMX_SPATIAL_DIM_FP ][HMX_OUTPUT_CHANNELS ]; +}HmxAccFp ; + +typedef struct HmxAccSet { +HmxAccFxp fxp_primary; +HmxAccFp fp_primary; +}HmxAccSet ; + +typedef struct HmxCvtStateFxp { +uint16_t data[HMX_SPATIAL_DIM_FXP ][HMX_OUTPUT_CHANNELS ]; +}HmxCvtStateFxp ; + +/* FP convert slot: one FP16 value, or an FP8 byte per spatial half */ +typedef struct HmxCvtStateFp { +uint16_t data[HMX_SPATIAL_DIM_FP ][HMX_OUTPUT_CHANNELS ]; +}HmxCvtStateFp ; + +typedef struct HmxState { +HmxAccSet acc[HMX_NUM_ACC_SETS ]; + +HmxCvtStateFxp cvt_fxp[HMX_NUM_CVT_AGES ]; +HmxCvtStateFp cvt_fp[HMX_NUM_CVT_AGES ]; + +HmxCvtStateFxp cvt_future_fxp; + +uint64_t bias_raw[HMX_NUM_BIAS_SETS ][HMX_OUTPUT_CHANNELS ]; + +uint32_t current_acc_set; + +uint8_t act_buffer[HMX_ACT_CACHE_SIZE ]; + +uint32_t act_rs; +uint32_t act_type; +uint8_t is_f8_odd;/* Rs[0]: FP8 activation reads odd byte of pair */ +uint8_t fp8_odd_sel;/* cvt Rs[11]: FP8 convert writes odd (1) half */ + +uint32_t format_offset;/* SM=2, DM=0 */ +uint32_t tile_x_mask; +uint32_t tile_y_mask; +uint32_t tile_x_inc; +uint32_t tile_y_inc; +uint32_t fx; +uint32_t fy; +int32_t ch_start;/* pre-computed channel start (raw) */ +int32_t ch_stop;/* pre-computed channel stop (exclusive) */ +uint32_t y_start; +uint32_t y_stop; +uint32_t y_dilate; +uint32_t blocks; +int32_t dY;/* offset to second activation crouton */ +uint32_t group_conv;/* ch_start > ch_stop */ +uint32_t group_size; +uint32_t group_count; + +int32_t mac_cycle_limit; + +/* Deferred CVT pipeline commit, at the next consumer or end of packet */ +uint32_t cvt_fxp_pending;/* 1 = future has uncommitted data */ +uint32_t cvt_fxp_pending_age;/* 1 = pipeline should age at commit */ + +/* Deferred accumulator clear/flip, at packet end or next accumulator use */ +uint32_t cvt_acc_clear_pending; +uint32_t cvt_acc_clear_set; +}HmxState ; + +#endif /* HEXAGON_HMX_STATE_H */
target/hexagon/attribs_def.h.inc +13 -0
@@ -210,5 +210,18 @@ DEF_ATTRIB(HVX_IEEE_FP_OUT_32, "HVX IEEE FP 32-bit output", "", "") DEF_ATTRIB(CVI_VX_NO_TMP_LD, "HVX multiply without tmp load", "", "") DEF_ATTRIB(HVX_FLT, "This a floating point HVX instruction.", "", "") +DEF_ATTRIB(SHARED_EXTENSION, "Shared extension instruction", "", "") +DEF_ATTRIB(EA_REG_ONLY, "EA = input register only", "", "") +DEF_ATTRIB(EA_PAGECROSS, "EA calculation can have a Page Cross Stall", "", "") +DEF_ATTRIB(MPY, "Has a multiply", "", "") +DEF_ATTRIB(PAIR_1OF2, "For assembler", "", "") +DEF_ATTRIB(PAIR_2OF2, "For assembler", "", "") +DEF_ATTRIB(HMX, "HMX coprocessor instruction", "", "") +DEF_ATTRIB(HMX_CVT, "HMX convert instruction", "", "") +DEF_ATTRIB(HMX_FLT, "HMX floating-point instruction", "", "") +DEF_ATTRIB(HMX_CU_SCALAR, "HMX scalar operand", "", "") +DEF_ATTRIB(HMX_BLOCK_ALIGN, "HMX block-aligned access", "", "") +DEF_ATTRIB(HMX_128B_ALIGN, "HMX 128-byte aligned access", "", "") + /* Keep this as the last attribute: */ DEF_ATTRIB(ZZ_LASTATTRIB, "Last attribute in the file", "", "")
Signature · 1 line
2.34.1
Re: [PATCH 1/8] target/hexagon: add HMX attrs, state
Quoted 10 lines · Brian Cain
Add inst attributes for HMX and state definition.
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/hmx_state.h | 92 ++++++++++++++++++++++++++++++++ target/hexagon/attribs_def.h.inc | 13 +++++ 2 files changed, 105 insertions(+) create mode 100644 target/hexagon/hmx_state.h
PATCH 2/8 hw/hexagon: add the HMX context device
In reply to Brian CainAdd a sysbus device that owns the HMX state. A core has one HMX unit shared by all its threads.
--- include/hw/hexagon/hexagon.h | 5 +++ include/hw/hexagon/hexagon_hmx_context.h | 24 ++++++++++++++ hw/hexagon/hex-subsys.c | 16 ++++++++++ hw/hexagon/hexagon_hmx_context.c | 40 ++++++++++++++++++++++++ hw/hexagon/meson.build | 1 + 5 files changed, 86 insertions(+) create mode 100644 include/hw/hexagon/hexagon_hmx_context.h create mode 100644 hw/hexagon/hexagon_hmx_context.c
include/hw/hexagon/hexagon.h +5 -0
@@ -40,6 +40,11 @@ typedef enum {#define HEXAGON_LATEST_REV v85#define HEXAGON_LATEST_REV_UPPER V85 +#define HEXAGON_COPROC_HMX (1U << 2) + +#define HEXAGON_CFGTABLE_HAS_HMX (t) \ + ((t)->coproc2_reg0 != 0 || ((t)->coproc_present & HEXAGON_COPROC_HMX)) +/* * Config table address bases represent bits [35:16]. */
include/hw/hexagon/hexagon_hmx_context.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Hexagon HMX Extension Context QOM Object +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_HMX_CONTEXT_H +#define HEXAGON_HMX_CONTEXT_H + +#include "hw/core/sysbus.h" +#include "qom/object.h" +#include "target/hexagon/hmx_state.h" + +#define TYPE_HEXAGON_HMX_CONTEXT "hexagon-hmx-context" +OBJECT_DECLARE_SIMPLE_TYPE(HexagonHMXContextState, HEXAGON_HMX_CONTEXT) + +struct HexagonHMXContextState { +SysBusDevice parent_obj; + +HmxState regs; +}; + +#endif /* HEXAGON_HMX_CONTEXT_H */
hw/hexagon/hex-subsys.c +16 -0
@@ -10,6 +10,7 @@#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_hvx_context.h" +#include "hw/hexagon/hexagon_hmx_context.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/intc/hex-l2vic.h" #include "hw/timer/qct-qtimer.h"
@@ -120,6 +121,20 @@ static void hvx_contexts_create(HexagonCommonMachineState *hms, hms->num_hvx_ctx = n; } +static void hmx_context_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg) +{ +DeviceState *ctx; + +if (!HEXAGON_CFGTABLE_HAS_HMX (&m_cfg->cfgtable)) { +return ; + } + + ctx =qdev_new (TYPE_HEXAGON_HMX_CONTEXT ); +object_property_add_child (OBJECT (hms),"hmx-context" ,OBJECT (ctx)); +sysbus_realize_and_unref (SYS_BUS_DEVICE (ctx), &error_fatal); +} +static DeviceState *cluster_create (HexagonCommonMachineState *hms) {DeviceState *cluster =qdev_new (TYPE_CPU_CLUSTER );
@@ -167,6 +182,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms, hms->glob_regs =globalreg_create (hms, m_cfg, rev); hms->tlb =tlb_create (hms, m_cfg);hvx_contexts_create (hms, m_cfg); +hmx_context_create (hms, m_cfg); }void hex_subsys_add_cpu (HexagonCommonMachineState *hms,DeviceState *cpu)
hw/hexagon/hexagon_hmx_context.c new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Hexagon HMX Extension Context QOM Object +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hw/hexagon/hexagon_hmx_context.h" + +static void hexagon_hmx_context_reset_hold (Object *obj,ResetType type) +{ +HexagonHMXContextState *s =HEXAGON_HMX_CONTEXT (obj); + +memset (&s->regs,0 ,sizeof (s->regs)); +} + +static void hexagon_hmx_context_class_init (ObjectClass *klass, +const void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ResettableClass *rc =RESETTABLE_CLASS (klass); + + rc->phases.hold = hexagon_hmx_context_reset_hold; + dc->user_creatable = false; +} + +static const TypeInfo hexagon_hmx_context_info = { + .name =TYPE_HEXAGON_HMX_CONTEXT , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (HexagonHMXContextState), + .class_init = hexagon_hmx_context_class_init, +}; + +static void hexagon_hmx_context_register_types (void ) +{ +type_register_static (&hexagon_hmx_context_info); +} + +type_init (hexagon_hmx_context_register_types)
hw/hexagon/meson.build +1 -0
@@ -2,6 +2,7 @@ hexagon_ss = ss.source_set() hexagon_ss.add(files('hexagon_tlb.c')) hexagon_ss.add(files('hexagon_globalreg.c')) hexagon_ss.add(files('hexagon_hvx_context.c')) +hexagon_ss.add(files('hexagon_hmx_context.c')) hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hex-subsys.c')) hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c')) hexagon_ss.add(when: 'CONFIG_HEX_BOARD', if_true: files('hex-board.c'))
Signature · 1 line
2.34.1
Re: [PATCH 2/8] hw/hexagon: add the HMX context device
Quoted 5 lines · Brian Cain
Add a sysbus device that owns the HMX state. A core has one HMX unit shared by all its threads.
Signed-off-by Brian Cain <[email protected]>
Quoted 10 lines
--- include/hw/hexagon/hexagon.h | 5 +++ include/hw/hexagon/hexagon_hmx_context.h | 24 ++++++++++++++ hw/hexagon/hex-subsys.c | 16 ++++++++++ hw/hexagon/hexagon_hmx_context.c | 40 ++++++++++++++++++++++++ hw/hexagon/meson.build | 1 + 5 files changed, 86 insertions(+) create mode 100644 include/hw/hexagon/hexagon_hmx_context.h create mode 100644 hw/hexagon/hexagon_hmx_context.c
PATCH 3/8 target/hexagon: add per-CPU HMX configuration
In reply to Brian CainAdd HmxConfig and hmx_init_config(), which derive the HMX configuration from the CPU revision.
--- target/hexagon/cpu.h | 8 ++++++++ target/hexagon/hmx_config.h | 17 +++++++++++++++++ hw/hexagon/hex-subsys.c | 7 +++++++ target/hexagon/cpu.c | 23 +++++++++++++++++++++++ target/hexagon/hmx_config.c | 15 +++++++++++++++ target/hexagon/meson.build | 1 + 6 files changed, 71 insertions(+) create mode 100644 target/hexagon/hmx_config.h create mode 100644 target/hexagon/hmx_config.c
target/hexagon/cpu.h +8 -0
@@ -30,12 +30,15 @@typedef struct HexagonTLBState HexagonTLBState ;typedef struct HexagonGlobalRegState HexagonGlobalRegState ;typedef struct HexagonHVXContextState HexagonHVXContextState ; +typedef struct HexagonHMXContextState HexagonHMXContextState ;#include "cpu-qom.h" #include "exec/cpu-common.h" #include "exec/target_long.h" #include "hex_regs.h" #include "mmvec/mmvec.h" +#include "hmx_config.h" +#include "hmx_state.h" #include "hw/core/registerfields.h" #include "qemu/bitmap.h"
@@ -197,6 +200,8 @@ typedef struct CPUArchState {target_ulong vstore_pending[VSTORES_MAX ];bool vtcm_pending;VTCMStoreLog vtcm_log; + +HmxState *hmx_state; } CPUHexagonState; typedef struct HexagonCPUClass {
@@ -217,12 +222,15 @@ struct ArchCPU {HexagonCPUConfig cfg;#ifndef CONFIG_USER_ONLY HexagonHVXContextState *hvx_ctx[HVX_CONTEXTS_MAX ]; +HexagonHMXContextState *hmx_ctx;HexagonTLBState *tlb;uint32_t boot_addr;HexagonGlobalRegState *globalregs;uint32_t htid;HexL2VicInterface *l2vic;#endif +HmxState *hmx; +HmxConfig hmx_cfg; };static inline HexagonHVXContext *hex_hvx (CPUHexagonState *env)
target/hexagon/hmx_config.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_HMX_CONFIG_H +#define HEXAGON_HMX_CONFIG_H + +#include "cpu-qom.h" + +typedef struct HmxConfig { +bool hmx_present; +}HmxConfig ; + +void hmx_init_config (HexagonCPU *cpu); + +#endif /* HEXAGON_HMX_CONFIG_H */
hw/hexagon/hex-subsys.c +7 -0
@@ -187,6 +187,8 @@ void hex_subsys_create(HexagonCommonMachineState *hms,void hex_subsys_add_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) { +Object *hmx; +object_property_add_child (OBJECT (hms->cluster),"cpu[*]" ,OBJECT (cpu));object_property_set_link (OBJECT (cpu),"global-regs" ,OBJECT (hms->glob_regs), &error_fatal);
@@ -200,6 +202,11 @@ void hex_subsys_add_cpu(HexagonCommonMachineState *hms, DeviceState *cpu)object_property_set_link (OBJECT (cpu), name, ctx, &error_fatal); } + hmx =object_resolve_path_component (OBJECT (hms),"hmx-context" ); +if (hmx) { +object_property_set_link (OBJECT (cpu),"hmx-context" , hmx, + &error_fatal); + } }void hex_subsys_realize_cluster (HexagonCommonMachineState *hms)
target/hexagon/cpu.c +23 -0
@@ -45,6 +45,7 @@#include "exec/target_page.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_hvx_context.h" +#include "hw/hexagon/hexagon_hmx_context.h" #endif static ObjectClass *hexagon_cpu_class_by_name (const char *cpu_model)
@@ -539,6 +540,24 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp) cpu->cfg.hex_def = mcc->hex_def; +hmx_init_config (cpu); +#ifdef CONFIG_USER_ONLY +/* All threads of the process share one HMX unit */ +static HmxState *user_hmx; + +if (cpu->hmx_cfg.hmx_present) { +if (!user_hmx) { + user_hmx =g_new0 (HmxState,1 ); + } + cpu->hmx = user_hmx; + } +#else +if (cpu->hmx_ctx && cpu->hmx_cfg.hmx_present) { + cpu->hmx = &cpu->hmx_ctx->regs; + } +#endif +cpu_env (cs)->hmx_state = cpu->hmx; +gdb_register_coprocessor (cs, hexagon_hvx_gdb_read_register, hexagon_hvx_gdb_write_register,gdb_find_static_feature ("hexagon-hvx.xml" ));
@@ -629,6 +648,10 @@ static void hexagon_cpu_init(Object *obj) qdev_prop_allow_set_link_before_realize, OBJ_PROP_LINK_STRONG); } +object_property_add_link (obj,"hmx-context" ,TYPE_HEXAGON_HMX_CONTEXT , + (Object **)&cpu->hmx_ctx, + qdev_prop_allow_set_link_before_realize, +OBJ_PROP_LINK_STRONG );#endif }
target/hexagon/hmx_config.c new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "hmx_config.h" + +void hmx_init_config (HexagonCPU *cpu) +{ +HexagonVersion ver = cpu->cfg.hex_def->hex_version; + + cpu->hmx_cfg.hmx_present = ver >=HEX_VER_V75 ; +}
target/hexagon/meson.build +1 -0
@@ -254,6 +254,7 @@ hexagon_ss.add(files( 'mmvec/system_ext_mmvec.c', 'mmvec/hvx_ieee_fp.c', 'mmvec/hvx_qfloat.c', + 'hmx_config.c', )) hexagon_softmmu_ss.add(files(
Signature · 1 line
2.34.1
Re: [PATCH 3/8] target/hexagon: add per-CPU HMX configuration
Quoted 5 lines · Brian Cain
Add HmxConfig and
hmx_init_config(), which derive the HMX configuration from the CPU revision.Signed-off-by Brian Cain <[email protected]>
Quoted 11 lines
--- target/hexagon/cpu.h | 8 ++++++++ target/hexagon/hmx_config.h | 17 +++++++++++++++++ hw/hexagon/hex-subsys.c | 7 +++++++ target/hexagon/cpu.c | 23 +++++++++++++++++++++++ target/hexagon/hmx_config.c | 15 +++++++++++++++ target/hexagon/meson.build | 1 + 6 files changed, 71 insertions(+) create mode 100644 target/hexagon/hmx_config.h create mode 100644 target/hexagon/hmx_config.c
PATCH 4/8 target/hexagon: import HMX instruction definitions
In reply to Brian CainImport the HMX instruction encodings and definitions. The semantics are no-ops for now.
--- target/hexagon/tag_rev_info.c.inc | 247 +++++++++++++++++++++ target/hexagon/imported/allext.idef | 6 + target/hexagon/imported/allextenc.def | 4 + target/hexagon/imported/hmx/encode_ext.def | 149 +++++++++++++ target/hexagon/imported/hmx/ext.idef | 175 +++++++++++++++ 5 files changed, 581 insertions(+) create mode 100644 target/hexagon/imported/hmx/encode_ext.def create mode 100644 target/hexagon/imported/hmx/ext.idef
target/hexagon/tag_rev_info.c.inc +247 -0
@@ -620,6 +620,253 @@ static const struct tag_rev_info tag_rev_info[XX_LAST_OPCODE] = { [V6_vcombine_tmp] = { .introduced = HEX_VER_V69, .removed = HEX_VER_NONE }, [V6_vmpyuhvs] = { .introduced = HEX_VER_V69, .removed = HEX_VER_NONE }, + /* HMX (matrix) coprocessor extension */ + [M8_cvt_rs_f8] = { .introduced = HEX_VER_V81, .removed = HEX_VER_NONE }, + [M8_cvt_rs_hf] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_cvt_rs_ub] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_cvt_rs_ub_sc0] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_cvt_rs_ub_sc1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_cvt_rs_uh_2x1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_cvt_rs_uh_2x2] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxaccshl] = { .introduced = HEX_VER_V75, .removed = HEX_VER_V79 }, + [M8_mxclracc] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxclracc_hf] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvta_sat_uh] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvta_sat_uh2x2] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvta_sat_uh2x2_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvta_sat_uh_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvta_uh] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvta_uh2x2] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvta_uh2x2_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvta_uh_r] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvtb_sat_uh] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtb_sat_uh2x2] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtb_sat_uh2x2_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtb_sat_uh_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtb_uh] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvtb_uh2x2] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvtb_uh2x2_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtb_uh_r] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvtl_dm_sat_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtl_dm_sat_ub_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtl_dm_ub] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvtl_dm_ub_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtl_sat_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtl_sat_hf_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtl_sat_pos_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtl_sat_pos_hf_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtl_sat_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtl_sat_ub_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtl_ub] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvtl_ub_r] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvtr_dm_sat_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtr_dm_sat_ub_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtr_dm_ub] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvtr_dm_ub_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtr_sat_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtr_sat_hf_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtr_sat_pos_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtr_sat_pos_hf_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtr_sat_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtr_sat_ub_r] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxcvtr_ub] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxcvtr_ub_r] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem2_bias] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem2_st_bias] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_2x2] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmema_wei_b] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmema_wei_b1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmema_wei_c] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmema_wei_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmema_wei_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmema_wei_n] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmema_wei_n_2x] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmema_wei_sb1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmema_wei_sc] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmema_wei_sm] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_bias] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem_blk_dm_act_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_blk_sm_act_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmem_blk_sm_act_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_blk_sm_act_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_cm] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem_cm_deep] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemd_blk_dm_act_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemd_blk_sm_act_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmemd_blk_sm_act_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemd_blk_sm_act_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_deep] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem_deep_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmemdi_wei_b] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdi_wei_b1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdi_wei_c] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdi_wei_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmemdi_wei_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdi_wei_n] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdi_wei_n_2x] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdi_wei_sb1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdi_wei_sc] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdi_wei_sm] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_dm_act_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdp_wei_b] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdp_wei_b1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdp_wei_c] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdp_wei_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmemdp_wei_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdp_wei_n] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdp_wei_n_2x] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdp_wei_sb1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdp_wei_sc] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdp_wei_sm] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdr_wei_b] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdr_wei_b1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdr_wei_c] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdr_wei_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmemdr_wei_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdr_wei_n] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdr_wei_n_2x] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdr_wei_sb1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdr_wei_sc] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemdr_wei_sm] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_f8] = { .introduced = HEX_VER_V81, .removed = HEX_VER_NONE }, + [M8_mxmems_blk_dm_act_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmems_blk_sm_act_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmems_blk_sm_act_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmems_blk_sm_act_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_sm_act_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmem_sm_act_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_sm_act_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_st_bias] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmems_wei_b] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmems_wei_b1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmems_wei_c] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmems_wei_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmems_wei_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmems_wei_n] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmems_wei_n_2x] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmems_wei_sb1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmems_wei_sc] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmems_wei_sm] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemu_blk_dm_act_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemu_blk_sm_act_f8] = { .introduced = HEX_VER_V81, + .removed = HEX_VER_NONE }, + [M8_mxmemu_blk_sm_act_hf] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmemu_blk_sm_act_ub] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_wei_b] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem_wei_b1] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem_wei_c] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem_wei_f8] = { .introduced = HEX_VER_V81, .removed = HEX_VER_NONE }, + [M8_mxmem_wei_hf] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem_wei_n] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem_wei_n_2x] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_wei_sb1] = { .introduced = HEX_VER_V75, + .removed = HEX_VER_NONE }, + [M8_mxmem_wei_sc] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxmem_wei_sm] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxswap] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [M8_mxswap_hf] = { .introduced = HEX_VER_V75, .removed = HEX_VER_NONE }, + [S2_pstorerbf_pi_nt] = { .introduced = HEX_VER_V79, .removed = HEX_VER_NONE }, [S2_pstorerbt_pi_nt] = { .introduced = HEX_VER_V79,
target/hexagon/imported/allext.idef +6 -0
@@ -23,3 +23,9 @@ #include "mmvec/ext.idef" #undef EXTNAME #undef EXTSTR + +#define EXTNAME hmx +#define EXTSTR "hmx" +#include "hmx/ext.idef" +#undef EXTNAME +#undef EXTSTR
target/hexagon/imported/allextenc.def +4 -0
@@ -18,3 +18,7 @@ #define EXTNAME mmvec #include "mmvec/encode_ext.def" #undef EXTNAME + +#define EXTNAME hmx +#include "hmx/encode_ext.def" +#undef EXTNAME
target/hexagon/imported/hmx/encode_ext.def new file +149 -0
149 lines not on this page · raw message
target/hexagon/imported/hmx/ext.idef new file +175 -0
175 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 4/8] target/hexagon: import HMX instruction definitions
target/hexagon/tag_rev_info.c.inc static const struct tag_rev_info tag_rev_info[XX_LAST_OPCODE] = {
Quoted 20 lines · Brian Cain
Import the HMX instruction encodings and definitions. The semantics are no-ops for now.
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/tag_rev_info.c.inc | 247 +++++++++++++++++++++ target/hexagon/imported/allext.idef | 6 + target/hexagon/imported/allextenc.def | 4 + target/hexagon/imported/hmx/encode_ext.def | 149 +++++++++++++ target/hexagon/imported/hmx/ext.idef | 175 +++++++++++++++ 5 files changed, 581 insertions(+) create mode 100644 target/hexagon/imported/hmx/encode_ext.def create mode 100644 target/hexagon/imported/hmx/ext.ideftarget/hexagon/tag_rev_info.c.inc +0
-0@@ -620,6 +620,253 @@ static const struct tag_rev_info tag_rev_info[XX_LAST_OPCODE] = {
Some instructions have a wrong intro revision. These are the ones I found:
Marked v81, should be v79:
- M8_mxmem_blk_sm_act_f8
- M8_mxmem_sm_act_f8
- M8_mxmemu_blk_sm_act_f8
- M8_mxmems_blk_sm_act_f8
- M8_mxmemd_blk_sm_act_f8
- M8_mxmem_wei_f8
- M8_mxmems_wei_f8
- M8_mxmemdr_wei_f8
- M8_mxmemdp_wei_f8
- M8_mxmema_wei_f8
- M8_mxmemdi_wei_f8
Marked v75, should be v79:
- M8_mxmem_deep: mxmem(Rs,Rt):deep=cvt
- M8_mxmem_cm_deep: mxmem(Rs,Rt):cm:deep=cvt
PATCH 5/8 target/hexagon: gate HMX exec on SSR:XE2
In reply to Brian CainExecuting an HMX instruction with SSR:XE2 clear raises a NO_COPROC2_ENABLE exception.
Log packets one as LOG_UNIMP for now.
--- target/hexagon/cpu.h | 1 + target/hexagon/insn.h | 1 + target/hexagon/translate.h | 2 ++ target/hexagon/cpu.c | 2 ++ target/hexagon/decode.c | 3 +++ target/hexagon/translate.c | 21 +++++++++++++++++++++ tests/functional/hexagon/test_systests.py | 3 +++ 7 files changed, 33 insertions(+)
target/hexagon/cpu.h +1 -0
@@ -247,6 +247,7 @@ FIELD(TB_FLAGS, MMU_INDEX, 1, 3) FIELD(TB_FLAGS, HVX_COPROC_ENABLED, 5, 1) FIELD(TB_FLAGS, CPU_MODE, 6, 2) FIELD(TB_FLAGS, SS_ACTIVE, 8, 1) +FIELD(TB_FLAGS, HMX_COPROC_ENABLED, 15, 1) G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env, uint32_t exception,
target/hexagon/insn.h +1 -0
@@ -70,6 +70,7 @@ struct Packet {bool pkt_has_scalar_store_s1;bool pkt_has_hvx; +bool pkt_has_hmx;Insn *vhist_insn;Insn insn[INSTRUCTIONS_MAX ];
target/hexagon/translate.h +2 -0
@@ -101,6 +101,8 @@ typedef struct DisasContext {TCGv dczero_addr;bool hvx_coproc_enabled;bool hvx_check_emitted; +bool hmx_coproc_enabled; +bool hmx_check_emitted; } DisasContext;bool is_gather_store_insn (DisasContext *ctx);
target/hexagon/cpu.c +2 -0
@@ -393,6 +393,8 @@ static TCGTBCPUState hexagon_get_tb_cpu_state(CPUState *cs) hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,SS_ACTIVE ,GET_SSR_FIELD (SSR_SS , env->t_sreg[HEX_SREG_SSR ]) &&get_cpu_mode (env) !=HEX_CPU_MODE_MONITOR ); + hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,HMX_COPROC_ENABLED , +GET_SSR_FIELD (SSR_XE2 , env->t_sreg[HEX_SREG_SSR ]));#else hex_flags =FIELD_DP32 (hex_flags,TB_FLAGS ,MMU_INDEX ,MMU_USER_IDX );#endif
target/hexagon/decode.c +3 -0
@@ -773,9 +773,12 @@ int decode_packet(DisasContext *ctx, int max_words, const uint32_t *words, pkt->encod_pkt_size_in_bytes = words_read *4 ; pkt->pkt_has_hvx = false; + pkt->pkt_has_hmx = false;for (i =0 ; i < num_insns; i++) { pkt->pkt_has_hvx |=GET_ATTRIB (pkt->insn[i].opcode,A_CVI ); + pkt->pkt_has_hmx |= +GET_ATTRIB (pkt->insn[i].opcode,A_HMX ); }/*
target/hexagon/translate.c +21 -0
@@ -860,6 +860,24 @@ static void gen_start_packet(DisasContext *ctx) ctx->hvx_check_emitted = true; }#endif + +if (ctx->pkt.pkt_has_hmx) { +for (i =0 ; i < ctx->pkt.num_insns; i++) { +if (GET_ATTRIB (ctx->pkt.insn[i].opcode,A_HMX )) { +qemu_log_mask (LOG_UNIMP ,"'%s' is not implemented\n" , + opcode_names[ctx->pkt.insn[i].opcode]); + } + } + } + +#ifndef CONFIG_USER_ONLY +/* HMX needs SSR:XE2 */ +if (ctx->pkt.pkt_has_hmx && !ctx->hmx_coproc_enabled && + !ctx->hmx_check_emitted) { +gen_precise_exception (HEX_CAUSE_NO_COPROC2_ENABLE , ctx->pkt.pc); + ctx->hmx_check_emitted = true; + } +#endif }bool is_gather_store_insn (DisasContext *ctx)
@@ -1434,6 +1452,9 @@ static void hexagon_tr_init_disas_context(DisasContextBase *dcbase, ctx->base.max_insns =1 ; ctx->is_tight_loop = false; } + ctx->hmx_coproc_enabled = +FIELD_EX32 (hex_flags,TB_FLAGS ,HMX_COPROC_ENABLED ); + ctx->hmx_check_emitted = false;#endif }
tests/functional/hexagon/test_systests.py +3 -0
@@ -90,6 +90,9 @@ def test_access(self): def test_semihost(self): self.run_console_pattern("semihost", "PASS", "-append", "arg1", "arg2") + def test_invalid_hmx(self): + self.run_exit_zero("invalid_hmx") + def test_dtg_interrupt(self): self.run_exit_zero("dtg_interrupt")
Signature · 1 line
2.34.1
Re: [PATCH 5/8] target/hexagon: gate HMX exec on SSR:XE2
Quoted 7 lines · Brian Cain
Executing an HMX instruction with SSR:XE2 clear raises a
NO_COPROC2_ENABLEexception.Log packets one as
LOG_UNIMPfor now.Signed-off-by Brian Cain <[email protected]>
Quoted 10 lines
--- target/hexagon/cpu.h | 1 + target/hexagon/insn.h | 1 + target/hexagon/translate.h | 2 ++ target/hexagon/cpu.c | 2 ++ target/hexagon/decode.c | 3 +++ target/hexagon/translate.c | 21 +++++++++++++++++++++ tests/functional/hexagon/test_systests.py | 3 +++ 7 files changed, 33 insertions(+)
PATCH 6/8 hw/hexagon: describe HMX in the device tree
In reply to Brian CainAdd a /soc/hmx node for HMX units.
--- hw/hexagon/hex-board.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/hexagon/hex-board.c +6 -0
@@ -106,6 +106,12 @@ void hex_board_fdt_add_hvx(MachineState *ms,qemu_fdt_setprop_cells (ms->fdt,"/soc/hvx" ,"qcom,hvx-vlength" , t->hvx_vec_log_length); } + +if (HEXAGON_CFGTABLE_HAS_HMX (t)) { +qemu_fdt_add_subnode (ms->fdt,"/soc/hmx" ); +qemu_fdt_setprop_string (ms->fdt,"/soc/hmx" ,"compatible" , +"qcom,hexagon-hmx" ); + } }void hex_board_fdt_add_cpus (MachineState *ms)
Signature · 1 line
2.34.1
Re: [PATCH 6/8] hw/hexagon: describe HMX in the device tree
Quoted 13 lines · Brian Cain
Add a /soc/hmx node for HMX units.
Signed-off-by Brian Cain <[email protected]>--- hw/hexagon/hex-board.c | 6 ++++++ 1 file changed, 6 insertions(+)hw/hexagon/hex-board.c +0
-0
hw/hexagon/hex-board.c void hex_board_fdt_add_hvx(MachineState *ms, · line 114
Quoted 9 lines
hw/hexagon/hex-board.c +6
-0@@ -106,6 +106,12 @@ void hex_board_fdt_add_hvx(MachineState *ms,qemu_fdt_setprop_cells (ms->fdt,"/soc/hvx" ,"qcom,hvx-vlength" , t->hvx_vec_log_length); } + +if (HEXAGON_CFGTABLE_HAS_HMX (t)) { +qemu_fdt_add_subnode (ms->fdt,"/soc/hmx" ); +qemu_fdt_setprop_string (ms->fdt,"/soc/hmx" ,"compatible" , +"qcom,hexagon-hmx" ); + }
Should HEXAGON_CFGTABLE_HAS_HMX check rev >= V75 too? As
it is right now using it will change machines older than V75 adding HMX.
Re: [PATCH 6/8] hw/hexagon: describe HMX in the device tree
Quoted 2 lines · Marco Liebel
Should
HEXAGON_CFGTABLE_HAS_HMXcheck rev >= V75 too? As
it is right now using it will change machines older than V75 adding HMX.
If it's present in the config table, it should be present in the device tree and QOM. Regardless of which arch rev.
At best it could be an assertion IMO.
-Brian
PATCH 7/8 hw/hexagon: migrate the HMX state
In reply to Brian Cain--- hw/hexagon/hexagon_hmx_context.c | 117 +++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+)
hw/hexagon/hexagon_hmx_context.c +117 -0
@@ -7,6 +7,7 @@#include "qemu/osdep.h" #include "hw/hexagon/hexagon_hmx_context.h" +#include "migration/vmstate.h" static void hexagon_hmx_context_reset_hold (Object *obj,ResetType type) {
@@ -15,6 +16,121 @@ static void hexagon_hmx_context_reset_hold(Object *obj, ResetType type)memset (&s->regs,0 ,sizeof (s->regs)); } +static const VMStateDescription vmstate_hmx_acc_fxp = { + .name ="hexagon_hmx_acc_fxp" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (const VMStateField []) { +VMSTATE_2DARRAY (data, HmxAccFxp,HMX_SPATIAL_DIM_FXP , +HMX_OUTPUT_CHANNELS ,0 , vmstate_info_int32, int32_t), +VMSTATE_END_OF_LIST () + }, +}; + +static const VMStateDescription vmstate_hmx_acc_fp = { + .name ="hexagon_hmx_acc_fp" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (const VMStateField []) { +VMSTATE_UINT64_2DARRAY (data, HmxAccFp,HMX_SPATIAL_DIM_FP , +HMX_OUTPUT_CHANNELS ), +VMSTATE_END_OF_LIST () + }, +}; + +static const VMStateDescription vmstate_hmx_acc_set = { + .name ="hexagon_hmx_acc_set" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (const VMStateField []) { +VMSTATE_STRUCT (fxp_primary, HmxAccSet,0 , vmstate_hmx_acc_fxp, + HmxAccFxp), +VMSTATE_STRUCT (fp_primary, HmxAccSet,0 , vmstate_hmx_acc_fp, + HmxAccFp), +VMSTATE_END_OF_LIST () + }, +}; + +static const VMStateDescription vmstate_hmx_cvt_fxp = { + .name ="hexagon_hmx_cvt_fxp" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (const VMStateField []) { +VMSTATE_UINT16_2DARRAY (data, HmxCvtStateFxp,HMX_SPATIAL_DIM_FXP , +HMX_OUTPUT_CHANNELS ), +VMSTATE_END_OF_LIST () + }, +}; + +static const VMStateDescription vmstate_hmx_cvt_fp = { + .name ="hexagon_hmx_cvt_fp" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (const VMStateField []) { +VMSTATE_UINT16_2DARRAY (data, HmxCvtStateFp,HMX_SPATIAL_DIM_FP , +HMX_OUTPUT_CHANNELS ), +VMSTATE_END_OF_LIST () + }, +}; + +static const VMStateDescription vmstate_hmx_regs = { + .name ="hexagon_hmx_regs" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (const VMStateField []) { +VMSTATE_STRUCT_ARRAY (acc, HmxState,HMX_NUM_ACC_SETS ,0 , + vmstate_hmx_acc_set, HmxAccSet), +VMSTATE_STRUCT_ARRAY (cvt_fxp, HmxState,HMX_NUM_CVT_AGES ,0 , + vmstate_hmx_cvt_fxp, HmxCvtStateFxp), +VMSTATE_STRUCT_ARRAY (cvt_fp, HmxState,HMX_NUM_CVT_AGES ,0 , + vmstate_hmx_cvt_fp, HmxCvtStateFp), +VMSTATE_STRUCT (cvt_future_fxp, HmxState,0 , vmstate_hmx_cvt_fxp, + HmxCvtStateFxp), +VMSTATE_UINT64_2DARRAY (bias_raw, HmxState,HMX_NUM_BIAS_SETS , +HMX_OUTPUT_CHANNELS ), +VMSTATE_UINT32 (current_acc_set, HmxState), +VMSTATE_BUFFER (act_buffer, HmxState), +VMSTATE_UINT32 (act_rs, HmxState), +VMSTATE_UINT32 (act_type, HmxState), +VMSTATE_UINT8 (is_f8_odd, HmxState), +VMSTATE_UINT8 (fp8_odd_sel, HmxState), +VMSTATE_UINT32 (format_offset, HmxState), +VMSTATE_UINT32 (tile_x_mask, HmxState), +VMSTATE_UINT32 (tile_y_mask, HmxState), +VMSTATE_UINT32 (tile_x_inc, HmxState), +VMSTATE_UINT32 (tile_y_inc, HmxState), +VMSTATE_UINT32 (fx, HmxState), +VMSTATE_UINT32 (fy, HmxState), +VMSTATE_INT32 (ch_start, HmxState), +VMSTATE_INT32 (ch_stop, HmxState), +VMSTATE_UINT32 (y_start, HmxState), +VMSTATE_UINT32 (y_stop, HmxState), +VMSTATE_UINT32 (y_dilate, HmxState), +VMSTATE_UINT32 (blocks, HmxState), +VMSTATE_INT32 (dY, HmxState), +VMSTATE_UINT32 (group_conv, HmxState), +VMSTATE_UINT32 (group_size, HmxState), +VMSTATE_UINT32 (group_count, HmxState), +VMSTATE_INT32 (mac_cycle_limit, HmxState), +VMSTATE_UINT32 (cvt_fxp_pending, HmxState), +VMSTATE_UINT32 (cvt_fxp_pending_age, HmxState), +VMSTATE_UINT32 (cvt_acc_clear_pending, HmxState), +VMSTATE_UINT32 (cvt_acc_clear_set, HmxState), +VMSTATE_END_OF_LIST () + }, +}; + +static const VMStateDescription vmstate_hexagon_hmx_context = { + .name ="hexagon_hmx_context" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (const VMStateField []) { +VMSTATE_STRUCT (regs, HexagonHMXContextState,1 , vmstate_hmx_regs, + HmxState), +VMSTATE_END_OF_LIST () + }, +}; +static void hexagon_hmx_context_class_init (ObjectClass *klass,const void *data) {
@@ -22,6 +138,7 @@ static void hexagon_hmx_context_class_init(ObjectClass *klass,ResettableClass *rc =RESETTABLE_CLASS (klass); rc->phases.hold = hexagon_hmx_context_reset_hold; + dc->vmsd = &vmstate_hexagon_hmx_context; dc->user_creatable = false; }
Signature · 1 line
2.34.1
Re: [PATCH 7/8] hw/hexagon: migrate the HMX state
hw/hexagon/hexagon_hmx_context.c line 7
Quoted 12 lines · Brian Cain
Signed-off-by Brian Cain <[email protected]>--- hw/hexagon/hexagon_hmx_context.c | 117 +++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+)hw/hexagon/hexagon_hmx_context.c +0
-0@@ -7,6 +7,7 @@
PATCH 8/8 target/hexagon: implement mxclracc
In reply to Brian CainImplement an HMX accumulator clear instruction - mxclracc.
--- target/hexagon/gen_tcg_hmx.h | 13 +++++++++++++ target/hexagon/helper.h | 2 ++ target/hexagon/genptr.c | 1 + target/hexagon/op_helper.c | 10 ++++++++++ target/hexagon/translate.c | 3 ++- target/hexagon/hex_common.py | 2 ++ target/hexagon/meson.build | 13 +++++++------ 7 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 target/hexagon/gen_tcg_hmx.h
target/hexagon/gen_tcg_hmx.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_GEN_TCG_HMX_H +#define HEXAGON_GEN_TCG_HMX_H + +#define fGEN_TCG_M8_mxclracc (SHORTCODE ) \ + gen_helper_mxclracc(tcg_env) + +#endif
target/hexagon/helper.h +2 -0
@@ -31,6 +31,8 @@ DEF_HELPER_FLAGS_4(vacsh_pred, TCG_CALL_NO_RWG_SE, s32, env, s64, s64, s64) DEF_HELPER_FLAGS_2(cabacdecbin_val, TCG_CALL_NO_RWG_SE, s64, s64, s64) DEF_HELPER_FLAGS_2(cabacdecbin_pred, TCG_CALL_NO_RWG_SE, s32, s64, s64) +DEF_HELPER_1 (mxclracc, void, env) + /* Floating point */ DEF_HELPER_3(conv_sf2df, f64, env, f32, i32)DEF_HELPER_3 (conv_df2sf, f32, env, f64, i32)
target/hexagon/genptr.c +1 -0
@@ -32,6 +32,7 @@#undef QEMU_GENERATE#include "gen_tcg.h" #include "gen_tcg_hvx.h" +#include "gen_tcg_hmx.h" #ifndef CONFIG_USER_ONLY #include "gen_tcg_sys.h" #endif
target/hexagon/op_helper.c +10 -0
@@ -2138,6 +2138,16 @@ void HELPER(pending_interrupt)(CPUHexagonState *env)#define BOGUS_HELPER (tag) \ printf("ERROR: bogus helper: " #tag "\n") +void HELPER (mxclracc )(CPUHexagonState *env) +{ +HmxState *hmx = env->hmx_state; +int i; + +for (i =0 ; i <HMX_NUM_ACC_SETS ; i++) { +memset (&hmx->acc[i].fxp_primary,0 ,sizeof (hmx->acc[i].fxp_primary)); + } +} +#include "helper_funcs_generated.c.inc" #define DO_ABSDIFF (NAME ,TYPE ,UTYPE ) \
target/hexagon/translate.c +2 -1
@@ -863,7 +863,8 @@ static void gen_start_packet(DisasContext *ctx)if (ctx->pkt.pkt_has_hmx) {for (i =0 ; i < ctx->pkt.num_insns; i++) { -if (GET_ATTRIB (ctx->pkt.insn[i].opcode,A_HMX )) { +if (GET_ATTRIB (ctx->pkt.insn[i].opcode,A_HMX ) && + ctx->pkt.insn[i].opcode != M8_mxclracc) {qemu_log_mask (LOG_UNIMP ,"'%s' is not implemented\n" , opcode_names[ctx->pkt.insn[i].opcode]); }
target/hexagon/hex_common.py +2 -0
@@ -1538,6 +1538,7 @@ def parse_common_args(desc): parser.add_argument("overrides", help="overrides file") parser.add_argument("overrides_vec", help="vector overrides file") parser.add_argument("overrides_sys", help="system overrides file") + parser.add_argument("overrides_hmx", help="matrix overrides file") parser.add_argument("out", help="output file") parser.add_argument("--idef-parser", help="file of instructions translated by idef-parser")
@@ -1546,6 +1547,7 @@ def parse_common_args(desc): read_overrides_file(args.overrides) read_overrides_file(args.overrides_vec) read_overrides_file(args.overrides_sys) + read_overrides_file(args.overrides_hmx) if args.idef_parser: read_idef_parser_enabled_file(args.idef_parser) calculate_attribs()
target/hexagon/meson.build +7 -6
@@ -21,6 +21,7 @@ hex_common_py = 'hex_common.py' gen_tcg_h = meson.current_source_dir() / 'gen_tcg.h' gen_tcg_hvx_h = meson.current_source_dir() / 'gen_tcg_hvx.h' gen_tcg_sys_h = meson.current_source_dir() / 'gen_tcg_sys.h' +gen_tcg_hmx_h = meson.current_source_dir() / 'gen_tcg_hmx.h' idef_parser_dir = meson.current_source_dir() / 'idef-parser' #
@@ -352,12 +353,12 @@ if idef_parser_enabled and ('hexagon-linux-user' in target_dirs or # Setup input and dependencies for the next step, this depends on whether or # not idef-parser is enabled helper_dep = [semantics_generated, idef_generated_tcg_c, idef_generated_tcg] - helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h, '--idef-parser', idef_generated_list] + helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h, gen_tcg_hmx_h, '--idef-parser', idef_generated_list] else # Setup input and dependencies for the next step, this depends on whether or # not idef-parser is enabled helper_dep = [semantics_generated] - helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h] + helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h, gen_tcg_hmx_h] endif #
@@ -371,7 +372,7 @@ helper_protos_generated = custom_target( 'helper_protos_generated.h.inc', output: 'helper_protos_generated.h.inc', depends: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h], + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h, gen_tcg_hmx_h], command: [python, files('gen_helper_protos.py'), helper_in, '@OUTPUT@'], ) hexagon_ss.add(helper_protos_generated)
@@ -380,7 +381,7 @@ helper_funcs_generated = custom_target( 'helper_funcs_generated.c.inc', output: 'helper_funcs_generated.c.inc', depends: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h], + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h, gen_tcg_hmx_h], command: [python, files('gen_helper_funcs.py'), helper_in, '@OUTPUT@'], ) hexagon_ss.add(helper_funcs_generated)
@@ -389,7 +390,7 @@ tcg_funcs_generated = custom_target( 'tcg_funcs_generated.c.inc', output: 'tcg_funcs_generated.c.inc', depends: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h], + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h, gen_tcg_hmx_h], command: [python, files('gen_tcg_funcs.py'), helper_in, '@OUTPUT@'], ) hexagon_ss.add(tcg_funcs_generated)
@@ -398,7 +399,7 @@ analyze_funcs_generated = custom_target( 'analyze_funcs_generated.c.inc', output: 'analyze_funcs_generated.c.inc', depends: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h], + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h, gen_tcg_sys_h, gen_tcg_hmx_h], command: [python, files('gen_analyze_funcs.py'), helper_in, '@OUTPUT@'], ) hexagon_ss.add(analyze_funcs_generated)
Signature · 1 line
2.34.1
Re: [PATCH 8/8] target/hexagon: implement mxclracc
Quoted 39 lines · Brian Cain
Implement an HMX accumulator clear instruction - mxclracc.
Signed-off-by Brian Cain <[email protected]>--- target/hexagon/gen_tcg_hmx.h | 13 +++++++++++++ target/hexagon/helper.h | 2 ++ target/hexagon/genptr.c | 1 + target/hexagon/op_helper.c | 10 ++++++++++ target/hexagon/translate.c | 3 ++- target/hexagon/hex_common.py | 2 ++ target/hexagon/meson.build | 13 +++++++------ 7 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 target/hexagon/gen_tcg_hmx.htarget/hexagon/gen_tcg_hmx.h new file +13
-0@@ -0,0 +1,13 @@ +/* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HEXAGON_GEN_TCG_HMX_H +#define HEXAGON_GEN_TCG_HMX_H + +#define fGEN_TCG_M8_mxclracc (SHORTCODE ) \ + gen_helper_mxclracc(tcg_env) + +#endif target/hexagon/helper.h +0
-0
target/hexagon/helper.h DEF_HELPER_FLAGS_4(vacsh_pred, TCG_CALL_NO_RWG_SE, s32, env, s64, s64, s64) · line 35
Quoted 5 lines
target/hexagon/helper.h +2
-0@@ -31,6 +31,8 @@ DEF_HELPER_FLAGS_4(vacsh_pred, TCG_CALL_NO_RWG_SE, s32, env, s64, s64, s64) DEF_HELPER_FLAGS_2(cabacdecbin_val, TCG_CALL_NO_RWG_SE, s64, s64, s64) DEF_HELPER_FLAGS_2(cabacdecbin_pred, TCG_CALL_NO_RWG_SE, s32, s64, s64) +DEF_HELPER_1 (mxclracc, void, env) +
The helper is only used in builds with idef-parser disabled. Since idef-parser is enabled by default, mxclracc gets an empty implementation in the default build.