aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2024-01-01 18:14:13 -0500
committerMike Frysinger <vapier@gentoo.org>2024-01-01 18:16:38 -0500
commit1b89e2b72052e60fc7a6c0301a67070accc714e1 (patch)
tree74599de2929676a7a8d1260d0b496f79fd0b7234 /sim
parent9ddac092a831d9eb4a53959764c2d13b12964a0c (diff)
downloadgdb-1b89e2b72052e60fc7a6c0301a67070accc714e1.zip
gdb-1b89e2b72052e60fc7a6c0301a67070accc714e1.tar.gz
gdb-1b89e2b72052e60fc7a6c0301a67070accc714e1.tar.bz2
sim: ppc: merge misc igen APIs
The common igen code provides the same misc APIs as the ppc version, so delete the ppc code and pull in the common one. There is one minor difference: the ppc code has a unique dumpf function. The common code switched to lf_printf for the same functionality, but since that requires changes throughout the igen codebase, delay that cleanup for now so we can merge the rest.
Diffstat (limited to 'sim')
-rw-r--r--sim/Makefile.in15
-rw-r--r--sim/ppc/dumpf.c40
-rw-r--r--sim/ppc/dumpf.h25
-rw-r--r--sim/ppc/ld-cache.c1
-rw-r--r--sim/ppc/ld-decode.c1
-rw-r--r--sim/ppc/ld-insn.c1
-rw-r--r--sim/ppc/local.mk6
-rw-r--r--sim/ppc/misc.c204
-rw-r--r--sim/ppc/misc.h80
-rw-r--r--sim/ppc/table.c1
10 files changed, 82 insertions, 292 deletions
diff --git a/sim/Makefile.in b/sim/Makefile.in
index cc00ca0..cc6ee92 100644
--- a/sim/Makefile.in
+++ b/sim/Makefile.in
@@ -806,10 +806,10 @@ or1k_libsim_a_OBJECTS = $(am_or1k_libsim_a_OBJECTS) \
$(nodist_or1k_libsim_a_OBJECTS)
ppc_libigen_a_AR = $(AR) $(ARFLAGS)
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_libigen_a_DEPENDENCIES = \
-@SIM_ENABLE_ARCH_ppc_TRUE@ igen/filter_host.o
+@SIM_ENABLE_ARCH_ppc_TRUE@ igen/filter_host.o igen/misc.o
@SIM_ENABLE_ARCH_ppc_TRUE@am_ppc_libigen_a_OBJECTS = \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/table.$(OBJEXT) ppc/lf.$(OBJEXT) \
-@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/misc.$(OBJEXT) \
+@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/dumpf.$(OBJEXT) \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-decode.$(OBJEXT) \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-cache.$(OBJEXT) \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/filter.$(OBJEXT) \
@@ -2908,7 +2908,7 @@ testsuite_common_CPPFLAGS = \
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_libigen_a_SOURCES = \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/table.c \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/lf.c \
-@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/misc.c \
+@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/dumpf.c \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-decode.c \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-cache.c \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/filter.c \
@@ -2920,7 +2920,10 @@ testsuite_common_CPPFLAGS = \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/gen-idecode.c \
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/gen-support.c
-@SIM_ENABLE_ARCH_ppc_TRUE@ppc_libigen_a_LIBADD = igen/filter_host.o
+@SIM_ENABLE_ARCH_ppc_TRUE@ppc_libigen_a_LIBADD = \
+@SIM_ENABLE_ARCH_ppc_TRUE@ igen/filter_host.o \
+@SIM_ENABLE_ARCH_ppc_TRUE@ igen/misc.o
+
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_igen_SOURCES = ppc/igen.c
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_igen_LDADD = ppc/libigen.a
@SIM_ENABLE_ARCH_ppc_TRUE@PPC_IGEN = ppc/igen$(EXEEXT)
@@ -3627,7 +3630,7 @@ ppc/$(DEPDIR)/$(am__dirstamp):
@: > ppc/$(DEPDIR)/$(am__dirstamp)
ppc/table.$(OBJEXT): ppc/$(am__dirstamp) ppc/$(DEPDIR)/$(am__dirstamp)
ppc/lf.$(OBJEXT): ppc/$(am__dirstamp) ppc/$(DEPDIR)/$(am__dirstamp)
-ppc/misc.$(OBJEXT): ppc/$(am__dirstamp) ppc/$(DEPDIR)/$(am__dirstamp)
+ppc/dumpf.$(OBJEXT): ppc/$(am__dirstamp) ppc/$(DEPDIR)/$(am__dirstamp)
ppc/ld-decode.$(OBJEXT): ppc/$(am__dirstamp) \
ppc/$(DEPDIR)/$(am__dirstamp)
ppc/ld-cache.$(OBJEXT): ppc/$(am__dirstamp) \
@@ -4085,6 +4088,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@moxie/$(DEPDIR)/modules.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@msp430/$(DEPDIR)/modules.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@or1k/$(DEPDIR)/modules.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/dumpf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/filter.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/gen-icache.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/gen-idecode.Po@am__quote@
@@ -4097,7 +4101,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/ld-decode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/ld-insn.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/lf.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/misc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/table.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@pru/$(DEPDIR)/modules.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@riscv/$(DEPDIR)/modules.Po@am__quote@
diff --git a/sim/ppc/dumpf.c b/sim/ppc/dumpf.c
new file mode 100644
index 0000000..6aaae16
--- /dev/null
+++ b/sim/ppc/dumpf.c
@@ -0,0 +1,40 @@
+/* This file is part of the program psim.
+
+ Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
+
+ 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 <http://www.gnu.org/licenses/>.
+
+ */
+
+/* TODO: Convert callers to lf_printf like common igen/. */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+#include "dumpf.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+void
+dumpf (int indent, const char *msg, ...)
+{
+ va_list ap;
+ for (; indent > 0; indent--)
+ printf(" ");
+ va_start(ap, msg);
+ vprintf(msg, ap);
+ va_end(ap);
+}
diff --git a/sim/ppc/dumpf.h b/sim/ppc/dumpf.h
new file mode 100644
index 0000000..9137463
--- /dev/null
+++ b/sim/ppc/dumpf.h
@@ -0,0 +1,25 @@
+/* This file is part of the program psim.
+
+ Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
+
+ 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 <http://www.gnu.org/licenses/>.
+
+ */
+
+/* TODO: Convert callers to lf_printf like common igen/. */
+
+#include "ansidecl.h"
+
+extern void dumpf (int indent, const char *msg, ...)
+ ATTRIBUTE_PRINTF (2, 3);
diff --git a/sim/ppc/ld-cache.c b/sim/ppc/ld-cache.c
index a5d101d..67e60eb 100644
--- a/sim/ppc/ld-cache.c
+++ b/sim/ppc/ld-cache.c
@@ -22,6 +22,7 @@
#include "lf.h"
#include "table.h"
#include "ld-cache.h"
+#include "dumpf.h"
enum {
diff --git a/sim/ppc/ld-decode.c b/sim/ppc/ld-decode.c
index a631645..09ed4b1 100644
--- a/sim/ppc/ld-decode.c
+++ b/sim/ppc/ld-decode.c
@@ -23,6 +23,7 @@
#include "lf.h"
#include "table.h"
#include "ld-decode.h"
+#include "dumpf.h"
enum {
diff --git a/sim/ppc/ld-insn.c b/sim/ppc/ld-insn.c
index c11b449..6b54026 100644
--- a/sim/ppc/ld-insn.c
+++ b/sim/ppc/ld-insn.c
@@ -25,6 +25,7 @@
#include "ld-decode.h"
#include "ld-cache.h"
#include "ld-insn.h"
+#include "dumpf.h"
#include "igen.h"
diff --git a/sim/ppc/local.mk b/sim/ppc/local.mk
index c72668c..8bcc7e7 100644
--- a/sim/ppc/local.mk
+++ b/sim/ppc/local.mk
@@ -47,7 +47,7 @@ EXTRA_LIBRARIES += %D%/libigen.a
%C%_libigen_a_SOURCES = \
%D%/table.c \
%D%/lf.c \
- %D%/misc.c \
+ %D%/dumpf.c \
%D%/ld-decode.c \
%D%/ld-cache.c \
%D%/filter.c \
@@ -58,7 +58,9 @@ EXTRA_LIBRARIES += %D%/libigen.a
%D%/gen-semantics.c \
%D%/gen-idecode.c \
%D%/gen-support.c
-%C%_libigen_a_LIBADD = igen/filter_host.o
+%C%_libigen_a_LIBADD = \
+ igen/filter_host.o \
+ igen/misc.o
%C%_igen_SOURCES = %D%/igen.c
%C%_igen_LDADD = %D%/libigen.a
diff --git a/sim/ppc/misc.c b/sim/ppc/misc.c
deleted file mode 100644
index 9499101..0000000
--- a/sim/ppc/misc.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/* This file is part of the program psim.
-
- Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au>
-
- 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 <http://www.gnu.org/licenses/>.
-
- */
-
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <ctype.h>
-
-#include "misc.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-void
-error (const void *line, const char *msg, ...)
-{
- va_list ap;
- va_start(ap, msg);
- vprintf(msg, ap);
- va_end(ap);
- exit (1);
-}
-
-void *
-zalloc(long size)
-{
- void *memory = malloc(size);
- if (memory == NULL)
- ERROR("zalloc failed\n");
- memset(memory, 0, size);
- return memory;
-}
-
-void
-dumpf (int indent, const char *msg, ...)
-{
- va_list ap;
- for (; indent > 0; indent--)
- printf(" ");
- va_start(ap, msg);
- vprintf(msg, ap);
- va_end(ap);
-}
-
-
-unsigned
-a2i(const char *a)
-{
- int neg = 0;
- int base = 10;
- unsigned num = 0;
- int looping;
-
- while (isspace (*a))
- a++;
-
- if (*a == '-') {
- neg = 1;
- a++;
- }
-
- if (*a == '0') {
- if (a[1] == 'x' || a[1] == 'X') {
- a += 2;
- base = 16;
- }
- else
- base = 8;
- }
-
- looping = 1;
- while (looping) {
- int ch = *a++;
-
- switch (base) {
- default:
- looping = 0;
- break;
-
- case 10:
- if (ch >= '0' && ch <= '9') {
- num = (num * 10) + (ch - '0');
- } else {
- looping = 0;
- }
- break;
-
- case 8:
- if (ch >= '0' && ch <= '7') {
- num = (num * 8) + (ch - '0');
- } else {
- looping = 0;
- }
- break;
-
- case 16:
- if (ch >= '0' && ch <= '9') {
- num = (num * 16) + (ch - '0');
- } else if (ch >= 'a' && ch <= 'f') {
- num = (num * 16) + (ch - 'a' + 10);
- } else if (ch >= 'A' && ch <= 'F') {
- num = (num * 16) + (ch - 'A' + 10);
- } else {
- looping = 0;
- }
- break;
- }
- }
-
- if (neg)
- num = - num;
-
- return num;
-}
-
-unsigned
-target_a2i(int ms_bit_nr,
- const char *a)
-{
- if (ms_bit_nr)
- return (ms_bit_nr - a2i(a));
- else
- return a2i(a);
-}
-
-unsigned
-i2target(int ms_bit_nr,
- unsigned bit)
-{
- if (ms_bit_nr)
- return ms_bit_nr - bit;
- else
- return bit;
-}
-
-
-int
-name2i(const char *names,
- const name_map *map)
-{
- const name_map *curr;
- const char *name = names;
- while (*name != '\0') {
- /* find our name */
- const char *end = strchr(name, ',');
- const char *next;
- int len;
- if (end == NULL) {
- end = strchr(name, '\0');
- next = end;
- }
- else {
- next = end + 1;
- }
- len = end - name;
- /* look it up */
- curr = map;
- while (curr->name != NULL) {
- if (strncmp(curr->name, name, len) == 0
- && strlen(curr->name) == len)
- return curr->i;
- curr++;
- }
- name = next;
- }
- /* nothing found, possibly return a default */
- curr = map;
- while (curr->name != NULL)
- curr++;
- if (curr->i >= 0)
- return curr->i;
- else
- ERROR("%s contains no valid names\n", names);
- return 0;
-}
-
-const char *
-i2name(const int i,
- const name_map *map)
-{
- while (map->name != NULL) {
- if (map->i == i)
- return map->name;
- map++;
- }
- ERROR("map lookup failed for %d\n", i);
- return NULL;
-}
diff --git a/sim/ppc/misc.h b/sim/ppc/misc.h
deleted file mode 100644
index 243d5c9..0000000
--- a/sim/ppc/misc.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* This file is part of the program psim.
-
- Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
-
- 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 <http://www.gnu.org/licenses/>.
-
- */
-
-
-/* Frustrating header junk */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "ansidecl.h"
-#include "filter_host.h"
-
-extern void error (const void *line, const char *msg, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
-
-#define ERROR(EXPRESSION, args...) \
- error (NULL, EXPRESSION, ## args)
-
-#define ASSERT(EXPRESSION) \
-do { \
- if (!(EXPRESSION)) { \
- error("%s:%d: assertion failed - %s\n", \
- filter_filename (__FILE__), __LINE__, #EXPRESSION); \
- } \
-} while (0)
-
-#define ZALLOC(TYPE) (TYPE*)zalloc(sizeof(TYPE))
-#define NZALLOC(TYPE,N) ((TYPE*) zalloc (sizeof(TYPE) * (N)))
-
-extern void *zalloc
-(long size);
-
-extern void dumpf (int indent, const char *msg, ...)
- ATTRIBUTE_PRINTF (2, 3);
-
-extern unsigned target_a2i
-(int ms_bit_nr,
- const char *a);
-
-extern unsigned i2target
-(int ms_bit_nr,
- unsigned bit);
-
-extern unsigned a2i
-(const char *a);
-
-/* Try looking for name in the map table (returning the corresponding
- integer value). If that fails, try converting the name into an
- integer */
-
-typedef struct _name_map {
- const char *name;
- int i;
-} name_map;
-
-extern int name2i
-(const char *name,
- const name_map *map);
-
-extern const char *i2name
-(const int i,
- const name_map *map);
diff --git a/sim/ppc/table.c b/sim/ppc/table.c
index 0c5b6fc..5cac56e 100644
--- a/sim/ppc/table.c
+++ b/sim/ppc/table.c
@@ -27,6 +27,7 @@
#include "misc.h"
#include "lf.h"
#include "table.h"
+#include "dumpf.h"
#include <unistd.h>
#include <stdlib.h>