/* Internal functions.
|
/* Internal functions.
|
Copyright (C) 2011 Free Software Foundation, Inc.
|
Copyright (C) 2011 Free Software Foundation, Inc.
|
|
|
This file is part of GCC.
|
This file is part of GCC.
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
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
|
the terms of the GNU General Public License as published by the Free
|
Software Foundation; either version 3, or (at your option) any later
|
Software Foundation; either version 3, or (at your option) any later
|
version.
|
version.
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
for more details.
|
for more details.
|
|
|
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
along with GCC; see the file COPYING3. If not see
|
along with GCC; see the file COPYING3. If not see
|
<http://www.gnu.org/licenses/>. */
|
<http://www.gnu.org/licenses/>. */
|
|
|
#include "config.h"
|
#include "config.h"
|
#include "system.h"
|
#include "system.h"
|
#include "coretypes.h"
|
#include "coretypes.h"
|
#include "internal-fn.h"
|
#include "internal-fn.h"
|
#include "tree.h"
|
#include "tree.h"
|
#include "expr.h"
|
#include "expr.h"
|
#include "optabs.h"
|
#include "optabs.h"
|
#include "gimple.h"
|
#include "gimple.h"
|
|
|
/* The names of each internal function, indexed by function number. */
|
/* The names of each internal function, indexed by function number. */
|
const char *const internal_fn_name_array[] = {
|
const char *const internal_fn_name_array[] = {
|
#define DEF_INTERNAL_FN(CODE, FLAGS) #CODE,
|
#define DEF_INTERNAL_FN(CODE, FLAGS) #CODE,
|
#include "internal-fn.def"
|
#include "internal-fn.def"
|
#undef DEF_INTERNAL_FN
|
#undef DEF_INTERNAL_FN
|
"<invalid-fn>"
|
"<invalid-fn>"
|
};
|
};
|
|
|
/* The ECF_* flags of each internal function, indexed by function number. */
|
/* The ECF_* flags of each internal function, indexed by function number. */
|
const int internal_fn_flags_array[] = {
|
const int internal_fn_flags_array[] = {
|
#define DEF_INTERNAL_FN(CODE, FLAGS) FLAGS,
|
#define DEF_INTERNAL_FN(CODE, FLAGS) FLAGS,
|
#include "internal-fn.def"
|
#include "internal-fn.def"
|
#undef DEF_INTERNAL_FN
|
#undef DEF_INTERNAL_FN
|
0
|
0
|
};
|
};
|
|
|
/* ARRAY_TYPE is an array of vector modes. Return the associated insn
|
/* ARRAY_TYPE is an array of vector modes. Return the associated insn
|
for load-lanes-style optab OPTAB. The insn must exist. */
|
for load-lanes-style optab OPTAB. The insn must exist. */
|
|
|
static enum insn_code
|
static enum insn_code
|
get_multi_vector_move (tree array_type, convert_optab optab)
|
get_multi_vector_move (tree array_type, convert_optab optab)
|
{
|
{
|
enum insn_code icode;
|
enum insn_code icode;
|
enum machine_mode imode;
|
enum machine_mode imode;
|
enum machine_mode vmode;
|
enum machine_mode vmode;
|
|
|
gcc_assert (TREE_CODE (array_type) == ARRAY_TYPE);
|
gcc_assert (TREE_CODE (array_type) == ARRAY_TYPE);
|
imode = TYPE_MODE (array_type);
|
imode = TYPE_MODE (array_type);
|
vmode = TYPE_MODE (TREE_TYPE (array_type));
|
vmode = TYPE_MODE (TREE_TYPE (array_type));
|
|
|
icode = convert_optab_handler (optab, imode, vmode);
|
icode = convert_optab_handler (optab, imode, vmode);
|
gcc_assert (icode != CODE_FOR_nothing);
|
gcc_assert (icode != CODE_FOR_nothing);
|
return icode;
|
return icode;
|
}
|
}
|
|
|
/* Expand LOAD_LANES call STMT. */
|
/* Expand LOAD_LANES call STMT. */
|
|
|
static void
|
static void
|
expand_LOAD_LANES (gimple stmt)
|
expand_LOAD_LANES (gimple stmt)
|
{
|
{
|
struct expand_operand ops[2];
|
struct expand_operand ops[2];
|
tree type, lhs, rhs;
|
tree type, lhs, rhs;
|
rtx target, mem;
|
rtx target, mem;
|
|
|
lhs = gimple_call_lhs (stmt);
|
lhs = gimple_call_lhs (stmt);
|
rhs = gimple_call_arg (stmt, 0);
|
rhs = gimple_call_arg (stmt, 0);
|
type = TREE_TYPE (lhs);
|
type = TREE_TYPE (lhs);
|
|
|
target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
|
target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
|
mem = expand_normal (rhs);
|
mem = expand_normal (rhs);
|
|
|
gcc_assert (MEM_P (mem));
|
gcc_assert (MEM_P (mem));
|
PUT_MODE (mem, TYPE_MODE (type));
|
PUT_MODE (mem, TYPE_MODE (type));
|
|
|
create_output_operand (&ops[0], target, TYPE_MODE (type));
|
create_output_operand (&ops[0], target, TYPE_MODE (type));
|
create_fixed_operand (&ops[1], mem);
|
create_fixed_operand (&ops[1], mem);
|
expand_insn (get_multi_vector_move (type, vec_load_lanes_optab), 2, ops);
|
expand_insn (get_multi_vector_move (type, vec_load_lanes_optab), 2, ops);
|
}
|
}
|
|
|
/* Expand STORE_LANES call STMT. */
|
/* Expand STORE_LANES call STMT. */
|
|
|
static void
|
static void
|
expand_STORE_LANES (gimple stmt)
|
expand_STORE_LANES (gimple stmt)
|
{
|
{
|
struct expand_operand ops[2];
|
struct expand_operand ops[2];
|
tree type, lhs, rhs;
|
tree type, lhs, rhs;
|
rtx target, reg;
|
rtx target, reg;
|
|
|
lhs = gimple_call_lhs (stmt);
|
lhs = gimple_call_lhs (stmt);
|
rhs = gimple_call_arg (stmt, 0);
|
rhs = gimple_call_arg (stmt, 0);
|
type = TREE_TYPE (rhs);
|
type = TREE_TYPE (rhs);
|
|
|
target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
|
target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
|
reg = expand_normal (rhs);
|
reg = expand_normal (rhs);
|
|
|
gcc_assert (MEM_P (target));
|
gcc_assert (MEM_P (target));
|
PUT_MODE (target, TYPE_MODE (type));
|
PUT_MODE (target, TYPE_MODE (type));
|
|
|
create_fixed_operand (&ops[0], target);
|
create_fixed_operand (&ops[0], target);
|
create_input_operand (&ops[1], reg, TYPE_MODE (type));
|
create_input_operand (&ops[1], reg, TYPE_MODE (type));
|
expand_insn (get_multi_vector_move (type, vec_store_lanes_optab), 2, ops);
|
expand_insn (get_multi_vector_move (type, vec_store_lanes_optab), 2, ops);
|
}
|
}
|
|
|
/* Routines to expand each internal function, indexed by function number.
|
/* Routines to expand each internal function, indexed by function number.
|
Each routine has the prototype:
|
Each routine has the prototype:
|
|
|
expand_<NAME> (gimple stmt)
|
expand_<NAME> (gimple stmt)
|
|
|
where STMT is the statement that performs the call. */
|
where STMT is the statement that performs the call. */
|
static void (*const internal_fn_expanders[]) (gimple) = {
|
static void (*const internal_fn_expanders[]) (gimple) = {
|
#define DEF_INTERNAL_FN(CODE, FLAGS) expand_##CODE,
|
#define DEF_INTERNAL_FN(CODE, FLAGS) expand_##CODE,
|
#include "internal-fn.def"
|
#include "internal-fn.def"
|
#undef DEF_INTERNAL_FN
|
#undef DEF_INTERNAL_FN
|
0
|
0
|
};
|
};
|
|
|
/* Expand STMT, which is a call to internal function FN. */
|
/* Expand STMT, which is a call to internal function FN. */
|
|
|
void
|
void
|
expand_internal_call (gimple stmt)
|
expand_internal_call (gimple stmt)
|
{
|
{
|
internal_fn_expanders[(int) gimple_call_internal_fn (stmt)] (stmt);
|
internal_fn_expanders[(int) gimple_call_internal_fn (stmt)] (stmt);
|
}
|
}
|
|
|