public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] morello: Add optabs for rrlen and rrmask
@ 2023-06-28 13:33 Alex Coplan
  0 siblings, 0 replies; only message in thread
From: Alex Coplan @ 2023-06-28 13:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:12376b43001a989f24a446757e2ea368e9b53984

commit 12376b43001a989f24a446757e2ea368e9b53984
Author: Alex Coplan <alex.coplan@arm.com>
Date:   Fri Apr 14 15:56:20 2023 +0100

    morello: Add optabs for rrlen and rrmask
    
    This patch adds optabs for rrlen and rrmask, which both simplifies the
    mid-end code, and also (partially) fixes the build on non-AArch64
    targets which would otherwise error out due to missing definitions of
    the gen_* functions which we were previously directly calling from
    explow.c:allocate_dynamic_stack_space.

Diff:
---
 gcc/config/aarch64/aarch64-morello.md |  4 ++--
 gcc/explow.c                          | 13 +++++--------
 gcc/internal-fn.def                   | 10 +++++-----
 gcc/optabs.def                        |  2 ++
 4 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-morello.md b/gcc/config/aarch64/aarch64-morello.md
index e22becabb50..6f6bd5870d5 100644
--- a/gcc/config/aarch64/aarch64-morello.md
+++ b/gcc/config/aarch64/aarch64-morello.md
@@ -197,7 +197,7 @@
   "gclen\\t%0, %1"
 )
 
-(define_insn "cap_representable_alignment_mask"
+(define_insn "cap_representable_alignment_mask_di"
   [(set (match_operand:DI 0 "register_operand" "=r")
         (unspec:DI [(match_operand:DI 1 "register_operand" "r")]
             UNSPEC_CHERI_REPR_ALIGN_MASK)
@@ -206,7 +206,7 @@
   "rrmask\\t%0, %1"
 )
 
-(define_insn "cap_round_representable_length"
+(define_insn "cap_round_representable_length_di"
   [(set (match_operand:DI 0 "register_operand" "=r")
         (unspec:DI [(match_operand:DI 1 "register_operand" "r")]
            UNSPEC_CHERI_ROUND_REPR_LEN)
diff --git a/gcc/explow.c b/gcc/explow.c
index e72f7221227..566d003763c 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -1506,10 +1506,8 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
     }
   else
     {
-      rtx tmp = force_reg (POmode, size);
-      rtx target = gen_reg_rtx (POmode);
-      emit_insn (gen_cap_round_representable_length (target, tmp));
-      size = target;
+      size = expand_unop (POmode, cap_round_representable_length_optab,
+			  size, NULL_RTX, 1);
     }
 
   bounds_size = size;
@@ -1579,10 +1577,9 @@ allocate_dynamic_stack_space (rtx size, unsigned size_align,
       emit_move_insn (saved_top, cap_aligned);
 
       /* Get the mask which describes the alignment we need.  */
-      rtx size_rtx = force_reg (POmode, orig_size);
-      cheri_alignment_mask = gen_reg_rtx (POmode);
-      emit_insn (gen_cap_representable_alignment_mask
-		 (cheri_alignment_mask, size_rtx));
+      cheri_alignment_mask = expand_unop (POmode,
+					  cap_representable_alignment_mask_optab,
+					  orig_size, NULL_RTX, 1);
 
       /* Use that mask to apply the relevant alignment to our pointer onto the
 	 stack.  */
diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def
index 4b51a43a2c0..e39d8cff88a 100644
--- a/gcc/internal-fn.def
+++ b/gcc/internal-fn.def
@@ -414,13 +414,13 @@ DEF_INTERNAL_INSN_FN (CAP_GLOBAL_DATA_DERIVE, ECF_CONST | ECF_NOTHROW,
 DEF_INTERNAL_INSN_FN (CAP_PROGRAM_COUNTER_GET,
 		      ECF_CONST | ECF_LEAF | ECF_NOTHROW,
 		      cap_program_counter_get, 1, 0)
-DEF_INTERNAL_INSN_FN (CAP_REPRESENTABLE_ALIGNMENT_MASK,
+
+DEF_INTERNAL_OPTAB_FN (CAP_REPRESENTABLE_ALIGNMENT_MASK,
 		      ECF_CONST | ECF_LEAF | ECF_NOTHROW,
-		      cap_representable_alignment_mask, 1, 1)
-DEF_INTERNAL_INSN_FN (CAP_ROUND_REPRESENTABLE_LENGTH,
+		      cap_representable_alignment_mask, unary)
+DEF_INTERNAL_OPTAB_FN (CAP_ROUND_REPRESENTABLE_LENGTH,
 		      ECF_CONST | ECF_LEAF | ECF_NOTHROW,
-		      cap_round_representable_length, 1, 1)
-
+		      cap_round_representable_length, unary)
 DEF_INTERNAL_OPTAB_FN (CAP_ADDRESS_GET, ECF_CONST | ECF_NOTHROW,
 		       cap_address_get, unary)
 DEF_INTERNAL_OPTAB_FN (CAP_BASE_GET, ECF_CONST | ECF_NOTHROW,
diff --git a/gcc/optabs.def b/gcc/optabs.def
index 9109da6bc5b..11b4289a8e0 100644
--- a/gcc/optabs.def
+++ b/gcc/optabs.def
@@ -466,6 +466,8 @@ OPTAB_D (cap_offset_get_optab, "cap_offset_get_$a")
 OPTAB_D (cap_offset_set_optab, "cap_offset_set_$a")
 OPTAB_D (cap_perms_and_optab, "cap_perms_and_$a")
 OPTAB_D (cap_perms_get_optab, "cap_perms_get_$a")
+OPTAB_D (cap_round_representable_length_optab, "cap_round_representable_length_$a")
+OPTAB_D (cap_representable_alignment_mask_optab, "cap_representable_alignment_mask_$a")
 OPTAB_D (cap_seal_entry_optab, "cap_seal_entry_$a")
 OPTAB_D (cap_seal_optab, "cap_seal_$a")
 OPTAB_D (cap_sealed_get_optab, "cap_sealed_get_$a")

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-28 13:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-28 13:33 [gcc(refs/vendors/ARM/heads/morello)] morello: Add optabs for rrlen and rrmask Alex Coplan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).