Hi Segher,

On 2020/3/5 下午6:42, Segher Boessenkool wrote:
Hi Bin Bin,

On Thu, Mar 05, 2020 at 10:31:39AM +0800, binbin wrote:
On 2020/3/5 上午2:35, Segher Boessenkool wrote:
On Wed, Mar 04, 2020 at 03:08:41PM +0800, binbin wrote:
        * config/rs6000/rs6000.h (MAX_MACHINE_MODE): Include the header file
        for MAX_MACHINE_MODE.

The changelog entry should say *what* file is included, and under what
condition.  It doesn't have to say why (that belongs in the commit
message).

But, can't you just include it unconditionally?  Don't we already,
anyway, via coretypes.h -> machmode.h -> insn-modes.h?

OK, change it to uncondition.  Thanks for your suggestion.

What about the second part?  Shouldn't it already be included anyway?

If "insn-modes.h" is not included in rs6000.h, it reports error showing
MAX_MACHINE_MODE’ undeclared here (not in a function) in file included
from
../../host-powerpc64le-unknown-linux-gnu/gcc/tm.h:25
from ../.././libgcc/libgcc2.c:29
../.././libgcc/../gcc/config/rs6000/rs6000.h:2495:42.  Thanks.

Sure.  But why do we need to include that file at all here?  It should
already be included via coretypes.h (which includes machmode.h, which
includes insn-modes.h).

+extern GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
+extern GTY(()) tree altivec_builtin_mask_for_load;
#ifndef USED_FOR_TARGET

Maybe it should be moved into here?  Or some other #ifdef trickery?


Segher


OK, changed the code.  Bootstrap and regression tests were done on
powerpc64le-linux-gnu (LE) with no regressions.  Thanks for your good
suggestion.
gcc/ChangeLog

2020-03-09  Bin Bin Lv  <s...@linux.ibm.com>

        * config/rs6000/rs6000-internal.h (altivec_builtin_mask_for_load,
        builtin_mode_to_type[MAX_MACHINE_MODE][2]): Remove the declaration.
        * config/rs6000/rs6000.h (altivec_builtin_mask_for_load,
        builtin_mode_to_type[MAX_MACHINE_MODE][2]): Add an extern GTY(())
        declaration.
        * config/rs6000/rs6000.c (altivec_builtin_mask_for_load,
        builtin_mode_to_type[MAX_MACHINE_MODE][2]): Remove the GTY(())
        declaration and add the definition.
---
 gcc/config/rs6000/rs6000-internal.h | 2 --
 gcc/config/rs6000/rs6000.c          | 4 ++--
 gcc/config/rs6000/rs6000.h          | 2 ++
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-internal.h 
b/gcc/config/rs6000/rs6000-internal.h
index a23e956..d331b9e 100644
--- a/gcc/config/rs6000/rs6000-internal.h
+++ b/gcc/config/rs6000/rs6000-internal.h
@@ -187,7 +187,5 @@ extern bool rs6000_passes_long_double;
 extern bool rs6000_passes_vector;
 extern bool rs6000_returns_struct;
 extern bool cpu_builtin_p;
-extern GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
-extern GTY(()) tree altivec_builtin_mask_for_load;
 
 #endif
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 9910b27..0faf44b 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -99,7 +99,7 @@
 #endif
 
 /* Support targetm.vectorize.builtin_mask_for_load.  */
-GTY(()) tree altivec_builtin_mask_for_load;
+tree altivec_builtin_mask_for_load;
 
 #ifdef USING_ELFOS_H
 /* Counter for labels which are to be placed in .fixup.  */
@@ -196,7 +196,7 @@ enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
 int rs6000_vector_align[NUM_MACHINE_MODES];
 
 /* Map selected modes to types for builtins.  */
-GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
+tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
 
 /* What modes to automatically generate reciprocal divide estimate (fre) and
    reciprocal sqrt (frsqrte) for.  */
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 1697186..724085b 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -2490,6 +2490,8 @@ extern GTY(()) tree rs6000_builtin_types[RS6000_BTI_MAX];
 extern GTY(()) tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
 
 #ifndef USED_FOR_TARGET
+extern GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
+extern GTY(()) tree altivec_builtin_mask_for_load;
 /* A C structure for machine-specific, per-function data.
    This is added to the cfun structure.  */
 typedef struct GTY(()) machine_function
-- 
1.8.3.1

Reply via email to