@@ -612,6 +612,14 @@
tcg_temp_free(tmp); \
} while (0)
+#define fGEN_TCG_J2_call(SHORTCODE) \
+ gen_call(ctx, pkt, riV)
+
+#define fGEN_TCG_J2_callt(SHORTCODE) \
+ gen_cond_call(ctx, pkt, PuV, true, riV)
+#define fGEN_TCG_J2_callf(SHORTCODE) \
+ gen_cond_call(ctx, pkt, PuV, false, riV)
+
#define fGEN_TCG_J2_pause(SHORTCODE) \
do { \
uiV = uiV; \
@@ -456,6 +456,65 @@ static TCGv gen_8bitsof(TCGv result, TCGv value)
return result;
}
+static void gen_write_new_pc_pcrel(DisasContext *ctx, Packet *pkt,
+ int pc_off, TCGv pred)
+{
+ target_ulong dest = pkt->pc + pc_off;
+ if (pkt->pkt_has_multi_cof) {
+ TCGLabel *pred_false = NULL;
+ if (pred != NULL) {
+ pred_false = gen_new_label();
+ tcg_gen_brcondi_tl(TCG_COND_EQ, pred, 0, pred_false);
+ }
+ /* If there are multiple branches in a packet, ignore the second one */
+ TCGLabel *skip = gen_new_label();
+ tcg_gen_brcondi_tl(TCG_COND_NE, hex_branch_taken, 0, skip);
+ tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], dest);
+ tcg_gen_movi_tl(hex_branch_taken, 1);
+ gen_set_label(skip);
+ if (pred != NULL) {
+ gen_set_label(pred_false);
+ }
+ } else {
+ TCGLabel *pred_false = NULL;
+ if (pred != NULL) {
+ pred_false = gen_new_label();
+ tcg_gen_brcondi_tl(TCG_COND_EQ, pred, 0, pred_false);
+ }
+ tcg_gen_movi_tl(hex_gpr[HEX_REG_PC], dest);
+ if (pred != NULL) {
+ gen_set_label(pred_false);
+ }
+ }
+}
+
+static void gen_call(DisasContext *ctx, Packet *pkt, int pc_off)
+{
+ TCGv next_PC =
+ tcg_constant_tl(pkt->pc + pkt->encod_pkt_size_in_bytes);
+ gen_log_reg_write(HEX_REG_LR, next_PC);
+ gen_write_new_pc_pcrel(ctx, pkt, pc_off, NULL);
+}
+
+static void gen_cond_call(DisasContext *ctx, Packet *pkt,
+ TCGv pred, bool sense, int pc_off)
+{
+ TCGv next_PC;
+ TCGv lsb = tcg_temp_local_new();
+ TCGLabel *skip = gen_new_label();
+ tcg_gen_andi_tl(lsb, pred, 1);
+ if (!sense) {
+ tcg_gen_xori_tl(lsb, lsb, 1);
+ }
+ gen_write_new_pc_pcrel(ctx, pkt, pc_off, lsb);
+ tcg_gen_brcondi_tl(TCG_COND_EQ, lsb, 0, skip);
+ tcg_temp_free(lsb);
+ next_PC =
+ tcg_constant_tl(pkt->pc + pkt->encod_pkt_size_in_bytes);
+ gen_log_reg_write(HEX_REG_LR, next_PC);
+ gen_set_label(skip);
+}
+
static intptr_t vreg_src_off(DisasContext *ctx, int num)
{
intptr_t offset = offsetof(CPUHexagonState, VRegs[num]);
Add overrides for J2_call J2_callt J2_callf Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> --- target/hexagon/gen_tcg.h | 8 ++++++ target/hexagon/genptr.c | 59 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)