[llvm-commits] [llvm-gcc-4.0] r45919 - /llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
Chris Lattner
sabre at nondot.org
Sat Jan 12 16:21:21 PST 2008
Author: lattner
Date: Sat Jan 12 18:21:21 2008
New Revision: 45919
URL: http://llvm.org/viewvc/llvm-project?rev=45919&view=rev
Log:
Fix test/C++Frontend/2008-01-12-VecInit.cpp and rdar://5685492
Modified:
llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=45919&r1=45918&r2=45919&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Sat Jan 12 18:21:21 2008
@@ -6065,28 +6065,32 @@
Constant *TreeConstantToLLVM::ConvertArrayCONSTRUCTOR(tree exp) {
// Vectors are like arrays, but the domain is stored via an array
// type indirectly.
- assert(TREE_CODE(TREE_TYPE(exp)) != VECTOR_TYPE &&
- "VECTOR_TYPE's haven't been tested!");
- // If we have a lower bound for the range of the type, get it. */
- tree Domain = TYPE_DOMAIN(TREE_TYPE(exp));
+ // If we have a lower bound for the range of the type, get it.
+ tree InitType = TREE_TYPE(exp);
tree min_element = size_zero_node;
- if (Domain && TYPE_MIN_VALUE(Domain))
- min_element = fold_convert(sizetype, TYPE_MIN_VALUE(Domain));
-
std::vector<Constant*> ResultElts;
- Constant *SomeVal = 0;
- if (Domain && TYPE_MAX_VALUE(Domain)) {
- tree max_element = fold_convert(sizetype, TYPE_MAX_VALUE(Domain));
- tree size = size_binop (MINUS_EXPR, max_element, min_element);
- size = size_binop (PLUS_EXPR, size, size_one_node);
-
- if (host_integerp(size, 1))
- ResultElts.resize(tree_low_cst(size, 1));
+ if (TREE_CODE(InitType) == VECTOR_TYPE) {
+ ResultElts.resize(TYPE_VECTOR_SUBPARTS(InitType));
+ } else {
+ assert(TREE_CODE(InitType) == ARRAY_TYPE && "Unknown type for init");
+ tree Domain = TYPE_DOMAIN(InitType);
+ if (Domain && TYPE_MIN_VALUE(Domain))
+ min_element = fold_convert(sizetype, TYPE_MIN_VALUE(Domain));
+
+ if (Domain && TYPE_MAX_VALUE(Domain)) {
+ tree max_element = fold_convert(sizetype, TYPE_MAX_VALUE(Domain));
+ tree size = size_binop (MINUS_EXPR, max_element, min_element);
+ size = size_binop (PLUS_EXPR, size, size_one_node);
+
+ if (host_integerp(size, 1))
+ ResultElts.resize(tree_low_cst(size, 1));
+ }
}
-
+
unsigned NextFieldToFill = 0;
+ Constant *SomeVal = 0;
for (tree elt = CONSTRUCTOR_ELTS(exp); elt; elt = TREE_CHAIN(elt)) {
// Find and decode the constructor's value.
Constant *Val = Convert(TREE_VALUE(elt));
@@ -6158,6 +6162,11 @@
AllEltsSameType = false;
}
+ if (TREE_CODE(InitType) == VECTOR_TYPE) {
+ assert(AllEltsSameType && "Vector of heterogeneous element types?");
+ return ConstantVector::get(ResultElts);
+ }
+
if (AllEltsSameType)
return ConstantArray::get(ArrayType::get(ElTy, ResultElts.size()),
ResultElts);
More information about the llvm-commits
mailing list