Skip to content

Commit 9e77d0c

Browse files
committed
[AMDGPU] gfx908 register file changes
Differential Revision: https://reviews.llvm.org/D64438 llvm-svn: 365546
1 parent 3fbd8fd commit 9e77d0c

File tree

7 files changed

+624
-53
lines changed

7 files changed

+624
-53
lines changed

llvm/lib/Target/AMDGPU/AMDGPURegisterInfo.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
let Namespace = "AMDGPU" in {
1414

15-
foreach Index = 0-15 in {
15+
foreach Index = 0-31 in {
1616
def sub#Index : SubRegIndex<32, !shl(Index, 5)>;
1717
}
1818

llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Lines changed: 211 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace {
6969

7070
class AMDGPUAsmParser;
7171

72-
enum RegisterKind { IS_UNKNOWN, IS_VGPR, IS_SGPR, IS_TTMP, IS_SPECIAL };
72+
enum RegisterKind { IS_UNKNOWN, IS_VGPR, IS_SGPR, IS_AGPR, IS_TTMP, IS_SPECIAL };
7373

7474
//===----------------------------------------------------------------------===//
7575
// Operand
@@ -179,8 +179,11 @@ class AMDGPUOperand : public MCParsedAsmOperand {
179179
ImmTyNegHi,
180180
ImmTySwizzle,
181181
ImmTyGprIdxMode,
182+
ImmTyHigh,
183+
ImmTyBLGP,
184+
ImmTyCBSZ,
185+
ImmTyABID,
182186
ImmTyEndpgm,
183-
ImmTyHigh
184187
};
185188

186189
private:
@@ -497,6 +500,126 @@ class AMDGPUOperand : public MCParsedAsmOperand {
497500
return isVSrcF16() || isLiteralImm(MVT::v2f16);
498501
}
499502

503+
bool isVISrcB32() const {
504+
return isRegOrInlineNoMods(AMDGPU::VGPR_32RegClassID, MVT::i32);
505+
}
506+
507+
bool isVISrcB16() const {
508+
return isRegOrInlineNoMods(AMDGPU::VGPR_32RegClassID, MVT::i16);
509+
}
510+
511+
bool isVISrcV2B16() const {
512+
return isVISrcB16();
513+
}
514+
515+
bool isVISrcF32() const {
516+
return isRegOrInlineNoMods(AMDGPU::VGPR_32RegClassID, MVT::f32);
517+
}
518+
519+
bool isVISrcF16() const {
520+
return isRegOrInlineNoMods(AMDGPU::VGPR_32RegClassID, MVT::f16);
521+
}
522+
523+
bool isVISrcV2F16() const {
524+
return isVISrcF16() || isVISrcB32();
525+
}
526+
527+
bool isAISrcB32() const {
528+
return isRegOrInlineNoMods(AMDGPU::AGPR_32RegClassID, MVT::i32);
529+
}
530+
531+
bool isAISrcB16() const {
532+
return isRegOrInlineNoMods(AMDGPU::AGPR_32RegClassID, MVT::i16);
533+
}
534+
535+
bool isAISrcV2B16() const {
536+
return isAISrcB16();
537+
}
538+
539+
bool isAISrcF32() const {
540+
return isRegOrInlineNoMods(AMDGPU::AGPR_32RegClassID, MVT::f32);
541+
}
542+
543+
bool isAISrcF16() const {
544+
return isRegOrInlineNoMods(AMDGPU::AGPR_32RegClassID, MVT::f16);
545+
}
546+
547+
bool isAISrcV2F16() const {
548+
return isAISrcF16() || isAISrcB32();
549+
}
550+
551+
bool isAISrc_128B32() const {
552+
return isRegOrInlineNoMods(AMDGPU::AReg_128RegClassID, MVT::i32);
553+
}
554+
555+
bool isAISrc_128B16() const {
556+
return isRegOrInlineNoMods(AMDGPU::AReg_128RegClassID, MVT::i16);
557+
}
558+
559+
bool isAISrc_128V2B16() const {
560+
return isAISrc_128B16();
561+
}
562+
563+
bool isAISrc_128F32() const {
564+
return isRegOrInlineNoMods(AMDGPU::AReg_128RegClassID, MVT::f32);
565+
}
566+
567+
bool isAISrc_128F16() const {
568+
return isRegOrInlineNoMods(AMDGPU::AReg_128RegClassID, MVT::f16);
569+
}
570+
571+
bool isAISrc_128V2F16() const {
572+
return isAISrc_128F16() || isAISrc_128B32();
573+
}
574+
575+
bool isAISrc_512B32() const {
576+
return isRegOrInlineNoMods(AMDGPU::AReg_512RegClassID, MVT::i32);
577+
}
578+
579+
bool isAISrc_512B16() const {
580+
return isRegOrInlineNoMods(AMDGPU::AReg_512RegClassID, MVT::i16);
581+
}
582+
583+
bool isAISrc_512V2B16() const {
584+
return isAISrc_512B16();
585+
}
586+
587+
bool isAISrc_512F32() const {
588+
return isRegOrInlineNoMods(AMDGPU::AReg_512RegClassID, MVT::f32);
589+
}
590+
591+
bool isAISrc_512F16() const {
592+
return isRegOrInlineNoMods(AMDGPU::AReg_512RegClassID, MVT::f16);
593+
}
594+
595+
bool isAISrc_512V2F16() const {
596+
return isAISrc_512F16() || isAISrc_512B32();
597+
}
598+
599+
bool isAISrc_1024B32() const {
600+
return isRegOrInlineNoMods(AMDGPU::AReg_1024RegClassID, MVT::i32);
601+
}
602+
603+
bool isAISrc_1024B16() const {
604+
return isRegOrInlineNoMods(AMDGPU::AReg_1024RegClassID, MVT::i16);
605+
}
606+
607+
bool isAISrc_1024V2B16() const {
608+
return isAISrc_1024B16();
609+
}
610+
611+
bool isAISrc_1024F32() const {
612+
return isRegOrInlineNoMods(AMDGPU::AReg_1024RegClassID, MVT::f32);
613+
}
614+
615+
bool isAISrc_1024F16() const {
616+
return isRegOrInlineNoMods(AMDGPU::AReg_1024RegClassID, MVT::f16);
617+
}
618+
619+
bool isAISrc_1024V2F16() const {
620+
return isAISrc_1024F16() || isAISrc_1024B32();
621+
}
622+
500623
bool isKImmFP32() const {
501624
return isLiteralImm(MVT::f32);
502625
}
@@ -526,6 +649,9 @@ class AMDGPUOperand : public MCParsedAsmOperand {
526649
bool isSMRDLiteralOffset() const;
527650
bool isDPP8() const;
528651
bool isDPPCtrl() const;
652+
bool isBLGP() const;
653+
bool isCBSZ() const;
654+
bool isABID() const;
529655
bool isGPRIdxMode() const;
530656
bool isS16Imm() const;
531657
bool isU16Imm() const;
@@ -728,9 +854,10 @@ class AMDGPUOperand : public MCParsedAsmOperand {
728854
case ImmTySwizzle: OS << "Swizzle"; break;
729855
case ImmTyGprIdxMode: OS << "GprIdxMode"; break;
730856
case ImmTyHigh: OS << "High"; break;
731-
case ImmTyEndpgm:
732-
OS << "Endpgm";
733-
break;
857+
case ImmTyBLGP: OS << "BLGP"; break;
858+
case ImmTyCBSZ: OS << "CBSZ"; break;
859+
case ImmTyABID: OS << "ABID"; break;
860+
case ImmTyEndpgm: OS << "Endpgm"; break;
734861
}
735862
}
736863

@@ -850,6 +977,7 @@ class KernelScopeInfo {
850977
void usesRegister(RegisterKind RegKind, unsigned DwordRegIndex, unsigned RegWidth) {
851978
switch (RegKind) {
852979
case IS_SGPR: usesSgprAt(DwordRegIndex + RegWidth - 1); break;
980+
case IS_AGPR: // fall through
853981
case IS_VGPR: usesVgprAt(DwordRegIndex + RegWidth - 1); break;
854982
default: break;
855983
}
@@ -1275,6 +1403,10 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
12751403
void cvtSDWA(MCInst &Inst, const OperandVector &Operands,
12761404
uint64_t BasicInstType, bool skipVcc = false);
12771405

1406+
AMDGPUOperand::Ptr defaultBLGP() const;
1407+
AMDGPUOperand::Ptr defaultCBSZ() const;
1408+
AMDGPUOperand::Ptr defaultABID() const;
1409+
12781410
OperandMatchResultTy parseEndpgmOp(OperandVector &Operands);
12791411
AMDGPUOperand::Ptr defaultEndpgmImmOperands() const;
12801412
};
@@ -1312,6 +1444,8 @@ static const fltSemantics *getOpFltSemantics(uint8_t OperandType) {
13121444
case AMDGPU::OPERAND_REG_IMM_FP32:
13131445
case AMDGPU::OPERAND_REG_INLINE_C_INT32:
13141446
case AMDGPU::OPERAND_REG_INLINE_C_FP32:
1447+
case AMDGPU::OPERAND_REG_INLINE_AC_INT32:
1448+
case AMDGPU::OPERAND_REG_INLINE_AC_FP32:
13151449
return &APFloat::IEEEsingle();
13161450
case AMDGPU::OPERAND_REG_IMM_INT64:
13171451
case AMDGPU::OPERAND_REG_IMM_FP64:
@@ -1324,6 +1458,10 @@ static const fltSemantics *getOpFltSemantics(uint8_t OperandType) {
13241458
case AMDGPU::OPERAND_REG_INLINE_C_FP16:
13251459
case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
13261460
case AMDGPU::OPERAND_REG_INLINE_C_V2FP16:
1461+
case AMDGPU::OPERAND_REG_INLINE_AC_INT16:
1462+
case AMDGPU::OPERAND_REG_INLINE_AC_FP16:
1463+
case AMDGPU::OPERAND_REG_INLINE_AC_V2INT16:
1464+
case AMDGPU::OPERAND_REG_INLINE_AC_V2FP16:
13271465
case AMDGPU::OPERAND_REG_IMM_V2INT16:
13281466
case AMDGPU::OPERAND_REG_IMM_V2FP16:
13291467
return &APFloat::IEEEhalf();
@@ -1580,12 +1718,18 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
15801718
case AMDGPU::OPERAND_REG_IMM_FP32:
15811719
case AMDGPU::OPERAND_REG_INLINE_C_INT32:
15821720
case AMDGPU::OPERAND_REG_INLINE_C_FP32:
1721+
case AMDGPU::OPERAND_REG_INLINE_AC_INT32:
1722+
case AMDGPU::OPERAND_REG_INLINE_AC_FP32:
15831723
case AMDGPU::OPERAND_REG_IMM_INT16:
15841724
case AMDGPU::OPERAND_REG_IMM_FP16:
15851725
case AMDGPU::OPERAND_REG_INLINE_C_INT16:
15861726
case AMDGPU::OPERAND_REG_INLINE_C_FP16:
15871727
case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
15881728
case AMDGPU::OPERAND_REG_INLINE_C_V2FP16:
1729+
case AMDGPU::OPERAND_REG_INLINE_AC_INT16:
1730+
case AMDGPU::OPERAND_REG_INLINE_AC_FP16:
1731+
case AMDGPU::OPERAND_REG_INLINE_AC_V2INT16:
1732+
case AMDGPU::OPERAND_REG_INLINE_AC_V2FP16:
15891733
case AMDGPU::OPERAND_REG_IMM_V2INT16:
15901734
case AMDGPU::OPERAND_REG_IMM_V2FP16: {
15911735
bool lost;
@@ -1614,6 +1758,8 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
16141758
case AMDGPU::OPERAND_REG_IMM_FP32:
16151759
case AMDGPU::OPERAND_REG_INLINE_C_INT32:
16161760
case AMDGPU::OPERAND_REG_INLINE_C_FP32:
1761+
case AMDGPU::OPERAND_REG_INLINE_AC_INT32:
1762+
case AMDGPU::OPERAND_REG_INLINE_AC_FP32:
16171763
case AMDGPU::OPERAND_REG_IMM_V2INT16:
16181764
case AMDGPU::OPERAND_REG_IMM_V2FP16:
16191765
if (isSafeTruncation(Val, 32) &&
@@ -1642,6 +1788,8 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
16421788
case AMDGPU::OPERAND_REG_IMM_FP16:
16431789
case AMDGPU::OPERAND_REG_INLINE_C_INT16:
16441790
case AMDGPU::OPERAND_REG_INLINE_C_FP16:
1791+
case AMDGPU::OPERAND_REG_INLINE_AC_INT16:
1792+
case AMDGPU::OPERAND_REG_INLINE_AC_FP16:
16451793
if (isSafeTruncation(Val, 16) &&
16461794
AMDGPU::isInlinableLiteral16(static_cast<int16_t>(Val),
16471795
AsmParser->hasInv2PiInlineImm())) {
@@ -1653,7 +1801,9 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
16531801
return;
16541802

16551803
case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
1656-
case AMDGPU::OPERAND_REG_INLINE_C_V2FP16: {
1804+
case AMDGPU::OPERAND_REG_INLINE_C_V2FP16:
1805+
case AMDGPU::OPERAND_REG_INLINE_AC_V2INT16:
1806+
case AMDGPU::OPERAND_REG_INLINE_AC_V2FP16: {
16571807
assert(isSafeTruncation(Val, 16));
16581808
assert(AMDGPU::isInlinableLiteral16(static_cast<int16_t>(Val),
16591809
AsmParser->hasInv2PiInlineImm()));
@@ -1741,6 +1891,15 @@ static int getRegClass(RegisterKind Is, unsigned RegWidth) {
17411891
case 8: return AMDGPU::SGPR_256RegClassID;
17421892
case 16: return AMDGPU::SGPR_512RegClassID;
17431893
}
1894+
} else if (Is == IS_AGPR) {
1895+
switch (RegWidth) {
1896+
default: return -1;
1897+
case 1: return AMDGPU::AGPR_32RegClassID;
1898+
case 2: return AMDGPU::AReg_64RegClassID;
1899+
case 4: return AMDGPU::AReg_128RegClassID;
1900+
case 16: return AMDGPU::AReg_512RegClassID;
1901+
case 32: return AMDGPU::AReg_1024RegClassID;
1902+
}
17441903
}
17451904
return -1;
17461905
}
@@ -1837,6 +1996,7 @@ bool AMDGPUAsmParser::AddNextRegisterToList(unsigned &Reg, unsigned &RegWidth,
18371996
return false;
18381997
case IS_VGPR:
18391998
case IS_SGPR:
1999+
case IS_AGPR:
18402000
case IS_TTMP:
18412001
if (Reg1 != Reg + RegWidth) {
18422002
return false;
@@ -1852,6 +2012,8 @@ static const StringRef Registers[] = {
18522012
{ "v" },
18532013
{ "s" },
18542014
{ "ttmp" },
2015+
{ "acc" },
2016+
{ "a" },
18552017
};
18562018

18572019
bool
@@ -1911,6 +2073,9 @@ bool AMDGPUAsmParser::ParseAMDGPURegister(RegisterKind &RegKind, unsigned &Reg,
19112073
} else if (RegName[0] == 's') {
19122074
RegNumIndex = 1;
19132075
RegKind = IS_SGPR;
2076+
} else if (RegName[0] == 'a') {
2077+
RegNumIndex = RegName.startswith("acc") ? 3 : 1;
2078+
RegKind = IS_AGPR;
19142079
} else if (RegName.startswith("ttmp")) {
19152080
RegNumIndex = strlen("ttmp");
19162081
RegKind = IS_TTMP;
@@ -1992,6 +2157,7 @@ bool AMDGPUAsmParser::ParseAMDGPURegister(RegisterKind &RegKind, unsigned &Reg,
19922157
break;
19932158
case IS_VGPR:
19942159
case IS_SGPR:
2160+
case IS_AGPR:
19952161
case IS_TTMP:
19962162
{
19972163
unsigned Size = 1;
@@ -2517,6 +2683,8 @@ bool AMDGPUAsmParser::isInlineConstant(const MCInst &Inst,
25172683
const unsigned OperandType = Desc.OpInfo[OpIdx].OperandType;
25182684
if (OperandType == AMDGPU::OPERAND_REG_INLINE_C_V2INT16 ||
25192685
OperandType == AMDGPU::OPERAND_REG_INLINE_C_V2FP16 ||
2686+
OperandType == AMDGPU::OPERAND_REG_INLINE_AC_V2INT16 ||
2687+
OperandType == AMDGPU::OPERAND_REG_INLINE_AC_V2FP16 ||
25202688
OperandType == AMDGPU::OPERAND_REG_IMM_V2INT16 ||
25212689
OperandType == AMDGPU::OPERAND_REG_IMM_V2FP16) {
25222690
return AMDGPU::isInlinableLiteralV216(Val, hasInv2PiInlineImm());
@@ -4327,7 +4495,7 @@ AMDGPUAsmParser::parseNamedBit(const char *Name, OperandVector &Operands,
43274495
if (Tok == Name) {
43284496
if (Tok == "r128" && isGFX9())
43294497
Error(S, "r128 modifier is not supported on this GPU");
4330-
if (Tok == "a16" && !isGFX9())
4498+
if (Tok == "a16" && !isGFX9() && !isGFX10())
43314499
Error(S, "a16 modifier is not supported on this GPU");
43324500
Bit = 1;
43334501
Parser.Lex();
@@ -5767,7 +5935,10 @@ static const OptionalOperand AMDGPUOptionalOperandTable[] = {
57675935
{"op_sel", AMDGPUOperand::ImmTyOpSel, false, nullptr},
57685936
{"op_sel_hi", AMDGPUOperand::ImmTyOpSelHi, false, nullptr},
57695937
{"neg_lo", AMDGPUOperand::ImmTyNegLo, false, nullptr},
5770-
{"neg_hi", AMDGPUOperand::ImmTyNegHi, false, nullptr}
5938+
{"neg_hi", AMDGPUOperand::ImmTyNegHi, false, nullptr},
5939+
{"blgp", AMDGPUOperand::ImmTyBLGP, false, nullptr},
5940+
{"cbsz", AMDGPUOperand::ImmTyCBSZ, false, nullptr},
5941+
{"abid", AMDGPUOperand::ImmTyABID, false, nullptr}
57715942
};
57725943

57735944
OperandMatchResultTy AMDGPUAsmParser::parseOptionalOperand(OperandVector &Operands) {
@@ -6109,6 +6280,22 @@ bool AMDGPUOperand::isDPPCtrl() const {
61096280
return false;
61106281
}
61116282

6283+
//===----------------------------------------------------------------------===//
6284+
// mAI
6285+
//===----------------------------------------------------------------------===//
6286+
6287+
bool AMDGPUOperand::isBLGP() const {
6288+
return isImm() && getImmTy() == ImmTyBLGP && isUInt<3>(getImm());
6289+
}
6290+
6291+
bool AMDGPUOperand::isCBSZ() const {
6292+
return isImm() && getImmTy() == ImmTyCBSZ && isUInt<3>(getImm());
6293+
}
6294+
6295+
bool AMDGPUOperand::isABID() const {
6296+
return isImm() && getImmTy() == ImmTyABID && isUInt<4>(getImm());
6297+
}
6298+
61126299
bool AMDGPUOperand::isS16Imm() const {
61136300
return isImm() && (isInt<16>(getImm()) || isUInt<16>(getImm()));
61146301
}
@@ -6594,6 +6781,22 @@ void AMDGPUAsmParser::cvtSDWA(MCInst &Inst, const OperandVector &Operands,
65946781
}
65956782
}
65966783

6784+
//===----------------------------------------------------------------------===//
6785+
// mAI
6786+
//===----------------------------------------------------------------------===//
6787+
6788+
AMDGPUOperand::Ptr AMDGPUAsmParser::defaultBLGP() const {
6789+
return AMDGPUOperand::CreateImm(this, 0, SMLoc(), AMDGPUOperand::ImmTyBLGP);
6790+
}
6791+
6792+
AMDGPUOperand::Ptr AMDGPUAsmParser::defaultCBSZ() const {
6793+
return AMDGPUOperand::CreateImm(this, 0, SMLoc(), AMDGPUOperand::ImmTyCBSZ);
6794+
}
6795+
6796+
AMDGPUOperand::Ptr AMDGPUAsmParser::defaultABID() const {
6797+
return AMDGPUOperand::CreateImm(this, 0, SMLoc(), AMDGPUOperand::ImmTyABID);
6798+
}
6799+
65976800
/// Force static initialization.
65986801
extern "C" void LLVMInitializeAMDGPUAsmParser() {
65996802
RegisterMCAsmParser<AMDGPUAsmParser> A(getTheAMDGPUTarget());

0 commit comments

Comments
 (0)