Hi all,
There is an op in the RTL dialect that is defined like this, note the required $lowBit
attribute:
def ExtractOp : RTLOp<"extract", [NoSideEffect]> {
let summary = "Extract a range of bits into a smaller value, lowBit "
"specifies the lowest bit included.";
let arguments = (ins RTLIntegerType:$input, I32Attr:$lowBit);
let results = (outs RTLIntegerType:$result);
let assemblyFormat =
"$input `from` $lowBit attr-dict `:` functional-type($input, $result)";
let hasFolder = true;
let verifier = "return ::verifyExtractOp(*this);";
}
ODS is generating this pile of build methods:
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result,
::mlir::Value input, ::mlir::IntegerAttr lowBit);
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes,
::mlir::Value input, ::mlir::IntegerAttr lowBit);
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result,
::mlir::Value input, uint32_t lowBit);
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes,
::mlir::Value input, uint32_t lowBit);
static void build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes,
::mlir::ValueRange operands,
::llvm::ArrayRef<::mlir::NamedAttribute> attributes = {});
We had a bug where some code accidentally forgot the attribute. It was:
Value replacement = rewriter.create<ExtractOp>(
op.getLoc(), resType, extract.input());
instead of:
Value replacement = rewriter.create<ExtractOp>(
op.getLoc(), resType, extract.input(), extract.lowBit());
This is super scary to me - this should be a static compiler error.
The question: Is there a reason that ODS is generating the = {}
on the attribute set for the last builder? This seems like it should only happen on ops that have no required attributes.
Another less important question, but why generate the TypeRange version of the builder for something that has known to have a single result type? This seems like just code size bloat, anyone that has a type range could extract the single type and pass it instead.
-Chris