include/exec/memop: Add MO_ATOM_*
This field may be used to describe the precise atomicity requirements of the guest, which may then be used to constrain the methods by which it may be emulated by the host. For instance, the AArch64 LDP (32-bit) instruction changes semantics with ARMv8.4 LSE2, from MO_64 | MO_ATOM_IFALIGN_PAIR (64-bits, single-copy atomic only on 4 byte units, nonatomic if not aligned by 4), to MO_64 | MO_ATOM_WITHIN16 (64-bits, single-copy atomic within a 16 byte block) The former may be implemented with two 4 byte loads, or a single 8 byte load if that happens to be efficient on the host. The latter may not be implemented with two 4 byte loads and may also require a helper when misaligned. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
988998503b
commit
37031fefc7
@ -72,6 +72,43 @@ typedef enum MemOp {
|
||||
MO_ALIGN_64 = 6 << MO_ASHIFT,
|
||||
MO_ALIGN = MO_AMASK,
|
||||
|
||||
/*
|
||||
* MO_ATOM_* describes the atomicity requirements of the operation:
|
||||
* MO_ATOM_IFALIGN: the operation must be single-copy atomic if it
|
||||
* is aligned; if unaligned there is no atomicity.
|
||||
* MO_ATOM_IFALIGN_PAIR: the entire operation may be considered to
|
||||
* be a pair of half-sized operations which are packed together
|
||||
* for convenience, with single-copy atomicity on each half if
|
||||
* the half is aligned.
|
||||
* This is the atomicity e.g. of Arm pre-FEAT_LSE2 LDP.
|
||||
* MO_ATOM_WITHIN16: the operation is single-copy atomic, even if it
|
||||
* is unaligned, so long as it does not cross a 16-byte boundary;
|
||||
* if it crosses a 16-byte boundary there is no atomicity.
|
||||
* This is the atomicity e.g. of Arm FEAT_LSE2 LDR.
|
||||
* MO_ATOM_WITHIN16_PAIR: the entire operation is single-copy atomic,
|
||||
* if it happens to be within a 16-byte boundary, otherwise it
|
||||
* devolves to a pair of half-sized MO_ATOM_WITHIN16 operations.
|
||||
* Depending on alignment, one or both will be single-copy atomic.
|
||||
* This is the atomicity e.g. of Arm FEAT_LSE2 LDP.
|
||||
* MO_ATOM_SUBALIGN: the operation is single-copy atomic by parts
|
||||
* by the alignment. E.g. if the address is 0 mod 4, then each
|
||||
* 4-byte subobject is single-copy atomic.
|
||||
* This is the atomicity e.g. of IBM Power.
|
||||
* MO_ATOM_NONE: the operation has no atomicity requirements.
|
||||
*
|
||||
* Note the default (i.e. 0) value is single-copy atomic to the
|
||||
* size of the operation, if aligned. This retains the behaviour
|
||||
* from before this field was introduced.
|
||||
*/
|
||||
MO_ATOM_SHIFT = 8,
|
||||
MO_ATOM_IFALIGN = 0 << MO_ATOM_SHIFT,
|
||||
MO_ATOM_IFALIGN_PAIR = 1 << MO_ATOM_SHIFT,
|
||||
MO_ATOM_WITHIN16 = 2 << MO_ATOM_SHIFT,
|
||||
MO_ATOM_WITHIN16_PAIR = 3 << MO_ATOM_SHIFT,
|
||||
MO_ATOM_SUBALIGN = 4 << MO_ATOM_SHIFT,
|
||||
MO_ATOM_NONE = 5 << MO_ATOM_SHIFT,
|
||||
MO_ATOM_MASK = 7 << MO_ATOM_SHIFT,
|
||||
|
||||
/* Combinations of the above, for ease of use. */
|
||||
MO_UB = MO_8,
|
||||
MO_UW = MO_16,
|
||||
|
27
tcg/tcg.c
27
tcg/tcg.c
@ -2195,6 +2195,15 @@ static const char * const alignment_name[(MO_AMASK >> MO_ASHIFT) + 1] = {
|
||||
[MO_ALIGN_64 >> MO_ASHIFT] = "al64+",
|
||||
};
|
||||
|
||||
static const char * const atom_name[(MO_ATOM_MASK >> MO_ATOM_SHIFT) + 1] = {
|
||||
[MO_ATOM_IFALIGN >> MO_ATOM_SHIFT] = "",
|
||||
[MO_ATOM_IFALIGN_PAIR >> MO_ATOM_SHIFT] = "pair+",
|
||||
[MO_ATOM_WITHIN16 >> MO_ATOM_SHIFT] = "w16+",
|
||||
[MO_ATOM_WITHIN16_PAIR >> MO_ATOM_SHIFT] = "w16p+",
|
||||
[MO_ATOM_SUBALIGN >> MO_ATOM_SHIFT] = "sub+",
|
||||
[MO_ATOM_NONE >> MO_ATOM_SHIFT] = "noat+",
|
||||
};
|
||||
|
||||
static const char bswap_flag_name[][6] = {
|
||||
[TCG_BSWAP_IZ] = "iz",
|
||||
[TCG_BSWAP_OZ] = "oz",
|
||||
@ -2330,17 +2339,23 @@ static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs)
|
||||
case INDEX_op_qemu_ld_i64:
|
||||
case INDEX_op_qemu_st_i64:
|
||||
{
|
||||
const char *s_al, *s_op, *s_at;
|
||||
MemOpIdx oi = op->args[k++];
|
||||
MemOp op = get_memop(oi);
|
||||
unsigned ix = get_mmuidx(oi);
|
||||
|
||||
if (op & ~(MO_AMASK | MO_BSWAP | MO_SSIZE)) {
|
||||
col += ne_fprintf(f, ",$0x%x,%u", op, ix);
|
||||
s_al = alignment_name[(op & MO_AMASK) >> MO_ASHIFT];
|
||||
s_op = ldst_name[op & (MO_BSWAP | MO_SSIZE)];
|
||||
s_at = atom_name[(op & MO_ATOM_MASK) >> MO_ATOM_SHIFT];
|
||||
op &= ~(MO_AMASK | MO_BSWAP | MO_SSIZE | MO_ATOM_MASK);
|
||||
|
||||
/* If all fields are accounted for, print symbolically. */
|
||||
if (!op && s_al && s_op && s_at) {
|
||||
col += ne_fprintf(f, ",%s%s%s,%u",
|
||||
s_at, s_al, s_op, ix);
|
||||
} else {
|
||||
const char *s_al, *s_op;
|
||||
s_al = alignment_name[(op & MO_AMASK) >> MO_ASHIFT];
|
||||
s_op = ldst_name[op & (MO_BSWAP | MO_SSIZE)];
|
||||
col += ne_fprintf(f, ",%s%s,%u", s_al, s_op, ix);
|
||||
op = get_memop(oi);
|
||||
col += ne_fprintf(f, ",$0x%x,%u", op, ix);
|
||||
}
|
||||
i = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user