Skip to contentSkip to conversation

target-sparc: fixed unused function warnings

PATCH Superseded Peter Maydell 2 participants 7 messages Jun 23, 2014 – Jun 24, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

Incidentally, Mark, if you wanted to send a patch to MAINTAINERS to add yourself as a listed comaintainer for SPARC I'd be happy to apply it...

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 | 10 +++++-----
 target-sparc/translate.c   | 24 ------------------------
 2 files changed, 5 insertions(+), 29 deletions(-)
Signature · 1 line
2.0.0
#1 lore raw

PATCH 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 1ab07a1..b19673a 100644
@@ -360,14 +360,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);
@@ -499,22 +491,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
2.0.0
#2 lore raw

cover target-sparc: fixed unused function warnings

In reply to Peter Maydell

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.

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 | 10 +++++-----
 target-sparc/translate.c   | 24 ------------------------
 2 files changed, 5 insertions(+), 29 deletions(-)
Signature · 1 line
2.0.0
#3 lore raw

PATCH 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.

---
 target-sparc/ldst_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
target-sparc/ldst_helper.c +4 -0
index 03bd9f9..f4be811 100644
@@ -250,6 +250,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb,
 
 #endif
 
+#if defined(TARGET_SPARC64) || defined(CONFIG_USER_ONLY)
 static inline target_ulong address_mask(CPUSPARCState *env1, target_ulong addr)
 {
 #ifdef TARGET_SPARC64
@@ -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,6 +289,7 @@ static inline int is_translating_asi(int asi)
 #endif
 }
 
+#ifdef TARGET_SPARC64
 static inline target_ulong asi_address_mask(CPUSPARCState *env,
                                             int asi, target_ulong 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
2.0.0
#4 lore raw

PATCH 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.

---
 target-sparc/ldst_helper.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
target-sparc/ldst_helper.c +2 -6
index f4be811..e0aee86 100644
@@ -262,11 +262,12 @@ static inline 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 */
+/* TODO: check sparc32 bits */
 static inline 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 inline target_ulong asi_address_mask(CPUSPARCState *env,
                                             int asi, target_ulong addr)
 {
Signature · 1 line
2.0.0
#5 lore raw
In reply to Peter Maydell
Quoted 6 lines · Peter Maydell

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 think I would be happier if you changed the functions to not be marked as "inline". I think that there's a large body of code that marks things inline exactly to prevent unused warnings with gcc. If we're going to play with the ifdeffery, we might as well just let any compiler warn if its unused.

r~

#6 lore raw
Quoted 4 lines · Richard Henderson

I think I would be happier if you changed the functions to not be marked as "inline". I think that there's a large body of code that marks things inline exactly to prevent unused warnings with gcc. If we're going to play with the ifdeffery, we might as well just let any compiler warn if its unused.

Makes sense.

thanks
-- PMM