Add inst attributes for HMX and state definition.
Reviewed-by: Marco Liebel <[email protected]>
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
diff --git a/target/hexagon/hmx_state.h b/target/hexagon/hmx_state.h
new file mode 100644
index 00000000000..43c8cbd9e07
--- /dev/null
+++ b/target/hexagon/hmx_state.h
@@ -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 */
diff --git a/target/hexagon/attribs_def.h.inc b/target/hexagon/attribs_def.h.inc
index 96ad1fd2f8e..439a268b591 100644
--- a/target/hexagon/attribs_def.h.inc
+++ b/target/hexagon/attribs_def.h.inc
@@ -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", "", "")
--
2.34.1