public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Cc: "hernandez, aldy" <aldyh@redhat.com>
Subject: [COMMITTED 10/15] Unify operator_cast range operator
Date: Fri, 9 Jun 2023 20:35:51 -0400	[thread overview]
Message-ID: <2afdd19f-b5a3-a7c5-b753-4a340c59ce32@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 75 bytes --]

Bootstrap on x86_64-pc-linux-gnu and pass all regressions. Pushed.

Andrew

[-- Attachment #2: 0010-Unify-operator_cast-range-operator.patch --]
[-- Type: text/x-patch, Size: 4242 bytes --]

From ee46a15733524103a9eda433df5dc44cdc055d73 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Fri, 9 Jun 2023 13:39:54 -0400
Subject: [PATCH 10/31] Unify operator_cast range operator

Move the declaration of the class to the range-op-mixed header, and use it
in the new unified table.

	* range-op-mixed.h (class operator_cast): Combined from integer
	and float files.
	* range-op.cc (op_cast): New object.
	(unified_table::unified_table): Add op_cast
	(class operator_cast): Move to range-op-mixed.h.
	(integral_table::integral_table): Remove op_cast
	(pointer_table::pointer_table): Remove op_cast.
---
 gcc/range-op-mixed.h | 24 ++++++++++++++++++++++++
 gcc/range-op.cc      | 34 ++++------------------------------
 2 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h
index 5b7fbe89856..9de8479cd24 100644
--- a/gcc/range-op-mixed.h
+++ b/gcc/range-op-mixed.h
@@ -304,4 +304,28 @@ public:
 		   relation_trio = TRIO_VARYING) const final override;
 };
 
+
+class operator_cast: public range_operator
+{
+public:
+  using range_operator::fold_range;
+  using range_operator::op1_range;
+  using range_operator::lhs_op1_relation;
+  bool fold_range (irange &r, tree type,
+		   const irange &op1, const irange &op2,
+		   relation_trio rel = TRIO_VARYING) const final override;
+  bool op1_range (irange &r, tree type,
+		  const irange &lhs, const irange &op2,
+		  relation_trio rel = TRIO_VARYING) const final override;
+  relation_kind lhs_op1_relation (const irange &lhs,
+				  const irange &op1, const irange &op2,
+				  relation_kind) const final override;
+private:
+  bool truncating_cast_p (const irange &inner, const irange &outer) const;
+  bool inside_domain_p (const wide_int &min, const wide_int &max,
+			const irange &outer) const;
+  void fold_pair (irange &r, unsigned index, const irange &inner,
+			   const irange &outer) const;
+};
+
 #endif // GCC_RANGE_OP_MIXED_H
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 31d4e1a1739..7d89b633da3 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -70,6 +70,7 @@ operator_gt op_gt;
 operator_ge op_ge;
 operator_identity op_ident;
 operator_cst op_cst;
+operator_cast op_cast;
 
 // Invoke the initialization routines for each class of range.
 
@@ -90,6 +91,9 @@ unified_table::unified_table ()
   set (OBJ_TYPE_REF, op_ident);
   set (REAL_CST, op_cst);
   set (INTEGER_CST, op_cst);
+  set (NOP_EXPR, op_cast);
+  set (CONVERT_EXPR, op_cast);
+
 }
 
 // The tables are hidden and accessed via a simple extern function.
@@ -2868,32 +2872,6 @@ operator_rshift::wi_fold (irange &r, tree type,
 }
 
 
-class operator_cast: public range_operator
-{
-  using range_operator::fold_range;
-  using range_operator::op1_range;
-  using range_operator::lhs_op1_relation;
-public:
-  virtual bool fold_range (irange &r, tree type,
-			   const irange &op1,
-			   const irange &op2,
-			   relation_trio rel = TRIO_VARYING) const;
-  virtual bool op1_range (irange &r, tree type,
-			  const irange &lhs,
-			  const irange &op2,
-			  relation_trio rel = TRIO_VARYING) const;
-  virtual relation_kind lhs_op1_relation (const irange &lhs,
-					  const irange &op1,
-					  const irange &op2,
-					  relation_kind) const;
-private:
-  bool truncating_cast_p (const irange &inner, const irange &outer) const;
-  bool inside_domain_p (const wide_int &min, const wide_int &max,
-			const irange &outer) const;
-  void fold_pair (irange &r, unsigned index, const irange &inner,
-			   const irange &outer) const;
-} op_cast;
-
 // Add a partial equivalence between the LHS and op1 for casts.
 
 relation_kind
@@ -4744,8 +4722,6 @@ integral_table::integral_table ()
   set (MIN_EXPR, op_min);
   set (MAX_EXPR, op_max);
   set (MULT_EXPR, op_mult);
-  set (NOP_EXPR, op_cast);
-  set (CONVERT_EXPR, op_cast);
   set (BIT_AND_EXPR, op_bitwise_and);
   set (BIT_IOR_EXPR, op_bitwise_or);
   set (BIT_XOR_EXPR, op_bitwise_xor);
@@ -4784,8 +4760,6 @@ pointer_table::pointer_table ()
   set (MAX_EXPR, op_ptr_min_max);
 
   set (ADDR_EXPR, op_addr);
-  set (NOP_EXPR, op_cast);
-  set (CONVERT_EXPR, op_cast);
 
   set (BIT_NOT_EXPR, op_bitwise_not);
   set (BIT_XOR_EXPR, op_bitwise_xor);
-- 
2.40.1


                 reply	other threads:[~2023-06-10  0:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2afdd19f-b5a3-a7c5-b753-4a340c59ce32@redhat.com \
    --to=amacleod@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).