From: Jacques Pienaar Date: Tue, 28 May 2019 04:18:19 +0000 (-0700) Subject: Fix correspondence between trait names in ODS and C++ class names. X-Git-Tag: llvmorg-11-init~1466^2~1585 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ffc4cf70919db5883c56edaec7889f8e3ae4a83f;p=platform%2Fupstream%2Fllvm.git Fix correspondence between trait names in ODS and C++ class names. Make the correspondence between the ODS and C++ side clearer. -- PiperOrigin-RevId: 250211194 --- diff --git a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td index 9757cdd..1cf74fc 100644 --- a/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td +++ b/mlir/include/mlir/Dialect/FxpMathOps/FxpMathOps.td @@ -97,7 +97,7 @@ class fxpmath_Op 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. }]; diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td index 5671828..c76ad2d 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td +++ b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td @@ -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."; diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index 99be357..8ef6e0b 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -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">; diff --git a/mlir/include/mlir/LLVMIR/LLVMOps.td b/mlir/include/mlir/LLVMIR/LLVMOps.td index f0b8caf..a207e94 100644 --- a/mlir/include/mlir/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/LLVMIR/LLVMOps.td @@ -114,7 +114,7 @@ class LLVM_TerminatorOp traits = []> : class LLVM_ArithmeticOp traits = []> : LLVM_OneResultOp, + !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); }]; diff --git a/mlir/include/mlir/SPIRV/SPIRVOps.td b/mlir/include/mlir/SPIRV/SPIRVOps.td index 73eee63..a3d74d1 100644 --- a/mlir/include/mlir/SPIRV/SPIRVOps.td +++ b/mlir/include/mlir/SPIRV/SPIRVOps.td @@ -69,7 +69,7 @@ class SPV_ScalarOrVectorOf : class SPV_Op traits = []> : Op; -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 = [{ diff --git a/mlir/include/mlir/StandardOps/Ops.td b/mlir/include/mlir/StandardOps/Ops.td index f7b77a1..a9f681a 100644 --- a/mlir/include/mlir/StandardOps/Ops.td +++ b/mlir/include/mlir/StandardOps/Ops.td @@ -75,7 +75,7 @@ class CastOp traits = []> : // types. Individual classes will have `lhs` and `rhs` accessor to operands. class ArithmeticOp traits = []> : Op { + !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 diff --git a/mlir/test/TestDialect/TestOps.td b/mlir/test/TestDialect/TestOps.td index 9a7ead7..3c0ade3 100644 --- a/mlir/test/TestDialect/TestOps.td +++ b/mlir/test/TestDialect/TestOps.td @@ -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); } diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td index 4bce522..bc356b8 100644 --- a/mlir/test/mlir-tblgen/op-result.td +++ b/mlir/test/mlir-tblgen/op-result.td @@ -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:$input); let results = (outs AnyTensor:$result); } diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index cd93b98..6933eee 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -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 {