[clang] [CIR][NFC] Update the constructor sites of `CIRGenFPOptionsRAII` (PR #182187)
Ayokunle Amodu via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 16:02:22 PST 2026
https://github.com/ayokunle321 created https://github.com/llvm/llvm-project/pull/182187
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.
>From 9a665661d115bbc832218094c71e4ee4bac8cbbd Mon Sep 17 00:00:00 2001
From: Ayokunle Amodu <ayokunle321 at gmail.com>
Date: Wed, 18 Feb 2026 15:33:01 -0700
Subject: [PATCH 1/3] enable RAII options
---
clang/include/clang/CIR/MissingFeatures.h | 1 -
clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp | 18 +++++++++---------
clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp | 2 +-
clang/lib/CIR/CodeGen/CIRGenExpr.cpp | 2 +-
clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp | 14 +++++++-------
clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 12 ++++++------
6 files changed, 24 insertions(+), 25 deletions(-)
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..dcb5895a28212 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -57,7 +57,7 @@ static mlir::Value emitVectorFCmp(CIRGenBuilderTy &builder,
llvm::SmallVector<mlir::Value> &ops,
mlir::Location loc, cir::CmpOpKind pred,
bool shouldInvert) {
- assert(!cir::MissingFeatures::cgFPOptionsRAII());
+ CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
// TODO(cir): Add isSignaling boolean once emitConstrainedFPCall implemented
assert(!cir::MissingFeatures::emitConstrainedFPCall());
mlir::Value cmp = builder.createVecCompare(loc, pred, ops[0], ops[1]);
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..e1c3fde275cb9 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(*this, e);
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(*this, 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(*this, e);
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(*this, e);
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(*this, e);
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(*this, e);
// 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(*this, e);
// 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..8980280ced3af 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
@@ -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(*this, 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(*this, e);
result.e = e;
return result;
}
@@ -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(*this, e);
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(*this, e);
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(*this, e);
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(*this, e);
return emitScalarConversion(Visit(subExpr), subExpr->getType(), destTy,
ce->getExprLoc());
}
>From 07ed887c4ef7efe31e4144d25c846dd41bfde0fd Mon Sep 17 00:00:00 2001
From: Ayokunle Amodu <ayokunle321 at gmail.com>
Date: Wed, 18 Feb 2026 16:48:02 -0700
Subject: [PATCH 2/3] fix parameters passed to FPOptsRAII constructors
---
clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp | 13 +++++++------
clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp | 14 +++++++-------
clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp | 16 ++++++++--------
3 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index dcb5895a28212..3233606e71bec 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,
+ cir::CmpOpKind pred,
bool shouldInvert) {
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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,11 +2316,11 @@ 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()),
+ 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()),
+ return emitVectorFCmp(*this, *expr, ops,
cir::CmpOpKind::le, /*shouldInvert=*/true);
case X86::BI__builtin_ia32_cmpordps:
case X86::BI__builtin_ia32_cmpordpd:
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp b/clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp
index e1c3fde275cb9..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: {
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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: {
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, op);
+ 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());
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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());
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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());
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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());
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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());
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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 8980280ced3af..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()) {
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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())) {
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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())) {
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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())) {
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ 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 {};
}
- CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(*this, e);
+ CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, ce);
return emitScalarConversion(Visit(subExpr), subExpr->getType(), destTy,
ce->getExprLoc());
}
>From e9b0ff4d6cedd966e0ac8bc4171f8d525a59a9f8 Mon Sep 17 00:00:00 2001
From: Ayokunle Amodu <ayokunle321 at gmail.com>
Date: Wed, 18 Feb 2026 16:51:40 -0700
Subject: [PATCH 3/3] fix style
---
clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index 3233606e71bec..e2a8958b43d5b 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -55,13 +55,13 @@ using namespace clang::CIRGen;
// LLVM lowering handles this.
static mlir::Value emitVectorFCmp(CIRGenFunction &cgf, const CallExpr &expr,
llvm::SmallVector<mlir::Value> &ops,
- cir::CmpOpKind pred,
- bool shouldInvert) {
+ cir::CmpOpKind pred, bool shouldInvert) {
CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(cgf, &expr);
// TODO(cir): Add isSignaling boolean once emitConstrainedFPCall implemented
assert(!cir::MissingFeatures::emitConstrainedFPCall());
clang::CIRGen::CIRGenBuilderTy &builder = cgf.getBuilder();
- mlir::Value cmp = builder.createVecCompare(cgf.getLoc(expr.getExprLoc()), pred, ops[0], ops[1]);
+ 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;
@@ -2316,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(*this, *expr, ops,
- 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(*this, *expr, ops,
- 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:
More information about the cfe-commits
mailing list