diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-07-21 12:07:51 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-08-25 12:40:25 +0100 |
commit | 4fe7b96c2726322191c0eadd2c1c712afb3d0299 (patch) | |
tree | 117f357a9849069359e7bf8d0ffe4ce56bdd3d57 /gcc/rust/backend/rust-tree.h | |
parent | 8a9b94d8c3ac6c691fa49585756c0df234602d8b (diff) | |
download | gcc-4fe7b96c2726322191c0eadd2c1c712afb3d0299.zip gcc-4fe7b96c2726322191c0eadd2c1c712afb3d0299.tar.gz gcc-4fe7b96c2726322191c0eadd2c1c712afb3d0299.tar.bz2 |
Const functions need to be marked as DECL_DECLARED_CONSTEXPR_P
This signifys in the GCC generic that this is a constant function and
should be foldable in the constexpr evaluation. This also ports over the
correct eval_store_expression which updates the context tables.
CPP consteval seems pretty powerful but overall the algorithm is fairly
simple at least for simple types. When we encounter a CALL_EXPR we must
"bind" the arguments. So when we encourter a PARAM_DECL the associated
argument for this parameter is bound to this parameter in a map of
map<tree, tree> using their pointer as the key to value. So when folding
a function body every usage of the parameter decl is then updated in the
context with the apropriate value fomr the context. When we hit
assignment operations a similar context store occurs for VAR_DECLS.
While walking the tree We finally hit the RESULT_DECL with the folded
result. The complex pieces remaining are aggregate, record and union types
so that we have zero allocation required to find the result. We also need
to support walking conditionals and loop expressions which require porting
a few more functions and using the jump_target tree.
Diffstat (limited to 'gcc/rust/backend/rust-tree.h')
-rw-r--r-- | gcc/rust/backend/rust-tree.h | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/gcc/rust/backend/rust-tree.h b/gcc/rust/backend/rust-tree.h index 624f936..01de727 100644 --- a/gcc/rust/backend/rust-tree.h +++ b/gcc/rust/backend/rust-tree.h @@ -2425,13 +2425,13 @@ extern bool is_byte_access_type (tree); extern bool comptypes (tree, tree, int); -extern tree canonical_eh_spec (tree); +extern tree canonical_eh_spec (tree); -extern int cp_tree_operand_length (const_tree); +extern int cp_tree_operand_length (const_tree); -extern bool rs_tree_equal (tree, tree); +extern bool rs_tree_equal (tree, tree); -extern bool compparms (const_tree, const_tree); +extern bool compparms (const_tree, const_tree); extern tree rs_build_qualified_type_real (tree, int, tsubst_flags_t); @@ -2443,11 +2443,12 @@ extern bool similar_type_p (tree, tree); extern bool rs_tree_equal (tree, tree); -extern bool vector_targets_convertible_p (const_tree t1, const_tree t2); +extern bool +vector_targets_convertible_p (const_tree t1, const_tree t2); extern bool same_type_ignoring_top_level_qualifiers_p (tree, tree); -extern bool comp_ptr_ttypes_const (tree, tree, compare_bounds_t); +extern bool comp_ptr_ttypes_const (tree, tree, compare_bounds_t); extern tree get_class_binding_direct (tree, tree, bool want_type = false); @@ -2710,6 +2711,23 @@ vec_safe_push (releasing_vec &r, const tree &t CXX_MEM_STAT_INFO) } inline bool +vec_safe_reserve (releasing_vec &r, unsigned n, + bool e = false CXX_MEM_STAT_INFO) +{ + return vec_safe_reserve (*&r, n, e PASS_MEM_STAT); +} +inline unsigned +vec_safe_length (releasing_vec &r) +{ + return r->length (); +} +inline void +vec_safe_splice (releasing_vec &r, vec<tree, va_gc> *p CXX_MEM_STAT_INFO) +{ + vec_safe_splice (*&r, p PASS_MEM_STAT); +} + +inline bool null_node_p (const_tree expr) { STRIP_ANY_LOCATION_WRAPPER (expr); @@ -2730,6 +2748,9 @@ cxx_incomplete_type_error (const_tree value, const_tree type) cxx_incomplete_type_diagnostic (value, type, DK_ERROR); } +extern location_t +location_of (tree t); + } // namespace Rust #endif // RUST_TREE |