Skip to content

Commit 53471ef

Browse files
committedNov 4, 2024
[qemu]It compiles!
1 parent dc23827 commit 53471ef

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed
 

‎CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ else()
277277
endwhile(TRUE)
278278
endif()
279279

280+
if(UNICORN_INTERPRETER)
281+
set(UNICORN_TARGET_ARCH "tci")
282+
endif()
283+
280284
set(EXTRA_CFLAGS "--extra-cflags=")
281285
if(UNICORN_HAS_X86)
282286
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_X86 ")
@@ -514,6 +518,10 @@ set(UNICORN_ARCH_COMMON
514518
qemu/softmmu/unicorn_vtlb.c
515519
)
516520

521+
if(UNICORN_INTERPRETER)
522+
list(APPEND UNICORN_ARCH_COMMON qemu/tcg/tci.c)
523+
endif()
524+
517525
if(UNICORN_HAS_X86)
518526
add_library(x86_64-softmmu STATIC
519527
${UNICORN_ARCH_COMMON}

‎qemu/include/tcg/tcg.h

+1
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ struct TCGContext {
695695
struct jit_code_entry *one_entry;
696696
/* qemu/tcg/tcg-common.c */
697697
TCGOpDef *tcg_op_defs;
698+
size_t tcg_op_defs_max;
698699

699700
// Unicorn engine variables
700701
struct uc_struct *uc;

‎qemu/tcg/tcg.c

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262

6363
#include <uc_priv.h>
6464

65+
#if CONFIG_TCG_INTERPRETER
66+
#include "tcg/tcg.h"
67+
#endif
68+
6569
/* Forward declarations for functions declared in tcg-target.inc.c and
6670
used here. */
6771
static void tcg_target_init(TCGContext *s);
@@ -659,6 +663,7 @@ static const TCGOpDef tcg_op_defs_org[] = {
659663
#include "tcg/tcg-opc.h"
660664
#undef DEF
661665
};
666+
static const size_t tcg_op_defs_max_org = ARRAY_SIZE(tcg_op_defs_org);
662667

663668
static void process_op_defs(TCGContext *s);
664669
static TCGTemp *tcg_global_reg_new_internal(TCGContext *s, TCGType type,
@@ -727,6 +732,7 @@ void tcg_context_init(TCGContext *s)
727732
// copy original tcg_op_defs_org for private usage
728733
s->tcg_op_defs = g_malloc0(sizeof(tcg_op_defs_org));
729734
memcpy(s->tcg_op_defs, tcg_op_defs_org, sizeof(tcg_op_defs_org));
735+
s->tcg_op_defs_max = tcg_op_defs_max_org;
730736

731737
/* Count total number of arguments and allocate the corresponding
732738
space */

‎qemu/tcg/tci/tcg-target.inc.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -871,14 +871,14 @@ static void tcg_target_init(TCGContext *s)
871871
#endif
872872

873873
/* The current code uses uint8_t for tcg operations. */
874-
tcg_debug_assert(tcg_op_defs_max <= UINT8_MAX);
874+
tcg_debug_assert(s->tcg_op_defs_max <= UINT8_MAX);
875875

876876
/* Registers available for 32 bit operations. */
877-
tcg_target_available_regs[TCG_TYPE_I32] = BIT(TCG_TARGET_NB_REGS) - 1;
877+
s->tcg_target_available_regs[TCG_TYPE_I32] = BIT(TCG_TARGET_NB_REGS) - 1;
878878
/* Registers available for 64 bit operations. */
879-
tcg_target_available_regs[TCG_TYPE_I64] = BIT(TCG_TARGET_NB_REGS) - 1;
879+
s->tcg_target_available_regs[TCG_TYPE_I64] = BIT(TCG_TARGET_NB_REGS) - 1;
880880
/* TODO: Which registers should be set here? */
881-
tcg_target_call_clobber_regs = BIT(TCG_TARGET_NB_REGS) - 1;
881+
s->tcg_target_call_clobber_regs = BIT(TCG_TARGET_NB_REGS) - 1;
882882

883883
s->reserved_regs = 0;
884884
tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK);

0 commit comments

Comments
 (0)