Skip to content

Commit

Permalink
[qemu]It compiles!
Browse files Browse the repository at this point in the history
  • Loading branch information
Naville committed Oct 29, 2024
1 parent 9d20ee8 commit 0d9f826
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ else()
endwhile(TRUE)
endif()

if(UNICORN_INTERPRETER)
set(UNICORN_TARGET_ARCH "tci")
endif()

set(EXTRA_CFLAGS "--extra-cflags=")
if(UNICORN_HAS_X86)
set(EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_X86 ")
Expand Down Expand Up @@ -496,6 +500,10 @@ set(UNICORN_ARCH_COMMON
qemu/softmmu/unicorn_vtlb.c
)

if(UNICORN_INTERPRETER)
list(APPEND UNICORN_ARCH_COMMON qemu/tcg/tci.c)
endif()

if(UNICORN_HAS_X86)
add_library(x86_64-softmmu STATIC
${UNICORN_ARCH_COMMON}
Expand Down
1 change: 1 addition & 0 deletions qemu/include/tcg/tcg.h
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ struct TCGContext {
struct jit_code_entry *one_entry;
/* qemu/tcg/tcg-common.c */
TCGOpDef *tcg_op_defs;
size_t tcg_op_defs_max;

// Unicorn engine variables
struct uc_struct *uc;
Expand Down
6 changes: 6 additions & 0 deletions qemu/tcg/tcg.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@

#include <uc_priv.h>

#if CONFIG_TCG_INTERPRETER
#include "tcg/tcg.h"
#endif

/* Forward declarations for functions declared in tcg-target.inc.c and
used here. */
static void tcg_target_init(TCGContext *s);
Expand Down Expand Up @@ -659,6 +663,7 @@ static const TCGOpDef tcg_op_defs_org[] = {
#include "tcg/tcg-opc.h"
#undef DEF
};
static const size_t tcg_op_defs_max_org = ARRAY_SIZE(tcg_op_defs_org);

static void process_op_defs(TCGContext *s);
static TCGTemp *tcg_global_reg_new_internal(TCGContext *s, TCGType type,
Expand Down Expand Up @@ -727,6 +732,7 @@ void tcg_context_init(TCGContext *s)
// copy original tcg_op_defs_org for private usage
s->tcg_op_defs = g_malloc0(sizeof(tcg_op_defs_org));
memcpy(s->tcg_op_defs, tcg_op_defs_org, sizeof(tcg_op_defs_org));
s->tcg_op_defs_max = tcg_op_defs_max_org;

/* Count total number of arguments and allocate the corresponding
space */
Expand Down
8 changes: 4 additions & 4 deletions qemu/tcg/tci/tcg-target.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,14 +871,14 @@ static void tcg_target_init(TCGContext *s)
#endif

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

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

s->reserved_regs = 0;
tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK);
Expand Down

0 comments on commit 0d9f826

Please sign in to comment.