diff mbox series

[1/2] LoongArch: NFC: Deduplicate crc instruction defines

Message ID 20240226042830.6927-1-xry111@xry111.site
State New
Headers show
Series [1/2] LoongArch: NFC: Deduplicate crc instruction defines | expand

Commit Message

Xi Ruoyao Feb. 26, 2024, 4:28 a.m. UTC
Introduce an iterator for UNSPEC_CRC and UNSPEC_CRCC to make the next
change easier.

gcc/ChangeLog:

	* config/loongarch/loongarch.md (CRC): New define_int_iterator.
	(crc): New define_int_attr.
	(loongarch_crc_w_<size>_w, loongarch_crcc_w_<size>_w): Unify
	into ...
	(loongarch_<crc>_w_<size>_w): ... here.
---
 gcc/config/loongarch/loongarch.md | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

Comments

Lulu Cheng Feb. 26, 2024, 10:07 a.m. UTC | #1
LGTM!

Thanks!

在 2024/2/26 下午12:28, Xi Ruoyao 写道:
> Introduce an iterator for UNSPEC_CRC and UNSPEC_CRCC to make the next
> change easier.
>
> gcc/ChangeLog:
>
> 	* config/loongarch/loongarch.md (CRC): New define_int_iterator.
> 	(crc): New define_int_attr.
> 	(loongarch_crc_w_<size>_w, loongarch_crcc_w_<size>_w): Unify
> 	into ...
> 	(loongarch_<crc>_w_<size>_w): ... here.
> ---
>   gcc/config/loongarch/loongarch.md | 18 +++++-------------
>   1 file changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md
> index 2ce7a151880..4ded1b3a117 100644
> --- a/gcc/config/loongarch/loongarch.md
> +++ b/gcc/config/loongarch/loongarch.md
> @@ -4251,24 +4251,16 @@ (define_peephole2
>   
>   
>   (define_mode_iterator QHSD [QI HI SI DI])
> +(define_int_iterator CRC [UNSPEC_CRC UNSPEC_CRCC])
> +(define_int_attr crc [(UNSPEC_CRC "crc") (UNSPEC_CRCC "crcc")])
>   
> -(define_insn "loongarch_crc_w_<size>_w"
> +(define_insn "loongarch_<crc>_w_<size>_w"
>     [(set (match_operand:SI 0 "register_operand" "=r")
>   	(unspec:SI [(match_operand:QHSD 1 "register_operand" "r")
>   		   (match_operand:SI 2 "register_operand" "r")]
> -		     UNSPEC_CRC))]
> +		     CRC))]
>     ""
> -  "crc.w.<size>.w\t%0,%1,%2"
> -  [(set_attr "type" "unknown")
> -   (set_attr "mode" "<MODE>")])
> -
> -(define_insn "loongarch_crcc_w_<size>_w"
> -  [(set (match_operand:SI 0 "register_operand" "=r")
> -	(unspec:SI [(match_operand:QHSD 1 "register_operand" "r")
> -		   (match_operand:SI 2 "register_operand" "r")]
> -		     UNSPEC_CRCC))]
> -  ""
> -  "crcc.w.<size>.w\t%0,%1,%2"
> +  "<crc>.w.<size>.w\t%0,%1,%2"
>     [(set_attr "type" "unknown")
>      (set_attr "mode" "<MODE>")])
>
diff mbox series

Patch

diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md
index 2ce7a151880..4ded1b3a117 100644
--- a/gcc/config/loongarch/loongarch.md
+++ b/gcc/config/loongarch/loongarch.md
@@ -4251,24 +4251,16 @@  (define_peephole2
 
 
 (define_mode_iterator QHSD [QI HI SI DI])
+(define_int_iterator CRC [UNSPEC_CRC UNSPEC_CRCC])
+(define_int_attr crc [(UNSPEC_CRC "crc") (UNSPEC_CRCC "crcc")])
 
-(define_insn "loongarch_crc_w_<size>_w"
+(define_insn "loongarch_<crc>_w_<size>_w"
   [(set (match_operand:SI 0 "register_operand" "=r")
 	(unspec:SI [(match_operand:QHSD 1 "register_operand" "r")
 		   (match_operand:SI 2 "register_operand" "r")]
-		     UNSPEC_CRC))]
+		     CRC))]
   ""
-  "crc.w.<size>.w\t%0,%1,%2"
-  [(set_attr "type" "unknown")
-   (set_attr "mode" "<MODE>")])
-
-(define_insn "loongarch_crcc_w_<size>_w"
-  [(set (match_operand:SI 0 "register_operand" "=r")
-	(unspec:SI [(match_operand:QHSD 1 "register_operand" "r")
-		   (match_operand:SI 2 "register_operand" "r")]
-		     UNSPEC_CRCC))]
-  ""
-  "crcc.w.<size>.w\t%0,%1,%2"
+  "<crc>.w.<size>.w\t%0,%1,%2"
   [(set_attr "type" "unknown")
    (set_attr "mode" "<MODE>")])