public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED 9/15] Unify operator_cst range operator
@ 2023-06-10  0:35 Andrew MacLeod
  0 siblings, 0 replies; only message in thread
From: Andrew MacLeod @ 2023-06-10  0:35 UTC (permalink / raw)
  To: gcc-patches; +Cc: hernandez, aldy

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

THis patch move the CONST operator into the mixed header.  It also sets 
REAL_CST to use this instead, as it has no op1_range routines.


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

Andrew

[-- Attachment #2: 0009-Unify-operator_cst-range-operator.patch --]
[-- Type: text/x-patch, Size: 3662 bytes --]

From 35a580f09eaceda5b0dd370b1e39fe05ba0a154f Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Fri, 9 Jun 2023 13:37:11 -0400
Subject: [PATCH 09/31] Unify operator_cst range operator

Move the declaration of the class to the range-op-mixed header, add the
floating point prototypes as well, and use it in the new unified table.

	* range-op-float.cc (operator_cst::fold_range): New.
	* range-op-mixed.h (class operator_cst): Move from integer file.
	* range-op.cc (op_cst): New object.
	(unified_table::unified_table): Add op_cst. Also use for REAL_CST.
	(class operator_cst): Move to range-op-mixed.h.
	(integral_table::integral_table): Remove op_cst.
	(pointer_table::pointer_table): Remove op_cst.
---
 gcc/range-op-float.cc |  7 +++++++
 gcc/range-op-mixed.h  | 12 ++++++++++++
 gcc/range-op.cc       | 16 +++-------------
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index bc8ecc61bce..11d76f2ef25 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -557,6 +557,13 @@ operator_identity::op1_range (frange &r, tree, const frange &lhs,
   return true;
 }
 
+bool
+operator_cst::fold_range (frange &r, tree, const frange &op1,
+			  const frange &, relation_trio) const
+{
+  r = op1;
+  return true;
+}
 
 bool
 operator_equal::op2_range (frange &r, tree type,
diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h
index f30f7d019ee..5b7fbe89856 100644
--- a/gcc/range-op-mixed.h
+++ b/gcc/range-op-mixed.h
@@ -292,4 +292,16 @@ public:
 				  relation_kind rel) const final override;
 };
 
+class operator_cst : public range_operator
+{
+public:
+  using range_operator::fold_range;
+  bool fold_range (irange &r, tree type,
+		   const irange &op1, const irange &op2,
+		   relation_trio rel = TRIO_VARYING) const final override;
+  bool fold_range (frange &r, tree type,
+		   const frange &op1, const frange &op2,
+		   relation_trio = TRIO_VARYING) const final override;
+};
+
 #endif // GCC_RANGE_OP_MIXED_H
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 70684b4c7f7..31d4e1a1739 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -69,6 +69,7 @@ operator_le op_le;
 operator_gt op_gt;
 operator_ge op_ge;
 operator_identity op_ident;
+operator_cst op_cst;
 
 // Invoke the initialization routines for each class of range.
 
@@ -87,7 +88,8 @@ unified_table::unified_table ()
   set (SSA_NAME, op_ident);
   set (PAREN_EXPR, op_ident);
   set (OBJ_TYPE_REF, op_ident);
-  set (REAL_CST, op_ident);
+  set (REAL_CST, op_cst);
+  set (INTEGER_CST, op_cst);
 }
 
 // The tables are hidden and accessed via a simple extern function.
@@ -4224,16 +4226,6 @@ operator_bitwise_not::op1_range (irange &r, tree type,
 }
 
 
-class operator_cst : public range_operator
-{
-  using range_operator::fold_range;
-public:
-  virtual bool fold_range (irange &r, tree type,
-			   const irange &op1,
-			   const irange &op2,
-			   relation_trio rel = TRIO_VARYING) const;
-} op_integer_cst;
-
 bool
 operator_cst::fold_range (irange &r, tree type ATTRIBUTE_UNUSED,
 			  const irange &lh,
@@ -4758,7 +4750,6 @@ integral_table::integral_table ()
   set (BIT_IOR_EXPR, op_bitwise_or);
   set (BIT_XOR_EXPR, op_bitwise_xor);
   set (BIT_NOT_EXPR, op_bitwise_not);
-  set (INTEGER_CST, op_integer_cst);
   set (ABS_EXPR, op_abs);
   set (NEGATE_EXPR, op_negate);
   set (ADDR_EXPR, op_addr);
@@ -4792,7 +4783,6 @@ pointer_table::pointer_table ()
   set (MIN_EXPR, op_ptr_min_max);
   set (MAX_EXPR, op_ptr_min_max);
 
-  set (INTEGER_CST, op_integer_cst);
   set (ADDR_EXPR, op_addr);
   set (NOP_EXPR, op_cast);
   set (CONVERT_EXPR, op_cast);
-- 
2.40.1


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

only message in thread, other threads:[~2023-06-10  0:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-10  0:35 [COMMITTED 9/15] Unify operator_cst range operator Andrew MacLeod

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).