diff options
author | Nate Begeman <natebegeman@mac.com> | 2009-01-18 01:01:34 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2009-01-18 01:01:34 +0000 |
commit | 3d309f9d62a6f9f634b869937139d533ccd7265b (patch) | |
tree | edebe93bfd90e6cf526952c13ce467d5b1c7e399 /lib/CodeGen/CGExprConstant.cpp | |
parent | 334a802eeb5acb959f99b8227ee995725b2624aa (diff) |
Add support for vectors to APValue. Vector constant evaluator and tests coming.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62438 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 72674f77fb..b7c4f7fd39 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -697,6 +697,19 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, return llvm::ConstantStruct::get(Complex, 2); } + case APValue::Vector: { + llvm::SmallVector<llvm::Constant *, 4> Inits; + unsigned NumElts = Result.Val.getVectorLength(); + + for (unsigned i = 0; i != NumElts; ++i) { + APValue &Elt = Result.Val.getVectorElt(i); + if (Elt.isInt()) + Inits.push_back(llvm::ConstantInt::get(Elt.getInt())); + else + Inits.push_back(llvm::ConstantFP::get(Elt.getFloat())); + } + return llvm::ConstantVector::get(&Inits[0], Inits.size()); + } } } |