memory: Access MemoryRegion with MemOp

Convert memory_region_dispatch_{read|write} operand "unsigned size"
into a "MemOp op".

Signed-off-by: Tony Nguyen <tony.nguyen@bt.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <1dd82df5801866743f838f1d046475115a1d32da.1566466906.git.tony.nguyen@bt.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Tony Nguyen
2019-09-03 08:30:39 -07:00
committed by Richard Henderson
parent 4cbb198eef
commit e67c904668
3 changed files with 25 additions and 13 deletions
+15 -7
View File
@@ -12,6 +12,8 @@
#ifndef MEMOP_H
#define MEMOP_H
#include "qemu/host-utils.h"
typedef enum MemOp {
MO_8 = 0,
MO_16 = 1,
@@ -107,14 +109,20 @@ typedef enum MemOp {
MO_SSIZE = MO_SIZE | MO_SIGN,
} MemOp;
/* Size in bytes to MemOp. */
static inline unsigned size_memop(unsigned size)
/* MemOp to size in bytes. */
static inline unsigned memop_size(MemOp op)
{
/*
* FIXME: No-op to aid conversion of memory_region_dispatch_{read|write}
* "unsigned size" operand into a "MemOp op".
*/
return size;
return 1 << (op & MO_SIZE);
}
/* Size in bytes to MemOp. */
static inline MemOp size_memop(unsigned size)
{
#ifdef CONFIG_DEBUG_TCG
/* Power of 2 up to 8. */
assert((size & (size - 1)) == 0 && size >= 1 && size <= 8);
#endif
return ctz32(size);
}
#endif