Fix correspondence between trait names in ODS and C++ class names.
authorJacques Pienaar <jpienaar@google.com>
Tue, 28 May 2019 04:18:19 +0000 (21:18 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Sun, 2 Jun 2019 03:04:52 +0000 (20:04 -0700)
    Make the correspondence between the ODS and C++ side clearer.

--

PiperOrigin-RevId: 250211194

mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td
mlir/include/mlir/Dialect/QuantOps/QuantOps.td
mlir/include/mlir/IR/OpBase.td
mlir/include/mlir/LLVMIR/LLVMOps.td
mlir/include/mlir/SPIRV/SPIRVOps.td
mlir/include/mlir/StandardOps/Ops.td
mlir/test/TestDialect/TestOps.td
mlir/test/mlir-tblgen/op-result.td
mlir/tools/mlir-tblgen/RewriterGen.cpp

index 9757cdd..1cf74fc 100644 (file)
@@ -97,7 +97,7 @@ class fxpmath_Op<string mnemonic, list<OpTrait> traits> :
 // Some of these are temporary pending inclusion into a more core dialect.
 //===----------------------------------------------------------------------===//
 
-def fxpmath_ClampISOp : fxpmath_Op<"clampis", [NoSideEffect, SameValueType]> {
+def fxpmath_ClampISOp : fxpmath_Op<"clampis", [NoSideEffect, SameOperandsAndResultType]> {
   let summary =
       "Clamps a signed-integer like argument to a min/max range.";
   let description = [{
@@ -112,7 +112,7 @@ def fxpmath_ClampISOp : fxpmath_Op<"clampis", [NoSideEffect, SameValueType]> {
 
 def fxpmath_ConvertISOp :
     fxpmath_Op<"convertis",
-               [NoSideEffect, SameValueShape]> {
+               [NoSideEffect, SameOperandsAndResultShape]> {
   let summary =
       "Does an element-wise conversion from a signed integer to signed integer";
   let description = [{
@@ -125,7 +125,7 @@ def fxpmath_ConvertISOp :
 
 def fxpmath_ConvertISToFOp :
     fxpmath_Op<"convertistof",
-               [NoSideEffect, SameValueShape]> {
+               [NoSideEffect, SameOperandsAndResultShape]> {
   let summary =
       "Does an element-wise conversion from a signed integer to a float";
   let description = [{
@@ -140,7 +140,7 @@ def fxpmath_ConvertISToFOp :
 
 def fxpmath_VecScalarSaturatingRoundingDoublingHighMulISOp :
     fxpmath_Op<"vs_saturating_rounding_doubling_high_mulis",
-               [NoSideEffect, SameValueType]> {
+               [NoSideEffect, SameOperandsAndResultType]> {
   let summary = "Implements equivalent functionality to ARMv7 NEON VQRDMULH";
   let description = [{
     Equivalent to the ARMv7 NEON VQRDMULH instruction.
@@ -152,7 +152,7 @@ def fxpmath_VecScalarSaturatingRoundingDoublingHighMulISOp :
 }
 
 def fxpmath_RoundingDivideByPotISOp :
-    fxpmath_Op<"rounding_divide_by_potis", [NoSideEffect, SameValueType]> {
+    fxpmath_Op<"rounding_divide_by_potis", [NoSideEffect, SameOperandsAndResultType]> {
   let summary = [{
     Computes a rounding arithmetic right shift.
   }];
index 5671828..c76ad2d 100644 (file)
@@ -104,7 +104,7 @@ def quant_StorageCastOp : quant_Op<"scast", [NoSideEffect]> {
 //===----------------------------------------------------------------------===//
 
 def quant_ConstFakeQuant : quant_Op<"const_fake_quant",
-                                    [SameValueType, NoSideEffect]> {
+                                    [SameOperandsAndResultType, NoSideEffect]> {
   let summary =
       "Simulates the effect of uniform quantization with const range.";
 
@@ -130,7 +130,7 @@ def quant_ConstFakeQuant : quant_Op<"const_fake_quant",
   );
 }
 
-def quant_StatisticsRefOp : quant_Op<"stats_ref", [SameValueType]> {
+def quant_StatisticsRefOp : quant_Op<"stats_ref", [SameOperandsAndResultType]> {
   let summary =
       "Indicates that statistics are resolved by reference.";
 
@@ -149,7 +149,7 @@ def quant_StatisticsRefOp : quant_Op<"stats_ref", [SameValueType]> {
   let results = (outs quant_RealValueType);
 }
 
-def quant_StatisticsOp : quant_Op<"stats", [SameValueType]> {
+def quant_StatisticsOp : quant_Op<"stats", [SameOperandsAndResultType]> {
   let summary =
       "Identity op which associates statistics with the value.";
 
@@ -203,7 +203,7 @@ def quant_StatisticsOp : quant_Op<"stats", [SameValueType]> {
   }];
 }
 
-def quant_CoupledRefOp : quant_Op<"coupled_ref", [SameValueType]> {
+def quant_CoupledRefOp : quant_Op<"coupled_ref", [SameOperandsAndResultType]> {
   let summary =
       "Indicates that one point of the computation is coupled to another.";
 
index 99be357..8ef6e0b 100644 (file)
@@ -827,15 +827,15 @@ def Broadcastable    : NativeOpTrait<"BroadcastableTwoOperandsOneResult">;
 // X op Y == Y op X
 def Commutative      : NativeOpTrait<"IsCommutative">;
 // Op results are float or vectors/tensors thereof.
-def FloatLikeResults : NativeOpTrait<"ResultsAreFloatLike">;
+def ResultsAreFloatLike : NativeOpTrait<"ResultsAreFloatLike">;
 // Op has no side effect.
 def NoSideEffect     : NativeOpTrait<"HasNoSideEffect">;
 // Op has the same operand type.
-def SameOperandType  : NativeOpTrait<"SameTypeOperands">;
+def SameTypeOperands  : NativeOpTrait<"SameTypeOperands">;
 // Op has same operand and result shape.
-def SameValueShape   : NativeOpTrait<"SameOperandsAndResultShape">;
+def SameOperandsAndResultShape   : NativeOpTrait<"SameOperandsAndResultShape">;
 // Op has the same operand and result type.
-def SameValueType    : NativeOpTrait<"SameOperandsAndResultType">;
+def SameOperandsAndResultType    : NativeOpTrait<"SameOperandsAndResultType">;
 // Op has the same operand and result element type.
 def SameOperandsAndResultElementType :
   NativeOpTrait<"SameOperandsAndResultElementType">;
index f0b8caf..a207e94 100644 (file)
@@ -114,7 +114,7 @@ class LLVM_TerminatorOp<string mnemonic, list<OpTrait> traits = []> :
 class LLVM_ArithmeticOp<string mnemonic, string builderFunc,
                         list<OpTrait> traits = []> :
     LLVM_OneResultOp<mnemonic,
-           !listconcat([NoSideEffect, SameValueType], traits)>,
+           !listconcat([NoSideEffect, SameOperandsAndResultType], traits)>,
     Arguments<(ins LLVM_Type:$lhs, LLVM_Type:$rhs)>,
     LLVM_Builder<"$res = builder." # builderFunc # "($lhs, $rhs);"> {
   let parser = [{ return impl::parseBinaryOp(parser, result); }];
index 73eee63..a3d74d1 100644 (file)
@@ -69,7 +69,7 @@ class SPV_ScalarOrVectorOf<Type type> :
 class SPV_Op<string mnemonic, list<OpTrait> traits = []> :
     Op<SPV_Dialect, mnemonic, traits>;
 
-def SPV_FMulOp : SPV_Op<"FMul", [NoSideEffect, SameValueType]> {
+def SPV_FMulOp : SPV_Op<"FMul", [NoSideEffect, SameOperandsAndResultType]> {
   let summary = "Floating-point multiplication of Operand 1 and Operand 2";
 
   let description = [{
index f7b77a1..a9f681a 100644 (file)
@@ -75,7 +75,7 @@ class CastOp<string mnemonic, list<OpTrait> traits = []> :
 // types.  Individual classes will have `lhs` and `rhs` accessor to operands.
 class ArithmeticOp<string mnemonic, list<OpTrait> traits = []> :
     Op<Std_Dialect, mnemonic,
-       !listconcat(traits, [NoSideEffect, SameValueType])> {
+       !listconcat(traits, [NoSideEffect, SameOperandsAndResultType])> {
 
   let results = (outs AnyType);
 
@@ -278,7 +278,7 @@ def CallIndirectOp : Std_Op<"call_indirect"> {
   let hasCanonicalizer = 1;
 }
 
-def CmpIOp : Std_Op<"cmpi", [NoSideEffect, SameOperandType, SameValueShape]> {
+def CmpIOp : Std_Op<"cmpi", [NoSideEffect, SameTypeOperands, SameOperandsAndResultShape]> {
   let summary = "integer comparison operation";
   let description = [{
     The "cmpi" operation compares its two operands according to the integer
@@ -323,7 +323,7 @@ def CmpIOp : Std_Op<"cmpi", [NoSideEffect, SameOperandType, SameValueShape]> {
   let hasFolder = 1;
 }
 
-def CmpFOp : Std_Op<"cmpf", [NoSideEffect, SameOperandType, SameValueShape]> {
+def CmpFOp : Std_Op<"cmpf", [NoSideEffect, SameTypeOperands, SameOperandsAndResultShape]> {
   let summary = "floating-point comparison operation";
   let description = [{
     The "cmpf" operation compares its two operands according to the float
@@ -607,7 +607,7 @@ def ReturnOp : Std_Op<"return", [Terminator]> {
   >];
 }
 
-def SelectOp : Std_Op<"select", [NoSideEffect, SameValueShape]> {
+def SelectOp : Std_Op<"select", [NoSideEffect, SameOperandsAndResultShape]> {
   let summary = "select operation";
   let description = [{
     The "select" operation chooses one value based on a binary condition
index 9a7ead7..3c0ade3 100644 (file)
@@ -72,7 +72,7 @@ def SameOperandAndResultElementTypeOp : TEST_Op<"same_operand_and_result_type",
 }
 
 def SameOperandAndResultShapeOp : TEST_Op<"same_operand_and_result_shape",
-    [SameValueShape]> {
+    [SameOperandsAndResultShape]> {
   let arguments = (ins AnyVectorOrTensor:$x, AnyVectorOrTensor:$y);
   let results = (outs AnyVectorOrTensor:$res);
 }
index 4bce522..bc356b8 100644 (file)
@@ -24,7 +24,7 @@ def OpA : NS_Op<"one_normal_result_op", []> {
 // CHECK:         if (!((this->getOperation()->getResult(0)->getType().isInteger(32))))
 // CHECK-NEXT:      return emitOpError("result #0 must be 32-bit integer");
 
-def OpB : NS_Op<"same_input_output_type_op", [SameValueType]> {
+def OpB : NS_Op<"same_input_output_type_op", [SameOperandsAndResultType]> {
   let arguments = (ins I32:$x);
   let results = (outs I32:$y);
 }
@@ -158,7 +158,7 @@ def OpJ : NS_Op<"one_variadic_among_multi_normal_results_op", []> {
 // Test that if the only operand is variadic, we acess the first value in the
 // pack to set result type
 // ---
-def OpK : NS_Op<"only_input_is_variadic_with_same_value_type_op", [SameValueType]> {
+def OpK : NS_Op<"only_input_is_variadic_with_same_value_type_op", [SameOperandsAndResultType]> {
   let arguments = (ins Variadic<AnyTensor>:$input);
   let results = (outs AnyTensor:$result);
 }
index cd93b98..6933eee 100644 (file)
@@ -713,11 +713,13 @@ std::string PatternEmitter::emitOpCreate(DagNode tree, int resultIndex,
 
   // Then we build the new op corresponding to this DAG node.
 
-  bool isSameValueType = resultOp.hasTrait("SameOperandsAndResultType");
+  bool isSameOperandsAndResultType =
+      resultOp.hasTrait("SameOperandsAndResultType");
   bool isBroadcastable = resultOp.hasTrait("BroadcastableTwoOperandsOneResult");
   bool useFirstAttr = resultOp.hasTrait("FirstAttrDerivedResultType");
 
-  if (isSameValueType || isBroadcastable || useFirstAttr || depth > 0) {
+  if (isSameOperandsAndResultType || isBroadcastable || useFirstAttr ||
+      depth > 0) {
     os.indent(4) << formatv("auto {0} = rewriter.create<{1}>(loc", resultValue,
                             resultOp.getQualCppClassName());
   } else {