@@ -2226,13 +2226,13 @@ 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,
2230
- llvm::SmallVector< mlir::Type> argTypes,
2231
- llvm::SmallVectorImpl <mlir::Value> &args ,
2232
- llvm::StringRef intrinsicName, mlir::Type funcResTy ,
2233
- mlir::Location loc ,
2234
- bool isConstrainedFPIntrinsic = false ,
2235
- unsigned shift = 0 , bool rightshift = false ) {
2229
+ template < typename Operation>
2230
+ static mlir::Value emitNeonCallToOp (
2231
+ CIRGenBuilderTy &builder, llvm::SmallVector <mlir::Type> argTypes ,
2232
+ llvm::SmallVectorImpl< mlir::Value> &args ,
2233
+ std::optional<llvm::StringRef> intrinsicName, mlir::Type funcResTy ,
2234
+ mlir::Location loc, bool isConstrainedFPIntrinsic = false ,
2235
+ unsigned shift = 0 , bool rightshift = false ) {
2236
2236
// TODO: Consider removing the following unreachable when we have
2237
2237
// emitConstrainedFPCall feature implemented
2238
2238
assert (!cir::MissingFeatures::emitConstrainedFPCall ());
@@ -2255,10 +2255,26 @@ mlir::Value emitNeonCall(CIRGenBuilderTy &builder,
2255
2255
assert (!cir::MissingFeatures::emitConstrainedFPCall ());
2256
2256
return nullptr ;
2257
2257
}
2258
- return builder
2259
- .create <cir::LLVMIntrinsicCallOp>(
2260
- loc, builder.getStringAttr (intrinsicName), funcResTy, args)
2261
- .getResult ();
2258
+ if constexpr (std::is_same_v<Operation, cir::LLVMIntrinsicCallOp>) {
2259
+ return builder
2260
+ .create <Operation>(loc, builder.getStringAttr (intrinsicName.value ()),
2261
+ funcResTy, args)
2262
+ .getResult ();
2263
+ } else {
2264
+ return builder.create <Operation>(loc, funcResTy, args).getResult ();
2265
+ }
2266
+ }
2267
+
2268
+ static mlir::Value emitNeonCall (CIRGenBuilderTy &builder,
2269
+ llvm::SmallVector<mlir::Type> argTypes,
2270
+ llvm::SmallVectorImpl<mlir::Value> &args,
2271
+ llvm::StringRef intrinsicName,
2272
+ mlir::Type funcResTy, mlir::Location loc,
2273
+ bool isConstrainedFPIntrinsic = false ,
2274
+ unsigned shift = 0 , bool rightshift = false ) {
2275
+ return emitNeonCallToOp<cir::LLVMIntrinsicCallOp>(
2276
+ builder, std::move (argTypes), args, intrinsicName, funcResTy, loc,
2277
+ isConstrainedFPIntrinsic, shift, rightshift);
2262
2278
}
2263
2279
2264
2280
// / This function `emitCommonNeonCallPattern0` implements a common way
@@ -4139,8 +4155,9 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
4139
4155
case NEON::BI__builtin_neon_vrndns_f32: {
4140
4156
mlir::Value arg0 = emitScalarExpr (E->getArg (0 ));
4141
4157
args.push_back (arg0);
4142
- return emitNeonCall (builder, {arg0.getType ()}, args, " roundeven.f32" ,
4143
- getCIRGenModule ().FloatTy , getLoc (E->getExprLoc ()));
4158
+ return emitNeonCallToOp<cir::RoundEvenOp>(
4159
+ builder, {arg0.getType ()}, args, std::nullopt,
4160
+ getCIRGenModule ().FloatTy , getLoc (E->getExprLoc ()));
4144
4161
}
4145
4162
case NEON::BI__builtin_neon_vrndph_f16: {
4146
4163
llvm_unreachable (" NEON::BI__builtin_neon_vrndph_f16 NYI" );
0 commit comments