Replace `binaryOperator` by EmitC ops (#16728)

diff --git a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp
index a4cb660..58233f4 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp
+++ b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/ConvertVMToEmitC.cpp
@@ -2271,9 +2271,12 @@
       Value size =
           emitc_builders::sizeOf(builder, loc, TypeAttr::get(valueType));
 
-      result = emitc_builders::binaryOperator(
-          builder, loc, emitc_builders::BinaryOperator::ADDITION, result, size,
-          hostSizeType);
+      result = builder
+                   .create<emitc::AddOp>(
+                       /*location=*/loc,
+                       /*type=*/hostSizeType,
+                       /*operands=*/ArrayRef<Value>{result, size})
+                   .getResult();
     }
 
     return {result};
@@ -2432,9 +2435,13 @@
         Type valueType = typeConverter.convertTypeAsNonPointer(argType);
         Value size =
             emitc_builders::sizeOf(builder, loc, TypeAttr::get(valueType));
-        uint8Ptr = emitc_builders::binaryOperator(
-            builder, loc, emitc_builders::BinaryOperator::ADDITION, uint8Ptr,
-            size, bytePtrType);
+
+        uint8Ptr = builder
+                       .create<emitc::AddOp>(
+                           /*location=*/loc,
+                           /*type=*/bytePtrType,
+                           /*operands=*/ArrayRef<Value>{uint8Ptr, size})
+                       .getResult();
       }
     }
     return success();
@@ -2502,9 +2509,12 @@
         Type valueType = llvm::cast<emitc::PointerType>(argType).getPointee();
         Value size =
             emitc_builders::sizeOf(builder, loc, TypeAttr::get(valueType));
-        uint8Ptr = emitc_builders::binaryOperator(
-            builder, loc, emitc_builders::BinaryOperator::ADDITION, uint8Ptr,
-            size, bytePtrType);
+        uint8Ptr = builder
+                       .create<emitc::AddOp>(
+                           /*location=*/loc,
+                           /*type=*/bytePtrType,
+                           /*operands=*/ArrayRef<Value>{uint8Ptr, size})
+                       .getResult();
       }
     }
     return success();
@@ -4208,9 +4218,14 @@
               .getResult();
 
       // ref->type != IREE_VM_REF_TYPE_NULL
-      auto refTypeIsNotNull = emitc_builders::binaryOperator(
-          rewriter, loc, emitc_builders::BinaryOperator::NOT_EQUAL_TO, refType,
-          refTypeNull, rewriter.getI1Type());
+      auto refTypeIsNotNull = rewriter
+                                  .create<emitc::CmpOp>(
+                                      /*location=*/loc,
+                                      /*type=*/rewriter.getI1Type(),
+                                      /*predicate*/ emitc::CmpPredicate::ne,
+                                      /*lhs*/ refType,
+                                      /*rhs*/ refTypeNull)
+                                  .getResult();
 
       // (iree_vm_type_def_is_value(type_def)
       auto typedefIsValue =
@@ -4237,17 +4252,30 @@
               .getResult(0);
 
       // ref->type != iree_vm_type_def_as_ref(type_def)
-      auto refTypesDontMatch = emitc_builders::binaryOperator(
-          rewriter, loc, emitc_builders::BinaryOperator::NOT_EQUAL_TO, refType,
-          typedefAsRef, rewriter.getI1Type());
+      auto refTypesDontMatch = rewriter
+                                   .create<emitc::CmpOp>(
+                                       /*location=*/loc,
+                                       /*type=*/rewriter.getI1Type(),
+                                       /*predicate*/ emitc::CmpPredicate::ne,
+                                       /*lhs*/ refType,
+                                       /*rhs*/ typedefAsRef)
+                                   .getResult();
 
-      auto invalidRefType = emitc_builders::binaryOperator(
-          rewriter, loc, emitc_builders::BinaryOperator::LOGICAL_OR,
-          typedefIsValue, refTypesDontMatch, rewriter.getI1Type());
+      auto invalidRefType = rewriter
+                                .create<emitc::LogicalOrOp>(
+                                    /*location=*/loc,
+                                    /*type=*/rewriter.getI1Type(),
+                                    /*lhs*/ typedefIsValue,
+                                    /*rhs*/ refTypesDontMatch)
+                                .getResult();
 
-      invalidType = emitc_builders::binaryOperator(
-          rewriter, loc, emitc_builders::BinaryOperator::LOGICAL_AND,
-          refTypeIsNotNull, invalidRefType, rewriter.getI1Type());
+      invalidType = rewriter
+                        .create<emitc::LogicalAndOp>(
+                            /*location=*/loc,
+                            /*type=*/rewriter.getI1Type(),
+                            /*lhs*/ refTypeIsNotNull,
+                            /*rhs*/ invalidRefType)
+                        .getResult();
     }
 
     // Start by splitting the block into two. The part before will contain
diff --git a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/EmitCBuilders.cpp b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/EmitCBuilders.cpp
index 84babe5..3e65b74 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/EmitCBuilders.cpp
+++ b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/EmitCBuilders.cpp
@@ -58,50 +58,6 @@
     return "XXX";
   }
 }
-
-std::string mapBinaryOperator(BinaryOperator op) {
-  switch (op) {
-  case BinaryOperator::ADDITION:
-    return "+";
-  case BinaryOperator::SUBTRACTION:
-    return "-";
-  case BinaryOperator::PRODUCT:
-    return "*";
-  case BinaryOperator::DIVISION:
-    return "/";
-  case BinaryOperator::REMAINDER:
-    return "%";
-  case BinaryOperator::BITWISE_AND:
-    return "&";
-  case BinaryOperator::BITWISE_OR:
-    return "|";
-  case BinaryOperator::BITWISE_XOR:
-    return "^";
-  case BinaryOperator::BITWISE_LEFT_SHIFT:
-    return "<<";
-  case BinaryOperator::BITWISE_RIGHT_SHIFT:
-    return ">>";
-  case BinaryOperator::LOGICAL_AND:
-    return "&&";
-  case BinaryOperator::LOGICAL_OR:
-    return "||";
-  case BinaryOperator::EQUAL_TO:
-    return "==";
-  case BinaryOperator::NOT_EQUAL_TO:
-    return "!=";
-  case BinaryOperator::LESS_THAN:
-    return "<";
-  case BinaryOperator::GREATER_THAN:
-    return ">";
-  case BinaryOperator::LESS_THAN_OR_EQUAL:
-    return "<=";
-  case BinaryOperator::GREATER_THAN_OR_EQUAL:
-    return ">=";
-  default:
-    llvm_unreachable("unsupported binary operator");
-    return "XXX";
-  }
-}
 } // namespace
 
 Value unaryOperator(OpBuilder builder, Location location, UnaryOperator op,
@@ -122,24 +78,6 @@
       .getResult(0);
 }
 
-Value binaryOperator(OpBuilder builder, Location location, BinaryOperator op,
-                     Value lhs, Value rhs, Type resultType) {
-  auto ctx = builder.getContext();
-
-  return builder
-      .create<emitc::CallOpaqueOp>(
-          /*location=*/location,
-          /*type=*/resultType,
-          /*callee=*/StringAttr::get(ctx, "EMITC_BINARY"),
-          /*args=*/
-          ArrayAttr::get(ctx,
-                         {emitc::OpaqueAttr::get(ctx, mapBinaryOperator(op)),
-                          builder.getIndexAttr(0), builder.getIndexAttr(1)}),
-          /*templateArgs=*/ArrayAttr{},
-          /*operands=*/ArrayRef<Value>{lhs, rhs})
-      .getResult(0);
-}
-
 Value allocateVariable(OpBuilder builder, Location location, Type type,
                        Attribute initializer) {
   return builder
diff --git a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/EmitCBuilders.h b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/EmitCBuilders.h
index ab107bc..fa13534 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/EmitCBuilders.h
+++ b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/EmitCBuilders.h
@@ -81,9 +81,6 @@
 Value unaryOperator(OpBuilder builder, Location location, UnaryOperator op,
                     Value operand, Type resultType);
 
-Value binaryOperator(OpBuilder builder, Location location, BinaryOperator op,
-                     Value lhs, Value rhs, Type resultType);
-
 Value allocateVariable(OpBuilder builder, Location location, Type type,
                        Attribute initializer);
 
diff --git a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/test/control_flow_ops.mlir b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/test/control_flow_ops.mlir
index 2f4b938..73c0644 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/test/control_flow_ops.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/test/control_flow_ops.mlir
@@ -433,18 +433,23 @@
   // Calculate the size of the arguments.
   // CHECK-NEXT: %[[ARGSIZE0:.+]] = "emitc.constant"() <{value = #emitc.opaque<"0">}> : () -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[ARGSIZE1:.+]] = emitc.call_opaque "sizeof"() {args = [i32]}
-  // CHECK-NEXT: %[[ARGSIZE01:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[ARGSIZE0]], %[[ARGSIZE1]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[ARGSIZE01:.+]] = emitc.add %[[ARGSIZE0]], %[[ARGSIZE1]]
+  // CHECK-SAME:     : (!emitc.opaque<"iree_host_size_t">, !emitc.opaque<"iree_host_size_t">) -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[ARGSIZE2:.+]] = emitc.call_opaque "sizeof"() {args = [i32]}
-  // CHECK-NEXT: %[[ARGSIZE012:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[ARGSIZE01]], %[[ARGSIZE2]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[ARGSIZE012:.+]] = emitc.add %[[ARGSIZE01]], %[[ARGSIZE2]]
+  // CHECK-SAME:     : (!emitc.opaque<"iree_host_size_t">, !emitc.opaque<"iree_host_size_t">) -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[ARGSIZE3:.+]] = emitc.call_opaque "sizeof"() {args = [i32]}
-  // CHECK-NEXT: %[[ARGSIZE0123:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[ARGSIZE012]], %[[ARGSIZE3]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[ARGSIZE0123:.+]] = emitc.add %[[ARGSIZE012]], %[[ARGSIZE3]]
+  // CHECK-SAME:     : (!emitc.opaque<"iree_host_size_t">, !emitc.opaque<"iree_host_size_t">) -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[ARGSIZE4:.+]] = emitc.call_opaque "sizeof"() {args = [i32]}
-  // CHECK-NEXT: %[[ARGSIZE:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[ARGSIZE0123]], %[[ARGSIZE4]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[ARGSIZE:.+]] = emitc.add %[[ARGSIZE0123]], %[[ARGSIZE4]]
+  // CHECK-SAME:     : (!emitc.opaque<"iree_host_size_t">, !emitc.opaque<"iree_host_size_t">) -> !emitc.opaque<"iree_host_size_t">
 
   // Calculate the size of the result.
   // CHECK-NEXT: %[[RESULTSIZE0:.+]] = "emitc.constant"() <{value = #emitc.opaque<"0">}> : () -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[RESULTSIZE1:.+]] = emitc.call_opaque "sizeof"() {args = [i32]}
-  // CHECK-NEXT: %[[RESULTSIZE:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[RESULTSIZE0]], %[[RESULTSIZE1]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[RESULTSIZE:.+]] = emitc.add %[[RESULTSIZE0]], %[[RESULTSIZE1]]
+  // CHECK-SAME:     : (!emitc.opaque<"iree_host_size_t">, !emitc.opaque<"iree_host_size_t">) -> !emitc.opaque<"iree_host_size_t">
 
   // Create a struct for the arguments and results.
   // CHECK: %[[ARGSTRUCT:.+]] = "emitc.variable"() <{value = #emitc.opaque<"">}> : () -> !emitc.opaque<"iree_vm_function_call_t">
@@ -481,19 +486,19 @@
   // CHECK-NEXT: %[[A1PTR:.+]] = emitc.apply "&"(%arg2) : (i32) -> !emitc.ptr<i32>
   // CHECK-NEXT: emitc.call_opaque "memcpy"(%[[ARGSPTR]], %[[A1PTR]], %[[ARGHOSTSIZE]])
   // CHECK-NEXT: %[[ARGHOSTSIZE2:.+]] = emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.opaque<"iree_host_size_t">
-  // CHECK-NEXT: %[[A1ADDR:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[ARGSPTR]], %[[ARGHOSTSIZE2]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[A1ADDR:.+]] = emitc.add %[[ARGSPTR]], %[[ARGHOSTSIZE2]]
   // CHECK-SAME:     : (!emitc.ptr<ui8>, !emitc.opaque<"iree_host_size_t">) -> !emitc.ptr<ui8>
   // CHECK-NEXT: %[[A1SIZE:.+]] = emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[A2PTR:.+]] = emitc.apply "&"(%arg3) : (i32) -> !emitc.ptr<i32>
   // CHECK-NEXT: emitc.call_opaque "memcpy"(%[[A1ADDR]], %[[A2PTR]], %[[A1SIZE]])
   // CHECK-NEXT: %[[A1SIZE2:.+]] = emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.opaque<"iree_host_size_t">
-  // CHECK-NEXT: %[[A2ADDR:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[A1ADDR]], %[[A1SIZE2]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[A2ADDR:.+]] = emitc.add %[[A1ADDR]], %[[A1SIZE2]]
   // CHECK-SAME:     : (!emitc.ptr<ui8>, !emitc.opaque<"iree_host_size_t">) -> !emitc.ptr<ui8>
   // CHECK-NEXT: %[[A2SIZE:.+]] = emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[A3PTR:.+]] = emitc.apply "&"(%arg4) : (i32) -> !emitc.ptr<i32>
   // CHECK-NEXT: emitc.call_opaque "memcpy"(%[[A2ADDR]], %[[A3PTR]], %[[A2SIZE]])
   // CHECK-NEXT: %[[A2SIZE2:.+]] = emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.opaque<"iree_host_size_t">
-  // CHECK-NEXT: %[[A3ADDR:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[A2ADDR]], %[[A2SIZE2]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[A3ADDR:.+]] = emitc.add %[[A2ADDR]], %[[A2SIZE2]]
   // CHECK-SAME:     : (!emitc.ptr<ui8>, !emitc.opaque<"iree_host_size_t">) -> !emitc.ptr<ui8>
   // CHECK-NEXT: %[[A3SIZE:.+]] = emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[A4PTR:.+]] = emitc.apply "&"(%arg5) : (i32) -> !emitc.ptr<i32>
@@ -536,14 +541,17 @@
   // Calculate the size of the arguments.
   // CHECK-NEXT: %[[ARGSIZE0:.+]] = "emitc.constant"() <{value = #emitc.opaque<"0">}> : () -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[ARGSIZE1:.+]] = emitc.call_opaque "sizeof"() {args = [i32]}
-  // CHECK-NEXT: %[[ARGSIZE01:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[ARGSIZE0]], %[[ARGSIZE1]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[ARGSIZE01:.+]] = emitc.add %[[ARGSIZE0]], %[[ARGSIZE1]]
+  // CHECK-SAME:     : (!emitc.opaque<"iree_host_size_t">, !emitc.opaque<"iree_host_size_t">) -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[ARGSIZE2:.+]] = emitc.call_opaque "sizeof"() {args = [i32]}
-  // CHECK-NEXT: %[[ARGSIZE:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[ARGSIZE01]], %[[ARGSIZE2]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[ARGSIZE:.+]] = emitc.add %[[ARGSIZE01]], %[[ARGSIZE2]]
+  // CHECK-SAME:     : (!emitc.opaque<"iree_host_size_t">, !emitc.opaque<"iree_host_size_t">) -> !emitc.opaque<"iree_host_size_t">
 
   // Calculate the size of the result.
   // CHECK-NEXT: %[[RESULTSIZE0:.+]] = "emitc.constant"() <{value = #emitc.opaque<"0">}> : () -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[RESULTSIZE1:.+]] = emitc.call_opaque "sizeof"() {args = [i32]}
-  // CHECK-NEXT: %[[RESULTSIZE:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[RESULTSIZE0]], %[[RESULTSIZE1]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[RESULTSIZE:.+]] = emitc.add %[[RESULTSIZE0]], %[[RESULTSIZE1]]
+  // CHECK-SAME:     : (!emitc.opaque<"iree_host_size_t">, !emitc.opaque<"iree_host_size_t">) -> !emitc.opaque<"iree_host_size_t">
 
   // Create a struct for the arguments and results.
   // CHECK: %[[ARGSTRUCT:.+]] = "emitc.variable"() <{value = #emitc.opaque<"">}> : () -> !emitc.opaque<"iree_vm_function_call_t">
@@ -580,7 +588,7 @@
   // CHECK-NEXT: %[[A1PTR:.+]] = emitc.apply "&"(%arg2) : (i32) -> !emitc.ptr<i32>
   // CHECK-NEXT: emitc.call_opaque "memcpy"(%[[ARGSPTR]], %[[A1PTR]], %[[ARGHOSTSIZE]])
   // CHECK-NEXT: %[[ARGHOSTSIZE2:.+]] = emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.opaque<"iree_host_size_t">
-  // CHECK-NEXT: %[[A1ADDR:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[ARGSPTR]], %[[ARGHOSTSIZE2]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[A1ADDR:.+]] = emitc.add %[[ARGSPTR]], %[[ARGHOSTSIZE2]]
   // CHECK-SAME:     : (!emitc.ptr<ui8>, !emitc.opaque<"iree_host_size_t">) -> !emitc.ptr<ui8>
   // CHECK-NEXT: %[[A1SIZE:.+]] = emitc.call_opaque "sizeof"() {args = [i32]} : () -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[A2PTR:.+]] = emitc.apply "&"(%arg3) : (i32) -> !emitc.ptr<i32>
@@ -623,12 +631,14 @@
   // Calculate the size of the arguments.
   // CHECK-NEXT: %[[ARGSIZE0:.+]] = "emitc.constant"() <{value = #emitc.opaque<"0">}> : () -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[ARGSIZE1:.+]] = emitc.call_opaque "sizeof"() {args = [!emitc.opaque<"iree_vm_ref_t">]}
-  // CHECK-NEXT: %[[ARGSIZE:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[ARGSIZE0]], %[[ARGSIZE1]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[ARGSIZE:.+]] = emitc.add %[[ARGSIZE0]], %[[ARGSIZE1]]
+  // CHECK-SAME:     : (!emitc.opaque<"iree_host_size_t">, !emitc.opaque<"iree_host_size_t">) -> !emitc.opaque<"iree_host_size_t">
 
   // Calculate the size of the result.
   // CHECK-NEXT: %[[RESULTSIZE0:.+]] = "emitc.constant"() <{value = #emitc.opaque<"0">}> : () -> !emitc.opaque<"iree_host_size_t">
   // CHECK-NEXT: %[[RESULTSIZE1:.+]] = emitc.call_opaque "sizeof"() {args = [!emitc.opaque<"iree_vm_ref_t">]}
-  // CHECK-NEXT: %[[RESULTSIZE:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[RESULTSIZE0]], %[[RESULTSIZE1]]) {args = [#emitc.opaque<"+">, 0 : index, 1 : index]}
+  // CHECK-NEXT: %[[RESULTSIZE:.+]] = emitc.add %[[RESULTSIZE0]], %[[RESULTSIZE1]]
+  // CHECK-SAME:     : (!emitc.opaque<"iree_host_size_t">, !emitc.opaque<"iree_host_size_t">) -> !emitc.opaque<"iree_host_size_t">
 
   // Create a struct for the arguments and results.
   // CHECK: %[[ARGSTRUCT:.+]] = "emitc.variable"() <{value = #emitc.opaque<"">}> : () -> !emitc.opaque<"iree_vm_function_call_t">
diff --git a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/test/list_ops.mlir b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/test/list_ops.mlir
index 92526fd..f1aeb89 100644
--- a/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/test/list_ops.mlir
+++ b/compiler/src/iree/compiler/Dialect/VM/Conversion/VMToEmitC/test/list_ops.mlir
@@ -82,12 +82,12 @@
     // CHECK: %{{.+}} = emitc.call_opaque "iree_vm_list_get_ref_retain"(%1, %arg4, %arg3) : (!emitc.ptr<!emitc.opaque<"iree_vm_list_t">>, i32, !emitc.ptr<!emitc.opaque<"iree_vm_ref_t">>) -> !emitc.opaque<"iree_status_t">
     // CHECK: %[[A:.+]] = emitc.call_opaque "EMITC_STRUCT_PTR_MEMBER"(%arg3) {args = [0 : index, #emitc.opaque<"type">]} : (!emitc.ptr<!emitc.opaque<"iree_vm_ref_t">>) -> !emitc.opaque<"iree_vm_ref_type_t">
     // CHECK: %[[B:.+]] = "emitc.constant"() <{value = #emitc.opaque<"IREE_VM_REF_TYPE_NULL">}> : () -> !emitc.opaque<"iree_vm_ref_type_t">
-    // CHECK: %[[C:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[A]], %[[B]]) {args = [#emitc.opaque<"!=">, 0 : index, 1 : index]} : (!emitc.opaque<"iree_vm_ref_type_t">, !emitc.opaque<"iree_vm_ref_type_t">) -> i1
+    // CHECK: %[[C:.+]] = emitc.cmp ne, %[[A]], %[[B]] : (!emitc.opaque<"iree_vm_ref_type_t">, !emitc.opaque<"iree_vm_ref_type_t">) -> i1
     // CHECK: %[[D:.+]] = emitc.call_opaque "iree_vm_type_def_is_value"(%{{.+}}) : (!emitc.opaque<"iree_vm_type_def_t">) -> i1
     // CHECK: %[[E:.+]] = emitc.call_opaque "iree_vm_type_def_as_ref"(%{{.+}}) : (!emitc.opaque<"iree_vm_type_def_t">) -> !emitc.opaque<"iree_vm_ref_type_t">
-    // CHECK: %[[F:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[A]], %[[E]]) {args = [#emitc.opaque<"!=">, 0 : index, 1 : index]} : (!emitc.opaque<"iree_vm_ref_type_t">, !emitc.opaque<"iree_vm_ref_type_t">) -> i1
-    // CHECK: %[[G:.+]] = emitc.call_opaque "EMITC_BINARY"(%[[D]], %[[F]]) {args = [#emitc.opaque<"||">, 0 : index, 1 : index]} : (i1, i1) -> i1
-    // CHECK: %{{.+}} = emitc.call_opaque "EMITC_BINARY"(%[[C]], %[[G]]) {args = [#emitc.opaque<"&&">, 0 : index, 1 : index]} : (i1, i1) -> i1
+    // CHECK: %[[F:.+]] = emitc.cmp ne, %[[A]], %[[E]] : (!emitc.opaque<"iree_vm_ref_type_t">, !emitc.opaque<"iree_vm_ref_type_t">) -> i1
+    // CHECK: %[[G:.+]] = emitc.logical_or %[[D]], %[[F]] : i1, i1
+    // CHECK: %{{.+}} = emitc.logical_and %[[C]], %[[G]] : i1, i1
     // CHECK: cf.cond_br %{{.+}}, ^[[FAIL:.+]], ^[[CONTINUE:.+]]
     // CHECK: ^[[FAIL]]:
     // CHECK-NEXT: emitc.call_opaque "iree_vm_ref_release"(%arg3) : (!emitc.ptr<!emitc.opaque<"iree_vm_ref_t">>) -> ()
diff --git a/runtime/src/iree/vm/ops_emitc.h b/runtime/src/iree/vm/ops_emitc.h
index 1bacddd..e4a0fa4 100644
--- a/runtime/src/iree/vm/ops_emitc.h
+++ b/runtime/src/iree/vm/ops_emitc.h
@@ -52,7 +52,4 @@
 // Unary operators
 #define EMITC_UNARY(op, arg) (op(arg))
 
-// Binary operators
-#define EMITC_BINARY(op, lhs, rhs) ((lhs)op(rhs))
-
 #endif  // IREE_VM_OPS_EMITC_H_