Rather than having to lookup for what the 0, 1, 2, ...
icount values are, use a enum definition.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <
20231208113529.74067-4-philmd@linaro.org>
/* Arbitrarily pick 1MIPS as the minimum allowable speed. */
#define MAX_ICOUNT_SHIFT 10
-/*
- * 0 = Do not count executed instructions.
- * 1 = Fixed conversion of insn to ns via "shift" option
- * 2 = Runtime adaptive algorithm to compute shift
- */
-int use_icount;
+/* Do not count executed instructions */
+ICountMode use_icount = ICOUNT_DISABLED;
static void icount_enable_precise(void)
{
- use_icount = 1;
+ /* Fixed conversion of insn to ns via "shift" option */
+ use_icount = ICOUNT_PRECISE;
}
static void icount_enable_adaptive(void)
{
- use_icount = 2;
+ /* Runtime adaptive algorithm to compute shift */
+ use_icount = ICOUNT_ADAPTATIVE;
}
/*
int64_t warp_delta;
warp_delta = clock - timers_state.vm_clock_warp_start;
- if (icount_enabled() == 2) {
+ if (icount_enabled() == ICOUNT_ADAPTATIVE) {
/*
* In adaptive mode, do not let QEMU_CLOCK_VIRTUAL run too far
* ahead of real time (it might already be ahead so careful not
/* icount - Instruction Counter API */
-/*
- * icount enablement state:
+/**
+ * ICountMode: icount enablement state:
*
- * 0 = Disabled - Do not count executed instructions.
- * 1 = Enabled - Fixed conversion of insn to ns via "shift" option
- * 2 = Enabled - Runtime adaptive algorithm to compute shift
+ * @ICOUNT_DISABLED: Disabled - Do not count executed instructions.
+ * @ICOUNT_PRECISE: Enabled - Fixed conversion of insn to ns via "shift" option
+ * @ICOUNT_ADAPTATIVE: Enabled - Runtime adaptive algorithm to compute shift
*/
+typedef enum {
+ ICOUNT_DISABLED = 0,
+ ICOUNT_PRECISE,
+ ICOUNT_ADAPTATIVE,
+} ICountMode;
+
#ifdef CONFIG_TCG
-extern int use_icount;
+extern ICountMode use_icount;
#define icount_enabled() (use_icount)
#else
-#define icount_enabled() 0
+#define icount_enabled() ICOUNT_DISABLED
#endif
/*
/* icount - Instruction Counter API */
-int use_icount;
+ICountMode use_icount = ICOUNT_DISABLED;
void icount_update(CPUState *cpu)
{
static bool icount_shift_state_needed(void *opaque)
{
- return icount_enabled() == 2;
+ return icount_enabled() == ICOUNT_ADAPTATIVE;
}
/*
static bool instructions_supported(CPUARMState *env)
{
- return icount_enabled() == 1; /* Precise instruction counting */
+ /* Precise instruction counting */
+ return icount_enabled() == ICOUNT_PRECISE;
}
static uint64_t instructions_get_count(CPUARMState *env)