Skip to content

Commit 086d7db

Browse files
committed
sim: ppc: unify igen filter modules
The common igen code was forked from the ppc long ago. The filter module is still pretty similar in API, so we can unfork them with a little bit of effort. The filter.c module is still here because of the unique it_is API. The common igen code doesn't seem to have an equiv API as this only operates on two strings and not an actual filter object, and it's easy enough to leave behind to unfork the rest.
1 parent 7811c75 commit 086d7db

File tree

11 files changed

+67
-190
lines changed

11 files changed

+67
-190
lines changed

sim/Makefile.in

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ or1k_libsim_a_AR = $(AR) $(ARFLAGS)
812812
or1k_libsim_a_OBJECTS = $(am_or1k_libsim_a_OBJECTS) \
813813
$(nodist_or1k_libsim_a_OBJECTS)
814814
ppc_libigen_a_AR = $(AR) $(ARFLAGS)
815-
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_libigen_a_DEPENDENCIES = \
815+
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_libigen_a_DEPENDENCIES = igen/filter.o \
816816
@SIM_ENABLE_ARCH_ppc_TRUE@ igen/filter_host.o igen/lf.o \
817817
@SIM_ENABLE_ARCH_ppc_TRUE@ igen/misc.o
818818
@SIM_ENABLE_ARCH_ppc_TRUE@am_ppc_libigen_a_OBJECTS = \
@@ -821,7 +821,7 @@ ppc_libigen_a_AR = $(AR) $(ARFLAGS)
821821
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/dumpf.$(OBJEXT) \
822822
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-decode.$(OBJEXT) \
823823
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-cache.$(OBJEXT) \
824-
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/filter.$(OBJEXT) \
824+
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/filter-ppc.$(OBJEXT) \
825825
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-insn.$(OBJEXT) \
826826
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/gen-model.$(OBJEXT) \
827827
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/gen-itable.$(OBJEXT) \
@@ -933,7 +933,6 @@ am__EXEEXT_1 = $(IGEN) igen/filter$(EXEEXT) igen/gen$(EXEEXT) \
933933
@SIM_ENABLE_ARCH_m32c_TRUE@am__EXEEXT_4 = m32c/opc2c$(EXEEXT)
934934
@SIM_ENABLE_ARCH_m68hc11_TRUE@am__EXEEXT_5 = m68hc11/gencode$(EXEEXT)
935935
@SIM_ENABLE_ARCH_ppc_TRUE@am__EXEEXT_6 = $(PPC_IGEN) \
936-
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/filter$(EXEEXT) \
937936
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-cache$(EXEEXT) \
938937
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-decode$(EXEEXT) \
939938
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-insn$(EXEEXT)
@@ -1148,10 +1147,6 @@ am_or1k_run_OBJECTS =
11481147
or1k_run_OBJECTS = $(am_or1k_run_OBJECTS)
11491148
@SIM_ENABLE_ARCH_or1k_TRUE@or1k_run_DEPENDENCIES = or1k/nrun.o \
11501149
@SIM_ENABLE_ARCH_or1k_TRUE@ or1k/libsim.a $(am__DEPENDENCIES_4)
1151-
am_ppc_filter_OBJECTS =
1152-
ppc_filter_OBJECTS = $(am_ppc_filter_OBJECTS)
1153-
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_filter_DEPENDENCIES = ppc/filter-main.o \
1154-
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/libigen.a
11551150
@SIM_ENABLE_ARCH_ppc_TRUE@am_ppc_igen_OBJECTS = ppc/igen.$(OBJEXT)
11561151
ppc_igen_OBJECTS = $(am_ppc_igen_OBJECTS)
11571152
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_igen_DEPENDENCIES = ppc/libigen.a
@@ -1311,8 +1306,7 @@ SOURCES = $(aarch64_libsim_a_SOURCES) \
13111306
$(m68hc11_run_SOURCES) $(mcore_run_SOURCES) \
13121307
$(microblaze_run_SOURCES) $(mips_run_SOURCES) \
13131308
$(mn10300_run_SOURCES) $(moxie_run_SOURCES) \
1314-
$(msp430_run_SOURCES) $(or1k_run_SOURCES) \
1315-
$(ppc_filter_SOURCES) $(ppc_igen_SOURCES) \
1309+
$(msp430_run_SOURCES) $(or1k_run_SOURCES) $(ppc_igen_SOURCES) \
13161310
$(ppc_ld_cache_SOURCES) $(ppc_ld_decode_SOURCES) \
13171311
$(ppc_ld_insn_SOURCES) $(ppc_run_SOURCES) $(pru_run_SOURCES) \
13181312
$(riscv_run_SOURCES) $(rl78_run_SOURCES) $(rx_run_SOURCES) \
@@ -2997,7 +2991,7 @@ testsuite_common_CPPFLAGS = \
29972991
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/dumpf.c \
29982992
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-decode.c \
29992993
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-cache.c \
3000-
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/filter.c \
2994+
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/filter-ppc.c \
30012995
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-insn.c \
30022996
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/gen-model.c \
30032997
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/gen-itable.c \
@@ -3007,6 +3001,7 @@ testsuite_common_CPPFLAGS = \
30073001
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/gen-support.c
30083002

30093003
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_libigen_a_LIBADD = \
3004+
@SIM_ENABLE_ARCH_ppc_TRUE@ igen/filter.o \
30103005
@SIM_ENABLE_ARCH_ppc_TRUE@ igen/filter_host.o \
30113006
@SIM_ENABLE_ARCH_ppc_TRUE@ igen/lf.o \
30123007
@SIM_ENABLE_ARCH_ppc_TRUE@ igen/misc.o
@@ -3046,8 +3041,6 @@ testsuite_common_CPPFLAGS = \
30463041
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/stamp-igen ppc/hw.c ppc/hw.h \
30473042
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/stamp-hw ppc/stamp-pk
30483043
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_IGEN_OPCODE_RULES = ppc/@sim_ppc_opcode@
3049-
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_filter_SOURCES =
3050-
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_filter_LDADD = ppc/filter-main.o ppc/libigen.a
30513044
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_ld_cache_SOURCES =
30523045
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_ld_cache_LDADD = ppc/ld-cache-main.o ppc/libigen.a
30533046
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_ld_decode_SOURCES =
@@ -3056,7 +3049,6 @@ testsuite_common_CPPFLAGS = \
30563049
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_ld_insn_LDADD = ppc/ld-insn-main.o ppc/libigen.a
30573050
@SIM_ENABLE_ARCH_ppc_TRUE@ppc_IGEN_TOOLS = \
30583051
@SIM_ENABLE_ARCH_ppc_TRUE@ $(PPC_IGEN) \
3059-
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/filter \
30603052
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-cache \
30613053
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-decode \
30623054
@SIM_ENABLE_ARCH_ppc_TRUE@ ppc/ld-insn
@@ -3756,7 +3748,7 @@ ppc/ld-decode.$(OBJEXT): ppc/$(am__dirstamp) \
37563748
ppc/$(DEPDIR)/$(am__dirstamp)
37573749
ppc/ld-cache.$(OBJEXT): ppc/$(am__dirstamp) \
37583750
ppc/$(DEPDIR)/$(am__dirstamp)
3759-
ppc/filter.$(OBJEXT): ppc/$(am__dirstamp) \
3751+
ppc/filter-ppc.$(OBJEXT): ppc/$(am__dirstamp) \
37603752
ppc/$(DEPDIR)/$(am__dirstamp)
37613753
ppc/ld-insn.$(OBJEXT): ppc/$(am__dirstamp) \
37623754
ppc/$(DEPDIR)/$(am__dirstamp)
@@ -4038,10 +4030,6 @@ msp430/run$(EXEEXT): $(msp430_run_OBJECTS) $(msp430_run_DEPENDENCIES) $(EXTRA_ms
40384030
or1k/run$(EXEEXT): $(or1k_run_OBJECTS) $(or1k_run_DEPENDENCIES) $(EXTRA_or1k_run_DEPENDENCIES) or1k/$(am__dirstamp)
40394031
@rm -f or1k/run$(EXEEXT)
40404032
$(AM_V_CCLD)$(LINK) $(or1k_run_OBJECTS) $(or1k_run_LDADD) $(LIBS)
4041-
4042-
ppc/filter$(EXEEXT): $(ppc_filter_OBJECTS) $(ppc_filter_DEPENDENCIES) $(EXTRA_ppc_filter_DEPENDENCIES) ppc/$(am__dirstamp)
4043-
@rm -f ppc/filter$(EXEEXT)
4044-
$(AM_V_CCLD)$(LINK) $(ppc_filter_OBJECTS) $(ppc_filter_LDADD) $(LIBS)
40454033
ppc/igen.$(OBJEXT): ppc/$(am__dirstamp) ppc/$(DEPDIR)/$(am__dirstamp)
40464034

40474035
@SIM_ENABLE_ARCH_ppc_FALSE@ppc/igen$(EXEEXT): $(ppc_igen_OBJECTS) $(ppc_igen_DEPENDENCIES) $(EXTRA_ppc_igen_DEPENDENCIES) ppc/$(am__dirstamp)
@@ -4216,7 +4204,7 @@ distclean-compile:
42164204
@AMDEP_TRUE@@am__include@ @am__quote@msp430/$(DEPDIR)/modules.Po@am__quote@
42174205
@AMDEP_TRUE@@am__include@ @am__quote@or1k/$(DEPDIR)/modules.Po@am__quote@
42184206
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/dumpf.Po@am__quote@
4219-
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/filter.Po@am__quote@
4207+
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/filter-ppc.Po@am__quote@
42204208
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/gen-icache.Po@am__quote@
42214209
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/gen-idecode.Po@am__quote@
42224210
@AMDEP_TRUE@@am__include@ @am__quote@ppc/$(DEPDIR)/gen-itable.Po@am__quote@

sim/ppc/filter-ppc.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* This file is part of the program psim.
2+
3+
Copyright (C) 1994-1995, Andrew Cagney <[email protected]>
4+
5+
This program is free software; you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation; either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program; if not, see <http://www.gnu.org/licenses/>.
17+
18+
*/
19+
20+
#include <string.h>
21+
22+
#include "filter-ppc.h"
23+
24+
int
25+
it_is(const char *flag,
26+
const char *flags)
27+
{
28+
int flag_len = strlen(flag);
29+
while (*flags != '\0') {
30+
if (!strncmp(flags, flag, flag_len)
31+
&& (flags[flag_len] == ',' || flags[flag_len] == '\0'))
32+
return 1;
33+
while (*flags != ',') {
34+
if (*flags == '\0')
35+
return 0;
36+
flags++;
37+
}
38+
flags++;
39+
}
40+
return 0;
41+
}

sim/ppc/filter.h renamed to sim/ppc/filter-ppc.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,19 @@
1111
but WITHOUT ANY WARRANTY; without even the implied warranty of
1212
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313
GNU General Public License for more details.
14-
14+
1515
You should have received a copy of the GNU General Public License
1616
along with this program; if not, see <http://www.gnu.org/licenses/>.
17-
18-
*/
19-
20-
21-
typedef struct _filter filter;
22-
2317
24-
/* append the filter onto the end of the list */
25-
26-
extern filter *new_filter
27-
(const char *filt,
28-
filter *filters);
29-
30-
31-
/* returns true if the flags are non empty and some are missing from the filter list */
18+
*/
3219

33-
extern int is_filtered_out
34-
(const char *flags,
35-
filter *filters);
20+
#ifndef PPC_FILTER_H
21+
#define PPC_FILTER_H
3622

3723
/* true if the flag is in the list */
3824

3925
extern int it_is
4026
(const char *flag,
4127
const char *flags);
4228

29+
#endif /* PPC_FILTER_H */

sim/ppc/filter.c

Lines changed: 0 additions & 141 deletions
This file was deleted.

sim/ppc/gen-icache.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "table.h"
2626

2727
#include "filter.h"
28+
#include "filter-ppc.h"
2829

2930
#include "ld-decode.h"
3031
#include "ld-cache.h"

sim/ppc/gen-idecode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "table.h"
2424

2525
#include "filter.h"
26+
#include "filter-ppc.h"
2627

2728
#include "ld-decode.h"
2829
#include "ld-cache.h"

sim/ppc/gen-semantics.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "lf-ppc.h"
2525
#include "table.h"
2626
#include "filter.h"
27+
#include "filter-ppc.h"
2728

2829
#include "ld-decode.h"
2930
#include "ld-cache.h"

sim/ppc/gen-support.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "lf-ppc.h"
2323
#include "table.h"
2424
#include "filter.h"
25+
#include "filter-ppc.h"
2526

2627
#include "ld-decode.h"
2728
#include "ld-cache.h"

sim/ppc/igen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ main(int argc,
480480
ASSERT(hi_bit_nr == insn_bit_size-1 || hi_bit_nr == 0);
481481
break;
482482
case 'F':
483-
filters = new_filter(optarg, filters);
483+
filter_parse(&filters, optarg);
484484
break;
485485
case 'J':
486486
code &= ~generate_calls;

0 commit comments

Comments
 (0)