From 9a326368bbae7c7b52ccb9558b21022e544929e4 Mon Sep 17 00:00:00 2001 From: Bea Healy <57840981+TaoBi22@users.noreply.github.com> Date: Wed, 30 Apr 2025 08:38:48 +0100 Subject: [PATCH] [Comb] Drop redundant concat verifier (#8454) --- include/circt/Dialect/Comb/Combinational.td | 1 - lib/Dialect/Comb/CombOps.cpp | 12 ------------ test/Dialect/Comb/errors.mlir | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/include/circt/Dialect/Comb/Combinational.td b/include/circt/Dialect/Comb/Combinational.td index 114d5ce1ce..9321d2912d 100644 --- a/include/circt/Dialect/Comb/Combinational.td +++ b/include/circt/Dialect/Comb/Combinational.td @@ -214,7 +214,6 @@ def ConcatOp : CombOp<"concat", [InferTypeOpInterface, Pure]> { let hasFolder = true; let hasCanonicalizeMethod = true; - let hasVerifier = 1; let assemblyFormat = "$inputs attr-dict `:` qualified(type($inputs))"; diff --git a/lib/Dialect/Comb/CombOps.cpp b/lib/Dialect/Comb/CombOps.cpp index 652ec40fba..941a205acc 100644 --- a/lib/Dialect/Comb/CombOps.cpp +++ b/lib/Dialect/Comb/CombOps.cpp @@ -297,18 +297,6 @@ static unsigned getTotalWidth(ValueRange inputs) { return resultWidth; } -LogicalResult ConcatOp::verify() { - unsigned tyWidth = cast(getType()).getWidth(); - unsigned operandsTotalWidth = getTotalWidth(getInputs()); - if (tyWidth != operandsTotalWidth) - return emitOpError("ConcatOp requires operands total width to " - "match type width. operands " - "totalWidth is") - << operandsTotalWidth << ", but concatOp type width is " << tyWidth; - - return success(); -} - void ConcatOp::build(OpBuilder &builder, OperationState &result, Value hd, ValueRange tl) { result.addOperands(ValueRange{hd}); diff --git a/test/Dialect/Comb/errors.mlir b/test/Dialect/Comb/errors.mlir index d8c6ca0883..363df1b51b 100644 --- a/test/Dialect/Comb/errors.mlir +++ b/test/Dialect/Comb/errors.mlir @@ -11,3 +11,22 @@ hw.module @err(in %a: i1, in %b: i1) { // expected-error @+1 {{Truth tables support a maximum of 63 inputs}} %0 = comb.truth_table %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b, %a, %b -> [false] } + +// ----- + +hw.module @err(in %a: i4, out out: i7) { + // expected-note @+1 {{prior use here}} + %0 = comb.concat %a, %a : i4, i4 + // expected-error @+1 {{use of value '%0' expects different type than prior uses: 'i7' vs 'i8'}} + hw.output %0 : i7 +} + +// ----- + +// Check return type is still inferred correctly with generic parser +hw.module @err(in %a: i4, out out: i7) { + // expected-error @+2 {{'comb.concat' op inferred type(s) 'i8' are incompatible with return type(s) of operation 'i7'}} + // expected-error @+1 {{'comb.concat' op failed to infer returned types}} + %0 = "comb.concat"(%a, %a) : (i4, i4) -> i7 + hw.output %0 : i7 +}