Skip to content

[AMDGPU][NFC] Make GFX*Gen records globally available. #97291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions llvm/lib/Target/AMDGPU/SIInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ def SIEncodingFamily {
int GFX12 = 11;
}

//===----------------------------------------------------------------------===//
// Subtarget info
//===----------------------------------------------------------------------===//

class GFXGen<Predicate pred, string dn, string suffix, int sub> {
Predicate AssemblerPredicate = pred;
string DecoderNamespace = dn;
string Suffix = suffix;
int Subtarget = sub;
}

def GFX12Gen : GFXGen<isGFX12Only, "GFX12", "_gfx12", SIEncodingFamily.GFX12>;
def GFX11Gen : GFXGen<isGFX11Only, "GFX11", "_gfx11", SIEncodingFamily.GFX11>;
def GFX10Gen : GFXGen<isGFX10Only, "GFX10", "_gfx10", SIEncodingFamily.GFX10>;

//===----------------------------------------------------------------------===//
// SI DAG Nodes
//===----------------------------------------------------------------------===//
Expand Down
66 changes: 28 additions & 38 deletions llvm/lib/Target/AMDGPU/SOPInstructions.td
Original file line number Diff line number Diff line change
Expand Up @@ -1966,19 +1966,9 @@ def : ScalarNot2Pat<S_ORN2_B64, or, v2i32>;
// Target-specific instruction encodings.
//===----------------------------------------------------------------------===//

class Select_gfx12<string opName> : SIMCInstr<opName, SIEncodingFamily.GFX12> {
Predicate AssemblerPredicate = isGFX12Only;
string DecoderNamespace = "GFX12";
}

class Select_gfx11<string opName> : SIMCInstr<opName, SIEncodingFamily.GFX11> {
Predicate AssemblerPredicate = isGFX11Only;
string DecoderNamespace = "GFX11";
}

class Select_gfx10<string opName> : SIMCInstr<opName, SIEncodingFamily.GFX10> {
Predicate AssemblerPredicate = isGFX10Only;
string DecoderNamespace = "GFX10";
class Select<GFXGen Gen, string opName> : SIMCInstr<opName, Gen.Subtarget> {
Predicate AssemblerPredicate = Gen.AssemblerPredicate;
string DecoderNamespace = Gen.DecoderNamespace;
}

class Select_vi<string opName> : SIMCInstr<opName, SIEncodingFamily.VI> {
Expand All @@ -1998,7 +1988,7 @@ class Select_gfx6_gfx7<string opName> : SIMCInstr<opName, SIEncodingFamily.SI> {
multiclass SOP1_Real_gfx11<bits<8> op, string name = !tolower(NAME)> {
defvar ps = !cast<SOP1_Pseudo>(NAME);
def _gfx11 : SOP1_Real<op, ps, name>,
Select_gfx11<ps.PseudoInstr>;
Select<GFX11Gen, ps.PseudoInstr>;
if !ne(ps.Mnemonic, name) then
def : AMDGPUMnemonicAlias<ps.Mnemonic, name> {
let AssemblerPredicate = isGFX11Only;
Expand All @@ -2008,7 +1998,7 @@ multiclass SOP1_Real_gfx11<bits<8> op, string name = !tolower(NAME)> {
multiclass SOP1_Real_gfx12<bits<8> op, string name = !tolower(NAME)> {
defvar ps = !cast<SOP1_Pseudo>(NAME);
def _gfx12 : SOP1_Real<op, ps, name>,
Select_gfx12<ps.PseudoInstr>;
Select<GFX12Gen, ps.PseudoInstr>;
if !ne(ps.Mnemonic, name) then
def : AMDGPUMnemonicAlias<ps.Mnemonic, name> {
let AssemblerPredicate = isGFX12Plus;
Expand All @@ -2017,15 +2007,15 @@ multiclass SOP1_Real_gfx12<bits<8> op, string name = !tolower(NAME)> {

multiclass SOP1_M0_Real_gfx12<bits<8> op> {
def _gfx12 : SOP1_Real<op, !cast<SOP1_Pseudo>(NAME)>,
Select_gfx12<!cast<SOP1_Pseudo>(NAME).PseudoInstr> {
Select<GFX12Gen, !cast<SOP1_Pseudo>(NAME).PseudoInstr> {
let Inst{7-0} = M0_gfx11plus.HWEncoding{7-0}; // Set Src0 encoding to M0
}
}

multiclass SOP1_IMM_Real_gfx12<bits<8> op> {
defvar ps = !cast<SOP1_Pseudo>(NAME);
def _gfx12 : SOP1_Real<op, ps>,
Select_gfx12<ps.PseudoInstr>;
Select<GFX12Gen, ps.PseudoInstr>;
}

multiclass SOP1_Real_gfx11_gfx12<bits<8> op, string name = !tolower(NAME)> :
Expand Down Expand Up @@ -2136,7 +2126,7 @@ defm S_RNDNE_F16 : SOP1_Real_gfx11_gfx12<0x06e>;
multiclass SOP1_Real_gfx10<bits<8> op> {
defvar ps = !cast<SOP1_Pseudo>(NAME);
def _gfx10 : SOP1_Real<op, ps>,
Select_gfx10<ps.PseudoInstr>;
Select<GFX10Gen, ps.PseudoInstr>;
}

multiclass SOP1_Real_gfx10_gfx11_gfx12<bits<8> op> :
Expand Down Expand Up @@ -2235,7 +2225,7 @@ defm S_ABS_I32 : SOP1_Real_gfx6_gfx7_gfx10<0x034>;
multiclass SOP2_Real_gfx12<bits<7> op, string name = !tolower(NAME)> {
defvar ps = !cast<SOP2_Pseudo>(NAME);
def _gfx12 : SOP2_Real32<op, ps, name>,
Select_gfx12<ps.PseudoInstr>;
Select<GFX12Gen, ps.PseudoInstr>;
if !ne(ps.Mnemonic, name) then
def : AMDGPUMnemonicAlias<ps.Mnemonic, name> {
let AssemblerPredicate = isGFX12Plus;
Expand All @@ -2254,7 +2244,7 @@ defm S_MAXIMUM_F16 : SOP2_Real_gfx12<0x052>;
multiclass SOP2_Real_gfx11<bits<7> op, string name = !tolower(NAME)> {
defvar ps = !cast<SOP2_Pseudo>(NAME);
def _gfx11 : SOP2_Real32<op, ps, name>,
Select_gfx11<ps.PseudoInstr>;
Select<GFX11Gen, ps.PseudoInstr>;
if !ne(ps.Mnemonic, name) then
def : AMDGPUMnemonicAlias<ps.Mnemonic, name> {
let AssemblerPredicate = isGFX11Only;
Expand Down Expand Up @@ -2317,12 +2307,12 @@ defm S_MUL_U64 : SOP2_Real_gfx12<0x055>;

multiclass SOP2_Real_FMAK_gfx12<bits<7> op> {
def _gfx12 : SOP2_Real64<op, !cast<SOP2_Pseudo>(NAME)>,
Select_gfx12<!cast<SOP2_Pseudo>(NAME).PseudoInstr>;
Select<GFX12Gen, !cast<SOP2_Pseudo>(NAME).PseudoInstr>;
}

multiclass SOP2_Real_FMAK_gfx11<bits<7> op> {
def _gfx11 : SOP2_Real64<op, !cast<SOP2_Pseudo>(NAME)>,
Select_gfx11<!cast<SOP2_Pseudo>(NAME).PseudoInstr>;
Select<GFX11Gen, !cast<SOP2_Pseudo>(NAME).PseudoInstr>;
}

multiclass SOP2_Real_FMAK_gfx11_gfx12<bits<7> op> :
Expand Down Expand Up @@ -2359,7 +2349,7 @@ defm S_MAX_F16 : SOP2_Real_gfx11_Renamed_gfx12<0x04c, "s_max_num_f16">;
multiclass SOP2_Real_gfx10<bits<7> op> {
defvar ps = !cast<SOP2_Pseudo>(NAME);
def _gfx10 : SOP2_Real32<op, ps>,
Select_gfx10<ps.PseudoInstr>;
Select<GFX10Gen, ps.PseudoInstr>;
}

multiclass SOP2_Real_gfx10_gfx11_gfx12<bits<7> op> :
Expand Down Expand Up @@ -2444,7 +2434,7 @@ defm S_ABSDIFF_I32 : SOP2_Real_gfx6_gfx7_gfx10<0x02c>;
multiclass SOPK_Real32_gfx12<bits<5> op, string name = !tolower(NAME)> {
defvar ps = !cast<SOPK_Pseudo>(NAME);
def _gfx12 : SOPK_Real32<op, ps, name>,
Select_gfx12<ps.PseudoInstr>;
Select<GFX12Gen, ps.PseudoInstr>;
if !ne(ps.Mnemonic, name) then
def : AMDGPUMnemonicAlias<ps.Mnemonic, name> {
let AssemblerPredicate = isGFX12Plus;
Expand All @@ -2453,17 +2443,17 @@ multiclass SOPK_Real32_gfx12<bits<5> op, string name = !tolower(NAME)> {

multiclass SOPK_Real32_gfx11<bits<5> op> {
def _gfx11 : SOPK_Real32<op, !cast<SOPK_Pseudo>(NAME)>,
Select_gfx11<!cast<SOPK_Pseudo>(NAME).PseudoInstr>;
Select<GFX11Gen, !cast<SOPK_Pseudo>(NAME).PseudoInstr>;
}

multiclass SOPK_Real64_gfx12<bits<5> op> {
def _gfx12 : SOPK_Real64<op, !cast<SOPK_Pseudo>(NAME)>,
Select_gfx12<!cast<SOPK_Pseudo>(NAME).PseudoInstr>;
Select<GFX12Gen, !cast<SOPK_Pseudo>(NAME).PseudoInstr>;
}

multiclass SOPK_Real64_gfx11<bits<5> op> {
def _gfx11 : SOPK_Real64<op, !cast<SOPK_Pseudo>(NAME)>,
Select_gfx11<!cast<SOPK_Pseudo>(NAME).PseudoInstr>;
Select<GFX11Gen, !cast<SOPK_Pseudo>(NAME).PseudoInstr>;
}

multiclass SOPK_Real32_gfx11_gfx12<bits<5> op> :
Expand All @@ -2490,13 +2480,13 @@ defm S_WAITCNT_LGKMCNT : SOPK_Real32_gfx11<0x01b>;
multiclass SOPK_Real32_gfx10<bits<5> op> {
defvar ps = !cast<SOPK_Pseudo>(NAME);
def _gfx10 : SOPK_Real32<op, ps>,
Select_gfx10<ps.PseudoInstr>;
Select<GFX10Gen, ps.PseudoInstr>;
}

multiclass SOPK_Real64_gfx10<bits<5> op> {
defvar ps = !cast<SOPK_Pseudo>(NAME);
def _gfx10 : SOPK_Real64<op, ps>,
Select_gfx10<ps.PseudoInstr>;
Select<GFX10Gen, ps.PseudoInstr>;
}

multiclass SOPK_Real32_gfx10_gfx11<bits<5> op> :
Expand Down Expand Up @@ -2575,7 +2565,7 @@ defm S_SETREG_IMM32_B32 : SOPK_Real64_gfx6_gfx7_gfx10<0x015>;
multiclass SOPP_Real_32_gfx12<bits<7> op, string name = !tolower(NAME)> {
defvar ps = !cast<SOPP_Pseudo>(NAME);
def _gfx12 : SOPP_Real_32<op, ps, name>,
Select_gfx12<ps.PseudoInstr>;
Select<GFX12Gen, ps.PseudoInstr>;
if !ne(ps.Mnemonic, name) then
def : AMDGPUMnemonicAlias<ps.Mnemonic, name> {
let AssemblerPredicate = isGFX12Plus;
Expand All @@ -2602,7 +2592,7 @@ defm S_WAIT_STORECNT_DSCNT : SOPP_Real_32_gfx12<0x049>;
multiclass SOPP_Real_32_gfx11<bits<7> op, string name = !tolower(NAME)> {
defvar ps = !cast<SOPP_Pseudo>(NAME);
def _gfx11 : SOPP_Real_32<op, ps, name>,
Select_gfx11<ps.PseudoInstr>,
Select<GFX11Gen, ps.PseudoInstr>,
SOPPRelaxTable<0, ps.KeyName, "_gfx11">;
if !ne(ps.Mnemonic, name) then
def : AMDGPUMnemonicAlias<ps.Mnemonic, name> {
Expand All @@ -2612,13 +2602,13 @@ multiclass SOPP_Real_32_gfx11<bits<7> op, string name = !tolower(NAME)> {

multiclass SOPP_Real_64_gfx12<bits<7> op> {
def _gfx12 : SOPP_Real_64<op, !cast<SOPP_Pseudo>(NAME), !cast<SOPP_Pseudo>(NAME).Mnemonic>,
Select_gfx12<!cast<SOPP_Pseudo>(NAME).PseudoInstr>,
Select<GFX12Gen, !cast<SOPP_Pseudo>(NAME).PseudoInstr>,
SOPPRelaxTable<1, !cast<SOPP_Pseudo>(NAME).KeyName, "_gfx12">;
}

multiclass SOPP_Real_64_gfx11<bits<7> op> {
def _gfx11 : SOPP_Real_64<op, !cast<SOPP_Pseudo>(NAME), !cast<SOPP_Pseudo>(NAME).Mnemonic>,
Select_gfx11<!cast<SOPP_Pseudo>(NAME).PseudoInstr>,
Select<GFX11Gen, !cast<SOPP_Pseudo>(NAME).PseudoInstr>,
SOPPRelaxTable<1, !cast<SOPP_Pseudo>(NAME).KeyName, "_gfx11">;
}

Expand Down Expand Up @@ -2708,7 +2698,7 @@ multiclass SOPP_Real_32_gfx8_gfx9<bits<7> op> {
multiclass SOPP_Real_32_gfx10<bits<7> op> {
defvar ps = !cast<SOPP_Pseudo>(NAME);
def _gfx10 : SOPP_Real_32<op, ps>,
Select_gfx10<ps.PseudoInstr>,
Select<GFX10Gen, ps.PseudoInstr>,
SOPPRelaxTable<0, ps.KeyName, "_gfx10">;
}

Expand Down Expand Up @@ -2745,7 +2735,7 @@ multiclass SOPP_Real_64_gfx8_gfx9<bits<7> op> {
multiclass SOPP_Real_64_gfx10<bits<7> op> {
defvar ps = !cast<SOPP_Pseudo>(NAME);
def _gfx10 : SOPP_Real_64<op, ps>,
Select_gfx10<ps.PseudoInstr>,
Select<GFX10Gen, ps.PseudoInstr>,
SOPPRelaxTable<1, ps.KeyName, "_gfx10">;
}

Expand Down Expand Up @@ -2811,12 +2801,12 @@ defm S_CBRANCH_CDBGSYS_AND_USER : SOPP_Real_With_Relaxation_gfx6_gfx7_gfx8_gfx9_

multiclass SOPC_Real_gfx12<bits<7> op> {
def _gfx12 : SOPC_Real<op, !cast<SOPC_Pseudo>(NAME)>,
Select_gfx12<!cast<SOPC_Pseudo>(NAME).PseudoInstr>;
Select<GFX12Gen, !cast<SOPC_Pseudo>(NAME).PseudoInstr>;
}

multiclass SOPC_Real_gfx11<bits<7> op> {
def _gfx11 : SOPC_Real<op, !cast<SOPC_Pseudo>(NAME)>,
Select_gfx11<!cast<SOPC_Pseudo>(NAME).PseudoInstr>;
Select<GFX11Gen, !cast<SOPC_Pseudo>(NAME).PseudoInstr>;
}

multiclass SOPC_Real_gfx11_gfx12<bits<7> op> :
Expand Down Expand Up @@ -2878,7 +2868,7 @@ multiclass SOPC_Real_gfx8_gfx9<bits<7> op> {
multiclass SOPC_Real_gfx10<bits<7> op> {
defvar ps = !cast<SOPC_Pseudo>(NAME);
def _gfx10 : SOPC_Real<op, ps>,
Select_gfx10<ps.PseudoInstr>;
Select<GFX10Gen, ps.PseudoInstr>;
}

multiclass SOPC_Real_gfx8_gfx9_gfx10<bits<7> op> :
Expand Down
16 changes: 0 additions & 16 deletions llvm/lib/Target/AMDGPU/VOPInstructions.td
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,6 @@ class LetDummies {
string DecoderNamespace;
}

//===----------------------------------------------------------------------===//
// VOP Subtarget info
//===----------------------------------------------------------------------===//

class GFXGen<Predicate pred, string dn, string suffix, int sub> {
Predicate AssemblerPredicate = pred;
string DecoderNamespace = dn;
string Suffix = suffix;
int Subtarget = sub;
}

def GFX12Gen : GFXGen<isGFX12Only, "GFX12", "_gfx12", SIEncodingFamily.GFX12>;
def GFX11Gen : GFXGen<isGFX11Only, "GFX11", "_gfx11", SIEncodingFamily.GFX11>;

//===----------------------------------------------------------------------===//

class VOP <string opName> {
string OpName = opName;
}
Expand Down
Loading