@@ -29,16 +29,6 @@ using namespace clang;
2929using namespace clang ::CIRGen;
3030using namespace llvm ;
3131
32- static mlir::Value tryUseTestFPKind (CIRGenFunction &cgf, unsigned BuiltinID,
33- mlir::Value V) {
34- if (cgf.getBuilder ().getIsFPConstrained () &&
35- cgf.getBuilder ().getDefaultConstrainedExcept () != cir::fp::ebIgnore) {
36- if (mlir::Value Result = cgf.getTargetHooks ().testFPKind (
37- V, BuiltinID, cgf.getBuilder (), cgf.cgm ))
38- return Result;
39- }
40- return nullptr ;
41- }
4232static RValue emitLibraryCall (CIRGenFunction &cgf, const FunctionDecl *fd,
4333 const CallExpr *e, mlir::Operation *calleeValue) {
4434 CIRGenCallee callee = CIRGenCallee::forDirect (calleeValue, GlobalDecl (fd));
@@ -533,36 +523,31 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
533523 // if the floating-point value, specified by the first argument, falls into
534524 // any of data classes, specified by the second argument.
535525 case Builtin::BI__builtin_isnan: {
536- CIRGenFunction::CIRGenFPOptionsRAII fpOptsRaii (* this , e );
526+ assert (! cir::MissingFeatures::cgFPOptionsRAII () );
537527 mlir::Value v = emitScalarExpr (e->getArg (0 ));
538- if (mlir::Value result = tryUseTestFPKind (*this , builtinID, v))
539- return RValue::get (result);
528+ assert (!cir::MissingFeatures::fpConstraints ());
540529 mlir::Location loc = getLoc (e->getBeginLoc ());
541- // FIXME: We should use builder.createZExt once createZExt is available.
542- return RValue::get (builder.createZExtOrBitCast (
543- loc, builder.createIsFPClass (loc, v, FPClassTest::fcNan),
530+ return RValue::get (builder.createBoolToInt (
531+ builder.createIsFPClass (loc, v, FPClassTest::fcNan),
544532 convertType (e->getType ())));
545533 }
546534
547535 case Builtin::BI__builtin_issignaling: {
548- CIRGenFunction::CIRGenFPOptionsRAII fpOptsRaii (* this , e );
536+ assert (! cir::MissingFeatures::cgFPOptionsRAII () );
549537 mlir::Value v = emitScalarExpr (e->getArg (0 ));
550538 mlir::Location loc = getLoc (e->getBeginLoc ());
551- // FIXME: We should use builder.createZExt once createZExt is available.
552- return RValue::get (builder.createZExtOrBitCast (
553- loc, builder.createIsFPClass (loc, v, FPClassTest::fcSNan),
539+ return RValue::get (builder.createBoolToInt (
540+ builder.createIsFPClass (loc, v, FPClassTest::fcSNan),
554541 convertType (e->getType ())));
555542 }
556543
557544 case Builtin::BI__builtin_isinf: {
558- CIRGenFunction::CIRGenFPOptionsRAII fpOptsRaii (* this , e );
545+ assert (! cir::MissingFeatures::cgFPOptionsRAII () );
559546 mlir::Value v = emitScalarExpr (e->getArg (0 ));
560- if (mlir::Value result = tryUseTestFPKind (*this , builtinID, v))
561- return RValue::get (result);
547+ assert (!cir::MissingFeatures::fpConstraints ());
562548 mlir::Location loc = getLoc (e->getBeginLoc ());
563- // FIXME: We should use builder.createZExt once createZExt is available.
564- return RValue::get (builder.createZExtOrBitCast (
565- loc, builder.createIsFPClass (loc, v, FPClassTest::fcInf),
549+ return RValue::get (builder.createBoolToInt (
550+ builder.createIsFPClass (loc, v, FPClassTest::fcInf),
566551 convertType (e->getType ())));
567552 }
568553
@@ -573,69 +558,62 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
573558 case Builtin::BIfinitel:
574559 case Builtin::BI__finitel:
575560 case Builtin::BI__builtin_isfinite: {
576- CIRGenFunction::CIRGenFPOptionsRAII fpOptsRaii (* this , e );
561+ assert (! cir::MissingFeatures::cgFPOptionsRAII () );
577562 mlir::Value v = emitScalarExpr (e->getArg (0 ));
578- if (mlir::Value result = tryUseTestFPKind (*this , builtinID, v))
579- return RValue::get (result);
563+ assert (!cir::MissingFeatures::fpConstraints ());
580564 mlir::Location loc = getLoc (e->getBeginLoc ());
581- // FIXME: We should use builder.createZExt once createZExt is available.
582- return RValue::get (builder.createZExtOrBitCast (
583- loc, builder.createIsFPClass (loc, v, FPClassTest::fcFinite),
565+ return RValue::get (builder.createBoolToInt (
566+ builder.createIsFPClass (loc, v, FPClassTest::fcFinite),
584567 convertType (e->getType ())));
585568 }
586569
587570 case Builtin::BI__builtin_isnormal: {
588- CIRGenFunction::CIRGenFPOptionsRAII fpOptsRaii (* this , e );
571+ assert (! cir::MissingFeatures::cgFPOptionsRAII () );
589572 mlir::Value v = emitScalarExpr (e->getArg (0 ));
590573 mlir::Location loc = getLoc (e->getBeginLoc ());
591- // FIXME: We should use builder.createZExt once createZExt is available.
592- return RValue::get (builder.createZExtOrBitCast (
593- loc, builder.createIsFPClass (loc, v, FPClassTest::fcNormal),
574+ return RValue::get (builder.createBoolToInt (
575+ builder.createIsFPClass (loc, v, FPClassTest::fcNormal),
594576 convertType (e->getType ())));
595577 }
596578
597579 case Builtin::BI__builtin_issubnormal: {
598- CIRGenFunction::CIRGenFPOptionsRAII fpOptsRaii (* this , e );
580+ assert (! cir::MissingFeatures::cgFPOptionsRAII () );
599581 mlir::Value v = emitScalarExpr (e->getArg (0 ));
600582 mlir::Location loc = getLoc (e->getBeginLoc ());
601- // FIXME: We should use builder.createZExt once createZExt is available.
602- return RValue::get (builder.createZExtOrBitCast (
603- loc, builder.createIsFPClass (loc, v, FPClassTest::fcSubnormal),
583+ return RValue::get (builder.createBoolToInt (
584+ builder.createIsFPClass (loc, v, FPClassTest::fcSubnormal),
604585 convertType (e->getType ())));
605586 }
606587
607588 case Builtin::BI__builtin_iszero: {
608- CIRGenFunction::CIRGenFPOptionsRAII fpOptsRaii (* this , e );
589+ assert (! cir::MissingFeatures::cgFPOptionsRAII () );
609590 mlir::Value v = emitScalarExpr (e->getArg (0 ));
610591 mlir::Location loc = getLoc (e->getBeginLoc ());
611- // FIXME: We should use builder.createZExt once createZExt is available.
612- return RValue::get (builder.createZExtOrBitCast (
613- loc, builder.createIsFPClass (loc, v, FPClassTest::fcZero),
592+ return RValue::get (builder.createBoolToInt (
593+ builder.createIsFPClass (loc, v, FPClassTest::fcZero),
614594 convertType (e->getType ())));
615595 }
616596 case Builtin::BI__builtin_isfpclass: {
617597 Expr::EvalResult result;
618598 if (!e->getArg (1 )->EvaluateAsInt (result, cgm.getASTContext ()))
619599 break ;
620600
621- CIRGenFunction::CIRGenFPOptionsRAII fpOptsRaii (* this , e );
601+ assert (! cir::MissingFeatures::cgFPOptionsRAII () );
622602 mlir::Value v = emitScalarExpr (e->getArg (0 ));
623603 uint64_t test = result.Val .getInt ().getLimitedValue ();
624604 mlir::Location loc = getLoc (e->getBeginLoc ());
625605 //
626- // // FIXME: We should use builder.createZExt once createZExt is available.
627- return RValue::get (builder.createZExtOrBitCast (
628- loc, builder.createIsFPClass (loc, v, test), convertType (e->getType ())));
606+ return RValue::get (builder.createBoolToInt (
607+ builder.createIsFPClass (loc, v, test), convertType (e->getType ())));
629608 }
630609 }
631610
632611 // If this is an alias for a lib function (e.g. __builtin_sin), emit
633612 // the call using the normal call path, but using the unmangled
634613 // version of the function name.
635- if (getContext ().BuiltinInfo .isLibFunction (builtinID)) {
614+ if (getContext ().BuiltinInfo .isLibFunction (builtinID))
636615 return emitLibraryCall (*this , fd, e,
637616 cgm.getBuiltinLibFunction (fd, builtinID));
638- }
639617
640618 // Some target-specific builtins can have aggregate return values, e.g.
641619 // __builtin_arm_mve_vld2q_u32. So if the result is an aggregate, force
0 commit comments