diff options
author | crux <crux@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-06-24 19:26:42 +0000 |
---|---|---|
committer | crux <crux@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-06-24 19:26:42 +0000 |
commit | 8a95ab857c0aa88461aa4f10944825c98f32d0df (patch) | |
tree | db94b2c1a07d5c04365806edf03c813ecba575c1 /gcc/convert.c | |
parent | 2323093ea57b891515a0792298d5e3998ee8218d (diff) | |
download | gcc-8a95ab857c0aa88461aa4f10944825c98f32d0df.tar.gz |
Vector conversions support
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@34680 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/convert.c')
-rw-r--r-- | gcc/convert.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/gcc/convert.c b/gcc/convert.c index 56a9e829e70..6eea7d684c6 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -108,8 +108,8 @@ convert_to_real (type, expr) /* Convert EXPR to some integer (or enum) type TYPE. - EXPR must be pointer, integer, discrete (enum, char, or bool), or float; - in other cases error is called. + EXPR must be pointer, integer, discrete (enum, char, or bool), float, or + vector; in other cases error is called. The result of this is always supposed to be a newly created tree node not in use in any existing structure. */ @@ -383,6 +383,15 @@ convert_to_integer (type, expr) fold (build1 (REALPART_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: error ("aggregate value used where an integer was expected"); return convert (type, integer_zero_node); @@ -444,3 +453,29 @@ convert_to_complex (type, expr) 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); + } +} |