[clang] [CIR] Add math and builtin intrinsics support (PR #175233)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 29 12:51:52 PST 2026
================
@@ -1080,40 +1191,67 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
convertType(e->getType())));
}
case Builtin::BI__builtin_nondeterministic_value:
- case Builtin::BI__builtin_elementwise_abs:
return errorBuiltinNYI(*this, e, builtinID);
+ case Builtin::BI__builtin_elementwise_abs: {
+ mlir::Type cirTy = convertType(e->getArg(0)->getType());
+ bool isIntTy = cir::isIntOrVectorOfIntType(cirTy);
+ if (!isIntTy)
+ return emitUnaryFPBuiltin<cir::FAbsOp>(*this, *e);
+ mlir::Value arg = emitScalarExpr(e->getArg(0));
+ mlir::Value result = cir::AbsOp::create(builder, getLoc(e->getExprLoc()),
+ arg.getType(), arg, false);
+ return RValue::get(result);
+ }
case Builtin::BI__builtin_elementwise_acos:
----------------
andykaylor wrote:
Can you remove the redundant handlers?
https://github.com/llvm/llvm-project/pull/175233
More information about the cfe-commits
mailing list