summaryrefslogtreecommitdiff
path: root/gcc/type-collector.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/type-collector.c')
-rw-r--r--gcc/type-collector.c237
1 files changed, 237 insertions, 0 deletions
diff --git a/gcc/type-collector.c b/gcc/type-collector.c
new file mode 100644
index 00000000000..af8778b8554
--- /dev/null
+++ b/gcc/type-collector.c
@@ -0,0 +1,237 @@
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "backend.h"
+#include "tree.h"
+#include "gimple-expr.h"
+#include "predict.h"
+#include "alloc-pool.h"
+#include "tree-pass.h"
+#include "cgraph.h"
+#include "diagnostic.h"
+#include "fold-const.h"
+#include "gimple-fold.h"
+#include "symbol-summary.h"
+#include "tree-vrp.h"
+#include "ipa-prop.h"
+#include "tree-pretty-print.h"
+#include "tree-inline.h"
+#include "ipa-fnsummary.h"
+#include "ipa-utils.h"
+#include "tree-ssa-ccp.h"
+#include "stringpool.h"
+#include "attribs.h"
+#include "tree-ssa-alias.h"
+#include "tree-ssanames.h"
+#include "gimple.h"
+#include "cfg.h"
+#include "gimple-iterator.h"
+#include "gimple-ssa.h"
+
+#include "type-collector.hpp"
+
+void
+TypeCollector::collect(const_tree t)
+{
+ const bool in_set = ptrset->in_universe(t);
+ // memoization...
+ if (in_set) return;
+ this->_points_to_record = false;
+ gcc_assert(ptrset && t);
+ gcc_assert(ptr.size() == 0);
+ walk(t);
+}
+
+bool
+TypeCollector::is_memoized(const_tree t)
+{
+ const bool in_set = ptrset->in_universe(t);
+ if (!in_set) return false;
+
+ const bool points_to_record = ptrset->in_points_to_record(t);
+ for (auto i = ptr.begin(), e = ptr.end(); i != e; ++i)
+ {
+ i->second = true;
+ }
+ return true;
+}
+
+void
+TypeCollector::_walk_void_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_void_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_integer_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_integer_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_real_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_real_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_fixed_point_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_fixed_point_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_complex_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_complex_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_enumeral_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_enumeral_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_boolean_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_boolean_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_collect_simple(const_tree t)
+{
+ ptrset->insert(t, ptr[t]);
+ ptr.erase(t);
+}
+
+void
+TypeCollector::_walk_array_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_array_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_pointer_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_pointer_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_reference_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_reference_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_record_post(const_tree t)
+{
+ // All in ptr point to record
+ for (auto i = ptr.begin(), e = ptr.end(); i != e; ++i)
+ {
+ i->second = true;
+ }
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_record_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_union_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_union_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_function_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_function_pre(const_tree t)
+{
+ ptr[t] = false;
+}
+
+void
+TypeCollector::_walk_method_post(const_tree t)
+{
+ _collect_simple(t);
+}
+
+void
+TypeCollector::_walk_method_pre(const_tree t)
+{
+ ptr[t] = false;
+}