summaryrefslogtreecommitdiff
path: root/gcc/value-prof.c
diff options
context:
space:
mode:
authorrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-26 09:38:34 +0000
committerrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>2003-06-26 09:38:34 +0000
commitd81602c4c871ee8a316a89085e46be4d6e93b469 (patch)
treeabbc5dc1430427bc019442085e99307b6cf8b7de /gcc/value-prof.c
parentf4a23a545929be6a8d6af6f51324b34290d52ccf (diff)
downloadgcc-d81602c4c871ee8a316a89085e46be4d6e93b469.tar.gz
* value-prof.c: New.
* value-prof.h: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68521 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/value-prof.c')
-rw-r--r--gcc/value-prof.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
new file mode 100644
index 00000000000..1c8ff4ed917
--- /dev/null
+++ b/gcc/value-prof.c
@@ -0,0 +1,106 @@
+/* Transformations based on profile information for values.
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "rtl.h"
+#include "expr.h"
+#include "hard-reg-set.h"
+#include "basic-block.h"
+#include "value-prof.h"
+#include "output.h"
+#include "flags.h"
+#include "insn-config.h"
+#include "recog.h"
+#include "optabs.h"
+
+/* In this file value profile based optimizations will be placed (none are
+ here just now, but they are hopefully coming soon).
+
+ Every such optimization should add its requirements for profiled values to
+ insn_values_to_profile function. This function is called from branch_prob
+ in profile.c and the requested values are instrumented by it in the first
+ compilation with -fprofile-arcs. The optimization may then read the
+ gathered data in the second compilation with -fbranch-probablities (the
+ description of an exact way how to do it will be added here once the
+ code responsible for reading of the data is merged). */
+
+static void insn_values_to_profile (rtx, unsigned *, struct histogram_value **);
+
+/* Release the list of VALUES of length N_VALUES for that we want to measure
+ histograms. */
+void
+free_profiled_values (unsigned n_values ATTRIBUTE_UNUSED,
+ struct histogram_value *values)
+{
+ free (values);
+}
+
+/* Find values inside INSN for that we want to measure histograms and adds
+ them to list VALUES (increasing the record of its length in N_VALUES). */
+static void
+insn_values_to_profile (rtx insn ATTRIBUTE_UNUSED,
+ unsigned *n_values ATTRIBUTE_UNUSED,
+ struct histogram_value **values ATTRIBUTE_UNUSED)
+{
+}
+
+/* Find list of values for that we want to measure histograms. */
+void
+find_values_to_profile (unsigned *n_values, struct histogram_value **values)
+{
+ rtx insn;
+ unsigned i;
+
+ *n_values = 0;
+ *values = NULL;
+ for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
+ insn_values_to_profile (insn, n_values, values);
+
+ for (i = 0; i < *n_values; i++)
+ {
+ switch ((*values)[i].type)
+ {
+ case HIST_TYPE_INTERVAL:
+ (*values)[i].n_counters = (*values)[i].hdata.intvl.steps +
+ ((*values)[i].hdata.intvl.may_be_less ? 1 : 0) +
+ ((*values)[i].hdata.intvl.may_be_more ? 1 : 0);
+ break;
+
+ case HIST_TYPE_POW2:
+ (*values)[i].n_counters = GET_MODE_BITSIZE ((*values)[i].mode) +
+ ((*values)[i].hdata.pow2.may_be_other ? 1 : 0);
+ break;
+
+ case HIST_TYPE_SINGLE_VALUE:
+ (*values)[i].n_counters = 3;
+ break;
+
+ case HIST_TYPE_CONST_DELTA:
+ (*values)[i].n_counters = 4;
+ break;
+
+ default:
+ abort ();
+ }
+ }
+}