1 | The following changes since commit 4c395ac42e55ff8e9fd4c992e351a04b10785503: | 1 | The following changes since commit a5ba0a7e4e150d1350a041f0d0ef9ca6c8d7c307: |
---|---|---|---|
2 | 2 | ||
3 | Merge tag 'pull-tcg-20240808' of https://gitlab.com/rth7680/qemu into staging (2024-08-08 09:07:00 +1000) | 3 | Merge tag 'pull-aspeed-20241211' of https://github.com/legoater/qemu into staging (2024-12-11 15:16:47 +0000) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/quic/qemu tags/pull-hex-20240807 | 7 | https://github.com/quic/qemu tags/pull-hex-20241212 |
8 | 8 | ||
9 | for you to fetch changes up to 47f3361a3af9d709218038a23b8907525310d2c3: | 9 | for you to fetch changes up to b29b11b51f1ac1884a64c5b6bde969a46206263f: |
10 | 10 | ||
11 | target/hexagon: switch to dc set_props() list (2024-08-07 20:37:21 -0700) | 11 | target/hexagon: Make HVX vector args. restrict * (2024-12-12 21:43:57 -0600) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Hexagon updates: lldb preds, v66 CPU, F2_conv* fix | 14 | Remove HEX_DEBUG, EXCP/CAUSE fixes |
15 | 15 | ||
16 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
17 | Anton Johansson (1): | 17 | Anton Johansson (2): |
18 | target/hexagon/idef-parser: Remove self-assignment | 18 | target/hexagon: Use argparse in all python scripts |
19 | target/hexagon: Make HVX vector args. restrict * | ||
19 | 20 | ||
20 | Brian Cain (3): | 21 | Brian Cain (2): |
21 | MAINTAINERS: Add my hexagon git tree | 22 | target/hexagon: rename HEX_EXCP_*=>HEX_CAUSE_* |
22 | target/hexagon: define a v66 CPU | 23 | target/hexagon: add enums for event, cause |
23 | target/hexagon: switch to dc set_props() list | ||
24 | |||
25 | Matheus Tavares Bernardino (1): | ||
26 | Hexagon: fix F2_conv_* instructions for negative zero | ||
27 | 24 | ||
28 | Taylor Simpson (1): | 25 | Taylor Simpson (1): |
29 | Hexagon: lldb read/write predicate registers p0/p1/p2/p3 | 26 | Hexagon (target/hexagon) Remove HEX_DEBUG/HEX_DEBUG_LOG |
30 | 27 | ||
31 | MAINTAINERS | 1 + | 28 | linux-user/hexagon/cpu_loop.c | 4 +- |
32 | gdb-xml/hexagon-core.xml | 6 +++++- | 29 | target/hexagon/README | 9 --- |
33 | target/hexagon/cpu-qom.h | 1 + | 30 | target/hexagon/cpu.h | 8 +-- |
34 | target/hexagon/cpu.c | 20 ++++++++++---------- | 31 | target/hexagon/cpu_bits.h | 21 ++++-- |
35 | target/hexagon/gdbstub.c | 19 ++++++++++++++++++- | 32 | target/hexagon/gen_analyze_funcs.py | 6 +- |
36 | target/hexagon/idef-parser/idef-parser.y | 1 - | 33 | target/hexagon/gen_decodetree.py | 19 ++++-- |
37 | target/hexagon/op_helper.c | 18 +++++++++--------- | 34 | target/hexagon/gen_helper_funcs.py | 7 +- |
38 | tests/tcg/hexagon/usr.c | 12 +++++++++++- | 35 | target/hexagon/gen_helper_protos.py | 7 +- |
39 | 8 files changed, 55 insertions(+), 23 deletions(-) | 36 | target/hexagon/gen_idef_parser_funcs.py | 11 +++- |
37 | target/hexagon/gen_op_attribs.py | 11 +++- | ||
38 | target/hexagon/gen_opcodes_def.py | 11 +++- | ||
39 | target/hexagon/gen_printinsn.py | 11 +++- | ||
40 | target/hexagon/gen_tcg.h | 2 +- | ||
41 | target/hexagon/gen_tcg_func_table.py | 11 +++- | ||
42 | target/hexagon/gen_tcg_funcs.py | 9 +-- | ||
43 | target/hexagon/gen_trans_funcs.py | 18 ++++- | ||
44 | target/hexagon/genptr.c | 7 -- | ||
45 | target/hexagon/helper.h | 3 - | ||
46 | target/hexagon/hex_common.py | 33 +++++----- | ||
47 | target/hexagon/internal.h | 11 ---- | ||
48 | target/hexagon/meson.build | 2 +- | ||
49 | target/hexagon/mmvec/macros.h | 36 +++++----- | ||
50 | target/hexagon/op_helper.c | 112 -------------------------------- | ||
51 | target/hexagon/translate.c | 72 +------------------- | ||
52 | target/hexagon/translate.h | 2 - | ||
53 | 25 files changed, 148 insertions(+), 295 deletions(-) | diff view generated by jsdifflib |
1 | From: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> | 1 | From: Taylor Simpson <ltaylorsimpson@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | The implementation for these instructions handles -0 as an invalid float | 3 | All Hexagon debugging is now done with QEMU mechanisms |
4 | point value, whereas the Hexagon hardware considers it the same as +0 | 4 | (e.g., -d in_asm) or with a connected debugger (lldb). |
5 | (which is valid). Let's fix that and add a regression test. | ||
6 | 5 | ||
7 | Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> | 6 | Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com> |
8 | Reviewed-by: Brian Cain <bcain@quicinc.com> | 7 | Reviewed-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> |
9 | Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com> | 8 | Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com> |
10 | Signed-off-by: Brian Cain <bcain@quicinc.com> | 9 | Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com> |
11 | --- | 10 | --- |
12 | target/hexagon/op_helper.c | 18 +++++++++--------- | 11 | target/hexagon/README | 9 --- |
13 | tests/tcg/hexagon/usr.c | 12 +++++++++++- | 12 | target/hexagon/cpu.h | 6 -- |
14 | 2 files changed, 20 insertions(+), 10 deletions(-) | 13 | target/hexagon/genptr.c | 7 --- |
14 | target/hexagon/helper.h | 3 - | ||
15 | target/hexagon/internal.h | 11 ---- | ||
16 | target/hexagon/op_helper.c | 112 ------------------------------------- | ||
17 | target/hexagon/translate.c | 66 ---------------------- | ||
18 | target/hexagon/translate.h | 2 - | ||
19 | 8 files changed, 216 deletions(-) | ||
15 | 20 | ||
21 | diff --git a/target/hexagon/README b/target/hexagon/README | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/target/hexagon/README | ||
24 | +++ b/target/hexagon/README | ||
25 | @@ -XXX,XX +XXX,XX @@ For Hexagon Vector eXtensions (HVX), the following fields are used | ||
26 | |||
27 | *** Debugging *** | ||
28 | |||
29 | -You can turn on a lot of debugging by changing the HEX_DEBUG macro to 1 in | ||
30 | -internal.h. This will stream a lot of information as it generates TCG and | ||
31 | -executes the code. | ||
32 | - | ||
33 | To track down nasty issues with Hexagon->TCG generation, we compare the | ||
34 | execution results with actual hardware running on a Hexagon Linux target. | ||
35 | Run qemu with the "-d cpu" option. Then, we can diff the results and figure | ||
36 | @@ -XXX,XX +XXX,XX @@ Here are some handy places to set breakpoints | ||
37 | The helper function for each instruction is named helper_<TAG>, so here's | ||
38 | an example that will set a breakpoint at the start | ||
39 | br helper_A2_add | ||
40 | - If you have the HEX_DEBUG macro set, the following will be useful | ||
41 | - At the start of execution of a packet for a given PC | ||
42 | - br helper_debug_start_packet if env->gpr[41] == 0xdeadbeef | ||
43 | - At the end of execution of a packet for a given PC | ||
44 | - br helper_debug_commit_end if this_PC == 0xdeadbeef | ||
45 | diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/hexagon/cpu.h | ||
48 | +++ b/target/hexagon/cpu.h | ||
49 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
50 | uint8_t slot_cancelled; | ||
51 | target_ulong new_value_usr; | ||
52 | |||
53 | - /* | ||
54 | - * Only used when HEX_DEBUG is on, but unconditionally included | ||
55 | - * to reduce recompile time when turning HEX_DEBUG on/off. | ||
56 | - */ | ||
57 | - target_ulong reg_written[TOTAL_PER_THREAD_REGS]; | ||
58 | - | ||
59 | MemLog mem_log_stores[STORES_MAX]; | ||
60 | |||
61 | float_status fp_status; | ||
62 | diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/target/hexagon/genptr.c | ||
65 | +++ b/target/hexagon/genptr.c | ||
66 | @@ -XXX,XX +XXX,XX @@ void gen_log_reg_write(DisasContext *ctx, int rnum, TCGv val) | ||
67 | |||
68 | gen_masked_reg_write(val, hex_gpr[rnum], reg_mask); | ||
69 | tcg_gen_mov_tl(get_result_gpr(ctx, rnum), val); | ||
70 | - if (HEX_DEBUG) { | ||
71 | - /* Do this so HELPER(debug_commit_end) will know */ | ||
72 | - tcg_gen_movi_tl(hex_reg_written[rnum], 1); | ||
73 | - } | ||
74 | } | ||
75 | |||
76 | static void gen_log_reg_write_pair(DisasContext *ctx, int rnum, TCGv_i64 val) | ||
77 | @@ -XXX,XX +XXX,XX @@ void gen_log_pred_write(DisasContext *ctx, int pnum, TCGv val) | ||
78 | } else { | ||
79 | tcg_gen_and_tl(pred, pred, base_val); | ||
80 | } | ||
81 | - if (HEX_DEBUG) { | ||
82 | - tcg_gen_ori_tl(ctx->pred_written, ctx->pred_written, 1 << pnum); | ||
83 | - } | ||
84 | set_bit(pnum, ctx->pregs_written); | ||
85 | } | ||
86 | |||
87 | diff --git a/target/hexagon/helper.h b/target/hexagon/helper.h | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/target/hexagon/helper.h | ||
90 | +++ b/target/hexagon/helper.h | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | #include "helper_protos_generated.h.inc" | ||
93 | |||
94 | DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_RETURN, noreturn, env, i32) | ||
95 | -DEF_HELPER_1(debug_start_packet, void, env) | ||
96 | -DEF_HELPER_FLAGS_3(debug_check_store_width, TCG_CALL_NO_WG, void, env, int, int) | ||
97 | -DEF_HELPER_FLAGS_5(debug_commit_end, TCG_CALL_NO_WG, void, env, i32, int, int, int) | ||
98 | DEF_HELPER_2(commit_store, void, env, int) | ||
99 | DEF_HELPER_3(gather_store, void, env, i32, int) | ||
100 | DEF_HELPER_1(commit_hvx_stores, void, env) | ||
101 | diff --git a/target/hexagon/internal.h b/target/hexagon/internal.h | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/hexagon/internal.h | ||
104 | +++ b/target/hexagon/internal.h | ||
105 | @@ -XXX,XX +XXX,XX @@ | ||
106 | |||
107 | #include "qemu/log.h" | ||
108 | |||
109 | -/* | ||
110 | - * Change HEX_DEBUG to 1 to turn on debugging output | ||
111 | - */ | ||
112 | -#define HEX_DEBUG 0 | ||
113 | -#define HEX_DEBUG_LOG(...) \ | ||
114 | - do { \ | ||
115 | - if (HEX_DEBUG) { \ | ||
116 | - qemu_log(__VA_ARGS__); \ | ||
117 | - } \ | ||
118 | - } while (0) | ||
119 | - | ||
120 | int hexagon_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); | ||
121 | int hexagon_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); | ||
122 | int hexagon_hvx_gdb_read_register(CPUState *env, GByteArray *mem_buf, int n); | ||
16 | diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c | 123 | diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 124 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/hexagon/op_helper.c | 125 | --- a/target/hexagon/op_helper.c |
19 | +++ b/target/hexagon/op_helper.c | 126 | +++ b/target/hexagon/op_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ | 127 | @@ -XXX,XX +XXX,XX @@ G_NORETURN void HELPER(raise_exception)(CPUHexagonState *env, uint32_t excp) |
21 | /* | 128 | void log_store32(CPUHexagonState *env, target_ulong addr, |
22 | - * Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. | 129 | target_ulong val, int width, int slot) |
23 | + * Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. | 130 | { |
24 | * | 131 | - HEX_DEBUG_LOG("log_store%d(0x" TARGET_FMT_lx |
25 | * This program is free software; you can redistribute it and/or modify | 132 | - ", %" PRId32 " [0x08%" PRIx32 "])\n", |
26 | * it under the terms of the GNU General Public License as published by | 133 | - width, addr, val, val); |
27 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(conv_sf2uw)(CPUHexagonState *env, float32 RsV) | 134 | env->mem_log_stores[slot].va = addr; |
28 | uint32_t RdV; | 135 | env->mem_log_stores[slot].width = width; |
29 | arch_fpop_start(env); | 136 | env->mem_log_stores[slot].data32 = val; |
30 | /* Hexagon checks the sign before rounding */ | 137 | @@ -XXX,XX +XXX,XX @@ void log_store32(CPUHexagonState *env, target_ulong addr, |
31 | - if (float32_is_neg(RsV) && !float32_is_any_nan(RsV)) { | 138 | void log_store64(CPUHexagonState *env, target_ulong addr, |
32 | + if (float32_is_neg(RsV) && !float32_is_any_nan(RsV) && !float32_is_zero(RsV)) { | 139 | int64_t val, int width, int slot) |
33 | float_raise(float_flag_invalid, &env->fp_status); | 140 | { |
34 | RdV = 0; | 141 | - HEX_DEBUG_LOG("log_store%d(0x" TARGET_FMT_lx |
35 | } else { | 142 | - ", %" PRId64 " [0x016%" PRIx64 "])\n", |
36 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(conv_sf2ud)(CPUHexagonState *env, float32 RsV) | 143 | - width, addr, val, val); |
37 | uint64_t RddV; | 144 | env->mem_log_stores[slot].va = addr; |
38 | arch_fpop_start(env); | 145 | env->mem_log_stores[slot].width = width; |
39 | /* Hexagon checks the sign before rounding */ | 146 | env->mem_log_stores[slot].data64 = val; |
40 | - if (float32_is_neg(RsV) && !float32_is_any_nan(RsV)) { | 147 | } |
41 | + if (float32_is_neg(RsV) && !float32_is_any_nan(RsV) && !float32_is_zero(RsV)) { | 148 | |
42 | float_raise(float_flag_invalid, &env->fp_status); | 149 | -/* Handy place to set a breakpoint */ |
43 | RddV = 0; | 150 | -void HELPER(debug_start_packet)(CPUHexagonState *env) |
44 | } else { | 151 | -{ |
45 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(conv_df2uw)(CPUHexagonState *env, float64 RssV) | 152 | - HEX_DEBUG_LOG("Start packet: pc = 0x" TARGET_FMT_lx "\n", |
46 | uint32_t RdV; | 153 | - env->gpr[HEX_REG_PC]); |
47 | arch_fpop_start(env); | 154 | - |
48 | /* Hexagon checks the sign before rounding */ | 155 | - for (int i = 0; i < TOTAL_PER_THREAD_REGS; i++) { |
49 | - if (float64_is_neg(RssV) && !float64_is_any_nan(RssV)) { | 156 | - env->reg_written[i] = 0; |
50 | + if (float64_is_neg(RssV) && !float64_is_any_nan(RssV) && !float64_is_zero(RssV)) { | 157 | - } |
51 | float_raise(float_flag_invalid, &env->fp_status); | 158 | -} |
52 | RdV = 0; | 159 | - |
53 | } else { | 160 | -/* Checks for bookkeeping errors between disassembly context and runtime */ |
54 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(conv_df2ud)(CPUHexagonState *env, float64 RssV) | 161 | -void HELPER(debug_check_store_width)(CPUHexagonState *env, int slot, int check) |
55 | uint64_t RddV; | 162 | -{ |
56 | arch_fpop_start(env); | 163 | - if (env->mem_log_stores[slot].width != check) { |
57 | /* Hexagon checks the sign before rounding */ | 164 | - HEX_DEBUG_LOG("ERROR: %d != %d\n", |
58 | - if (float64_is_neg(RssV) && !float64_is_any_nan(RssV)) { | 165 | - env->mem_log_stores[slot].width, check); |
59 | + if (float64_is_neg(RssV) && !float64_is_any_nan(RssV) && !float64_is_zero(RssV)) { | 166 | - g_assert_not_reached(); |
60 | float_raise(float_flag_invalid, &env->fp_status); | 167 | - } |
61 | RddV = 0; | 168 | -} |
62 | } else { | 169 | - |
63 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(conv_sf2uw_chop)(CPUHexagonState *env, float32 RsV) | 170 | static void commit_store(CPUHexagonState *env, int slot_num, uintptr_t ra) |
64 | uint32_t RdV; | 171 | { |
65 | arch_fpop_start(env); | 172 | uint8_t width = env->mem_log_stores[slot_num].width; |
66 | /* Hexagon checks the sign before rounding */ | 173 | @@ -XXX,XX +XXX,XX @@ void HELPER(commit_hvx_stores)(CPUHexagonState *env) |
67 | - if (float32_is_neg(RsV) && !float32_is_any_nan(RsV)) { | 174 | } |
68 | + if (float32_is_neg(RsV) && !float32_is_any_nan(RsV) && !float32_is_zero(RsV)) { | 175 | } |
69 | float_raise(float_flag_invalid, &env->fp_status); | 176 | |
70 | RdV = 0; | 177 | -static void print_store(CPUHexagonState *env, int slot) |
71 | } else { | 178 | -{ |
72 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(conv_sf2ud_chop)(CPUHexagonState *env, float32 RsV) | 179 | - if (!(env->slot_cancelled & (1 << slot))) { |
73 | uint64_t RddV; | 180 | - uint8_t width = env->mem_log_stores[slot].width; |
74 | arch_fpop_start(env); | 181 | - if (width == 1) { |
75 | /* Hexagon checks the sign before rounding */ | 182 | - uint32_t data = env->mem_log_stores[slot].data32 & 0xff; |
76 | - if (float32_is_neg(RsV) && !float32_is_any_nan(RsV)) { | 183 | - HEX_DEBUG_LOG("\tmemb[0x" TARGET_FMT_lx "] = %" PRId32 |
77 | + if (float32_is_neg(RsV) && !float32_is_any_nan(RsV) && !float32_is_zero(RsV)) { | 184 | - " (0x%02" PRIx32 ")\n", |
78 | float_raise(float_flag_invalid, &env->fp_status); | 185 | - env->mem_log_stores[slot].va, data, data); |
79 | RddV = 0; | 186 | - } else if (width == 2) { |
80 | } else { | 187 | - uint32_t data = env->mem_log_stores[slot].data32 & 0xffff; |
81 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(conv_df2uw_chop)(CPUHexagonState *env, float64 RssV) | 188 | - HEX_DEBUG_LOG("\tmemh[0x" TARGET_FMT_lx "] = %" PRId32 |
82 | uint32_t RdV; | 189 | - " (0x%04" PRIx32 ")\n", |
83 | arch_fpop_start(env); | 190 | - env->mem_log_stores[slot].va, data, data); |
84 | /* Hexagon checks the sign before rounding */ | 191 | - } else if (width == 4) { |
85 | - if (float64_is_neg(RssV) && !float64_is_any_nan(RssV)) { | 192 | - uint32_t data = env->mem_log_stores[slot].data32; |
86 | + if (float64_is_neg(RssV) && !float64_is_any_nan(RssV) && !float64_is_zero(RssV)) { | 193 | - HEX_DEBUG_LOG("\tmemw[0x" TARGET_FMT_lx "] = %" PRId32 |
87 | float_raise(float_flag_invalid, &env->fp_status); | 194 | - " (0x%08" PRIx32 ")\n", |
88 | RdV = 0; | 195 | - env->mem_log_stores[slot].va, data, data); |
89 | } else { | 196 | - } else if (width == 8) { |
90 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(conv_df2ud_chop)(CPUHexagonState *env, float64 RssV) | 197 | - HEX_DEBUG_LOG("\tmemd[0x" TARGET_FMT_lx "] = %" PRId64 |
91 | uint64_t RddV; | 198 | - " (0x%016" PRIx64 ")\n", |
92 | arch_fpop_start(env); | 199 | - env->mem_log_stores[slot].va, |
93 | /* Hexagon checks the sign before rounding */ | 200 | - env->mem_log_stores[slot].data64, |
94 | - if (float64_is_neg(RssV) && !float64_is_any_nan(RssV)) { | 201 | - env->mem_log_stores[slot].data64); |
95 | + if (float64_is_neg(RssV) && !float64_is_any_nan(RssV) && !float64_is_zero(RssV)) { | 202 | - } else { |
96 | float_raise(float_flag_invalid, &env->fp_status); | 203 | - HEX_DEBUG_LOG("\tBad store width %d\n", width); |
97 | RddV = 0; | 204 | - g_assert_not_reached(); |
98 | } else { | 205 | - } |
99 | diff --git a/tests/tcg/hexagon/usr.c b/tests/tcg/hexagon/usr.c | 206 | - } |
100 | index XXXXXXX..XXXXXXX 100644 | 207 | -} |
101 | --- a/tests/tcg/hexagon/usr.c | 208 | - |
102 | +++ b/tests/tcg/hexagon/usr.c | 209 | -/* This function is a handy place to set a breakpoint */ |
103 | @@ -XXX,XX +XXX,XX @@ | 210 | -void HELPER(debug_commit_end)(CPUHexagonState *env, uint32_t this_PC, |
104 | /* | 211 | - int pred_written, int has_st0, int has_st1) |
105 | - * Copyright(c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. | 212 | -{ |
106 | + * Copyright(c) 2022-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. | 213 | - bool reg_printed = false; |
107 | * | 214 | - bool pred_printed = false; |
108 | * This program is free software; you can redistribute it and/or modify | 215 | - int i; |
109 | * it under the terms of the GNU General Public License as published by | 216 | - |
110 | @@ -XXX,XX +XXX,XX @@ int main() | 217 | - HEX_DEBUG_LOG("Packet committed: pc = 0x" TARGET_FMT_lx "\n", this_PC); |
111 | TEST_P_OP_R(conv_sf2d_chop, SF_QNaN, 0xffffffffffffffffULL, USR_FPINVF); | 218 | - HEX_DEBUG_LOG("slot_cancelled = %d\n", env->slot_cancelled); |
112 | TEST_P_OP_R(conv_sf2d_chop, SF_SNaN, 0xffffffffffffffffULL, USR_FPINVF); | 219 | - |
113 | 220 | - for (i = 0; i < TOTAL_PER_THREAD_REGS; i++) { | |
114 | + TEST_R_OP_R(conv_sf2uw, SF_zero_neg, 0, USR_CLEAR); | 221 | - if (env->reg_written[i]) { |
115 | + TEST_R_OP_R(conv_sf2uw_chop, SF_zero_neg, 0, USR_CLEAR); | 222 | - if (!reg_printed) { |
116 | + TEST_P_OP_R(conv_sf2ud, SF_zero_neg, 0, USR_CLEAR); | 223 | - HEX_DEBUG_LOG("Regs written\n"); |
117 | + TEST_P_OP_R(conv_sf2ud_chop, SF_zero_neg, 0, USR_CLEAR); | 224 | - reg_printed = true; |
118 | + | 225 | - } |
119 | TEST_R_OP_P(conv_df2sf, DF_QNaN, SF_HEX_NaN, USR_CLEAR); | 226 | - HEX_DEBUG_LOG("\tr%d = " TARGET_FMT_ld " (0x" TARGET_FMT_lx ")\n", |
120 | TEST_R_OP_P(conv_df2sf, DF_SNaN, SF_HEX_NaN, USR_FPINVF); | 227 | - i, env->gpr[i], env->gpr[i]); |
121 | TEST_R_OP_P(conv_df2uw, DF_QNaN, 0xffffffff, USR_FPINVF); | 228 | - } |
122 | @@ -XXX,XX +XXX,XX @@ int main() | 229 | - } |
123 | TEST_R_OP_P(conv_df2uw_chop, DF_QNaN, 0xffffffff, USR_FPINVF); | 230 | - |
124 | TEST_R_OP_P(conv_df2uw_chop, DF_SNaN, 0xffffffff, USR_FPINVF); | 231 | - for (i = 0; i < NUM_PREGS; i++) { |
125 | 232 | - if (pred_written & (1 << i)) { | |
126 | + TEST_R_OP_P(conv_df2uw, DF_zero_neg, 0, USR_CLEAR); | 233 | - if (!pred_printed) { |
127 | + TEST_R_OP_P(conv_df2uw_chop, DF_zero_neg, 0, USR_CLEAR); | 234 | - HEX_DEBUG_LOG("Predicates written\n"); |
128 | + TEST_P_OP_P(conv_df2ud, DF_zero_neg, 0, USR_CLEAR); | 235 | - pred_printed = true; |
129 | + TEST_P_OP_P(conv_df2ud_chop, DF_zero_neg, 0, USR_CLEAR); | 236 | - } |
130 | + | 237 | - HEX_DEBUG_LOG("\tp%d = 0x" TARGET_FMT_lx "\n", |
131 | /* Test for typo in HELPER(conv_df2uw_chop) */ | 238 | - i, env->pred[i]); |
132 | TEST_R_OP_P(conv_df2uw_chop, 0xffffff7f00000001ULL, 0xffffffff, USR_FPINVF); | 239 | - } |
133 | 240 | - } | |
241 | - | ||
242 | - if (has_st0 || has_st1) { | ||
243 | - HEX_DEBUG_LOG("Stores\n"); | ||
244 | - if (has_st0) { | ||
245 | - print_store(env, 0); | ||
246 | - } | ||
247 | - if (has_st1) { | ||
248 | - print_store(env, 1); | ||
249 | - } | ||
250 | - } | ||
251 | - | ||
252 | - HEX_DEBUG_LOG("Next PC = " TARGET_FMT_lx "\n", env->gpr[HEX_REG_PC]); | ||
253 | - HEX_DEBUG_LOG("Exec counters: pkt = " TARGET_FMT_lx | ||
254 | - ", insn = " TARGET_FMT_lx | ||
255 | - ", hvx = " TARGET_FMT_lx "\n", | ||
256 | - env->gpr[HEX_REG_QEMU_PKT_CNT], | ||
257 | - env->gpr[HEX_REG_QEMU_INSN_CNT], | ||
258 | - env->gpr[HEX_REG_QEMU_HVX_CNT]); | ||
259 | - | ||
260 | -} | ||
261 | - | ||
262 | int32_t HELPER(fcircadd)(int32_t RxV, int32_t offset, int32_t M, int32_t CS) | ||
263 | { | ||
264 | uint32_t K_const = extract32(M, 24, 4); | ||
265 | diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c | ||
266 | index XXXXXXX..XXXXXXX 100644 | ||
267 | --- a/target/hexagon/translate.c | ||
268 | +++ b/target/hexagon/translate.c | ||
269 | @@ -XXX,XX +XXX,XX @@ TCGv hex_gpr[TOTAL_PER_THREAD_REGS]; | ||
270 | TCGv hex_pred[NUM_PREGS]; | ||
271 | TCGv hex_slot_cancelled; | ||
272 | TCGv hex_new_value_usr; | ||
273 | -TCGv hex_reg_written[TOTAL_PER_THREAD_REGS]; | ||
274 | TCGv hex_store_addr[STORES_MAX]; | ||
275 | TCGv hex_store_width[STORES_MAX]; | ||
276 | TCGv hex_store_val32[STORES_MAX]; | ||
277 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_end_tb(DisasContext *ctx, int excp) | ||
278 | |||
279 | } | ||
280 | |||
281 | -#define PACKET_BUFFER_LEN 1028 | ||
282 | -static void print_pkt(Packet *pkt) | ||
283 | -{ | ||
284 | - GString *buf = g_string_sized_new(PACKET_BUFFER_LEN); | ||
285 | - snprint_a_pkt_debug(buf, pkt); | ||
286 | - HEX_DEBUG_LOG("%s", buf->str); | ||
287 | - g_string_free(buf, true); | ||
288 | -} | ||
289 | -#define HEX_DEBUG_PRINT_PKT(pkt) \ | ||
290 | - do { \ | ||
291 | - if (HEX_DEBUG) { \ | ||
292 | - print_pkt(pkt); \ | ||
293 | - } \ | ||
294 | - } while (0) | ||
295 | - | ||
296 | static int read_packet_words(CPUHexagonState *env, DisasContext *ctx, | ||
297 | uint32_t words[]) | ||
298 | { | ||
299 | @@ -XXX,XX +XXX,XX @@ static int read_packet_words(CPUHexagonState *env, DisasContext *ctx, | ||
300 | g_assert(ctx->base.num_insns == 1); | ||
301 | } | ||
302 | |||
303 | - HEX_DEBUG_LOG("decode_packet: pc = 0x%" VADDR_PRIx "\n", | ||
304 | - ctx->base.pc_next); | ||
305 | - HEX_DEBUG_LOG(" words = { "); | ||
306 | - for (int i = 0; i < nwords; i++) { | ||
307 | - HEX_DEBUG_LOG("0x%x, ", words[i]); | ||
308 | - } | ||
309 | - HEX_DEBUG_LOG("}\n"); | ||
310 | - | ||
311 | return nwords; | ||
312 | } | ||
313 | |||
314 | @@ -XXX,XX +XXX,XX @@ static void gen_start_packet(DisasContext *ctx) | ||
315 | */ | ||
316 | bitmap_zero(ctx->pregs_written, NUM_PREGS); | ||
317 | |||
318 | - if (HEX_DEBUG) { | ||
319 | - /* Handy place to set a breakpoint before the packet executes */ | ||
320 | - gen_helper_debug_start_packet(tcg_env); | ||
321 | - } | ||
322 | - | ||
323 | /* Initialize the runtime state for packet semantics */ | ||
324 | if (need_slot_cancelled(pkt)) { | ||
325 | tcg_gen_movi_tl(hex_slot_cancelled, 0); | ||
326 | @@ -XXX,XX +XXX,XX @@ static void gen_start_packet(DisasContext *ctx) | ||
327 | tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], next_PC); | ||
328 | } | ||
329 | } | ||
330 | - if (HEX_DEBUG) { | ||
331 | - ctx->pred_written = tcg_temp_new(); | ||
332 | - tcg_gen_movi_tl(ctx->pred_written, 0); | ||
333 | - } | ||
334 | |||
335 | /* Preload the predicated registers into get_result_gpr(ctx, i) */ | ||
336 | if (ctx->need_commit && | ||
337 | @@ -XXX,XX +XXX,XX @@ static void gen_pred_writes(DisasContext *ctx) | ||
338 | } | ||
339 | } | ||
340 | |||
341 | -static void gen_check_store_width(DisasContext *ctx, int slot_num) | ||
342 | -{ | ||
343 | - if (HEX_DEBUG) { | ||
344 | - TCGv slot = tcg_constant_tl(slot_num); | ||
345 | - TCGv check = tcg_constant_tl(ctx->store_width[slot_num]); | ||
346 | - gen_helper_debug_check_store_width(tcg_env, slot, check); | ||
347 | - } | ||
348 | -} | ||
349 | - | ||
350 | static bool slot_is_predicated(Packet *pkt, int slot_num) | ||
351 | { | ||
352 | for (int i = 0; i < pkt->num_insns; i++) { | ||
353 | @@ -XXX,XX +XXX,XX @@ void process_store(DisasContext *ctx, int slot_num) | ||
354 | */ | ||
355 | switch (ctx->store_width[slot_num]) { | ||
356 | case 1: | ||
357 | - gen_check_store_width(ctx, slot_num); | ||
358 | tcg_gen_qemu_st_tl(hex_store_val32[slot_num], | ||
359 | hex_store_addr[slot_num], | ||
360 | ctx->mem_idx, MO_UB); | ||
361 | break; | ||
362 | case 2: | ||
363 | - gen_check_store_width(ctx, slot_num); | ||
364 | tcg_gen_qemu_st_tl(hex_store_val32[slot_num], | ||
365 | hex_store_addr[slot_num], | ||
366 | ctx->mem_idx, MO_TEUW); | ||
367 | break; | ||
368 | case 4: | ||
369 | - gen_check_store_width(ctx, slot_num); | ||
370 | tcg_gen_qemu_st_tl(hex_store_val32[slot_num], | ||
371 | hex_store_addr[slot_num], | ||
372 | ctx->mem_idx, MO_TEUL); | ||
373 | break; | ||
374 | case 8: | ||
375 | - gen_check_store_width(ctx, slot_num); | ||
376 | tcg_gen_qemu_st_i64(hex_store_val64[slot_num], | ||
377 | hex_store_addr[slot_num], | ||
378 | ctx->mem_idx, MO_TEUQ); | ||
379 | @@ -XXX,XX +XXX,XX @@ static void gen_commit_packet(DisasContext *ctx) | ||
380 | gen_commit_hvx(ctx); | ||
381 | } | ||
382 | update_exec_counters(ctx); | ||
383 | - if (HEX_DEBUG) { | ||
384 | - TCGv has_st0 = | ||
385 | - tcg_constant_tl(pkt->pkt_has_store_s0 && !pkt->pkt_has_dczeroa); | ||
386 | - TCGv has_st1 = | ||
387 | - tcg_constant_tl(pkt->pkt_has_store_s1 && !pkt->pkt_has_dczeroa); | ||
388 | - | ||
389 | - /* Handy place to set a breakpoint at the end of execution */ | ||
390 | - gen_helper_debug_commit_end(tcg_env, tcg_constant_tl(ctx->pkt->pc), | ||
391 | - ctx->pred_written, has_st0, has_st1); | ||
392 | - } | ||
393 | |||
394 | if (pkt->vhist_insn != NULL) { | ||
395 | ctx->pre_commit = false; | ||
396 | @@ -XXX,XX +XXX,XX @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx) | ||
397 | ctx->pkt = &pkt; | ||
398 | if (decode_packet(ctx, nwords, words, &pkt, false) > 0) { | ||
399 | pkt.pc = ctx->base.pc_next; | ||
400 | - HEX_DEBUG_PRINT_PKT(&pkt); | ||
401 | gen_start_packet(ctx); | ||
402 | for (i = 0; i < pkt.num_insns; i++) { | ||
403 | ctx->insn = &pkt.insn[i]; | ||
404 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, | ||
405 | } | ||
406 | |||
407 | #define NAME_LEN 64 | ||
408 | -static char reg_written_names[TOTAL_PER_THREAD_REGS][NAME_LEN]; | ||
409 | static char store_addr_names[STORES_MAX][NAME_LEN]; | ||
410 | static char store_width_names[STORES_MAX][NAME_LEN]; | ||
411 | static char store_val32_names[STORES_MAX][NAME_LEN]; | ||
412 | @@ -XXX,XX +XXX,XX @@ void hexagon_translate_init(void) | ||
413 | hex_gpr[i] = tcg_global_mem_new(tcg_env, | ||
414 | offsetof(CPUHexagonState, gpr[i]), | ||
415 | hexagon_regnames[i]); | ||
416 | - | ||
417 | - if (HEX_DEBUG) { | ||
418 | - snprintf(reg_written_names[i], NAME_LEN, "reg_written_%s", | ||
419 | - hexagon_regnames[i]); | ||
420 | - hex_reg_written[i] = tcg_global_mem_new(tcg_env, | ||
421 | - offsetof(CPUHexagonState, reg_written[i]), | ||
422 | - reg_written_names[i]); | ||
423 | - } | ||
424 | } | ||
425 | hex_new_value_usr = tcg_global_mem_new(tcg_env, | ||
426 | offsetof(CPUHexagonState, new_value_usr), "new_value_usr"); | ||
427 | diff --git a/target/hexagon/translate.h b/target/hexagon/translate.h | ||
428 | index XXXXXXX..XXXXXXX 100644 | ||
429 | --- a/target/hexagon/translate.h | ||
430 | +++ b/target/hexagon/translate.h | ||
431 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
432 | bool has_hvx_overlap; | ||
433 | TCGv new_value[TOTAL_PER_THREAD_REGS]; | ||
434 | TCGv new_pred_value[NUM_PREGS]; | ||
435 | - TCGv pred_written; | ||
436 | TCGv branch_taken; | ||
437 | TCGv dczero_addr; | ||
438 | } DisasContext; | ||
439 | @@ -XXX,XX +XXX,XX @@ extern TCGv hex_gpr[TOTAL_PER_THREAD_REGS]; | ||
440 | extern TCGv hex_pred[NUM_PREGS]; | ||
441 | extern TCGv hex_slot_cancelled; | ||
442 | extern TCGv hex_new_value_usr; | ||
443 | -extern TCGv hex_reg_written[TOTAL_PER_THREAD_REGS]; | ||
444 | extern TCGv hex_store_addr[STORES_MAX]; | ||
445 | extern TCGv hex_store_width[STORES_MAX]; | ||
446 | extern TCGv hex_store_val32[STORES_MAX]; | ||
134 | -- | 447 | -- |
135 | 2.34.1 | 448 | 2.34.1 |
136 | 449 | diff view generated by jsdifflib |
1 | From: Taylor Simpson <ltaylorsimpson@gmail.com> | 1 | From: Brian Cain <bcain@quicinc.com> |
---|---|---|---|
2 | 2 | ||
3 | hexagon-core.xml only exposes register p3_0 which is an alias that | 3 | The values previously used for "HEX_EXCP_*" were the cause code |
4 | aggregates the predicate registers. It is more convenient for users | 4 | definitions and not the event numbers. So in this commit, we update |
5 | to interact directly with the predicate registers. | 5 | the names to reflect the cause codes. In HEX_EVENT_TRAP0's case, we add |
6 | a new "HEX_EVENT_*" with the correct event number. | ||
6 | 7 | ||
7 | Tested with lldb downloaded from this location | 8 | Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com> |
8 | https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.4/clang+llvm-18.1.4-x86_64-linux-gnu-ubuntu-18.04.tar.xz | 9 | Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com> |
10 | --- | ||
11 | linux-user/hexagon/cpu_loop.c | 4 ++-- | ||
12 | target/hexagon/cpu.h | 2 +- | ||
13 | target/hexagon/cpu_bits.h | 15 ++++++++------- | ||
14 | target/hexagon/gen_tcg.h | 2 +- | ||
15 | target/hexagon/translate.c | 6 +++--- | ||
16 | 5 files changed, 15 insertions(+), 14 deletions(-) | ||
9 | 17 | ||
10 | BEFORE: | 18 | diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c |
11 | (lldb) reg read p3_0 | ||
12 | p3_0 = 0x00000000 | ||
13 | (lldb) reg read p0 | ||
14 | error: Invalid register name 'p0'. | ||
15 | (lldb) reg write p1 0xf | ||
16 | error: Register not found for 'p1'. | ||
17 | |||
18 | AFTER: | ||
19 | (lldb) reg read p3_0 | ||
20 | p3_0 = 0x00000000 | ||
21 | (lldb) reg read p0 | ||
22 | p0 = 0x00 | ||
23 | (lldb) reg read -s 1 | ||
24 | Predicate Registers: | ||
25 | p0 = 0x00 | ||
26 | p1 = 0x00 | ||
27 | p2 = 0x00 | ||
28 | p3 = 0x00 | ||
29 | |||
30 | (lldb) reg write p1 0xf | ||
31 | (lldb) reg read p3_0 | ||
32 | p3_0 = 0x00000f00 | ||
33 | (lldb) reg write p3_0 0xff00ff00 | ||
34 | (lldb) reg read -s 1 | ||
35 | Predicate Registers: | ||
36 | p0 = 0x00 | ||
37 | p1 = 0xff | ||
38 | p2 = 0x00 | ||
39 | p3 = 0xff | ||
40 | |||
41 | Signed-off-by: Taylor Simpson <ltaylorsimpson@gmail.com> | ||
42 | Reviewed-by: Brian Cain <bcain@quicinc.com> | ||
43 | Reviewed-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> | ||
44 | Message-Id: <20240613182209.140082-1-ltaylorsimpson@gmail.com> | ||
45 | Signed-off-by: Brian Cain <bcain@quicinc.com> | ||
46 | --- | ||
47 | gdb-xml/hexagon-core.xml | 6 +++++- | ||
48 | target/hexagon/gdbstub.c | 19 ++++++++++++++++++- | ||
49 | 2 files changed, 23 insertions(+), 2 deletions(-) | ||
50 | |||
51 | diff --git a/gdb-xml/hexagon-core.xml b/gdb-xml/hexagon-core.xml | ||
52 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/gdb-xml/hexagon-core.xml | 20 | --- a/linux-user/hexagon/cpu_loop.c |
54 | +++ b/gdb-xml/hexagon-core.xml | 21 | +++ b/linux-user/hexagon/cpu_loop.c |
22 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUHexagonState *env) | ||
23 | case EXCP_INTERRUPT: | ||
24 | /* just indicate that signals should be handled asap */ | ||
25 | break; | ||
26 | - case HEX_EXCP_TRAP0: | ||
27 | + case HEX_EVENT_TRAP0: | ||
28 | syscallnum = env->gpr[6]; | ||
29 | env->gpr[HEX_REG_PC] += 4; | ||
30 | ret = do_syscall(env, | ||
31 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUHexagonState *env) | ||
32 | env->gpr[0] = ret; | ||
33 | } | ||
34 | break; | ||
35 | - case HEX_EXCP_PC_NOT_ALIGNED: | ||
36 | + case HEX_CAUSE_PC_NOT_ALIGNED: | ||
37 | force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, | ||
38 | env->gpr[HEX_REG_R31]); | ||
39 | break; | ||
40 | diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/hexagon/cpu.h | ||
43 | +++ b/target/hexagon/cpu.h | ||
44 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_get_tb_cpu_state(CPUHexagonState *env, vaddr *pc, | ||
45 | } | ||
46 | *flags = hex_flags; | ||
47 | if (*pc & PCALIGN_MASK) { | ||
48 | - hexagon_raise_exception_err(env, HEX_EXCP_PC_NOT_ALIGNED, 0); | ||
49 | + hexagon_raise_exception_err(env, HEX_CAUSE_PC_NOT_ALIGNED, 0); | ||
50 | } | ||
51 | } | ||
52 | |||
53 | diff --git a/target/hexagon/cpu_bits.h b/target/hexagon/cpu_bits.h | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/hexagon/cpu_bits.h | ||
56 | +++ b/target/hexagon/cpu_bits.h | ||
55 | @@ -XXX,XX +XXX,XX @@ | 57 | @@ -XXX,XX +XXX,XX @@ |
56 | <?xml version="1.0"?> | 58 | #define PCALIGN 4 |
57 | <!-- | 59 | #define PCALIGN_MASK (PCALIGN - 1) |
58 | - Copyright(c) 2023 Qualcomm Innovation Center, Inc. All Rights Reserved. | 60 | |
59 | + Copyright(c) 2023-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. | 61 | -#define HEX_EXCP_FETCH_NO_UPAGE 0x012 |
60 | 62 | -#define HEX_EXCP_INVALID_PACKET 0x015 | |
61 | This work is licensed under the terms of the GNU GPL, version 2 or | 63 | -#define HEX_EXCP_INVALID_OPCODE 0x015 |
62 | (at your option) any later version. See the COPYING file in the | 64 | -#define HEX_EXCP_PC_NOT_ALIGNED 0x01e |
65 | -#define HEX_EXCP_PRIV_NO_UREAD 0x024 | ||
66 | -#define HEX_EXCP_PRIV_NO_UWRITE 0x025 | ||
67 | +#define HEX_EVENT_TRAP0 0x008 | ||
68 | |||
69 | -#define HEX_EXCP_TRAP0 0x172 | ||
70 | +#define HEX_CAUSE_TRAP0 0x172 | ||
71 | +#define HEX_CAUSE_FETCH_NO_UPAGE 0x012 | ||
72 | +#define HEX_CAUSE_INVALID_PACKET 0x015 | ||
73 | +#define HEX_CAUSE_INVALID_OPCODE 0x015 | ||
74 | +#define HEX_CAUSE_PC_NOT_ALIGNED 0x01e | ||
75 | +#define HEX_CAUSE_PRIV_NO_UREAD 0x024 | ||
76 | +#define HEX_CAUSE_PRIV_NO_UWRITE 0x025 | ||
77 | |||
78 | #define PACKET_WORDS_MAX 4 | ||
79 | |||
80 | diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/hexagon/gen_tcg.h | ||
83 | +++ b/target/hexagon/gen_tcg.h | ||
63 | @@ -XXX,XX +XXX,XX @@ | 84 | @@ -XXX,XX +XXX,XX @@ |
64 | <reg name="c29" bitsize="32" offset="244" encoding="uint" format="hex" group="Thread Registers" dwarf_regnum="61"/> | 85 | do { \ |
65 | <reg name="utimerlo" bitsize="32" offset="248" encoding="uint" format="hex" group="Thread Registers" dwarf_regnum="62"/> | 86 | uiV = uiV; \ |
66 | <reg name="utimerhi" bitsize="32" offset="252" encoding="uint" format="hex" group="Thread Registers" dwarf_regnum="63"/> | 87 | tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], ctx->pkt->pc); \ |
67 | + <reg name="p0" bitsize="8" offset="256" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="64"/> | 88 | - TCGv excp = tcg_constant_tl(HEX_EXCP_TRAP0); \ |
68 | + <reg name="p1" bitsize="8" offset="257" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="65"/> | 89 | + TCGv excp = tcg_constant_tl(HEX_EVENT_TRAP0); \ |
69 | + <reg name="p2" bitsize="8" offset="258" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="66"/> | 90 | gen_helper_raise_exception(tcg_env, excp); \ |
70 | + <reg name="p3" bitsize="8" offset="259" encoding="uint" format="hex" group="Predicate Registers" dwarf_regnum="67"/> | 91 | } while (0) |
71 | 92 | #endif | |
72 | </feature> | 93 | diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c |
73 | diff --git a/target/hexagon/gdbstub.c b/target/hexagon/gdbstub.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | 94 | index XXXXXXX..XXXXXXX 100644 |
75 | --- a/target/hexagon/gdbstub.c | 95 | --- a/target/hexagon/translate.c |
76 | +++ b/target/hexagon/gdbstub.c | 96 | +++ b/target/hexagon/translate.c |
77 | @@ -XXX,XX +XXX,XX @@ | 97 | @@ -XXX,XX +XXX,XX @@ static void gen_insn(DisasContext *ctx) |
78 | /* | 98 | ctx->insn->generate(ctx); |
79 | - * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved. | 99 | mark_store_width(ctx); |
80 | + * Copyright(c) 2019-2024 Qualcomm Innovation Center, Inc. All Rights Reserved. | 100 | } else { |
81 | * | 101 | - gen_exception_end_tb(ctx, HEX_EXCP_INVALID_OPCODE); |
82 | * This program is free software; you can redistribute it and/or modify | 102 | + gen_exception_end_tb(ctx, HEX_CAUSE_INVALID_OPCODE); |
83 | * it under the terms of the GNU General Public License as published by | ||
84 | @@ -XXX,XX +XXX,XX @@ int hexagon_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) | ||
85 | return gdb_get_regl(mem_buf, env->gpr[n]); | ||
86 | } | 103 | } |
87 | |||
88 | + n -= TOTAL_PER_THREAD_REGS; | ||
89 | + | ||
90 | + if (n < NUM_PREGS) { | ||
91 | + return gdb_get_reg8(mem_buf, env->pred[n]); | ||
92 | + } | ||
93 | + | ||
94 | + n -= NUM_PREGS; | ||
95 | + | ||
96 | g_assert_not_reached(); | ||
97 | } | 104 | } |
98 | 105 | ||
99 | @@ -XXX,XX +XXX,XX @@ int hexagon_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | 106 | @@ -XXX,XX +XXX,XX @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx) |
100 | return sizeof(target_ulong); | 107 | |
108 | nwords = read_packet_words(env, ctx, words); | ||
109 | if (!nwords) { | ||
110 | - gen_exception_end_tb(ctx, HEX_EXCP_INVALID_PACKET); | ||
111 | + gen_exception_end_tb(ctx, HEX_CAUSE_INVALID_PACKET); | ||
112 | return; | ||
101 | } | 113 | } |
102 | 114 | ||
103 | + n -= TOTAL_PER_THREAD_REGS; | 115 | @@ -XXX,XX +XXX,XX @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx) |
104 | + | 116 | gen_commit_packet(ctx); |
105 | + if (n < NUM_PREGS) { | 117 | ctx->base.pc_next += pkt.encod_pkt_size_in_bytes; |
106 | + env->pred[n] = ldtul_p(mem_buf) & 0xff; | 118 | } else { |
107 | + return sizeof(uint8_t); | 119 | - gen_exception_end_tb(ctx, HEX_EXCP_INVALID_PACKET); |
108 | + } | 120 | + gen_exception_end_tb(ctx, HEX_CAUSE_INVALID_PACKET); |
109 | + | 121 | } |
110 | + n -= NUM_PREGS; | ||
111 | + | ||
112 | g_assert_not_reached(); | ||
113 | } | 122 | } |
114 | 123 | ||
115 | -- | 124 | -- |
116 | 2.34.1 | 125 | 2.34.1 |
117 | 126 | diff view generated by jsdifflib |
1 | Define a hexagon_cpu_properties list to match the idiom used | 1 | From: Brian Cain <bcain@quicinc.com> |
---|---|---|---|
2 | by other targets. | ||
3 | 2 | ||
4 | Signed-off-by: Brian Cain <bcain@quicinc.com> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com> | 3 | Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com> |
4 | Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com> | ||
7 | --- | 5 | --- |
8 | target/hexagon/cpu.c | 18 ++++++++---------- | 6 | target/hexagon/cpu_bits.h | 22 ++++++++++++++-------- |
9 | 1 file changed, 8 insertions(+), 10 deletions(-) | 7 | 1 file changed, 14 insertions(+), 8 deletions(-) |
10 | 8 | ||
11 | diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c | 9 | diff --git a/target/hexagon/cpu_bits.h b/target/hexagon/cpu_bits.h |
12 | index XXXXXXX..XXXXXXX 100644 | 10 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/hexagon/cpu.c | 11 | --- a/target/hexagon/cpu_bits.h |
14 | +++ b/target/hexagon/cpu.c | 12 | +++ b/target/hexagon/cpu_bits.h |
15 | @@ -XXX,XX +XXX,XX @@ static ObjectClass *hexagon_cpu_class_by_name(const char *cpu_model) | 13 | @@ -XXX,XX +XXX,XX @@ |
16 | return oc; | 14 | #define PCALIGN 4 |
17 | } | 15 | #define PCALIGN_MASK (PCALIGN - 1) |
18 | 16 | ||
19 | -static Property hexagon_lldb_compat_property = | 17 | -#define HEX_EVENT_TRAP0 0x008 |
20 | - DEFINE_PROP_BOOL("lldb-compat", HexagonCPU, lldb_compat, false); | 18 | +enum hex_event { |
21 | -static Property hexagon_lldb_stack_adjust_property = | 19 | + HEX_EVENT_NONE = -1, |
22 | - DEFINE_PROP_UNSIGNED("lldb-stack-adjust", HexagonCPU, lldb_stack_adjust, | 20 | + HEX_EVENT_TRAP0 = 0x008, |
23 | - 0, qdev_prop_uint32, target_ulong); | ||
24 | -static Property hexagon_short_circuit_property = | ||
25 | - DEFINE_PROP_BOOL("short-circuit", HexagonCPU, short_circuit, true); | ||
26 | +static Property hexagon_cpu_properties[] = { | ||
27 | + DEFINE_PROP_BOOL("lldb-compat", HexagonCPU, lldb_compat, false), | ||
28 | + DEFINE_PROP_UNSIGNED("lldb-stack-adjust", HexagonCPU, lldb_stack_adjust, 0, | ||
29 | + qdev_prop_uint32, target_ulong), | ||
30 | + DEFINE_PROP_BOOL("short-circuit", HexagonCPU, short_circuit, true), | ||
31 | + DEFINE_PROP_END_OF_LIST() | ||
32 | +}; | 21 | +}; |
33 | 22 | ||
34 | const char * const hexagon_regnames[TOTAL_PER_THREAD_REGS] = { | 23 | -#define HEX_CAUSE_TRAP0 0x172 |
35 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | 24 | -#define HEX_CAUSE_FETCH_NO_UPAGE 0x012 |
36 | @@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp) | 25 | -#define HEX_CAUSE_INVALID_PACKET 0x015 |
37 | 26 | -#define HEX_CAUSE_INVALID_OPCODE 0x015 | |
38 | static void hexagon_cpu_init(Object *obj) | 27 | -#define HEX_CAUSE_PC_NOT_ALIGNED 0x01e |
39 | { | 28 | -#define HEX_CAUSE_PRIV_NO_UREAD 0x024 |
40 | - qdev_property_add_static(DEVICE(obj), &hexagon_lldb_compat_property); | 29 | -#define HEX_CAUSE_PRIV_NO_UWRITE 0x025 |
41 | - qdev_property_add_static(DEVICE(obj), &hexagon_lldb_stack_adjust_property); | 30 | +enum hex_cause { |
42 | - qdev_property_add_static(DEVICE(obj), &hexagon_short_circuit_property); | 31 | + HEX_CAUSE_NONE = -1, |
43 | } | 32 | + HEX_CAUSE_TRAP0 = 0x172, |
44 | 33 | + HEX_CAUSE_FETCH_NO_UPAGE = 0x012, | |
45 | #include "hw/core/tcg-cpu-ops.h" | 34 | + HEX_CAUSE_INVALID_PACKET = 0x015, |
46 | @@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_class_init(ObjectClass *c, void *data) | 35 | + HEX_CAUSE_INVALID_OPCODE = 0x015, |
47 | device_class_set_parent_realize(dc, hexagon_cpu_realize, | 36 | + HEX_CAUSE_PC_NOT_ALIGNED = 0x01e, |
48 | &mcc->parent_realize); | 37 | + HEX_CAUSE_PRIV_NO_UREAD = 0x024, |
49 | 38 | + HEX_CAUSE_PRIV_NO_UWRITE = 0x025, | |
50 | + device_class_set_props(dc, hexagon_cpu_properties); | 39 | +}; |
51 | resettable_class_set_parent_phases(rc, NULL, hexagon_cpu_reset_hold, NULL, | 40 | |
52 | &mcc->parent_phases); | 41 | #define PACKET_WORDS_MAX 4 |
53 | 42 | ||
54 | -- | 43 | -- |
55 | 2.34.1 | 44 | 2.34.1 |
56 | 45 | diff view generated by jsdifflib |
1 | For now, v66 behavior is the same as other CPUs. | 1 | From: Anton Johansson <anjo@rev.ng> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Brian Cain <bcain@quicinc.com> | 3 | QOL commit, all the various gen_* python scripts take a large set |
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 4 | arguments where order is implicit. Using argparse we also get decent |
5 | Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com> | 5 | error messages if a field is missing or too many are added. |
6 | |||
7 | Signed-off-by: Anton Johansson <anjo@rev.ng> | ||
8 | Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com> | ||
9 | Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com> | ||
6 | --- | 10 | --- |
7 | target/hexagon/cpu-qom.h | 1 + | 11 | target/hexagon/gen_analyze_funcs.py | 6 +++-- |
8 | target/hexagon/cpu.c | 2 ++ | 12 | target/hexagon/gen_decodetree.py | 19 +++++++++++--- |
9 | 2 files changed, 3 insertions(+) | 13 | target/hexagon/gen_helper_funcs.py | 7 +++--- |
14 | target/hexagon/gen_helper_protos.py | 7 +++--- | ||
15 | target/hexagon/gen_idef_parser_funcs.py | 11 +++++++-- | ||
16 | target/hexagon/gen_op_attribs.py | 11 +++++++-- | ||
17 | target/hexagon/gen_opcodes_def.py | 11 +++++++-- | ||
18 | target/hexagon/gen_printinsn.py | 11 +++++++-- | ||
19 | target/hexagon/gen_tcg_func_table.py | 11 +++++++-- | ||
20 | target/hexagon/gen_tcg_funcs.py | 9 ++++--- | ||
21 | target/hexagon/gen_trans_funcs.py | 18 +++++++++++--- | ||
22 | target/hexagon/hex_common.py | 33 ++++++++++++------------- | ||
23 | target/hexagon/meson.build | 2 +- | ||
24 | 13 files changed, 109 insertions(+), 47 deletions(-) | ||
10 | 25 | ||
11 | diff --git a/target/hexagon/cpu-qom.h b/target/hexagon/cpu-qom.h | 26 | diff --git a/target/hexagon/gen_analyze_funcs.py b/target/hexagon/gen_analyze_funcs.py |
27 | index XXXXXXX..XXXXXXX 100755 | ||
28 | --- a/target/hexagon/gen_analyze_funcs.py | ||
29 | +++ b/target/hexagon/gen_analyze_funcs.py | ||
30 | @@ -XXX,XX +XXX,XX @@ def gen_analyze_func(f, tag, regs, imms): | ||
31 | |||
32 | |||
33 | def main(): | ||
34 | - hex_common.read_common_files() | ||
35 | + args = hex_common.parse_common_args( | ||
36 | + "Emit functions analyzing register accesses" | ||
37 | + ) | ||
38 | tagregs = hex_common.get_tagregs() | ||
39 | tagimms = hex_common.get_tagimms() | ||
40 | |||
41 | - with open(sys.argv[-1], "w") as f: | ||
42 | + with open(args.out, "w") as f: | ||
43 | f.write("#ifndef HEXAGON_ANALYZE_FUNCS_C_INC\n") | ||
44 | f.write("#define HEXAGON_ANALYZE_FUNCS_C_INC\n\n") | ||
45 | |||
46 | diff --git a/target/hexagon/gen_decodetree.py b/target/hexagon/gen_decodetree.py | ||
47 | index XXXXXXX..XXXXXXX 100755 | ||
48 | --- a/target/hexagon/gen_decodetree.py | ||
49 | +++ b/target/hexagon/gen_decodetree.py | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | import textwrap | ||
52 | import iset | ||
53 | import hex_common | ||
54 | +import argparse | ||
55 | |||
56 | encs = { | ||
57 | tag: "".join(reversed(iset.iset[tag]["enc"].replace(" ", ""))) | ||
58 | @@ -XXX,XX +XXX,XX @@ def gen_decodetree_file(f, class_to_decode): | ||
59 | f.write(f"{tag}\t{enc_str} @{tag}\n") | ||
60 | |||
61 | |||
62 | +def main(): | ||
63 | + parser = argparse.ArgumentParser( | ||
64 | + description="Emit opaque macro calls with instruction semantics" | ||
65 | + ) | ||
66 | + parser.add_argument("semantics", help="semantics file") | ||
67 | + parser.add_argument("class_to_decode", help="instruction class to decode") | ||
68 | + parser.add_argument("out", help="output file") | ||
69 | + args = parser.parse_args() | ||
70 | + | ||
71 | + hex_common.read_semantics_file(args.semantics) | ||
72 | + with open(args.out, "w") as f: | ||
73 | + gen_decodetree_file(f, args.class_to_decode) | ||
74 | + | ||
75 | if __name__ == "__main__": | ||
76 | - hex_common.read_semantics_file(sys.argv[1]) | ||
77 | - class_to_decode = sys.argv[2] | ||
78 | - with open(sys.argv[3], "w") as f: | ||
79 | - gen_decodetree_file(f, class_to_decode) | ||
80 | + main() | ||
81 | diff --git a/target/hexagon/gen_helper_funcs.py b/target/hexagon/gen_helper_funcs.py | ||
82 | index XXXXXXX..XXXXXXX 100755 | ||
83 | --- a/target/hexagon/gen_helper_funcs.py | ||
84 | +++ b/target/hexagon/gen_helper_funcs.py | ||
85 | @@ -XXX,XX +XXX,XX @@ def gen_helper_function(f, tag, tagregs, tagimms): | ||
86 | |||
87 | |||
88 | def main(): | ||
89 | - hex_common.read_common_files() | ||
90 | + args = hex_common.parse_common_args( | ||
91 | + "Emit helper function definitions for each instruction" | ||
92 | + ) | ||
93 | tagregs = hex_common.get_tagregs() | ||
94 | tagimms = hex_common.get_tagimms() | ||
95 | |||
96 | - output_file = sys.argv[-1] | ||
97 | - with open(output_file, "w") as f: | ||
98 | + with open(args.out, "w") as f: | ||
99 | for tag in hex_common.tags: | ||
100 | ## Skip the priv instructions | ||
101 | if "A_PRIV" in hex_common.attribdict[tag]: | ||
102 | diff --git a/target/hexagon/gen_helper_protos.py b/target/hexagon/gen_helper_protos.py | ||
103 | index XXXXXXX..XXXXXXX 100755 | ||
104 | --- a/target/hexagon/gen_helper_protos.py | ||
105 | +++ b/target/hexagon/gen_helper_protos.py | ||
106 | @@ -XXX,XX +XXX,XX @@ def gen_helper_prototype(f, tag, tagregs, tagimms): | ||
107 | |||
108 | |||
109 | def main(): | ||
110 | - hex_common.read_common_files() | ||
111 | + args = hex_common.parse_common_args( | ||
112 | + "Emit helper function prototypes for each instruction" | ||
113 | + ) | ||
114 | tagregs = hex_common.get_tagregs() | ||
115 | tagimms = hex_common.get_tagimms() | ||
116 | |||
117 | - output_file = sys.argv[-1] | ||
118 | - with open(output_file, "w") as f: | ||
119 | + with open(args.out, "w") as f: | ||
120 | for tag in hex_common.tags: | ||
121 | ## Skip the priv instructions | ||
122 | if "A_PRIV" in hex_common.attribdict[tag]: | ||
123 | diff --git a/target/hexagon/gen_idef_parser_funcs.py b/target/hexagon/gen_idef_parser_funcs.py | ||
12 | index XXXXXXX..XXXXXXX 100644 | 124 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/hexagon/cpu-qom.h | 125 | --- a/target/hexagon/gen_idef_parser_funcs.py |
14 | +++ b/target/hexagon/cpu-qom.h | 126 | +++ b/target/hexagon/gen_idef_parser_funcs.py |
15 | @@ -XXX,XX +XXX,XX @@ | 127 | @@ -XXX,XX +XXX,XX @@ |
16 | #define HEXAGON_CPU_TYPE_SUFFIX "-" TYPE_HEXAGON_CPU | 128 | import sys |
17 | #define HEXAGON_CPU_TYPE_NAME(name) (name HEXAGON_CPU_TYPE_SUFFIX) | 129 | import re |
18 | 130 | import string | |
19 | +#define TYPE_HEXAGON_CPU_V66 HEXAGON_CPU_TYPE_NAME("v66") | 131 | +import argparse |
20 | #define TYPE_HEXAGON_CPU_V67 HEXAGON_CPU_TYPE_NAME("v67") | 132 | from io import StringIO |
21 | #define TYPE_HEXAGON_CPU_V68 HEXAGON_CPU_TYPE_NAME("v68") | 133 | |
22 | #define TYPE_HEXAGON_CPU_V69 HEXAGON_CPU_TYPE_NAME("v69") | 134 | import hex_common |
23 | diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c | 135 | @@ -XXX,XX +XXX,XX @@ |
136 | ## them are inputs ("in" prefix), while some others are outputs. | ||
137 | ## | ||
138 | def main(): | ||
139 | - hex_common.read_semantics_file(sys.argv[1]) | ||
140 | + parser = argparse.ArgumentParser( | ||
141 | + "Emit instruction implementations that can be fed to idef-parser" | ||
142 | + ) | ||
143 | + parser.add_argument("semantics", help="semantics file") | ||
144 | + parser.add_argument("out", help="output file") | ||
145 | + args = parser.parse_args() | ||
146 | + hex_common.read_semantics_file(args.semantics) | ||
147 | hex_common.calculate_attribs() | ||
148 | hex_common.init_registers() | ||
149 | tagregs = hex_common.get_tagregs() | ||
150 | tagimms = hex_common.get_tagimms() | ||
151 | |||
152 | - with open(sys.argv[-1], "w") as f: | ||
153 | + with open(args.out, "w") as f: | ||
154 | f.write('#include "macros.h.inc"\n\n') | ||
155 | |||
156 | for tag in hex_common.tags: | ||
157 | diff --git a/target/hexagon/gen_op_attribs.py b/target/hexagon/gen_op_attribs.py | ||
158 | index XXXXXXX..XXXXXXX 100755 | ||
159 | --- a/target/hexagon/gen_op_attribs.py | ||
160 | +++ b/target/hexagon/gen_op_attribs.py | ||
161 | @@ -XXX,XX +XXX,XX @@ | ||
162 | import re | ||
163 | import string | ||
164 | import hex_common | ||
165 | +import argparse | ||
166 | |||
167 | |||
168 | def main(): | ||
169 | - hex_common.read_semantics_file(sys.argv[1]) | ||
170 | + parser = argparse.ArgumentParser( | ||
171 | + "Emit opaque macro calls containing instruction attributes" | ||
172 | + ) | ||
173 | + parser.add_argument("semantics", help="semantics file") | ||
174 | + parser.add_argument("out", help="output file") | ||
175 | + args = parser.parse_args() | ||
176 | + hex_common.read_semantics_file(args.semantics) | ||
177 | hex_common.calculate_attribs() | ||
178 | |||
179 | ## | ||
180 | ## Generate all the attributes associated with each instruction | ||
181 | ## | ||
182 | - with open(sys.argv[-1], "w") as f: | ||
183 | + with open(args.out, "w") as f: | ||
184 | for tag in hex_common.tags: | ||
185 | f.write( | ||
186 | f"OP_ATTRIB({tag},ATTRIBS(" | ||
187 | diff --git a/target/hexagon/gen_opcodes_def.py b/target/hexagon/gen_opcodes_def.py | ||
188 | index XXXXXXX..XXXXXXX 100755 | ||
189 | --- a/target/hexagon/gen_opcodes_def.py | ||
190 | +++ b/target/hexagon/gen_opcodes_def.py | ||
191 | @@ -XXX,XX +XXX,XX @@ | ||
192 | import re | ||
193 | import string | ||
194 | import hex_common | ||
195 | +import argparse | ||
196 | |||
197 | |||
198 | def main(): | ||
199 | - hex_common.read_semantics_file(sys.argv[1]) | ||
200 | + parser = argparse.ArgumentParser( | ||
201 | + description="Emit opaque macro calls with instruction names" | ||
202 | + ) | ||
203 | + parser.add_argument("semantics", help="semantics file") | ||
204 | + parser.add_argument("out", help="output file") | ||
205 | + args = parser.parse_args() | ||
206 | + hex_common.read_semantics_file(args.semantics) | ||
207 | |||
208 | ## | ||
209 | ## Generate a list of all the opcodes | ||
210 | ## | ||
211 | - with open(sys.argv[-1], "w") as f: | ||
212 | + with open(args.out, "w") as f: | ||
213 | for tag in hex_common.tags: | ||
214 | f.write(f"OPCODE({tag}),\n") | ||
215 | |||
216 | diff --git a/target/hexagon/gen_printinsn.py b/target/hexagon/gen_printinsn.py | ||
217 | index XXXXXXX..XXXXXXX 100755 | ||
218 | --- a/target/hexagon/gen_printinsn.py | ||
219 | +++ b/target/hexagon/gen_printinsn.py | ||
220 | @@ -XXX,XX +XXX,XX @@ | ||
221 | import re | ||
222 | import string | ||
223 | import hex_common | ||
224 | +import argparse | ||
225 | |||
226 | |||
227 | ## | ||
228 | @@ -XXX,XX +XXX,XX @@ def spacify(s): | ||
229 | |||
230 | |||
231 | def main(): | ||
232 | - hex_common.read_semantics_file(sys.argv[1]) | ||
233 | + parser = argparse.ArgumentParser( | ||
234 | + "Emit opaque macro calls with information for printing string representations of instrucions" | ||
235 | + ) | ||
236 | + parser.add_argument("semantics", help="semantics file") | ||
237 | + parser.add_argument("out", help="output file") | ||
238 | + args = parser.parse_args() | ||
239 | + hex_common.read_semantics_file(args.semantics) | ||
240 | |||
241 | immext_casere = re.compile(r"IMMEXT\(([A-Za-z])") | ||
242 | |||
243 | - with open(sys.argv[-1], "w") as f: | ||
244 | + with open(args.out, "w") as f: | ||
245 | for tag in hex_common.tags: | ||
246 | if not hex_common.behdict[tag]: | ||
247 | continue | ||
248 | diff --git a/target/hexagon/gen_tcg_func_table.py b/target/hexagon/gen_tcg_func_table.py | ||
249 | index XXXXXXX..XXXXXXX 100755 | ||
250 | --- a/target/hexagon/gen_tcg_func_table.py | ||
251 | +++ b/target/hexagon/gen_tcg_func_table.py | ||
252 | @@ -XXX,XX +XXX,XX @@ | ||
253 | import re | ||
254 | import string | ||
255 | import hex_common | ||
256 | +import argparse | ||
257 | |||
258 | |||
259 | def main(): | ||
260 | - hex_common.read_semantics_file(sys.argv[1]) | ||
261 | + parser = argparse.ArgumentParser( | ||
262 | + "Emit opaque macro calls with instruction semantics" | ||
263 | + ) | ||
264 | + parser.add_argument("semantics", help="semantics file") | ||
265 | + parser.add_argument("out", help="output file") | ||
266 | + args = parser.parse_args() | ||
267 | + hex_common.read_semantics_file(args.semantics) | ||
268 | hex_common.calculate_attribs() | ||
269 | tagregs = hex_common.get_tagregs() | ||
270 | tagimms = hex_common.get_tagimms() | ||
271 | |||
272 | - with open(sys.argv[-1], "w") as f: | ||
273 | + with open(args.out, "w") as f: | ||
274 | f.write("#ifndef HEXAGON_FUNC_TABLE_H\n") | ||
275 | f.write("#define HEXAGON_FUNC_TABLE_H\n\n") | ||
276 | |||
277 | diff --git a/target/hexagon/gen_tcg_funcs.py b/target/hexagon/gen_tcg_funcs.py | ||
278 | index XXXXXXX..XXXXXXX 100755 | ||
279 | --- a/target/hexagon/gen_tcg_funcs.py | ||
280 | +++ b/target/hexagon/gen_tcg_funcs.py | ||
281 | @@ -XXX,XX +XXX,XX @@ def gen_def_tcg_func(f, tag, tagregs, tagimms): | ||
282 | |||
283 | |||
284 | def main(): | ||
285 | - is_idef_parser_enabled = hex_common.read_common_files() | ||
286 | + args = hex_common.parse_common_args( | ||
287 | + "Emit functions calling generated code implementing instruction semantics (helpers, idef-parser)" | ||
288 | + ) | ||
289 | tagregs = hex_common.get_tagregs() | ||
290 | tagimms = hex_common.get_tagimms() | ||
291 | |||
292 | - output_file = sys.argv[-1] | ||
293 | - with open(output_file, "w") as f: | ||
294 | + with open(args.out, "w") as f: | ||
295 | f.write("#ifndef HEXAGON_TCG_FUNCS_H\n") | ||
296 | f.write("#define HEXAGON_TCG_FUNCS_H\n\n") | ||
297 | - if is_idef_parser_enabled: | ||
298 | + if args.idef_parser: | ||
299 | f.write('#include "idef-generated-emitter.h.inc"\n\n') | ||
300 | |||
301 | for tag in hex_common.tags: | ||
302 | diff --git a/target/hexagon/gen_trans_funcs.py b/target/hexagon/gen_trans_funcs.py | ||
303 | index XXXXXXX..XXXXXXX 100755 | ||
304 | --- a/target/hexagon/gen_trans_funcs.py | ||
305 | +++ b/target/hexagon/gen_trans_funcs.py | ||
306 | @@ -XXX,XX +XXX,XX @@ | ||
307 | import textwrap | ||
308 | import iset | ||
309 | import hex_common | ||
310 | +import argparse | ||
311 | |||
312 | encs = { | ||
313 | tag: "".join(reversed(iset.iset[tag]["enc"].replace(" ", ""))) | ||
314 | @@ -XXX,XX +XXX,XX @@ def gen_trans_funcs(f): | ||
315 | """)) | ||
316 | |||
317 | |||
318 | -if __name__ == "__main__": | ||
319 | - hex_common.read_semantics_file(sys.argv[1]) | ||
320 | +def main(): | ||
321 | + parser = argparse.ArgumentParser( | ||
322 | + description="Emit trans_*() functions to be called by " \ | ||
323 | + "instruction decoder" | ||
324 | + ) | ||
325 | + parser.add_argument("semantics", help="semantics file") | ||
326 | + parser.add_argument("out", help="output file") | ||
327 | + args = parser.parse_args() | ||
328 | + hex_common.read_semantics_file(args.semantics) | ||
329 | hex_common.init_registers() | ||
330 | - with open(sys.argv[2], "w") as f: | ||
331 | + with open(args.out, "w") as f: | ||
332 | gen_trans_funcs(f) | ||
333 | + | ||
334 | + | ||
335 | +if __name__ == "__main__": | ||
336 | + main() | ||
337 | diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py | ||
338 | index XXXXXXX..XXXXXXX 100755 | ||
339 | --- a/target/hexagon/hex_common.py | ||
340 | +++ b/target/hexagon/hex_common.py | ||
341 | @@ -XXX,XX +XXX,XX @@ | ||
342 | import re | ||
343 | import string | ||
344 | import textwrap | ||
345 | +import argparse | ||
346 | |||
347 | behdict = {} # tag ->behavior | ||
348 | semdict = {} # tag -> semantics | ||
349 | @@ -XXX,XX +XXX,XX @@ def helper_args(tag, regs, imms): | ||
350 | return args | ||
351 | |||
352 | |||
353 | -def read_common_files(): | ||
354 | - read_semantics_file(sys.argv[1]) | ||
355 | - read_overrides_file(sys.argv[2]) | ||
356 | - read_overrides_file(sys.argv[3]) | ||
357 | - ## Whether or not idef-parser is enabled is | ||
358 | - ## determined by the number of arguments to | ||
359 | - ## this script: | ||
360 | - ## | ||
361 | - ## 4 args. -> not enabled, | ||
362 | - ## 5 args. -> idef-parser enabled. | ||
363 | - ## | ||
364 | - ## The 5:th arg. then holds a list of the successfully | ||
365 | - ## parsed instructions. | ||
366 | - is_idef_parser_enabled = len(sys.argv) > 5 | ||
367 | - if is_idef_parser_enabled: | ||
368 | - read_idef_parser_enabled_file(sys.argv[4]) | ||
369 | +def parse_common_args(desc): | ||
370 | + parser = argparse.ArgumentParser(desc) | ||
371 | + parser.add_argument("semantics", help="semantics file") | ||
372 | + parser.add_argument("overrides", help="overrides file") | ||
373 | + parser.add_argument("overrides_vec", help="vector overrides file") | ||
374 | + parser.add_argument("out", help="output file") | ||
375 | + parser.add_argument("--idef-parser", | ||
376 | + help="file of instructions translated by idef-parser") | ||
377 | + args = parser.parse_args() | ||
378 | + read_semantics_file(args.semantics) | ||
379 | + read_overrides_file(args.overrides) | ||
380 | + read_overrides_file(args.overrides_vec) | ||
381 | + if args.idef_parser: | ||
382 | + read_idef_parser_enabled_file(args.idef_parser) | ||
383 | calculate_attribs() | ||
384 | init_registers() | ||
385 | - return is_idef_parser_enabled | ||
386 | + return args | ||
387 | diff --git a/target/hexagon/meson.build b/target/hexagon/meson.build | ||
24 | index XXXXXXX..XXXXXXX 100644 | 388 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/hexagon/cpu.c | 389 | --- a/target/hexagon/meson.build |
26 | +++ b/target/hexagon/cpu.c | 390 | +++ b/target/hexagon/meson.build |
27 | @@ -XXX,XX +XXX,XX @@ | 391 | @@ -XXX,XX +XXX,XX @@ if idef_parser_enabled and 'hexagon-linux-user' in target_dirs |
28 | #include "tcg/tcg.h" | 392 | # Setup input and dependencies for the next step, this depends on whether or |
29 | #include "exec/gdbstub.h" | 393 | # not idef-parser is enabled |
30 | 394 | helper_dep = [semantics_generated, idef_generated_tcg_c, idef_generated_tcg] | |
31 | +static void hexagon_v66_cpu_init(Object *obj) { } | 395 | - helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, idef_generated_list] |
32 | static void hexagon_v67_cpu_init(Object *obj) { } | 396 | + helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, '--idef-parser', idef_generated_list] |
33 | static void hexagon_v68_cpu_init(Object *obj) { } | 397 | else |
34 | static void hexagon_v69_cpu_init(Object *obj) { } | 398 | # Setup input and dependencies for the next step, this depends on whether or |
35 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo hexagon_cpu_type_infos[] = { | 399 | # not idef-parser is enabled |
36 | .class_size = sizeof(HexagonCPUClass), | ||
37 | .class_init = hexagon_cpu_class_init, | ||
38 | }, | ||
39 | + DEFINE_CPU(TYPE_HEXAGON_CPU_V66, hexagon_v66_cpu_init), | ||
40 | DEFINE_CPU(TYPE_HEXAGON_CPU_V67, hexagon_v67_cpu_init), | ||
41 | DEFINE_CPU(TYPE_HEXAGON_CPU_V68, hexagon_v68_cpu_init), | ||
42 | DEFINE_CPU(TYPE_HEXAGON_CPU_V69, hexagon_v69_cpu_init), | ||
43 | -- | 400 | -- |
44 | 2.34.1 | 401 | 2.34.1 |
45 | 402 | diff view generated by jsdifflib |
1 | From: Anton Johansson <anjo@rev.ng> | 1 | From: Anton Johansson <anjo@rev.ng> |
---|---|---|---|
2 | 2 | ||
3 | The self assignment is clearly useless, and @1.last_column does not have | 3 | Adds restrict qualifier to HVX pointer arguments. This will allow the |
4 | to be set for an expression with only a single token, so remove it. | 4 | compiler to produce better optimized code, as input vectors are now |
5 | assumed not to alias, and no runtime aliasing checks will be required. | ||
5 | 6 | ||
6 | Reported-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Anton Johansson <anjo@rev.ng> | 7 | Signed-off-by: Anton Johansson <anjo@rev.ng> |
8 | Reviewed-by: Brian Cain <bcain@quicinc.com> | 8 | Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com> |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 9 | Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com> |
10 | Message-Id: <20230713120853.27023-1-anjo@rev.ng> | ||
11 | Signed-off-by: Brian Cain <bcain@quicinc.com> | ||
12 | --- | 10 | --- |
13 | target/hexagon/idef-parser/idef-parser.y | 1 - | 11 | target/hexagon/mmvec/macros.h | 36 +++++++++++++++++------------------ |
14 | 1 file changed, 1 deletion(-) | 12 | 1 file changed, 18 insertions(+), 18 deletions(-) |
15 | 13 | ||
16 | diff --git a/target/hexagon/idef-parser/idef-parser.y b/target/hexagon/idef-parser/idef-parser.y | 14 | diff --git a/target/hexagon/mmvec/macros.h b/target/hexagon/mmvec/macros.h |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/hexagon/idef-parser/idef-parser.y | 16 | --- a/target/hexagon/mmvec/macros.h |
19 | +++ b/target/hexagon/idef-parser/idef-parser.y | 17 | +++ b/target/hexagon/mmvec/macros.h |
20 | @@ -XXX,XX +XXX,XX @@ rvalue : FAIL | 18 | @@ -XXX,XX +XXX,XX @@ |
21 | 19 | #include "mmvec/system_ext_mmvec.h" | |
22 | lvalue : FAIL | 20 | |
23 | { | 21 | #ifndef QEMU_GENERATE |
24 | - @1.last_column = @1.last_column; | 22 | -#define VdV (*(MMVector *)(VdV_void)) |
25 | yyassert(c, &@1, false, "Encountered a FAIL token as lvalue.\n"); | 23 | -#define VsV (*(MMVector *)(VsV_void)) |
26 | } | 24 | -#define VuV (*(MMVector *)(VuV_void)) |
27 | | REG | 25 | -#define VvV (*(MMVector *)(VvV_void)) |
26 | -#define VwV (*(MMVector *)(VwV_void)) | ||
27 | -#define VxV (*(MMVector *)(VxV_void)) | ||
28 | -#define VyV (*(MMVector *)(VyV_void)) | ||
29 | +#define VdV (*(MMVector *restrict)(VdV_void)) | ||
30 | +#define VsV (*(MMVector *restrict)(VsV_void)) | ||
31 | +#define VuV (*(MMVector *restrict)(VuV_void)) | ||
32 | +#define VvV (*(MMVector *restrict)(VvV_void)) | ||
33 | +#define VwV (*(MMVector *restrict)(VwV_void)) | ||
34 | +#define VxV (*(MMVector *restrict)(VxV_void)) | ||
35 | +#define VyV (*(MMVector *restrict)(VyV_void)) | ||
36 | |||
37 | -#define VddV (*(MMVectorPair *)(VddV_void)) | ||
38 | -#define VuuV (*(MMVectorPair *)(VuuV_void)) | ||
39 | -#define VvvV (*(MMVectorPair *)(VvvV_void)) | ||
40 | -#define VxxV (*(MMVectorPair *)(VxxV_void)) | ||
41 | +#define VddV (*(MMVectorPair *restrict)(VddV_void)) | ||
42 | +#define VuuV (*(MMVectorPair *restrict)(VuuV_void)) | ||
43 | +#define VvvV (*(MMVectorPair *restrict)(VvvV_void)) | ||
44 | +#define VxxV (*(MMVectorPair *restrict)(VxxV_void)) | ||
45 | |||
46 | -#define QeV (*(MMQReg *)(QeV_void)) | ||
47 | -#define QdV (*(MMQReg *)(QdV_void)) | ||
48 | -#define QsV (*(MMQReg *)(QsV_void)) | ||
49 | -#define QtV (*(MMQReg *)(QtV_void)) | ||
50 | -#define QuV (*(MMQReg *)(QuV_void)) | ||
51 | -#define QvV (*(MMQReg *)(QvV_void)) | ||
52 | -#define QxV (*(MMQReg *)(QxV_void)) | ||
53 | +#define QeV (*(MMQReg *restrict)(QeV_void)) | ||
54 | +#define QdV (*(MMQReg *restrict)(QdV_void)) | ||
55 | +#define QsV (*(MMQReg *restrict)(QsV_void)) | ||
56 | +#define QtV (*(MMQReg *restrict)(QtV_void)) | ||
57 | +#define QuV (*(MMQReg *restrict)(QuV_void)) | ||
58 | +#define QvV (*(MMQReg *restrict)(QvV_void)) | ||
59 | +#define QxV (*(MMQReg *restrict)(QxV_void)) | ||
60 | #endif | ||
61 | |||
62 | #define LOG_VTCM_BYTE(VA, MASK, VAL, IDX) \ | ||
28 | -- | 63 | -- |
29 | 2.34.1 | 64 | 2.34.1 |
30 | 65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Add my git tree for hexagon. Note that the branch is "hex-next" and not | ||
2 | "hex.next" as had been used previously. But I'll keep the "hex.next" branch | ||
3 | in sync with "hex-next" until this commit lands to avoid confusion. | ||
4 | 1 | ||
5 | Signed-off-by: Brian Cain <bcain@quicinc.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | --- | ||
9 | MAINTAINERS | 1 + | ||
10 | 1 file changed, 1 insertion(+) | ||
11 | |||
12 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/MAINTAINERS | ||
15 | +++ b/MAINTAINERS | ||
16 | @@ -XXX,XX +XXX,XX @@ F: disas/hexagon.c | ||
17 | F: configs/targets/hexagon-linux-user/default.mak | ||
18 | F: docker/dockerfiles/debian-hexagon-cross.docker | ||
19 | F: gdb-xml/hexagon*.xml | ||
20 | +T: git https://github.com/quic/qemu.git hex-next | ||
21 | |||
22 | Hexagon idef-parser | ||
23 | M: Alessandro Di Federico <ale@rev.ng> | ||
24 | -- | ||
25 | 2.34.1 | ||
26 | diff view generated by jsdifflib |