Skip to contentSkip to conversation

target-sparc: fixed unused function warnings

PATCH In review Peter Maydell 4 participants 8 messages Sep 2, 2014 – Sep 3, 2014

lore
Share & tools
lore
#0 lore raw

v2 cover target-sparc: fixed unused function warnings

These patchsets fix clang 3.4 warnings about unused static inline functions (clang now warns about these if they're defined in a .c file but then not used; gcc doesn't). The first patch just removes two totally unused functions; the second two patches use ifdeffery to avoid defining the functions in non-TARGET_SPARC64 builds.

(I sent out v1 back in June; the only change here is to drop the now-unnecessary "inline" specifiers, as suggested by RTH.)

Peter Maydell (3):
target-sparc: Remove unused gen_op_subi_cc and gen_op_addi_cc
target-sparc: address_mask(), asi_address_mask() are TARGET_SPARC64
only
target-sparc: is_translating_asi() is TARGET_SPARC64 only

 target-sparc/ldst_helper.c | 18 +++++++++---------
 target-sparc/translate.c   | 24 ------------------------
 2 files changed, 9 insertions(+), 33 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/3 target-sparc: Remove unused gen_op_subi_cc and gen_op_addi_cc

The functions gen_op_addi_cc() and gen_op_subi_cc() are unused; remove them.

---
 target-sparc/translate.c | 24 ------------------------
 1 file changed, 24 deletions(-)
target-sparc/translate.c +0 -24
index 78c4e21..62edf20 100644
@@ -363,14 +363,6 @@ static inline void gen_mov_reg_C(TCGv reg, TCGv_i32 src)
     tcg_gen_andi_tl(reg, reg, 0x1);
 }
 
-static inline void gen_op_addi_cc(TCGv dst, TCGv src1, target_long src2)
-{
-    tcg_gen_mov_tl(cpu_cc_src, src1);
-    tcg_gen_movi_tl(cpu_cc_src2, src2);
-    tcg_gen_addi_tl(cpu_cc_dst, cpu_cc_src, src2);
-    tcg_gen_mov_tl(dst, cpu_cc_dst);
-}
-
 static inline void gen_op_add_cc(TCGv dst, TCGv src1, TCGv src2)
 {
     tcg_gen_mov_tl(cpu_cc_src, src1);
@@ -502,22 +494,6 @@ static void gen_op_addx_int(DisasContext *dc, TCGv dst, TCGv src1,
     }
 }
 
-static inline void gen_op_subi_cc(TCGv dst, TCGv src1, target_long src2, DisasContext *dc)
-{
-    tcg_gen_mov_tl(cpu_cc_src, src1);
-    tcg_gen_movi_tl(cpu_cc_src2, src2);
-    if (src2 == 0) {
-        tcg_gen_mov_tl(cpu_cc_dst, src1);
-        tcg_gen_movi_i32(cpu_cc_op, CC_OP_LOGIC);
-        dc->cc_op = CC_OP_LOGIC;
-    } else {
-        tcg_gen_subi_tl(cpu_cc_dst, cpu_cc_src, src2);
-        tcg_gen_movi_i32(cpu_cc_op, CC_OP_SUB);
-        dc->cc_op = CC_OP_SUB;
-    }
-    tcg_gen_mov_tl(dst, cpu_cc_dst);
-}
-
 static inline void gen_op_sub_cc(TCGv dst, TCGv src1, TCGv src2)
 {
     tcg_gen_mov_tl(cpu_cc_src, src1);
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/3 target-sparc: address_mask(), asi_address_mask() are TARGET_SPARC64 only

In reply to Peter Maydell

The address_mask() and asi_address_mask() functions are only used in TARGET_SPARC64 configs, so guard with ifdefs to avoid warnings about unused functions in 32-bit builds.

Since the main reason these functions were marked 'inline' was to suppress unused-function warnings with gcc, we remove the 'inline' as no longer necessary.

---
 target-sparc/ldst_helper.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
target-sparc/ldst_helper.c +7 -3
index 1a62e19..2d028a5 100644
@@ -250,7 +250,8 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,
 
 #endif
 
-static inline target_ulong address_mask(CPUSPARCState *env1, target_ulong addr)
+#if defined(TARGET_SPARC64) || defined(CONFIG_USER_ONLY)
+static target_ulong address_mask(CPUSPARCState *env1, target_ulong addr)
 {
 #ifdef TARGET_SPARC64
     if (AM_CHECK(env1)) {
@@ -259,6 +260,7 @@ static inline target_ulong address_mask(CPUSPARCState *env1, target_ulong addr)
 #endif
     return addr;
 }
+#endif
 
 /* returns true if access using this ASI is to have address translated by MMU
    otherwise access is to raw physical address */
@@ -287,8 +289,9 @@ static inline int is_translating_asi(int asi)
 #endif
 }
 
-static inline target_ulong asi_address_mask(CPUSPARCState *env,
-                                            int asi, target_ulong addr)
+#ifdef TARGET_SPARC64
+static target_ulong asi_address_mask(CPUSPARCState *env,
+                                     int asi, target_ulong addr)
 {
     if (is_translating_asi(asi)) {
         return address_mask(env, addr);
@@ -296,6 +299,7 @@ static inline target_ulong asi_address_mask(CPUSPARCState *env,
         return addr;
     }
 }
+#endif
 
 void helper_check_align(CPUSPARCState *env, target_ulong addr, uint32_t align)
 {
Signature · 1 line
1.9.1
#3 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] target-sparc: address_mask(), asi_address_mask() are TARGET_SPARC64 only

Quoted 7 lines · Peter Maydell

The address_mask() and asi_address_mask() functions are only used in TARGET_SPARC64 configs, so guard with ifdefs to avoid warnings about unused functions in 32-bit builds.

Since the main reason these functions were marked 'inline' was to suppress unused-function warnings with gcc, we remove the 'inline' as no longer necessary.

I thought address_mask was inline because it's in the hot path. Wouldn't the removal hit performance?

Artyom

Quoted 51 lines
---
 target-sparc/ldst_helper.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
target-sparc/ldst_helper.c +7 -4
index 1a62e19..2d028a5 100644
@@ -250,7 +250,8 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,
 
 #endif
 
-static inline target_ulong address_mask(CPUSPARCState *env1, target_ulong addr)
+#if defined(TARGET_SPARC64) || defined(CONFIG_USER_ONLY)
+static target_ulong address_mask(CPUSPARCState *env1, target_ulong addr)
 {
 #ifdef TARGET_SPARC64
     if (AM_CHECK(env1)) {
@@ -259,6 +260,7 @@ static inline target_ulong address_mask(CPUSPARCState *env1, target_ulong addr)
 #endif
     return addr;
 }
+#endif
 
 /* returns true if access using this ASI is to have address translated by MMU
    otherwise access is to raw physical address */
@@ -287,8 +289,9 @@ static inline int is_translating_asi(int asi)
 #endif
 }
 
-static inline target_ulong asi_address_mask(CPUSPARCState *env,
-                                            int asi, target_ulong addr)
+#ifdef TARGET_SPARC64
+static target_ulong asi_address_mask(CPUSPARCState *env,
+                                     int asi, target_ulong addr)
 {
     if (is_translating_asi(asi)) {
         return address_mask(env, addr);
@@ -296,6 +299,7 @@ static inline target_ulong asi_address_mask(CPUSPARCState *env,
         return addr;
     }
 }
+#endif
 
 void helper_check_align(CPUSPARCState *env, target_ulong addr, uint32_t align)
 {
--

1.9.1

Signature · 5 lines
Regards,
Artyom Tarasenko

linux/sparc and solaris/sparc under qemu blog:
http://tyom.blogspot.com/search/label/qemu
#4 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] target-sparc: address_mask(), asi_address_mask() are TARGET_SPARC64 only

Quoted 11 lines · Artyom Tarasenko
Quoted 7 lines · Peter Maydell

The address_mask() and asi_address_mask() functions are only used in TARGET_SPARC64 configs, so guard with ifdefs to avoid warnings about unused functions in 32-bit builds.

Since the main reason these functions were marked 'inline' was to suppress unused-function warnings with gcc, we remove the 'inline' as no longer necessary.

I thought address_mask was inline because it's in the hot path. Wouldn't the removal hit performance?

The compiler will probably inline it itself as it sees fit.

r~

#5 lore raw

PATCH v2 3/3 target-sparc: is_translating_asi() is TARGET_SPARC64 only

In reply to Peter Maydell

Move the is_translating_asi() inside the TARGET_SPARC64 ifdef (and remove the unimplemented 32-bit codepath), as it is only called from TARGET_SPARC64 code. This fixes a clang 3.4 unused-function warning.

Again, this allows us to remove an 'inline' tag that was there largely to suppress gcc warnings.

---
 target-sparc/ldst_helper.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
target-sparc/ldst_helper.c +3 -7
index 2d028a5..9f65bc3 100644
@@ -262,11 +262,12 @@ static target_ulong address_mask(CPUSPARCState *env1, target_ulong addr)
 }
 #endif
 
+#ifdef TARGET_SPARC64
 /* returns true if access using this ASI is to have address translated by MMU
    otherwise access is to raw physical address */
-static inline int is_translating_asi(int asi)
+/* TODO: check sparc32 bits */
+static int is_translating_asi(int asi)
 {
-#ifdef TARGET_SPARC64
     /* Ultrasparc IIi translating asi
        - note this list is defined by cpu implementation
     */
@@ -283,13 +284,8 @@ static inline int is_translating_asi(int asi)
     default:
         return 0;
     }
-#else
-    /* TODO: check sparc32 bits */
-    return 0;
-#endif
 }
 
-#ifdef TARGET_SPARC64
 static target_ulong asi_address_mask(CPUSPARCState *env,
                                      int asi, target_ulong addr)
 {
Signature · 1 line
1.9.1
#7 lore raw
Quoted 6 lines · Richard Henderson
Quoted 5 lines · Peter Maydell

Peter Maydell (3):
target-sparc: Remove unused gen_op_subi_cc and gen_op_addi_cc
target-sparc: address_mask(), asi_address_mask() are TARGET_SPARC64
only
target-sparc: is_translating_asi() is TARGET_SPARC64 only

At first glance I can't see anything too controversial here, so I'm happy for this to be applied given it has passed Richard's review.

ATB,

Mark.