aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flang/include/flang/Optimizer/Dialect/FIROps.td6
-rw-r--r--flang/lib/Lower/OpenACC.cpp4
-rw-r--r--flang/lib/Optimizer/Dialect/FIROps.cpp115
-rw-r--r--flang/test/Fir/convert-to-llvm-openmp-and-fir.fir4
-rw-r--r--flang/test/Fir/convert-to-llvm.fir8
-rw-r--r--mlir/docs/PatternRewriter.md2
-rw-r--r--mlir/include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td2
-rw-r--r--mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td2
-rw-r--r--mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td2
-rw-r--r--mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td2
-rw-r--r--mlir/include/mlir/IR/ValueRange.h8
-rw-r--r--mlir/lib/Dialect/Async/IR/Async.cpp10
-rw-r--r--mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp2
-rw-r--r--mlir/lib/Dialect/GPU/IR/GPUDialect.cpp12
-rw-r--r--mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp10
-rw-r--r--mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp8
-rw-r--r--mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp6
-rw-r--r--mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp4
-rw-r--r--mlir/lib/Dialect/SCF/IR/SCF.cpp16
-rw-r--r--mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp8
-rw-r--r--mlir/lib/Dialect/Vector/IR/VectorOps.cpp16
-rw-r--r--mlir/lib/IR/Operation.cpp21
-rw-r--r--mlir/lib/IR/OperationSupport.cpp23
-rw-r--r--mlir/lib/Rewrite/ByteCode.cpp6
-rw-r--r--mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp2
-rw-r--r--mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir4
-rw-r--r--mlir/test/Dialect/GPU/invalid.mlir8
-rw-r--r--mlir/test/Dialect/Linalg/named-ops.mlir4
-rw-r--r--mlir/test/Dialect/OpenMP/invalid.mlir20
-rw-r--r--mlir/test/Dialect/OpenMP/ops.mlir30
-rw-r--r--mlir/test/Dialect/PDL/invalid.mlir10
-rw-r--r--mlir/test/Dialect/PDLInterp/invalid.mlir3
-rw-r--r--mlir/test/Dialect/SCF/invalid.mlir4
-rw-r--r--mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir4
-rw-r--r--mlir/test/IR/parser.mlir2
-rw-r--r--mlir/test/IR/traits.mlir45
-rw-r--r--mlir/test/Rewrite/pdl-bytecode.mlir4
-rw-r--r--mlir/test/Target/LLVMIR/openmp-llvm.mlir16
-rw-r--r--mlir/test/Transforms/canonicalize-block-merge.mlir2
-rw-r--r--mlir/test/Transforms/sccp.mlir3
-rw-r--r--mlir/test/lib/Dialect/Test/TestOps.td6
-rw-r--r--mlir/test/python/dialects/linalg/ops.py10
-rw-r--r--mlir/test/python/dialects/ods_helpers.py6
-rw-r--r--mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp30
-rw-r--r--mlir/tools/mlir-tblgen/OpFormatGen.cpp6
45 files changed, 244 insertions, 272 deletions
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index e7d8fa4..ff0642b 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -417,7 +417,7 @@ def fir_UndefOp : fir_OneResultOp<"undefined", [NoSideEffect]> {
let results = (outs AnyType:$intype);
let assemblyFormat = "type($intype) attr-dict";
-
+
// Note: we allow `undef : ref<T>` since it is a possible from transformations.
let hasVerifier = 0;
}
@@ -538,9 +538,9 @@ class fir_IntegralSwitchTerminatorOp<string mnemonic,
}
}
$_state.addAttribute(getOperandSegmentSizeAttr(),
- $_builder.getI32VectorAttr({1, 0, sumArgs}));
+ $_builder.getDenseI32ArrayAttr({1, 0, sumArgs}));
$_state.addAttribute(getTargetOffsetAttr(),
- $_builder.getI32VectorAttr(argOffs));
+ $_builder.getDenseI32ArrayAttr(argOffs));
$_state.addAttributes(attributes);
}]
>];
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 2259060..4b55c8b 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -113,7 +113,7 @@ createRegionOp(fir::FirOpBuilder &builder, mlir::Location loc,
builder.create<Terminator>(loc);
op->setAttr(Op::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr(operandSegments));
+ builder.getDenseI32ArrayAttr(operandSegments));
// Place the insertion point to the start of the first block.
builder.setInsertionPointToStart(&block);
@@ -129,7 +129,7 @@ createSimpleOp(fir::FirOpBuilder &builder, mlir::Location loc,
llvm::ArrayRef<mlir::Type> argTy;
Op op = builder.create<Op>(loc, argTy, operands);
op->setAttr(Op::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr(operandSegments));
+ builder.getDenseI32ArrayAttr(operandSegments));
return op;
}
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 6db08c9..1c1e1a6 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -126,8 +126,9 @@ static mlir::ParseResult parseAllocatableOp(FN wrapResultType,
parser.emitError(parser.getNameLoc(), "invalid allocate type: ") << intype;
return mlir::failure();
}
- result.addAttribute("operand_segment_sizes",
- builder.getI32VectorAttr({typeparamsSize, shapeSize}));
+ result.addAttribute(
+ "operand_segment_sizes",
+ builder.getDenseI32ArrayAttr({typeparamsSize, shapeSize}));
if (parser.parseOptionalAttrDict(result.attributes) ||
parser.addTypeToList(restype, result.types))
return mlir::failure();
@@ -2431,8 +2432,8 @@ static mlir::ParseResult parseIntegralSwitchTerminator(
sumArgs += argSize;
}
result.addAttribute(operandSegmentAttr,
- bld.getI32VectorAttr({1, 0, sumArgs}));
- result.addAttribute(getTargetOffsetAttr(), bld.getI32VectorAttr(argOffs));
+ bld.getDenseI32ArrayAttr({1, 0, sumArgs}));
+ result.addAttribute(getTargetOffsetAttr(), bld.getDenseI32ArrayAttr(argOffs));
return mlir::success();
}
@@ -2480,13 +2481,12 @@ void fir::SelectOp::print(mlir::OpAsmPrinter &p) {
}
template <typename A, typename... AdditionalArgs>
-static A getSubOperands(unsigned pos, A allArgs,
- mlir::DenseIntElementsAttr ranges,
+static A getSubOperands(unsigned pos, A allArgs, mlir::DenseI32ArrayAttr ranges,
AdditionalArgs &&...additionalArgs) {
unsigned start = 0;
for (unsigned i = 0; i < pos; ++i)
- start += (*(ranges.begin() + i)).getZExtValue();
- return allArgs.slice(start, (*(ranges.begin() + pos)).getZExtValue(),
+ start += ranges[i];
+ return allArgs.slice(start, ranges[pos],
std::forward<AdditionalArgs>(additionalArgs)...);
}
@@ -2498,14 +2498,10 @@ getMutableSuccessorOperands(unsigned pos, mlir::MutableOperandRange operands,
*owner->getAttrDictionary().getNamed(offsetAttr);
return getSubOperands(
pos, operands,
- targetOffsetAttr.getValue().cast<mlir::DenseIntElementsAttr>(),
+ targetOffsetAttr.getValue().cast<mlir::DenseI32ArrayAttr>(),
mlir::MutableOperandRange::OperandSegment(pos, targetOffsetAttr));
}
-static unsigned denseElementsSize(mlir::DenseIntElementsAttr attr) {
- return attr.getNumElements();
-}
-
llvm::Optional<mlir::OperandRange> fir::SelectOp::getCompareOperands(unsigned) {
return {};
}
@@ -2524,8 +2520,8 @@ llvm::Optional<llvm::ArrayRef<mlir::Value>>
fir::SelectOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands,
unsigned oper) {
auto a =
- (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(
getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
@@ -2533,15 +2529,16 @@ fir::SelectOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands,
llvm::Optional<mlir::ValueRange>
fir::SelectOp::getSuccessorOperands(mlir::ValueRange operands, unsigned oper) {
auto a =
- (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(
getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
unsigned fir::SelectOp::targetOffsetSize() {
- return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
- getTargetOffsetAttr()));
+ return (*this)
+ ->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr())
+ .size();
}
//===----------------------------------------------------------------------===//
@@ -2550,17 +2547,17 @@ unsigned fir::SelectOp::targetOffsetSize() {
llvm::Optional<mlir::OperandRange>
fir::SelectCaseOp::getCompareOperands(unsigned cond) {
- auto a = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
- getCompareOffsetAttr());
+ auto a =
+ (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(getCompareOffsetAttr());
return {getSubOperands(cond, getCompareArgs(), a)};
}
llvm::Optional<llvm::ArrayRef<mlir::Value>>
fir::SelectCaseOp::getCompareOperands(llvm::ArrayRef<mlir::Value> operands,
unsigned cond) {
- auto a = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
- getCompareOffsetAttr());
- auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ auto a =
+ (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(getCompareOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(
getOperandSegmentSizeAttr());
return {getSubOperands(cond, getSubOperands(1, operands, segments), a)};
}
@@ -2568,9 +2565,9 @@ fir::SelectCaseOp::getCompareOperands(llvm::ArrayRef<mlir::Value> operands,
llvm::Optional<mlir::ValueRange>
fir::SelectCaseOp::getCompareOperands(mlir::ValueRange operands,
unsigned cond) {
- auto a = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
- getCompareOffsetAttr());
- auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ auto a =
+ (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(getCompareOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(
getOperandSegmentSizeAttr());
return {getSubOperands(cond, getSubOperands(1, operands, segments), a)};
}
@@ -2584,8 +2581,8 @@ llvm::Optional<llvm::ArrayRef<mlir::Value>>
fir::SelectCaseOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands,
unsigned oper) {
auto a =
- (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(
getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
@@ -2594,8 +2591,8 @@ llvm::Optional<mlir::ValueRange>
fir::SelectCaseOp::getSuccessorOperands(mlir::ValueRange operands,
unsigned oper) {
auto a =
- (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(
getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
@@ -2668,9 +2665,11 @@ mlir::ParseResult fir::SelectCaseOp::parse(mlir::OpAsmParser &parser,
}
auto &bld = parser.getBuilder();
result.addAttribute(fir::SelectCaseOp::getOperandSegmentSizeAttr(),
- bld.getI32VectorAttr({1, offSize, toffSize}));
- result.addAttribute(getCompareOffsetAttr(), bld.getI32VectorAttr(argOffs));
- result.addAttribute(getTargetOffsetAttr(), bld.getI32VectorAttr(targOffs));
+ bld.getDenseI32ArrayAttr({1, offSize, toffSize}));
+ result.addAttribute(getCompareOffsetAttr(),
+ bld.getDenseI32ArrayAttr(argOffs));
+ result.addAttribute(getTargetOffsetAttr(),
+ bld.getDenseI32ArrayAttr(targOffs));
return mlir::success();
}
@@ -2703,13 +2702,15 @@ void fir::SelectCaseOp::print(mlir::OpAsmPrinter &p) {
}
unsigned fir::SelectCaseOp::compareOffsetSize() {
- return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
- getCompareOffsetAttr()));
+ return (*this)
+ ->getAttrOfType<mlir::DenseI32ArrayAttr>(getCompareOffsetAttr())
+ .size();
}
unsigned fir::SelectCaseOp::targetOffsetSize() {
- return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
- getTargetOffsetAttr()));
+ return (*this)
+ ->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr())
+ .size();
}
void fir::SelectCaseOp::build(mlir::OpBuilder &builder,
@@ -2738,7 +2739,7 @@ void fir::SelectCaseOp::build(mlir::OpBuilder &builder,
for (auto ops : cmpOperands)
result.addOperands(ops);
result.addAttribute(getCompareOffsetAttr(),
- builder.getI32VectorAttr(operOffs));
+ builder.getDenseI32ArrayAttr(operOffs));
const auto count = destinations.size();
for (auto d : destinations)
result.addSuccessors(d);
@@ -2756,8 +2757,9 @@ void fir::SelectCaseOp::build(mlir::OpBuilder &builder,
}
}
result.addAttribute(getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr({1, operSize, sumArgs}));
- result.addAttribute(getTargetOffsetAttr(), builder.getI32VectorAttr(argOffs));
+ builder.getDenseI32ArrayAttr({1, operSize, sumArgs}));
+ result.addAttribute(getTargetOffsetAttr(),
+ builder.getDenseI32ArrayAttr(argOffs));
result.addAttributes(attributes);
}
@@ -2854,8 +2856,8 @@ llvm::Optional<llvm::ArrayRef<mlir::Value>>
fir::SelectRankOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands,
unsigned oper) {
auto a =
- (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(
getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
@@ -2864,15 +2866,16 @@ llvm::Optional<mlir::ValueRange>
fir::SelectRankOp::getSuccessorOperands(mlir::ValueRange operands,
unsigned oper) {
auto a =
- (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(
getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
unsigned fir::SelectRankOp::targetOffsetSize() {
- return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
- getTargetOffsetAttr()));
+ return (*this)
+ ->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr())
+ .size();
}
//===----------------------------------------------------------------------===//
@@ -2898,8 +2901,8 @@ llvm::Optional<llvm::ArrayRef<mlir::Value>>
fir::SelectTypeOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands,
unsigned oper) {
auto a =
- (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(getTargetOffsetAttr());
- auto segments = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
+ (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr());
+ auto segments = (*this)->getAttrOfType<mlir::DenseI32ArrayAttr>(
getOperandSegmentSizeAttr());
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
@@ -2944,14 +2947,15 @@ mlir::ParseResult fir::SelectTypeOp::parse(mlir::OpAsmParser &parser,
offSize += argSize;
}
result.addAttribute(fir::SelectTypeOp::getOperandSegmentSizeAttr(),
- bld.getI32VectorAttr({1, 0, offSize}));
- result.addAttribute(getTargetOffsetAttr(), bld.getI32VectorAttr(argOffs));
+ bld.getDenseI32ArrayAttr({1, 0, offSize}));
+ result.addAttribute(getTargetOffsetAttr(), bld.getDenseI32ArrayAttr(argOffs));
return mlir::success();
}
unsigned fir::SelectTypeOp::targetOffsetSize() {
- return denseElementsSize((*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
- getTargetOffsetAttr()));
+ return (*this)
+ ->getAttrOfType<mlir::DenseI32ArrayAttr>(getTargetOffsetAttr())
+ .size();
}
void fir::SelectTypeOp::print(mlir::OpAsmPrinter &p) {
@@ -3021,8 +3025,9 @@ void fir::SelectTypeOp::build(mlir::OpBuilder &builder,
}
}
result.addAttribute(getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr({1, 0, sumArgs}));
- result.addAttribute(getTargetOffsetAttr(), builder.getI32VectorAttr(argOffs));
+ builder.getDenseI32ArrayAttr({1, 0, sumArgs}));
+ result.addAttribute(getTargetOffsetAttr(),
+ builder.getDenseI32ArrayAttr(argOffs));
result.addAttributes(attributes);
}
diff --git a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
index c600878..d40e69d 100644
--- a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
+++ b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
@@ -28,7 +28,7 @@ func.func @_QPsb1(%arg0: !fir.ref<i32> {fir.bindc_name = "n"}, %arg1: !fir.ref<!
// CHECK: %[[ONE_2:.*]] = llvm.mlir.constant(1 : i32) : i32
// CHECK: omp.parallel {
// CHECK: %[[ONE_3:.*]] = llvm.mlir.constant(1 : i64) : i64
-// CHECK: %[[I_VAR:.*]] = llvm.alloca %[[ONE_3]] x i32 {adapt.valuebyref, in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>, pinned} : (i64) -> !llvm.ptr<i32>
+// CHECK: %[[I_VAR:.*]] = llvm.alloca %[[ONE_3]] x i32 {adapt.valuebyref, in_type = i32, operand_segment_sizes = array<i32: 0, 0>, pinned} : (i64) -> !llvm.ptr<i32>
// CHECK: %[[N:.*]] = llvm.load %[[N_REF]] : !llvm.ptr<i32>
// CHECK: omp.wsloop nowait
// CHECK-SAME: for (%[[I:.*]]) : i32 = (%[[ONE_2]]) to (%[[N]]) inclusive step (%[[ONE_2]]) {
@@ -201,7 +201,7 @@ func.func @_QPsimd1(%arg0: !fir.ref<i32> {fir.bindc_name = "n"}, %arg1: !fir.ref
// CHECK: %[[ONE_2:.*]] = llvm.mlir.constant(1 : i32) : i32
// CHECK: omp.parallel {
// CHECK: %[[ONE_3:.*]] = llvm.mlir.constant(1 : i64) : i64
-// CHECK: %[[I_VAR:.*]] = llvm.alloca %[[ONE_3]] x i32 {adapt.valuebyref, in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>, pinned} : (i64) -> !llvm.ptr<i32>
+// CHECK: %[[I_VAR:.*]] = llvm.alloca %[[ONE_3]] x i32 {adapt.valuebyref, in_type = i32, operand_segment_sizes = array<i32: 0, 0>, pinned} : (i64) -> !llvm.ptr<i32>
// CHECK: %[[N:.*]] = llvm.load %[[N_REF]] : !llvm.ptr<i32>
// CHECK: omp.simdloop
// CHECK-SAME: (%[[I:.*]]) : i32 = (%[[ONE_2]]) to (%[[N]]) step (%[[ONE_2]]) {
diff --git a/flang/test/Fir/convert-to-llvm.fir b/flang/test/Fir/convert-to-llvm.fir
index 388f465..2bd27ee 100644
--- a/flang/test/Fir/convert-to-llvm.fir
+++ b/flang/test/Fir/convert-to-llvm.fir
@@ -1701,7 +1701,7 @@ func.func @no_reassoc(%arg0: !fir.ref<i32>) {
// CHECK-LABEL: llvm.func @no_reassoc(
// CHECK-SAME: %[[ARG0:.*]]: !llvm.ptr<i32>) {
// CHECK: %[[C1:.*]] = llvm.mlir.constant(1 : i64) : i64
-// CHECK: %[[ALLOC:.*]] = llvm.alloca %[[C1]] x i32 {in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>} : (i64) -> !llvm.ptr<i32>
+// CHECK: %[[ALLOC:.*]] = llvm.alloca %[[C1]] x i32 {in_type = i32, operand_segment_sizes = array<i32: 0, 0>} : (i64) -> !llvm.ptr<i32>
// CHECK: %[[LOAD:.*]] = llvm.load %[[ARG0]] : !llvm.ptr<i32>
// CHECK: llvm.store %[[LOAD]], %[[ALLOC]] : !llvm.ptr<i32>
// CHECK: llvm.return
@@ -1821,7 +1821,7 @@ func.func private @_QPxb(!fir.box<!fir.array<?x?xf64>>)
// CHECK: %[[C1_0:.*]] = llvm.mlir.constant(1 : i64) : i64
// CHECK: %[[ARR_SIZE_TMP1:.*]] = llvm.mul %[[C1_0]], %[[N1]] : i64
// CHECK: %[[ARR_SIZE:.*]] = llvm.mul %[[ARR_SIZE_TMP1]], %[[N2]] : i64
-// CHECK: %[[ARR:.*]] = llvm.alloca %[[ARR_SIZE]] x f64 {bindc_name = "arr", in_type = !fir.array<?x?xf64>, operand_segment_sizes = dense<[0, 2]> : vector<2xi32>, uniq_name = "_QFsbEarr"} : (i64) -> !llvm.ptr<f64>
+// CHECK: %[[ARR:.*]] = llvm.alloca %[[ARR_SIZE]] x f64 {bindc_name = "arr", in_type = !fir.array<?x?xf64>, operand_segment_sizes = array<i32: 0, 2>, uniq_name = "_QFsbEarr"} : (i64) -> !llvm.ptr<f64>
// CHECK: %[[BOX0:.*]] = llvm.mlir.undef : !llvm.struct<(ptr<f64>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, array<2 x array<3 x i64>>)>
// CHECK: %[[ELEM_LEN:.*]] = llvm.mlir.constant(8 : i32) : i32
// CHECK: %[[TYPE_CODE:.*]] = llvm.mlir.constant(28 : i32) : i32
@@ -1898,9 +1898,9 @@ func.func private @_QPtest_dt_callee(%arg0: !fir.box<!fir.array<?xi32>>)
// CHECK: %[[C10:.*]] = llvm.mlir.constant(10 : i64) : i64
// CHECK: %[[C2:.*]] = llvm.mlir.constant(2 : i64) : i64
// CHECK: %[[ALLOCA_SIZE_V:.*]] = llvm.mlir.constant(1 : i64) : i64
-// CHECK: %[[V:.*]] = llvm.alloca %[[ALLOCA_SIZE_V]] x i32 {bindc_name = "v", in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFtest_dt_sliceEv"} : (i64) -> !llvm.ptr<i32>
+// CHECK: %[[V:.*]] = llvm.alloca %[[ALLOCA_SIZE_V]] x i32 {bindc_name = "v", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFtest_dt_sliceEv"} : (i64) -> !llvm.ptr<i32>
// CHECK: %[[ALLOCA_SIZE_X:.*]] = llvm.mlir.constant(1 : i64) : i64
-// CHECK: %[[X:.*]] = llvm.alloca %[[ALLOCA_SIZE_X]] x !llvm.array<20 x struct<"_QFtest_dt_sliceTt", (i32, i32)>> {bindc_name = "x", in_type = !fir.array<20x!fir.type<_QFtest_dt_sliceTt{i:i32,j:i32}>>, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFtest_dt_sliceEx"} : (i64) -> !llvm.ptr<array<20 x struct<"_QFtest_dt_sliceTt", (i32, i32)>>>
+// CHECK: %[[X:.*]] = llvm.alloca %[[ALLOCA_SIZE_X]] x !llvm.array<20 x struct<"_QFtest_dt_sliceTt", (i32, i32)>> {bindc_name = "x", in_type = !fir.array<20x!fir.type<_QFtest_dt_sliceTt{i:i32,j:i32}>>, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFtest_dt_sliceEx"} : (i64) -> !llvm.ptr<array<20 x struct<"_QFtest_dt_sliceTt", (i32, i32)>>>
// CHECK: %[[BOX0:.*]] = llvm.mlir.undef : !llvm.struct<(ptr<i32>, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, i{{.*}}, array<1 x array<3 x i64>>)>
// CHECK: %[[ELEM_LEN:.*]] = llvm.mlir.constant(4 : i32) : i32
// CHECK: %[[TYPE_CODE:.*]] = llvm.mlir.constant(9 : i32) : i32
diff --git a/mlir/docs/PatternRewriter.md b/mlir/docs/PatternRewriter.md
index d221ce9..3ae6547 100644
--- a/mlir/docs/PatternRewriter.md
+++ b/mlir/docs/PatternRewriter.md
@@ -357,7 +357,7 @@ Example output is shown below:
```
//===-------------------------------------------===//
Processing operation : 'cf.cond_br'(0x60f000001120) {
- "cf.cond_br"(%arg0)[^bb2, ^bb2] {operand_segment_sizes = dense<[1, 0, 0]> : vector<3xi32>} : (i1) -> ()
+ "cf.cond_br"(%arg0)[^bb2, ^bb2] {operand_segment_sizes = array<i32: 1, 0, 0>} : (i1) -> ()
* Pattern SimplifyConstCondBranchPred : 'cf.cond_br -> ()' {
} -> failure : pattern failed to match
diff --git a/mlir/include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td b/mlir/include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td
index 94c5323..baba706 100644
--- a/mlir/include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td
+++ b/mlir/include/mlir/Dialect/ControlFlow/IR/ControlFlowOps.td
@@ -254,7 +254,7 @@ def SwitchOp : CF_Op<"switch",
Variadic<AnyType>:$defaultOperands,
VariadicOfVariadic<AnyType, "case_operand_segments">:$caseOperands,
OptionalAttr<AnyIntElementsAttr>:$case_values,
- I32ElementsAttr:$case_operand_segments
+ DenseI32ArrayAttr:$case_operand_segments
);
let successors = (successor
AnySuccessor:$defaultDestination,
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 84fc592..b9b0256 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -915,7 +915,7 @@ def LLVM_SwitchOp : LLVM_TerminatorOp<"switch",
Variadic<AnyType>:$defaultOperands,
VariadicOfVariadic<AnyType, "case_operand_segments">:$caseOperands,
OptionalAttr<ElementsAttr>:$case_values,
- ElementsAttr:$case_operand_segments,
+ DenseI32ArrayAttr:$case_operand_segments,
OptionalAttr<ElementsAttr>:$branch_weights
);
let successors = (successor
diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
index cd1b87d..d397d29 100644
--- a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
+++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td
@@ -86,7 +86,7 @@ class AllocLikeOp<string mnemonic,
$_state.addOperands(dynamicSizes);
$_state.addOperands(symbolOperands);
$_state.addAttribute(getOperandSegmentSizeAttr(),
- $_builder.getI32VectorAttr({
+ $_builder.getDenseI32ArrayAttr({
static_cast<int32_t>(dynamicSizes.size()),
static_cast<int32_t>(symbolOperands.size())}));
if (alignment)
diff --git a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
index 44dc6cd..6d32892 100644
--- a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
+++ b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
@@ -417,7 +417,7 @@ def PDLInterp_CreateOperationOp
```mlir
// Create an instance of a `foo.op` operation.
%op = pdl_interp.create_operation "foo.op"(%arg0 : !pdl.value) {"attrA" = %attr0} -> (%type : !pdl.type)
-
+
// Create an instance of a `foo.op` operation that has inferred result types
// (using the InferTypeOpInterface).
%op = pdl_interp.create_operation "foo.op"(%arg0 : !pdl.value) {"attrA" = %attr0} -> <inferred>
diff --git a/mlir/include/mlir/IR/ValueRange.h b/mlir/include/mlir/IR/ValueRange.h
index 6fb35eae..64b816f 100644
--- a/mlir/include/mlir/IR/ValueRange.h
+++ b/mlir/include/mlir/IR/ValueRange.h
@@ -13,6 +13,7 @@
#ifndef MLIR_IR_VALUERANGE_H
#define MLIR_IR_VALUERANGE_H
+#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/Types.h"
#include "mlir/IR/Value.h"
#include "llvm/ADT/PointerUnion.h"
@@ -22,7 +23,6 @@ namespace mlir {
class ValueRange;
template <typename ValueRangeT>
class ValueTypeRange;
-class ElementsAttr;
class TypeRangeRange;
template <typename ValueIteratorT>
class ValueTypeIterator;
@@ -54,7 +54,7 @@ public:
/// Split this range into a set of contiguous subranges using the given
/// elements attribute, which contains the sizes of the sub ranges.
- OperandRangeRange split(ElementsAttr segmentSizes) const;
+ OperandRangeRange split(DenseI32ArrayAttr segmentSizes) const;
private:
/// See `llvm::detail::indexed_accessor_range_base` for details.
@@ -114,8 +114,8 @@ private:
class MutableOperandRange {
public:
/// A pair of a named attribute corresponding to an operand segment attribute,
- /// and the index within that attribute. The attribute should correspond to an
- /// i32 DenseElementsAttr.
+ /// and the index within that attribute. The attribute should correspond to a
+ /// dense i32 array attr.
using OperandSegment = std::pair<unsigned, NamedAttribute>;
/// Construct a new mutable range from the given operand, operand start index,
diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp
index 7331e5f..8a68e0d 100644
--- a/mlir/lib/Dialect/Async/IR/Async.cpp
+++ b/mlir/lib/Dialect/Async/IR/Async.cpp
@@ -97,9 +97,8 @@ void ExecuteOp::build(OpBuilder &builder, OperationState &result,
// Add derived `operand_segment_sizes` attribute based on parsed operands.
int32_t numDependencies = dependencies.size();
int32_t numOperands = operands.size();
- auto operandSegmentSizes = DenseIntElementsAttr::get(
- VectorType::get({2}, builder.getIntegerType(32)),
- {numDependencies, numOperands});
+ auto operandSegmentSizes =
+ builder.getDenseI32ArrayAttr({numDependencies, numOperands});
result.addAttribute(kOperandSegmentSizesAttr, operandSegmentSizes);
// First result is always a token, and then `resultTypes` wrapped into
@@ -203,9 +202,8 @@ ParseResult ExecuteOp::parse(OpAsmParser &parser, OperationState &result) {
int32_t numOperands = valueArgs.size();
// Add derived `operand_segment_sizes` attribute based on parsed operands.
- auto operandSegmentSizes = DenseIntElementsAttr::get(
- VectorType::get({2}, parser.getBuilder().getI32Type()),
- {numDependencies, numOperands});
+ auto operandSegmentSizes =
+ parser.getBuilder().getDenseI32ArrayAttr({numDependencies, numOperands});
result.addAttribute(kOperandSegmentSizesAttr, operandSegmentSizes);
// Parse the types of results returned from the async execute op.
diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
index c4bad43..9ca51f8 100644
--- a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
+++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
@@ -388,7 +388,7 @@ ParseResult AllocTensorOp::parse(OpAsmParser &parser, OperationState &result) {
if (parser.resolveOperand(copyOperand, type, result.operands))
return failure();
result.addAttribute(AllocTensorOp::getOperandSegmentSizeAttr(),
- parser.getBuilder().getI32VectorAttr(
+ parser.getBuilder().getDenseI32ArrayAttr(
{static_cast<int32_t>(dynamicSizesOperands.size()),
static_cast<int32_t>(copyKeyword.succeeded())}));
return success();
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index d102dbe..d564f53 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -374,15 +374,15 @@ void gpu::addAsyncDependency(Operation *op, Value token) {
return;
auto attrName =
OpTrait::AttrSizedOperandSegments<void>::getOperandSegmentSizeAttr();
- auto sizeAttr = op->template getAttrOfType<DenseIntElementsAttr>(attrName);
+ auto sizeAttr = op->template getAttrOfType<DenseI32ArrayAttr>(attrName);
// Async dependencies is the only variadic operand.
if (!sizeAttr)
return;
- SmallVector<int32_t, 8> sizes(sizeAttr.getValues<int32_t>());
+ SmallVector<int32_t, 8> sizes(sizeAttr.asArrayRef());
++sizes.front();
- op->setAttr(attrName, Builder(op->getContext()).getI32VectorAttr(sizes));
+ op->setAttr(attrName, Builder(op->getContext()).getDenseI32ArrayAttr(sizes));
}
//===----------------------------------------------------------------------===//
@@ -416,7 +416,7 @@ void LaunchOp::build(OpBuilder &builder, OperationState &result,
segmentSizes.front() = asyncDependencies.size();
segmentSizes.back() = dynamicSharedMemorySize ? 1 : 0;
result.addAttribute(getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr(segmentSizes));
+ builder.getDenseI32ArrayAttr(segmentSizes));
}
KernelDim3 LaunchOp::getBlockIds() {
@@ -636,7 +636,7 @@ ParseResult LaunchOp::parse(OpAsmParser &parser, OperationState &result) {
segmentSizes.front() = asyncDependencies.size();
segmentSizes.back() = hasDynamicSharedMemorySize ? 1 : 0;
result.addAttribute(LaunchOp::getOperandSegmentSizeAttr(),
- parser.getBuilder().getI32VectorAttr(segmentSizes));
+ parser.getBuilder().getDenseI32ArrayAttr(segmentSizes));
return success();
}
@@ -709,7 +709,7 @@ void LaunchFuncOp::build(OpBuilder &builder, OperationState &result,
segmentSizes[segmentSizes.size() - 2] = dynamicSharedMemorySize ? 1 : 0;
segmentSizes.back() = static_cast<int32_t>(kernelOperands.size());
result.addAttribute(getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr(segmentSizes));
+ builder.getDenseI32ArrayAttr(segmentSizes));
}
StringAttr LaunchFuncOp::getKernelModuleName() {
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 7c4f1a4..a92cfbd 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -1048,11 +1048,11 @@ ParseResult InvokeOp::parse(OpAsmParser &parser, OperationState &result) {
result.addOperands(normalOperands);
result.addOperands(unwindOperands);
- result.addAttribute(
- InvokeOp::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr({static_cast<int32_t>(operands.size()),
- static_cast<int32_t>(normalOperands.size()),
- static_cast<int32_t>(unwindOperands.size())}));
+ result.addAttribute(InvokeOp::getOperandSegmentSizeAttr(),
+ builder.getDenseI32ArrayAttr(
+ {static_cast<int32_t>(operands.size()),
+ static_cast<int32_t>(normalOperands.size()),
+ static_cast<int32_t>(unwindOperands.size())}));
return success();
}
diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
index b28ef14..1b1e0e7 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
@@ -233,9 +233,9 @@ void MmaOp::build(OpBuilder &builder, OperationState &result, Type resultType,
result.addTypes(resultType);
result.addAttribute(
MmaOp::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr({static_cast<int32_t>(operandA.size()),
- static_cast<int32_t>(operandB.size()),
- static_cast<int32_t>(operandC.size())}));
+ builder.getDenseI32ArrayAttr({static_cast<int32_t>(operandA.size()),
+ static_cast<int32_t>(operandB.size()),
+ static_cast<int32_t>(operandC.size())}));
}
// <operation> :=
@@ -326,7 +326,7 @@ ParseResult MmaOp::parse(OpAsmParser &parser, OperationState &result) {
if (!namedAttributes.empty())
result.addAttributes(namedAttributes);
result.addAttribute(MmaOp::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr({
+ builder.getDenseI32ArrayAttr({
static_cast<int32_t>(frags[0].regs.size()),
static_cast<int32_t>(frags[1].regs.size()),
static_cast<int32_t>(frags[2].regs.size()),
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index 650d7a2..74b503c 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -111,8 +111,8 @@ static void buildStructuredOp(OpBuilder &b, OperationState &state,
state.addAttributes(attributes);
state.addAttribute(
"operand_segment_sizes",
- b.getI32VectorAttr({static_cast<int32_t>(inputs.size()),
- static_cast<int32_t>(outputs.size())}));
+ b.getDenseI32ArrayAttr({static_cast<int32_t>(inputs.size()),
+ static_cast<int32_t>(outputs.size())}));
// Create and fill the region of the structured operation.
Region &region = *state.addRegion();
@@ -157,7 +157,7 @@ parseCommonStructuredOpParts(OpAsmParser &parser, OperationState &result,
return failure();
result.addAttribute("operand_segment_sizes",
- parser.getBuilder().getI32VectorAttr(
+ parser.getBuilder().getDenseI32ArrayAttr(
{static_cast<int32_t>(inputsOperands.size()),
static_cast<int32_t>(outputsOperands.size())}));
return success();
diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
index b2960a6..82e276e 100644
--- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
+++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
@@ -361,7 +361,7 @@ ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) {
result.addAttribute(
ParallelOp::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr(
+ builder.getDenseI32ArrayAttr(
{static_cast<int32_t>(async.has_value() ? 1 : 0),
static_cast<int32_t>(waitOperands.size()),
static_cast<int32_t>(numGangs.has_value() ? 1 : 0),
@@ -590,7 +590,7 @@ ParseResult LoopOp::parse(OpAsmParser &parser, OperationState &result) {
return failure();
result.addAttribute(LoopOp::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr(
+ builder.getDenseI32ArrayAttr(
{static_cast<int32_t>(gangNum.has_value() ? 1 : 0),
static_cast<int32_t>(gangStatic.has_value() ? 1 : 0),
static_cast<int32_t>(worker.has_value() ? 1 : 0),
diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp
index 607811a..0198295 100644
--- a/mlir/lib/Dialect/SCF/IR/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp
@@ -2105,10 +2105,10 @@ void ParallelOp::build(
result.addOperands(initVals);
result.addAttribute(
ParallelOp::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr({static_cast<int32_t>(lowerBounds.size()),
- static_cast<int32_t>(upperBounds.size()),
- static_cast<int32_t>(steps.size()),
- static_cast<int32_t>(initVals.size())}));
+ builder.getDenseI32ArrayAttr({static_cast<int32_t>(lowerBounds.size()),
+ static_cast<int32_t>(upperBounds.size()),
+ static_cast<int32_t>(steps.size()),
+ static_cast<int32_t>(initVals.size())}));
result.addTypes(initVals.getTypes());
OpBuilder::InsertionGuard guard(builder);
@@ -2258,10 +2258,10 @@ ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) {
// Set `operand_segment_sizes` attribute.
result.addAttribute(
ParallelOp::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr({static_cast<int32_t>(lower.size()),
- static_cast<int32_t>(upper.size()),
- static_cast<int32_t>(steps.size()),
- static_cast<int32_t>(initVals.size())}));
+ builder.getDenseI32ArrayAttr({static_cast<int32_t>(lower.size()),
+ static_cast<int32_t>(upper.size()),
+ static_cast<int32_t>(steps.size()),
+ static_cast<int32_t>(initVals.size())}));
// Parse attributes.
if (parser.parseOptionalAttrDict(result.attributes) ||
diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
index f7758f9..eaa623f 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp
@@ -1579,10 +1579,10 @@ ParseResult spirv::BranchConditionalOp::parse(OpAsmParser &parser,
return failure();
result.addSuccessors(dest);
result.addOperands(falseOperands);
- result.addAttribute(
- spirv::BranchConditionalOp::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr({1, static_cast<int32_t>(trueOperands.size()),
- static_cast<int32_t>(falseOperands.size())}));
+ result.addAttribute(spirv::BranchConditionalOp::getOperandSegmentSizeAttr(),
+ builder.getDenseI32ArrayAttr(
+ {1, static_cast<int32_t>(trueOperands.size()),
+ static_cast<int32_t>(falseOperands.size())}));
return success();
}
diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
index ce494c3..c971cd8 100644
--- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
@@ -3015,10 +3015,10 @@ ParseResult TransferReadOp::parse(OpAsmParser &parser, OperationState &result) {
if (parser.resolveOperand(maskInfo, maskType, result.operands))
return failure();
}
- result.addAttribute(
- TransferReadOp::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr({1, static_cast<int32_t>(indexInfo.size()), 1,
- static_cast<int32_t>(hasMask.succeeded())}));
+ result.addAttribute(TransferReadOp::getOperandSegmentSizeAttr(),
+ builder.getDenseI32ArrayAttr(
+ {1, static_cast<int32_t>(indexInfo.size()), 1,
+ static_cast<int32_t>(hasMask.succeeded())}));
return parser.addTypeToList(vectorType, result.types);
}
@@ -3465,10 +3465,10 @@ ParseResult TransferWriteOp::parse(OpAsmParser &parser,
if (parser.resolveOperand(maskInfo, maskType, result.operands))
return failure();
}
- result.addAttribute(
- TransferWriteOp::getOperandSegmentSizeAttr(),
- builder.getI32VectorAttr({1, 1, static_cast<int32_t>(indexInfo.size()),
- static_cast<int32_t>(hasMask.succeeded())}));
+ result.addAttribute(TransferWriteOp::getOperandSegmentSizeAttr(),
+ builder.getDenseI32ArrayAttr(
+ {1, 1, static_cast<int32_t>(indexInfo.size()),
+ static_cast<int32_t>(hasMask.succeeded())}));
return failure(shapedType.isa<RankedTensorType>() &&
parser.addTypeToList(shapedType, result.types));
}
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index b255e80..e30d5ea 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -987,26 +987,19 @@ LogicalResult OpTrait::impl::verifyValueSizeAttr(Operation *op,
StringRef attrName,
StringRef valueGroupName,
size_t expectedCount) {
- auto sizeAttr = op->getAttrOfType<DenseIntElementsAttr>(attrName);
+ auto sizeAttr = op->getAttrOfType<DenseI32ArrayAttr>(attrName);
if (!sizeAttr)
- return op->emitOpError("requires 1D i32 elements attribute '")
+ return op->emitOpError("requires dense i32 array attribute '")
<< attrName << "'";
- auto sizeAttrType = sizeAttr.getType();
- if (sizeAttrType.getRank() != 1 ||
- !sizeAttrType.getElementType().isInteger(32))
- return op->emitOpError("requires 1D i32 elements attribute '")
- << attrName << "'";
-
- if (llvm::any_of(sizeAttr.getValues<APInt>(), [](const APInt &element) {
- return !element.isNonNegative();
- }))
+ ArrayRef<int32_t> sizes = sizeAttr.asArrayRef();
+ if (llvm::any_of(sizes, [](int32_t element) { return element < 0; }))
return op->emitOpError("'")
<< attrName << "' attribute cannot have negative elements";
- size_t totalCount = std::accumulate(
- sizeAttr.begin(), sizeAttr.end(), 0,
- [](unsigned all, const APInt &one) { return all + one.getZExtValue(); });
+ size_t totalCount =
+ std::accumulate(sizes.begin(), sizes.end(), 0,
+ [](unsigned all, int32_t one) { return all + one; });
if (totalCount != expectedCount)
return op->emitOpError()
diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp
index 1f7a739..53d55ef 100644
--- a/mlir/lib/IR/OperationSupport.cpp
+++ b/mlir/lib/IR/OperationSupport.cpp
@@ -377,7 +377,7 @@ unsigned OperandRange::getBeginOperandIndex() const {
return base->getOperandNumber();
}
-OperandRangeRange OperandRange::split(ElementsAttr segmentSizes) const {
+OperandRangeRange OperandRange::split(DenseI32ArrayAttr segmentSizes) const {
return OperandRangeRange(*this, segmentSizes);
}
@@ -387,18 +387,18 @@ OperandRangeRange OperandRange::split(ElementsAttr segmentSizes) const {
OperandRangeRange::OperandRangeRange(OperandRange operands,
Attribute operandSegments)
: OperandRangeRange(OwnerT(operands.getBase(), operandSegments), 0,
- operandSegments.cast<DenseElementsAttr>().size()) {}
+ operandSegments.cast<DenseI32ArrayAttr>().size()) {}
OperandRange OperandRangeRange::join() const {
const OwnerT &owner = getBase();
- auto sizeData = owner.second.cast<DenseElementsAttr>().getValues<uint32_t>();
+ ArrayRef<int32_t> sizeData = owner.second.cast<DenseI32ArrayAttr>();
return OperandRange(owner.first,
std::accumulate(sizeData.begin(), sizeData.end(), 0));
}
OperandRange OperandRangeRange::dereference(const OwnerT &object,
ptrdiff_t index) {
- auto sizeData = object.second.cast<DenseElementsAttr>().getValues<uint32_t>();
+ ArrayRef<int32_t> sizeData = object.second.cast<DenseI32ArrayAttr>();
uint32_t startIndex =
std::accumulate(sizeData.begin(), sizeData.begin() + index, 0);
return OperandRange(object.first + startIndex, *(sizeData.begin() + index));
@@ -490,11 +490,11 @@ void MutableOperandRange::updateLength(unsigned newLength) {
// Update any of the provided segment attributes.
for (OperandSegment &segment : operandSegments) {
- auto attr = segment.second.getValue().cast<DenseIntElementsAttr>();
- SmallVector<int32_t, 8> segments(attr.getValues<int32_t>());
+ auto attr = segment.second.getValue().cast<DenseI32ArrayAttr>();
+ SmallVector<int32_t, 8> segments(attr.asArrayRef());
segments[segment.first] += diff;
segment.second.setValue(
- DenseIntElementsAttr::get(attr.getType(), segments));
+ DenseI32ArrayAttr::get(attr.getContext(), segments));
owner->setAttr(segment.second.getName(), segment.second.getValue());
}
}
@@ -506,21 +506,20 @@ MutableOperandRangeRange::MutableOperandRangeRange(
const MutableOperandRange &operands, NamedAttribute operandSegmentAttr)
: MutableOperandRangeRange(
OwnerT(operands, operandSegmentAttr), 0,
- operandSegmentAttr.getValue().cast<DenseElementsAttr>().size()) {}
+ operandSegmentAttr.getValue().cast<DenseI32ArrayAttr>().size()) {}
MutableOperandRange MutableOperandRangeRange::join() const {
return getBase().first;
}
MutableOperandRangeRange::operator OperandRangeRange() const {
- return OperandRangeRange(
- getBase().first, getBase().second.getValue().cast<DenseElementsAttr>());
+ return OperandRangeRange(getBase().first, getBase().second.getValue());
}
MutableOperandRange MutableOperandRangeRange::dereference(const OwnerT &object,
ptrdiff_t index) {
- auto sizeData =
- object.second.getValue().cast<DenseElementsAttr>().getValues<uint32_t>();
+ ArrayRef<int32_t> sizeData =
+ object.second.getValue().cast<DenseI32ArrayAttr>();
uint32_t startIndex =
std::accumulate(sizeData.begin(), sizeData.begin() + index, 0);
return object.first.slice(
diff --git a/mlir/lib/Rewrite/ByteCode.cpp b/mlir/lib/Rewrite/ByteCode.cpp
index d4ca8b2..388d6dc 100644
--- a/mlir/lib/Rewrite/ByteCode.cpp
+++ b/mlir/lib/Rewrite/ByteCode.cpp
@@ -1713,11 +1713,11 @@ executeGetOperandsResults(RangeT values, Operation *op, unsigned index,
LLVM_DEBUG(llvm::dbgs()
<< " * Extracting values from `" << attrSizedSegments << "`\n");
- auto segmentAttr = op->getAttrOfType<DenseElementsAttr>(attrSizedSegments);
- if (!segmentAttr || segmentAttr.getNumElements() <= index)
+ auto segmentAttr = op->getAttrOfType<DenseI32ArrayAttr>(attrSizedSegments);
+ if (!segmentAttr || segmentAttr.asArrayRef().size() <= index)
return nullptr;
- auto segments = segmentAttr.getValues<int32_t>();
+ ArrayRef<int32_t> segments = segmentAttr;
unsigned startIndex =
std::accumulate(segments.begin(), segments.begin() + index, 0);
values = values.slice(startIndex, *std::next(segments.begin(), index));
diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
index 089d20a..92ec7d1 100644
--- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -906,7 +906,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) {
if (brInst->isConditional()) {
state.addAttribute(LLVM::CondBrOp::getOperandSegmentSizeAttr(),
- b.getI32VectorAttr(operandSegmentSizes));
+ b.getDenseI32ArrayAttr(operandSegmentSizes));
}
b.create(state);
diff --git a/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir b/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
index b9dcbb4..b457811 100644
--- a/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
+++ b/mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir
@@ -73,13 +73,13 @@ func.func @wsloop(%arg0: index, %arg1: index, %arg2: index, %arg3: index, %arg4:
omp.parallel {
// CHECK: omp.wsloop for (%[[ARG6:.*]], %[[ARG7:.*]]) : i64 = (%[[ARG0]], %[[ARG1]]) to (%[[ARG2]], %[[ARG3]]) step (%[[ARG4]], %[[ARG5]]) {
"omp.wsloop"(%arg0, %arg1, %arg2, %arg3, %arg4, %arg5) ({
- ^bb0(%arg6: index, %arg7: index):
+ ^bb0(%arg6: index, %arg7: index):
// CHECK-DAG: %[[CAST_ARG6:.*]] = builtin.unrealized_conversion_cast %[[ARG6]] : i64 to index
// CHECK-DAG: %[[CAST_ARG7:.*]] = builtin.unrealized_conversion_cast %[[ARG7]] : i64 to index
// CHECK: "test.payload"(%[[CAST_ARG6]], %[[CAST_ARG7]]) : (index, index) -> ()
"test.payload"(%arg6, %arg7) : (index, index) -> ()
omp.yield
- }) {operand_segment_sizes = dense<[2, 2, 2, 0, 0, 0, 0]> : vector<7xi32>} : (index, index, index, index, index, index) -> ()
+ }) {operand_segment_sizes = array<i32: 2, 2, 2, 0, 0, 0, 0>} : (index, index, index, index, index, index) -> ()
omp.terminator
}
return
diff --git a/mlir/test/Dialect/GPU/invalid.mlir b/mlir/test/Dialect/GPU/invalid.mlir
index 9a8f884..877ba26 100644
--- a/mlir/test/Dialect/GPU/invalid.mlir
+++ b/mlir/test/Dialect/GPU/invalid.mlir
@@ -4,7 +4,7 @@ func.func @not_enough_sizes(%sz : index) {
// expected-error@+1 {{expected 6 or more operands, but found 5}}
"gpu.launch"(%sz, %sz, %sz, %sz, %sz) ({
gpu.return
- }) {operand_segment_sizes = dense<[0, 1, 1, 1, 1, 1, 1, 0]> : vector<8xi32>} : (index, index, index, index, index) -> ()
+ }) {operand_segment_sizes = array<i32: 0, 1, 1, 1, 1, 1, 1, 0>} : (index, index, index, index, index) -> ()
return
}
@@ -16,7 +16,7 @@ func.func @no_region_attrs(%sz : index) {
^bb1(%bx: index, %by: index, %bz: index,
%tx: index, %ty: index, %tz: index):
gpu.terminator
- }) {operand_segment_sizes = dense<[0, 1, 1, 1, 1, 1, 1, 0]> : vector<8xi32>} : (index, index, index, index, index, index) -> ()
+ }) {operand_segment_sizes = array<i32: 0, 1, 1, 1, 1, 1, 1, 0>} : (index, index, index, index, index, index) -> ()
return
}
@@ -38,7 +38,7 @@ func.func @launch_requires_gpu_return(%sz : index) {
func.func @launch_func_too_few_operands(%sz : index) {
// expected-error@+1 {{expected 6 or more operands}}
"gpu.launch_func"(%sz, %sz, %sz, %sz, %sz)
- {operand_segment_sizes = dense<[0, 1, 1, 1, 1, 1, 0, 0]> : vector<8xi32>}
+ {operand_segment_sizes = array<i32: 0, 1, 1, 1, 1, 1, 0, 0>}
: (index, index, index, index, index) -> ()
return
}
@@ -57,7 +57,7 @@ module attributes {gpu.container_module} {
func.func @launch_func_missing_callee_attribute(%sz : index) {
// expected-error@+1 {{'gpu.launch_func' op requires attribute 'kernel'}}
"gpu.launch_func"(%sz, %sz, %sz, %sz, %sz, %sz)
- {operand_segment_sizes = dense<[0, 1, 1, 1, 1, 1, 1, 0, 0]> : vector<9xi32>}
+ {operand_segment_sizes = array<i32: 0, 1, 1, 1, 1, 1, 1, 0, 0>}
: (index, index, index, index, index, index) -> ()
return
}
diff --git a/mlir/test/Dialect/Linalg/named-ops.mlir b/mlir/test/Dialect/Linalg/named-ops.mlir
index 9c60df3..6512847 100644
--- a/mlir/test/Dialect/Linalg/named-ops.mlir
+++ b/mlir/test/Dialect/Linalg/named-ops.mlir
@@ -742,7 +742,7 @@ func.func @conv_interface_wrong_input_indexing_map(
%1 = "arith.mulf"(%arg3, %arg4) : (f32, f32) -> f32
%2 = "arith.addf"(%arg5, %1) : (f32, f32) -> f32
"linalg.yield"(%2) : (f32) -> ()
- }) {dilations = dense<1> : tensor<2xi64>, linalg.memoized_indexing_maps = [#map0, #map1, #map2], operand_segment_sizes = dense<[2, 1]> : vector<2xi32>, strides = dense<2> : tensor<2xi64>} : (tensor<?x?x?x?xf32>, tensor<?x?x?x?xf32>, tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32>
+ }) {dilations = dense<1> : tensor<2xi64>, linalg.memoized_indexing_maps = [#map0, #map1, #map2], operand_segment_sizes = array<i32: 2, 1>, strides = dense<2> : tensor<2xi64>} : (tensor<?x?x?x?xf32>, tensor<?x?x?x?xf32>, tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32>
return %0 : tensor<?x?x?x?xf32>
}
@@ -759,6 +759,6 @@ func.func @conv_interface_wrong_num_operands(
%1 = "arith.mulf"(%arg3, %arg4) : (f32, f32) -> f32
%2 = "arith.addf"(%arg5, %1) : (f32, f32) -> f32
"linalg.yield"(%2) : (f32) -> ()
- }) {dilations = dense<1> : tensor<2xi64>, linalg.memoized_indexing_maps = [#map0, #map1, #map2], operand_segment_sizes = dense<[2, 1]> : vector<2xi32>, strides = dense<1> : tensor<2xi64>} : (tensor<?x?x?x?xf32>, tensor<?x?x?x?x?xf32>, tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32>
+ }) {dilations = dense<1> : tensor<2xi64>, linalg.memoized_indexing_maps = [#map0, #map1, #map2], operand_segment_sizes = array<i32: 2, 1>, strides = dense<1> : tensor<2xi64>} : (tensor<?x?x?x?xf32>, tensor<?x?x?x?x?xf32>, tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32>
return %0 : tensor<?x?x?x?xf32>
}
diff --git a/mlir/test/Dialect/OpenMP/invalid.mlir b/mlir/test/Dialect/OpenMP/invalid.mlir
index 6e62773..c833bdd 100644
--- a/mlir/test/Dialect/OpenMP/invalid.mlir
+++ b/mlir/test/Dialect/OpenMP/invalid.mlir
@@ -197,8 +197,8 @@ func.func @omp_simdloop(%lb : index, %ub : index, %step : i32) -> () {
"omp.simdloop" (%lb, %ub, %step) ({
^bb0(%iv: index):
omp.yield
- }) {operand_segment_sizes = dense<[1,1,1,0]> : vector<4xi32>} :
- (index, index, i32) -> ()
+ }) {operand_segment_sizes = array<i32: 1,1,1,0>} :
+ (index, index, i32) -> ()
return
}
@@ -985,7 +985,7 @@ func.func @omp_sections(%data_var : memref<i32>) -> () {
// expected-error @below {{expected equal sizes for allocate and allocator variables}}
"omp.sections" (%data_var) ({
omp.terminator
- }) {operand_segment_sizes = dense<[0,1,0]> : vector<3xi32>} : (memref<i32>) -> ()
+ }) {operand_segment_sizes = array<i32: 0,1,0>} : (memref<i32>) -> ()
return
}
@@ -995,7 +995,7 @@ func.func @omp_sections(%data_var : memref<i32>) -> () {
// expected-error @below {{expected as many reduction symbol references as reduction variables}}
"omp.sections" (%data_var) ({
omp.terminator
- }) {operand_segment_sizes = dense<[1,0,0]> : vector<3xi32>} : (memref<i32>) -> ()
+ }) {operand_segment_sizes = array<i32: 1,0,0>} : (memref<i32>) -> ()
return
}
@@ -1110,7 +1110,7 @@ func.func @omp_single(%data_var : memref<i32>) -> () {
// expected-error @below {{expected equal sizes for allocate and allocator variables}}
"omp.single" (%data_var) ({
omp.barrier
- }) {operand_segment_sizes = dense<[1,0]> : vector<2xi32>} : (memref<i32>) -> ()
+ }) {operand_segment_sizes = array<i32: 1,0>} : (memref<i32>) -> ()
return
}
@@ -1302,7 +1302,7 @@ func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {
"omp.taskloop"(%lb, %ub, %ub, %lb, %step, %step, %testmemref) ({
^bb0(%arg3: i32, %arg4: i32):
"omp.terminator"() : () -> ()
- }) {operand_segment_sizes = dense<[2, 2, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0]> : vector<12xi32>} : (i32, i32, i32, i32, i32, i32, memref<i32>) -> ()
+ }) {operand_segment_sizes = array<i32: 2, 2, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0>} : (i32, i32, i32, i32, i32, i32, memref<i32>) -> ()
return
}
@@ -1315,7 +1315,7 @@ func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {
"omp.taskloop"(%lb, %ub, %ub, %lb, %step, %step, %testf32, %testf32_2) ({
^bb0(%arg3: i32, %arg4: i32):
"omp.terminator"() : () -> ()
- }) {operand_segment_sizes = dense<[2, 2, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0]> : vector<12xi32>, reductions = [@add_f32]} : (i32, i32, i32, i32, i32, i32, !llvm.ptr<f32>, !llvm.ptr<f32>) -> ()
+ }) {operand_segment_sizes = array<i32: 2, 2, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0>, reductions = [@add_f32]} : (i32, i32, i32, i32, i32, i32, !llvm.ptr<f32>, !llvm.ptr<f32>) -> ()
return
}
@@ -1328,7 +1328,7 @@ func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {
"omp.taskloop"(%lb, %ub, %ub, %lb, %step, %step, %testf32) ({
^bb0(%arg3: i32, %arg4: i32):
"omp.terminator"() : () -> ()
- }) {operand_segment_sizes = dense<[2, 2, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0]> : vector<12xi32>, reductions = [@add_f32, @add_f32]} : (i32, i32, i32, i32, i32, i32, !llvm.ptr<f32>) -> ()
+ }) {operand_segment_sizes = array<i32: 2, 2, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0>, reductions = [@add_f32, @add_f32]} : (i32, i32, i32, i32, i32, i32, !llvm.ptr<f32>) -> ()
return
}
@@ -1341,7 +1341,7 @@ func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {
"omp.taskloop"(%lb, %ub, %ub, %lb, %step, %step, %testf32, %testf32_2) ({
^bb0(%arg3: i32, %arg4: i32):
"omp.terminator"() : () -> ()
- }) {in_reductions = [@add_f32], operand_segment_sizes = dense<[2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0]> : vector<12xi32>} : (i32, i32, i32, i32, i32, i32, !llvm.ptr<f32>, !llvm.ptr<f32>) -> ()
+ }) {in_reductions = [@add_f32], operand_segment_sizes = array<i32: 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0>} : (i32, i32, i32, i32, i32, i32, !llvm.ptr<f32>, !llvm.ptr<f32>) -> ()
return
}
@@ -1354,7 +1354,7 @@ func.func @taskloop(%lb: i32, %ub: i32, %step: i32) {
"omp.taskloop"(%lb, %ub, %ub, %lb, %step, %step, %testf32_2) ({
^bb0(%arg3: i32, %arg4: i32):
"omp.terminator"() : () -> ()
- }) {in_reductions = [@add_f32, @add_f32], operand_segment_sizes = dense<[2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0]> : vector<12xi32>} : (i32, i32, i32, i32, i32, i32, !llvm.ptr<f32>) -> ()
+ }) {in_reductions = [@add_f32, @add_f32], operand_segment_sizes = array<i32: 2, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0>} : (i32, i32, i32, i32, i32, i32, !llvm.ptr<f32>) -> ()
return
}
diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir
index 6e28324..99c35fc 100644
--- a/mlir/test/Dialect/OpenMP/ops.mlir
+++ b/mlir/test/Dialect/OpenMP/ops.mlir
@@ -59,7 +59,7 @@ func.func @omp_parallel(%data_var : memref<i32>, %if_cond : i1, %num_threads : i
// CHECK: omp.parallel num_threads(%{{.*}} : i32) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
"omp.parallel"(%num_threads, %data_var, %data_var) ({
omp.terminator
- }) {operand_segment_sizes = dense<[0,1,1,1,0]> : vector<5xi32>} : (i32, memref<i32>, memref<i32>) -> ()
+ }) {operand_segment_sizes = array<i32: 0,1,1,1,0>} : (i32, memref<i32>, memref<i32>) -> ()
// CHECK: omp.barrier
omp.barrier
@@ -68,22 +68,22 @@ func.func @omp_parallel(%data_var : memref<i32>, %if_cond : i1, %num_threads : i
// CHECK: omp.parallel if(%{{.*}}) allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
"omp.parallel"(%if_cond, %data_var, %data_var) ({
omp.terminator
- }) {operand_segment_sizes = dense<[1,0,1,1,0]> : vector<5xi32>} : (i1, memref<i32>, memref<i32>) -> ()
+ }) {operand_segment_sizes = array<i32: 1,0,1,1,0>} : (i1, memref<i32>, memref<i32>) -> ()
// test without allocate
// CHECK: omp.parallel if(%{{.*}}) num_threads(%{{.*}} : i32)
"omp.parallel"(%if_cond, %num_threads) ({
omp.terminator
- }) {operand_segment_sizes = dense<[1,1,0,0,0]> : vector<5xi32>} : (i1, i32) -> ()
+ }) {operand_segment_sizes = array<i32: 1,1,0,0,0>} : (i1, i32) -> ()
omp.terminator
- }) {operand_segment_sizes = dense<[1,1,1,1,0]> : vector<5xi32>, proc_bind_val = #omp<procbindkind spread>} : (i1, i32, memref<i32>, memref<i32>) -> ()
+ }) {operand_segment_sizes = array<i32: 1,1,1,1,0>, proc_bind_val = #omp<procbindkind spread>} : (i1, i32, memref<i32>, memref<i32>) -> ()
// test with multiple parameters for single variadic argument
// CHECK: omp.parallel allocate(%{{.*}} : memref<i32> -> %{{.*}} : memref<i32>)
"omp.parallel" (%data_var, %data_var) ({
omp.terminator
- }) {operand_segment_sizes = dense<[0,0,1,1,0]> : vector<5xi32>} : (memref<i32>, memref<i32>) -> ()
+ }) {operand_segment_sizes = array<i32: 0,0,1,1,0>} : (memref<i32>, memref<i32>) -> ()
return
}
@@ -141,7 +141,7 @@ func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memre
"omp.wsloop" (%lb, %ub, %step) ({
^bb0(%iv: index):
omp.yield
- }) {operand_segment_sizes = dense<[1,1,1,0,0,0,0]> : vector<7xi32>, ordered_val = 1} :
+ }) {operand_segment_sizes = array<i32: 1,1,1,0,0,0,0>, ordered_val = 1} :
(index, index, index) -> ()
// CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(static)
@@ -149,7 +149,7 @@ func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memre
"omp.wsloop" (%lb, %ub, %step, %data_var, %linear_var) ({
^bb0(%iv: index):
omp.yield
- }) {operand_segment_sizes = dense<[1,1,1,1,1,0,0]> : vector<7xi32>, schedule_val = #omp<schedulekind static>} :
+ }) {operand_segment_sizes = array<i32: 1,1,1,1,1,0,0>, schedule_val = #omp<schedulekind static>} :
(index, index, index, memref<i32>, i32) -> ()
// CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref<i32>, %{{.*}} = %{{.*}} : memref<i32>) schedule(static)
@@ -157,7 +157,7 @@ func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memre
"omp.wsloop" (%lb, %ub, %step, %data_var, %data_var, %linear_var, %linear_var) ({
^bb0(%iv: index):
omp.yield
- }) {operand_segment_sizes = dense<[1,1,1,2,2,0,0]> : vector<7xi32>, schedule_val = #omp<schedulekind static>} :
+ }) {operand_segment_sizes = array<i32: 1,1,1,2,2,0,0>, schedule_val = #omp<schedulekind static>} :
(index, index, index, memref<i32>, memref<i32>, i32, i32) -> ()
// CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref<i32>) schedule(dynamic = %{{.*}}) ordered(2)
@@ -165,7 +165,7 @@ func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memre
"omp.wsloop" (%lb, %ub, %step, %data_var, %linear_var, %chunk_var) ({
^bb0(%iv: index):
omp.yield
- }) {operand_segment_sizes = dense<[1,1,1,1,1,0,1]> : vector<7xi32>, schedule_val = #omp<schedulekind dynamic>, ordered_val = 2} :
+ }) {operand_segment_sizes = array<i32: 1,1,1,1,1,0,1>, schedule_val = #omp<schedulekind dynamic>, ordered_val = 2} :
(index, index, index, memref<i32>, i32, i32) -> ()
// CHECK: omp.wsloop schedule(auto) nowait
@@ -173,7 +173,7 @@ func.func @omp_wsloop(%lb : index, %ub : index, %step : index, %data_var : memre
"omp.wsloop" (%lb, %ub, %step) ({
^bb0(%iv: index):
omp.yield
- }) {operand_segment_sizes = dense<[1,1,1,0,0,0,0]> : vector<7xi32>, nowait, schedule_val = #omp<schedulekind auto>} :
+ }) {operand_segment_sizes = array<i32: 1,1,1,0,0,0,0>, nowait, schedule_val = #omp<schedulekind auto>} :
(index, index, index) -> ()
return
@@ -333,8 +333,8 @@ func.func @omp_simdloop(%lb : index, %ub : index, %step : index) -> () {
"omp.simdloop" (%lb, %ub, %step) ({
^bb0(%iv: index):
omp.yield
- }) {operand_segment_sizes = dense<[1,1,1,0]> : vector<4xi32>} :
- (index, index, index) -> ()
+ }) {operand_segment_sizes = array<i32: 1,1,1,0>} :
+ (index, index, index) -> ()
return
}
@@ -383,7 +383,7 @@ func.func @omp_target(%if_cond : i1, %device : si32, %num_threads : i32) -> ()
"omp.target"(%if_cond, %device, %num_threads) ({
// CHECK: omp.terminator
omp.terminator
- }) {nowait, operand_segment_sizes = dense<[1,1,1]>: vector<3xi32>} : ( i1, si32, i32 ) -> ()
+ }) {nowait, operand_segment_sizes = array<i32: 1,1,1>} : ( i1, si32, i32 ) -> ()
// CHECK: omp.barrier
omp.barrier
@@ -1227,13 +1227,13 @@ func.func @omp_sectionsop(%data_var1 : memref<i32>, %data_var2 : memref<i32>,
"omp.sections" (%data_var1, %data_var1) ({
// CHECK: omp.terminator
omp.terminator
- }) {operand_segment_sizes = dense<[0,1,1]> : vector<3xi32>} : (memref<i32>, memref<i32>) -> ()
+ }) {operand_segment_sizes = array<i32: 0,1,1>} : (memref<i32>, memref<i32>) -> ()
// CHECK: omp.sections reduction(@add_f32 -> %{{.*}} : !llvm.ptr<f32>)
"omp.sections" (%redn_var) ({
// CHECK: omp.terminator
omp.terminator
- }) {operand_segment_sizes = dense<[1,0,0]> : vector<3xi32>, reductions=[@add_f32]} : (!llvm.ptr<f32>) -> ()
+ }) {operand_segment_sizes = array<i32: 1,0,0>, reductions=[@add_f32]} : (!llvm.ptr<f32>) -> ()
// CHECK: omp.sections nowait {
omp.sections nowait {
diff --git a/mlir/test/Dialect/PDL/invalid.mlir b/mlir/test/Dialect/PDL/invalid.mlir
index 954b5d0..e93d34c 100644
--- a/mlir/test/Dialect/PDL/invalid.mlir
+++ b/mlir/test/Dialect/PDL/invalid.mlir
@@ -122,7 +122,7 @@ pdl.pattern : benefit(1) {
// expected-error@below {{expected the same number of attribute values and attribute names, got 1 names and 0 values}}
%op = "pdl.operation"() {
attributeNames = ["attr"],
- operand_segment_sizes = dense<0> : vector<3xi32>
+ operand_segment_sizes = array<i32: 0, 0, 0>
} : () -> (!pdl.operation)
rewrite %op with "rewriter"
}
@@ -230,7 +230,7 @@ pdl.pattern : benefit(1) {
// expected-error@below {{expected no replacement values to be provided when the replacement operation is present}}
"pdl.replace"(%root, %newOp, %newResult) {
- operand_segment_sizes = dense<1> : vector<3xi32>
+ operand_segment_sizes = array<i32: 1, 1, 1>
} : (!pdl.operation, !pdl.operation, !pdl.value) -> ()
}
}
@@ -259,7 +259,7 @@ pdl.pattern : benefit(1) {
// expected-error@below {{expected rewrite region to be non-empty if external name is not specified}}
"pdl.rewrite"(%op) ({}) {
- operand_segment_sizes = dense<[1,0]> : vector<2xi32>
+ operand_segment_sizes = array<i32: 1,0>
} : (!pdl.operation) -> ()
}
@@ -272,7 +272,7 @@ pdl.pattern : benefit(1) {
"pdl.rewrite"(%op, %op) ({
^bb1:
}) {
- operand_segment_sizes = dense<1> : vector<2xi32>
+ operand_segment_sizes = array<i32: 1, 1>
}: (!pdl.operation, !pdl.operation) -> ()
}
@@ -286,7 +286,7 @@ pdl.pattern : benefit(1) {
^bb1:
}) {
name = "foo",
- operand_segment_sizes = dense<[1,0]> : vector<2xi32>
+ operand_segment_sizes = array<i32: 1,0>
} : (!pdl.operation) -> ()
}
diff --git a/mlir/test/Dialect/PDLInterp/invalid.mlir b/mlir/test/Dialect/PDLInterp/invalid.mlir
index e44625d..f194d32 100644
--- a/mlir/test/Dialect/PDLInterp/invalid.mlir
+++ b/mlir/test/Dialect/PDLInterp/invalid.mlir
@@ -19,8 +19,7 @@ pdl_interp.func @rewriter() {
inferredResultTypes,
inputAttributeNames = [],
name = "foo.op",
- operand_segment_sizes = dense<[0, 0, 1]> : vector<3xi32>
+ operand_segment_sizes = array<i32: 0, 0, 1>
} : (!pdl.type) -> (!pdl.operation)
pdl_interp.finalize
}
-
diff --git a/mlir/test/Dialect/SCF/invalid.mlir b/mlir/test/Dialect/SCF/invalid.mlir
index 6fcde70..86d1cb6 100644
--- a/mlir/test/Dialect/SCF/invalid.mlir
+++ b/mlir/test/Dialect/SCF/invalid.mlir
@@ -131,7 +131,7 @@ func.func @parallel_body_arguments_wrong_type(
"scf.parallel"(%arg0, %arg1, %arg2) ({
^bb0(%i0: f32):
scf.yield
- }) {operand_segment_sizes = dense<[1, 1, 1, 0]>: vector<4xi32>}: (index, index, index) -> ()
+ }) {operand_segment_sizes = array<i32: 1, 1, 1, 0>}: (index, index, index) -> ()
return
}
@@ -143,7 +143,7 @@ func.func @parallel_body_wrong_number_of_arguments(
"scf.parallel"(%arg0, %arg1, %arg2) ({
^bb0(%i0: index, %i1: index):
scf.yield
- }) {operand_segment_sizes = dense<[1, 1, 1, 0]>: vector<4xi32>}: (index, index, index) -> ()
+ }) {operand_segment_sizes = array<i32: 1, 1, 1, 0>}: (index, index, index) -> ()
return
}
diff --git a/mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir b/mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir
index 4a2c9fd..1780c94 100644
--- a/mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir
+++ b/mlir/test/Dialect/SPIRV/IR/control-flow-ops.mlir
@@ -117,7 +117,7 @@ func.func @wrong_condition_type() -> () {
func.func @wrong_accessor_count() -> () {
%true = spv.Constant true
// expected-error @+1 {{requires 2 successors but found 1}}
- "spv.BranchConditional"(%true)[^one] {operand_segment_sizes = dense<[1, 0, 0]>: vector<3xi32>} : (i1) -> ()
+ "spv.BranchConditional"(%true)[^one] {operand_segment_sizes = array<i32: 1, 0, 0>} : (i1) -> ()
^one:
spv.Return
^two:
@@ -130,7 +130,7 @@ func.func @wrong_number_of_weights() -> () {
%true = spv.Constant true
// expected-error @+1 {{must have exactly two branch weights}}
"spv.BranchConditional"(%true)[^one, ^two] {branch_weights = [1 : i32, 2 : i32, 3 : i32],
- operand_segment_sizes = dense<[1, 0, 0]>: vector<3xi32>} : (i1) -> ()
+ operand_segment_sizes = array<i32: 1, 0, 0>} : (i1) -> ()
^one:
spv.Return
^two:
diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir
index 34b667f..ba57a91 100644
--- a/mlir/test/IR/parser.mlir
+++ b/mlir/test/IR/parser.mlir
@@ -457,7 +457,7 @@ func.func @verbose_terminators() -> (i1, i17) {
^bb1(%x : i1, %y : i17):
// CHECK: cf.cond_br %{{.*}}, ^bb2(%{{.*}} : i17), ^bb3(%{{.*}}, %{{.*}} : i1, i17)
- "cf.cond_br"(%x, %y, %x, %y) [^bb2, ^bb3] {operand_segment_sizes = dense<[1, 1, 2]>: vector<3xi32>} : (i1, i17, i1, i17) -> ()
+ "cf.cond_br"(%x, %y, %x, %y) [^bb2, ^bb3] {operand_segment_sizes = array<i32: 1, 1, 2>} : (i1, i17, i1, i17) -> ()
^bb2(%a : i17):
%true = arith.constant true
diff --git a/mlir/test/IR/traits.mlir b/mlir/test/IR/traits.mlir
index b5846d1..80e0d4c 100644
--- a/mlir/test/IR/traits.mlir
+++ b/mlir/test/IR/traits.mlir
@@ -375,114 +375,101 @@ func.func private @foo()
// -----
func.func @failedMissingOperandSizeAttr(%arg: i32) {
- // expected-error @+1 {{requires 1D i32 elements attribute 'operand_segment_sizes'}}
+ // expected-error @+1 {{requires dense i32 array attribute 'operand_segment_sizes'}}
"test.attr_sized_operands"(%arg, %arg, %arg, %arg) : (i32, i32, i32, i32) -> ()
}
// -----
func.func @failedOperandSizeAttrWrongType(%arg: i32) {
- // expected-error @+1 {{requires 1D i32 elements attribute 'operand_segment_sizes'}}
+ // expected-error @+1 {{requires dense i32 array attribute 'operand_segment_sizes'}}
"test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = 10} : (i32, i32, i32, i32) -> ()
}
// -----
-func.func @failedOperandSizeAttrWrongRank(%arg: i32) {
- // expected-error @+1 {{requires 1D i32 elements attribute 'operand_segment_sizes'}}
- "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = dense<[[1, 1], [1, 1]]>: vector<2x2xi32>} : (i32, i32, i32, i32) -> ()
-}
-
-// -----
-
func.func @failedOperandSizeAttrWrongElementType(%arg: i32) {
- // expected-error @+1 {{requires 1D i32 elements attribute 'operand_segment_sizes'}}
- "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = dense<[1, 1, 1, 1]>: vector<4xi64>} : (i32, i32, i32, i32) -> ()
+ // expected-error @+1 {{requires dense i32 array attribute 'operand_segment_sizes'}}
+ "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = array<i64: 1, 1, 1, 1>} : (i32, i32, i32, i32) -> ()
}
// -----
func.func @failedOperandSizeAttrNegativeValue(%arg: i32) {
// expected-error @+1 {{'operand_segment_sizes' attribute cannot have negative elements}}
- "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = dense<[1, 1, -1, 1]>: vector<4xi32>} : (i32, i32, i32, i32) -> ()
+ "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = array<i32: 1, 1, -1, 1>} : (i32, i32, i32, i32) -> ()
}
// -----
func.func @failedOperandSizeAttrWrongTotalSize(%arg: i32) {
// expected-error @+1 {{operand count (4) does not match with the total size (3) specified in attribute 'operand_segment_sizes'}}
- "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = dense<[0, 1, 1, 1]>: vector<4xi32>} : (i32, i32, i32, i32) -> ()
+ "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = array<i32: 0, 1, 1, 1>} : (i32, i32, i32, i32) -> ()
}
// -----
func.func @failedOperandSizeAttrWrongCount(%arg: i32) {
// expected-error @+1 {{'operand_segment_sizes' attribute for specifying operand segments must have 4 elements}}
- "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = dense<[2, 1, 1]>: vector<3xi32>} : (i32, i32, i32, i32) -> ()
+ "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = array<i32: 2, 1, 1>} : (i32, i32, i32, i32) -> ()
}
// -----
func.func @succeededOperandSizeAttr(%arg: i32) {
// CHECK: test.attr_sized_operands
- "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = dense<[0, 2, 1, 1]>: vector<4xi32>} : (i32, i32, i32, i32) -> ()
+ "test.attr_sized_operands"(%arg, %arg, %arg, %arg) {operand_segment_sizes = array<i32: 0, 2, 1, 1>} : (i32, i32, i32, i32) -> ()
return
}
// -----
func.func @failedMissingResultSizeAttr() {
- // expected-error @+1 {{requires 1D i32 elements attribute 'result_segment_sizes'}}
+ // expected-error @+1 {{requires dense i32 array attribute 'result_segment_sizes'}}
%0:4 = "test.attr_sized_results"() : () -> (i32, i32, i32, i32)
}
// -----
func.func @failedResultSizeAttrWrongType() {
- // expected-error @+1 {{requires 1D i32 elements attribute 'result_segment_sizes'}}
+ // expected-error @+1 {{requires dense i32 array attribute 'result_segment_sizes'}}
%0:4 = "test.attr_sized_results"() {result_segment_sizes = 10} : () -> (i32, i32, i32, i32)
}
-// -----
-
-func.func @failedResultSizeAttrWrongRank() {
- // expected-error @+1 {{requires 1D i32 elements attribute 'result_segment_sizes'}}
- %0:4 = "test.attr_sized_results"() {result_segment_sizes = dense<[[1, 1], [1, 1]]>: vector<2x2xi32>} : () -> (i32, i32, i32, i32)
-}
// -----
func.func @failedResultSizeAttrWrongElementType() {
- // expected-error @+1 {{requires 1D i32 elements attribute 'result_segment_sizes'}}
- %0:4 = "test.attr_sized_results"() {result_segment_sizes = dense<[1, 1, 1, 1]>: vector<4xi64>} : () -> (i32, i32, i32, i32)
+ // expected-error @+1 {{requires dense i32 array attribute 'result_segment_sizes'}}
+ %0:4 = "test.attr_sized_results"() {result_segment_sizes = array<i64: 1, 1, 1, 1>} : () -> (i32, i32, i32, i32)
}
// -----
func.func @failedResultSizeAttrNegativeValue() {
// expected-error @+1 {{'result_segment_sizes' attribute cannot have negative elements}}
- %0:4 = "test.attr_sized_results"() {result_segment_sizes = dense<[1, 1, -1, 1]>: vector<4xi32>} : () -> (i32, i32, i32, i32)
+ %0:4 = "test.attr_sized_results"() {result_segment_sizes = array<i32: 1, 1, -1, 1>} : () -> (i32, i32, i32, i32)
}
// -----
func.func @failedResultSizeAttrWrongTotalSize() {
// expected-error @+1 {{result count (4) does not match with the total size (3) specified in attribute 'result_segment_sizes'}}
- %0:4 = "test.attr_sized_results"() {result_segment_sizes = dense<[0, 1, 1, 1]>: vector<4xi32>} : () -> (i32, i32, i32, i32)
+ %0:4 = "test.attr_sized_results"() {result_segment_sizes = array<i32: 0, 1, 1, 1>} : () -> (i32, i32, i32, i32)
}
// -----
func.func @failedResultSizeAttrWrongCount() {
// expected-error @+1 {{'result_segment_sizes' attribute for specifying result segments must have 4 elements, but got 3}}
- %0:4 = "test.attr_sized_results"() {result_segment_sizes = dense<[2, 1, 1]>: vector<3xi32>} : () -> (i32, i32, i32, i32)
+ %0:4 = "test.attr_sized_results"() {result_segment_sizes = array<i32: 2, 1, 1>} : () -> (i32, i32, i32, i32)
}
// -----
func.func @succeededResultSizeAttr() {
// CHECK: test.attr_sized_results
- %0:4 = "test.attr_sized_results"() {result_segment_sizes = dense<[0, 2, 1, 1]>: vector<4xi32>} : () -> (i32, i32, i32, i32)
+ %0:4 = "test.attr_sized_results"() {result_segment_sizes = array<i32: 0, 2, 1, 1>} : () -> (i32, i32, i32, i32)
return
}
diff --git a/mlir/test/Rewrite/pdl-bytecode.mlir b/mlir/test/Rewrite/pdl-bytecode.mlir
index aed1bbc..20e2490 100644
--- a/mlir/test/Rewrite/pdl-bytecode.mlir
+++ b/mlir/test/Rewrite/pdl-bytecode.mlir
@@ -1051,7 +1051,7 @@ module @patterns {
// CHECK-NEXT: "test.success"(%[[INPUTS]]#4) : (i32) -> ()
module @ir attributes { test.get_operands_2 } {
%inputs:5 = "test.producer"() : () -> (i32, i32, i32, i32, i32)
- "test.attr_sized_operands"(%inputs#0, %inputs#1, %inputs#2, %inputs#3, %inputs#4) {operand_segment_sizes = dense<[0, 4, 1, 0]> : vector<4xi32>} : (i32, i32, i32, i32, i32) -> ()
+ "test.attr_sized_operands"(%inputs#0, %inputs#1, %inputs#2, %inputs#3, %inputs#4) {operand_segment_sizes = array<i32: 0, 4, 1, 0>} : (i32, i32, i32, i32, i32) -> ()
}
// -----
@@ -1204,7 +1204,7 @@ module @patterns {
// CHECK: %[[RESULTS_2_SINGLE:.*]] = "test.success"() : () -> i32
// CHECK: "test.consumer"(%[[RESULTS_1]]#0, %[[RESULTS_1]]#1, %[[RESULTS_1]]#2, %[[RESULTS_1]]#3, %[[RESULTS_2]]) : (i32, i32, i32, i32, i32) -> ()
module @ir attributes { test.get_results_2 } {
- %results:5 = "test.attr_sized_results"() {result_segment_sizes = dense<[0, 4, 1, 0]> : vector<4xi32>} : () -> (i32, i32, i32, i32, i32)
+ %results:5 = "test.attr_sized_results"() {result_segment_sizes = array<i32: 0, 4, 1, 0>} : () -> (i32, i32, i32, i32, i32)
"test.consumer"(%results#0, %results#1, %results#2, %results#3, %results#4) : (i32, i32, i32, i32, i32) -> ()
}
diff --git a/mlir/test/Target/LLVMIR/openmp-llvm.mlir b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
index a3e6aa2..05ab821 100644
--- a/mlir/test/Target/LLVMIR/openmp-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/openmp-llvm.mlir
@@ -379,7 +379,7 @@ llvm.func @wsloop_simple(%arg0: !llvm.ptr<f32>) {
llvm.store %3, %4 : !llvm.ptr<f32>
omp.yield
// CHECK: call void @__kmpc_for_static_fini(ptr @[[$wsloop_loc_struct]],
- }) {operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0]> : vector<7xi32>} : (i64, i64, i64) -> ()
+ }) {operand_segment_sizes = array<i32: 1, 1, 1, 0, 0, 0, 0>} : (i64, i64, i64) -> ()
omp.terminator
}
llvm.return
@@ -399,7 +399,7 @@ llvm.func @wsloop_inclusive_1(%arg0: !llvm.ptr<f32>) {
%4 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
llvm.store %3, %4 : !llvm.ptr<f32>
omp.yield
- }) {operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0]> : vector<7xi32>} : (i64, i64, i64) -> ()
+ }) {operand_segment_sizes = array<i32: 1, 1, 1, 0, 0, 0, 0>} : (i64, i64, i64) -> ()
llvm.return
}
@@ -417,7 +417,7 @@ llvm.func @wsloop_inclusive_2(%arg0: !llvm.ptr<f32>) {
%4 = llvm.getelementptr %arg0[%arg1] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
llvm.store %3, %4 : !llvm.ptr<f32>
omp.yield
- }) {inclusive, operand_segment_sizes = dense<[1, 1, 1, 0, 0, 0, 0]> : vector<7xi32>} : (i64, i64, i64) -> ()
+ }) {inclusive, operand_segment_sizes = array<i32: 1, 1, 1, 0, 0, 0, 0>} : (i64, i64, i64) -> ()
llvm.return
}
@@ -697,8 +697,8 @@ llvm.func @simdloop_simple(%lb : i64, %ub : i64, %step : i64, %arg0: !llvm.ptr<f
%4 = llvm.getelementptr %arg0[%iv] : (!llvm.ptr<f32>, i64) -> !llvm.ptr<f32>
llvm.store %3, %4 : !llvm.ptr<f32>
omp.yield
- }) {operand_segment_sizes = dense<[1,1,1,0]> : vector<4xi32>} :
- (i64, i64, i64) -> ()
+ }) {operand_segment_sizes = array<i32: 1,1,1,0>} :
+ (i64, i64, i64) -> ()
llvm.return
}
@@ -720,7 +720,7 @@ llvm.func @simdloop_simple_multiple(%lb1 : i64, %ub1 : i64, %step1 : i64, %lb2 :
llvm.store %3, %4 : !llvm.ptr<f32>
llvm.store %3, %5 : !llvm.ptr<f32>
omp.yield
- }
+ }
llvm.return
}
// CHECK: llvm.loop.parallel_accesses
@@ -753,9 +753,9 @@ llvm.func @simdloop_simple_multiple_simdlen(%lb1 : i64, %ub1 : i64, %step1 : i64
// CHECK-LABEL: @simdloop_if
llvm.func @simdloop_if(%arg0: !llvm.ptr<i32> {fir.bindc_name = "n"}, %arg1: !llvm.ptr<i32> {fir.bindc_name = "threshold"}) {
%0 = llvm.mlir.constant(1 : i64) : i64
- %1 = llvm.alloca %0 x i32 {adapt.valuebyref, in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>} : (i64) -> !llvm.ptr<i32>
+ %1 = llvm.alloca %0 x i32 {adapt.valuebyref, in_type = i32, operand_segment_sizes = array<i32: 0, 0>} : (i64) -> !llvm.ptr<i32>
%2 = llvm.mlir.constant(1 : i64) : i64
- %3 = llvm.alloca %2 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFtest_simdEi"} : (i64) -> !llvm.ptr<i32>
+ %3 = llvm.alloca %2 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFtest_simdEi"} : (i64) -> !llvm.ptr<i32>
%4 = llvm.mlir.constant(0 : i32) : i32
%5 = llvm.load %arg0 : !llvm.ptr<i32>
%6 = llvm.mlir.constant(1 : i32) : i32
diff --git a/mlir/test/Transforms/canonicalize-block-merge.mlir b/mlir/test/Transforms/canonicalize-block-merge.mlir
index 4c5cd75..3a19cac 100644
--- a/mlir/test/Transforms/canonicalize-block-merge.mlir
+++ b/mlir/test/Transforms/canonicalize-block-merge.mlir
@@ -257,7 +257,7 @@ func.func @nomerge(%arg0: i32, %i: i32) {
func.func @mismatch_dominance() -> i32 {
// CHECK: %[[RES:.*]] = "test.producing_br"()
%0 = "test.producing_br"()[^bb1, ^bb2] {
- operand_segment_sizes = dense<0> : vector<2 x i32>
+ operand_segment_sizes = array<i32: 0, 0>
} : () -> i32
^bb1:
diff --git a/mlir/test/Transforms/sccp.mlir b/mlir/test/Transforms/sccp.mlir
index 490809f..2c7f571 100644
--- a/mlir/test/Transforms/sccp.mlir
+++ b/mlir/test/Transforms/sccp.mlir
@@ -204,7 +204,7 @@ func.func @simple_produced_operand() -> (i32, i32) {
// CHECK: %[[ONE:.*]] = arith.constant 1
%1 = arith.constant 1 : i32
"test.internal_br"(%1) [^bb1, ^bb2] {
- operand_segment_sizes = dense<[0, 1]> : vector<2 x i32>
+ operand_segment_sizes = array<i32: 0, 1>
} : (i32) -> ()
^bb1:
@@ -231,4 +231,3 @@ func.func @inplace_fold(%arg: i1) -> (i32) {
^b:
return %1 : i32
}
-
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index b500a54..377e902 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -716,14 +716,14 @@ def AttrSizedOperandOp : TEST_Op<"attr_sized_operands",
Variadic<I32>:$b,
I32:$c,
Variadic<I32>:$d,
- I32ElementsAttr:$operand_segment_sizes
+ DenseI32ArrayAttr:$operand_segment_sizes
);
}
def AttrSizedResultOp : TEST_Op<"attr_sized_results",
[AttrSizedResultSegments]> {
let arguments = (ins
- I32ElementsAttr:$result_segment_sizes
+ DenseI32ArrayAttr:$result_segment_sizes
);
let results = (outs
Variadic<I32>:$a,
@@ -2056,7 +2056,7 @@ def FormatVariadicOfVariadicOperand
: TEST_Op<"format_variadic_of_variadic_operand"> {
let arguments = (ins
VariadicOfVariadic<I64, "operand_segments">:$operand,
- I32ElementsAttr:$operand_segments
+ DenseI32ArrayAttr:$operand_segments
);
let assemblyFormat = [{ $operand `:` type($operand) attr-dict}];
}
diff --git a/mlir/test/python/dialects/linalg/ops.py b/mlir/test/python/dialects/linalg/ops.py
index f11c059..fbb0552 100644
--- a/mlir/test/python/dialects/linalg/ops.py
+++ b/mlir/test/python/dialects/linalg/ops.py
@@ -1,12 +1,8 @@
# RUN: %PYTHON %s | FileCheck %s
-from mlir.ir import *
-from mlir.dialects import arith
-from mlir.dialects import builtin
-from mlir.dialects import func
-from mlir.dialects import linalg
-
+from mlir.dialects import arith, builtin, func, linalg
from mlir.dialects.linalg.opdsl.lang import *
+from mlir.ir import *
def run(f):
@@ -138,7 +134,7 @@ def testNamedStructuredOpGenericForm():
# CHECK-NEXT: arith.addf{{.*}} (f32, f32) -> f32
# CHECK-NEXT: linalg.yield{{.*}} (f32) -> ()
# CHECK-NEXT: cast = #linalg.type_fn<cast_signed>
- # CHECK-SAME: operand_segment_sizes = dense<[2, 1]> : vector<2xi32>
+ # CHECK-SAME: operand_segment_sizes = array<i32: 2, 1>
# CHECK-SAME: (tensor<4x16xf32>, tensor<16x8xf32>, tensor<4x8xf32>) -> tensor<4x8xf32>
return linalg.matmul(lhs, rhs, outs=[init_result.result])
diff --git a/mlir/test/python/dialects/ods_helpers.py b/mlir/test/python/dialects/ods_helpers.py
index 5aa9bef..f09d730 100644
--- a/mlir/test/python/dialects/ods_helpers.py
+++ b/mlir/test/python/dialects/ods_helpers.py
@@ -1,8 +1,10 @@
# RUN: %PYTHON %s | FileCheck %s
import gc
+
from mlir.ir import *
+
def run(f):
print("\nTEST:", f.__name__)
f()
@@ -125,8 +127,8 @@ def testOdsBuildDefaultSizedVariadic():
# CHECK: %[[V2:.+]] = "custom.value"
# CHECK: %[[V3:.+]] = "custom.value"
# CHECK: "custom.test_op"(%[[V0]], %[[V1]], %[[V2]], %[[V3]])
- # CHECK-SAME: operand_segment_sizes = dense<[1, 2, 1]> : vector<3xi32>
- # CHECK-SAME: result_segment_sizes = dense<[2, 1, 1]> : vector<3xi32>
+ # CHECK-SAME: operand_segment_sizes = array<i32: 1, 2, 1>
+ # CHECK-SAME: result_segment_sizes = array<i32: 2, 1, 1>>]
# CHECK-SAME: : (i32, i32, i32, i32) -> (i8, i16, i32, i64)
op = TestOp.build_generic(
results=[[t0, t1], t2, t3],
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 0b03c76..1efe6af 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -94,27 +94,23 @@ static const char *const sameVariadicSizeValueRangeCalcCode = R"(
/// the op has an attribute specifying the size of each operand/result segment
/// (variadic or not).
static const char *const attrSizedSegmentValueRangeCalcCode = R"(
- const uint32_t *sizeAttrValueIt = &*sizeAttr.value_begin<uint32_t>();
- if (sizeAttr.isSplat())
- return {*sizeAttrValueIt * index, *sizeAttrValueIt};
-
unsigned start = 0;
for (unsigned i = 0; i < index; ++i)
- start += sizeAttrValueIt[i];
- return {start, sizeAttrValueIt[index]};
+ start += sizeAttr[i];
+ return {start, sizeAttr[index]};
)";
/// The code snippet to initialize the sizes for the value range calculation.
///
/// {0}: The code to get the attribute.
static const char *const adapterSegmentSizeAttrInitCode = R"(
assert(odsAttrs && "missing segment size attribute for op");
- auto sizeAttr = {0}.cast<::mlir::DenseIntElementsAttr>();
+ auto sizeAttr = {0}.cast<::mlir::DenseI32ArrayAttr>();
)";
/// The code snippet to initialize the sizes for the value range calculation.
///
/// {0}: The code to get the attribute.
static const char *const opSegmentSizeAttrInitCode = R"(
- auto sizeAttr = {0}.cast<::mlir::DenseIntElementsAttr>();
+ auto sizeAttr = {0}.cast<::mlir::DenseI32ArrayAttr>();
)";
/// The logic to calculate the actual value range for a declared operand
@@ -124,13 +120,12 @@ static const char *const opSegmentSizeAttrInitCode = R"(
/// {1}: The index of the main operand.
static const char *const variadicOfVariadicAdaptorCalcCode = R"(
auto tblgenTmpOperands = getODSOperands({1});
- auto sizeAttrValues = {0}().getValues<uint32_t>();
- auto sizeAttrIt = sizeAttrValues.begin();
+ auto sizes = {0}();
::llvm::SmallVector<::mlir::ValueRange> tblgenTmpOperandGroups;
- for (int i = 0, e = ::llvm::size(sizeAttrValues); i < e; ++i, ++sizeAttrIt) {{
- tblgenTmpOperandGroups.push_back(tblgenTmpOperands.take_front(*sizeAttrIt));
- tblgenTmpOperands = tblgenTmpOperands.drop_front(*sizeAttrIt);
+ for (int i = 0, e = sizes.size(); i < e; ++i) {{
+ tblgenTmpOperandGroups.push_back(tblgenTmpOperands.take_front(sizes[i]));
+ tblgenTmpOperands = tblgenTmpOperands.drop_front(sizes[i]);
}
return tblgenTmpOperandGroups;
)";
@@ -608,9 +603,8 @@ static void genNativeTraitAttrVerifier(MethodBody &body,
// {3}: Emit error prefix.
const char *const checkAttrSizedValueSegmentsCode = R"(
{
- auto sizeAttr = tblgen_{0}.cast<::mlir::DenseIntElementsAttr>();
- auto numElements =
- sizeAttr.getType().cast<::mlir::ShapedType>().getNumElements();
+ auto sizeAttr = tblgen_{0}.cast<::mlir::DenseI32ArrayAttr>();
+ auto numElements = sizeAttr.asArrayRef().size();
if (numElements != {1})
return {3}"'{0}' attribute for specifying {2} segments must have {1} "
"elements, but got ") << numElements;
@@ -2056,7 +2050,7 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(
<< op.getGetterName(
operand.constraint.getVariadicOfVariadicSegmentSizeAttr())
<< "AttrName(" << builderOpState << ".name), " << odsBuilder
- << ".getI32TensorAttr(rangeSegments));"
+ << ".getDenseI32ArrayAttr(rangeSegments));"
<< " }\n";
continue;
}
@@ -2071,7 +2065,7 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(
std::string sizes = op.getGetterName(operandSegmentAttrName);
body << " " << builderOpState << ".addAttribute(" << sizes << "AttrName("
<< builderOpState << ".name), "
- << "odsBuilder.getI32VectorAttr({";
+ << "odsBuilder.getDenseI32ArrayAttr({";
interleaveComma(llvm::seq<int>(0, op.getNumOperands()), body, [&](int i) {
const NamedTypeConstraint &operand = op.getOperand(i);
if (!operand.isVariableLength()) {
diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index f52d14d..55a4a8f 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -1558,7 +1558,7 @@ void OperationFormat::genParserVariadicSegmentResolution(Operator &op,
if (!allOperands) {
if (op.getTrait("::mlir::OpTrait::AttrSizedOperandSegments")) {
body << " result.addAttribute(\"operand_segment_sizes\", "
- << "parser.getBuilder().getI32VectorAttr({";
+ << "parser.getBuilder().getDenseI32ArrayAttr({";
auto interleaveFn = [&](const NamedTypeConstraint &operand) {
// If the operand is variadic emit the parsed size.
if (operand.isVariableLength())
@@ -1574,7 +1574,7 @@ void OperationFormat::genParserVariadicSegmentResolution(Operator &op,
continue;
body << llvm::formatv(
" result.addAttribute(\"{0}\", "
- "parser.getBuilder().getI32TensorAttr({1}OperandGroupSizes));\n",
+ "parser.getBuilder().getDenseI32ArrayAttr({1}OperandGroupSizes));\n",
operand.constraint.getVariadicOfVariadicSegmentSizeAttr(),
operand.name);
}
@@ -1583,7 +1583,7 @@ void OperationFormat::genParserVariadicSegmentResolution(Operator &op,
if (!allResultTypes &&
op.getTrait("::mlir::OpTrait::AttrSizedResultSegments")) {
body << " result.addAttribute(\"result_segment_sizes\", "
- << "parser.getBuilder().getI32VectorAttr({";
+ << "parser.getBuilder().getDenseI32ArrayAttr({";
auto interleaveFn = [&](const NamedTypeConstraint &result) {
// If the result is variadic emit the parsed size.
if (result.isVariableLength())