|
1 | 1 | //===---- CIRGenBuiltinAArch64.cpp - Emit CIR for AArch64 builtins --------===// |
2 | | -// |
3 | 2 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | 3 | // See https://llvm.org/LICENSE.txt for license information. |
5 | 4 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
@@ -88,6 +87,42 @@ findARMVectorIntrinsicInMap(ArrayRef<AArch64BuiltinInfo> intrinsicMap, |
88 | 87 | return nullptr; |
89 | 88 | } |
90 | 89 |
|
| 90 | +//===----------------------------------------------------------------------===// |
| 91 | +// Emit-helpers |
| 92 | +//===----------------------------------------------------------------------===// |
| 93 | +static mlir::Value |
| 94 | +emitAArch64CompareBuiltinExpr(CIRGenFunction &cgf, CIRGenBuilderTy &builder, |
| 95 | + mlir::Location loc, mlir::Value src, |
| 96 | + mlir::Type retTy, const cir::CmpOpKind kind) { |
| 97 | + |
| 98 | + bool scalarCmp = !isa<cir::VectorType>(src.getType()); |
| 99 | + if (!scalarCmp) { |
| 100 | + assert(cast<cir::VectorType>(retTy).getIsScalable() && |
| 101 | + "This is only intended for fixed-width vectors"); |
| 102 | + // Vector retTypes are cast to i8 vectors. Recover original retType. |
| 103 | + cgf.cgm.errorNYI(loc, std::string("unimplemented vector compare")); |
| 104 | + } |
| 105 | + |
| 106 | + mlir::Value zero = builder.getNullValue(src.getType(), loc); |
| 107 | + mlir::Value cmp; |
| 108 | + if (cir::isFPOrVectorOfFPType(src.getType())) { |
| 109 | + cgf.cgm.errorNYI(loc, std::string("unimplemented FP compare")); |
| 110 | + } else { |
| 111 | + if (scalarCmp) |
| 112 | + // For scalars, cast !cir.bool to !cir.int<s, 1> so that the compare |
| 113 | + // result is sign- rather zero-extended when casting to the output |
| 114 | + // retType. |
| 115 | + cmp = builder.createCast( |
| 116 | + loc, cir::CastKind::bool_to_int, |
| 117 | + builder.createCompare(loc, cir::CmpOpKind::eq, src, zero), |
| 118 | + builder.getSIntNTy(1)); |
| 119 | + else |
| 120 | + cgf.cgm.errorNYI(loc, std::string("unimplemented vector compare")); |
| 121 | + } |
| 122 | + |
| 123 | + return builder.createCast(loc, cir::CastKind::integral, cmp, retTy); |
| 124 | +} |
| 125 | + |
91 | 126 | bool CIRGenFunction::getAArch64SVEProcessedOperands( |
92 | 127 | unsigned builtinID, const CallExpr *expr, SmallVectorImpl<mlir::Value> &ops, |
93 | 128 | SVETypeFlags typeFlags) { |
@@ -1357,7 +1392,15 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned builtinID, const CallExpr *expr, |
1357 | 1392 | case NEON::BI__builtin_neon_vpaddd_s64: |
1358 | 1393 | case NEON::BI__builtin_neon_vpaddd_f64: |
1359 | 1394 | case NEON::BI__builtin_neon_vpadds_f32: |
| 1395 | + cgm.errorNYI(expr->getSourceRange(), |
| 1396 | + std::string("unimplemented AArch64 builtin call: ") + |
| 1397 | + getContext().BuiltinInfo.getName(builtinID)); |
| 1398 | + return mlir::Value{}; |
1360 | 1399 | case NEON::BI__builtin_neon_vceqzd_s64: |
| 1400 | + ops.push_back(emitScalarExpr(expr->getArg(0))); |
| 1401 | + return emitAArch64CompareBuiltinExpr( |
| 1402 | + *this, builder, loc, ops[0], |
| 1403 | + convertType(expr->getCallReturnType(getContext())), cir::CmpOpKind::eq); |
1361 | 1404 | case NEON::BI__builtin_neon_vceqzd_f64: |
1362 | 1405 | case NEON::BI__builtin_neon_vceqzs_f32: |
1363 | 1406 | case NEON::BI__builtin_neon_vceqzh_f16: |
|
0 commit comments