diff options
author | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-05 09:53:17 +0200 |
---|---|---|
committer | Erick Ochoa <erick.ochoa@theobroma-systems.com> | 2020-06-05 09:53:17 +0200 |
commit | ddbfc0cf40c7806c1d9b0e251f86894b54c5a697 (patch) | |
tree | 01fce302bb7de949aa32a8c85b6fc9129745b9bd | |
parent | 43c64ce69e6bb70169394987d9cfbcf4f1fa932e (diff) |
updating interface
-rw-r--r-- | gcc/expr-walker.hpp | 8 | ||||
-rw-r--r-- | gcc/gimple-escaper.c | 8 | ||||
-rw-r--r-- | gcc/gimple-escaper.hpp | 10 | ||||
-rw-r--r-- | gcc/gimple-walker.c | 18 | ||||
-rw-r--r-- | gcc/gimple-walker.hpp | 4 | ||||
-rw-r--r-- | gcc/type-collector.c | 56 | ||||
-rw-r--r-- | gcc/type-collector.hpp | 56 | ||||
-rw-r--r-- | gcc/type-escaper.c | 16 | ||||
-rw-r--r-- | gcc/type-escaper.hpp | 18 | ||||
-rw-r--r-- | gcc/type-stringifier.c | 52 | ||||
-rw-r--r-- | gcc/type-stringifier.hpp | 36 | ||||
-rw-r--r-- | gcc/type-structural-equality.hpp | 12 | ||||
-rw-r--r-- | gcc/type-walker.c | 306 | ||||
-rw-r--r-- | gcc/type-walker.hpp | 113 |
14 files changed, 275 insertions, 438 deletions
diff --git a/gcc/expr-walker.hpp b/gcc/expr-walker.hpp index 42702bbf28d..e38084c8838 100644 --- a/gcc/expr-walker.hpp +++ b/gcc/expr-walker.hpp @@ -9,19 +9,19 @@ public: ExprWalker() {}; void walk(const_tree e); private: - virtual void _walk_pre(const_tree e) {}; + virtual void _walk_pre(__attribute__((unused)) const_tree e) {}; void _walk(const_tree e); - virtual void _walk_post(const_tree e) {}; + virtual void _walk_post(__attribute__((unused)) const_tree e) {}; inline void _walk_leaf(const_tree e, const enum tree_code c); inline void _walk_op_n(const_tree e, unsigned n); inline void _walk_op_0(const_tree e, const enum tree_code c); inline void _walk_op_1(const_tree e, const enum tree_code c); #define ExprWalkerFuncDecl(code) \ - virtual void _walk_ ## code ## _pre(const_tree e) {}; \ + virtual void _walk_ ## code ## _pre(__attribute__((unused)) const_tree e) {}; \ void walk_ ## code (const_tree e); \ void _walk_ ## code (const_tree e); \ - virtual void _walk_ ## code ## _post(const_tree e) {} + virtual void _walk_ ## code ## _post(__attribute__((unused)) const_tree e) {} ExprWalkerFuncDecl(CONSTRUCTOR); ExprWalkerFuncDecl(INTEGER_CST); diff --git a/gcc/gimple-escaper.c b/gcc/gimple-escaper.c index a71a588df2b..a3cd880c281 100644 --- a/gcc/gimple-escaper.c +++ b/gcc/gimple-escaper.c @@ -87,7 +87,7 @@ GimpleEscaper::filter_known_function(cgraph_node *node) } void -GimpleEscaper::_walk_pre(const_tree t) +GimpleEscaper::_walk_pre(__attribute__((unused)) const_tree t) { // Is any global variable escaping? Reason reason; @@ -95,7 +95,7 @@ GimpleEscaper::_walk_pre(const_tree t) } void -GimpleEscaper::_walk_pre(gassign *s) +GimpleEscaper::_walk_pre(__attribute__((unused)) gassign *s) { Reason reason; // We really should also walk over the different assigns... @@ -105,14 +105,14 @@ GimpleEscaper::_walk_pre(gassign *s) } void -GimpleEscaper::_walk_pre(greturn *s) +GimpleEscaper::_walk_pre(__attribute__((unused)) greturn *s) { Reason reason; //exprEscaper.update(expr, reason); } void -GimpleEscaper::_walk_pre(gcond *s) +GimpleEscaper::_walk_pre(__attribute__((unused)) gcond *s) { Reason reason; //exprEscaper.update(expr, reason); diff --git a/gcc/gimple-escaper.hpp b/gcc/gimple-escaper.hpp index 7ed2a89907e..447a4f83bee 100644 --- a/gcc/gimple-escaper.hpp +++ b/gcc/gimple-escaper.hpp @@ -14,9 +14,9 @@ private: void _init(); static bool filter_known_function(cgraph_node *); static bool is_function_escaping(cgraph_node *); - virtual void _walk_pre(const_tree) final; - virtual void _walk_pre(gassign *s) final; - virtual void _walk_pre(greturn *s) final; - virtual void _walk_pre(gcond *s) final; - virtual void _walk_pre(gcall *s) final; + virtual void _walk_pre(gassign *s) ; + virtual void _walk_pre(greturn *s) ; + virtual void _walk_pre(gcond *s) ; + virtual void _walk_pre(gcall *s) ; + virtual void _walk_pre(const_tree) ; }; diff --git a/gcc/gimple-walker.c b/gcc/gimple-walker.c index 4735960c076..cf7742c6862 100644 --- a/gcc/gimple-walker.c +++ b/gcc/gimple-walker.c @@ -47,7 +47,6 @@ GimpleWalker::walk() _walk_globals(); cgraph_node *node = NULL; - long unsigned i = 0; FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) { node->get_untransformed_body(); @@ -59,7 +58,6 @@ void GimpleWalker::_walk_globals() { varpool_node *vnode = NULL; - unsigned long i = 0; FOR_EACH_VARIABLE(vnode) { gcc_assert(vnode); @@ -205,14 +203,14 @@ GimpleWalker::walk (type e) \ } \ \ void \ -GimpleWalker::_walk (type e) \ +GimpleWalker::_walk (__attribute__((unused)) type e) \ { \ } -GimpleWalkerFuncDef(const_tree); -GimpleWalkerFuncDef(gassign *); -GimpleWalkerFuncDef(greturn *); -GimpleWalkerFuncDef(gcond *); -GimpleWalkerFuncDef(gcall *); -GimpleWalkerFuncDef(glabel *); -GimpleWalkerFuncDef(gswitch *); +GimpleWalkerFuncDef(const_tree) +GimpleWalkerFuncDef(gassign *) +GimpleWalkerFuncDef(greturn *) +GimpleWalkerFuncDef(gcond *) +GimpleWalkerFuncDef(gcall *) +GimpleWalkerFuncDef(glabel *) +GimpleWalkerFuncDef(gswitch *) diff --git a/gcc/gimple-walker.hpp b/gcc/gimple-walker.hpp index 7604cb7f505..219eb7b00b2 100644 --- a/gcc/gimple-walker.hpp +++ b/gcc/gimple-walker.hpp @@ -17,10 +17,10 @@ private: void _walk(basic_block bb); #define GimpleWalkerFuncDecl(type) \ - virtual void _walk_pre(type stmt) {}; \ + virtual void _walk_pre(__attribute__((unused)) type stmt) {}; \ void walk(type stmt); \ void _walk(type stmt); \ - virtual void _walk_post(type stmt) {} + virtual void _walk_post(__attribute__((unused)) type stmt) {} GimpleWalkerFuncDecl(const_tree); GimpleWalkerFuncDecl(gimple*); diff --git a/gcc/type-collector.c b/gcc/type-collector.c index d17dde42933..a199087ce56 100644 --- a/gcc/type-collector.c +++ b/gcc/type-collector.c @@ -92,85 +92,85 @@ TypeCollector::is_memoized(const_tree t) } void -TypeCollector::_walk_void_pre(const_tree t) +TypeCollector::_walk_VOID_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_void_post(const_tree t) +TypeCollector::_walk_VOID_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_integer_pre(const_tree t) +TypeCollector::_walk_INTEGER_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_integer_post(const_tree t) +TypeCollector::_walk_INTEGER_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_real_pre(const_tree t) +TypeCollector::_walk_REAL_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_real_post(const_tree t) +TypeCollector::_walk_REAL_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_fixed_point_pre(const_tree t) +TypeCollector::_walk_FIXED_POINT_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_fixed_point_post(const_tree t) +TypeCollector::_walk_FIXED_POINT_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_complex_pre(const_tree t) +TypeCollector::_walk_COMPLEX_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_complex_post(const_tree t) +TypeCollector::_walk_COMPLEX_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_enumeral_pre(const_tree t) +TypeCollector::_walk_ENUMERAL_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_enumeral_post(const_tree t) +TypeCollector::_walk_ENUMERAL_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_boolean_pre(const_tree t) +TypeCollector::_walk_BOOLEAN_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_boolean_post(const_tree t) +TypeCollector::_walk_BOOLEAN_TYPE_post(const_tree t) { _collect_simple(t); } @@ -183,43 +183,43 @@ TypeCollector::_collect_simple(const_tree t) } void -TypeCollector::_walk_array_pre(const_tree t) +TypeCollector::_walk_ARRAY_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_array_post(const_tree t) +TypeCollector::_walk_ARRAY_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_pointer_pre(const_tree t) +TypeCollector::_walk_POINTER_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_pointer_post(const_tree t) +TypeCollector::_walk_POINTER_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_reference_pre(const_tree t) +TypeCollector::_walk_REFERENCE_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_reference_post(const_tree t) +TypeCollector::_walk_REFERENCE_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_record_post(const_tree t) +TypeCollector::_walk_RECORD_TYPE_post(const_tree t) { // All in ptr point to record for (auto i = ptr.begin(), e = ptr.end(); i != e; ++i) @@ -230,43 +230,43 @@ TypeCollector::_walk_record_post(const_tree t) } void -TypeCollector::_walk_record_pre(const_tree t) +TypeCollector::_walk_RECORD_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_union_pre(const_tree t) +TypeCollector::_walk_UNION_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_union_post(const_tree t) +TypeCollector::_walk_UNION_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_function_post(const_tree t) +TypeCollector::_walk_FUNCTION_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_function_pre(const_tree t) +TypeCollector::_walk_FUNCTION_TYPE_pre(const_tree t) { ptr[t] = false; } void -TypeCollector::_walk_method_post(const_tree t) +TypeCollector::_walk_METHOD_TYPE_post(const_tree t) { _collect_simple(t); } void -TypeCollector::_walk_method_pre(const_tree t) +TypeCollector::_walk_METHOD_TYPE_pre(const_tree t) { ptr[t] = false; } diff --git a/gcc/type-collector.hpp b/gcc/type-collector.hpp index 44d7695ccc5..0252747ee9a 100644 --- a/gcc/type-collector.hpp +++ b/gcc/type-collector.hpp @@ -17,33 +17,33 @@ private: void _collect_simple(const_tree t); virtual bool is_memoized(const_tree t); - virtual void _walk_void_pre(const_tree t); - virtual void _walk_void_post(const_tree t); - virtual void _walk_integer_pre(const_tree t); - virtual void _walk_integer_post(const_tree t); - virtual void _walk_real_pre(const_tree t); - virtual void _walk_real_post(const_tree t); - virtual void _walk_fixed_point_pre(const_tree t); - virtual void _walk_fixed_point_post(const_tree t); - virtual void _walk_complex_pre(const_tree t); - virtual void _walk_complex_post(const_tree t); - virtual void _walk_enumeral_pre(const_tree t); - virtual void _walk_enumeral_post(const_tree t); - virtual void _walk_boolean_pre(const_tree t); - virtual void _walk_boolean_post(const_tree t); - virtual void _walk_array_pre(const_tree t); - virtual void _walk_array_post(const_tree t); - virtual void _walk_pointer_pre(const_tree t); - virtual void _walk_pointer_post(const_tree t); - virtual void _walk_reference_pre(const_tree t); - virtual void _walk_reference_post(const_tree t); - virtual void _walk_record_pre(const_tree t); - virtual void _walk_record_post(const_tree t); - virtual void _walk_union_pre(const_tree t); - virtual void _walk_union_post(const_tree t); - virtual void _walk_function_pre(const_tree t); - virtual void _walk_function_post(const_tree t); - virtual void _walk_method_pre(const_tree t); - virtual void _walk_method_post(const_tree t); + virtual void _walk_VOID_TYPE_pre(const_tree t); + virtual void _walk_VOID_TYPE_post(const_tree t); + virtual void _walk_INTEGER_TYPE_pre(const_tree t); + virtual void _walk_INTEGER_TYPE_post(const_tree t); + virtual void _walk_REAL_TYPE_pre(const_tree t); + virtual void _walk_REAL_TYPE_post(const_tree t); + virtual void _walk_FIXED_POINT_TYPE_pre(const_tree t); + virtual void _walk_FIXED_POINT_TYPE_post(const_tree t); + virtual void _walk_COMPLEX_TYPE_pre(const_tree t); + virtual void _walk_COMPLEX_TYPE_post(const_tree t); + virtual void _walk_ENUMERAL_TYPE_pre(const_tree t); + virtual void _walk_ENUMERAL_TYPE_post(const_tree t); + virtual void _walk_BOOLEAN_TYPE_pre(const_tree t); + virtual void _walk_BOOLEAN_TYPE_post(const_tree t); + virtual void _walk_ARRAY_TYPE_pre(const_tree t); + virtual void _walk_ARRAY_TYPE_post(const_tree t); + virtual void _walk_POINTER_TYPE_pre(const_tree t); + virtual void _walk_POINTER_TYPE_post(const_tree t); + virtual void _walk_REFERENCE_TYPE_pre(const_tree t); + virtual void _walk_REFERENCE_TYPE_post(const_tree t); + virtual void _walk_RECORD_TYPE_pre(const_tree t); + virtual void _walk_RECORD_TYPE_post(const_tree t); + virtual void _walk_UNION_TYPE_pre(const_tree t); + virtual void _walk_UNION_TYPE_post(const_tree t); + virtual void _walk_FUNCTION_TYPE_pre(const_tree t); + virtual void _walk_FUNCTION_TYPE_post(const_tree t); + virtual void _walk_METHOD_TYPE_pre(const_tree t); + virtual void _walk_METHOD_TYPE_post(const_tree t); }; diff --git a/gcc/type-escaper.c b/gcc/type-escaper.c index 32d39611ea1..0acceb1c8fb 100644 --- a/gcc/type-escaper.c +++ b/gcc/type-escaper.c @@ -65,31 +65,31 @@ TypeEscaper::_update(const_tree t) } void -TypeEscaper::_walk_array_pre(const_tree t) +TypeEscaper::_walk_ARRAY_TYPE_pre(const_tree t) { _update(t); } void -TypeEscaper::_walk_pointer_pre(const_tree t) +TypeEscaper::_walk_POINTER_TYPE_pre(const_tree t) { _update(t); } void -TypeEscaper::_walk_reference_pre(const_tree t) +TypeEscaper::_walk_REFERENCE_TYPE_pre(const_tree t) { _update(t); } void -TypeEscaper::_walk_record_pre(const_tree t) +TypeEscaper::_walk_RECORD_TYPE_pre(const_tree t) { _update(t); } void -TypeEscaper::_walk_union_pre(const_tree t) +TypeEscaper::_walk_UNION_TYPE_pre(const_tree t) { _inside_union++; bool is_escaping = _inside_union > 0; @@ -100,7 +100,7 @@ TypeEscaper::_walk_union_pre(const_tree t) } void -TypeEscaper::_walk_union_post(const_tree t) +TypeEscaper::_walk_UNION_TYPE_post(const_tree t) { _inside_union--; Reason prev = calc[t]; @@ -109,13 +109,13 @@ TypeEscaper::_walk_union_post(const_tree t) } void -TypeEscaper::_walk_function_pre(const_tree t) +TypeEscaper::_walk_FUNCTION_TYPEpre(const_tree t) { _update(t); } void -TypeEscaper::_walk_method_pre(const_tree t) +TypeEscaper::_walk_METHOD_TYPE_pre(const_tree t) { _update(t); } diff --git a/gcc/type-escaper.hpp b/gcc/type-escaper.hpp index ccd7534e293..b5b883fcbcc 100644 --- a/gcc/type-escaper.hpp +++ b/gcc/type-escaper.hpp @@ -7,19 +7,19 @@ class TypeEscaper : public TypeWalker { public: - TypeEscaper(ptrset_t &p) : _inside_union(0), _ptrset(p) {}; + TypeEscaper(ptrset_t &p) : _ptrset(p), _inside_union(0) {}; void update(const_tree t, Reason r); ptrset_t &_ptrset; typemap calc; private: - virtual void _walk_pointer_pre(const_tree t); - virtual void _walk_reference_pre(const_tree t); - virtual void _walk_array_pre(const_tree t); - virtual void _walk_record_pre(const_tree t); - virtual void _walk_union_pre(const_tree t); - virtual void _walk_union_post(const_tree t); - virtual void _walk_method_pre(const_tree t); - virtual void _walk_function_pre(const_tree t); + virtual void _walk_POINTER_TYPE_pre(const_tree t); + virtual void _walk_REFERENCE_TYPE_pre(const_tree t); + virtual void _walk_ARRAY_TYPE_pre(const_tree t); + virtual void _walk_RECORD_TYPE_pre(const_tree t); + virtual void _walk_UNION_TYPE_pre(const_tree t); + virtual void _walk_UNION_TYPE_post(const_tree t); + virtual void _walk_METHOD_TYPE_pre(const_tree t); + virtual void _walk_FUNCTION_TYPEpre(const_tree t); virtual bool is_memoized(const_tree t); unsigned _inside_union; Reason _reason; diff --git a/gcc/type-stringifier.c b/gcc/type-stringifier.c index 3b2a50604e0..39e4e0ec9dc 100644 --- a/gcc/type-stringifier.c +++ b/gcc/type-stringifier.c @@ -42,43 +42,43 @@ TypeStringifier::stringify(const_tree t) } void -TypeStringifier::_walk_void_pre(const_tree t) +TypeStringifier::_walk_VOID_TYPE_pre(const_tree t) { _stringify_simple(t); } void -TypeStringifier::_walk_integer_pre(const_tree t) +TypeStringifier::_walk_INTEGER_TYPE_pre(const_tree t) { _stringify_simple(t); } void -TypeStringifier::_walk_real_pre(const_tree t) +TypeStringifier::_walk_REAL_TYPE_pre(const_tree t) { _stringify_simple(t); } void -TypeStringifier::_walk_fixed_point_pre(const_tree t) +TypeStringifier::_walk_FIXED_POINT_TYPE_pre(const_tree t) { _stringify_simple(t); } void -TypeStringifier::_walk_complex_pre(const_tree t) +TypeStringifier::_walk_COMPLEX_TYPE_pre(const_tree t) { _stringify_simple(t); } void -TypeStringifier::_walk_offset_pre(const_tree t) +TypeStringifier::_walk_OFFSET_TYPE_pre(const_tree t) { _stringify_simple(t); } void -TypeStringifier::_walk_boolean_pre(const_tree t) +TypeStringifier::_walk_BOOLEAN_TYPE_pre(const_tree t) { _stringify_simple(t); } @@ -92,45 +92,45 @@ TypeStringifier::_stringify_simple(const_tree t) } void -TypeStringifier::_walk_pointer_post(const_tree t) +TypeStringifier::_walk_POINTER_TYPE_post(__attribute__((unused))const_tree t) { this->_stringification += std::string("*"); } void -TypeStringifier::_walk_array_post(const_tree t) +TypeStringifier::_walk_ARRAY_TYPE_post(__attribute__((unused))const_tree t) { this->_stringification += std::string("[]"); } void -TypeStringifier::_walk_reference_post(const_tree t) +TypeStringifier::_walk_REFERENCE_TYPE_post(__attribute__((unused))const_tree t) { this->_stringification += std::string("&"); } void -TypeStringifier::_walk_union_pre(const_tree t) +TypeStringifier::_walk_UNION_TYPE_pre(const_tree t) { this->_stringification += std::string(" union "); _stringify_aggregate_pre(t); } void -TypeStringifier::_walk_union_post(const_tree t) +TypeStringifier::_walk_UNION_TYPE_post(const_tree t) { _stringify_aggregate_post(t); } void -TypeStringifier::_walk_record_pre(const_tree t) +TypeStringifier::_walk_RECORD_TYPE_pre(const_tree t) { this->_stringification += std::string(" record "); _stringify_aggregate_pre(t); } void -TypeStringifier::_walk_record_post(const_tree t) +TypeStringifier::_walk_RECORD_TYPE_post(const_tree t) { _stringify_aggregate_post(t); } @@ -142,7 +142,7 @@ TypeStringifier::_stringify_aggregate_pre(const_tree t) } void -TypeStringifier::_stringify_aggregate_post(const_tree t) +TypeStringifier::_stringify_aggregate_post(__attribute__((unused))const_tree t) { this->_stringification += std::string("}"); } @@ -154,67 +154,67 @@ TypeStringifier::_walk_field_post(const_tree t) } void -TypeStringifier::_walk_method_pre(const_tree t) +TypeStringifier::_walk_METHOD_TYPE_pre(const_tree t) { _stringify_fm_pre(t); } void -TypeStringifier::_walk_method_post(const_tree t) +TypeStringifier::_walk_METHOD_TYPE_post(const_tree t) { _stringify_fm_post(t); } void -TypeStringifier::_walk_function_pre(const_tree t) +TypeStringifier::_walk_FUNCTION_TYPE_pre(const_tree t) { _stringify_fm_pre(t); } void -TypeStringifier::_walk_function_post(const_tree t) +TypeStringifier::_walk_FUNCTION_TYPE_post(const_tree t) { _stringify_fm_post(t); } void -TypeStringifier::_stringify_fm_pre(const_tree t) +TypeStringifier::_stringify_fm_pre(__attribute__((unused)) const_tree t) { this->_stringification += std::string("function { "); } void -TypeStringifier::_stringify_fm_post(const_tree t) +TypeStringifier::_stringify_fm_post(__attribute__((unused))const_tree t) { this->_stringification += std::string("}"); } void -TypeStringifier::_walk_return_pre(const_tree t) +TypeStringifier::_walk_return_pre(__attribute__((unused)) const_tree t) { this->_stringification += std::string("("); } void -TypeStringifier::_walk_return_post(const_tree t) +TypeStringifier::_walk_return_post(__attribute__((unused)) const_tree t) { this->_stringification += std::string(")"); } void -TypeStringifier::_walk_args_pre(const_tree t) +TypeStringifier::_walk_args_pre(__attribute__((unused)) const_tree t) { this->_stringification += std::string("("); } void -TypeStringifier::_walk_args_post(const_tree t) +TypeStringifier::_walk_args_post(__attribute__((unused)) const_tree t) { this->_stringification += std::string(")"); } void -TypeStringifier::_walk_arg_post(const_tree t) +TypeStringifier::_walk_arg_post(__attribute__((unused)) const_tree t) { this->_stringification += std::string(", "); } diff --git a/gcc/type-stringifier.hpp b/gcc/type-stringifier.hpp index 49e9054ab5e..25e43d34ab1 100644 --- a/gcc/type-stringifier.hpp +++ b/gcc/type-stringifier.hpp @@ -17,30 +17,30 @@ private: void _stringify_fm_pre(const_tree t); void _stringify_fm_post(const_tree t); - virtual void _walk_void_pre(const_tree t); - virtual void _walk_integer_pre(const_tree t); - virtual void _walk_real_pre(const_tree t); - virtual void _walk_fixed_point_pre(const_tree t); - virtual void _walk_complex_pre(const_tree t); - virtual void _walk_boolean_pre(const_tree t); - virtual void _walk_offset_pre(const_tree t); - virtual void _walk_pointer_post(const_tree t); - virtual void _walk_reference_post(const_tree t); - virtual void _walk_array_post(const_tree t); - virtual void _walk_record_pre(const_tree t); - virtual void _walk_record_post(const_tree t); - virtual void _walk_union_pre(const_tree t); - virtual void _walk_union_post(const_tree t); + virtual void _walk_VOID_TYPE_pre(const_tree t); + virtual void _walk_INTEGER_TYPE_pre(const_tree t); + virtual void _walk_REAL_TYPE_pre(const_tree t); + virtual void _walk_FIXED_POINT_TYPE_pre(const_tree t); + virtual void _walk_COMPLEX_TYPE_pre(const_tree t); + virtual void _walk_BOOLEAN_TYPE_pre(const_tree t); + virtual void _walk_OFFSET_TYPE_pre(const_tree t); + virtual void _walk_POINTER_TYPE_post(const_tree t); + virtual void _walk_REFERENCE_TYPE_post(const_tree t); + virtual void _walk_ARRAY_TYPE_post(const_tree t); + virtual void _walk_RECORD_TYPE_pre(const_tree t); + virtual void _walk_RECORD_TYPE_post(const_tree t); + virtual void _walk_UNION_TYPE_pre(const_tree t); + virtual void _walk_UNION_TYPE_post(const_tree t); virtual void _walk_field_post(const_tree t); virtual void _walk_return_pre(const_tree t); virtual void _walk_return_post(const_tree t); virtual void _walk_args_pre(const_tree t); virtual void _walk_args_post(const_tree t); virtual void _walk_arg_post(const_tree t); - virtual void _walk_method_pre(const_tree t); - virtual void _walk_method_post(const_tree t); - virtual void _walk_function_pre(const_tree t); - virtual void _walk_function_post(const_tree t); + virtual void _walk_METHOD_TYPE_pre(const_tree t); + virtual void _walk_METHOD_TYPE_post(const_tree t); + virtual void _walk_FUNCTION_TYPE_pre(const_tree t); + virtual void _walk_FUNCTION_TYPE_post(const_tree t); public: std::string stringify(const_tree t); TypeStringifier() {}; diff --git a/gcc/type-structural-equality.hpp b/gcc/type-structural-equality.hpp new file mode 100644 index 00000000000..66f2023c2ab --- /dev/null +++ b/gcc/type-structural-equality.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include "type-walker.hpp" + +class TypeStructuralEquality { +public: + TypeStructuralEquality() {}; + bool equal(const_tree a, const_tree b); +private: + bool are_equal; + const_tree left; +} diff --git a/gcc/type-walker.c b/gcc/type-walker.c index b74db433ee9..a1b6b421107 100644 --- a/gcc/type-walker.c +++ b/gcc/type-walker.c @@ -36,11 +36,11 @@ TypeWalker::walk(const_tree t) { gcc_assert(t); this->tset.clear(); - this->_walk(t, this->tset); + this->_walk(t); } void -TypeWalker::_walk(const_tree type, tset_t &tset) +TypeWalker::_walk(const_tree type) { gcc_assert(type); @@ -57,49 +57,49 @@ TypeWalker::_walk(const_tree type, tset_t &tset) switch (code) { case VOID_TYPE: - this->walk_void(type, tset); + this->walk_VOID_TYPE(type); break; case INTEGER_TYPE: - this->walk_integer(type, tset); + this->walk_INTEGER_TYPE(type); break; case REAL_TYPE: - this->walk_real(type, tset); + this->walk_REAL_TYPE(type); break; case FIXED_POINT_TYPE: - this->walk_fixed_point(type, tset); + this->walk_FIXED_POINT_TYPE(type); break; case COMPLEX_TYPE: - this->walk_complex(type, tset); + this->walk_COMPLEX_TYPE(type); break; case ENUMERAL_TYPE: - this->walk_enumeral(type, tset); + this->walk_ENUMERAL_TYPE(type); break; case BOOLEAN_TYPE: - this->walk_boolean(type, tset); + this->walk_BOOLEAN_TYPE(type); break; case OFFSET_TYPE: - this->walk_offset(type, tset); + this->walk_OFFSET_TYPE(type); break; case RECORD_TYPE: - this->walk_record(type, tset); + this->walk_RECORD_TYPE(type); break; case POINTER_TYPE: - this->walk_pointer(type, tset); + this->walk_POINTER_TYPE(type); break; case REFERENCE_TYPE: - this->walk_reference(type, tset); + this->walk_REFERENCE_TYPE(type); break; case ARRAY_TYPE: - this->walk_array(type, tset); + this->walk_ARRAY_TYPE(type); break; case UNION_TYPE: - this->walk_union(type, tset); + this->walk_UNION_TYPE(type); break; case FUNCTION_TYPE: - this->walk_function(type, tset); + this->walk_FUNCTION_TYPE(type); break; case METHOD_TYPE: - this->walk_method(type, tset); + this->walk_METHOD_TYPE(type); break; case QUAL_UNION_TYPE: case LANG_TYPE: @@ -114,293 +114,169 @@ TypeWalker::_walk(const_tree type, tset_t &tset) tset.erase(type); } -void -TypeWalker::walk_void(const_tree t, tset_t &tset) -{ - assert_is_type(t, VOID_TYPE); - _walk_void_pre(t); - _walk_void(t, tset); - _walk_void_post(t); -} -void -TypeWalker::_walk_void(const_tree t, tset_t &tset) {}; - -void -TypeWalker::walk_integer(const_tree t, tset_t &tset) -{ - assert_is_type(t, INTEGER_TYPE); - _walk_integer_pre(t); - _walk_integer(t, tset); - _walk_integer_post(t); +#define TypeWalkerFuncDef(code) \ +void \ +TypeWalker::walk_ ## code (const_tree t) \ +{ \ + assert_is_type(t, code); \ + _walk_ ## code ## _pre(t); \ + _walk_ ## code (t); \ + _walk_ ## code ## _post(t); \ } -void -TypeWalker::_walk_integer(const_tree t, tset_t &tset) {}; +#define TypeWalkerFuncDefInternal(code) \ +void TypeWalker::_walk_ ## code (__attribute__((unused)) const_tree t) {} -void -TypeWalker::walk_real(const_tree t, tset_t &tset) -{ - assert_is_type(t, REAL_TYPE); - _walk_real_pre(t); - _walk_real(t, tset); - _walk_real_post(t); -} +TypeWalkerFuncDef(VOID_TYPE) +TypeWalkerFuncDefInternal(VOID_TYPE) +TypeWalkerFuncDef(INTEGER_TYPE) +TypeWalkerFuncDefInternal(INTEGER_TYPE) +TypeWalkerFuncDef(REAL_TYPE) +TypeWalkerFuncDefInternal(REAL_TYPE) +TypeWalkerFuncDef(BOOLEAN_TYPE) +TypeWalkerFuncDefInternal(BOOLEAN_TYPE) +TypeWalkerFuncDef(OFFSET_TYPE) +TypeWalkerFuncDefInternal(OFFSET_TYPE) +TypeWalkerFuncDef(FIXED_POINT_TYPE) +TypeWalkerFuncDefInternal(FIXED_POINT_TYPE) +TypeWalkerFuncDef(COMPLEX_TYPE) +TypeWalkerFuncDefInternal(COMPLEX_TYPE) +TypeWalkerFuncDef(ENUMERAL_TYPE) +TypeWalkerFuncDefInternal(ENUMERAL_TYPE) void -TypeWalker::_walk_real(const_tree t, tset_t &tset) {}; - -void -TypeWalker::walk_boolean(const_tree t, tset_t &tset) -{ - assert_is_type(t, BOOLEAN_TYPE); - _walk_boolean_pre(t); - _walk_boolean(t, tset); - _walk_boolean_post(t); -} - -void -TypeWalker::_walk_boolean(const_tree t, tset_t &tset) {}; - -void -TypeWalker::walk_offset(const_tree t, tset_t &tset) -{ - assert_is_type(t, OFFSET_TYPE); - _walk_offset_pre(t); - _walk_offset(t, tset); - _walk_offset_post(t); -} - -void -TypeWalker::_walk_offset(const_tree t, tset_t &tset) {}; - -void -TypeWalker::walk_fixed_point(const_tree t, tset_t &tset) -{ - assert_is_type(t, FIXED_POINT_TYPE); - _walk_fixed_point_pre(t); - _walk_fixed_point(t, tset); - _walk_fixed_point_post(t); -} - -void -TypeWalker::_walk_fixed_point(const_tree t, tset_t &tset) {}; - -void -TypeWalker::walk_complex(const_tree t, tset_t &tset) -{ - assert_is_type(t, COMPLEX_TYPE); - _walk_complex_pre(t); - _walk_complex(t, tset); - _walk_complex_post(t); -} - -void -TypeWalker::_walk_complex(const_tree t, tset_t &tset) {}; - -void -TypeWalker::walk_enumeral(const_tree t, tset_t &tset) -{ - assert_is_type(t, ENUMERAL_TYPE); - _walk_enumeral_pre(t); - _walk_enumeral(t, tset); - _walk_enumeral_post(t); -} - -void -TypeWalker::_walk_enumeral(const_tree t, tset_t &tset) {}; - -void -TypeWalker::walk_pointer(const_tree t, tset_t &tset) -{ - assert_is_type(t, POINTER_TYPE); - _walk_pointer_pre(t); - _walk_pointer(t, tset); - _walk_pointer_post(t); -} - -void -TypeWalker::_walk_pointer(const_tree t, tset_t &tset) -{ - _walk_wrapper(t, tset); -} - -void -TypeWalker::walk_reference(const_tree t, tset_t &tset) -{ - assert_is_type(t, REFERENCE_TYPE); - _walk_reference_pre(t); - _walk_reference(t, tset); - _walk_reference_post(t); -} - -void -TypeWalker::_walk_reference(const_tree t, tset_t &tset) -{ - _walk_wrapper(t, tset); -} - -void -TypeWalker::walk_array(const_tree t, tset_t &tset) -{ - assert_is_type(t, ARRAY_TYPE); - _walk_array_pre(t); - _walk_array(t, tset); - _walk_array_post(t); -} - -void -TypeWalker::_walk_array(const_tree t, tset_t &tset) -{ - _walk_wrapper(t, tset); -} - -void -TypeWalker::_walk_wrapper(const_tree t, tset_t &tset) +TypeWalker::_walk_wrapper(const_tree t) { const_tree inner_type = TREE_TYPE(t); gcc_assert(inner_type); - _walk(inner_type, tset); + _walk(inner_type); } -void -TypeWalker::walk_record(const_tree t, tset_t &tset) -{ - assert_is_type(t, RECORD_TYPE); - _walk_record_pre(t); - _walk_record(t, tset); - _walk_record_post(t); +#define TypeWalkerFuncDefWrapper(code) \ +void \ +TypeWalker::_walk_ ## code (const_tree t) \ +{ \ + _walk_wrapper(t); \ } -void -TypeWalker::_walk_record(const_tree t, tset_t &tset) -{ - _walk_record_or_union(t, tset); -} +TypeWalkerFuncDef(POINTER_TYPE) +TypeWalkerFuncDefWrapper(POINTER_TYPE) +TypeWalkerFuncDefWrapper(REFERENCE_TYPE) +TypeWalkerFuncDef(REFERENCE_TYPE) +TypeWalkerFuncDef(ARRAY_TYPE) +TypeWalkerFuncDefWrapper(ARRAY_TYPE) + +TypeWalkerFuncDef(RECORD_TYPE) void -TypeWalker::walk_union(const_tree t, tset_t &tset) +TypeWalker::_walk_RECORD_TYPE(const_tree t) { - assert_is_type(t, UNION_TYPE); - _walk_union_pre(t); - _walk_union(t, tset); - _walk_union_post(t); + _walk_record_or_union(t); } +TypeWalkerFuncDef(UNION_TYPE) + void -TypeWalker::_walk_union(const_tree t, tset_t &tset) +TypeWalker::_walk_UNION_TYPE(const_tree t) { - _walk_record_or_union(t, tset); + _walk_record_or_union(t); } void -TypeWalker::_walk_record_or_union(const_tree t, tset_t &tset) +TypeWalker::_walk_record_or_union(const_tree t) { for (tree field = TYPE_FIELDS(t); field; field = DECL_CHAIN(field)) { gcc_assert(field); - walk_field(field, tset); + walk_field(field); } } void -TypeWalker::walk_field(const_tree t, tset_t &tset) +TypeWalker::walk_field(const_tree t) { _walk_field_pre(t); - _walk_field(t, tset); + _walk_field(t); _walk_field_post(t); } void -TypeWalker::_walk_field(const_tree t, tset_t &tset) +TypeWalker::_walk_field(const_tree t) { const_tree inner_type = TREE_TYPE(t); gcc_assert(inner_type); - _walk(inner_type, tset); + _walk(inner_type); } -void -TypeWalker::walk_function(const_tree t, tset_t &tset) -{ - assert_is_type(t, FUNCTION_TYPE); - _walk_function_pre(t); - _walk_function(t, tset); - _walk_function_post(t); -} +TypeWalkerFuncDef(FUNCTION_TYPE) void -TypeWalker::_walk_function(const_tree t, tset_t &tset) +TypeWalker::_walk_FUNCTION_TYPE(const_tree t) { - _walk_function_or_method(t, tset); + _walk_function_or_method(t); } -void -TypeWalker::walk_method(const_tree t, tset_t &tset) -{ - assert_is_type(t, METHOD_TYPE); - _walk_method_pre(t); - _walk_method(t, tset); - _walk_method_post(t); -} +TypeWalkerFuncDef(METHOD_TYPE) void -TypeWalker::_walk_method(const_tree t, tset_t &tset) +TypeWalker::_walk_METHOD_TYPE(const_tree t) { - _walk_function_or_method(t, tset); + _walk_function_or_method(t); } void -TypeWalker::_walk_function_or_method(const_tree t, tset_t &tset) +TypeWalker::_walk_function_or_method(const_tree t) { const_tree ret_type = TREE_TYPE(t); - walk_return(ret_type, tset); - walk_args(t, tset); + walk_return(ret_type); + walk_args(t); } void -TypeWalker::walk_return(const_tree t, tset_t &tset) +TypeWalker::walk_return(const_tree t) { _walk_return_pre(t); - _walk_return(t, tset); + _walk_return(t); _walk_return_post(t); } void -TypeWalker::_walk_return(const_tree t, tset_t &tset) +TypeWalker::_walk_return(const_tree t) { - _walk(t, tset); + _walk(t); } void -TypeWalker::walk_args(const_tree t, tset_t &tset) +TypeWalker::walk_args(const_tree t) { _walk_args_pre(t); - _walk_args(t, tset); + _walk_args(t); _walk_args_post(t); } void -TypeWalker::_walk_args(const_tree t, tset_t &tset) +TypeWalker::_walk_args(const_tree t) { assert_is_type(t, FUNCTION_TYPE); for (tree arg_node = TYPE_ARG_TYPES(t); NULL_TREE != arg_node; arg_node = TREE_CHAIN(arg_node)) { tree arg_node_type = TREE_VALUE(arg_node); gcc_assert(arg_node_type); - walk_arg(arg_node_type, tset); + walk_arg(arg_node_type); } } void -TypeWalker::walk_arg(const_tree t, tset_t &tset) +TypeWalker::walk_arg(const_tree t) { _walk_arg_pre(t); - _walk_arg(t, tset); + _walk_arg(t); _walk_arg_post(t); } void -TypeWalker::_walk_arg(const_tree t, tset_t &tset) +TypeWalker::_walk_arg(const_tree t) { - _walk(t, tset); + _walk(t); } diff --git a/gcc/type-walker.hpp b/gcc/type-walker.hpp index 2484843d135..1849b601bd4 100644 --- a/gcc/type-walker.hpp +++ b/gcc/type-walker.hpp @@ -13,87 +13,38 @@ protected: private: tset_t tset; - void _walk(const_tree t, tset_t &tset); - void _walk_wrapper(const_tree t, tset_t &tset); - void _walk_record_or_union(const_tree t, tset_t &tset); - void _walk_function_or_method(const_tree t, tset_t &tset); - virtual bool is_memoized(const_tree t) { return false; }; + void _walk(const_tree t); + void _walk_wrapper(const_tree t); + void _walk_record_or_union(const_tree t); + void _walk_function_or_method(const_tree t); + virtual bool is_memoized(__attribute__((unused))const_tree t) { return false; }; - virtual void _walk_void_pre(const_tree t) {}; - void walk_void(const_tree t, tset_t &tset); - void _walk_void(const_tree t, tset_t &tset); - virtual void _walk_void_post(const_tree t) {}; - virtual void _walk_integer_pre(const_tree t) {}; - void walk_integer(const_tree t, tset_t &tset); - void _walk_integer(const_tree t, tset_t &tset); - virtual void _walk_integer_post(const_tree t) {}; - virtual void _walk_real_pre(const_tree t) {}; - void walk_real(const_tree t, tset_t &tset); - void _walk_real(const_tree t, tset_t &tset); - virtual void _walk_real_post(const_tree t) {}; - virtual void _walk_fixed_point_pre(const_tree t) {}; - void walk_fixed_point(const_tree t, tset_t &tset); - void _walk_fixed_point(const_tree t, tset_t &tset); - virtual void _walk_fixed_point_post(const_tree t) {}; - virtual void _walk_complex_pre(const_tree t) {}; - void _walk_complex(const_tree t, tset_t &tset); - void walk_complex(const_tree t, tset_t &tset); - virtual void _walk_complex_post(const_tree t) {}; - virtual void _walk_enumeral_pre(const_tree t) {}; - void walk_enumeral(const_tree t, tset_t &tset); - void _walk_enumeral(const_tree t, tset_t &tset); - virtual void _walk_enumeral_post(const_tree t) {}; - virtual void _walk_boolean_pre(const_tree t) {}; - void walk_boolean(const_tree t, tset_t &tset); - void _walk_boolean(const_tree t, tset_t &tset); - virtual void _walk_boolean_post(const_tree t) {}; - virtual void _walk_offset_pre(const_tree t) {}; - void walk_offset(const_tree t, tset_t &tset); - void _walk_offset(const_tree t, tset_t &tset); - virtual void _walk_offset_post(const_tree t) {}; - virtual void _walk_record_pre(const_tree t) {}; - void walk_record(const_tree t, tset_t &tset); - void _walk_record(const_tree t, tset_t &tset); - virtual void _walk_record_post(const_tree t) {}; - virtual void _walk_pointer_pre(const_tree t) {}; - void walk_pointer(const_tree t, tset_t &tset); - void _walk_pointer(const_tree t, tset_t &tset); - virtual void _walk_pointer_post(const_tree t) {}; - virtual void _walk_reference_pre(const_tree t) {}; - void walk_reference(const_tree t, tset_t &tset); - void _walk_reference(const_tree t, tset_t &tset); - virtual void _walk_reference_post(const_tree t) {}; - virtual void _walk_array_pre(const_tree t) {}; - void walk_array(const_tree t, tset_t &tset); - void _walk_array(const_tree t, tset_t &tset); - virtual void _walk_array_post(const_tree t) {}; - virtual void _walk_union_pre(const_tree t) {}; - void walk_union(const_tree t, tset_t &tset); - void _walk_union(const_tree t, tset_t &tset); - virtual void _walk_union_post(const_tree t) {}; - virtual void _walk_field_pre(const_tree) {}; - void walk_field(const_tree t, tset_t &tset); - void _walk_field(const_tree t, tset_t &tset); - virtual void _walk_field_post(const_tree t) {}; - virtual void _walk_return_pre(const_tree t) {}; - void walk_return(const_tree, tset_t &tset); - void _walk_return(const_tree, tset_t &tset); - virtual void _walk_return_post(const_tree t) {}; - virtual void _walk_args_pre(const_tree t) {}; - void walk_args(const_tree t, tset_t &tset); - void _walk_args(const_tree t, tset_t &tset); - virtual void _walk_args_post(const_tree t) {}; - virtual void _walk_arg_pre(const_tree t) {}; - void walk_arg(const_tree t, tset_t &tset); - void _walk_arg(const_tree t, tset_t &tset); - virtual void _walk_arg_post(const_tree t) {}; - virtual void _walk_function_pre(const_tree t) {}; - void walk_function(const_tree t, tset_t &tset); - void _walk_function(const_tree t, tset_t &tset); - virtual void _walk_function_post(const_tree t) {}; - virtual void _walk_method_pre(const_tree t) {}; - void walk_method(const_tree t, tset_t &tset); - void _walk_method(const_tree t, tset_t &tset); - virtual void _walk_method_post(const_tree t) {}; +#define TypeWalkerFuncDecl(code) \ + virtual void _walk_ ## code ## _pre(__attribute__((unused)) const_tree t) {}; \ + void walk_ ## code (const_tree t); \ + virtual void _walk_ ## code (const_tree t); \ + virtual void _walk_ ## code ## _post(__attribute__((unused)) const_tree t) {} + + TypeWalkerFuncDecl(VOID_TYPE); + TypeWalkerFuncDecl(INTEGER_TYPE); + TypeWalkerFuncDecl(REAL_TYPE); + TypeWalkerFuncDecl(FIXED_POINT_TYPE); + TypeWalkerFuncDecl(COMPLEX_TYPE); + TypeWalkerFuncDecl(ENUMERAL_TYPE); + TypeWalkerFuncDecl(BOOLEAN_TYPE); + TypeWalkerFuncDecl(OFFSET_TYPE); + TypeWalkerFuncDecl(RECORD_TYPE); + TypeWalkerFuncDecl(POINTER_TYPE); + TypeWalkerFuncDecl(REFERENCE_TYPE); + TypeWalkerFuncDecl(ARRAY_TYPE); + TypeWalkerFuncDecl(UNION_TYPE); + TypeWalkerFuncDecl(FUNCTION_TYPE); + TypeWalkerFuncDecl(METHOD_TYPE); + + // These are not types... + TypeWalkerFuncDecl(field); + TypeWalkerFuncDecl(return); + TypeWalkerFuncDecl(args); + TypeWalkerFuncDecl(arg); }; |