Skip to contentSkip to conversation

tcg: Rename tcg-target.c to tcg-target.inc.c

PATCH In review Peter Maydell 3 participants 9 messages Feb 23, 2016

lore
Share & tools
lore
#0 lore raw

cover tcg: Rename tcg-target.c to tcg-target.inc.c

This patchset renames the arch-specific tcg-target.c files to tcg-target.inc.c, to better indicate the fact that they are not standalone source files but are just #included from another .c file.

Having done that we can teach clean-includes about the .inc.c convention, and then undo some unnecessary #includes that it added earlier.

thanks
-- PMM

Peter Maydell (3):
tcg: Rename tcg-target.c to tcg-target.inc.c scripts/clean-includes: Ignore .inc.c files
tcg: Remove unnecessary osdep.h includes from tcg-target.inc.c

 qemu-tech.texi                                 | 2 +-
 scripts/clean-includes                         | 5 +++++
 tcg/README                                     | 5 +++--
 tcg/aarch64/{tcg-target.c => tcg-target.inc.c} | 1 -
 tcg/arm/{tcg-target.c => tcg-target.inc.c}     | 1 -
 tcg/i386/{tcg-target.c => tcg-target.inc.c}    | 1 -
 tcg/ia64/{tcg-target.c => tcg-target.inc.c}    | 0
 tcg/mips/{tcg-target.c => tcg-target.inc.c}    | 1 -
 tcg/ppc/{tcg-target.c => tcg-target.inc.c}     | 1 -
 tcg/s390/{tcg-target.c => tcg-target.inc.c}    | 1 -
 tcg/sparc/{tcg-target.c => tcg-target.inc.c}   | 1 -
 tcg/tcg.c                                      | 7 ++++---
 tcg/tcg.h                                      | 2 +-
 tcg/tci/README                                 | 4 ++--
 tcg/tci/{tcg-target.c => tcg-target.inc.c}     | 1 -
 15 files changed, 16 insertions(+), 17 deletions(-)
 rename tcg/aarch64/{tcg-target.c => tcg-target.inc.c} (99%)
 rename tcg/arm/{tcg-target.c => tcg-target.inc.c} (99%)
 rename tcg/i386/{tcg-target.c => tcg-target.inc.c} (99%)
 rename tcg/ia64/{tcg-target.c => tcg-target.inc.c} (100%)
 rename tcg/mips/{tcg-target.c => tcg-target.inc.c} (99%)
 rename tcg/ppc/{tcg-target.c => tcg-target.inc.c} (99%)
 rename tcg/s390/{tcg-target.c => tcg-target.inc.c} (99%)
 rename tcg/sparc/{tcg-target.c => tcg-target.inc.c} (99%)
 rename tcg/tci/{tcg-target.c => tcg-target.inc.c} (99%)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 tcg: Rename tcg-target.c to tcg-target.inc.c

Rename the per-architecture tcg-target.c files to tcg-target.inc.c. This makes it clearer that they are not intended to be standalone C files, but are instead #included into another source file.

---
 qemu-tech.texi                                 | 2 +-
 tcg/README                                     | 5 +++--
 tcg/aarch64/{tcg-target.c => tcg-target.inc.c} | 0
 tcg/arm/{tcg-target.c => tcg-target.inc.c}     | 0
 tcg/i386/{tcg-target.c => tcg-target.inc.c}    | 0
 tcg/ia64/{tcg-target.c => tcg-target.inc.c}    | 0
 tcg/mips/{tcg-target.c => tcg-target.inc.c}    | 0
 tcg/ppc/{tcg-target.c => tcg-target.inc.c}     | 0
 tcg/s390/{tcg-target.c => tcg-target.inc.c}    | 0
 tcg/sparc/{tcg-target.c => tcg-target.inc.c}   | 0
 tcg/tcg.c                                      | 7 ++++---
 tcg/tcg.h                                      | 2 +-
 tcg/tci/README                                 | 4 ++--
 tcg/tci/{tcg-target.c => tcg-target.inc.c}     | 0
 14 files changed, 11 insertions(+), 9 deletions(-)
 rename tcg/aarch64/{tcg-target.c => tcg-target.inc.c} (100%)
 rename tcg/arm/{tcg-target.c => tcg-target.inc.c} (100%)
 rename tcg/i386/{tcg-target.c => tcg-target.inc.c} (100%)
 rename tcg/ia64/{tcg-target.c => tcg-target.inc.c} (100%)
 rename tcg/mips/{tcg-target.c => tcg-target.inc.c} (100%)
 rename tcg/ppc/{tcg-target.c => tcg-target.inc.c} (100%)
 rename tcg/s390/{tcg-target.c => tcg-target.inc.c} (100%)
 rename tcg/sparc/{tcg-target.c => tcg-target.inc.c} (100%)
 rename tcg/tci/{tcg-target.c => tcg-target.inc.c} (100%)
qemu-tech.texi +1 -1
index 022017d..bdb2285 100644
@@ -385,7 +385,7 @@ ops (see @code{target-i386/translate.c}). Some optimizations can be
 performed at this stage, including liveness analysis and trivial
 constant expression evaluation. TCG ops are then implemented in the
 host CPU back end, also known as TCG target (see
-@code{tcg/i386/tcg-target.c}). For more information, please take a
+@code{tcg/i386/tcg-target.inc.c}). For more information, please take a
 look at @code{tcg/README}.
 
 @node Condition code optimisations
tcg/README +3 -2
index 34c0775..f4a8ac1 100644
@@ -460,8 +460,9 @@ function tcg_gen_xxx(args).
 
 4) Backend
 
-tcg-target.h contains the target specific definitions. tcg-target.c
-contains the target specific code.
+tcg-target.h contains the target specific definitions. tcg-target.inc.c
+contains the target specific code; it is #included by tcg/tcg.c, rather
+than being a standalone C file.
 
 4.1) Assumptions
 
tcg/aarch64/tcg-target.inc.c renamed from tcg/aarch64/tcg-target.c +0 -0
similarity index 100%
rename from tcg/aarch64/tcg-target.c
rename to tcg/aarch64/tcg-target.inc.c
tcg/arm/tcg-target.inc.c renamed from tcg/arm/tcg-target.c +0 -0
similarity index 100%
rename from tcg/arm/tcg-target.c
rename to tcg/arm/tcg-target.inc.c
tcg/i386/tcg-target.inc.c renamed from tcg/i386/tcg-target.c +0 -0
similarity index 100%
rename from tcg/i386/tcg-target.c
rename to tcg/i386/tcg-target.inc.c
tcg/ia64/tcg-target.inc.c renamed from tcg/ia64/tcg-target.c +0 -0
similarity index 100%
rename from tcg/ia64/tcg-target.c
rename to tcg/ia64/tcg-target.inc.c
tcg/mips/tcg-target.inc.c renamed from tcg/mips/tcg-target.c +0 -0
similarity index 100%
rename from tcg/mips/tcg-target.c
rename to tcg/mips/tcg-target.inc.c
tcg/ppc/tcg-target.inc.c renamed from tcg/ppc/tcg-target.c +0 -0
similarity index 100%
rename from tcg/ppc/tcg-target.c
rename to tcg/ppc/tcg-target.inc.c
tcg/s390/tcg-target.inc.c renamed from tcg/s390/tcg-target.c +0 -0
similarity index 100%
rename from tcg/s390/tcg-target.c
rename to tcg/s390/tcg-target.inc.c
tcg/sparc/tcg-target.inc.c renamed from tcg/sparc/tcg-target.c +0 -0
similarity index 100%
rename from tcg/sparc/tcg-target.c
rename to tcg/sparc/tcg-target.inc.c
tcg/tcg.c +4 -3
index 0317c9e..88567a6 100644
@@ -62,7 +62,8 @@
 #include "elf.h"
 #include "exec/log.h"
 
-/* Forward declarations for functions declared in tcg-target.c and used here. */
+/* Forward declarations for functions declared in tcg-target.inc.c and
+   used here. */
 static void tcg_target_init(TCGContext *s);
 static void tcg_target_qemu_prologue(TCGContext *s);
 static void patch_reloc(tcg_insn_unit *code_ptr, int type,
@@ -96,7 +97,7 @@ static void tcg_register_jit_int(void *buf, size_t size,
                                  size_t debug_frame_size)
     __attribute__((unused));
 
-/* Forward declarations for functions declared and used in tcg-target.c. */
+/* Forward declarations for functions declared and used in tcg-target.inc.c. */
 static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str);
 static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1,
                        intptr_t arg2);
@@ -250,7 +251,7 @@ TCGLabel *gen_new_label(void)
     return l;
 }
 
-#include "tcg-target.c"
+#include "tcg-target.inc.c"
 
 /* pool based memory allocation */
 void *tcg_malloc_internal(TCGContext *s, int size)
tcg/tcg.h +1 -1
index 83da5fb..143908b 100644
@@ -566,7 +566,7 @@ struct TCGContext {
 
     TBContext tb_ctx;
 
-    /* The TCGBackendData structure is private to tcg-target.c.  */
+    /* The TCGBackendData structure is private to tcg-target.inc.c.  */
     struct TCGBackendData *be;
 
     TCGTempSet free_temps[TCG_TYPE_COUNT * 2];
tcg/tci/README +2 -2
index dc57f07..3786b09 100644
@@ -21,7 +21,7 @@ This is what TCI (Tiny Code Interpreter) does.
 2) Implementation
 
 Like each TCG host frontend, TCI implements the code generator in
-tcg-target.c, tcg-target.h. Both files are in directory tcg/tci.
+tcg-target.inc.c, tcg-target.h. Both files are in directory tcg/tci.
 
 The additional file tcg/tci.c adds the interpreter.
 
@@ -123,7 +123,7 @@ u1 = linux-user-test works
   would also improve speed for hosts which support byte alignment).
 
 * A better disassembler for the pseudo code would be nice (a very primitive
-  disassembler is included in tcg-target.c).
+  disassembler is included in tcg-target.inc.c).
 
 * It might be useful to have a runtime option which selects the native TCG
   or TCI, so QEMU would have to include two TCGs. Today, selecting TCI
tcg/tci/tcg-target.inc.c renamed from tcg/tci/tcg-target.c +0 -0
similarity index 100%
rename from tcg/tci/tcg-target.c
rename to tcg/tci/tcg-target.inc.c
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/3 scripts/clean-includes: Ignore .inc.c files

In reply to Peter Maydell

Ignore files which have a .inc.c extension -- these are not headers but they are not standalone C source files either, so we can't make any automated decisions about what #include directives they should have.

---
 scripts/clean-includes | 5 +++++
 1 file changed, 5 insertions(+)
scripts/clean-includes +5 -0
index 8a3f398..177d253 100755
@@ -94,6 +94,11 @@ EOT
 
 for f in "$@"; do
   case "$f" in
+    *.inc.c)
+      # These aren't standalone C source files
+      echo "SKIPPING $f (not a standalone source file)"
+      continue
+      ;;
     *.c)
       MODE=c
       ;;
Signature · 1 line
1.9.1
Reviewed-by on v1 2/3
#3 lore raw

Re: [Qemu-devel] [PATCH 2/3] scripts/clean-includes: Ignore .inc.c files

Quoted 9 lines · Peter Maydell

Ignore files which have a .inc.c extension -- these are not headers but they are not standalone C source files either, so we can't make any automated decisions about what #include directives they should have.

---
 scripts/clean-includes | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 18 lines
scripts/clean-includes +5 -0
index 8a3f398..177d253 100755
@@ -94,6 +94,11 @@ EOT
 
 for f in "$@"; do
   case "$f" in
+    *.inc.c)
+      # These aren't standalone C source files
+      echo "SKIPPING $f (not a standalone source file)"
+      continue
+      ;;
     *.c)
       MODE=c
       ;;
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#4 lore raw

PATCH 3/3 tcg: Remove unnecessary osdep.h includes from tcg-target.inc.c

In reply to Peter Maydell

Commit 757e725b58c57d added a number of #include "qemu/osdep.h" files to the tcg-target.c files (as they were named at the time). These are unnecessary because these files are not standalone C files, and the tcg/tcg.c file which includes them will have already included osdep.h on their behalf. Remove the unneeded include directives.

---
 tcg/aarch64/tcg-target.inc.c | 1 -
 tcg/arm/tcg-target.inc.c     | 1 -
 tcg/i386/tcg-target.inc.c    | 1 -
 tcg/mips/tcg-target.inc.c    | 1 -
 tcg/ppc/tcg-target.inc.c     | 1 -
 tcg/s390/tcg-target.inc.c    | 1 -
 tcg/sparc/tcg-target.inc.c   | 1 -
 tcg/tci/tcg-target.inc.c     | 1 -
 8 files changed, 8 deletions(-)
tcg/aarch64/tcg-target.inc.c +0 -1
index 8467d5d..0ed10a9 100644
@@ -10,7 +10,6 @@
  * See the COPYING file in the top-level directory for details.
  */
 
-#include "qemu/osdep.h"
 #include "tcg-be-ldst.h"
 #include "qemu/bitops.h"
 
tcg/arm/tcg-target.inc.c +0 -1
index 146ac00..3edf6a6 100644
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 
-#include "qemu/osdep.h"
 #include "elf.h"
 #include "tcg-be-ldst.h"
 
tcg/i386/tcg-target.inc.c +0 -1
index d90636c..9187d34 100644
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 
-#include "qemu/osdep.h"
 #include "tcg-be-ldst.h"
 
 #ifndef NDEBUG
tcg/mips/tcg-target.inc.c +0 -1
index 2dc4998..297bd00 100644
@@ -24,7 +24,6 @@
  * THE SOFTWARE.
  */
 
-#include "qemu/osdep.h"
 #include "tcg-be-ldst.h"
 
 #ifdef HOST_WORDS_BIGENDIAN
tcg/ppc/tcg-target.inc.c +0 -1
index c593344..8c1c2df 100644
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 
-#include "qemu/osdep.h"
 #include "tcg-be-ldst.h"
 
 #if defined _CALL_DARWIN || defined __APPLE__
tcg/s390/tcg-target.inc.c +0 -1
index 58520fa..fbf97bb 100644
@@ -24,7 +24,6 @@
  * THE SOFTWARE.
  */
 
-#include "qemu/osdep.h"
 #include "tcg-be-ldst.h"
 
 /* We only support generating code for 64-bit mode.  */
tcg/sparc/tcg-target.inc.c +0 -1
index d3100ab..54df1bc 100644
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 
-#include "qemu/osdep.h"
 #include "tcg-be-null.h"
 
 #ifndef NDEBUG
tcg/tci/tcg-target.inc.c +0 -1
index 16ce048..4afe4d7 100644
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 
-#include "qemu/osdep.h"
 #include "tcg-be-null.h"
 
 /* TODO list:
Signature · 1 line
1.9.1
Reviewed-by Tested-by on the v1 series
#5 lore raw
In reply to Peter Maydell
Quoted 9 lines · Peter Maydell

This patchset renames the arch-specific tcg-target.c files to tcg-target.inc.c, to better indicate the fact that they are not standalone source files but are just #included from another .c file.

Having done that we can teach clean-includes about the .inc.c convention, and then undo some unnecessary #includes that it added earlier.

Quoted 7 lines

thanks
-- PMM

Peter Maydell (3):
tcg: Rename tcg-target.c to tcg-target.inc.c scripts/clean-includes: Ignore .inc.c files
tcg: Remove unnecessary osdep.h includes from tcg-target.inc.c

also, for this series and for "post-include-cleanup followups":

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#7 lore raw
Quoted 7 lines · Richard Henderson
Quoted 4 lines · Peter Maydell

Peter Maydell (3):
tcg: Rename tcg-target.c to tcg-target.inc.c scripts/clean-includes: Ignore .inc.c files
tcg: Remove unnecessary osdep.h includes from tcg-target.inc.c

Thanks. I'm assuming you'll prefer to take these via the tcg tree to avoid conflicts with anything else you have pending.

thanks
-- PMM

#8 lore raw
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Richard Henderson
Quoted 4 lines · Peter Maydell

Peter Maydell (3):
tcg: Rename tcg-target.c to tcg-target.inc.c scripts/clean-includes: Ignore .inc.c files
tcg: Remove unnecessary osdep.h includes from tcg-target.inc.c

Quoted 5 lines
Quoted 1 line

Thanks. I'm assuming you'll prefer to take these via the tcg tree to avoid conflicts with anything else you have pending.

Sure. I'm about to rebase and resubmit that, so this will be in.

r~