forked from OSchip/llvm-project
parent
43fc86d0f2
commit
b67e596d86
|
@ -121,14 +121,15 @@ public:
|
|||
Value *VisitPreDefinedExpr(Expr *E) { return EmitLValue(E).getAddress(); }
|
||||
|
||||
Value *VisitInitListExpr(InitListExpr *E) {
|
||||
std::vector<llvm::Constant *> Elements;
|
||||
unsigned N = E->getNumInits();
|
||||
QualType T = E->getInit(0)->getType();
|
||||
Value *V = llvm::UndefValue::get(llvm::VectorType::get(ConvertType(T), N));
|
||||
for (unsigned i = 0; i < N; ++i) {
|
||||
Value *V = Visit(E->getInit(i));
|
||||
llvm::Constant * C = cast<llvm::Constant>(V);
|
||||
Elements.push_back(C);
|
||||
Value *NewV = Visit(E->getInit(i));
|
||||
Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
|
||||
V = Builder.CreateInsertElement(V, NewV, Idx);
|
||||
}
|
||||
return llvm::ConstantVector::get(Elements);
|
||||
return V;
|
||||
}
|
||||
|
||||
Value *VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
|
||||
|
|
|
@ -22,3 +22,14 @@ static void test2() {
|
|||
vec2.yx = vec2; // reverse
|
||||
}
|
||||
|
||||
static void test3(float4 *out) {
|
||||
*out = ((float4) {1.0f, 2.0f, 3.0f, 4.0f });
|
||||
}
|
||||
|
||||
static void test4(float4 *out) {
|
||||
float a = 1.0f;
|
||||
float b = 2.0f;
|
||||
float c = 3.0f;
|
||||
float d = 4.0f;
|
||||
*out = ((float4) {a,b,c,d});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue