Skip to content

Commit 19dc789

Browse files
ghehglanza
authored andcommitted
[CIR][CIRGen][Builtin][Neon] Lower neon_splat_lane, neon_splat_laneq, neon_splatq_lane and neon_splatq_laneq (llvm#1126)
1 parent e8bca05 commit 19dc789

File tree

2 files changed

+630
-0
lines changed

2 files changed

+630
-0
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,6 +2186,14 @@ static int64_t getIntValueFromConstOp(mlir::Value val) {
21862186
.getSExtValue();
21872187
}
21882188

2189+
static mlir::Value emitNeonSplat(CIRGenBuilderTy &builder, mlir::Location loc,
2190+
mlir::Value splatVec, mlir::Value splatLane,
2191+
unsigned int splatCnt) {
2192+
int64_t splatValInt = getIntValueFromConstOp(splatLane);
2193+
llvm::SmallVector<int64_t, 4> splatMask(splatCnt, splatValInt);
2194+
return builder.createVecShuffle(loc, splatVec, splatMask);
2195+
}
2196+
21892197
/// Build a constant shift amount vector of `vecTy` to shift a vector
21902198
/// Here `shitfVal` is a constant integer that will be splated into a
21912199
/// a const vector of `vecTy` which is the return of this function
@@ -2339,6 +2347,19 @@ mlir::Value CIRGenFunction::emitCommonNeonBuiltinExpr(
23392347
switch (builtinID) {
23402348
default:
23412349
break;
2350+
case NEON::BI__builtin_neon_splat_lane_v:
2351+
case NEON::BI__builtin_neon_splat_laneq_v:
2352+
case NEON::BI__builtin_neon_splatq_lane_v:
2353+
case NEON::BI__builtin_neon_splatq_laneq_v: {
2354+
uint64_t numElements = vTy.getSize();
2355+
if (builtinID == NEON::BI__builtin_neon_splatq_lane_v)
2356+
numElements = numElements << 1;
2357+
if (builtinID == NEON::BI__builtin_neon_splat_laneq_v)
2358+
numElements = numElements >> 1;
2359+
ops[0] = builder.createBitcast(ops[0], vTy);
2360+
return emitNeonSplat(builder, getLoc(e->getExprLoc()), ops[0], ops[1],
2361+
numElements);
2362+
}
23422363
case NEON::BI__builtin_neon_vmovl_v: {
23432364
cir::VectorType dTy = builder.getExtendedOrTruncatedElementVectorType(
23442365
vTy, false /* truncate */,

0 commit comments

Comments
 (0)