public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] sim: hoist gencode & opc2c build rules up to common builds
@ 2021-11-03  3:37 Mike Frysinger
  2021-11-03  3:37 ` [PATCH 2/3] sim: hoist mn10300 & v850 igen " Mike Frysinger
  2021-11-03  3:37 ` [PATCH 3/3] sim: hoist cgen mloop " Mike Frysinger
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Frysinger @ 2021-11-03  3:37 UTC (permalink / raw)
  To: gdb-patches

These rules don't depend on the target compiler settings, so hoist
the build logic up to the common builds for better parallelization.
---
 sim/Makefile.am         |  16 ++
 sim/Makefile.in         | 387 ++++++++++++++++++++++++++++++++++++++--
 sim/cr16/Makefile.in    |  22 ---
 sim/cr16/local.mk       |  47 +++++
 sim/d10v/Makefile.in    |  19 --
 sim/d10v/local.mk       |  47 +++++
 sim/m32c/Makefile.in    |  23 ---
 sim/m32c/local.mk       |  53 ++++++
 sim/m68hc11/Makefile.in |  17 --
 sim/m68hc11/local.mk    |  44 +++++
 sim/sh/Makefile.in      |  21 ---
 sim/sh/local.mk         |  48 +++++
 12 files changed, 625 insertions(+), 119 deletions(-)
 create mode 100644 sim/cr16/local.mk
 create mode 100644 sim/d10v/local.mk
 create mode 100644 sim/m32c/local.mk
 create mode 100644 sim/m68hc11/local.mk
 create mode 100644 sim/sh/local.mk

diff --git a/sim/Makefile.am b/sim/Makefile.am
index 8f53aa80da75..6fa3b62de224 100644
--- a/sim/Makefile.am
+++ b/sim/Makefile.am
@@ -67,4 +67,20 @@ include igen/local.mk
 endif
 include testsuite/local.mk
 
+if SIM_ENABLE_ARCH_cr16
+include cr16/local.mk
+endif
+if SIM_ENABLE_ARCH_d10v
+include d10v/local.mk
+endif
+if SIM_ENABLE_ARCH_m32c
+include m32c/local.mk
+endif
+if SIM_ENABLE_ARCH_m68hc11
+include m68hc11/local.mk
+endif
+if SIM_ENABLE_ARCH_sh
+include sh/local.mk
+endif
+
 all-recursive: $(SIM_ALL_RECURSIVE_DEPS)
diff --git a/sim/cr16/Makefile.in b/sim/cr16/Makefile.in
index 99b2becf792b..4d7345a6b516 100644
--- a/sim/cr16/Makefile.in
+++ b/sim/cr16/Makefile.in
@@ -23,32 +23,10 @@ SIM_OBJS = \
 	interp.o \
 	table.o \
 	simops.o
-SIM_EXTRA_CLEAN = clean-extra
 
 SIM_EXTRA_DEPS = simops.h
 
-INCLUDE = cr16_sim.h $(srcroot)/include/sim/callback.h targ-vals.h \
-	$(srcroot)/include/gdb/sim-cr16.h
-
 # This selects the cr16 newlib/libgloss syscall definitions.
 NL_TARGET = -DNL_TARGET_cr16
 
 ## COMMON_POST_CONFIG_FRAG
-
-simops.h: gencode
-	$(ECHO_GEN) ./gencode -h >$@
-
-table.c: gencode simops.h
-	$(ECHO_GEN) ./gencode >$@
-
-gencode.o: gencode.c $(INCLUDE)
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) $(WARN_CFLAGS) -c $(srcdir)/gencode.c
-
-cr16-opc.o: $(srcdir)/../../opcodes/cr16-opc.c
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) $(WARN_CFLAGS) -c $(srcdir)/../../opcodes/cr16-opc.c
-
-gencode: gencode.o cr16-opc.o
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) gencode.o cr16-opc.o
-
-clean-extra:
-	rm -f table.c simops.h gencode
diff --git a/sim/cr16/local.mk b/sim/cr16/local.mk
new file mode 100644
index 000000000000..77866c2b2a31
--- /dev/null
+++ b/sim/cr16/local.mk
@@ -0,0 +1,47 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 2008-2021 Free Software Foundation, Inc.
+# Contributed by M Ranga Swami Reddy <MR.Swami.Reddy@nsc.com>
+#
+# 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/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/gencode$(EXEEXT) \
+	%D%/simops.h \
+	%D%/table.c
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%C%_gencode_SOURCES = %D%/gencode.c
+%C%_gencode_LDADD = %D%/cr16-opc.o
+
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+%D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
+	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_gencode_OBJECTS) $(%C%_gencode_LDADD)
+
+# gencode is a build-time only tool.  Override the default rules for it.
+%D%/gencode.o: %D%/gencode.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+%D%/cr16-opc.o: ../opcodes/cr16-opc.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+
+%D%/simops.h: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -h >$@
+
+%D%/table.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< >$@
+
+EXTRA_PROGRAMS += %D%/gencode
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/d10v/Makefile.in b/sim/d10v/Makefile.in
index 4f8759b3deac..51fb9eb72d1a 100644
--- a/sim/d10v/Makefile.in
+++ b/sim/d10v/Makefile.in
@@ -24,7 +24,6 @@ SIM_OBJS = \
 	table.o \
 	simops.o \
 	endian.o
-SIM_EXTRA_CLEAN = clean-extra
 
 SIM_EXTRA_DEPS = simops.h
 
@@ -35,21 +34,3 @@ INCLUDE = d10v_sim.h $(srcroot)/include/sim/callback.h targ-vals.h endian.c \
 NL_TARGET = -DNL_TARGET_d10v
 
 ## COMMON_POST_CONFIG_FRAG
-
-simops.h: gencode
-	$(ECHO_GEN) ./gencode -h >$@
-
-table.c: gencode simops.h
-	$(ECHO_GEN) ./gencode >$@
-
-gencode.o: gencode.c $(INCLUDE)
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) $(WARN_CFLAGS) -c $(srcdir)/gencode.c
-
-d10v-opc.o: $(srcdir)/../../opcodes/d10v-opc.c
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) $(WARN_CFLAGS) -c $(srcdir)/../../opcodes/d10v-opc.c
-
-gencode: gencode.o d10v-opc.o
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) gencode.o d10v-opc.o
-
-clean-extra:
-	rm -f table.c simops.h gencode
diff --git a/sim/d10v/local.mk b/sim/d10v/local.mk
new file mode 100644
index 000000000000..1f19eab8ded1
--- /dev/null
+++ b/sim/d10v/local.mk
@@ -0,0 +1,47 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1996-2021 Free Software Foundation, Inc.
+# Written by Cygnus Support.
+#
+# 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/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/gencode$(EXEEXT) \
+	%D%/simops.h \
+	%D%/table.c
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%C%_gencode_SOURCES = %D%/gencode.c
+%C%_gencode_LDADD = %D%/d10v-opc.o
+
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+%D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
+	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_gencode_OBJECTS) $(%C%_gencode_LDADD)
+
+# gencode is a build-time only tool.  Override the default rules for it.
+%D%/gencode.o: %D%/gencode.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+%D%/d10v-opc.o: ../opcodes/d10v-opc.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+
+%D%/simops.h: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -h >$@
+
+%D%/table.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< >$@
+
+EXTRA_PROGRAMS += %D%/gencode
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/m32c/Makefile.in b/sim/m32c/Makefile.in
index cfdadd041048..c5b1495c7059 100644
--- a/sim/m32c/Makefile.in
+++ b/sim/m32c/Makefile.in
@@ -41,26 +41,3 @@ SIM_OBJS = \
 	$(ENDLIST)
 
 ## COMMON_POST_CONFIG_FRAG
-
-arch = m32c
-
-# opc2c leaks memory, and therefore makes AddressSanitizer unhappy.  Disable
-# leak detection while running it.
-OPC2C = ASAN_OPTIONS=detect_leaks=0 ./opc2c
-
-r8c.c : r8c.opc opc2c
-	$(ECHO_GEN) $(OPC2C) -l r8c.out $(srcdir)/r8c.opc > r8c.c.tmp
-	$(SILENCE) mv r8c.c.tmp r8c.c
-
-m32c.c : m32c.opc opc2c
-	$(ECHO_GEN) $(OPC2C) -l m32c.out $(srcdir)/m32c.opc > m32c.c.tmp
-	$(SILENCE) mv m32c.c.tmp m32c.c
-
-opc2c : opc2c.o
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) $^
-
-encodings:
-	grep '/\* [01]' $(srcdir)/r8c.opc | sort
-
-opc2c.o : opc2c.c
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/opc2c.c
diff --git a/sim/m32c/local.mk b/sim/m32c/local.mk
new file mode 100644
index 000000000000..f1e86e6304b0
--- /dev/null
+++ b/sim/m32c/local.mk
@@ -0,0 +1,53 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 2005-2021 Free Software Foundation, Inc.
+# Contributed by Red Hat, Inc.
+#
+# 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/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/opc2c$(EXEEXT) \
+	%D%/m32c.c \
+	%D%/r8c.c
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%C%_opc2c_SOURCES = %D%/opc2c.c
+
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+%D%/opc2c$(EXEEXT): $(%C%_opc2c_OBJECTS) $(%C%_opc2c_DEPENDENCIES) %D%/$(am__dirstamp)
+	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_opc2c_OBJECTS) $(%C%_opc2c_LDADD)
+
+# opc2c is a build-time only tool.  Override the default rules for it.
+%D%/opc2c.o: %D%/opc2c.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+
+# opc2c leaks memory, and therefore makes AddressSanitizer unhappy.  Disable
+# leak detection while running it.
+%C%_OPC2C_RUN = ASAN_OPTIONS=detect_leaks=0 %D%/opc2c$(EXEEXT)
+
+%D%/m32c.c: %D%/m32c.opc %D%/opc2c$(EXEEXT)
+	$(AM_V_GEN)$(%C%_OPC2C_RUN) -l $@.log $< > $@.tmp
+	$(AM_V_at)mv $@.tmp $@
+
+%D%/r8c.c: %D%/r8c.opc %D%/opc2c$(EXEEXT)
+	$(AM_V_GEN)$(%C%_OPC2C_RUN) -l $@.log $< > $@.tmp
+	$(AM_V_at)mv $@.tmp $@
+
+EXTRA_PROGRAMS += %D%/opc2c
+MOSTLYCLEANFILES += \
+	$(%C%_BUILD_OUTPUTS) \
+	%D%/m32c.c.log \
+	%D%/r8c.c.log
diff --git a/sim/m68hc11/Makefile.in b/sim/m68hc11/Makefile.in
index f906a7c2bb67..0b2c4f1ea6b2 100644
--- a/sim/m68hc11/Makefile.in
+++ b/sim/m68hc11/Makefile.in
@@ -36,22 +36,5 @@ SIM_EXTRA_CFLAGS = -DWITH_TARGET_WORD_BITSIZE=32 \
 		   -DWITH_TARGET_CELL_BITSIZE=32 \
 		   -DWITH_TARGET_ADDRESS_BITSIZE=32 \
 		   -DWITH_TARGET_WORD_MSB=31
-SIM_EXTRA_CLEAN = clean-extra
-
 
 ## COMMON_POST_CONFIG_FRAG
-
-m68hc11int.c: gencode
-	$(ECHO_GEN) ./gencode -m6811 > $@
-
-m68hc12int.c: gencode
-	$(ECHO_GEN) ./gencode -m6812 > $@
-
-gencode.o: gencode.c
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) -c $< -o $@
-
-gencode: gencode.o
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) $^
-
-clean-extra:
-	rm -f gencode m68hc11int.c
diff --git a/sim/m68hc11/local.mk b/sim/m68hc11/local.mk
new file mode 100644
index 000000000000..7596e1466080
--- /dev/null
+++ b/sim/m68hc11/local.mk
@@ -0,0 +1,44 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
+# Written by Cygnus Support.
+#
+# 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/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/gencode$(EXEEXT) \
+	%D%/m68hc11int.c \
+	%D%/m68hc12int.c
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%C%_gencode_SOURCES = %D%/gencode.c
+
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+%D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
+	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_gencode_OBJECTS) $(%C%_gencode_LDADD)
+
+# gencode is a build-time only tool.  Override the default rules for it.
+%D%/gencode.o: %D%/gencode.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+
+%D%/m68hc11int.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -m6811 >$@
+
+%D%/m68hc12int.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -m6812 >$@
+
+EXTRA_PROGRAMS += %D%/gencode
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
diff --git a/sim/sh/Makefile.in b/sim/sh/Makefile.in
index e79efd1ff5e2..4c5b9ad9a0af 100644
--- a/sim/sh/Makefile.in
+++ b/sim/sh/Makefile.in
@@ -25,30 +25,9 @@ SIM_OBJS = \
 	$(SIM_NEW_COMMON_OBJS) \
 	table.o
 SIM_EXTRA_LIBS = -lm
-SIM_EXTRA_CLEAN = sh-clean
 SIM_EXTRA_DEPS = table.c code.c ppi.c
 
 # Some modules don't build cleanly yet.
 interp.o: SIM_WERROR_CFLAGS =
 
 ## COMMON_POST_CONFIG_FRAG
-
-code.c: gencode
-	$(ECHO_GEN) ./gencode -x >code.c
-#	indent code.c
-
-table.c: gencode
-	$(ECHO_GEN) ./gencode -s >table.c
-#	indent table.c
-
-ppi.c: gencode
-	$(ECHO_GEN) ./gencode -p >ppi.c
-
-gencode.o: gencode.c
-	$(ECHO_CC) $(COMPILE_FOR_BUILD) -c $< -o $@
-
-gencode: gencode.o
-	$(ECHO_CCLD) $(LINK_FOR_BUILD) $^
-
-sh-clean:
-	rm -f gencode code.c table.c
diff --git a/sim/sh/local.mk b/sim/sh/local.mk
new file mode 100644
index 000000000000..583899c33944
--- /dev/null
+++ b/sim/sh/local.mk
@@ -0,0 +1,48 @@
+# See sim/Makefile.am
+#
+# Copyright (C) 1990-2021 Free Software Foundation, Inc.
+# Written by Cygnus Support.
+#
+# 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/>.
+
+%C%_BUILD_OUTPUTS = \
+	%D%/gencode$(EXEEXT) \
+	%D%/code.c \
+	%D%/ppi.c \
+	%D%/table.c
+
+# This makes sure build tools are available before building the arch-subdirs.
+SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS)
+
+%C%_gencode_SOURCES = %D%/gencode.c
+
+# These rules are copied from automake, but tweaked to use FOR_BUILD variables.
+%D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
+	$(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_gencode_OBJECTS) $(%C%_gencode_LDADD)
+
+# gencode is a build-time only tool.  Override the default rules for it.
+%D%/gencode.o: %D%/gencode.c
+	$(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@
+
+%D%/code.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -x >$@
+
+%D%/ppi.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -p >$@
+
+%D%/table.c: %D%/gencode$(EXEEXT)
+	$(AM_V_GEN)$< -s >$@
+
+EXTRA_PROGRAMS += %D%/gencode
+MOSTLYCLEANFILES += $(%C%_BUILD_OUTPUTS)
-- 
2.33.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-03  3:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-03  3:37 [PATCH 1/3] sim: hoist gencode & opc2c build rules up to common builds Mike Frysinger
2021-11-03  3:37 ` [PATCH 2/3] sim: hoist mn10300 & v850 igen " Mike Frysinger
2021-11-03  3:37 ` [PATCH 3/3] sim: hoist cgen mloop " Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).