[1/3] LoongArch: Include rtl.h for COSTS_N_INSNS instead of hard coding our own

Message ID 20231209170347.12601-3-xry111@xry111.site
State Unresolved
Headers
Series LoongArch: Fix instruction costs |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Xi Ruoyao Dec. 9, 2023, 5:03 p.m. UTC
  With loongarch-def.cc switched from C to C++, we can include rtl.h for
COSTS_N_INSNS, instead of hard coding our own.

THis is a non-functional change for now, but it will make the code more
future-proof in case COSTS_N_INSNS in rtl.h would be changed.

gcc/ChangeLog:

	* config/loongarch/loongarch-def.cc (rtl.h): Include.
	(COSTS_N_INSNS): Remove the macro definition.
---
 gcc/config/loongarch/loongarch-def.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

chenglulu Dec. 13, 2023, 12:57 p.m. UTC | #1
LGTM!

Thanks.

在 2023/12/10 上午1:03, Xi Ruoyao 写道:
> With loongarch-def.cc switched from C to C++, we can include rtl.h for
> COSTS_N_INSNS, instead of hard coding our own.
>
> THis is a non-functional change for now, but it will make the code more
> future-proof in case COSTS_N_INSNS in rtl.h would be changed.
>
> gcc/ChangeLog:
>
> 	* config/loongarch/loongarch-def.cc (rtl.h): Include.
> 	(COSTS_N_INSNS): Remove the macro definition.
> ---
>   gcc/config/loongarch/loongarch-def.cc | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/gcc/config/loongarch/loongarch-def.cc b/gcc/config/loongarch/loongarch-def.cc
> index c41804a180e..6217b19268c 100644
> --- a/gcc/config/loongarch/loongarch-def.cc
> +++ b/gcc/config/loongarch/loongarch-def.cc
> @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
>   #include "system.h"
>   #include "coretypes.h"
>   #include "tm.h"
> +#include "rtl.h"
>   
>   #include "loongarch-def.h"
>   #include "loongarch-str.h"
> @@ -89,8 +90,6 @@ array_tune<loongarch_align> loongarch_cpu_align =
>       .set (CPU_LA464, la464_align ())
>       .set (CPU_LA664, la464_align ());
>   
> -#define COSTS_N_INSNS(N) ((N) * 4)
> -
>   /* Default RTX cost initializer.  */
>   loongarch_rtx_cost_data::loongarch_rtx_cost_data ()
>     : fp_add (COSTS_N_INSNS (1)),
  

Patch

diff --git a/gcc/config/loongarch/loongarch-def.cc b/gcc/config/loongarch/loongarch-def.cc
index c41804a180e..6217b19268c 100644
--- a/gcc/config/loongarch/loongarch-def.cc
+++ b/gcc/config/loongarch/loongarch-def.cc
@@ -22,6 +22,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
+#include "rtl.h"
 
 #include "loongarch-def.h"
 #include "loongarch-str.h"
@@ -89,8 +90,6 @@  array_tune<loongarch_align> loongarch_cpu_align =
     .set (CPU_LA464, la464_align ())
     .set (CPU_LA664, la464_align ());
 
-#define COSTS_N_INSNS(N) ((N) * 4)
-
 /* Default RTX cost initializer.  */
 loongarch_rtx_cost_data::loongarch_rtx_cost_data ()
   : fp_add (COSTS_N_INSNS (1)),