From patchwork Sat Nov 5 13:32:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 60006 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 091EA385742C for ; Sat, 5 Nov 2022 13:35:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 091EA385742C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667655301; bh=J39GoEYMz2U0yCcx1ZolUy1B0XumRSj67E2kTFDWfnU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=P3Uz7tcBJ4FrFGnnkKdK6geLNjdznOXGBe6KWQ/vLgn6cOrjcY8pbmiPpbTgYFdv2 WQGRQcrPLyPrZJDrzbVd951j8MO6XWVtfb5KQTq7iKFgj90w2KAP/kyweb2S3QGMqt 3C4O2SGtqu3IGzyu3NUSA6PDm3atZIwVOqYWsV/A= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 4EC5138582B3 for ; Sat, 5 Nov 2022 13:33:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4EC5138582B3 Received: by smtp.gentoo.org (Postfix, from userid 559) id F12353412CC; Sat, 5 Nov 2022 13:33:33 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH 13/26] sim: h8300: invert sim_cpu storage Date: Sat, 5 Nov 2022 20:32:45 +0700 Message-Id: <20221105133258.23409-14-vapier@gentoo.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221105133258.23409-1-vapier@gentoo.org> References: <20221101151158.24916-1-vapier@gentoo.org> <20221105133258.23409-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mike Frysinger via Gdb-patches From: Mike Frysinger Reply-To: Mike Frysinger Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" --- sim/h8300/compile.c | 59 ++++++++++++++++++++++---------------------- sim/h8300/sim-main.h | 11 +++++---- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c index 25fb8b822251..a55a26474180 100644 --- a/sim/h8300/compile.c +++ b/sim/h8300/compile.c @@ -57,13 +57,13 @@ static int memory_size; static unsigned int h8_get_reg (sim_cpu *cpu, int regnum) { - return cpu->regs[regnum]; + return H8300_SIM_CPU (cpu)->regs[regnum]; } static void h8_set_reg (sim_cpu *cpu, int regnum, int val) { - cpu->regs[regnum] = val; + H8300_SIM_CPU (cpu)->regs[regnum] = val; } #define h8_get_ccr(cpu) h8_get_reg (cpu, CCR_REGNUM) @@ -88,25 +88,25 @@ h8_set_reg (sim_cpu *cpu, int regnum, int val) static int h8_get_mask (sim_cpu *cpu) { - return cpu->mask; + return H8300_SIM_CPU (cpu)->mask; } static void h8_set_mask (sim_cpu *cpu, int val) { - cpu->mask = val; + H8300_SIM_CPU (cpu)->mask = val; } #if 0 static int h8_get_exception (sim_cpu *cpu) { - return cpu->exception; + return H8300_SIM_CPU (cpu)->exception; } static void h8_set_exception (sim_cpu *cpu, int val) { - cpu->exception = val; + H8300_SIM_CPU (cpu)->exception = val; } static enum h8300_sim_state @@ -125,7 +125,7 @@ h8_set_state (SIM_DESC sd, enum h8300_sim_state val) static unsigned int * h8_get_reg_buf (sim_cpu *cpu) { - return &cpu->regs[0]; + return &H8300_SIM_CPU (cpu)->regs[0]; } #ifdef ADEBUG @@ -145,77 +145,77 @@ h8_increment_stats (SIM_DESC sd, int idx) static unsigned char * h8_get_memory_buf (sim_cpu *cpu) { - return cpu->memory; + return H8300_SIM_CPU (cpu)->memory; } static void h8_set_memory_buf (sim_cpu *cpu, unsigned char *ptr) { - cpu->memory = ptr; + H8300_SIM_CPU (cpu)->memory = ptr; } static unsigned char h8_get_memory (sim_cpu *cpu, int idx) { ASSERT (idx < memory_size); - return cpu->memory[idx]; + return H8300_SIM_CPU (cpu)->memory[idx]; } static void h8_set_memory (sim_cpu *cpu, int idx, unsigned int val) { ASSERT (idx < memory_size); - cpu->memory[idx] = (unsigned char) val; + H8300_SIM_CPU (cpu)->memory[idx] = (unsigned char) val; } static unsigned int h8_get_delayed_branch (sim_cpu *cpu) { - return cpu->delayed_branch; + return H8300_SIM_CPU (cpu)->delayed_branch; } static void h8_set_delayed_branch (sim_cpu *cpu, unsigned int dest) { - cpu->delayed_branch = dest; + H8300_SIM_CPU (cpu)->delayed_branch = dest; } static char ** h8_get_command_line (sim_cpu *cpu) { - return cpu->command_line; + return H8300_SIM_CPU (cpu)->command_line; } static void h8_set_command_line (sim_cpu *cpu, char ** val) { - cpu->command_line = val; + H8300_SIM_CPU (cpu)->command_line = val; } static char * h8_get_cmdline_arg (sim_cpu *cpu, int index) { - return cpu->command_line[index]; + return H8300_SIM_CPU (cpu)->command_line[index]; } static void h8_set_cmdline_arg (sim_cpu *cpu, int index, char * val) { - cpu->command_line[index] = val; + H8300_SIM_CPU (cpu)->command_line[index] = val; } /* MAC Saturation Mode */ static int h8_get_macS (sim_cpu *cpu) { - return cpu->macS; + return H8300_SIM_CPU (cpu)->macS; } #if 0 static void h8_set_macS (sim_cpu *cpu, int val) { - cpu->macS = (val != 0); + H8300_SIM_CPU (cpu)->macS = (val != 0); } #endif @@ -223,39 +223,39 @@ h8_set_macS (sim_cpu *cpu, int val) static int h8_get_macZ (sim_cpu *cpu) { - return cpu->macZ; + return H8300_SIM_CPU (cpu)->macZ; } static void h8_set_macZ (sim_cpu *cpu, int val) { - cpu->macZ = (val != 0); + H8300_SIM_CPU (cpu)->macZ = (val != 0); } /* MAC Negative Flag */ static int h8_get_macN (sim_cpu *cpu) { - return cpu->macN; + return H8300_SIM_CPU (cpu)->macN; } static void h8_set_macN (sim_cpu *cpu, int val) { - cpu->macN = (val != 0); + H8300_SIM_CPU (cpu)->macN = (val != 0); } /* MAC Overflow Flag */ static int h8_get_macV (sim_cpu *cpu) { - return cpu->macV; + return H8300_SIM_CPU (cpu)->macV; } static void h8_set_macV (sim_cpu *cpu, int val) { - cpu->macV = (val != 0); + H8300_SIM_CPU (cpu)->macV = (val != 0); } /* End CPU data object. */ @@ -1593,7 +1593,7 @@ init_pointers (SIM_DESC sd) h8_set_mask (cpu, memory_size - 1); - memset (h8_get_reg_buf (cpu), 0, sizeof (cpu->regs)); + memset (h8_get_reg_buf (cpu), 0, sizeof (H8300_SIM_CPU (cpu)->regs)); for (i = 0; i < 8; i++) { @@ -4592,13 +4592,13 @@ static const OPTION h8300_options[] = static sim_cia h8300_pc_get (sim_cpu *cpu) { - return cpu->pc; + return H8300_SIM_CPU (cpu)->pc; } static void h8300_pc_set (sim_cpu *cpu, sim_cia pc) { - cpu->pc = pc; + H8300_SIM_CPU (cpu)->pc = pc; } /* Cover function of sim_state_free to free the cpu buffers as well. */ @@ -4629,7 +4629,8 @@ sim_open (SIM_OPEN_KIND kind, current_target_byte_order = BFD_ENDIAN_BIG; /* The cpu data is kept in a separately allocated chunk of memory. */ - if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK) + if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct h8300_sim_cpu)) + != SIM_RC_OK) { free_state (sd); return 0; diff --git a/sim/h8300/sim-main.h b/sim/h8300/sim-main.h index f27ba6827381..d0a04f5fa46a 100644 --- a/sim/h8300/sim-main.h +++ b/sim/h8300/sim-main.h @@ -5,6 +5,8 @@ #ifndef SIM_MAIN_H #define SIM_MAIN_H +#define SIM_HAVE_COMMON_SIM_CPU + #define DEBUG /* These define the size of main memory for the simulator. @@ -114,7 +116,7 @@ typedef struct #endif } decoded_inst; -struct _sim_cpu { +struct h8300_sim_cpu { unsigned int regs[20]; /* 8 GR's plus ZERO, SBR, and VBR. */ unsigned int pc; @@ -128,9 +130,8 @@ struct _sim_cpu { unsigned char *memory; int mask; - - sim_cpu_base base; }; +#define H8300_SIM_CPU(sd) ((struct h8300_sim_cpu *) CPU_ARCH_DATA (sd)) struct h8300_sim_state { unsigned long memory_size; @@ -142,8 +143,8 @@ struct h8300_sim_state { /* The current state of the processor; registers, memory, etc. */ -#define cpu_set_pc(CPU, VAL) (((CPU)->pc) = (VAL)) -#define cpu_get_pc(CPU) (((CPU)->pc)) +#define cpu_set_pc(cpu, val) (H8300_SIM_CPU (cpu)->pc = (val)) +#define cpu_get_pc(cpu) (H8300_SIM_CPU (cpu)->pc) /* Magic numbers used to distinguish an exit from a breakpoint. */ #define LIBC_EXIT_MAGIC1 0xdead