Skip to content

Commit df4e726

Browse files
committed
extract prepareNeonCallArgs
1 parent 2a1df0b commit df4e726

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp

+30-23
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,9 @@ static const std::pair<unsigned, unsigned> NEONEquivalentIntrinsicMap[] = {
16541654
static const ARMVectorIntrinsicInfo AArch64SVEIntrinsicMap[] = {
16551655
#define GET_SVE_LLVM_INTRINSIC_MAP
16561656
#include "clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def"
1657+
16571658
#include "clang/Basic/arm_sve_builtin_cg.inc"
1659+
16581660
#undef GET_SVE_LLVM_INTRINSIC_MAP
16591661
};
16601662

@@ -1670,6 +1672,7 @@ static const ARMVectorIntrinsicInfo AArch64SVEIntrinsicMap[] = {
16701672
static const ARMVectorIntrinsicInfo AArch64SMEIntrinsicMap[] = {
16711673
#define GET_SME_LLVM_INTRINSIC_MAP
16721674
#include "clang/Basic/arm_sme_builtin_cg.inc"
1675+
16731676
#undef GET_SME_LLVM_INTRINSIC_MAP
16741677
};
16751678

@@ -2226,19 +2229,12 @@ static mlir::Value vecReduceIntValue(CIRGenFunction &cgf, mlir::Value val,
22262229
loc, val, builder.getConstInt(loc, cgf.SizeTy, 0));
22272230
}
22282231

2229-
static mlir::Value emitNeonCall(CIRGenBuilderTy &builder,
2232+
static void prepareNeonCallArgs(CIRGenBuilderTy &builder,
22302233
llvm::SmallVector<mlir::Type> argTypes,
22312234
llvm::SmallVectorImpl<mlir::Value> &args,
2232-
llvm::StringRef intrinsicName,
2233-
mlir::Type funcResTy, mlir::Location loc,
2234-
bool isConstrainedFPIntrinsic = false,
2235-
unsigned shift = 0, bool rightshift = false) {
2236-
// TODO: Consider removing the following unreachable when we have
2237-
// emitConstrainedFPCall feature implemented
2238-
assert(!cir::MissingFeatures::emitConstrainedFPCall());
2239-
if (isConstrainedFPIntrinsic)
2240-
llvm_unreachable("isConstrainedFPIntrinsic NYI");
2241-
2235+
mlir::Location loc,
2236+
bool isConstrainedFPIntrinsic, unsigned shift,
2237+
bool rightshift) {
22422238
for (unsigned j = 0; j < argTypes.size(); ++j) {
22432239
if (isConstrainedFPIntrinsic) {
22442240
assert(!cir::MissingFeatures::emitConstrainedFPCall());
@@ -2251,6 +2247,24 @@ static mlir::Value emitNeonCall(CIRGenBuilderTy &builder,
22512247
args[j] = builder.createBitcast(args[j], argTypes[j]);
22522248
}
22532249
}
2250+
}
2251+
2252+
static mlir::Value emitNeonCall(CIRGenBuilderTy &builder,
2253+
llvm::SmallVector<mlir::Type> argTypes,
2254+
llvm::SmallVectorImpl<mlir::Value> &args,
2255+
llvm::StringRef intrinsicName,
2256+
mlir::Type funcResTy, mlir::Location loc,
2257+
bool isConstrainedFPIntrinsic = false,
2258+
unsigned shift = 0, bool rightshift = false) {
2259+
// TODO: Consider removing the following unreachable when we have
2260+
// emitConstrainedFPCall feature implemented
2261+
assert(!cir::MissingFeatures::emitConstrainedFPCall());
2262+
if (isConstrainedFPIntrinsic)
2263+
llvm_unreachable("isConstrainedFPIntrinsic NYI");
2264+
2265+
prepareNeonCallArgs(builder, std::move(argTypes), args, loc,
2266+
isConstrainedFPIntrinsic, shift, rightshift);
2267+
22542268
if (isConstrainedFPIntrinsic) {
22552269
assert(!cir::MissingFeatures::emitConstrainedFPCall());
22562270
return nullptr;
@@ -2261,6 +2275,8 @@ static mlir::Value emitNeonCall(CIRGenBuilderTy &builder,
22612275
.getResult();
22622276
}
22632277

2278+
// This one is similar to the function above, except for creating an operation
2279+
// from template instead of creating a LLVMIntrinsicCallOp
22642280
template <typename Operation>
22652281
static mlir::Value
22662282
emitNeonCall(CIRGenBuilderTy &builder, llvm::SmallVector<mlir::Type> argTypes,
@@ -2273,18 +2289,9 @@ emitNeonCall(CIRGenBuilderTy &builder, llvm::SmallVector<mlir::Type> argTypes,
22732289
if (isConstrainedFPIntrinsic)
22742290
llvm_unreachable("isConstrainedFPIntrinsic NYI");
22752291

2276-
for (unsigned j = 0; j < argTypes.size(); ++j) {
2277-
if (isConstrainedFPIntrinsic) {
2278-
assert(!cir::MissingFeatures::emitConstrainedFPCall());
2279-
}
2280-
if (shift > 0 && shift == j) {
2281-
args[j] = emitNeonShiftVector(builder, args[j],
2282-
mlir::cast<cir::VectorType>(argTypes[j]),
2283-
loc, rightshift);
2284-
} else {
2285-
args[j] = builder.createBitcast(args[j], argTypes[j]);
2286-
}
2287-
}
2292+
prepareNeonCallArgs(builder, std::move(argTypes), args, loc,
2293+
isConstrainedFPIntrinsic, shift, rightshift);
2294+
22882295
if (isConstrainedFPIntrinsic) {
22892296
assert(!cir::MissingFeatures::emitConstrainedFPCall());
22902297
return nullptr;

0 commit comments

Comments
 (0)