llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clangir Author: Ayokunle Amodu (ayokunle321) <details> <summary>Changes</summary> As support for FP environments and RAII options have been upstreamed (#<!-- -->179121), this patch removes `CIRGenFPOptionsRAII` from the `MissingFeatures` list and updates its supposed constructor sites. --- Full diff: https://github.com/llvm/llvm-project/pull/182187.diff 6 Files Affected: - (modified) clang/include/clang/CIR/MissingFeatures.h (-1) - (modified) clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp (+9-9) - (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp (+10-9) - (modified) clang/lib/CIR/CodeGen/CIRGenExpr.cpp (+1-1) - (modified) clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp (+7-7) - (modified) clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp (+8-8) ``````````diff 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 87c50585c1afb..85265dd365573 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 = @@ -1296,7 +1296,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()); @@ -1306,7 +1306,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( @@ -1315,7 +1315,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()); @@ -1330,7 +1330,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()); @@ -1340,7 +1340,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( @@ -1349,7 +1349,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( @@ -1358,7 +1358,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( @@ -1370,7 +1370,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 83d51bac01d1e..d41509bd58e94 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 2c5a57e1ba2ee..698eeaf2f9629 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; } @@ -1455,7 +1455,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(); @@ -1861,7 +1861,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); } @@ -1920,7 +1920,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); } @@ -1968,7 +1968,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); } @@ -2351,7 +2351,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()); } `````````` </details> https://github.com/llvm/llvm-project/pull/182187 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
