[1/2] soft-fp: Automatically create KF files from TF ones

Message ID 8e65d35c381c163cad808f089d8a94666aa0c2a6.1445882428.git.tuliom@linux.vnet.ibm.com
State Superseded
Delegated to: Joseph Myers
Headers

Commit Message

Tulio Magno Quites Machado Filho Oct. 26, 2015, 6:05 p.m. UTC
  Use a sed script to automatically generate KF files based on their
respective TF.

2015-10-26  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
            Michael Meissner  <meissner@linux.vnet.ibm.com>

	* soft-fp/Makefile: Generate KF files from TF.
	* soft-fp/.gitignore: Ignore auto-generated files.
---
 soft-fp/.gitignore |  1 +
 soft-fp/Makefile   | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 soft-fp/.gitignore
  

Comments

Joseph Myers Oct. 26, 2015, 6:16 p.m. UTC | #1
On Mon, 26 Oct 2015, Tulio Magno Quites Machado Filho wrote:

> Use a sed script to automatically generate KF files based on their
> respective TF.
> 
> 2015-10-26  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
>             Michael Meissner  <meissner@linux.vnet.ibm.com>
> 
> 	* soft-fp/Makefile: Generate KF files from TF.
> 	* soft-fp/.gitignore: Ignore auto-generated files.

Even in GCC, creating generated files like that in the source directory 
would be wrong.  If you can create them with a sed script, you can do so 
at build time and put the files in the build directory, not the source 
directory (which should be able to be on a read-only filesystem).
  
Michael Meissner Oct. 26, 2015, 6:44 p.m. UTC | #2
On Mon, Oct 26, 2015 at 06:16:38PM +0000, Joseph Myers wrote:
> On Mon, 26 Oct 2015, Tulio Magno Quites Machado Filho wrote:
> 
> > Use a sed script to automatically generate KF files based on their
> > respective TF.
> > 
> > 2015-10-26  Tulio Magno Quites Machado Filho  <tuliom@linux.vnet.ibm.com>
> >             Michael Meissner  <meissner@linux.vnet.ibm.com>
> > 
> > 	* soft-fp/Makefile: Generate KF files from TF.
> > 	* soft-fp/.gitignore: Ignore auto-generated files.
> 
> Even in GCC, creating generated files like that in the source directory 
> would be wrong.  If you can create them with a sed script, you can do so 
> at build time and put the files in the build directory, not the source 
> directory (which should be able to be on a read-only filesystem).

In my original patch for libgcc, it places the created .c files in the build
directory. I tend to think it is better to put it in the build directory.
  

Patch

diff --git a/soft-fp/.gitignore b/soft-fp/.gitignore
new file mode 100644
index 0000000..833e136
--- /dev/null
+++ b/soft-fp/.gitignore
@@ -0,0 +1 @@ 
+*kf*.c
diff --git a/soft-fp/Makefile b/soft-fp/Makefile
index 28f9f0c..e392b9d 100644
--- a/soft-fp/Makefile
+++ b/soft-fp/Makefile
@@ -37,4 +37,18 @@  gcc-quad-routines := negtf2 addtf3 subtf3 multf3 divtf3 eqtf2 \
 	fixunstfdi floatditf extendsftf2 trunctfsf2 extenddftf2 \
 	trunctfdf2 sqrttf2 floatunsitf floatunditf
 
+# Auto-generate KF routines list, removing unused files.
+gcc-kf-routines-auto := $(subst tf,kf,\
+                          $(filter-out sqrttf2,$(gcc-quad-routines)))
+
+generate-routines: $(addsuffix .c,$(gcc-kf-routines-auto))
+
+clean:
+	-rm -f $(addsuffix .c,$(gcc-kf-routines-auto))
+
 include ../Rules
+
+.SECONDEXPANSION:
+$(addsuffix .c,$(gcc-kf-routines-auto)): $$(subst kf,tf,$$@)
+	@sed -e 's/\(__[a-z]\+\)tf\([a-z0-9]*\)/\1kf\2/g' \
+	     -e 's/quad[.]h/quad-float128.h/g' $< > $@