struct OperandOrAttribute {
enum class Kind { Operand, Attribute };
OperandOrAttribute(Kind kind, int index) {
- packed = (index << 1) & (kind == Kind::Attribute);
+ packed = (index << 1) | (kind == Kind::Attribute);
}
int operandOrAttributeIndex() const { return (packed >> 1); }
Kind kind() { return (packed & 0x1) ? Kind::Attribute : Kind::Operand; }
// Test with inferred shapes and interleaved with operands/attributes.
//
-def OpL : NS_Op<"op_with_all_types_constraint",
+def OpL1 : NS_Op<"op_with_all_types_constraint",
[AllTypesMatch<["a", "b"]>]> {
let arguments = (ins I32Attr:$attr1, AnyType:$a);
let results = (outs Res<AnyType, "output b", []>:$b);
}
-// CHECK-LABEL: LogicalResult OpL::inferReturnTypes
+// CHECK-LABEL: LogicalResult OpL1::inferReturnTypes
// CHECK-NOT: }
// CHECK: inferredReturnTypes[0] = operands[0].getType();
+
+def OpL2 : NS_Op<"op_with_all_types_constraint",
+ [AllTypesMatch<["c", "b"]>, AllTypesMatch<["a", "d"]>]> {
+ let arguments = (ins I32Attr:$attr1, AnyType:$a, AnyType:$a2, AnyType:$c);
+ let results = (outs Res<AnyType, "output b", []>:$b, AnyType:$d);
+}
+
+// CHECK-LABEL: LogicalResult OpL2::inferReturnTypes
+// CHECK-NOT: }
+// CHECK: inferredReturnTypes[0] = operands[2].getType();
+// CHECK: inferredReturnTypes[1] = operands[0].getType();