From patchwork Wed Jan 3 07:19:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83212 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 48DE0385C6F7 for ; Wed, 3 Jan 2024 07:20:30 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id C25F7385DC33 for ; Wed, 3 Jan 2024 07:19:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C25F7385DC33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C25F7385DC33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704266374; cv=none; b=HxZdSrzi5B2xYFmriCoqio503+U8BQ/CHvyIw3CMEkcwqzHx7P2i3UqJktxirWUXi58eAupURBIHzacXzcCOGY0Lh7cEIYAhjd2MGZEYW/ZFS3BA+e+6vpLsVN2I/YaKnUnrZVSR13zkSh3atQCkStdwHZllEtV9OJk3eg2kZBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704266374; c=relaxed/simple; bh=L4HXFLCKsCpgq60ZWL5yyDyE8YO1UNhCCoac4gzVdmI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=mzThSCie1jyrKO0N4/+eS+Bay3gKJCgRXWy56K445NQP1vMRb2qIiBX3KC2I7GHrR3eHKZPsGIZNfqcKpSY66H9maJ74Kd/Pu6z2u7OEbUUtJIKGiVtQ9Vjk+aFYlbreIl9FngOlVOROp8/vjbJySM8qfhpQhIthsyMoQtGPbzk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 5F656340DE6; Wed, 3 Jan 2024 07:19:30 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 1/4] sim: ppc: sync WITH_TARGET_{ADDRESS, CELL}_BITSIZE with common/ Date: Wed, 3 Jan 2024 02:19:25 -0500 Message-ID: <20240103071928.26550-1-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This will make it easier to share common/ code that rely on these additional defines. --- sim/ppc/std-config.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sim/ppc/std-config.h b/sim/ppc/std-config.h index d317826ba1d4..de68cf261816 100644 --- a/sim/ppc/std-config.h +++ b/sim/ppc/std-config.h @@ -90,6 +90,14 @@ extern enum bfd_endian current_target_byte_order; #define WITH_TARGET_WORD_BITSIZE 32 /* compiled only */ #endif +#ifndef WITH_TARGET_ADDRESS_BITSIZE +#define WITH_TARGET_ADDRESS_BITSIZE WITH_TARGET_WORD_BITSIZE +#endif + +#ifndef WITH_TARGET_CELL_BITSIZE +#define WITH_TARGET_CELL_BITSIZE WITH_TARGET_WORD_BITSIZE +#endif + /* Program environment: From patchwork Wed Jan 3 07:19:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83216 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 679EB385DC26 for ; Wed, 3 Jan 2024 07:22:07 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 8A0B53857C51 for ; Wed, 3 Jan 2024 07:19:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A0B53857C51 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8A0B53857C51 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704266376; cv=none; b=TBMZyzP/HotFNVAG5ih34LqPNhIE8bUn8TItfxNS4U8puxIk5G3DH9wbpfLD5bVDUioOOUYXXQe1JlFbbIHacrwTWvIDk7XXEm6lAhf26ANB3c0GagNAN5yZ0mfQiX+M73ZxQK12iCe+VFwuW62uFCbu8j84hW3+3uFxXLDFafM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704266376; c=relaxed/simple; bh=wjx8dk29N28NYtP8RKVVgZGOOqDpC6sh2xjQ4pL42Y4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=KMeYZWMxOqIEUNIVloRC30zumQBxFPovAfbOPOgBbmDgALpA0U9+fObpngyDKBiSwikEpNyzADmToXb2LNbeiejfa8ZmqimmamQpuCE6URVjmFwt2iFT4ZrzTpgoFY5QGZfMQRYYdx9tuOugyXAm1BAwYkN6G3drIpc6xyglpmg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id D9441341E1C; Wed, 3 Jan 2024 07:19:32 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 2/4] sim: ppc: rename local ALU SIGNED64 macros Date: Wed, 3 Jan 2024 02:19:26 -0500 Message-ID: <20240103071928.26550-2-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103071928.26550-1-vapier@gentoo.org> References: <20240103071928.26550-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org The common/ code has macros with the same name but different behavior: it's for declaring integer constants as 64-bit, not for casting them. Rename ppc's local variant since it's only used in this file in order to avoid conflicts. --- sim/ppc/idecode_expression.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sim/ppc/idecode_expression.h b/sim/ppc/idecode_expression.h index 9c4cb7a55a98..86b33945b77c 100644 --- a/sim/ppc/idecode_expression.h +++ b/sim/ppc/idecode_expression.h @@ -57,8 +57,8 @@ /* Macro's to type cast 32bit constants to 64bits */ -#define SIGNED64(val) ((int64_t)(int32_t)(val)) -#define UNSIGNED64(val) ((uint64_t)(uint32_t)(val)) +#define ALU_SIGNED64(val) ((int64_t)(int32_t)(val)) +#define ALU_UNSIGNED64(val) ((uint64_t)(uint32_t)(val)) /* Start a section of ALU code */ @@ -134,14 +134,14 @@ do { \ #if (WITH_TARGET_WORD_BITSIZE == 64) #define ALU_ADD(val) \ do { \ - uint64_t alu_lo = (UNSIGNED64(alu_val) \ - + UNSIGNED64(val)); \ + uint64_t alu_lo = (ALU_UNSIGNED64(alu_val) \ + + ALU_UNSIGNED64(val)); \ signed alu_carry = ((alu_lo & BIT(31)) != 0); \ alu_carry_val = (alu_carry_val \ - + UNSIGNED64(EXTRACTED(val, 0, 31)) \ + + ALU_UNSIGNED64(EXTRACTED(val, 0, 31)) \ + alu_carry); \ alu_overflow_val = (alu_overflow_val \ - + SIGNED64(EXTRACTED(val, 0, 31)) \ + + ALU_SIGNED64(EXTRACTED(val, 0, 31)) \ + alu_carry); \ alu_val = alu_val + val; \ } while (0) From patchwork Wed Jan 3 07:19:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83214 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 DC05F385E004 for ; Wed, 3 Jan 2024 07:20:57 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 4AE9F385C424 for ; Wed, 3 Jan 2024 07:19:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4AE9F385C424 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4AE9F385C424 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704266376; cv=none; b=yCiWmNOY1ApUZr0ZpGYMa6gvD+a4fNpSZncaaXdcEEly9xdh0hG0GHWASPJJwzmvM2FL8ML0pIXVQ06pyvvmGcPkOHQdj5O1vsFgWcrvVIiB55B4Pznk0in8qrEhg+WtQptKgOJ4B75R0S1CKnoUJSywJKaMQ0I5voMikMdaV4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704266376; c=relaxed/simple; bh=LoMCl/bJYK+YIysKsnR+CkDBDz15IRoAyclLHrevd1c=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=OfXz2/WR3gWDrhxHOMs+ZZrhSaGP3tz/8nC6r0wnlbLtrSh4L0FwdY+UqG32/w/07TpuTD1xxetNGcTVeXZiX3iNXoxDV/YB+yl7Q2lIahRDhawZ1p2GCtOk/Ei89Iz15EBaCap+R+0lnBE0wZQdAX6cLuzx577/0+QQWPYUjoE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id DBA7C342FFA; Wed, 3 Jan 2024 07:19:34 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 3/4] sim: common: include sim-types.h in the endian header directly Date: Wed, 3 Jan 2024 02:19:27 -0500 Message-ID: <20240103071928.26550-3-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103071928.26550-1-vapier@gentoo.org> References: <20240103071928.26550-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This is a bit redundant for most ports as they go through sim-basics.h which always includes sim-types.h before including sim-endian.h, but in order to unify ppc's sim-endian code, we need this include here. Plus, it's the directly we generally want to go to get away from one header that defines all APIs and causes hard to untangle dependencies. --- sim/common/sim-endian.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sim/common/sim-endian.h b/sim/common/sim-endian.h index 589169ea11cf..93a6d0d8c13a 100644 --- a/sim/common/sim-endian.h +++ b/sim/common/sim-endian.h @@ -23,6 +23,8 @@ #ifndef SIM_ENDIAN_H #define SIM_ENDIAN_H +#include "sim-types.h" + /* C byte conversion functions */ INLINE_SIM_ENDIAN(unsigned_1) endian_h2t_1(unsigned_1 x); From patchwork Wed Jan 3 07:19:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83217 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 7F40A385DC2E for ; Wed, 3 Jan 2024 07:22:15 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id AF1843857BAB for ; Wed, 3 Jan 2024 07:19:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AF1843857BAB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AF1843857BAB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704266385; cv=none; b=rEFnZ127Rw8STwip/Xw7o0DebNju7/wVe/74N3hE+kWXOvD7xSm3VTjAPF9nex7J72Eic9jhqTO+Hzb8fRE/IuGyWUR/zADLp4rbWMEzyFT0ZDSMOh1boKm4aOSpf0SxuZwTbJ61FntPsj6aDSaMDGMtdtxb/82KpXWlTyRbLOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704266385; c=relaxed/simple; bh=RczFAVxuEriQwgocyspNO4gOqDzGrfJm7gNlgmW2rB0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=f8Ie/g2ZwDBXWxQuxjFGPwyW0eT/KNJEGD8uxZdOxx6hLNNB/ept82J0ZcmhAoVkM+4O02xEVE5P0vpRwS+EESo/jOy1/mH2XxRjGHawbAigJPSTDc5WggUe0DoQWLMqlQ8XW2y2l/ztNyNo75p/0Dg579sPnCs/iKjrL0JhVBc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id D9CFB342F64; Wed, 3 Jan 2024 07:19:36 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 4/4] sim: ppc: switch to common endian code Date: Wed, 3 Jan 2024 02:19:28 -0500 Message-ID: <20240103071928.26550-4-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103071928.26550-1-vapier@gentoo.org> References: <20240103071928.26550-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org The common sim-endian is a forked & updated version of the ppc code. Fortunately, they didn't diverge from the basic APIs, so they are still compatible, which means we can just delete the ppc version now that the build env is merged at the top-level. --- sim/Makefile.in | 2 - sim/ppc/local.mk | 4 - sim/ppc/sim-endian-n.h | 133 ------------------------ sim/ppc/sim-endian.c | 76 -------------- sim/ppc/sim-endian.h | 225 ----------------------------------------- 5 files changed, 440 deletions(-) delete mode 100644 sim/ppc/sim-endian-n.h delete mode 100644 sim/ppc/sim-endian.c delete mode 100644 sim/ppc/sim-endian.h diff --git a/sim/ppc/local.mk b/sim/ppc/local.mk index 01cc1251a89b..f6da1c213385 100644 --- a/sim/ppc/local.mk +++ b/sim/ppc/local.mk @@ -67,10 +67,6 @@ AM_CPPFLAGS_%C%_options.o = '-DOPCODE_RULES="$(IGEN_OPCODE_RULES)"' '-DIGEN_FLAG noinst_LIBRARIES += %D%/libsim.a -## common/sim-endian.c is matched before ppc/sim-endian.c due to the pattern -## rule below. Force the ppc version until we can unify the two properly. -%D%/sim-endian.o: $(srcdir)/%D%/sim-endian.c ; $(SIM_COMPILE) - %D%/%.o: common/%.c ; $(SIM_COMPILE) -@am__include@ %D%/$(DEPDIR)/*.Po diff --git a/sim/ppc/sim-endian-n.h b/sim/ppc/sim-endian-n.h deleted file mode 100644 index a9b2e2078234..000000000000 --- a/sim/ppc/sim-endian-n.h +++ /dev/null @@ -1,133 +0,0 @@ -/* This file is part of the program psim. - - Copyright (C) 1994-1995, Andrew Cagney - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . - - */ - - -#ifndef N -#error "N must be #defined" -#endif - -/* NOTE: See end of file for #undef */ -#define unsigned_N XCONCAT2(unsigned_,N) -#define endian_t2h_N XCONCAT2(endian_t2h_,N) -#define endian_h2t_N XCONCAT2(endian_h2t_,N) -#define _SWAP_N XCONCAT2(_SWAP_,N) -#define swap_N XCONCAT2(swap_,N) -#define endian_h2be_N XCONCAT2(endian_h2be_,N) -#define endian_be2h_N XCONCAT2(endian_be2h_,N) -#define endian_h2le_N XCONCAT2(endian_h2le_,N) -#define endian_le2h_N XCONCAT2(endian_le2h_,N) - - -INLINE_PSIM_ENDIAN\ -(unsigned_N) -endian_t2h_N(unsigned_N raw_in) -{ - if (CURRENT_TARGET_BYTE_ORDER == HOST_BYTE_ORDER) { - return raw_in; - } - else { - _SWAP_N(return,raw_in); - } -} - - -INLINE_PSIM_ENDIAN\ -(unsigned_N) -endian_h2t_N(unsigned_N raw_in) -{ - if (CURRENT_TARGET_BYTE_ORDER == HOST_BYTE_ORDER) { - return raw_in; - } - else { - _SWAP_N(return,raw_in); - } -} - - -INLINE_PSIM_ENDIAN\ -(unsigned_N) -swap_N(unsigned_N raw_in) -{ - _SWAP_N(return,raw_in); -} - - - -INLINE_PSIM_ENDIAN\ -(unsigned_N) -endian_h2be_N(unsigned_N raw_in) -{ - if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG) { - return raw_in; - } - else { - _SWAP_N(return,raw_in); - } -} - - -INLINE_PSIM_ENDIAN\ -(unsigned_N) -endian_be2h_N(unsigned_N raw_in) -{ - if (HOST_BYTE_ORDER == BFD_ENDIAN_BIG) { - return raw_in; - } - else { - _SWAP_N(return,raw_in); - } -} - - -INLINE_PSIM_ENDIAN\ -(unsigned_N) -endian_h2le_N(unsigned_N raw_in) -{ - if (HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE) { - return raw_in; - } - else { - _SWAP_N(return,raw_in); - } -} - - -INLINE_PSIM_ENDIAN\ -(unsigned_N) -endian_le2h_N(unsigned_N raw_in) -{ - if (HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE) { - return raw_in; - } - else { - _SWAP_N(return,raw_in); - } -} - - -/* NOTE: See start of file for #define */ -#undef unsigned_N -#undef endian_t2h_N -#undef endian_h2t_N -#undef _SWAP_N -#undef swap_N -#undef endian_h2be_N -#undef endian_be2h_N -#undef endian_h2le_N -#undef endian_le2h_N diff --git a/sim/ppc/sim-endian.c b/sim/ppc/sim-endian.c deleted file mode 100644 index ee1e0839939b..000000000000 --- a/sim/ppc/sim-endian.c +++ /dev/null @@ -1,76 +0,0 @@ -/* This file is part of the program psim. - - Copyright (C) 1994-1995, Andrew Cagney - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . - - */ - - -#ifndef _SIM_ENDIAN_C_ -#define _SIM_ENDIAN_C_ - -/* This must come before any other includes. */ -#include "defs.h" - -#include "basics.h" -#include "symcat.h" - - -#if !defined(_SWAP_1) -#define _SWAP_1(SET,RAW) SET (RAW) -#endif - -#if !defined(_SWAP_2) && (HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE) && defined(htons) -#define _SWAP_2(SET,RAW) SET htons (RAW) -#endif - -#ifndef _SWAP_2 -#define _SWAP_2(SET,RAW) SET (((RAW) >> 8) | ((RAW) << 8)) -#endif - -#if !defined(_SWAP_4) && (HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE) && defined(htonl) -#define _SWAP_4(SET,RAW) SET htonl (RAW) -#endif - -#ifndef _SWAP_4 -#define _SWAP_4(SET,RAW) SET (((RAW) << 24) | (((RAW) & 0xff00) << 8) | (((RAW) & 0xff0000) >> 8) | ((RAW) >> 24)) -#endif - -#ifndef _SWAP_8 -#define _SWAP_8(SET,RAW) \ - union { unsigned_8 dword; unsigned_4 words[2]; } in, out; \ - in.dword = RAW; \ - _SWAP_4 (out.words[0] =, in.words[1]); \ - _SWAP_4 (out.words[1] =, in.words[0]); \ - SET out.dword; -#endif - -#define N 1 -#include "sim-endian-n.h" -#undef N - -#define N 2 -#include "sim-endian-n.h" -#undef N - -#define N 4 -#include "sim-endian-n.h" -#undef N - -#define N 8 -#include "sim-endian-n.h" -#undef N - -#endif /* _SIM_ENDIAN_C_ */ diff --git a/sim/ppc/sim-endian.h b/sim/ppc/sim-endian.h deleted file mode 100644 index e07457212874..000000000000 --- a/sim/ppc/sim-endian.h +++ /dev/null @@ -1,225 +0,0 @@ -/* This file is part of the program psim. - - Copyright (C) 1994-1995, Andrew Cagney - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . - - */ - - -#ifndef _SIM_ENDIAN_H_ -#define _SIM_ENDIAN_H_ - - -/* C byte conversion functions */ - -INLINE_PSIM_ENDIAN(unsigned_1) endian_h2t_1(unsigned_1 x); -INLINE_PSIM_ENDIAN(unsigned_2) endian_h2t_2(unsigned_2 x); -INLINE_PSIM_ENDIAN(unsigned_4) endian_h2t_4(unsigned_4 x); -INLINE_PSIM_ENDIAN(unsigned_8) endian_h2t_8(unsigned_8 x); - -INLINE_PSIM_ENDIAN(unsigned_1) endian_t2h_1(unsigned_1 x); -INLINE_PSIM_ENDIAN(unsigned_2) endian_t2h_2(unsigned_2 x); -INLINE_PSIM_ENDIAN(unsigned_4) endian_t2h_4(unsigned_4 x); -INLINE_PSIM_ENDIAN(unsigned_8) endian_t2h_8(unsigned_8 x); - -INLINE_PSIM_ENDIAN(unsigned_1) swap_1(unsigned_1 x); -INLINE_PSIM_ENDIAN(unsigned_2) swap_2(unsigned_2 x); -INLINE_PSIM_ENDIAN(unsigned_4) swap_4(unsigned_4 x); -INLINE_PSIM_ENDIAN(unsigned_8) swap_8(unsigned_8 x); - -INLINE_PSIM_ENDIAN(unsigned_1) endian_h2be_1(unsigned_1 x); -INLINE_PSIM_ENDIAN(unsigned_2) endian_h2be_2(unsigned_2 x); -INLINE_PSIM_ENDIAN(unsigned_4) endian_h2be_4(unsigned_4 x); -INLINE_PSIM_ENDIAN(unsigned_8) endian_h2be_8(unsigned_8 x); - -INLINE_PSIM_ENDIAN(unsigned_1) endian_be2h_1(unsigned_1 x); -INLINE_PSIM_ENDIAN(unsigned_2) endian_be2h_2(unsigned_2 x); -INLINE_PSIM_ENDIAN(unsigned_4) endian_be2h_4(unsigned_4 x); -INLINE_PSIM_ENDIAN(unsigned_8) endian_be2h_8(unsigned_8 x); - -INLINE_PSIM_ENDIAN(unsigned_1) endian_h2le_1(unsigned_1 x); -INLINE_PSIM_ENDIAN(unsigned_2) endian_h2le_2(unsigned_2 x); -INLINE_PSIM_ENDIAN(unsigned_4) endian_h2le_4(unsigned_4 x); -INLINE_PSIM_ENDIAN(unsigned_8) endian_h2le_8(unsigned_8 x); - -INLINE_PSIM_ENDIAN(unsigned_1) endian_le2h_1(unsigned_1 x); -INLINE_PSIM_ENDIAN(unsigned_2) endian_le2h_2(unsigned_2 x); -INLINE_PSIM_ENDIAN(unsigned_4) endian_le2h_4(unsigned_4 x); -INLINE_PSIM_ENDIAN(unsigned_8) endian_le2h_8(unsigned_8 x); - - -/* SWAP */ - -#define SWAP_1 swap_1 -#define SWAP_2 swap_2 -#define SWAP_4 swap_4 -#define SWAP_8 swap_8 - - -/* HOST to BE */ - -#define H2BE_1 endian_h2be_1 -#define H2BE_2 endian_h2be_2 -#define H2BE_4 endian_h2be_4 -#define H2BE_8 endian_h2be_8 -#define BE2H_1 endian_be2h_1 -#define BE2H_2 endian_be2h_2 -#define BE2H_4 endian_be2h_4 -#define BE2H_8 endian_be2h_8 - - -/* HOST to LE */ - -#define H2LE_1 endian_h2le_1 -#define H2LE_2 endian_h2le_2 -#define H2LE_4 endian_h2le_4 -#define H2LE_8 endian_h2le_8 -#define LE2H_1 endian_le2h_1 -#define LE2H_2 endian_le2h_2 -#define LE2H_4 endian_le2h_4 -#define LE2H_8 endian_le2h_8 - - -/* HOST to TARGET */ - -#define H2T_1 endian_h2t_1 -#define H2T_2 endian_h2t_2 -#define H2T_4 endian_h2t_4 -#define H2T_8 endian_h2t_8 -#define T2H_1 endian_t2h_1 -#define T2H_2 endian_t2h_2 -#define T2H_4 endian_t2h_4 -#define T2H_8 endian_t2h_8 - - -/* CONVERT IN PLACE - - These macros, given an argument of unknown size, swap its value in - place if a host/target conversion is required. */ - -#define H2T(VARIABLE) \ -do { \ - switch (sizeof(VARIABLE)) { \ - case 1: VARIABLE = H2T_1(VARIABLE); break; \ - case 2: VARIABLE = H2T_2(VARIABLE); break; \ - case 4: VARIABLE = H2T_4(VARIABLE); break; \ - case 8: VARIABLE = H2T_8(VARIABLE); break; \ - } \ -} while (0) - -#define T2H(VARIABLE) \ -do { \ - switch (sizeof(VARIABLE)) { \ - case 1: VARIABLE = T2H_1(VARIABLE); break; \ - case 2: VARIABLE = T2H_2(VARIABLE); break; \ - case 4: VARIABLE = T2H_4(VARIABLE); break; \ - case 8: VARIABLE = T2H_8(VARIABLE); break; \ - } \ -} while (0) - -#define SWAP(VARIABLE) \ -do { \ - switch (sizeof(VARIABLE)) { \ - case 1: VARIABLE = SWAP_1(VARIABLE); break; \ - case 2: VARIABLE = SWAP_2(VARIABLE); break; \ - case 4: VARIABLE = SWAP_4(VARIABLE); break; \ - case 8: VARIABLE = SWAP_8(VARIABLE); break; \ - } \ -} while (0) - -#define H2BE(VARIABLE) \ -do { \ - switch (sizeof(VARIABLE)) { \ - case 1: VARIABLE = H2BE_1(VARIABLE); break; \ - case 2: VARIABLE = H2BE_2(VARIABLE); break; \ - case 4: VARIABLE = H2BE_4(VARIABLE); break; \ - case 8: VARIABLE = H2BE_8(VARIABLE); break; \ - } \ -} while (0) - -#define BE2H(VARIABLE) \ -do { \ - switch (sizeof(VARIABLE)) { \ - case 1: VARIABLE = BE2H_1(VARIABLE); break; \ - case 2: VARIABLE = BE2H_2(VARIABLE); break; \ - case 4: VARIABLE = BE2H_4(VARIABLE); break; \ - case 8: VARIABLE = BE2H_8(VARIABLE); break; \ - } \ -} while (0) - -#define H2LE(VARIABLE) \ -do { \ - switch (sizeof(VARIABLE)) { \ - case 1: VARIABLE = H2LE_1(VARIABLE); break; \ - case 2: VARIABLE = H2LE_2(VARIABLE); break; \ - case 4: VARIABLE = H2LE_4(VARIABLE); break; \ - case 8: VARIABLE = H2LE_8(VARIABLE); break; \ - } \ -} while (0) - -#define LE2H(VARIABLE) \ -do { \ - switch (sizeof(VARIABLE)) { \ - case 1: VARIABLE = LE2H_1(VARIABLE); break; \ - case 2: VARIABLE = LE2H_2(VARIABLE); break; \ - case 4: VARIABLE = LE2H_4(VARIABLE); break; \ - case 8: VARIABLE = LE2H_8(VARIABLE); break; \ - } \ -} while (0) - - - -/* TARGET WORD: - - Byte swap a quantity the size of the targets word */ - -#if (WITH_TARGET_WORD_BITSIZE == 64) -#define H2T_word H2T_8 -#define T2H_word T2H_8 -#define H2BE_word H2BE_8 -#define BE2H_word BE2H_8 -#define H2LE_word H2LE_8 -#define LE2H_word LE2H_8 -#define SWAP_word SWAP_8 -#endif -#if (WITH_TARGET_WORD_BITSIZE == 32) -#define H2T_word H2T_4 -#define T2H_word T2H_4 -#define H2BE_word H2BE_4 -#define BE2H_word BE2H_4 -#define H2LE_word H2LE_4 -#define LE2H_word LE2H_4 -#define SWAP_word SWAP_4 -#endif - - -/* TARGET CELL: - - Byte swap a quantity the size of the targets IEEE 1275 memory cell */ - -#define H2T_cell H2T_4 -#define T2H_cell T2H_4 -#define H2BE_cell H2BE_4 -#define BE2H_cell BE2H_4 -#define H2LE_cell H2LE_4 -#define LE2H_cell LE2H_4 -#define SWAP_cell SWAP_4 - - -#if (SIM_ENDIAN_INLINE & INCLUDE_MODULE) -# include "sim-endian.c" -#endif - -#endif /* _SIM_ENDIAN_H_ */