Skip to content

Commit e319379

Browse files
committed
AMDGPU: Create InstrMapping from VGPR MFMA to equivalent AGPR instruction
This provides infrastructure for a future optimization.
1 parent a4f835c commit e319379

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

llvm/lib/Target/AMDGPU/SIInstrInfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,11 @@ namespace AMDGPU {
15681568
LLVM_READONLY
15691569
int getMFMAEarlyClobberOp(uint16_t Opcode);
15701570

1571+
/// \returns Version of an MFMA instruction which uses AGPRs for srcC and
1572+
/// vdst, given an \p Opcode of an MFMA which uses VGPRs for srcC/vdst.
1573+
LLVM_READONLY
1574+
int getMFMASrcCVDstAGPROp(uint16_t Opcode);
1575+
15711576
/// \returns v_cmpx version of a v_cmp instruction.
15721577
LLVM_READONLY
15731578
int getVCMPXOpFromVCMP(uint16_t Opcode);

llvm/lib/Target/AMDGPU/SIInstrInfo.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3146,6 +3146,15 @@ def getMFMAEarlyClobberOp : InstrMapping {
31463146
let ValueCols = [["0"]];
31473147
}
31483148

3149+
// Map from an mfma using VGPRs to one using AGPRs.
3150+
def getMFMASrcCVDstAGPROp : InstrMapping {
3151+
let FilterClass = "MFMATable";
3152+
let RowFields = ["AGPROp"];
3153+
let ColFields = ["MFMAKind"];
3154+
let KeyCol = ["VGPR"];
3155+
let ValueCols = [["AGPR"]];
3156+
}
3157+
31493158
// Maps an v_cmp instruction to its v_cmpx equivalent.
31503159
def getVCMPXOpFromVCMP : InstrMapping {
31513160
let FilterClass = "VCMPVCMPXTable";

llvm/lib/Target/AMDGPU/VOP3PInstructions.td

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,14 @@ def VOPProfileMAI_F32_V4I32_V4I32_X512_VCD : VOPProfileMAI<VOP_V16F32_V4I32_V4I3
721721
}
722722

723723

724-
class MFMATable <bit is_mac, string Name> {
724+
class MFMATable <bit is_mac, string Kind, string Name,
725+
string AGPROpName = NAME> {
725726
bit IsMac = is_mac;
726727
string FMAOp = Name;
728+
string AGPROp = AGPROpName;
729+
730+
// Does this MFMA use "AGPR" or "VGPR" for srcC/vdst
731+
string MFMAKind = Kind;
727732
}
728733

729734
class MFMA_F8F6F4_WithSizeTable<int A, int B, Instruction ThisVariant, Instruction F8F8Variant> {
@@ -829,12 +834,12 @@ multiclass MAIInst<string OpName, string P, SDPatternOperator node = null_frag,
829834
let Constraints = !if(NoDstOverlap, "@earlyclobber $vdst", "") in {
830835
def _e64 : MAIInst<OpName, !cast<VOPProfileMAI>("VOPProfileMAI_" # P),
831836
!if(!or(NoDstOverlap, !eq(node, null_frag)), null_frag, AgprMAIFrag<node, HasAbid, Scaled>), Scaled>,
832-
MFMATable<0, NAME # "_e64">;
837+
MFMATable<0, "AGPR", NAME # "_e64">;
833838

834839
let OtherPredicates = [isGFX90APlus], Mnemonic = OpName in
835840
def _vgprcd_e64 : MAIInst<OpName # "_vgprcd", !cast<VOPProfileMAI>("VOPProfileMAI_" # P # "_VCD"),
836841
!if(!or(NoDstOverlap, !eq(node, null_frag)), null_frag, VgprMAIFrag<node, HasAbid, Scaled>), Scaled>,
837-
MFMATable<0, NAME # "_vgprcd_e64">;
842+
MFMATable<0, "VGPR", NAME # "_vgprcd_e64", NAME # "_e64">;
838843
}
839844

840845
if NoDstOverlap then {
@@ -843,6 +848,7 @@ multiclass MAIInst<string OpName, string P, SDPatternOperator node = null_frag,
843848
Mnemonic = OpName in {
844849
def "_mac_e64" : MAIInst<OpName # "_mac", !cast<VOPProfileMAI>("VOPProfileMAI_" # P),
845850
!if(!eq(node, null_frag), null_frag, AgprMAIFrag<node, HasAbid, Scaled>), Scaled>,
851+
MFMATable<1, "AGPR", NAME # "_e64", NAME # "_mac_e64">;
846852
MFMATable<1, NAME # "_e64">;
847853

848854
let OtherPredicates = [isGFX90APlus] in

0 commit comments

Comments
 (0)