Merge tag 'pull-hex-20241212' of https://github.com/quic/qemu into staging

Remove HEX_DEBUG, EXCP/CAUSE fixes

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEPWaq5HRZSCTIjOD4GlSvuOVkbDIFAmdbtW4ACgkQGlSvuOVk
# bDJTOxAArBX1tuF46hpqsUIENvfKEXgb64W9YjzPi4CsFM90FP/4zVkxoLVjkyxe
# jhngUsgNc/p7gEGhW8/OGPVwYrvXdS486E32+l4Qv2E7lWR7nNP0PeNdVYUiZotB
# hALWMAwUWVXy23gMFlzjIyuRBYtRNhjwP6aLmbyWVqNhVckhpiQRxlNmv5+0nLmi
# 1mp92z6ziBJK4i8HX7Nm4ske4b0mHhtmkOZe8ulx+Ky3Ag+q1wptt+XIMnv7dTFT
# w7RH22LBQaRX6OKShRYspnDyMWQUaUXP8t4clnNOp+aesUpVyAlaB4mXj/uaSNlZ
# hX944xJoC3Qh5K5kh64nbnm8SpqRalwe7K0CvWEeVCRlO8uFmtI6IZ9hxuBnMl/v
# cHc+yaM3FG0BnN3GtCJIsl2x/8qQBChqS9EOLNhAzsbeyedHUSJCbnPKGtf0ggnK
# jwhsDEl/1jnZ+ZTZxT+bW1aAXvh/dowHDmz9joVdibnYNKdHox0ur1S0foZptFVQ
# TkFLkZ0m3AqgxWc4fL5xUvrN6o8EbZjzhG+gVuCP8rQANX90L2rGp7neteDRMviE
# V5D2a76iOor2qHwR6rc2Um0Kd6c8X0UUnDsBWW5TpqOvxfKsdbwfOI+c46+nZkGZ
# riFeeYpISv3g8wVvLK9HoTr30D4hQox3wyl7Bn6w8QXvcrcLk8w=
# =6vY4
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 12 Dec 2024 23:17:50 EST
# gpg:                using RSA key 3D66AAE474594824C88CE0F81A54AFB8E5646C32
# gpg: Good signature from "Brian Cain (OSS Qualcomm) <brian.cain@oss.qualcomm.com>" [unknown]
# gpg:                 aka "Brian Cain <bcain@kernel.org>" [unknown]
# gpg:                 aka "Brian Cain (QuIC) <bcain@quicinc.com>" [unknown]
# gpg:                 aka "Brian Cain (CAF) <bcain@codeaurora.org>" [unknown]
# gpg:                 aka "bcain" [unknown]
# gpg:                 aka "Brian Cain (QUIC) <quic_bcain@quicinc.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6350 20F9 67A7 7164 79EF  49E0 175C 464E 541B 6D47
#      Subkey fingerprint: 3D66 AAE4 7459 4824 C88C  E0F8 1A54 AFB8 E564 6C32

* tag 'pull-hex-20241212' of https://github.com/quic/qemu:
  target/hexagon: Make HVX vector args. restrict *
  target/hexagon: Use argparse in all python scripts
  target/hexagon: add enums for event, cause
  target/hexagon: rename HEX_EXCP_*=>HEX_CAUSE_*
  Hexagon (target/hexagon) Remove HEX_DEBUG/HEX_DEBUG_LOG

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi
2024-12-14 08:36:05 -05:00
25 changed files with 148 additions and 295 deletions
+2 -2
View File
@@ -42,7 +42,7 @@ void cpu_loop(CPUHexagonState *env)
case EXCP_INTERRUPT:
/* just indicate that signals should be handled asap */
break;
case HEX_EXCP_TRAP0:
case HEX_EVENT_TRAP0:
syscallnum = env->gpr[6];
env->gpr[HEX_REG_PC] += 4;
ret = do_syscall(env,
@@ -60,7 +60,7 @@ void cpu_loop(CPUHexagonState *env)
env->gpr[0] = ret;
}
break;
case HEX_EXCP_PC_NOT_ALIGNED:
case HEX_CAUSE_PC_NOT_ALIGNED:
force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN,
env->gpr[HEX_REG_R31]);
break;
-9
View File
@@ -282,10 +282,6 @@ For Hexagon Vector eXtensions (HVX), the following fields are used
*** Debugging ***
You can turn on a lot of debugging by changing the HEX_DEBUG macro to 1 in
internal.h. This will stream a lot of information as it generates TCG and
executes the code.
To track down nasty issues with Hexagon->TCG generation, we compare the
execution results with actual hardware running on a Hexagon Linux target.
Run qemu with the "-d cpu" option. Then, we can diff the results and figure
@@ -305,8 +301,3 @@ Here are some handy places to set breakpoints
The helper function for each instruction is named helper_<TAG>, so here's
an example that will set a breakpoint at the start
br helper_A2_add
If you have the HEX_DEBUG macro set, the following will be useful
At the start of execution of a packet for a given PC
br helper_debug_start_packet if env->gpr[41] == 0xdeadbeef
At the end of execution of a packet for a given PC
br helper_debug_commit_end if this_PC == 0xdeadbeef
+1 -7
View File
@@ -79,12 +79,6 @@ typedef struct CPUArchState {
uint8_t slot_cancelled;
target_ulong new_value_usr;
/*
* Only used when HEX_DEBUG is on, but unconditionally included
* to reduce recompile time when turning HEX_DEBUG on/off.
*/
target_ulong reg_written[TOTAL_PER_THREAD_REGS];
MemLog mem_log_stores[STORES_MAX];
float_status fp_status;
@@ -149,7 +143,7 @@ static inline void cpu_get_tb_cpu_state(CPUHexagonState *env, vaddr *pc,
}
*flags = hex_flags;
if (*pc & PCALIGN_MASK) {
hexagon_raise_exception_err(env, HEX_EXCP_PC_NOT_ALIGNED, 0);
hexagon_raise_exception_err(env, HEX_CAUSE_PC_NOT_ALIGNED, 0);
}
}
+14 -7
View File
@@ -23,14 +23,21 @@
#define PCALIGN 4
#define PCALIGN_MASK (PCALIGN - 1)
#define HEX_EXCP_FETCH_NO_UPAGE 0x012
#define HEX_EXCP_INVALID_PACKET 0x015
#define HEX_EXCP_INVALID_OPCODE 0x015
#define HEX_EXCP_PC_NOT_ALIGNED 0x01e
#define HEX_EXCP_PRIV_NO_UREAD 0x024
#define HEX_EXCP_PRIV_NO_UWRITE 0x025
enum hex_event {
HEX_EVENT_NONE = -1,
HEX_EVENT_TRAP0 = 0x008,
};
#define HEX_EXCP_TRAP0 0x172
enum hex_cause {
HEX_CAUSE_NONE = -1,
HEX_CAUSE_TRAP0 = 0x172,
HEX_CAUSE_FETCH_NO_UPAGE = 0x012,
HEX_CAUSE_INVALID_PACKET = 0x015,
HEX_CAUSE_INVALID_OPCODE = 0x015,
HEX_CAUSE_PC_NOT_ALIGNED = 0x01e,
HEX_CAUSE_PRIV_NO_UREAD = 0x024,
HEX_CAUSE_PRIV_NO_UWRITE = 0x025,
};
#define PACKET_WORDS_MAX 4
+4 -2
View File
@@ -78,11 +78,13 @@ def gen_analyze_func(f, tag, regs, imms):
def main():
hex_common.read_common_files()
args = hex_common.parse_common_args(
"Emit functions analyzing register accesses"
)
tagregs = hex_common.get_tagregs()
tagimms = hex_common.get_tagimms()
with open(sys.argv[-1], "w") as f:
with open(args.out, "w") as f:
f.write("#ifndef HEXAGON_ANALYZE_FUNCS_C_INC\n")
f.write("#define HEXAGON_ANALYZE_FUNCS_C_INC\n\n")
+15 -4
View File
@@ -24,6 +24,7 @@ import sys
import textwrap
import iset
import hex_common
import argparse
encs = {
tag: "".join(reversed(iset.iset[tag]["enc"].replace(" ", "")))
@@ -191,8 +192,18 @@ def gen_decodetree_file(f, class_to_decode):
f.write(f"{tag}\t{enc_str} @{tag}\n")
def main():
parser = argparse.ArgumentParser(
description="Emit opaque macro calls with instruction semantics"
)
parser.add_argument("semantics", help="semantics file")
parser.add_argument("class_to_decode", help="instruction class to decode")
parser.add_argument("out", help="output file")
args = parser.parse_args()
hex_common.read_semantics_file(args.semantics)
with open(args.out, "w") as f:
gen_decodetree_file(f, args.class_to_decode)
if __name__ == "__main__":
hex_common.read_semantics_file(sys.argv[1])
class_to_decode = sys.argv[2]
with open(sys.argv[3], "w") as f:
gen_decodetree_file(f, class_to_decode)
main()
+4 -3
View File
@@ -102,12 +102,13 @@ def gen_helper_function(f, tag, tagregs, tagimms):
def main():
hex_common.read_common_files()
args = hex_common.parse_common_args(
"Emit helper function definitions for each instruction"
)
tagregs = hex_common.get_tagregs()
tagimms = hex_common.get_tagimms()
output_file = sys.argv[-1]
with open(output_file, "w") as f:
with open(args.out, "w") as f:
for tag in hex_common.tags:
## Skip the priv instructions
if "A_PRIV" in hex_common.attribdict[tag]:
+4 -3
View File
@@ -52,12 +52,13 @@ def gen_helper_prototype(f, tag, tagregs, tagimms):
def main():
hex_common.read_common_files()
args = hex_common.parse_common_args(
"Emit helper function prototypes for each instruction"
)
tagregs = hex_common.get_tagregs()
tagimms = hex_common.get_tagimms()
output_file = sys.argv[-1]
with open(output_file, "w") as f:
with open(args.out, "w") as f:
for tag in hex_common.tags:
## Skip the priv instructions
if "A_PRIV" in hex_common.attribdict[tag]:
+9 -2
View File
@@ -20,6 +20,7 @@
import sys
import re
import string
import argparse
from io import StringIO
import hex_common
@@ -43,13 +44,19 @@ import hex_common
## them are inputs ("in" prefix), while some others are outputs.
##
def main():
hex_common.read_semantics_file(sys.argv[1])
parser = argparse.ArgumentParser(
"Emit instruction implementations that can be fed to idef-parser"
)
parser.add_argument("semantics", help="semantics file")
parser.add_argument("out", help="output file")
args = parser.parse_args()
hex_common.read_semantics_file(args.semantics)
hex_common.calculate_attribs()
hex_common.init_registers()
tagregs = hex_common.get_tagregs()
tagimms = hex_common.get_tagimms()
with open(sys.argv[-1], "w") as f:
with open(args.out, "w") as f:
f.write('#include "macros.h.inc"\n\n')
for tag in hex_common.tags:
+9 -2
View File
@@ -21,16 +21,23 @@ import sys
import re
import string
import hex_common
import argparse
def main():
hex_common.read_semantics_file(sys.argv[1])
parser = argparse.ArgumentParser(
"Emit opaque macro calls containing instruction attributes"
)
parser.add_argument("semantics", help="semantics file")
parser.add_argument("out", help="output file")
args = parser.parse_args()
hex_common.read_semantics_file(args.semantics)
hex_common.calculate_attribs()
##
## Generate all the attributes associated with each instruction
##
with open(sys.argv[-1], "w") as f:
with open(args.out, "w") as f:
for tag in hex_common.tags:
f.write(
f"OP_ATTRIB({tag},ATTRIBS("
+9 -2
View File
@@ -21,15 +21,22 @@ import sys
import re
import string
import hex_common
import argparse
def main():
hex_common.read_semantics_file(sys.argv[1])
parser = argparse.ArgumentParser(
description="Emit opaque macro calls with instruction names"
)
parser.add_argument("semantics", help="semantics file")
parser.add_argument("out", help="output file")
args = parser.parse_args()
hex_common.read_semantics_file(args.semantics)
##
## Generate a list of all the opcodes
##
with open(sys.argv[-1], "w") as f:
with open(args.out, "w") as f:
for tag in hex_common.tags:
f.write(f"OPCODE({tag}),\n")
+9 -2
View File
@@ -21,6 +21,7 @@ import sys
import re
import string
import hex_common
import argparse
##
@@ -96,11 +97,17 @@ def spacify(s):
def main():
hex_common.read_semantics_file(sys.argv[1])
parser = argparse.ArgumentParser(
"Emit opaque macro calls with information for printing string representations of instrucions"
)
parser.add_argument("semantics", help="semantics file")
parser.add_argument("out", help="output file")
args = parser.parse_args()
hex_common.read_semantics_file(args.semantics)
immext_casere = re.compile(r"IMMEXT\(([A-Za-z])")
with open(sys.argv[-1], "w") as f:
with open(args.out, "w") as f:
for tag in hex_common.tags:
if not hex_common.behdict[tag]:
continue
+1 -1
View File
@@ -1365,7 +1365,7 @@
do { \
uiV = uiV; \
tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], ctx->pkt->pc); \
TCGv excp = tcg_constant_tl(HEX_EXCP_TRAP0); \
TCGv excp = tcg_constant_tl(HEX_EVENT_TRAP0); \
gen_helper_raise_exception(tcg_env, excp); \
} while (0)
#endif
+9 -2
View File
@@ -21,15 +21,22 @@ import sys
import re
import string
import hex_common
import argparse
def main():
hex_common.read_semantics_file(sys.argv[1])
parser = argparse.ArgumentParser(
"Emit opaque macro calls with instruction semantics"
)
parser.add_argument("semantics", help="semantics file")
parser.add_argument("out", help="output file")
args = parser.parse_args()
hex_common.read_semantics_file(args.semantics)
hex_common.calculate_attribs()
tagregs = hex_common.get_tagregs()
tagimms = hex_common.get_tagimms()
with open(sys.argv[-1], "w") as f:
with open(args.out, "w") as f:
f.write("#ifndef HEXAGON_FUNC_TABLE_H\n")
f.write("#define HEXAGON_FUNC_TABLE_H\n\n")
+5 -4
View File
@@ -108,15 +108,16 @@ def gen_def_tcg_func(f, tag, tagregs, tagimms):
def main():
is_idef_parser_enabled = hex_common.read_common_files()
args = hex_common.parse_common_args(
"Emit functions calling generated code implementing instruction semantics (helpers, idef-parser)"
)
tagregs = hex_common.get_tagregs()
tagimms = hex_common.get_tagimms()
output_file = sys.argv[-1]
with open(output_file, "w") as f:
with open(args.out, "w") as f:
f.write("#ifndef HEXAGON_TCG_FUNCS_H\n")
f.write("#define HEXAGON_TCG_FUNCS_H\n\n")
if is_idef_parser_enabled:
if args.idef_parser:
f.write('#include "idef-generated-emitter.h.inc"\n\n')
for tag in hex_common.tags:
+15 -3
View File
@@ -24,6 +24,7 @@ import sys
import textwrap
import iset
import hex_common
import argparse
encs = {
tag: "".join(reversed(iset.iset[tag]["enc"].replace(" ", "")))
@@ -136,8 +137,19 @@ def gen_trans_funcs(f):
"""))
if __name__ == "__main__":
hex_common.read_semantics_file(sys.argv[1])
def main():
parser = argparse.ArgumentParser(
description="Emit trans_*() functions to be called by " \
"instruction decoder"
)
parser.add_argument("semantics", help="semantics file")
parser.add_argument("out", help="output file")
args = parser.parse_args()
hex_common.read_semantics_file(args.semantics)
hex_common.init_registers()
with open(sys.argv[2], "w") as f:
with open(args.out, "w") as f:
gen_trans_funcs(f)
if __name__ == "__main__":
main()
-7
View File
@@ -100,10 +100,6 @@ void gen_log_reg_write(DisasContext *ctx, int rnum, TCGv val)
gen_masked_reg_write(val, hex_gpr[rnum], reg_mask);
tcg_gen_mov_tl(get_result_gpr(ctx, rnum), val);
if (HEX_DEBUG) {
/* Do this so HELPER(debug_commit_end) will know */
tcg_gen_movi_tl(hex_reg_written[rnum], 1);
}
}
static void gen_log_reg_write_pair(DisasContext *ctx, int rnum, TCGv_i64 val)
@@ -151,9 +147,6 @@ void gen_log_pred_write(DisasContext *ctx, int pnum, TCGv val)
} else {
tcg_gen_and_tl(pred, pred, base_val);
}
if (HEX_DEBUG) {
tcg_gen_ori_tl(ctx->pred_written, ctx->pred_written, 1 << pnum);
}
set_bit(pnum, ctx->pregs_written);
}
-3
View File
@@ -19,9 +19,6 @@
#include "helper_protos_generated.h.inc"
DEF_HELPER_FLAGS_2(raise_exception, TCG_CALL_NO_RETURN, noreturn, env, i32)
DEF_HELPER_1(debug_start_packet, void, env)
DEF_HELPER_FLAGS_3(debug_check_store_width, TCG_CALL_NO_WG, void, env, int, int)
DEF_HELPER_FLAGS_5(debug_commit_end, TCG_CALL_NO_WG, void, env, i32, int, int, int)
DEF_HELPER_2(commit_store, void, env, int)
DEF_HELPER_3(gather_store, void, env, i32, int)
DEF_HELPER_1(commit_hvx_stores, void, env)
+16 -17
View File
@@ -21,6 +21,7 @@ import sys
import re
import string
import textwrap
import argparse
behdict = {} # tag ->behavior
semdict = {} # tag -> semantics
@@ -1181,22 +1182,20 @@ def helper_args(tag, regs, imms):
return args
def read_common_files():
read_semantics_file(sys.argv[1])
read_overrides_file(sys.argv[2])
read_overrides_file(sys.argv[3])
## Whether or not idef-parser is enabled is
## determined by the number of arguments to
## this script:
##
## 4 args. -> not enabled,
## 5 args. -> idef-parser enabled.
##
## The 5:th arg. then holds a list of the successfully
## parsed instructions.
is_idef_parser_enabled = len(sys.argv) > 5
if is_idef_parser_enabled:
read_idef_parser_enabled_file(sys.argv[4])
def parse_common_args(desc):
parser = argparse.ArgumentParser(desc)
parser.add_argument("semantics", help="semantics file")
parser.add_argument("overrides", help="overrides file")
parser.add_argument("overrides_vec", help="vector overrides file")
parser.add_argument("out", help="output file")
parser.add_argument("--idef-parser",
help="file of instructions translated by idef-parser")
args = parser.parse_args()
read_semantics_file(args.semantics)
read_overrides_file(args.overrides)
read_overrides_file(args.overrides_vec)
if args.idef_parser:
read_idef_parser_enabled_file(args.idef_parser)
calculate_attribs()
init_registers()
return is_idef_parser_enabled
return args
-11
View File
@@ -20,17 +20,6 @@
#include "qemu/log.h"
/*
* Change HEX_DEBUG to 1 to turn on debugging output
*/
#define HEX_DEBUG 0
#define HEX_DEBUG_LOG(...) \
do { \
if (HEX_DEBUG) { \
qemu_log(__VA_ARGS__); \
} \
} while (0)
int hexagon_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
int hexagon_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
int hexagon_hvx_gdb_read_register(CPUState *env, GByteArray *mem_buf, int n);

Some files were not shown because too many files have changed in this diff Show More