[clang] [CIR] Upstream CmpOp (PR #133159)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 26 16:10:36 PDT 2025
================
@@ -710,6 +710,89 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
HANDLEBINOP(Xor)
HANDLEBINOP(Or)
#undef HANDLEBINOP
+
+ mlir::Value emitCmp(const BinaryOperator *e) {
+ mlir::Value result;
+ QualType lhsTy = e->getLHS()->getType();
+ QualType rhsTy = e->getRHS()->getType();
+
+ auto clangCmpToCIRCmp =
+ [](clang::BinaryOperatorKind clangCmp) -> cir::CmpOpKind {
+ switch (clangCmp) {
+ case BO_LT:
+ return cir::CmpOpKind::lt;
+ case BO_GT:
+ return cir::CmpOpKind::gt;
+ case BO_LE:
+ return cir::CmpOpKind::le;
+ case BO_GE:
+ return cir::CmpOpKind::ge;
+ case BO_EQ:
+ return cir::CmpOpKind::eq;
+ case BO_NE:
+ return cir::CmpOpKind::ne;
+ default:
+ llvm_unreachable("unsupported comparison kind");
+ }
+ };
+
+ if (lhsTy->getAs<MemberPointerType>()) {
+ assert(e->getOpcode() == BO_EQ || e->getOpcode() == BO_NE);
----------------
andykaylor wrote:
We won't be able to reach this code until support for classes is upstreamed. Maybe add a MissingFeature assert as a reminder to add a test for this case?
https://github.com/llvm/llvm-project/pull/133159
More information about the cfe-commits
mailing list