@@ -2226,7 +2226,7 @@ static mlir::Value vecReduceIntValue(CIRGenFunction &cgf, mlir::Value val,
2226
2226
loc, val, builder.getConstInt (loc, cgf.SizeTy , 0 ));
2227
2227
}
2228
2228
2229
- mlir::Value emitNeonCall (CIRGenBuilderTy &builder,
2229
+ static mlir::Value emitNeonCall (CIRGenBuilderTy &builder,
2230
2230
llvm::SmallVector<mlir::Type> argTypes,
2231
2231
llvm::SmallVectorImpl<mlir::Value> &args,
2232
2232
llvm::StringRef intrinsicName, mlir::Type funcResTy,
@@ -2261,6 +2261,41 @@ mlir::Value emitNeonCall(CIRGenBuilderTy &builder,
2261
2261
.getResult ();
2262
2262
}
2263
2263
2264
+ template <typename Operation>
2265
+ static mlir::Value emitNeonCall (CIRGenBuilderTy &builder,
2266
+ llvm::SmallVector<mlir::Type> argTypes,
2267
+ llvm::SmallVectorImpl<mlir::Value> &args,
2268
+ mlir::Type funcResTy,
2269
+ mlir::Location loc,
2270
+ bool isConstrainedFPIntrinsic = false ,
2271
+ unsigned shift = 0 , bool rightshift = false ) {
2272
+ // TODO: Consider removing the following unreachable when we have
2273
+ // emitConstrainedFPCall feature implemented
2274
+ assert (!cir::MissingFeatures::emitConstrainedFPCall ());
2275
+ if (isConstrainedFPIntrinsic)
2276
+ llvm_unreachable (" isConstrainedFPIntrinsic NYI" );
2277
+
2278
+ for (unsigned j = 0 ; j < argTypes.size (); ++j) {
2279
+ if (isConstrainedFPIntrinsic) {
2280
+ assert (!cir::MissingFeatures::emitConstrainedFPCall ());
2281
+ }
2282
+ if (shift > 0 && shift == j) {
2283
+ args[j] = emitNeonShiftVector (builder, args[j],
2284
+ mlir::cast<cir::VectorType>(argTypes[j]),
2285
+ loc, rightshift);
2286
+ } else {
2287
+ args[j] = builder.createBitcast (args[j], argTypes[j]);
2288
+ }
2289
+ }
2290
+ if (isConstrainedFPIntrinsic) {
2291
+ assert (!cir::MissingFeatures::emitConstrainedFPCall ());
2292
+ return nullptr ;
2293
+ }
2294
+ return builder
2295
+ .create <Operation>(loc, funcResTy, args)
2296
+ .getResult ();
2297
+ }
2298
+
2264
2299
// / This function `emitCommonNeonCallPattern0` implements a common way
2265
2300
// / to generate neon intrinsic call that has following pattern:
2266
2301
// / 1. There is a need to cast result of the intrinsic call back to
@@ -4139,7 +4174,7 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
4139
4174
case NEON::BI__builtin_neon_vrndns_f32: {
4140
4175
mlir::Value arg0 = emitScalarExpr (E->getArg (0 ));
4141
4176
args.push_back (arg0);
4142
- return emitNeonCall (builder, {arg0.getType ()}, args, " roundeven.f32 " ,
4177
+ return emitNeonCall<cir::RoundEvenOp> (builder, {arg0.getType ()}, args,
4143
4178
getCIRGenModule ().FloatTy , getLoc (E->getExprLoc ()));
4144
4179
}
4145
4180
case NEON::BI__builtin_neon_vrndph_f16: {
0 commit comments