Commit 0b4565c9 by Bernd Schmidt Committed by Bernd Schmidt

Vector conversions support

From-SVN: r34680
parent cf036e71
2000-06-24 Bernd Schmidt <bernds@cygnus.co.uk>
* tree.def (VECTOR_TYPE): New node type.
* tree.h: Adjust some comments to reflect addition of vector types.
(TYPE_VECTOR_SUBPARTS): New macro.
* stor-layout.c (layout_type): Handle VECTOR_TYPE.
* c-convert.c (convert): Likewise.
* convert.c (convert_to_integer): Handle vector modes.
(convert_to_vector): New function.
* convert.h (convert_to_vector): Declare.
* expr.c (convert_move): Handle vector modes.
* expmed.c (extract_bit_field): Don't abort for vector modes.
2000-06-24 Marek Michalkiewicz <marekm@linux.org.pl> 2000-06-24 Marek Michalkiewicz <marekm@linux.org.pl>
* config/avr/avr-protos.h (avr_hard_regno_mode_ok): New prototype. * config/avr/avr-protos.h (avr_hard_regno_mode_ok): New prototype.
......
...@@ -94,6 +94,8 @@ convert (type, expr) ...@@ -94,6 +94,8 @@ convert (type, expr)
return fold (convert_to_real (type, e)); return fold (convert_to_real (type, e));
if (code == COMPLEX_TYPE) if (code == COMPLEX_TYPE)
return fold (convert_to_complex (type, e)); return fold (convert_to_complex (type, e));
if (code == VECTOR_TYPE)
return fold (convert_to_vector (type, e));
error ("conversion to non-scalar type requested"); error ("conversion to non-scalar type requested");
return error_mark_node; return error_mark_node;
......
...@@ -108,8 +108,8 @@ convert_to_real (type, expr) ...@@ -108,8 +108,8 @@ convert_to_real (type, expr)
/* Convert EXPR to some integer (or enum) type TYPE. /* Convert EXPR to some integer (or enum) type TYPE.
EXPR must be pointer, integer, discrete (enum, char, or bool), or float; EXPR must be pointer, integer, discrete (enum, char, or bool), float, or
in other cases error is called. vector; in other cases error is called.
The result of this is always supposed to be a newly created tree node The result of this is always supposed to be a newly created tree node
not in use in any existing structure. */ not in use in any existing structure. */
...@@ -383,6 +383,15 @@ convert_to_integer (type, expr) ...@@ -383,6 +383,15 @@ convert_to_integer (type, expr)
fold (build1 (REALPART_EXPR, fold (build1 (REALPART_EXPR,
TREE_TYPE (TREE_TYPE (expr)), expr))); TREE_TYPE (TREE_TYPE (expr)), expr)));
case VECTOR_TYPE:
if (GET_MODE_SIZE (TYPE_MODE (type))
!= GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr))))
{
error ("can't convert between vector values of different size");
return error_mark_node;
}
return build1 (NOP_EXPR, type, expr);
default: default:
error ("aggregate value used where an integer was expected"); error ("aggregate value used where an integer was expected");
return convert (type, integer_zero_node); return convert (type, integer_zero_node);
...@@ -444,3 +453,29 @@ convert_to_complex (type, expr) ...@@ -444,3 +453,29 @@ convert_to_complex (type, expr)
return convert_to_complex (type, integer_zero_node); return convert_to_complex (type, integer_zero_node);
} }
} }
/* Convert EXPR to the vector type TYPE in the usual ways. */
tree
convert_to_vector (type, expr)
tree type, expr;
{
tree subtype = TREE_TYPE (type);
switch (TREE_CODE (TREE_TYPE (expr)))
{
case INTEGER_TYPE:
case VECTOR_TYPE:
if (GET_MODE_SIZE (TYPE_MODE (type))
!= GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr))))
{
error ("can't convert between vector values of different size");
return error_mark_node;
}
return build1 (NOP_EXPR, type, expr);
default:
error ("can't convert value to a vector");
return convert_to_vector (type, integer_zero_node);
}
}
...@@ -22,3 +22,4 @@ extern tree convert_to_integer PARAMS ((tree, tree)); ...@@ -22,3 +22,4 @@ extern tree convert_to_integer PARAMS ((tree, tree));
extern tree convert_to_pointer PARAMS ((tree, tree)); extern tree convert_to_pointer PARAMS ((tree, tree));
extern tree convert_to_real PARAMS ((tree, tree)); extern tree convert_to_real PARAMS ((tree, tree));
extern tree convert_to_complex PARAMS ((tree, tree)); extern tree convert_to_complex PARAMS ((tree, tree));
extern tree convert_to_vector PARAMS ((tree, tree));
...@@ -1072,7 +1072,8 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp, ...@@ -1072,7 +1072,8 @@ extract_bit_field (str_rtx, bitsize, bitnum, unsignedp,
: bitpos == 0)))) : bitpos == 0))))
{ {
enum machine_mode mode1 enum machine_mode mode1
= mode_for_size (bitsize, GET_MODE_CLASS (tmode), 0); = (VECTOR_MODE_P (tmode) ? mode
: mode_for_size (bitsize, GET_MODE_CLASS (tmode), 0));
if (mode1 != GET_MODE (op0)) if (mode1 != GET_MODE (op0))
{ {
......
...@@ -545,6 +545,23 @@ convert_move (to, from, unsignedp) ...@@ -545,6 +545,23 @@ convert_move (to, from, unsignedp)
return; return;
} }
if (VECTOR_MODE_P (to_mode) || VECTOR_MODE_P (from_mode))
{
if (GET_MODE_BITSIZE (from_mode) != GET_MODE_BITSIZE (to_mode))
abort ();
if (VECTOR_MODE_P (to_mode))
from = gen_rtx_SUBREG (to_mode, from, 0);
else
to = gen_rtx_SUBREG (from_mode, to, 0);
emit_move_insn (to, from);
return;
}
if (to_real != from_real)
abort ();
if (to_real) if (to_real)
{ {
rtx value; rtx value;
......
...@@ -1286,6 +1286,17 @@ layout_type (type) ...@@ -1286,6 +1286,17 @@ layout_type (type)
TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type))); TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type)));
break; break;
case VECTOR_TYPE:
{
tree subtype;
subtype = TREE_TYPE (type);
TREE_UNSIGNED (type) = TREE_UNSIGNED (subtype);
TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (type)));
TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (TYPE_MODE (type)));
}
break;
case VOID_TYPE: case VOID_TYPE:
/* This is an incomplete type and so doesn't have a size. */ /* This is an incomplete type and so doesn't have a size. */
TYPE_ALIGN (type) = 1; TYPE_ALIGN (type) = 1;
......
...@@ -150,6 +150,10 @@ DEFTREECODE (REAL_TYPE, "real_type", 't', 0) ...@@ -150,6 +150,10 @@ DEFTREECODE (REAL_TYPE, "real_type", 't', 0)
of the real and imaginary parts. */ of the real and imaginary parts. */
DEFTREECODE (COMPLEX_TYPE, "complex_type", 't', 0) DEFTREECODE (COMPLEX_TYPE, "complex_type", 't', 0)
/* Vector types. The TREE_TYPE field is the data type of the vector
elements. */
DEFTREECODE (VECTOR_TYPE, "vector_type", 't', 0)
/* C enums. The type node looks just like an INTEGER_TYPE node. /* C enums. The type node looks just like an INTEGER_TYPE node.
The symbols for the values of the enum type are defined by The symbols for the values of the enum type are defined by
CONST_DECL nodes, but the type does not point to them; CONST_DECL nodes, but the type does not point to them;
......
...@@ -332,7 +332,8 @@ extern void tree_class_check_failed PARAMS ((const tree, int, ...@@ -332,7 +332,8 @@ extern void tree_class_check_failed PARAMS ((const tree, int,
/* In all nodes that are expressions, this is the data type of the expression. /* In all nodes that are expressions, this is the data type of the expression.
In POINTER_TYPE nodes, this is the type that the pointer points to. In POINTER_TYPE nodes, this is the type that the pointer points to.
In ARRAY_TYPE nodes, this is the type of the elements. */ In ARRAY_TYPE nodes, this is the type of the elements.
In VECTOR_TYPE nodes, this is the type of the elements. */
#define TREE_TYPE(NODE) ((NODE)->common.type) #define TREE_TYPE(NODE) ((NODE)->common.type)
/* Nodes are chained together for many purposes. /* Nodes are chained together for many purposes.
...@@ -1012,7 +1013,10 @@ struct tree_block ...@@ -1012,7 +1013,10 @@ struct tree_block
object of the given ARRAY_TYPE. This allows temporaries to be allocated. */ object of the given ARRAY_TYPE. This allows temporaries to be allocated. */
#define TYPE_ARRAY_MAX_SIZE(ARRAY_TYPE) TYPE_MAX_VALUE (ARRAY_TYPE) #define TYPE_ARRAY_MAX_SIZE(ARRAY_TYPE) TYPE_MAX_VALUE (ARRAY_TYPE)
/* Indicates that objects of this type must be initialized by calling a /* For a VECTOR_TYPE, this is the number of sub-parts of the vector. */
#define TYPE_VECTOR_SUBPARTS(VECTOR_TYPE) (GET_MODE_NUNITS (TYPE_CHECK (VECTOR_TYPE)->type.mode))
/* Indicates that objects of this type must be initialized by calling a
function when they are created. */ function when they are created. */
#define TYPE_NEEDS_CONSTRUCTING(NODE) \ #define TYPE_NEEDS_CONSTRUCTING(NODE) \
(TYPE_CHECK (NODE)->type.needs_constructing_flag) (TYPE_CHECK (NODE)->type.needs_constructing_flag)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment