aboutsummaryrefslogtreecommitdiff
path: root/gcc/convert.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/convert.c')
-rw-r--r--gcc/convert.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/gcc/convert.c b/gcc/convert.c
index 005d3e2089b..23d44ec5ae9 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -1,6 +1,6 @@
/* Utility routines for data type conversion for GCC.
Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1997, 1998,
- 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GCC.
@@ -30,6 +30,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "tree.h"
#include "flags.h"
#include "convert.h"
+/* APPLE LOCAL begin AltiVec */
+#include "c-tree.h"
+#include "c-common.h"
+/* APPLE LOCAL end AltiVec */
#include "toplev.h"
#include "langhooks.h"
#include "real.h"
@@ -722,6 +726,31 @@ convert_to_complex (tree type, tree expr)
}
}
+/* APPLE LOCAL begin AltiVec */
+/* Build a COMPOUND_LITERAL_EXPR. TYPE is the type given in the compound
+ literal. INIT is a CONSTRUCTOR that initializes the compound literal. */
+
+static tree
+build_compound_literal_vector (tree type, tree init)
+{
+ tree decl;
+ tree complit;
+ tree stmt;
+
+ decl = build_decl (VAR_DECL, NULL_TREE, type);
+ DECL_EXTERNAL (decl) = 0;
+ TREE_PUBLIC (decl) = 0;
+ TREE_USED (decl) = 1;
+ TREE_TYPE (decl) = type;
+ TREE_READONLY (decl) = TYPE_READONLY (type);
+ store_init_value (decl, init);
+ stmt = build_stmt (DECL_EXPR, decl);
+ complit = build1 (COMPOUND_LITERAL_EXPR, TREE_TYPE (decl), stmt);
+ layout_decl (decl, 0);
+ return complit;
+}
+/* APPLE LOCAL end AltiVec */
+
/* Convert EXPR to the vector type TYPE in the usual ways. */
tree
@@ -736,6 +765,14 @@ convert_to_vector (tree type, tree expr)
error ("can't convert between vector values of different size");
return error_mark_node;
}
+ /* APPLE LOCAL begin AltiVec */
+ if (TREE_CODE (type) == VECTOR_TYPE
+ && TREE_CODE (TREE_TYPE (expr)) == VECTOR_TYPE
+ && TREE_CODE (expr) == CONSTRUCTOR && TREE_CONSTANT (expr))
+ /* converting a constant vector to new vector type with Motorola Syntax. */
+ return convert (type, build_compound_literal_vector (TREE_TYPE (expr), expr));
+ /* APPLE LOCAL end AltiVec */
+
return build1 (NOP_EXPR, type, expr);
default: