aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ"orn Rennecke <joern.rennecke@st.com>2009-05-19 18:21:53 +0000
committerJ"orn Rennecke <joern.rennecke@st.com>2009-05-19 18:21:53 +0000
commitb4b4d0949a3f5c5ab2c1d3e4ff55e497aace2c78 (patch)
treeec7e3c42ecd721e90d688ffde27d443f645bf0a9
parenta06ca79b36e9e214aae9c063945d6c91ba95e157 (diff)
* optabs.c (optab_for_tree_code_array): New array.
(optab_for_tree_code): Rename to... (optab_for_tree_code_1) ... this. * optabs.h: Include target.h. Make types at start of file non-target- specific. (enum optab_subtype): No longer target specific. (optab_for_tree_code_1, optab_for_tree_code_array): Declare. (optab_for_tree_code): New a static inline function. * target.h (struct gcc_target): New member target_arch. * tree-vectorizer.c (vectorize_loops): Use actually selected target architecture. * stor-layout.c (vector_type_mode_array): Declare. (vector_type_mode): Dispatch through vector_type_mode_array. [!EXTRA_TARGET]: (vector_type_mode_array): Define. * target-def.h (TARGET_INITIALIZER): Add TARGET_NUM. * Makefile.in (OPTABS_H): Add $(TARGET_H). * targhooks.c: Include diagnostic.h and tree-pass.h. (default_vectype_for_scalar_type): New function. * targhooks.h (default_vectype_for_scalar_type): Declare. * target.h (struct vectorize): New member vectype_for_scalar_type. toplev.c (backend_init): Set targetm_pnt at function start and after EXTRA_TARGETS_CALL. (lang_dependent_init): Likewise. * function.c (init_emit_array): Declare. [!EXTRA_TARGET] (init_emit_array): Define and initialize. (prepare_function_start): Call the init_emit function for cfun->target_arch. (init_dummy_function_start): Don't call init_emit. * tree-vectorizer.c (get_vectype_from_scalar_type): Remove. (vectorize_loops): Call vect_analyze_loops for all targets. Set loop_vinfo->target_arch to the selected target. * tree-vectorizer.h: Include target.h (struct loop_vec_info): New member target_arch. (get_vectype_for_scalar_type): Now a static incline function. * tree-vect-analyze.c (vect_analyze_loop): Show for which target we are doing the analysis. * emit-rtl.c (gen_reg_rtx): Add assert. * cfgexpand.c (gimple_expand_cfg): Don't call init_emit. * target-def.h (TARGET_VECTORIZE_VECTYPE_FOR_SCALAR_TYPE): Define. (TARGET_VECTORIZE): Add TARGET_VECTORIZE_VECTYPE_FOR_SCALAR_TYPE. * tree-flow.h (get_vectype_for_scalar_type): Don't declare. * Makefile.in (TREE_VECTORIZER_H): Set. Use it to replace tree-vectorizer.h in dependencies. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/arc-milepost-branch@147715 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.multi-target17
-rw-r--r--gcc/Makefile.in2
-rw-r--r--gcc/optabs.c14
-rw-r--r--gcc/optabs.h25
-rw-r--r--gcc/stor-layout.c11
-rw-r--r--gcc/target-def.h1
-rw-r--r--gcc/target.h4
-rw-r--r--gcc/tree-vectorizer.c3
8 files changed, 68 insertions, 9 deletions
diff --git a/gcc/ChangeLog.multi-target b/gcc/ChangeLog.multi-target
index 998668f965b..049f4441f52 100644
--- a/gcc/ChangeLog.multi-target
+++ b/gcc/ChangeLog.multi-target
@@ -1,5 +1,22 @@
2009-05-19 J"orn Rennecke <joern.rennecke@arc.com>
+ * optabs.c (optab_for_tree_code_array): New array.
+ (optab_for_tree_code): Rename to...
+ (optab_for_tree_code_1) ... this.
+ * optabs.h: Include target.h. Make types at start of file
+ non-target- specific.
+ (enum optab_subtype): No longer target specific.
+ (optab_for_tree_code_1, optab_for_tree_code_array): Declare.
+ (optab_for_tree_code): New a static inline function.
+ * target.h (struct gcc_target): New member target_arch.
+ * tree-vectorizer.c (vectorize_loops): Use actually selected target
+ architecture.
+ * stor-layout.c (vector_type_mode_array): Declare.
+ (vector_type_mode): Dispatch through vector_type_mode_array.
+ [!EXTRA_TARGET]: (vector_type_mode_array): Define.
+ * target-def.h (TARGET_INITIALIZER): Add TARGET_NUM.
+ * Makefile.in (OPTABS_H): Add $(TARGET_H).
+
* targhooks.c: Include diagnostic.h and tree-pass.h.
(default_vectype_for_scalar_type): New function.
* targhooks.h (default_vectype_for_scalar_type): Declare.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index d9a2232e227..0af8f5a5ef0 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -787,7 +787,7 @@ EMIT_RTL_H = emit-rtl.h
FLAGS_H = flags.h options.h
FUNCTION_H = function.h $(TREE_H) $(HASHTAB_H) varray.h
EXPR_H = expr.h insn-config.h $(FUNCTION_H) $(RTL_H) $(FLAGS_H) $(TREE_H) $(MACHMODE_H) $(EMIT_RTL_H)
-OPTABS_H = optabs.h insn-codes.h
+OPTABS_H = optabs.h insn-codes.h $(TARGET_H)
REGS_H = regs.h varray.h $(MACHMODE_H) $(OBSTACK_H) $(BASIC_BLOCK_H) $(FUNCTION_H)
RESOURCE_H = resource.h hard-reg-set.h
SCHED_INT_H = sched-int.h $(INSN_ATTR_H) $(BASIC_BLOCK_H) $(RTL_H) $(DF_H) vecprim.h
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 57ccfa422b6..c3b111d50ba 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -337,13 +337,21 @@ widen_operand (rtx op, enum machine_mode mode, enum machine_mode oldmode,
return result;
}
+#ifndef EXTRA_TARGET
+EXTRA_TARGETS_DECL (optab optab_for_tree_code_1 (enum tree_code, const_tree,
+ enum optab_subtype));
+optab
+ (*optab_for_tree_code_array[]) (enum tree_code, const_tree, enum optab_subtype)
+ = { optab_for_tree_code_1,
+ EXTRA_TARGETS_EXPAND_COMMA (&, optab_for_tree_code_1) };
+#endif
/* Return the optab used for computing the operation given by the tree code,
CODE and the tree EXP. This function is not always usable (for example, it
cannot give complete results for multiplication or division) but probably
ought to be relied on more widely throughout the expander. */
optab
-optab_for_tree_code (enum tree_code code, const_tree type,
- enum optab_subtype subtype)
+optab_for_tree_code_1 (enum tree_code code, const_tree type,
+ enum optab_subtype subtype)
{
bool trapv;
switch (code)
@@ -571,7 +579,7 @@ expand_widen_pattern_expr (tree exp, rtx op0, rtx op1, rtx wide_op, rtx target,
oprnd0 = TREE_OPERAND (exp, 0);
tmode0 = TYPE_MODE (TREE_TYPE (oprnd0));
widen_pattern_optab =
- optab_for_tree_code (TREE_CODE (exp), TREE_TYPE (oprnd0), optab_default);
+ optab_for_tree_code_1 (TREE_CODE (exp), TREE_TYPE (oprnd0), optab_default);
icode = (int) optab_handler (widen_pattern_optab, tmode0)->insn_code;
gcc_assert (icode != CODE_FOR_nothing);
xmode0 = insn_data[icode].operand[1].mode;
diff --git a/gcc/optabs.h b/gcc/optabs.h
index aec14827840..f5ce82fcf96 100644
--- a/gcc/optabs.h
+++ b/gcc/optabs.h
@@ -23,8 +23,7 @@ along with GCC; see the file COPYING3. If not see
#include "multi-target.h"
#include "insn-codes.h"
-
-START_TARGET_SPECIFIC
+#include "target.h"
/* Optabs are tables saying how to generate insn bodies
for various machine modes and numbers of operands.
@@ -375,6 +374,8 @@ enum optab_index
OTI_MAX
};
+START_TARGET_SPECIFIC
+
extern struct optab_d optab_table[OTI_MAX];
#define ssadd_optab (&optab_table[OTI_ssadd])
@@ -731,6 +732,7 @@ extern bool maybe_emit_unop_insn (int, rtx, rtx, enum rtx_code);
extern void emit_cmp_insn (rtx, rtx, enum rtx_code, rtx, enum machine_mode,
int);
+END_TARGET_SPECIFIC
/* An extra flag to control optab_for_tree_code's behavior. This is needed to
distinguish between machines with a vector shift that takes a scalar for the
shift amount vs. machines that take a vector for the shift amount. */
@@ -740,13 +742,26 @@ enum optab_subtype
optab_scalar,
optab_vector
};
+START_TARGET_SPECIFIC
/* Return the optab used for computing the given operation on the type given by
the second argument. The third argument distinguishes between the types of
vector shifts and rotates */
-/* FIXME: need a different interface to take optabs of extra targets into
- account. */
-extern optab optab_for_tree_code (enum tree_code, const_tree, enum optab_subtype);
+extern optab optab_for_tree_code_1 (enum tree_code, const_tree,
+ enum optab_subtype);
+extern optab (*optab_for_tree_code_array[]) (enum tree_code, const_tree,
+ enum optab_subtype);
+static inline optab
+optab_for_tree_code (enum tree_code code, const_tree type,
+ enum optab_subtype subtype)
+{
+#if NUM_TARGETS > 1
+ return (*optab_for_tree_code_array[targetm.target_arch]) (code, type,
+ subtype);
+#else
+ return optab_for_tree_code_1 (code, type, subtype);
+#endif
+}
/* The various uses that a comparison can have; used by can_compare_p:
jumps, conditional moves, store flag operations. */
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 25c06df6796..6af45482a05 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -39,6 +39,8 @@ along with GCC; see the file COPYING3. If not see
#include "params.h"
#include "multi-target.h"
+extern enum machine_mode (*vector_type_mode_array[]) (const_tree);
+
START_TARGET_SPECIFIC
/* Data type for the expressions representing sizes of data types.
@@ -1912,6 +1914,9 @@ vector_type_mode (const_tree t)
{
enum machine_mode mode;
+ if (&targetm != &this_targetm)
+ return (*vector_type_mode_array[targetm.target_arch]) (t);
+
gcc_assert (TREE_CODE (t) == VECTOR_TYPE);
mode = t->type.mode;
@@ -1936,6 +1941,12 @@ vector_type_mode (const_tree t)
return mode;
}
+
+#ifndef EXTRA_TARGET
+EXTRA_TARGETS_DECL (enum machine_mode vector_type_mode (const_tree));
+enum machine_mode (*vector_type_mode_array[]) (const_tree)
+ = { &vector_type_mode, EXTRA_TARGETS_EXPAND_COMMA (&, vector_type_mode) };
+#endif /* !EXTRA_TARGET */
/* Create and return a type for signed integers of PRECISION bits. */
diff --git a/gcc/target-def.h b/gcc/target-def.h
index 0ba1a86ce8b..374f30fedb1 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -845,6 +845,7 @@
#define TARGET_INITIALIZER \
{ \
TARGET_NAME, \
+ TARGET_NUM, \
TARGET_ASM_OUT, \
TARGET_SCHED, \
TARGET_VECTORIZE, \
diff --git a/gcc/target.h b/gcc/target.h
index dd328fe620c..2ae2c7c420c 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -698,6 +698,10 @@ struct gcc_target
this target for options, attributes and error messages. */
const char *name;
+ /* Position of this target vector in targetm_array.
+ Initialized with the Makefile-generated TARGET_NUM. */
+ int target_arch;
+
/* Functions that output assembler for the target. */
struct asm_out asm_out;
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index a05d2214d5f..706dafe2a26 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -2784,6 +2784,7 @@ vectorize_loops (void)
destroy_loop_vec_info (loop_vinfo, true);
targetm_pnt = targetm_array[best_arch];
loop_vinfo = vect_analyze_loop (loop);
+ target_arch = best_arch;
}
targetm_pnt = &this_targetm;
loop->aux = loop_vinfo;
@@ -2792,7 +2793,9 @@ vectorize_loops (void)
continue;
loop_vinfo->target_arch = target_arch;
+ targetm_pnt = targetm_array[target_arch];
vect_transform_loop (loop_vinfo);
+ targetm_pnt = &this_targetm;
num_vectorized_loops++;
}
vect_loop_location = UNKNOWN_LOC;