Skip to content

Commit

Permalink
tcg/ppc: Add support for fence
Browse files Browse the repository at this point in the history
Signed-off-by: Pranith Kumar <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
  • Loading branch information
pranith authored and rth7680 committed Sep 16, 2016
1 parent 6f0b991 commit 7b4af5e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tcg/ppc/tcg-target.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ static int tcg_target_const_match(tcg_target_long val, TCGType type,
#define STHX XO31(407)
#define STWX XO31(151)

#define EIEIO XO31(854)
#define HWSYNC XO31(598)
#define LWSYNC (HWSYNC | (1u << 21))

#define SPR(a, b) ((((a)<<5)|(b))<<11)
#define LR SPR(8, 0)
#define CTR SPR(9, 0)
Expand Down Expand Up @@ -1243,6 +1247,18 @@ static void tcg_out_brcond2 (TCGContext *s, const TCGArg *args,
tcg_out_bc(s, BC | BI(7, CR_EQ) | BO_COND_TRUE, arg_label(args[5]));
}

static void tcg_out_mb(TCGContext *s, TCGArg a0)
{
uint32_t insn = HWSYNC;
a0 &= TCG_MO_ALL;
if (a0 == TCG_MO_LD_LD) {
insn = LWSYNC;
} else if (a0 == TCG_MO_ST_ST) {
insn = EIEIO;
}
tcg_out32(s, insn);
}

#ifdef __powerpc64__
void ppc_tb_set_jmp_target(uintptr_t jmp_addr, uintptr_t addr)
{
Expand Down Expand Up @@ -2453,6 +2469,10 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
tcg_out32(s, MULHD | TAB(args[0], args[1], args[2]));
break;

case INDEX_op_mb:
tcg_out_mb(s, args[0]);
break;

case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */
case INDEX_op_mov_i64:
case INDEX_op_movi_i32: /* Always emitted via tcg_out_movi. */
Expand Down Expand Up @@ -2600,6 +2620,7 @@ static const TCGTargetOpDef ppc_op_defs[] = {
{ INDEX_op_qemu_st_i64, { "S", "S", "S", "S" } },
#endif

{ INDEX_op_mb, { } },
{ -1 },
};

Expand Down

0 comments on commit 7b4af5e

Please sign in to comment.