[clang] [CIR] Add binary operators (PR #132420)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 21 14:50:36 PDT 2025
================
@@ -570,13 +853,425 @@ mlir::Value CIRGenFunction::emitScalarExpr(const Expr *e) {
return ScalarExprEmitter(*this, builder).Visit(const_cast<Expr *>(e));
}
-[[maybe_unused]] static bool MustVisitNullValue(const Expr *e) {
+mlir::Value CIRGenFunction::emitPromotedScalarExpr(const Expr *e,
+ QualType promotionType) {
+ if (!promotionType.isNull())
+ return ScalarExprEmitter(*this, builder).emitPromoted(e, promotionType);
+ return ScalarExprEmitter(*this, builder).Visit(const_cast<Expr *>(e));
+}
+
+[[maybe_unused]] static bool mustVisitNullValue(const Expr *e) {
// If a null pointer expression's type is the C++0x nullptr_t, then
// it's not necessarily a simple constant and it must be evaluated
// for its potential side effects.
return e->getType()->isNullPtrType();
}
+/// If \p E is a widened promoted integer, get its base (unpromoted) type.
+static std::optional<QualType>
+getUnwidenedIntegerType(const ASTContext &astContext, const Expr *e) {
+ const Expr *base = e->IgnoreImpCasts();
+ if (e == base)
+ return std::nullopt;
+
+ QualType baseTy = base->getType();
+ if (!astContext.isPromotableIntegerType(baseTy) ||
+ astContext.getTypeSize(baseTy) >= astContext.getTypeSize(e->getType()))
+ return std::nullopt;
+
+ return baseTy;
+}
+
+/// Check if \p E is a widened promoted integer.
----------------
andykaylor wrote:
```suggestion
/// Check if \p e is a widened promoted integer.
```
https://github.com/llvm/llvm-project/pull/132420
More information about the cfe-commits
mailing list