19 case arm_sme::TypeSize::Byte:
21 case arm_sme::TypeSize::Half:
23 case arm_sme::TypeSize::Word:
25 case arm_sme::TypeSize::Double:
28 llvm_unreachable(
"unknown type size");
44 if ((vType.getRank() != 2) || !vType.allDimsScalable())
47 auto elemType = vType.getElementType();
61 switch (type.getElementTypeBitWidth()) {
63 return ArmSMETileType::ZAB;
65 return ArmSMETileType::ZAH;
67 return ArmSMETileType::ZAS;
69 return ArmSMETileType::ZAD;
71 return ArmSMETileType::ZAQ;
73 llvm_unreachable(
"unknown SME tile type");
78 auto tileOp = llvm::dyn_cast<ArmSMETileOpInterface>(op);
81 auto tileId = tileOp.getTileId();
84 if (!tileId.getType().isSignlessInteger(32))
85 return tileOp.emitOpError(
"tile ID should be a 32-bit signless integer");
95 rewriter, loc, llvm::cast<VectorType>(initTile.
getType()).getDimSize(0));
97 vector::VectorScaleOp::create(rewriter, loc, rewriter.
getIndexType());
100 arith::MulIOp::create(rewriter, loc, minTileSlices, vscale);
101 auto forOp = scf::ForOp::create(rewriter, loc, lowerBound, numTileSlices,
105 makeLoopBody(rewriter, loc, forOp.getInductionVar(),
106 forOp.getRegionIterArg(0));
107 scf::YieldOp::create(rewriter, loc, nextTile);
112 if (vType.getRank() != 2 || !vType.allDimsScalable())
115 auto elementType = vType.getElementType();
121 int64_t vectorRows = vType.getDimSize(0);
122 int64_t vectorCols = vType.getDimSize(1);
124 return (vectorRows > minNumElts || vectorCols > minNumElts) &&
125 vectorRows % minNumElts == 0 && vectorCols % minNumElts == 0;
130 return VectorType::get({minNumElts, minNumElts}, elementType, {
true,
true});
134 FunctionOpInterface
function) {
137 auto armSMEOp = dyn_cast<arm_sme::ArmSMETileOpInterface>(op);
139 worklist.push_back(armSMEOp);
141 while (!worklist.empty()) {
146 if (
auto armSMEOp = value.getDefiningOp<arm_sme::ArmSMETileOpInterface>())
147 worklist.push_back(armSMEOp);
154 return tileOp && tileOp->getNumResults() == 1 &&
155 tileOp->getNumOperands() == 0 &&
isPure(tileOp);
159 for (
Value result : tileOp->getResults()) {
169 auto isTileOperandType = [](
OpOperand &operand) {
172 assert(llvm::count_if(tileOp->getOpOperands(), isTileOperandType) <= 1 &&
173 "expected at most one tile operand");
175 llvm::find_if(tileOp->getOpOperands(), isTileOperandType);
176 if (tileOperand == tileOp->getOpOperands().end())
183 return static_cast<unsigned>(typeA) <=
static_cast<unsigned>(typeB);
This class coordinates rewriting a piece of IR outside of a pattern rewrite, providing a way to keep ...
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
RAII guard to reset the insertion point of the builder when destroyed.
This class helps build Operations.
void setInsertionPointToStart(Block *block)
Sets the insertion point to the start of the specified block.
This class represents an operand of an operation.
Operation is the basic unit of execution within MLIR.
operand_range getOperands()
Returns an iterator on the underlying Value's.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
virtual void eraseOp(Operation *op)
This method erases an operation that is known to have no uses.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
bool isInteger() const
Return true if this is an integer type (with the specified width).
unsigned getIntOrFloatBitWidth() const
Return the bit width of an integer or a float type, assert failure on other types.
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
static ConstantIndexOp create(OpBuilder &builder, Location location, int64_t value)
std::optional< ArmSMETileType > getSMETileType(VectorType)
Returns the type of SME tile this vector type corresponds to, or none if the vector type does not fit...
void eraseTriviallyDeadTileOps(IRRewriter &rewriter, FunctionOpInterface function)
Erase trivially dead tile ops from a function.
VectorType getSMETileTypeForElement(Type elementType)
Creates a vector type for the SME tile of elementType.
unsigned getSMETileSliceMinNumElts(Type type)
Return minimum number of elements for the given element type in a vector of SVL bits.
bool isValidSMETileElementType(Type type)
Returns true if type is a valid element type for an SME tile or false otherwise.
bool isMultipleOfSMETileVectorType(VectorType vType)
Returns true if vType is a multiple of an SME tile size.
bool isTriviallyCloneableTileOp(arm_sme::ArmSMETileOpInterface tileOp)
Returns true if tileOp is trivially cloneable.
scf::ForOp createLoopOverTileSlices(PatternRewriter &rewriter, Location loc, Value initTile, std::function< Value(OpBuilder &, Location, Value, Value)> makeLoopBody)
Generates a for loop over ZA tile slices where the induction variable is the tile slice index and eac...
unsigned getSizeInBytes(TypeSize type)
Return the size represented by arm_sme::TypeSize in bytes.
bool isTileTypeGreaterOrEqual(ArmSMETileType typeA, ArmSMETileType typeB)
Returns true typeA is >= (in terms of bytes) than typeB.
bool isValidSMETileVectorType(VectorType vType)
Returns true if vType is a valid vector type for an SME tile or false otherwise.
OpOperand * getTileOpOperand(arm_sme::ArmSMETileOpInterface tileOp)
Returns the tile OpOperand for this tileOp (or null).
LogicalResult verifyOperationHasValidTileId(Operation *)
Verifies the tile ID (if set) on this tile operation is valid.
bool hasTileResult(arm_sme::ArmSMETileOpInterface tileOp)
Returns true if tileOp produces a tile result.
constexpr unsigned MinStreamingVectorLengthInBits
bool isPure(Operation *op)
Returns true if the given operation is pure, i.e., is speculatable that does not touch memory.
bool isOpTriviallyDead(Operation *op)
Return true if the given operation is unused, and has no side effects on memory that prevent erasing.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...