diff options
author | Nate Begeman <natebegeman@mac.com> | 2008-01-25 05:34:48 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2008-01-25 05:34:48 +0000 |
commit | d47d4f518e43eaa716e2d18359bd725a03b87f58 (patch) | |
tree | 1a57ddf9a8f55ae9f4f97486879a3c4f66a68617 /CodeGen/CodeGenModule.cpp | |
parent | a99603333fffb57cf9ac37eabb190c8f5afc914b (diff) |
Support checking and codegen of constant vector globals
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46343 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CodeGenModule.cpp')
-rw-r--r-- | CodeGen/CodeGenModule.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp index bb61dc7cd8..e841ee5492 100644 --- a/CodeGen/CodeGenModule.cpp +++ b/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); |