Author: Ayokunle Amodu Date: 2026-02-24T09:49:13-08:00 New Revision: a637cde428065f3a6207b8ce4d84f6d159476df0
URL: https://github.com/llvm/llvm-project/commit/a637cde428065f3a6207b8ce4d84f6d159476df0 DIFF: https://github.com/llvm/llvm-project/commit/a637cde428065f3a6207b8ce4d84f6d159476df0.diff LOG: [CIR][NFC] Update the constructor sites of `CIRGenFPOptionsRAII` (#182187) As support for RAII FP options has been upstreamed (#179121), this patch removes `CIRGenFPOptionsRAII` from the `MissingFeatures` list and updates its expected constructor sites. Added: Modified: clang/include/clang/CIR/MissingFeatures.h clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp clang/lib/CIR/CodeGen/CIRGenExpr.cpp clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp Removed: ################################################################################ diff --git a/clang/include/clang/CIR/MissingFeatures.h b/clang/include/clang/CIR/MissingFeatures.h index 97c76df0bb0b9..e6a33f56d518f 100644 --- a/clang/include/clang/CIR/MissingFeatures.h +++ b/clang/include/clang/CIR/MissingFeatures.h @@ -232,7 +232,6 @@ struct MissingFeatures { static bool builtinCheckKind() { return false; } static bool cgCapturedStmtInfo() { return false; } static bool countedBySize() { return false; } - static bool cgFPOptionsRAII() { return false; } static bool checkBitfieldClipping() { return false; } static bool cirgenABIInfo() { return false; } static bool cleanupAfterErrorDiags() { return false; } diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp index 43a85328faa0a..50e6892f4bbc5 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp @@ -257,7 +257,7 @@ static RValue emitUnaryMaybeConstrainedFPBuiltin(CIRGenFunction &cgf, const CallExpr &e) { mlir::Value arg = cgf.emitScalarExpr(e.getArg(0)); - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, &e); assert(!cir::MissingFeatures::fpConstraints()); auto call = @@ -1346,7 +1346,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID, // if the floating-point value, specified by the first argument, falls into // any of data classes, specified by the second argument. case Builtin::BI__builtin_isnan: { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e); mlir::Value v = emitScalarExpr(e->getArg(0)); assert(!cir::MissingFeatures::fpConstraints()); mlir::Location loc = getLoc(e->getBeginLoc()); @@ -1356,7 +1356,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID, } case Builtin::BI__builtin_issignaling: { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e); mlir::Value v = emitScalarExpr(e->getArg(0)); mlir::Location loc = getLoc(e->getBeginLoc()); return RValue::get(builder.createBoolToInt( @@ -1365,7 +1365,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID, } case Builtin::BI__builtin_isinf: { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e); mlir::Value v = emitScalarExpr(e->getArg(0)); assert(!cir::MissingFeatures::fpConstraints()); mlir::Location loc = getLoc(e->getBeginLoc()); @@ -1380,7 +1380,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID, case Builtin::BIfinitel: case Builtin::BI__finitel: case Builtin::BI__builtin_isfinite: { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e); mlir::Value v = emitScalarExpr(e->getArg(0)); assert(!cir::MissingFeatures::fpConstraints()); mlir::Location loc = getLoc(e->getBeginLoc()); @@ -1390,7 +1390,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID, } case Builtin::BI__builtin_isnormal: { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e); mlir::Value v = emitScalarExpr(e->getArg(0)); mlir::Location loc = getLoc(e->getBeginLoc()); return RValue::get(builder.createBoolToInt( @@ -1399,7 +1399,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID, } case Builtin::BI__builtin_issubnormal: { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e); mlir::Value v = emitScalarExpr(e->getArg(0)); mlir::Location loc = getLoc(e->getBeginLoc()); return RValue::get(builder.createBoolToInt( @@ -1408,7 +1408,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID, } case Builtin::BI__builtin_iszero: { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e); mlir::Value v = emitScalarExpr(e->getArg(0)); mlir::Location loc = getLoc(e->getBeginLoc()); return RValue::get(builder.createBoolToInt( @@ -1420,7 +1420,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID, if (!e->getArg(1)->EvaluateAsInt(result, cgm.getASTContext())) break; - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e); mlir::Value v = emitScalarExpr(e->getArg(0)); uint64_t test = result.Val.getInt().getLimitedValue(); mlir::Location loc = getLoc(e->getBeginLoc()); diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp index a0d80900a3475..e2a8958b43d5b 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp @@ -53,14 +53,15 @@ using namespace clang::CIRGen; // comparison // - Just emit the intrinsics call instead of calling this helper, see how the // LLVM lowering handles this. -static mlir::Value emitVectorFCmp(CIRGenBuilderTy &builder, +static mlir::Value emitVectorFCmp(CIRGenFunction &cgf, const CallExpr &expr, llvm::SmallVector<mlir::Value> &ops, - mlir::Location loc, cir::CmpOpKind pred, - bool shouldInvert) { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + cir::CmpOpKind pred, bool shouldInvert) { + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, &expr); // TODO(cir): Add isSignaling boolean once emitConstrainedFPCall implemented assert(!cir::MissingFeatures::emitConstrainedFPCall()); - mlir::Value cmp = builder.createVecCompare(loc, pred, ops[0], ops[1]); + clang::CIRGen::CIRGenBuilderTy &builder = cgf.getBuilder(); + mlir::Value cmp = builder.createVecCompare(cgf.getLoc(expr.getExprLoc()), + pred, ops[0], ops[1]); mlir::Value bitCast = builder.createBitcast( shouldInvert ? builder.createNot(cmp) : cmp, ops[0].getType()); return bitCast; @@ -2315,12 +2316,12 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, const CallExpr *expr) { return mlir::Value{}; case X86::BI__builtin_ia32_cmpnltps: case X86::BI__builtin_ia32_cmpnltpd: - return emitVectorFCmp(builder, ops, getLoc(expr->getExprLoc()), - cir::CmpOpKind::lt, /*shouldInvert=*/true); + return emitVectorFCmp(*this, *expr, ops, cir::CmpOpKind::lt, + /*shouldInvert=*/true); case X86::BI__builtin_ia32_cmpnleps: case X86::BI__builtin_ia32_cmpnlepd: - return emitVectorFCmp(builder, ops, getLoc(expr->getExprLoc()), - cir::CmpOpKind::le, /*shouldInvert=*/true); + return emitVectorFCmp(*this, *expr, ops, cir::CmpOpKind::le, + /*shouldInvert=*/true); case X86::BI__builtin_ia32_cmpordps: case X86::BI__builtin_ia32_cmpordpd: case X86::BI__builtin_ia32_cmpph128_mask: diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index 69d98c34c249c..d8519cec27fae 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -989,7 +989,7 @@ mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr *e) { return createDummyValue(getLoc(loc), boolTy); } - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e); if (!e->getType()->isAnyComplexType()) return emitScalarConversion(emitScalarExpr(e), e->getType(), boolTy, loc); diff --git a/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp b/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp index e35e630d06c4f..b909623aa662b 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp @@ -556,7 +556,7 @@ mlir::Value ComplexExprEmitter::emitCast(CastKind ck, Expr *op, case CK_FloatingRealToComplex: case CK_IntegralRealToComplex: { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, op); return emitScalarToComplexCast(cgf.emitScalarExpr(op), op->getType(), destTy, op->getExprLoc()); } @@ -565,7 +565,7 @@ mlir::Value ComplexExprEmitter::emitCast(CastKind ck, Expr *op, case CK_FloatingComplexToIntegralComplex: case CK_IntegralComplexCast: case CK_IntegralComplexToFloatingComplex: { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, op); return emitComplexToComplexCast(Visit(op), op->getType(), destTy, op->getExprLoc()); } @@ -612,7 +612,7 @@ mlir::Value ComplexExprEmitter::VisitUnaryNot(const UnaryOperator *e) { mlir::Value ComplexExprEmitter::emitBinAdd(const BinOpInfo &op) { assert(!cir::MissingFeatures::fastMathFlags()); - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, op.fpFeatures); if (mlir::isa<cir::ComplexType>(op.lhs.getType()) && mlir::isa<cir::ComplexType>(op.rhs.getType())) @@ -634,7 +634,7 @@ mlir::Value ComplexExprEmitter::emitBinAdd(const BinOpInfo &op) { mlir::Value ComplexExprEmitter::emitBinSub(const BinOpInfo &op) { assert(!cir::MissingFeatures::fastMathFlags()); - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, op.fpFeatures); if (mlir::isa<cir::ComplexType>(op.lhs.getType()) && mlir::isa<cir::ComplexType>(op.rhs.getType())) @@ -673,7 +673,7 @@ getComplexRangeAttr(LangOptions::ComplexRangeKind range) { mlir::Value ComplexExprEmitter::emitBinMul(const BinOpInfo &op) { assert(!cir::MissingFeatures::fastMathFlags()); - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, op.fpFeatures); if (mlir::isa<cir::ComplexType>(op.lhs.getType()) && mlir::isa<cir::ComplexType>(op.rhs.getType())) { @@ -701,7 +701,7 @@ mlir::Value ComplexExprEmitter::emitBinMul(const BinOpInfo &op) { mlir::Value ComplexExprEmitter::emitBinDiv(const BinOpInfo &op) { assert(!cir::MissingFeatures::fastMathFlags()); - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, op.fpFeatures); // Handle division between two complex values. In the case of complex integer // types mixed with scalar integers, the scalar integer type will always be @@ -835,7 +835,7 @@ LValue ComplexExprEmitter::emitCompoundAssignLValue( BinOpInfo opInfo{loc}; opInfo.fpFeatures = e->getFPFeaturesInEffect(cgf.getLangOpts()); - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, opInfo.fpFeatures); // Load the RHS and LHS operands. // __block variables need to have the rhs evaluated first, plus this should diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index c74fbbad488d5..7fe7fa347cd03 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -38,7 +38,7 @@ struct BinOpInfo { QualType compType; // Type used for computations. Element type // for vectors, otherwise same as FullType. BinaryOperator::Opcode opcode; // Opcode of BinOp to perform - FPOptions fpfeatures; + FPOptions fpFeatures; const Expr *e; // Entire expr, for error unsupported. May not be binop. /// Check if the binop computes a division or a remainder. @@ -695,7 +695,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> { cgf.cgm.errorNYI(e->getSourceRange(), "Unary inc/dec vector"); return {}; } else if (type->isRealFloatingType()) { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, e); if (type->isHalfType() && !cgf.getContext().getLangOpts().NativeHalfType) { @@ -1066,7 +1066,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> { result.opcode = e->getOpcode(); result.loc = e->getSourceRange(); // TODO(cir): Result.FPFeatures - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, e); result.e = e; return result; } @@ -1459,7 +1459,7 @@ LValue ScalarExprEmitter::emitCompoundAssignLValue( if (const auto *vecType = dyn_cast_or_null<VectorType>(opInfo.fullType)) opInfo.compType = vecType->getElementType(); opInfo.opcode = e->getOpcode(); - opInfo.fpfeatures = e->getFPFeaturesInEffect(cgf.getLangOpts()); + opInfo.fpFeatures = e->getFPFeaturesInEffect(cgf.getLangOpts()); opInfo.e = e; opInfo.loc = e->getSourceRange(); @@ -1865,7 +1865,7 @@ mlir::Value ScalarExprEmitter::emitMul(const BinOpInfo &ops) { cgf.cgm.errorNYI("unsigned int overflow sanitizer"); if (cir::isFPOrVectorOfFPType(ops.lhs.getType())) { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, ops.fpFeatures); return builder.createFMul(loc, ops.lhs, ops.rhs); } @@ -1924,7 +1924,7 @@ mlir::Value ScalarExprEmitter::emitAdd(const BinOpInfo &ops) { cgf.cgm.errorNYI("unsigned int overflow sanitizer"); if (cir::isFPOrVectorOfFPType(ops.lhs.getType())) { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, ops.fpFeatures); return builder.createFAdd(loc, ops.lhs, ops.rhs); } @@ -1972,7 +1972,7 @@ mlir::Value ScalarExprEmitter::emitSub(const BinOpInfo &ops) { cgf.cgm.errorNYI("unsigned int overflow sanitizer"); if (cir::isFPOrVectorOfFPType(ops.lhs.getType())) { - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, ops.fpFeatures); return builder.createFSub(loc, ops.lhs, ops.rhs); } @@ -2355,7 +2355,7 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr *ce) { "fixed point casts"); return {}; } - assert(!cir::MissingFeatures::cgFPOptionsRAII()); + CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, ce); return emitScalarConversion(Visit(subExpr), subExpr->getType(), destTy, ce->getExprLoc()); } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
