[Mlir-commits] [mlir] b41bfb8 - [mlir][ods] Fix packing in OperandOrAttribute

Jacques Pienaar llvmlistbot at llvm.org
Tue Aug 17 20:56:14 PDT 2021


Author: Jacques Pienaar
Date: 2021-08-17T20:55:48-07:00
New Revision: b41bfb819d0c3cbffe6dc0679f427ab1f44377b9

URL: https://github.com/llvm/llvm-project/commit/b41bfb819d0c3cbffe6dc0679f427ab1f44377b9
DIFF: https://github.com/llvm/llvm-project/commit/b41bfb819d0c3cbffe6dc0679f427ab1f44377b9.diff

LOG: [mlir][ods] Fix packing in OperandOrAttribute

Wrong combiner was used which led to information loss.

Added: 
    

Modified: 
    mlir/include/mlir/TableGen/Operator.h
    mlir/test/mlir-tblgen/op-result.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/TableGen/Operator.h b/mlir/include/mlir/TableGen/Operator.h
index 7187daa53d90c..4d41d4865b6dc 100644
--- a/mlir/include/mlir/TableGen/Operator.h
+++ b/mlir/include/mlir/TableGen/Operator.h
@@ -277,7 +277,7 @@ class Operator {
   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; }

diff  --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td
index ac8f1cbd49f68..63bc5d0fb417c 100644
--- a/mlir/test/mlir-tblgen/op-result.td
+++ b/mlir/test/mlir-tblgen/op-result.td
@@ -115,12 +115,23 @@ def OpK : NS_Op<"only_input_is_variadic_with_same_value_type_op", [SameOperandsA
 
 // 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();


        


More information about the Mlir-commits mailing list