// CHECK: bool fold(SmallVectorImpl<Value *> &results);
// CHECK: };
-def NS__BOp : Op<"_b_op", []>;
+// Check op trait for different number of operands
+// ---
-// CHECK-LABEL: NS::_BOp declarations
-// CHECK: class _BOp : public Op<_BOp
+def NS_BOp : Op<"op_with_no_operand", []> {
+ let arguments = (ins);
+}
-def _COp : Op<"_c_op", []>;
+// CHECK-LABEL: NS::BOp declarations
+// CHECK: OpTrait::NOperands<0>::Impl
+
+def NS_COp : Op<"op_with_one_operand", []> {
+ let arguments = (ins I32:$operand);
+}
+
+// CHECK-LABEL: NS::COp declarations
+// CHECK: OpTrait::NOperands<1>::Impl
+
+def NS_DOp : Op<"op_with_two_operands", []> {
+ let arguments = (ins I32:$input1, I32:$input2);
+}
-// CHECK-LABEL: _COp declarations
-// CHECK: class _COp : public Op<_COp
+// CHECK-LABEL: NS::DOp declarations
+// CHECK: OpTrait::NOperands<2>::Impl
+
+// Check leading underscore in op name
+// ---
+
+def NS__AOp : Op<"_op_with_leading_underscore", []>;
+
+// CHECK-LABEL: NS::_AOp declarations
+// CHECK: class _AOp : public Op<_AOp
+
+def _BOp : Op<"_op_with_leading_underscore_and_no_namespace", []>;
+
+// CHECK-LABEL: _BOp declarations
+// CHECK: class _BOp : public Op<_BOp
opClass.addTrait("AtLeastNOperands<" + Twine(numOperands - 1) +
">::Impl");
} else {
- switch (numOperands) {
- case 0:
- opClass.addTrait("ZeroOperands");
- break;
- case 1:
- opClass.addTrait("OneOperand");
- break;
- default:
- opClass.addTrait("NOperands<" + Twine(numOperands) + ">::Impl");
- break;
- }
+ opClass.addTrait("NOperands<" + Twine(numOperands) + ">::Impl");
}
}