summaryrefslogtreecommitdiffstats
path: root/clang/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2008-01-25 05:34:48 +0000
committerNate Begeman <natebegeman@mac.com>2008-01-25 05:34:48 +0000
commit43eec490fbdabbfd6b4de437cfe88770872e8e1a (patch)
treed42893443fbd6db58c5b3d327efc7edbaccf01fb /clang/CodeGen/CodeGenModule.cpp
parent78c6cdf95e38b7356e351aaeebea486dd2ed849e (diff)
downloadbcm5719-llvm-43eec490fbdabbfd6b4de437cfe88770872e8e1a.tar.gz
bcm5719-llvm-43eec490fbdabbfd6b4de437cfe88770872e8e1a.zip
Support checking and codegen of constant vector globals
llvm-svn: 46343
Diffstat (limited to 'clang/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/CodeGen/CodeGenModule.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/CodeGen/CodeGenModule.cpp b/clang/CodeGen/CodeGenModule.cpp
index bb61dc7cd82..e841ee54926 100644
--- a/clang/CodeGen/CodeGenModule.cpp
+++ b/clang/CodeGen/CodeGenModule.cpp
@@ -300,7 +300,8 @@ static llvm::Constant *GenerateAggregateInit(const InitListExpr *ILE,
return 0;
}
- assert((ILE->getType()->isArrayType() || ILE->getType()->isStructureType()) &&
+ assert((ILE->getType()->isArrayType() || ILE->getType()->isStructureType() ||
+ ILE->getType()->isVectorType()) &&
"Bad type for init list!");
CodeGenTypes& Types = CGM.getTypes();
@@ -342,6 +343,9 @@ static llvm::Constant *GenerateAggregateInit(const InitListExpr *ILE,
if (ILE->getType()->isStructureType())
return llvm::ConstantStruct::get(cast<llvm::StructType>(CType), Elts);
+ if (ILE->getType()->isVectorType())
+ return llvm::ConstantVector::get(cast<llvm::VectorType>(CType), Elts);
+
// Make sure we have an array at this point
assert(AType);
@@ -417,6 +421,12 @@ static llvm::Constant *GenerateConstantExpr(const Expr *Expression,
return llvm::ConstantArray::get(Str, false);
}
+ // Generate initializer for the CompoundLiteral
+ case Stmt::CompoundLiteralExprClass: {
+ const CompoundLiteralExpr *CLE = cast<CompoundLiteralExpr>(Expression);
+ return GenerateConstantExpr(CLE->getInitializer(), CGM);
+ }
+
// Elide parenthesis.
case Stmt::ParenExprClass:
return GenerateConstantExpr(cast<ParenExpr>(Expression)->getSubExpr(), CGM);
OpenPOWER on IntegriCloud