@@ -2351,6 +2351,26 @@ emitCommonNeonCallPattern0(CIRGenFunction &cgf, llvm::StringRef intrincsName,
2351
2351
return builder.createBitcast (res, resultType);
2352
2352
}
2353
2353
2354
+ // / The function `emitCommonNeonVecAcrossCall` implements a common way
2355
+ // / to implement neon intrinsic which has the following pattern:
2356
+ // / 1. There is only one argument which is of vector type
2357
+ // / 2. The result of the neon intrinsic is the element type of the input.
2358
+ // / This type of intrinsic usually is for across operations of the input vector.
2359
+
2360
+ static mlir::Value emitCommonNeonVecAcrossCall (CIRGenFunction &cgf,
2361
+ llvm::StringRef intrincsName,
2362
+ mlir::Type eltTy,
2363
+ unsigned vecLen,
2364
+ const clang::CallExpr *e) {
2365
+ CIRGenBuilderTy &builder = cgf.getBuilder ();
2366
+ mlir::Value op = cgf.emitScalarExpr (e->getArg (0 ));
2367
+ cir::VectorType vTy =
2368
+ cir::VectorType::get (&cgf.getMLIRContext (), eltTy, vecLen);
2369
+ llvm::SmallVector<mlir::Value, 1 > args{op};
2370
+ return emitNeonCall (builder, {vTy}, args, intrincsName, eltTy,
2371
+ cgf.getLoc (e->getExprLoc ()));
2372
+ }
2373
+
2354
2374
mlir::Value CIRGenFunction::emitCommonNeonBuiltinExpr (
2355
2375
unsigned builtinID, unsigned llvmIntrinsic, unsigned altLLVMIntrinsic,
2356
2376
const char *nameHint, unsigned modifier, const CallExpr *e,
@@ -4269,25 +4289,29 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
4269
4289
llvm_unreachable (" NEON::BI__builtin_neon_vaddvq_s16 NYI" );
4270
4290
}
4271
4291
case NEON::BI__builtin_neon_vmaxv_u8: {
4272
- llvm_unreachable (" NEON::BI__builtin_neon_vmaxv_u8 NYI" );
4292
+ return emitCommonNeonVecAcrossCall (*this , " aarch64.neon.umaxv" , UInt8Ty, 8 ,
4293
+ E);
4273
4294
}
4274
4295
case NEON::BI__builtin_neon_vmaxv_u16: {
4275
4296
llvm_unreachable (" NEON::BI__builtin_neon_vmaxv_u16 NYI" );
4276
4297
}
4277
4298
case NEON::BI__builtin_neon_vmaxvq_u8: {
4278
- llvm_unreachable (" NEON::BI__builtin_neon_vmaxvq_u8 NYI" );
4299
+ return emitCommonNeonVecAcrossCall (*this , " aarch64.neon.umaxv" , UInt8Ty, 16 ,
4300
+ E);
4279
4301
}
4280
4302
case NEON::BI__builtin_neon_vmaxvq_u16: {
4281
4303
llvm_unreachable (" NEON::BI__builtin_neon_vmaxvq_u16 NYI" );
4282
4304
}
4283
4305
case NEON::BI__builtin_neon_vmaxv_s8: {
4284
- llvm_unreachable (" NEON::BI__builtin_neon_vmaxv_s8 NYI" );
4306
+ return emitCommonNeonVecAcrossCall (*this , " aarch64.neon.smaxv" , SInt8Ty, 8 ,
4307
+ E);
4285
4308
}
4286
4309
case NEON::BI__builtin_neon_vmaxv_s16: {
4287
4310
llvm_unreachable (" NEON::BI__builtin_neon_vmaxv_s16 NYI" );
4288
4311
}
4289
4312
case NEON::BI__builtin_neon_vmaxvq_s8: {
4290
- llvm_unreachable (" NEON::BI__builtin_neon_vmaxvq_s8 NYI" );
4313
+ return emitCommonNeonVecAcrossCall (*this , " aarch64.neon.smaxv" , SInt8Ty, 16 ,
4314
+ E);
4291
4315
}
4292
4316
case NEON::BI__builtin_neon_vmaxvq_s16: {
4293
4317
llvm_unreachable (" NEON::BI__builtin_neon_vmaxvq_s16 NYI" );
0 commit comments