]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Move remaining expression-related methods into base class Backend
authorOwen Avery <powerboat9.gamer@gmail.com>
Thu, 31 Aug 2023 21:25:55 +0000 (17:25 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:04:34 +0000 (19:04 +0100)
gcc/rust/ChangeLog:

* rust-backend.h
(Backend::real_part_expression): Make non-virtual.
(Backend::imag_part_expression): Likewise.
(Backend::complex_expression): Likewise.
(Backend::convert_expression): Likewise.
(Backend::struct_field_expression): Likewise.
(Backend::compound_expression): Likewise.
(Backend::conditional_expression): Likewise.
(Backend::negation_expression): Likewise.
(Backend::arithmetic_or_logical_expression): Likewise.
(Backend::arithmetic_or_logical_expression_checked): Likewise.
(Backend::comparison_expression): Likewise.
(Backend::lazy_boolean_expression): Likewise.
(Backend::constructor_expression): Likewise.
(Backend::array_constructor_expression): Likewise.
(Backend::array_initializer): Likewise.
(Backend::array_index_expression): Likewise.
(Backend::call_expression): Likewise.

(Gcc_backend::real_part_expression): Remove.
(Gcc_backend::imag_part_expression): Remove.
(Gcc_backend::complex_expression): Remove.
(Gcc_backend::convert_expression): Remove.
(Gcc_backend::struct_field_expression): Remove.
(Gcc_backend::compound_expression): Remove.
(Gcc_backend::conditional_expression): Remove.
(Gcc_backend::negation_expression): Remove.
(Gcc_backend::arithmetic_or_logical_expression): Remove.
(Gcc_backend::arithmetic_or_logical_expression_checked): Remove.
(Gcc_backend::comparison_expression): Remove.
(Gcc_backend::lazy_boolean_expression): Remove.
(Gcc_backend::constructor_expression): Remove.
(Gcc_backend::array_constructor_expression): Remove.
(Gcc_backend::array_initializer): Remove.
(Gcc_backend::array_index_expression): Remove.
(Gcc_backend::call_expression): Remove.
* rust-gcc.cc
(Gcc_backend::real_part_expression): Rename to ...
(Backend::real_part_expression): ... here.
(Gcc_backend::imag_part_expression): Rename to ...
(Backend::imag_part_expression): ... here.
(Gcc_backend::complex_expression): Rename to ...
(Backend::complex_expression): ... here.
(Gcc_backend::convert_expression): Rename to ...
(Backend::convert_expression): ... here.
(Gcc_backend::struct_field_expression): Rename to ...
(Backend::struct_field_expression): ... here.
(Gcc_backend::compound_expression): Rename to ...
(Backend::compound_expression): ... here.
(Gcc_backend::conditional_expression): Rename to ...
(Backend::conditional_expression): ... here.
(Gcc_backend::negation_expression): Rename to ...
(Backend::negation_expression): ... here.
(Gcc_backend::arithmetic_or_logical_expression): Rename to ...
(Backend::arithmetic_or_logical_expression): ... here.
(Gcc_backend::arithmetic_or_logical_expression_checked): Rename to ...
(Backend::arithmetic_or_logical_expression_checked): ... here.
(Gcc_backend::comparison_expression): Rename to ...
(Backend::comparison_expression): ... here.
(Gcc_backend::lazy_boolean_expression): Rename to ...
(Backend::lazy_boolean_expression): ... here.
(Gcc_backend::constructor_expression): Rename to ...
(Backend::constructor_expression): ... here.
(Gcc_backend::array_constructor_expression): Rename to ...
(Backend::array_constructor_expression): ... here.
(Gcc_backend::array_initializer): Rename to ...
(Backend::array_initializer): ... here.
(Gcc_backend::array_index_expression): Rename to ...
(Backend::array_index_expression): ... here.
(Gcc_backend::call_expression): Rename to ...
(Backend::call_expression): ... here.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/rust-backend.h
gcc/rust/rust-gcc.cc

index 082f6b977f99495bd7ad67690d8ab0829e566312..2c04f7aff81cc58c8688eaf4e6043afac04c43ca 100644 (file)
@@ -184,97 +184,81 @@ public:
   tree boolean_constant_expression (bool val);
 
   // Return an expression for the real part of BCOMPLEX.
-  virtual tree real_part_expression (tree bcomplex, location_t) = 0;
+  tree real_part_expression (tree bcomplex, location_t);
 
   // Return an expression for the imaginary part of BCOMPLEX.
-  virtual tree imag_part_expression (tree bcomplex, location_t) = 0;
+  tree imag_part_expression (tree bcomplex, location_t);
 
   // Return an expression for the complex number (BREAL, BIMAG).
-  virtual tree complex_expression (tree breal, tree bimag, location_t) = 0;
+  tree complex_expression (tree breal, tree bimag, location_t);
 
   // Return an expression that converts EXPR to TYPE.
-  virtual tree convert_expression (tree type, tree expr, location_t) = 0;
+  tree convert_expression (tree type, tree expr, location_t);
 
   // Return an expression for the field at INDEX in BSTRUCT.
-  virtual tree struct_field_expression (tree bstruct, size_t index, location_t)
-    = 0;
+  tree struct_field_expression (tree bstruct, size_t index, location_t);
 
   // Create an expression that executes BSTAT before BEXPR.
-  virtual tree compound_expression (tree bstat, tree bexpr, location_t) = 0;
+  tree compound_expression (tree bstat, tree bexpr, location_t);
 
   // Return an expression that executes THEN_EXPR if CONDITION is true, or
   // ELSE_EXPR otherwise and returns the result as type BTYPE, within the
   // specified function FUNCTION.  ELSE_EXPR may be NULL.  BTYPE may be NULL.
-  virtual tree conditional_expression (tree function, tree btype,
-                                      tree condition, tree then_expr,
-                                      tree else_expr, location_t)
-    = 0;
+  tree conditional_expression (tree function, tree btype, tree condition,
+                              tree then_expr, tree else_expr, location_t);
 
   // Return an expression for the negation operation OP EXPR.
   // Supported values of OP are enumerated in NegationOperator.
-  virtual tree negation_expression (NegationOperator op, tree expr, location_t)
-    = 0;
+  tree negation_expression (NegationOperator op, tree expr, location_t);
 
   // Return an expression for the operation LEFT OP RIGHT.
   // Supported values of OP are enumerated in ArithmeticOrLogicalOperator.
-  virtual tree arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op,
-                                                tree left, tree right,
-                                                location_t loc)
-    = 0;
+  tree arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op,
+                                        tree left, tree right, location_t loc);
 
   // Return an expression for the operation LEFT OP RIGHT.
   // Supported values of OP are enumerated in ArithmeticOrLogicalOperator.
   // This function adds overflow checking and returns a list of statements to
   // add to the current function context. The `receiver` variable refers to the
   // variable which will contain the result of that operation.
-  virtual tree
-  arithmetic_or_logical_expression_checked (ArithmeticOrLogicalOperator op,
-                                           tree left, tree right,
-                                           location_t loc, Bvariable *receiver)
-    = 0;
+  tree arithmetic_or_logical_expression_checked (ArithmeticOrLogicalOperator op,
+                                                tree left, tree right,
+                                                location_t loc,
+                                                Bvariable *receiver);
 
   // Return an expression for the operation LEFT OP RIGHT.
   // Supported values of OP are enumerated in ComparisonOperator.
-  virtual tree comparison_expression (ComparisonOperator op, tree left,
-                                     tree right, location_t loc)
-    = 0;
+  tree comparison_expression (ComparisonOperator op, tree left, tree right,
+                             location_t loc);
 
   // Return an expression for the operation LEFT OP RIGHT.
   // Supported values of OP are enumerated in LazyBooleanOperator.
-  virtual tree lazy_boolean_expression (LazyBooleanOperator op, tree left,
-                                       tree right, location_t)
-    = 0;
+  tree lazy_boolean_expression (LazyBooleanOperator op, tree left, tree right,
+                               location_t);
 
   // Return an expression that constructs BTYPE with VALS.  BTYPE must be the
   // backend representation a of struct.  VALS must be in the same order as the
   // corresponding fields in BTYPE.
-  virtual tree constructor_expression (tree btype, bool is_variant,
-                                      const std::vector<tree> &vals, int,
-                                      location_t)
-    = 0;
+  tree constructor_expression (tree btype, bool is_variant,
+                              const std::vector<tree> &vals, int, location_t);
 
   // Return an expression that constructs an array of BTYPE with INDEXES and
   // VALS.  INDEXES and VALS must have the same amount of elements. Each index
   // in INDEXES must be in the same order as the corresponding value in VALS.
-  virtual tree
-  array_constructor_expression (tree btype,
-                               const std::vector<unsigned long> &indexes,
-                               const std::vector<tree> &vals, location_t)
-    = 0;
+  tree array_constructor_expression (tree btype,
+                                    const std::vector<unsigned long> &indexes,
+                                    const std::vector<tree> &vals, location_t);
 
-  virtual tree array_initializer (tree, tree, tree, tree, tree, tree *,
-                                 location_t)
-    = 0;
+  tree array_initializer (tree, tree, tree, tree, tree, tree *, location_t);
 
   // Return an expression for ARRAY[INDEX] as an l-value.  ARRAY is a valid
   // fixed-length array, not a slice.
-  virtual tree array_index_expression (tree array, tree index, location_t) = 0;
+  tree array_index_expression (tree array, tree index, location_t);
 
   // Create an expression for a call to FN with ARGS, taking place within
   // caller CALLER.
-  virtual tree call_expression (tree fn, const std::vector<tree> &args,
-                               tree static_chain, location_t)
-    = 0;
+  tree call_expression (tree fn, const std::vector<tree> &args,
+                       tree static_chain, location_t);
 
   // Statements.
 
@@ -490,51 +474,6 @@ class Gcc_backend : public Backend
 {
 public:
   Gcc_backend ();
-
-  // Expressions.
-
-  tree real_part_expression (tree bcomplex, location_t);
-
-  tree imag_part_expression (tree bcomplex, location_t);
-
-  tree complex_expression (tree breal, tree bimag, location_t);
-
-  tree convert_expression (tree type, tree expr, location_t);
-
-  tree struct_field_expression (tree, size_t, location_t);
-
-  tree compound_expression (tree, tree, location_t);
-
-  tree conditional_expression (tree, tree, tree, tree, tree, location_t);
-
-  tree negation_expression (NegationOperator op, tree expr, location_t);
-
-  tree arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op,
-                                        tree left, tree right, location_t);
-
-  tree arithmetic_or_logical_expression_checked (ArithmeticOrLogicalOperator op,
-                                                tree left, tree right,
-                                                location_t,
-                                                Bvariable *receiver);
-
-  tree comparison_expression (ComparisonOperator op, tree left, tree right,
-                             location_t);
-
-  tree lazy_boolean_expression (LazyBooleanOperator op, tree left, tree right,
-                               location_t);
-
-  tree constructor_expression (tree, bool, const std::vector<tree> &, int,
-                              location_t);
-
-  tree array_constructor_expression (tree, const std::vector<unsigned long> &,
-                                    const std::vector<tree> &, location_t);
-
-  tree array_initializer (tree, tree, tree, tree, tree, tree *, location_t);
-
-  tree array_index_expression (tree array, tree index, location_t);
-
-  tree call_expression (tree fn, const std::vector<tree> &args,
-                       tree static_chain, location_t);
 };
 
 #endif // RUST_BACKEND_H
index 330772f9313f6dfbe80170faf0f76ce911ca8e7a..aae536c52b1900fe05703bc74755c92fa4af7f07 100644 (file)
@@ -891,7 +891,7 @@ Backend::boolean_constant_expression (bool val)
 // Return the real part of a complex expression.
 
 tree
-Gcc_backend::real_part_expression (tree complex_tree, location_t location)
+Backend::real_part_expression (tree complex_tree, location_t location)
 {
   if (complex_tree == error_mark_node)
     return error_mark_node;
@@ -905,7 +905,7 @@ Gcc_backend::real_part_expression (tree complex_tree, location_t location)
 // Return the imaginary part of a complex expression.
 
 tree
-Gcc_backend::imag_part_expression (tree complex_tree, location_t location)
+Backend::imag_part_expression (tree complex_tree, location_t location)
 {
   if (complex_tree == error_mark_node)
     return error_mark_node;
@@ -919,8 +919,8 @@ Gcc_backend::imag_part_expression (tree complex_tree, location_t location)
 // Make a complex expression given its real and imaginary parts.
 
 tree
-Gcc_backend::complex_expression (tree real_tree, tree imag_tree,
-                                location_t location)
+Backend::complex_expression (tree real_tree, tree imag_tree,
+                            location_t location)
 {
   if (real_tree == error_mark_node || imag_tree == error_mark_node)
     return error_mark_node;
@@ -936,8 +936,8 @@ Gcc_backend::complex_expression (tree real_tree, tree imag_tree,
 // An expression that converts an expression to a different type.
 
 tree
-Gcc_backend::convert_expression (tree type_tree, tree expr_tree,
-                                location_t location)
+Backend::convert_expression (tree type_tree, tree expr_tree,
+                            location_t location)
 {
   if (type_tree == error_mark_node || expr_tree == error_mark_node
       || TREE_TYPE (expr_tree) == error_mark_node)
@@ -970,8 +970,8 @@ Gcc_backend::convert_expression (tree type_tree, tree expr_tree,
 // Return an expression for the field at INDEX in BSTRUCT.
 
 tree
-Gcc_backend::struct_field_expression (tree struct_tree, size_t index,
-                                     location_t location)
+Backend::struct_field_expression (tree struct_tree, size_t index,
+                                 location_t location)
 {
   if (struct_tree == error_mark_node
       || TREE_TYPE (struct_tree) == error_mark_node)
@@ -1002,7 +1002,7 @@ Gcc_backend::struct_field_expression (tree struct_tree, size_t index,
 // Return an expression that executes BSTAT before BEXPR.
 
 tree
-Gcc_backend::compound_expression (tree stat, tree expr, location_t location)
+Backend::compound_expression (tree stat, tree expr, location_t location)
 {
   if (stat == error_mark_node || expr == error_mark_node)
     return error_mark_node;
@@ -1015,9 +1015,9 @@ Gcc_backend::compound_expression (tree stat, tree expr, location_t location)
 // ELSE_EXPR otherwise.
 
 tree
-Gcc_backend::conditional_expression (tree, tree type_tree, tree cond_expr,
-                                    tree then_expr, tree else_expr,
-                                    location_t location)
+Backend::conditional_expression (tree, tree type_tree, tree cond_expr,
+                                tree then_expr, tree else_expr,
+                                location_t location)
 {
   if (type_tree == error_mark_node || cond_expr == error_mark_node
       || then_expr == error_mark_node || else_expr == error_mark_node)
@@ -1127,8 +1127,8 @@ is_floating_point (tree t)
 
 // Return an expression for the negation operation OP EXPR.
 tree
-Gcc_backend::negation_expression (NegationOperator op, tree expr_tree,
-                                 location_t location)
+Backend::negation_expression (NegationOperator op, tree expr_tree,
+                             location_t location)
 {
   /* Check if the expression is an error, in which case we return an error
      expression. */
@@ -1163,9 +1163,9 @@ Gcc_backend::negation_expression (NegationOperator op, tree expr_tree,
 }
 
 tree
-Gcc_backend::arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op,
-                                              tree left, tree right,
-                                              location_t location)
+Backend::arithmetic_or_logical_expression (ArithmeticOrLogicalOperator op,
+                                          tree left, tree right,
+                                          location_t location)
 {
   /* Check if either expression is an error, in which case we return an error
      expression. */
@@ -1265,7 +1265,7 @@ fetch_overflow_builtins (ArithmeticOrLogicalOperator op)
 // Return an expression for the arithmetic or logical operation LEFT OP RIGHT
 // with overflow checking when possible
 tree
-Gcc_backend::arithmetic_or_logical_expression_checked (
+Backend::arithmetic_or_logical_expression_checked (
   ArithmeticOrLogicalOperator op, tree left, tree right, location_t location,
   Bvariable *receiver_var)
 {
@@ -1314,8 +1314,8 @@ Gcc_backend::arithmetic_or_logical_expression_checked (
 
 // Return an expression for the comparison operation LEFT OP RIGHT.
 tree
-Gcc_backend::comparison_expression (ComparisonOperator op, tree left_tree,
-                                   tree right_tree, location_t location)
+Backend::comparison_expression (ComparisonOperator op, tree left_tree,
+                               tree right_tree, location_t location)
 {
   /* Check if either expression is an error, in which case we return an error
      expression. */
@@ -1334,8 +1334,8 @@ Gcc_backend::comparison_expression (ComparisonOperator op, tree left_tree,
 
 // Return an expression for the lazy boolean operation LEFT OP RIGHT.
 tree
-Gcc_backend::lazy_boolean_expression (LazyBooleanOperator op, tree left_tree,
-                                     tree right_tree, location_t location)
+Backend::lazy_boolean_expression (LazyBooleanOperator op, tree left_tree,
+                                 tree right_tree, location_t location)
 {
   /* Check if either expression is an error, in which case we return an error
      expression. */
@@ -1356,9 +1356,9 @@ Gcc_backend::lazy_boolean_expression (LazyBooleanOperator op, tree left_tree,
 // Return an expression that constructs BTYPE with VALS.
 
 tree
-Gcc_backend::constructor_expression (tree type_tree, bool is_variant,
-                                    const std::vector<tree> &vals,
-                                    int union_index, location_t location)
+Backend::constructor_expression (tree type_tree, bool is_variant,
+                                const std::vector<tree> &vals, int union_index,
+                                location_t location)
 {
   if (type_tree == error_mark_node)
     return error_mark_node;
@@ -1468,7 +1468,7 @@ Gcc_backend::constructor_expression (tree type_tree, bool is_variant,
 }
 
 tree
-Gcc_backend::array_constructor_expression (
+Backend::array_constructor_expression (
   tree type_tree, const std::vector<unsigned long> &indexes,
   const std::vector<tree> &vals, location_t location)
 {
@@ -1522,9 +1522,9 @@ Gcc_backend::array_constructor_expression (
 // Build insns to create an array, initialize all elements of the array to
 // value, and return it
 tree
-Gcc_backend::array_initializer (tree fndecl, tree block, tree array_type,
-                               tree length, tree value, tree *tmp,
-                               location_t locus)
+Backend::array_initializer (tree fndecl, tree block, tree array_type,
+                           tree length, tree value, tree *tmp,
+                           location_t locus)
 {
   std::vector<tree> stmts;
 
@@ -1592,8 +1592,8 @@ Gcc_backend::array_initializer (tree fndecl, tree block, tree array_type,
 // Return an expression representing ARRAY[INDEX]
 
 tree
-Gcc_backend::array_index_expression (tree array_tree, tree index_tree,
-                                    location_t location)
+Backend::array_index_expression (tree array_tree, tree index_tree,
+                                location_t location)
 {
   if (array_tree == error_mark_node || TREE_TYPE (array_tree) == error_mark_node
       || index_tree == error_mark_node)
@@ -1615,8 +1615,8 @@ Gcc_backend::array_index_expression (tree array_tree, tree index_tree,
 
 // Create an expression for a call to FN_EXPR with FN_ARGS.
 tree
-Gcc_backend::call_expression (tree fn, const std::vector<tree> &fn_args,
-                             tree chain_expr, location_t location)
+Backend::call_expression (tree fn, const std::vector<tree> &fn_args,
+                         tree chain_expr, location_t location)
 {
   if (fn == error_mark_node || TREE_TYPE (fn) == error_mark_node)
     return error_mark_node;