Skip to content

Commit af5d41e

Browse files
committed
[clang][Interp] Support CXXScalarValueInitExprs of vector type
1 parent 2f9462e commit af5d41e

File tree

2 files changed

+45
-16
lines changed

2 files changed

+45
-16
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,26 +2292,54 @@ bool ByteCodeExprGen<Emitter>::VisitCXXScalarValueInitExpr(
22922292
if (std::optional<PrimType> T = classify(Ty))
22932293
return this->visitZeroInitializer(*T, Ty, E);
22942294

2295-
assert(Ty->isAnyComplexType());
2296-
if (!Initializing) {
2297-
std::optional<unsigned> LocalIndex = allocateLocal(E, /*IsExtended=*/false);
2298-
if (!LocalIndex)
2299-
return false;
2300-
if (!this->emitGetPtrLocal(*LocalIndex, E))
2301-
return false;
2295+
if (const auto *CT = Ty->getAs<ComplexType>()) {
2296+
if (!Initializing) {
2297+
std::optional<unsigned> LocalIndex =
2298+
allocateLocal(E, /*IsExtended=*/false);
2299+
if (!LocalIndex)
2300+
return false;
2301+
if (!this->emitGetPtrLocal(*LocalIndex, E))
2302+
return false;
2303+
}
2304+
2305+
// Initialize both fields to 0.
2306+
QualType ElemQT = CT->getElementType();
2307+
PrimType ElemT = classifyPrim(ElemQT);
2308+
2309+
for (unsigned I = 0; I != 2; ++I) {
2310+
if (!this->visitZeroInitializer(ElemT, ElemQT, E))
2311+
return false;
2312+
if (!this->emitInitElem(ElemT, I, E))
2313+
return false;
2314+
}
2315+
return true;
23022316
}
23032317

2304-
// Initialize both fields to 0.
2305-
QualType ElemQT = Ty->getAs<ComplexType>()->getElementType();
2306-
PrimType ElemT = classifyPrim(ElemQT);
2318+
if (const auto *VT = Ty->getAs<VectorType>()) {
2319+
// FIXME: Code duplication with the _Complex case above.
2320+
if (!Initializing) {
2321+
std::optional<unsigned> LocalIndex =
2322+
allocateLocal(E, /*IsExtended=*/false);
2323+
if (!LocalIndex)
2324+
return false;
2325+
if (!this->emitGetPtrLocal(*LocalIndex, E))
2326+
return false;
2327+
}
23072328

2308-
for (unsigned I = 0; I != 2; ++I) {
2309-
if (!this->visitZeroInitializer(ElemT, ElemQT, E))
2310-
return false;
2311-
if (!this->emitInitElem(ElemT, I, E))
2312-
return false;
2329+
// Initialize all fields to 0.
2330+
QualType ElemQT = VT->getElementType();
2331+
PrimType ElemT = classifyPrim(ElemQT);
2332+
2333+
for (unsigned I = 0, N = VT->getNumElements(); I != N; ++I) {
2334+
if (!this->visitZeroInitializer(ElemT, ElemQT, E))
2335+
return false;
2336+
if (!this->emitInitElem(ElemT, I, E))
2337+
return false;
2338+
}
2339+
return true;
23132340
}
2314-
return true;
2341+
2342+
return false;
23152343
}
23162344

23172345
template <class Emitter>

clang/test/CodeGenCXX/mangle-ms-vector-types.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -fms-extensions -fcxx-exceptions -ffreestanding -target-feature +avx -emit-llvm %s -o - -triple=i686-pc-win32 | FileCheck %s
2+
// RUN: %clang_cc1 -fms-extensions -fcxx-exceptions -ffreestanding -target-feature +avx -emit-llvm %s -o - -triple=i686-pc-win32 -fexperimental-new-constant-interpreter | FileCheck %s
23

34
#include <xmmintrin.h>
45
#include <emmintrin.h>

0 commit comments

Comments
 (0)