From patchwork Fri Dec 13 04:18:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Cain X-Patchwork-Id: 13906481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B452DE7717D for ; Fri, 13 Dec 2024 04:20:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLx8p-0006av-H1; Thu, 12 Dec 2024 23:19:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8n-0006Zl-CG for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:01 -0500 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8k-00082W-DK for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:01 -0500 Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BCNj9x9028128 for ; Fri, 13 Dec 2024 04:18:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Aj00Z3p+h0VahwZ0D+VmE+kLTFmkMO18ZEMhQMOcVSE=; b=eaiVfaYl7JAkNQTD qIeDe7jVoPbqeEl5BuyZOwMc+WQ2CBMr58wT6l1d4SN8Cwi/HAHJd/2I5AqZ84Gk IPAaQLLf14veMsU127XOidNANLNhyGF5AZ4AKzL9+rJ6LnQ5AUdxswawy4Cci5mw oAm25Ks2cbgRye1Ge5D+P/okJ6ejwg6FfCadi59cf1r5XIwfYne/SnpDJQ+8/vDq FCIotOL75eP+CVywDOoKcym16+1oRJ6KCj14/a0pHfdPyXLkIUwjY6to8pftD6Hz EmDn1GDnjqKuWsFhGDG+LUjz6KMuQOL92pghhB1hPM98Z4jzHA/wD8ii7NSxuY47 dlmcsA== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 43fxw4tb0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 13 Dec 2024 04:18:54 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-725e8775611so1282063b3a.1 for ; Thu, 12 Dec 2024 20:18:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734063533; x=1734668333; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Aj00Z3p+h0VahwZ0D+VmE+kLTFmkMO18ZEMhQMOcVSE=; b=uYISg4T7sFjdpJ410DX93+0YnuIqcA3FRZCkbNE6YLWI3YcOVT/zp6wC4CiBGA0TVL Jip0nJfU629mOkXjEwgc7RB/lFwJOY9iX6whjcJeI5t0XHncpkHmrAFLDmulDecmXlJf dwUIsOX+DUMkwWTjF4dFejha71lcx6qcY9kCuapwrlJrO27itFmAwvu9Q3ORKl8MkSET oc3F1jgYisPFYORhA/Sh1oIIKMeC3WIB7TkF0f0WeLejZAHLRunNjybYoI+cqUvxT51p /EgnNAhfBoIf7YoOErOU+2sTGzRDBHeE/VdRxMLjd9DDryLaQ47WrQIe39Q7aiixtteP nGJQ== X-Gm-Message-State: AOJu0YyYZL9wELddriBkJPgh4le1V9v8sYNP+EsbWMIPwTTUbh0R1v+8 A703qxpSg++W6BQi9UajZa/ZnTTpIGPLLVNowxf2FAosATN+1pcUpojnAHcWHu+qnWXZHb/J5j1 bJq5mSiYabsxoFSFXZiAIAblRDAB4sC/ejwysf2r3JE+fRuJEM2vkYdUGPtting== X-Gm-Gg: ASbGncuxO8svpc7McgrXwxVvqSV7sGni/o9PgCgDaNgDTozG5LuQ0sx3rtCzvqL0Lx7 gevll63qNdsyry0sllkKKGZqZ15xH0VKKJUxLQee3oaDjgUWoigQ4Q1oLnnC7BBp0NyUA2X12QF TymgXsV7kYk9f1LBiuCbqkY1sa4h8Uy49+wHkTMk2Fln5tt/pFCVbWZk1zuFpQoPJTayHKK8CFZ 6tdjZA03GDUE7vkRtS+vvUKfdlYbVTQqUZKSPRKIn2KrKfz6Dp6psgzqRmMY8ulXgBassiiEk6W cFpjzp27GYQjtvY/kr+wDsDt1ecWWw== X-Received: by 2002:a05:6a00:2e89:b0:724:d758:f35 with SMTP id d2e1a72fcca58-7290c0def31mr1622830b3a.2.1734063533226; Thu, 12 Dec 2024 20:18:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVBJI3FbX7arlXXKowHeSgRhsyNlaywMCm4xPV6K1Dp7jg+VoQ19wMEImNuikNaq/Va+G8FQ== X-Received: by 2002:a05:6a00:2e89:b0:724:d758:f35 with SMTP id d2e1a72fcca58-7290c0def31mr1622792b3a.2.1734063532690; Thu, 12 Dec 2024 20:18:52 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725deac1daasm9451938b3a.171.2024.12.12.20.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 20:18:52 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: brian.cain@oss.qualcomm.com, philmd@linaro.org, peter.maydell@linaro.org, quic_mathbern@quicinc.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com, ltaylorsimpson@gmail.com, Brian Cain Subject: [PULL 1/5] Hexagon (target/hexagon) Remove HEX_DEBUG/HEX_DEBUG_LOG Date: Thu, 12 Dec 2024 20:18:32 -0800 Message-Id: <20241213041836.39986-2-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> References: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: EsKb2d5WlfIPfKp_hMUZtKPBsPDq9ppq X-Proofpoint-GUID: EsKb2d5WlfIPfKp_hMUZtKPBsPDq9ppq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 clxscore=1015 phishscore=0 spamscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412130030 Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Taylor Simpson All Hexagon debugging is now done with QEMU mechanisms (e.g., -d in_asm) or with a connected debugger (lldb). Signed-off-by: Taylor Simpson Reviewed-by: Matheus Tavares Bernardino Reviewed-by: Brian Cain Signed-off-by: Brian Cain --- target/hexagon/README | 9 --- target/hexagon/cpu.h | 6 -- target/hexagon/genptr.c | 7 --- target/hexagon/helper.h | 3 - target/hexagon/internal.h | 11 ---- target/hexagon/op_helper.c | 112 ------------------------------------- target/hexagon/translate.c | 66 ---------------------- target/hexagon/translate.h | 2 - 8 files changed, 216 deletions(-) diff --git a/target/hexagon/README b/target/hexagon/README index 7ffd517d70..ca617e3364 100644 --- a/target/hexagon/README +++ b/target/hexagon/README @@ -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_, 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 diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h index 764f3c38cc..25150d5214 100644 --- a/target/hexagon/cpu.h +++ b/target/hexagon/cpu.h @@ -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; diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c index dbae6c570a..2c5e15cfcf 100644 --- a/target/hexagon/genptr.c +++ b/target/hexagon/genptr.c @@ -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); } diff --git a/target/hexagon/helper.h b/target/hexagon/helper.h index fa0ebaf7c8..f8baa599c8 100644 --- a/target/hexagon/helper.h +++ b/target/hexagon/helper.h @@ -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) diff --git a/target/hexagon/internal.h b/target/hexagon/internal.h index beb08cb7e3..32e96f00d9 100644 --- a/target/hexagon/internal.h +++ b/target/hexagon/internal.h @@ -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); diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 90e7aaa097..01d1a1b1a7 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -54,9 +54,6 @@ G_NORETURN void HELPER(raise_exception)(CPUHexagonState *env, uint32_t excp) void log_store32(CPUHexagonState *env, target_ulong addr, target_ulong val, int width, int slot) { - HEX_DEBUG_LOG("log_store%d(0x" TARGET_FMT_lx - ", %" PRId32 " [0x08%" PRIx32 "])\n", - width, addr, val, val); env->mem_log_stores[slot].va = addr; env->mem_log_stores[slot].width = width; env->mem_log_stores[slot].data32 = val; @@ -65,35 +62,11 @@ void log_store32(CPUHexagonState *env, target_ulong addr, void log_store64(CPUHexagonState *env, target_ulong addr, int64_t val, int width, int slot) { - HEX_DEBUG_LOG("log_store%d(0x" TARGET_FMT_lx - ", %" PRId64 " [0x016%" PRIx64 "])\n", - width, addr, val, val); env->mem_log_stores[slot].va = addr; env->mem_log_stores[slot].width = width; env->mem_log_stores[slot].data64 = val; } -/* Handy place to set a breakpoint */ -void HELPER(debug_start_packet)(CPUHexagonState *env) -{ - HEX_DEBUG_LOG("Start packet: pc = 0x" TARGET_FMT_lx "\n", - env->gpr[HEX_REG_PC]); - - for (int i = 0; i < TOTAL_PER_THREAD_REGS; i++) { - env->reg_written[i] = 0; - } -} - -/* Checks for bookkeeping errors between disassembly context and runtime */ -void HELPER(debug_check_store_width)(CPUHexagonState *env, int slot, int check) -{ - if (env->mem_log_stores[slot].width != check) { - HEX_DEBUG_LOG("ERROR: %d != %d\n", - env->mem_log_stores[slot].width, check); - g_assert_not_reached(); - } -} - static void commit_store(CPUHexagonState *env, int slot_num, uintptr_t ra) { uint8_t width = env->mem_log_stores[slot_num].width; @@ -173,91 +146,6 @@ void HELPER(commit_hvx_stores)(CPUHexagonState *env) } } -static void print_store(CPUHexagonState *env, int slot) -{ - if (!(env->slot_cancelled & (1 << slot))) { - uint8_t width = env->mem_log_stores[slot].width; - if (width == 1) { - uint32_t data = env->mem_log_stores[slot].data32 & 0xff; - HEX_DEBUG_LOG("\tmemb[0x" TARGET_FMT_lx "] = %" PRId32 - " (0x%02" PRIx32 ")\n", - env->mem_log_stores[slot].va, data, data); - } else if (width == 2) { - uint32_t data = env->mem_log_stores[slot].data32 & 0xffff; - HEX_DEBUG_LOG("\tmemh[0x" TARGET_FMT_lx "] = %" PRId32 - " (0x%04" PRIx32 ")\n", - env->mem_log_stores[slot].va, data, data); - } else if (width == 4) { - uint32_t data = env->mem_log_stores[slot].data32; - HEX_DEBUG_LOG("\tmemw[0x" TARGET_FMT_lx "] = %" PRId32 - " (0x%08" PRIx32 ")\n", - env->mem_log_stores[slot].va, data, data); - } else if (width == 8) { - HEX_DEBUG_LOG("\tmemd[0x" TARGET_FMT_lx "] = %" PRId64 - " (0x%016" PRIx64 ")\n", - env->mem_log_stores[slot].va, - env->mem_log_stores[slot].data64, - env->mem_log_stores[slot].data64); - } else { - HEX_DEBUG_LOG("\tBad store width %d\n", width); - g_assert_not_reached(); - } - } -} - -/* This function is a handy place to set a breakpoint */ -void HELPER(debug_commit_end)(CPUHexagonState *env, uint32_t this_PC, - int pred_written, int has_st0, int has_st1) -{ - bool reg_printed = false; - bool pred_printed = false; - int i; - - HEX_DEBUG_LOG("Packet committed: pc = 0x" TARGET_FMT_lx "\n", this_PC); - HEX_DEBUG_LOG("slot_cancelled = %d\n", env->slot_cancelled); - - for (i = 0; i < TOTAL_PER_THREAD_REGS; i++) { - if (env->reg_written[i]) { - if (!reg_printed) { - HEX_DEBUG_LOG("Regs written\n"); - reg_printed = true; - } - HEX_DEBUG_LOG("\tr%d = " TARGET_FMT_ld " (0x" TARGET_FMT_lx ")\n", - i, env->gpr[i], env->gpr[i]); - } - } - - for (i = 0; i < NUM_PREGS; i++) { - if (pred_written & (1 << i)) { - if (!pred_printed) { - HEX_DEBUG_LOG("Predicates written\n"); - pred_printed = true; - } - HEX_DEBUG_LOG("\tp%d = 0x" TARGET_FMT_lx "\n", - i, env->pred[i]); - } - } - - if (has_st0 || has_st1) { - HEX_DEBUG_LOG("Stores\n"); - if (has_st0) { - print_store(env, 0); - } - if (has_st1) { - print_store(env, 1); - } - } - - HEX_DEBUG_LOG("Next PC = " TARGET_FMT_lx "\n", env->gpr[HEX_REG_PC]); - HEX_DEBUG_LOG("Exec counters: pkt = " TARGET_FMT_lx - ", insn = " TARGET_FMT_lx - ", hvx = " TARGET_FMT_lx "\n", - env->gpr[HEX_REG_QEMU_PKT_CNT], - env->gpr[HEX_REG_QEMU_INSN_CNT], - env->gpr[HEX_REG_QEMU_HVX_CNT]); - -} - int32_t HELPER(fcircadd)(int32_t RxV, int32_t offset, int32_t M, int32_t CS) { uint32_t K_const = extract32(M, 24, 4); diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index 4b1bee3c6d..bce85eaeb8 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -50,7 +50,6 @@ TCGv hex_gpr[TOTAL_PER_THREAD_REGS]; TCGv hex_pred[NUM_PREGS]; TCGv hex_slot_cancelled; TCGv hex_new_value_usr; -TCGv hex_reg_written[TOTAL_PER_THREAD_REGS]; TCGv hex_store_addr[STORES_MAX]; TCGv hex_store_width[STORES_MAX]; TCGv hex_store_val32[STORES_MAX]; @@ -195,21 +194,6 @@ static void gen_exception_end_tb(DisasContext *ctx, int excp) } -#define PACKET_BUFFER_LEN 1028 -static void print_pkt(Packet *pkt) -{ - GString *buf = g_string_sized_new(PACKET_BUFFER_LEN); - snprint_a_pkt_debug(buf, pkt); - HEX_DEBUG_LOG("%s", buf->str); - g_string_free(buf, true); -} -#define HEX_DEBUG_PRINT_PKT(pkt) \ - do { \ - if (HEX_DEBUG) { \ - print_pkt(pkt); \ - } \ - } while (0) - static int read_packet_words(CPUHexagonState *env, DisasContext *ctx, uint32_t words[]) { @@ -235,14 +219,6 @@ static int read_packet_words(CPUHexagonState *env, DisasContext *ctx, g_assert(ctx->base.num_insns == 1); } - HEX_DEBUG_LOG("decode_packet: pc = 0x%" VADDR_PRIx "\n", - ctx->base.pc_next); - HEX_DEBUG_LOG(" words = { "); - for (int i = 0; i < nwords; i++) { - HEX_DEBUG_LOG("0x%x, ", words[i]); - } - HEX_DEBUG_LOG("}\n"); - return nwords; } @@ -465,11 +441,6 @@ static void gen_start_packet(DisasContext *ctx) */ bitmap_zero(ctx->pregs_written, NUM_PREGS); - if (HEX_DEBUG) { - /* Handy place to set a breakpoint before the packet executes */ - gen_helper_debug_start_packet(tcg_env); - } - /* Initialize the runtime state for packet semantics */ if (need_slot_cancelled(pkt)) { tcg_gen_movi_tl(hex_slot_cancelled, 0); @@ -484,10 +455,6 @@ static void gen_start_packet(DisasContext *ctx) tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], next_PC); } } - if (HEX_DEBUG) { - ctx->pred_written = tcg_temp_new(); - tcg_gen_movi_tl(ctx->pred_written, 0); - } /* Preload the predicated registers into get_result_gpr(ctx, i) */ if (ctx->need_commit && @@ -635,15 +602,6 @@ static void gen_pred_writes(DisasContext *ctx) } } -static void gen_check_store_width(DisasContext *ctx, int slot_num) -{ - if (HEX_DEBUG) { - TCGv slot = tcg_constant_tl(slot_num); - TCGv check = tcg_constant_tl(ctx->store_width[slot_num]); - gen_helper_debug_check_store_width(tcg_env, slot, check); - } -} - static bool slot_is_predicated(Packet *pkt, int slot_num) { for (int i = 0; i < pkt->num_insns; i++) { @@ -691,25 +649,21 @@ void process_store(DisasContext *ctx, int slot_num) */ switch (ctx->store_width[slot_num]) { case 1: - gen_check_store_width(ctx, slot_num); tcg_gen_qemu_st_tl(hex_store_val32[slot_num], hex_store_addr[slot_num], ctx->mem_idx, MO_UB); break; case 2: - gen_check_store_width(ctx, slot_num); tcg_gen_qemu_st_tl(hex_store_val32[slot_num], hex_store_addr[slot_num], ctx->mem_idx, MO_TEUW); break; case 4: - gen_check_store_width(ctx, slot_num); tcg_gen_qemu_st_tl(hex_store_val32[slot_num], hex_store_addr[slot_num], ctx->mem_idx, MO_TEUL); break; case 8: - gen_check_store_width(ctx, slot_num); tcg_gen_qemu_st_i64(hex_store_val64[slot_num], hex_store_addr[slot_num], ctx->mem_idx, MO_TEUQ); @@ -937,16 +891,6 @@ static void gen_commit_packet(DisasContext *ctx) gen_commit_hvx(ctx); } update_exec_counters(ctx); - if (HEX_DEBUG) { - TCGv has_st0 = - tcg_constant_tl(pkt->pkt_has_store_s0 && !pkt->pkt_has_dczeroa); - TCGv has_st1 = - tcg_constant_tl(pkt->pkt_has_store_s1 && !pkt->pkt_has_dczeroa); - - /* Handy place to set a breakpoint at the end of execution */ - gen_helper_debug_commit_end(tcg_env, tcg_constant_tl(ctx->pkt->pc), - ctx->pred_written, has_st0, has_st1); - } if (pkt->vhist_insn != NULL) { ctx->pre_commit = false; @@ -975,7 +919,6 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx) ctx->pkt = &pkt; if (decode_packet(ctx, nwords, words, &pkt, false) > 0) { pkt.pc = ctx->base.pc_next; - HEX_DEBUG_PRINT_PKT(&pkt); gen_start_packet(ctx); for (i = 0; i < pkt.num_insns; i++) { ctx->insn = &pkt.insn[i]; @@ -1093,7 +1036,6 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int *max_insns, } #define NAME_LEN 64 -static char reg_written_names[TOTAL_PER_THREAD_REGS][NAME_LEN]; static char store_addr_names[STORES_MAX][NAME_LEN]; static char store_width_names[STORES_MAX][NAME_LEN]; static char store_val32_names[STORES_MAX][NAME_LEN]; @@ -1112,14 +1054,6 @@ void hexagon_translate_init(void) hex_gpr[i] = tcg_global_mem_new(tcg_env, offsetof(CPUHexagonState, gpr[i]), hexagon_regnames[i]); - - if (HEX_DEBUG) { - snprintf(reg_written_names[i], NAME_LEN, "reg_written_%s", - hexagon_regnames[i]); - hex_reg_written[i] = tcg_global_mem_new(tcg_env, - offsetof(CPUHexagonState, reg_written[i]), - reg_written_names[i]); - } } hex_new_value_usr = tcg_global_mem_new(tcg_env, offsetof(CPUHexagonState, new_value_usr), "new_value_usr"); diff --git a/target/hexagon/translate.h b/target/hexagon/translate.h index 00cc2bcd63..d251e2233f 100644 --- a/target/hexagon/translate.h +++ b/target/hexagon/translate.h @@ -73,7 +73,6 @@ typedef struct DisasContext { bool has_hvx_overlap; TCGv new_value[TOTAL_PER_THREAD_REGS]; TCGv new_pred_value[NUM_PREGS]; - TCGv pred_written; TCGv branch_taken; TCGv dczero_addr; } DisasContext; @@ -271,7 +270,6 @@ extern TCGv hex_gpr[TOTAL_PER_THREAD_REGS]; extern TCGv hex_pred[NUM_PREGS]; extern TCGv hex_slot_cancelled; extern TCGv hex_new_value_usr; -extern TCGv hex_reg_written[TOTAL_PER_THREAD_REGS]; extern TCGv hex_store_addr[STORES_MAX]; extern TCGv hex_store_width[STORES_MAX]; extern TCGv hex_store_val32[STORES_MAX]; From patchwork Fri Dec 13 04:18:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Cain X-Patchwork-Id: 13906480 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D24AE7717D for ; Fri, 13 Dec 2024 04:20:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLx8r-0006b4-DW; Thu, 12 Dec 2024 23:19:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8n-0006Zy-TG for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:02 -0500 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8k-00082b-ST for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:01 -0500 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BD0vQOP023114 for ; Fri, 13 Dec 2024 04:18:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Ysrokvq/Lw6vkrpLlAVaHo30vhxe3UGTZ9VPrTE3GKw=; b=lzVLw5dLMvfiaRkR /IRt2AUx6/biXKMniH5BMrPh6k5zU+YMfcmGgzM9seEGzsB4rD32YRAjyex8MLYA oVzOVwQ/Lk7MKQqR0O8raMHD5Qi75+bYuwTxpwwJwXNcI+fownECAvKcgZQuj84l jVsFQhBEifNeR7GQ6ohHcYndBQzHSBAZZ6TDxXpj+EVosqvMZgPg+lMq2xaSXTX+ GfowkIlecLndkdULRBmLMug9f6ulOeKDvukrqDrbNdXXnrVtvvX/XWLP6LQQI9xM xm6Cio/qs6GAteSJWWHuQybS+mzfEB2zDPF+dwT/uLy4Ku3rp2KIvrc3OomtefJV uYh/cQ== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 43fd40n220-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 13 Dec 2024 04:18:55 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-725dd39ebe7so1166953b3a.3 for ; Thu, 12 Dec 2024 20:18:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734063534; x=1734668334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ysrokvq/Lw6vkrpLlAVaHo30vhxe3UGTZ9VPrTE3GKw=; b=Ln4LFC8XMU0qqnPIGLW+H7Af+RGp/3yMK2TchBslyZEjqx7jmvtN7ysqm0p74fmFTh ++oMos6HgzuRtsS6E/FvKGjjg7LrbQQFdo3dijPqESEg3MAb3sChoSQfeCXHA7dkq2+2 7Pk3/tsf36ddd87TFZf9qzm/1hf1WaUYnF7t97k5NuvxCa2y8OM5+8MyV+8g2s5+uf/7 Y2w6hpehvdMKJMuhO1lLD4b3L03LJwP1MhgFNeFXdyOLYiAxFFzQtpnlbZOL/kNxn7dE BRG7lDyU+OTcS2vN+lJcBpEgPzITW6xp73drm4TcCjhkAPJPgP2hvrXwriH6EhLZlVBK yiBQ== X-Gm-Message-State: AOJu0YyNlgHzQdKIEj+y86JiAENF4P2L9/Ai/wGTq7ElFlq13cHrKY1u ro8X9v+lImLo8OxYU/1oROFDqZoTw6PYQoJ/RLaNmkLAs/QBnrj33TkGnxjQwtQ9xVmLc0NEl4x 5fLH97j8LJH4u3f3/f/MGd1qY1XC2zIFm/m9Ysk3e2eiOGiFuQmWyoEf953QdPw== X-Gm-Gg: ASbGncvawHOuxv3v5J8PxEHLkTgusTcj8edVnsWe3X0JdArAx3csGVbQbtoZDgtmqeI DEJYNdEiPsfFBEkRqlkXFuUoObW2rqhaLjLlK75DlZlWUXVSSLRHmCPOiQdLrqpMKEz6PQ5SIH6 RktdE664XcCbj9wSplTant3q4x9XVZL8iCZfglRN35DEIrQDZi+a+e1ndRqtOsukmrUuz6HXnmm U/SUqHgsoVvZIA63hUg9eBPXtkz0oj8gTHUy4px7fK9gjMdCiArzs+O3+m7lJ78QfS6RAe+0dJg y8Fs/uwyC1K1I10VuCPtxynTupo2uQ== X-Received: by 2002:a05:6a00:c96:b0:724:bf30:147d with SMTP id d2e1a72fcca58-7290c17f109mr1641759b3a.11.1734063534373; Thu, 12 Dec 2024 20:18:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQiu6zsuVpmsUf5cVaAGThCreDmsF/rZXbxJEAvSuxlhsZhrHCW91Vdz+y7pUMA3Nv1NZsag== X-Received: by 2002:a05:6a00:c96:b0:724:bf30:147d with SMTP id d2e1a72fcca58-7290c17f109mr1641723b3a.11.1734063533881; Thu, 12 Dec 2024 20:18:53 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725deac1daasm9451938b3a.171.2024.12.12.20.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 20:18:53 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: brian.cain@oss.qualcomm.com, philmd@linaro.org, peter.maydell@linaro.org, quic_mathbern@quicinc.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com, ltaylorsimpson@gmail.com, Brian Cain , Brian Cain , Laurent Vivier Subject: [PULL 2/5] target/hexagon: rename HEX_EXCP_*=>HEX_CAUSE_* Date: Thu, 12 Dec 2024 20:18:33 -0800 Message-Id: <20241213041836.39986-3-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> References: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-GUID: XB2zKYBqqJJo5fJewHPNAq9zorisrkf5 X-Proofpoint-ORIG-GUID: XB2zKYBqqJJo5fJewHPNAq9zorisrkf5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 suspectscore=0 impostorscore=0 phishscore=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 mlxlogscore=627 priorityscore=1501 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412130030 Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Brian Cain The values previously used for "HEX_EXCP_*" were the cause code definitions and not the event numbers. So in this commit, we update the names to reflect the cause codes. In HEX_EVENT_TRAP0's case, we add a new "HEX_EVENT_*" with the correct event number. Reviewed-by: Taylor Simpson Signed-off-by: Brian Cain --- linux-user/hexagon/cpu_loop.c | 4 ++-- target/hexagon/cpu.h | 2 +- target/hexagon/cpu_bits.h | 15 ++++++++------- target/hexagon/gen_tcg.h | 2 +- target/hexagon/translate.c | 6 +++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c index d41159e52a..40db596301 100644 --- a/linux-user/hexagon/cpu_loop.c +++ b/linux-user/hexagon/cpu_loop.c @@ -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; diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h index 25150d5214..14e6e819c2 100644 --- a/target/hexagon/cpu.h +++ b/target/hexagon/cpu.h @@ -143,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); } } diff --git a/target/hexagon/cpu_bits.h b/target/hexagon/cpu_bits.h index 4279281a71..2e60c0fafe 100644 --- a/target/hexagon/cpu_bits.h +++ b/target/hexagon/cpu_bits.h @@ -23,14 +23,15 @@ #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 +#define HEX_EVENT_TRAP0 0x008 -#define HEX_EXCP_TRAP0 0x172 +#define HEX_CAUSE_TRAP0 0x172 +#define HEX_CAUSE_FETCH_NO_UPAGE 0x012 +#define HEX_CAUSE_INVALID_PACKET 0x015 +#define HEX_CAUSE_INVALID_OPCODE 0x015 +#define HEX_CAUSE_PC_NOT_ALIGNED 0x01e +#define HEX_CAUSE_PRIV_NO_UREAD 0x024 +#define HEX_CAUSE_PRIV_NO_UWRITE 0x025 #define PACKET_WORDS_MAX 4 diff --git a/target/hexagon/gen_tcg.h b/target/hexagon/gen_tcg.h index 3fc1f4e281..8a3b801287 100644 --- a/target/hexagon/gen_tcg.h +++ b/target/hexagon/gen_tcg.h @@ -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 diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index bce85eaeb8..562105705a 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -558,7 +558,7 @@ static void gen_insn(DisasContext *ctx) ctx->insn->generate(ctx); mark_store_width(ctx); } else { - gen_exception_end_tb(ctx, HEX_EXCP_INVALID_OPCODE); + gen_exception_end_tb(ctx, HEX_CAUSE_INVALID_OPCODE); } } @@ -912,7 +912,7 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx) nwords = read_packet_words(env, ctx, words); if (!nwords) { - gen_exception_end_tb(ctx, HEX_EXCP_INVALID_PACKET); + gen_exception_end_tb(ctx, HEX_CAUSE_INVALID_PACKET); return; } @@ -927,7 +927,7 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx) gen_commit_packet(ctx); ctx->base.pc_next += pkt.encod_pkt_size_in_bytes; } else { - gen_exception_end_tb(ctx, HEX_EXCP_INVALID_PACKET); + gen_exception_end_tb(ctx, HEX_CAUSE_INVALID_PACKET); } } From patchwork Fri Dec 13 04:18:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Cain X-Patchwork-Id: 13906478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65E33E7717D for ; Fri, 13 Dec 2024 04:20:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLx8o-0006a2-8x; Thu, 12 Dec 2024 23:19:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8n-0006Zk-BT for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:01 -0500 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8k-00082h-Ek for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:01 -0500 Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BCKpm8B030100 for ; Fri, 13 Dec 2024 04:18:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= zQvZiKgrtXs8Zu4Ms6Zmq72hJ9m6gqm2Cz2XsblQju4=; b=linaUZdR7idJteMc NnXVvMN9gMgsUcGefhTv5AzQ/UB/DZYhUT2qN9hFOt5uV1o1inbGgG6ejIwdrAOb CErOgryn2coZjPQ/1A3mmAWJQ22M4rZtEHyKwUeCwEXgw4ywzPRF7P8TRQuphCok /Ft14tq6QPR42mpTO24SiX7I80vhMmLnZkzL2bygBqE5ey4ahWAMXU4BX9lA7C6q OFx9UM4GKZMgkoK+PmFpDzaGzf91lSMPDgdibjTlMbvZTIp2FFb+S7CykeqiodIr EHYGmeGqzLvbUPaV6fyHP31IzpNv3U4AE7FxFxmNZp+UyXY7tvtdV7tHlb/MrCUV nKMBlw== Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 43fwgejhed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 13 Dec 2024 04:18:56 +0000 (GMT) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-728e3ae8112so1153973b3a.0 for ; Thu, 12 Dec 2024 20:18:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734063536; x=1734668336; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zQvZiKgrtXs8Zu4Ms6Zmq72hJ9m6gqm2Cz2XsblQju4=; b=v/Ax25qnlW2uMuiu0ecKXarzr54Bvk1rMsoeJQQtbhwBwbsDeDm7rxLFim/AUjq7+K DoAaLpYz+Y88WQ9KGGrjquux7UjXLVFs5nxuNI66s6gyA6/7iwp8++qXI0ffC6VivhB7 VpW7D0IojZnIAOEkKvOdqs054Z30Ue+Q6Ou7292hK4nzKidl52QnVzdeE8Dq5kBR7SDC LXJX5HA1tr2uZ5DcJ2T5GI5XkEFh9Eg6VXZ1VeWwCpd+StNNDm1QHMn+FUpD3GKi1eP2 HEP/UTKACYk7b15wxh6JRctHjpjZJslPCrDtPrEObc9cf1jtf/j1TAkTmAladk75sKNp C/GQ== X-Gm-Message-State: AOJu0Yxwu9scRr+lW84xfb+SsDTui7jsIV2D2z9hq7n8+dh3ZyYahg2a onFegZ7LnbX96euB4895BHBvMlomyV6pEGPIi0pWIgAAw6sb9vdVCsvTOzogr5lMbS6uMxhzJCW Hu9pUN/GHOgoEDBeUsfOjNGnz6wUy28jHGvK+13XLlS/GtJ0O/Ny9/uekYJrNXQ== X-Gm-Gg: ASbGncvTL6LOuXmaXlF1TMm2AG72Z3CHuvZdjhcY3TfpuFhTuOOlml2qaQv47Vk72xh x/jZgDL1FtvSbOa/CU5uU8ex8/95hjX/sGaqDpyU+kQzPbcOomVpfvDbZu6wkDNmP8p1YV6qLkn JgpqXraBlFmjgfDkJl8VIVuJ7ipWtS/9aET7UAnBMBJxHRwvng0eTWu7OXN7E4+R5kJnFLgDzxi TZVXebdzTBSNNFdhy0bBGSJjXNrrxxBDzz7Ycc77P43xDhuyeQEbYSh2YQfGgxQoc5JGRNhhaVf 9NZjaGDPuBkvAAZPengZLngC1NxOXA== X-Received: by 2002:a05:6a21:33a2:b0:1e1:a9c1:b343 with SMTP id adf61e73a8af0-1e1dfe43d95mr1575512637.43.1734063535680; Thu, 12 Dec 2024 20:18:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAHDQu6qQ7EmLoOtLLufIRBn/4+WmF5qtMo8GhqmkLOy/J6BXIQwgkc0BgLHCnZ5F2NrbfRg== X-Received: by 2002:a05:6a21:33a2:b0:1e1:a9c1:b343 with SMTP id adf61e73a8af0-1e1dfe43d95mr1575492637.43.1734063535286; Thu, 12 Dec 2024 20:18:55 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725deac1daasm9451938b3a.171.2024.12.12.20.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 20:18:54 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: brian.cain@oss.qualcomm.com, philmd@linaro.org, peter.maydell@linaro.org, quic_mathbern@quicinc.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com, ltaylorsimpson@gmail.com, Brian Cain , Brian Cain Subject: [PULL 3/5] target/hexagon: add enums for event, cause Date: Thu, 12 Dec 2024 20:18:34 -0800 Message-Id: <20241213041836.39986-4-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> References: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-GUID: Q_gO9pCbQD8qaMPAk9dXUPLzUVU2Fx0O X-Proofpoint-ORIG-GUID: Q_gO9pCbQD8qaMPAk9dXUPLzUVU2Fx0O X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 bulkscore=0 mlxlogscore=852 spamscore=0 clxscore=1015 impostorscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412130030 Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Brian Cain Reviewed-by: Taylor Simpson Signed-off-by: Brian Cain --- target/hexagon/cpu_bits.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/target/hexagon/cpu_bits.h b/target/hexagon/cpu_bits.h index 2e60c0fafe..ff596e2a94 100644 --- a/target/hexagon/cpu_bits.h +++ b/target/hexagon/cpu_bits.h @@ -23,15 +23,21 @@ #define PCALIGN 4 #define PCALIGN_MASK (PCALIGN - 1) -#define HEX_EVENT_TRAP0 0x008 +enum hex_event { + HEX_EVENT_NONE = -1, + HEX_EVENT_TRAP0 = 0x008, +}; -#define HEX_CAUSE_TRAP0 0x172 -#define HEX_CAUSE_FETCH_NO_UPAGE 0x012 -#define HEX_CAUSE_INVALID_PACKET 0x015 -#define HEX_CAUSE_INVALID_OPCODE 0x015 -#define HEX_CAUSE_PC_NOT_ALIGNED 0x01e -#define HEX_CAUSE_PRIV_NO_UREAD 0x024 -#define HEX_CAUSE_PRIV_NO_UWRITE 0x025 +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 From patchwork Fri Dec 13 04:18:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Cain X-Patchwork-Id: 13906482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F168E7717D for ; Fri, 13 Dec 2024 04:20:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLx8r-0006bu-Hq; Thu, 12 Dec 2024 23:19:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8o-0006aB-G6 for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:02 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8m-00082v-1W for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:02 -0500 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BCI0ECZ029980 for ; Fri, 13 Dec 2024 04:18:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= jFN2KrPddaWoK465RuaqilrI8aTRieIcfTQH9VOUXT4=; b=O5qEA8/XZ4+Prhwv 2kJIXN3IAzfqMLZswxpqQ53fyFcfPbJN2wy+B1D15TuPpf0RNI9G4vEeA1vzvgOG cQ/GSo3+9/DqCZxW1nWmodK41nWmdJtdhss5caAEqea2SAAf8tTWfJIeECR45ktD rWvTvW0wWpjjd6eKfCy5JRFKlhgQ/sLcmemEisYhQ97MInlZihKbzJ/E4GWBM5tE JeCiZP22WJKVdDznso+yrfoRt3cvsgLMe7GfvdBbSyoAlsqWfXK/NXttBNMRm7Fe Wew48Lg7Al5jIekjp4CEWDeSdHxqZREQU1BirUeLWMGscduFcDdWoUkbbiFk3G7+ y+T5zg== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 43dxw4ddyt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 13 Dec 2024 04:18:58 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-725eaaf8914so1773305b3a.1 for ; Thu, 12 Dec 2024 20:18:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734063537; x=1734668337; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jFN2KrPddaWoK465RuaqilrI8aTRieIcfTQH9VOUXT4=; b=W5W/c1MDZLM4SSqOjYqHVEqD86eaMx/9b6KGoBl8Ie8Te8fuAWYVND/zrdmq13ne9o Qi26fSfxYCag4ADLa/+MTlKKjcquT0Hp29qyj/ogu7gIjQ873uk4KewalrGIRKB4y/om p598bfR8cGeBX6NwuPZ/uwMs9Jyu9EZN6J9FHf5H6F6/Qlwam1uov7Yj+4F59DIEb729 oq46kV0wo7ixMCfJqHe93UJ/vtRkGQzQ0GFv5Jj65ZA05qd3Ll6Hlu1Ww+5FD1gvixyS BfHmILGQzIYzaFPvV//dXRd6HJvcR1xDplTB9fPhSQbaHSrqmEsgcddvDEu1IDRyZqoU WUzQ== X-Gm-Message-State: AOJu0YzQxEwbUvMZVFlSiL0Gwe2VngrCdR51F/I6Zl4sdyqgJ8iUD330 JNkXXCZ2yw8QixmjDQde7hiVzMDB7E5ae+TZ2sKeOeZk+ZUgz1dO59/6RbHe/3WEF+Ez5uqkdv2 0ECNoiomSGzXneymd3JEwELiztc/Q2rSZ6+JneSSvuBEQactBhrHnc/PChfiSMw== X-Gm-Gg: ASbGnct6mYyAKDAxZICckI40BA/tajKbMerr05dV8mGb/sGCjnIu4tcskmrMzTdg4jW Sd6mcWzjG8pz6tytm5wmC/3U00mkSf0cVtNIkFHJrYJELyFFGjD0gjAj2btc0I2mp8CHDAnh16x msbPjnr4ZYNgola/cDLcIK2ufxCgwJejP7cmYMsZ5veEdJf3MsGKg0GHjVoI6B79z6+O69l3Ir7 zxV5Ssr3+NoCtZfMHoECk7Xjb0ucU6n2nHqXtaLnvu6tMiCGapUsyNCZQmFsmP5yUoBXV/4DG8G 4c+Jj2j5hIIs8cyJ+/WDcCrm1lUQRg== X-Received: by 2002:a05:6a00:4f89:b0:725:eb85:f7ef with SMTP id d2e1a72fcca58-7290c1b290bmr1913519b3a.14.1734063536980; Thu, 12 Dec 2024 20:18:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHH+iGQP0b5ao7QudoB8228qKitYfn2o2qkTNgFM9T7yw/nQBFGRZIjEDLkoLIr7F+QMxNKdw== X-Received: by 2002:a05:6a00:4f89:b0:725:eb85:f7ef with SMTP id d2e1a72fcca58-7290c1b290bmr1913479b3a.14.1734063536535; Thu, 12 Dec 2024 20:18:56 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725deac1daasm9451938b3a.171.2024.12.12.20.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 20:18:56 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: brian.cain@oss.qualcomm.com, philmd@linaro.org, peter.maydell@linaro.org, quic_mathbern@quicinc.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com, ltaylorsimpson@gmail.com, Brian Cain Subject: [PULL 4/5] target/hexagon: Use argparse in all python scripts Date: Thu, 12 Dec 2024 20:18:35 -0800 Message-Id: <20241213041836.39986-5-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> References: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: BlKl96_V7_KD_Yfn5OL0swswcEsOrxKs X-Proofpoint-GUID: BlKl96_V7_KD_Yfn5OL0swswcEsOrxKs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 clxscore=1015 spamscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412130030 Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Anton Johansson QOL commit, all the various gen_* python scripts take a large set arguments where order is implicit. Using argparse we also get decent error messages if a field is missing or too many are added. Signed-off-by: Anton Johansson Reviewed-by: Brian Cain Signed-off-by: Brian Cain --- target/hexagon/gen_analyze_funcs.py | 6 +++-- target/hexagon/gen_decodetree.py | 19 +++++++++++--- target/hexagon/gen_helper_funcs.py | 7 +++--- target/hexagon/gen_helper_protos.py | 7 +++--- target/hexagon/gen_idef_parser_funcs.py | 11 +++++++-- target/hexagon/gen_op_attribs.py | 11 +++++++-- target/hexagon/gen_opcodes_def.py | 11 +++++++-- target/hexagon/gen_printinsn.py | 11 +++++++-- target/hexagon/gen_tcg_func_table.py | 11 +++++++-- target/hexagon/gen_tcg_funcs.py | 9 ++++--- target/hexagon/gen_trans_funcs.py | 18 +++++++++++--- target/hexagon/hex_common.py | 33 ++++++++++++------------- target/hexagon/meson.build | 2 +- 13 files changed, 109 insertions(+), 47 deletions(-) diff --git a/target/hexagon/gen_analyze_funcs.py b/target/hexagon/gen_analyze_funcs.py index 54bac19724..3ac7cc2cfe 100755 --- a/target/hexagon/gen_analyze_funcs.py +++ b/target/hexagon/gen_analyze_funcs.py @@ -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") diff --git a/target/hexagon/gen_decodetree.py b/target/hexagon/gen_decodetree.py index a4fcd622c5..ce703af41d 100755 --- a/target/hexagon/gen_decodetree.py +++ b/target/hexagon/gen_decodetree.py @@ -24,6 +24,7 @@ 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() diff --git a/target/hexagon/gen_helper_funcs.py b/target/hexagon/gen_helper_funcs.py index e9685bff2f..c1f806ac4b 100755 --- a/target/hexagon/gen_helper_funcs.py +++ b/target/hexagon/gen_helper_funcs.py @@ -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]: diff --git a/target/hexagon/gen_helper_protos.py b/target/hexagon/gen_helper_protos.py index fd2bfd0f36..77f8e0a6a3 100755 --- a/target/hexagon/gen_helper_protos.py +++ b/target/hexagon/gen_helper_protos.py @@ -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]: diff --git a/target/hexagon/gen_idef_parser_funcs.py b/target/hexagon/gen_idef_parser_funcs.py index 72f11c68ca..2f6e826f76 100644 --- a/target/hexagon/gen_idef_parser_funcs.py +++ b/target/hexagon/gen_idef_parser_funcs.py @@ -20,6 +20,7 @@ import sys import re import string +import argparse from io import StringIO import hex_common @@ -43,13 +44,19 @@ ## 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: diff --git a/target/hexagon/gen_op_attribs.py b/target/hexagon/gen_op_attribs.py index 99448220da..bbbb02df3a 100755 --- a/target/hexagon/gen_op_attribs.py +++ b/target/hexagon/gen_op_attribs.py @@ -21,16 +21,23 @@ 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(" diff --git a/target/hexagon/gen_opcodes_def.py b/target/hexagon/gen_opcodes_def.py index 536f0eb68a..94a19ff412 100755 --- a/target/hexagon/gen_opcodes_def.py +++ b/target/hexagon/gen_opcodes_def.py @@ -21,15 +21,22 @@ 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") diff --git a/target/hexagon/gen_printinsn.py b/target/hexagon/gen_printinsn.py index 8bf4d0985c..d5f969960a 100755 --- a/target/hexagon/gen_printinsn.py +++ b/target/hexagon/gen_printinsn.py @@ -21,6 +21,7 @@ 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 diff --git a/target/hexagon/gen_tcg_func_table.py b/target/hexagon/gen_tcg_func_table.py index 978ac1819b..299a39b1aa 100755 --- a/target/hexagon/gen_tcg_func_table.py +++ b/target/hexagon/gen_tcg_func_table.py @@ -21,15 +21,22 @@ 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") diff --git a/target/hexagon/gen_tcg_funcs.py b/target/hexagon/gen_tcg_funcs.py index 05aa0a7855..c2ba91ddc0 100755 --- a/target/hexagon/gen_tcg_funcs.py +++ b/target/hexagon/gen_tcg_funcs.py @@ -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: diff --git a/target/hexagon/gen_trans_funcs.py b/target/hexagon/gen_trans_funcs.py index 30f0c73e0c..45da1b7b5d 100755 --- a/target/hexagon/gen_trans_funcs.py +++ b/target/hexagon/gen_trans_funcs.py @@ -24,6 +24,7 @@ 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() diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py index 15ed4980e4..758e5fd12d 100755 --- a/target/hexagon/hex_common.py +++ b/target/hexagon/hex_common.py @@ -21,6 +21,7 @@ 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 diff --git a/target/hexagon/meson.build b/target/hexagon/meson.build index f1723778a6..bb4ebaae81 100644 --- a/target/hexagon/meson.build +++ b/target/hexagon/meson.build @@ -346,7 +346,7 @@ if idef_parser_enabled and 'hexagon-linux-user' in target_dirs # 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, idef_generated_list] + helper_in = [semantics_generated, gen_tcg_h, gen_tcg_hvx_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 From patchwork Fri Dec 13 04:18:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Cain X-Patchwork-Id: 13906483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA508E7717F for ; Fri, 13 Dec 2024 04:20:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLx8s-0006bw-0d; Thu, 12 Dec 2024 23:19:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8o-0006aH-Lm for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:02 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLx8m-000833-Dw for qemu-devel@nongnu.org; Thu, 12 Dec 2024 23:19:02 -0500 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BCGPf92002087 for ; Fri, 13 Dec 2024 04:18:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= DHoweVfTbzrWQRyHIi4LJxPyZAf+eqY3mL/Bb9OrBJw=; b=kYwZPMD6YvGR0/8S qL8xuXOSZaTSckwEOg2EC/38dN4iwfTGgSAGpOZTpvM0eGvrv1QOPG5oH/wOdXoA 4Nnn0F53Y6Bwjx3ExBuciwfesQgKCqIMJVEEVitnzOKo05jbuA6qXh+sowHUFU7o qfl9r16j/CzEO+uyy6D7XhrR3jCMP0S4opTExE/mVp5dMoIcQLMsH+Tnr7KtoWCb /Ycg0EHZjPRA0menXZfOPKMmnaNc1q1TXqy7B1m6dzRe0LhNZ5y8QEN1sQ2Yccow +n9mLtsAjgs8jXz+GTKA7UjDLffC57pr2i+CvFJRc6nxwJO9ReItvAWzwwvqTLdT Lv2GLw== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 43f0r9yfkq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 13 Dec 2024 04:18:59 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-725e87a142dso1814325b3a.2 for ; Thu, 12 Dec 2024 20:18:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734063538; x=1734668338; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DHoweVfTbzrWQRyHIi4LJxPyZAf+eqY3mL/Bb9OrBJw=; b=oY2LpflJ2rm8e/8TZdjN4LnoXL1UZVvHy2GczjuojJzlIYfcIMpA9frw39kbc7u5Iu TfJImJUjf36quIj9wXzJL/83nhGhTUTKjsHCAxm3ZU37LOW0twc3C5tY+3RkSxP3lACx wrH2xVpkRhERCJGV3B/v/ahTu8/OVPIfWaYmc0LzZHRyYRCKvNC+ZpViJ9VKGwR3tikn IeXYlt1ZsoNpgHCDX63JGlQVCAT2pJ1PEZz3EvY2MwclmgOkHNZbFU+lTxTA2HYvThrW ayy8ZlhEZK8E/EXOGCF3xbiqOF+zhbp8Po5xKho8Wc6M6ogGP3xxE72dbq72wxdouUdY izCA== X-Gm-Message-State: AOJu0YyzXzMQnRh7CQbyGRcopImo+l6f8axsOLIWT8e6PSQ1sCBRTDN9 gEZGm/8HPVSkoQgdzsIO9SZGF0LaSEIkT3WYRz8tSrsxxzh7EurH9kpsWSw0foWxr5me/g4mP2v jmbB0VhzsHNTdBbFxfUvJsIOWDm29ocSqh1bv4VOlw93JG+lYtYJePit1+w47yA== X-Gm-Gg: ASbGncvIlID7PSJ8//WsbayAHpl2jx0KGPjFubwR5zvBVdr+IIqiHSr6kIiccV8PBXZ 9cPQffdTzbsXsMzZmwuNbMyRiqyP/lqsqbRo1vgv5DwOEQwqCkdT8XPBbGWeVWUzN0l68QSddSr W/EhdESM2PosZSrVQUR7pJoSvwOWd/weI+PvBNEylUB9hOO/YeGHOgpkgruw/ES4V8Ur868Wd77 w9p7oHz6Z6YEirx+n9D9oOHdKoKQ/UfoOT1TQ0ABGkDB+A7dwX+dTUeCSWSBkOeA4LQNMMsIkN8 kB/CbwSkErnSbCfbGhq+NdAOtSPCKg== X-Received: by 2002:a05:6a21:3a93:b0:1e1:dbfd:1fde with SMTP id adf61e73a8af0-1e1dfda98bfmr1476680637.27.1734063537922; Thu, 12 Dec 2024 20:18:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IET2cxMqIL6T7hLkKsBFWDnlZWQk6mchyirh1L13fUxxjnihQhsrwxlFmBQGXOm/sokXZCAog== X-Received: by 2002:a05:6a21:3a93:b0:1e1:dbfd:1fde with SMTP id adf61e73a8af0-1e1dfda98bfmr1476659637.27.1734063537587; Thu, 12 Dec 2024 20:18:57 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725deac1daasm9451938b3a.171.2024.12.12.20.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 20:18:57 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: brian.cain@oss.qualcomm.com, philmd@linaro.org, peter.maydell@linaro.org, quic_mathbern@quicinc.com, ale@rev.ng, anjo@rev.ng, quic_mliebel@quicinc.com, ltaylorsimpson@gmail.com, Brian Cain Subject: [PULL 5/5] target/hexagon: Make HVX vector args. restrict * Date: Thu, 12 Dec 2024 20:18:36 -0800 Message-Id: <20241213041836.39986-6-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> References: <20241213041836.39986-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: x4pHjl_dtBI_dobamB7fKY68phQI-CUC X-Proofpoint-GUID: x4pHjl_dtBI_dobamB7fKY68phQI-CUC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 phishscore=0 spamscore=0 clxscore=1015 mlxlogscore=702 malwarescore=0 lowpriorityscore=0 mlxscore=0 bulkscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412130030 Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Anton Johansson Adds restrict qualifier to HVX pointer arguments. This will allow the compiler to produce better optimized code, as input vectors are now assumed not to alias, and no runtime aliasing checks will be required. Signed-off-by: Anton Johansson Reviewed-by: Brian Cain Signed-off-by: Brian Cain --- target/hexagon/mmvec/macros.h | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/target/hexagon/mmvec/macros.h b/target/hexagon/mmvec/macros.h index 1ceb9453ee..bcd4a1e897 100644 --- a/target/hexagon/mmvec/macros.h +++ b/target/hexagon/mmvec/macros.h @@ -23,26 +23,26 @@ #include "mmvec/system_ext_mmvec.h" #ifndef QEMU_GENERATE -#define VdV (*(MMVector *)(VdV_void)) -#define VsV (*(MMVector *)(VsV_void)) -#define VuV (*(MMVector *)(VuV_void)) -#define VvV (*(MMVector *)(VvV_void)) -#define VwV (*(MMVector *)(VwV_void)) -#define VxV (*(MMVector *)(VxV_void)) -#define VyV (*(MMVector *)(VyV_void)) +#define VdV (*(MMVector *restrict)(VdV_void)) +#define VsV (*(MMVector *restrict)(VsV_void)) +#define VuV (*(MMVector *restrict)(VuV_void)) +#define VvV (*(MMVector *restrict)(VvV_void)) +#define VwV (*(MMVector *restrict)(VwV_void)) +#define VxV (*(MMVector *restrict)(VxV_void)) +#define VyV (*(MMVector *restrict)(VyV_void)) -#define VddV (*(MMVectorPair *)(VddV_void)) -#define VuuV (*(MMVectorPair *)(VuuV_void)) -#define VvvV (*(MMVectorPair *)(VvvV_void)) -#define VxxV (*(MMVectorPair *)(VxxV_void)) +#define VddV (*(MMVectorPair *restrict)(VddV_void)) +#define VuuV (*(MMVectorPair *restrict)(VuuV_void)) +#define VvvV (*(MMVectorPair *restrict)(VvvV_void)) +#define VxxV (*(MMVectorPair *restrict)(VxxV_void)) -#define QeV (*(MMQReg *)(QeV_void)) -#define QdV (*(MMQReg *)(QdV_void)) -#define QsV (*(MMQReg *)(QsV_void)) -#define QtV (*(MMQReg *)(QtV_void)) -#define QuV (*(MMQReg *)(QuV_void)) -#define QvV (*(MMQReg *)(QvV_void)) -#define QxV (*(MMQReg *)(QxV_void)) +#define QeV (*(MMQReg *restrict)(QeV_void)) +#define QdV (*(MMQReg *restrict)(QdV_void)) +#define QsV (*(MMQReg *restrict)(QsV_void)) +#define QtV (*(MMQReg *restrict)(QtV_void)) +#define QuV (*(MMQReg *restrict)(QuV_void)) +#define QvV (*(MMQReg *restrict)(QvV_void)) +#define QxV (*(MMQReg *restrict)(QxV_void)) #endif #define LOG_VTCM_BYTE(VA, MASK, VAL, IDX) \