@@ -62,8 +62,6 @@ constexpr unsigned packedSizeInBitsForDefault =
6262 16 ; // Minimum packing size per register for DPAS A.
6363constexpr unsigned packedSizeInBitsForDpasB =
6464 32 ; // Minimum packing size per register for DPAS B.
65- static const char *const operandLayoutNamePrefix = " layout_operand_" ;
66- static const char *const resultLayoutNamePrefix = " layout_result_" ;
6765
6866namespace {
6967
@@ -728,10 +726,7 @@ class LayoutAttrAssignment {
728726void LayoutAttrAssignment::assignToUsers (Value v, xegpu::LayoutAttr layout) {
729727 for (OpOperand &user : v.getUses ()) {
730728 Operation *owner = user.getOwner ();
731- unsigned operandNumber = user.getOperandNumber ();
732- // Use a generic name for ease of querying the layout attribute later.
733- std::string attrName =
734- operandLayoutNamePrefix + std::to_string (operandNumber);
729+ std::string attrName = xegpu::getLayoutName (user);
735730 owner->setAttr (attrName, layout);
736731 }
737732}
@@ -805,10 +800,10 @@ LogicalResult LayoutAttrAssignment::assign(Operation *op) {
805800 return success ();
806801 }
807802 // Otherwise simply attach the layout to the op itself.
808- for (auto [i, r] : llvm::enumerate ( op->getResults () )) {
803+ for (auto r : op->getOpResults ( )) {
809804 xegpu::LayoutAttr layoutInfo = getLayoutAttrForValue (r);
810805 if (layoutInfo) {
811- std::string attrName = resultLayoutNamePrefix + std::to_string (i );
806+ std::string attrName = xegpu::getLayoutName (r );
812807 op->setAttr (attrName, layoutInfo);
813808 // Attach the layout attribute to the users of the result.
814809 assignToUsers (r, layoutInfo);
@@ -928,11 +923,8 @@ static SmallVector<NamedAttribute>
928923removeTemporaryLayoutAttributes (ArrayRef<NamedAttribute> attrs) {
929924 SmallVector<NamedAttribute> newAttrs;
930925 for (NamedAttribute attr : attrs) {
931- if (attr.getName ().strref ().contains (operandLayoutNamePrefix) ||
932- attr.getName ().strref ().contains (resultLayoutNamePrefix)) {
933- continue ;
934- }
935- newAttrs.push_back (attr);
926+ if (!isa<xegpu::LayoutAttr>(attr.getValue ()))
927+ newAttrs.push_back (attr);
936928 }
937929 return newAttrs;
938930}
@@ -1335,11 +1327,10 @@ struct DpasDistribution final : public gpu::WarpDistributionPattern {
13351327
13361328 auto dpasOp = operand->get ().getDefiningOp <xegpu::DpasOp>();
13371329 unsigned operandIdx = operand->getOperandNumber ();
1338- std::string layoutAName =
1339- llvm::formatv (" {0}{1}" , operandLayoutNamePrefix, 0 ).str ();
1340- std::string layoutBName =
1341- llvm::formatv (" {0}{1}" , operandLayoutNamePrefix, 1 ).str ();
1342- auto layoutCName = llvm::formatv (" {0}{1}" , resultLayoutNamePrefix, 0 ).str ();
1330+ std::string layoutAName = xegpu::getLayoutName (dpasOp->getOpOperand (0 ));
1331+ std::string layoutBName = xegpu::getLayoutName (dpasOp->getOpOperand (1 ));
1332+ std::string layoutCName = xegpu::getLayoutName (dpasOp->getOpResult (0 ));
1333+
13431334 xegpu::LayoutAttr layoutA =
13441335 dpasOp->getAttrOfType <xegpu::LayoutAttr>(layoutAName);
13451336 xegpu::LayoutAttr layoutB =
0 commit comments