summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-03-10 13:23:55 +0100
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-04-28 23:35:50 +0200
commitd719ddb69b9bc56b46f28689a7dc4d31f980f702 (patch)
tree4dd33781d695221d0837194240cfcc52d1938c36
parent987a8a810ecaaf065dac29b635dcd1d09e61b4dd (diff)
Initial commit of new pass
-rw-r--r--gcc/ipa-hello-world.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/gcc/ipa-hello-world.c b/gcc/ipa-hello-world.c
new file mode 100644
index 00000000000..9040a9360a6
--- /dev/null
+++ b/gcc/ipa-hello-world.c
@@ -0,0 +1,80 @@
+#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"
+
+
+static unsigned int
+iphw_execute()
+{
+ cgraph_node *node;
+ FOR_EACH_FUNCTION(node)
+ {
+ if (dump_file) fprintf(dump_file, "the name of the function is %s\n", node->dump_asm_name());
+
+ if (strcmp(node->dump_asm_name(), "bar/49") != 0) continue;
+
+ node->get_untransformed_body();
+ fprintf(dump_file, "we are where we need to be\n");
+ cgraph_node *clone = node->create_version_clone_with_body(
+ node->collect_callers(),
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ "helloworld",
+ NULL);
+ }
+ return 0;
+}
+
+namespace {
+const pass_data pass_data_ipa_hello_world =
+{
+ SIMPLE_IPA_PASS,
+ "hello_world",
+ OPTGROUP_NONE,
+ TV_NONE,
+ (PROP_cfg | PROP_ssa),
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+class pass_ipa_hello_world : public simple_ipa_opt_pass
+{
+public:
+ pass_ipa_hello_world (gcc::context *ctx)
+ : simple_ipa_opt_pass(pass_data_ipa_hello_world, ctx)
+ {}
+
+ virtual bool gate(function*) { return flag_ipa_hello_world; }
+ virtual unsigned execute (function*) { return iphw_execute(); }
+};
+} // anon namespace
+
+simple_ipa_opt_pass*
+make_pass_ipa_hello_world (gcc::context *ctx)
+{
+ return new pass_ipa_hello_world (ctx);
+}