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