Skip to content

Commit

Permalink
[mlir][vector][NFC] Drop get...AttrStrName helper functions
Browse files Browse the repository at this point in the history
These functions are not needed. They are auto-generated from the `.td` files.

Differential Revision: https://reviews.llvm.org/D155483
  • Loading branch information
matthias-springer committed Jul 17, 2023
1 parent d17b518 commit 9f808f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 47 deletions.
26 changes: 0 additions & 26 deletions mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
Expand Up @@ -354,9 +354,6 @@ def Vector_MultiDimReductionOp :
"ArrayRef<bool>":$reductionMask, "CombiningKind":$kind)>
];
let extraClassDeclaration = [{
static StringRef getKindAttrStrName() { return "kind"; }
static StringRef getReductionDimsAttrStrName() { return "reduction_dims"; }

VectorType getSourceVectorType() {
return ::llvm::cast<VectorType>(getSource().getType());
}
Expand Down Expand Up @@ -510,7 +507,6 @@ def Vector_ShuffleOp :
let hasFolder = 1;
let hasCanonicalizer = 1;
let extraClassDeclaration = [{
static StringRef getMaskAttrStrName() { return "mask"; }
VectorType getV1VectorType() {
return ::llvm::cast<VectorType>(getV1().getType());
}
Expand Down Expand Up @@ -599,7 +595,6 @@ def Vector_ExtractOp :
OpBuilder<(ins "Value":$source, "ValueRange":$position)>
];
let extraClassDeclaration = [{
static StringRef getPositionAttrStrName() { return "position"; }
VectorType getSourceVectorType() {
return ::llvm::cast<VectorType>(getVector().getType());
}
Expand Down Expand Up @@ -723,7 +718,6 @@ def Vector_InsertOp :
OpBuilder<(ins "Value":$source, "Value":$dest, "ValueRange":$position)>
];
let extraClassDeclaration = [{
static StringRef getPositionAttrStrName() { return "position"; }
Type getSourceType() { return getSource().getType(); }
VectorType getDestVectorType() {
return ::llvm::cast<VectorType>(getDest().getType());
Expand Down Expand Up @@ -882,8 +876,6 @@ def Vector_InsertStridedSliceOp :
"ArrayRef<int64_t>":$offsets, "ArrayRef<int64_t>":$strides)>
];
let extraClassDeclaration = [{
static StringRef getOffsetsAttrStrName() { return "offsets"; }
static StringRef getStridesAttrStrName() { return "strides"; }
VectorType getSourceVectorType() {
return ::llvm::cast<VectorType>(getSource().getType());
}
Expand Down Expand Up @@ -981,9 +973,6 @@ def Vector_OuterProductOp :
VectorType getResultVectorType() {
return ::llvm::cast<VectorType>(getResult().getType());
}
static constexpr StringRef getKindAttrStrName() {
return "kind";
}
static CombiningKind getDefaultKind() {
return CombiningKind::ADD;
}
Expand Down Expand Up @@ -1099,12 +1088,6 @@ def Vector_ReshapeOp :
int64_t getNumOutputShapeSizes() { return getOutputShape().size(); }

void getFixedVectorSizes(SmallVectorImpl<int64_t> &results);

static StringRef getFixedVectorSizesAttrStrName() {
return "fixed_vector_sizes";
}
static StringRef getInputShapeAttrStrName() { return "input_shape"; }
static StringRef getOutputShapeAttrStrName() { return "output_shape"; }
}];

let assemblyFormat = [{
Expand Down Expand Up @@ -1151,9 +1134,6 @@ def Vector_ExtractStridedSliceOp :
"ArrayRef<int64_t>":$sizes, "ArrayRef<int64_t>":$strides)>
];
let extraClassDeclaration = [{
static StringRef getOffsetsAttrStrName() { return "offsets"; }
static StringRef getSizesAttrStrName() { return "sizes"; }
static StringRef getStridesAttrStrName() { return "strides"; }
VectorType getSourceVectorType() {
return ::llvm::cast<VectorType>(getVector().getType());
}
Expand Down Expand Up @@ -2288,9 +2268,6 @@ def Vector_ConstantMaskOp :
```
}];

let extraClassDeclaration = [{
static StringRef getMaskDimSizesAttrStrName() { return "mask_dim_sizes"; }
}];
let assemblyFormat = "$mask_dim_sizes attr-dict `:` type(results)";
let hasVerifier = 1;
}
Expand Down Expand Up @@ -2473,7 +2450,6 @@ def Vector_TransposeOp :
return ::llvm::cast<VectorType>(getResult().getType());
}
void getTransp(SmallVectorImpl<int64_t> &results);
static StringRef getTranspAttrStrName() { return "transp"; }
}];
let assemblyFormat = [{
$vector `,` $transp attr-dict `:` type($vector) `to` type($result)
Expand Down Expand Up @@ -2738,8 +2714,6 @@ def Vector_ScanOp :
CArg<"bool", "true">:$inclusive)>
];
let extraClassDeclaration = [{
static StringRef getKindAttrStrName() { return "kind"; }
static StringRef getReductionDimAttrStrName() { return "reduction_dim"; }
VectorType getSourceType() {
return ::llvm::cast<VectorType>(getSource().getType());
}
Expand Down
42 changes: 21 additions & 21 deletions mlir/lib/Dialect/Vector/IR/VectorOps.cpp
Expand Up @@ -1218,8 +1218,7 @@ static LogicalResult foldExtractOpFromExtractChain(ExtractOp extractOp) {
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(extractOp.getContext());
std::reverse(globalPosition.begin(), globalPosition.end());
extractOp->setAttr(ExtractOp::getPositionAttrStrName(),
b.getI64ArrayAttr(globalPosition));
extractOp.setPositionAttr(b.getI64ArrayAttr(globalPosition));
return success();
}

Expand Down Expand Up @@ -1499,8 +1498,7 @@ static Value foldExtractFromBroadcast(ExtractOp extractOp) {
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(extractOp.getContext());
extractOp.setOperand(source);
extractOp->setAttr(ExtractOp::getPositionAttrStrName(),
b.getI64ArrayAttr(extractPos));
extractOp.setPositionAttr(b.getI64ArrayAttr(extractPos));
return extractOp.getResult();
}

Expand Down Expand Up @@ -1565,8 +1563,7 @@ static Value foldExtractFromShapeCast(ExtractOp extractOp) {
SmallVector<int64_t, 4> newPosition = delinearize(position, newStrides);
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(extractOp.getContext());
extractOp->setAttr(ExtractOp::getPositionAttrStrName(),
b.getI64ArrayAttr(newPosition));
extractOp.setPositionAttr(b.getI64ArrayAttr(newPosition));
extractOp.setOperand(shapeCastOp.getSource());
return extractOp.getResult();
}
Expand Down Expand Up @@ -1613,8 +1610,7 @@ static Value foldExtractFromExtractStrided(ExtractOp extractOp) {
extractOp.getVectorMutable().assign(extractStridedSliceOp.getVector());
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(extractOp.getContext());
extractOp->setAttr(ExtractOp::getPositionAttrStrName(),
b.getI64ArrayAttr(extractedPos));
extractOp.setPositionAttr(b.getI64ArrayAttr(extractedPos));
return extractOp.getResult();
}

Expand Down Expand Up @@ -1679,8 +1675,7 @@ static Value foldExtractStridedOpFromInsertChain(ExtractOp extractOp) {
extractOp.getVectorMutable().assign(insertOp.getSource());
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(extractOp.getContext());
extractOp->setAttr(ExtractOp::getPositionAttrStrName(),
b.getI64ArrayAttr(offsetDiffs));
extractOp.setPositionAttr(b.getI64ArrayAttr(offsetDiffs));
return extractOp.getResult();
}
// If the chunk extracted is disjoint from the chunk inserted, keep
Expand Down Expand Up @@ -2300,7 +2295,7 @@ void InsertOp::build(OpBuilder &builder, OperationState &result, Value source,
result.addOperands({source, dest});
auto positionAttr = getVectorSubscriptAttr(builder, position);
result.addTypes(dest.getType());
result.addAttribute(getPositionAttrStrName(), positionAttr);
result.addAttribute(InsertOp::getPositionAttrName(result.name), positionAttr);
}

// Convenience builder which assumes the values are constant indices.
Expand Down Expand Up @@ -2467,8 +2462,10 @@ void InsertStridedSliceOp::build(OpBuilder &builder, OperationState &result,
auto offsetsAttr = getVectorSubscriptAttr(builder, offsets);
auto stridesAttr = getVectorSubscriptAttr(builder, strides);
result.addTypes(dest.getType());
result.addAttribute(getOffsetsAttrStrName(), offsetsAttr);
result.addAttribute(getStridesAttrStrName(), stridesAttr);
result.addAttribute(InsertStridedSliceOp::getOffsetsAttrName(result.name),
offsetsAttr);
result.addAttribute(InsertStridedSliceOp::getStridesAttrName(result.name),
stridesAttr);
}

// TODO: Should be moved to Tablegen ConfinedAttr attributes.
Expand Down Expand Up @@ -2790,9 +2787,9 @@ ParseResult OuterProductOp::parse(OpAsmParser &parser, OperationState &result) {
scalableDimsRes);
}

if (!result.attributes.get(OuterProductOp::getKindAttrStrName())) {
if (!result.attributes.get(OuterProductOp::getKindAttrName(result.name))) {
result.attributes.append(
OuterProductOp::getKindAttrStrName(),
OuterProductOp::getKindAttrName(result.name),
CombiningKindAttr::get(result.getContext(),
OuterProductOp::getDefaultKind()));
}
Expand Down Expand Up @@ -2951,9 +2948,12 @@ void ExtractStridedSliceOp::build(OpBuilder &builder, OperationState &result,
result.addTypes(
inferStridedSliceOpResultType(llvm::cast<VectorType>(source.getType()),
offsetsAttr, sizesAttr, stridesAttr));
result.addAttribute(getOffsetsAttrStrName(), offsetsAttr);
result.addAttribute(getSizesAttrStrName(), sizesAttr);
result.addAttribute(getStridesAttrStrName(), stridesAttr);
result.addAttribute(ExtractStridedSliceOp::getOffsetsAttrName(result.name),
offsetsAttr);
result.addAttribute(ExtractStridedSliceOp::getSizesAttrName(result.name),
sizesAttr);
result.addAttribute(ExtractStridedSliceOp::getStridesAttrName(result.name),
stridesAttr);
}

LogicalResult ExtractStridedSliceOp::verify() {
Expand Down Expand Up @@ -3046,8 +3046,7 @@ foldExtractStridedOpFromInsertChain(ExtractStridedSliceOp op) {
op.setOperand(insertOp.getSource());
// OpBuilder is only used as a helper to build an I64ArrayAttr.
OpBuilder b(op.getContext());
op->setAttr(ExtractStridedSliceOp::getOffsetsAttrStrName(),
b.getI64ArrayAttr(offsetDiffs));
op.setOffsetsAttr(b.getI64ArrayAttr(offsetDiffs));
return success();
}
// If the chunk extracted is disjoint from the chunk inserted, keep looking
Expand Down Expand Up @@ -4973,7 +4972,8 @@ void vector::TransposeOp::build(OpBuilder &builder, OperationState &result,

result.addOperands(vector);
result.addTypes(VectorType::get(transposedShape, vt.getElementType()));
result.addAttribute(getTranspAttrStrName(), builder.getI64ArrayAttr(transp));
result.addAttribute(TransposeOp::getTranspAttrName(result.name),
builder.getI64ArrayAttr(transp));
}

OpFoldResult vector::TransposeOp::fold(FoldAdaptor adaptor) {
Expand Down

0 comments on commit 9f808f6

Please sign in to comment.