18
18
#include " mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
19
19
#include " mlir/Support/LogicalResult.h"
20
20
#include " mlir/Target/SPIRV/SPIRVBinaryUtils.h"
21
+ #include " llvm/ADT/STLExtras.h"
21
22
#include " llvm/ADT/Sequence.h"
22
23
#include " llvm/ADT/SmallPtrSet.h"
23
24
#include " llvm/ADT/StringExtras.h"
@@ -443,13 +444,13 @@ LogicalResult Serializer::prepareBasicType(
443
444
if (failed (processType (loc, imageType.getElementType (), sampledTypeID)))
444
445
return failure ();
445
446
446
- operands. push_back ( sampledTypeID);
447
- operands. push_back ( static_cast <uint32_t >(imageType.getDim ()));
448
- operands. push_back ( static_cast <uint32_t >(imageType.getDepthInfo ()));
449
- operands. push_back ( static_cast <uint32_t >(imageType.getArrayedInfo ()));
450
- operands. push_back ( static_cast <uint32_t >(imageType.getSamplingInfo ()));
451
- operands. push_back ( static_cast <uint32_t >(imageType.getSamplerUseInfo ()));
452
- operands. push_back ( static_cast <uint32_t >(imageType.getImageFormat ()));
447
+ llvm::append_values (operands, sampledTypeID,
448
+ static_cast <uint32_t >(imageType.getDim ()),
449
+ static_cast <uint32_t >(imageType.getDepthInfo ()),
450
+ static_cast <uint32_t >(imageType.getArrayedInfo ()),
451
+ static_cast <uint32_t >(imageType.getSamplingInfo ()),
452
+ static_cast <uint32_t >(imageType.getSamplerUseInfo ()),
453
+ static_cast <uint32_t >(imageType.getImageFormat ()));
453
454
return success ();
454
455
}
455
456
@@ -605,12 +606,11 @@ LogicalResult Serializer::prepareBasicType(
605
606
auto attr = IntegerAttr::get (IntegerType::get (type.getContext (), 32 ), id);
606
607
return prepareConstantInt (loc, attr);
607
608
};
608
- operands.push_back (elementTypeID);
609
- operands.push_back (
610
- getConstantOp (static_cast <uint32_t >(cooperativeMatrixType.getScope ())));
611
- operands.push_back (getConstantOp (cooperativeMatrixType.getRows ()));
612
- operands.push_back (getConstantOp (cooperativeMatrixType.getColumns ()));
613
- operands.push_back (
609
+ llvm::append_values (
610
+ operands, elementTypeID,
611
+ getConstantOp (static_cast <uint32_t >(cooperativeMatrixType.getScope ())),
612
+ getConstantOp (cooperativeMatrixType.getRows ()),
613
+ getConstantOp (cooperativeMatrixType.getColumns ()),
614
614
getConstantOp (static_cast <uint32_t >(cooperativeMatrixType.getUse ())));
615
615
return success ();
616
616
}
@@ -627,11 +627,11 @@ LogicalResult Serializer::prepareBasicType(
627
627
auto attr = IntegerAttr::get (IntegerType::get (type.getContext (), 32 ), id);
628
628
return prepareConstantInt (loc, attr);
629
629
};
630
- operands. push_back (elementTypeID);
631
- operands. push_back (
632
- getConstantOp (static_cast <uint32_t >(cooperativeMatrixType.getScope ())));
633
- operands. push_back ( getConstantOp (cooperativeMatrixType.getRows ()));
634
- operands. push_back ( getConstantOp (cooperativeMatrixType.getColumns ()));
630
+ llvm::append_values (
631
+ operands, elementTypeID,
632
+ getConstantOp (static_cast <uint32_t >(cooperativeMatrixType.getScope ())),
633
+ getConstantOp (cooperativeMatrixType.getRows ()),
634
+ getConstantOp (cooperativeMatrixType.getColumns ()));
635
635
return success ();
636
636
}
637
637
@@ -646,12 +646,10 @@ LogicalResult Serializer::prepareBasicType(
646
646
auto attr = IntegerAttr::get (IntegerType::get (type.getContext (), 32 ), id);
647
647
return prepareConstantInt (loc, attr);
648
648
};
649
- operands.push_back (elementTypeID);
650
- operands.push_back (getConstantOp (jointMatrixType.getRows ()));
651
- operands.push_back (getConstantOp (jointMatrixType.getColumns ()));
652
- operands.push_back (getConstantOp (
653
- static_cast <uint32_t >(jointMatrixType.getMatrixLayout ())));
654
- operands.push_back (
649
+ llvm::append_values (
650
+ operands, elementTypeID, getConstantOp (jointMatrixType.getRows ()),
651
+ getConstantOp (jointMatrixType.getColumns ()),
652
+ getConstantOp (static_cast <uint32_t >(jointMatrixType.getMatrixLayout ())),
655
653
getConstantOp (static_cast <uint32_t >(jointMatrixType.getScope ())));
656
654
return success ();
657
655
}
@@ -663,8 +661,7 @@ LogicalResult Serializer::prepareBasicType(
663
661
return failure ();
664
662
}
665
663
typeEnum = spirv::Opcode::OpTypeMatrix;
666
- operands.push_back (elementTypeID);
667
- operands.push_back (matrixType.getNumColumns ());
664
+ llvm::append_values (operands, elementTypeID, matrixType.getNumColumns ());
668
665
return success ();
669
666
}
670
667
@@ -1261,11 +1258,11 @@ LogicalResult Serializer::emitDecoration(uint32_t target,
1261
1258
spirv::Decoration decoration,
1262
1259
ArrayRef<uint32_t > params) {
1263
1260
uint32_t wordCount = 3 + params.size ();
1264
- decorations. push_back (
1265
- spirv::getPrefixedOpcode (wordCount, spirv::Opcode::OpDecorate));
1266
- decorations. push_back (target);
1267
- decorations. push_back ( static_cast <uint32_t >(decoration));
1268
- decorations. append (params. begin () , params. end () );
1261
+ llvm::append_values (
1262
+ decorations,
1263
+ spirv::getPrefixedOpcode (wordCount, spirv::Opcode::OpDecorate), target,
1264
+ static_cast <uint32_t >(decoration));
1265
+ llvm::append_range (decorations , params);
1269
1266
return success ();
1270
1267
}
1271
1268
0 commit comments