@@ -69,7 +69,7 @@ namespace {
69
69
70
70
class AMDGPUAsmParser ;
71
71
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 };
73
73
74
74
// ===----------------------------------------------------------------------===//
75
75
// Operand
@@ -179,8 +179,11 @@ class AMDGPUOperand : public MCParsedAsmOperand {
179
179
ImmTyNegHi,
180
180
ImmTySwizzle,
181
181
ImmTyGprIdxMode,
182
+ ImmTyHigh,
183
+ ImmTyBLGP,
184
+ ImmTyCBSZ,
185
+ ImmTyABID,
182
186
ImmTyEndpgm,
183
- ImmTyHigh
184
187
};
185
188
186
189
private:
@@ -497,6 +500,126 @@ class AMDGPUOperand : public MCParsedAsmOperand {
497
500
return isVSrcF16 () || isLiteralImm (MVT::v2f16);
498
501
}
499
502
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
+
500
623
bool isKImmFP32 () const {
501
624
return isLiteralImm (MVT::f32);
502
625
}
@@ -526,6 +649,9 @@ class AMDGPUOperand : public MCParsedAsmOperand {
526
649
bool isSMRDLiteralOffset () const ;
527
650
bool isDPP8 () const ;
528
651
bool isDPPCtrl () const ;
652
+ bool isBLGP () const ;
653
+ bool isCBSZ () const ;
654
+ bool isABID () const ;
529
655
bool isGPRIdxMode () const ;
530
656
bool isS16Imm () const ;
531
657
bool isU16Imm () const ;
@@ -728,9 +854,10 @@ class AMDGPUOperand : public MCParsedAsmOperand {
728
854
case ImmTySwizzle: OS << " Swizzle" ; break ;
729
855
case ImmTyGprIdxMode: OS << " GprIdxMode" ; break ;
730
856
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 ;
734
861
}
735
862
}
736
863
@@ -850,6 +977,7 @@ class KernelScopeInfo {
850
977
void usesRegister (RegisterKind RegKind, unsigned DwordRegIndex, unsigned RegWidth) {
851
978
switch (RegKind) {
852
979
case IS_SGPR: usesSgprAt (DwordRegIndex + RegWidth - 1 ); break ;
980
+ case IS_AGPR: // fall through
853
981
case IS_VGPR: usesVgprAt (DwordRegIndex + RegWidth - 1 ); break ;
854
982
default : break ;
855
983
}
@@ -1275,6 +1403,10 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
1275
1403
void cvtSDWA (MCInst &Inst, const OperandVector &Operands,
1276
1404
uint64_t BasicInstType, bool skipVcc = false );
1277
1405
1406
+ AMDGPUOperand::Ptr defaultBLGP () const ;
1407
+ AMDGPUOperand::Ptr defaultCBSZ () const ;
1408
+ AMDGPUOperand::Ptr defaultABID () const ;
1409
+
1278
1410
OperandMatchResultTy parseEndpgmOp (OperandVector &Operands);
1279
1411
AMDGPUOperand::Ptr defaultEndpgmImmOperands () const ;
1280
1412
};
@@ -1312,6 +1444,8 @@ static const fltSemantics *getOpFltSemantics(uint8_t OperandType) {
1312
1444
case AMDGPU::OPERAND_REG_IMM_FP32:
1313
1445
case AMDGPU::OPERAND_REG_INLINE_C_INT32:
1314
1446
case AMDGPU::OPERAND_REG_INLINE_C_FP32:
1447
+ case AMDGPU::OPERAND_REG_INLINE_AC_INT32:
1448
+ case AMDGPU::OPERAND_REG_INLINE_AC_FP32:
1315
1449
return &APFloat::IEEEsingle ();
1316
1450
case AMDGPU::OPERAND_REG_IMM_INT64:
1317
1451
case AMDGPU::OPERAND_REG_IMM_FP64:
@@ -1324,6 +1458,10 @@ static const fltSemantics *getOpFltSemantics(uint8_t OperandType) {
1324
1458
case AMDGPU::OPERAND_REG_INLINE_C_FP16:
1325
1459
case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
1326
1460
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:
1327
1465
case AMDGPU::OPERAND_REG_IMM_V2INT16:
1328
1466
case AMDGPU::OPERAND_REG_IMM_V2FP16:
1329
1467
return &APFloat::IEEEhalf ();
@@ -1580,12 +1718,18 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
1580
1718
case AMDGPU::OPERAND_REG_IMM_FP32:
1581
1719
case AMDGPU::OPERAND_REG_INLINE_C_INT32:
1582
1720
case AMDGPU::OPERAND_REG_INLINE_C_FP32:
1721
+ case AMDGPU::OPERAND_REG_INLINE_AC_INT32:
1722
+ case AMDGPU::OPERAND_REG_INLINE_AC_FP32:
1583
1723
case AMDGPU::OPERAND_REG_IMM_INT16:
1584
1724
case AMDGPU::OPERAND_REG_IMM_FP16:
1585
1725
case AMDGPU::OPERAND_REG_INLINE_C_INT16:
1586
1726
case AMDGPU::OPERAND_REG_INLINE_C_FP16:
1587
1727
case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
1588
1728
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:
1589
1733
case AMDGPU::OPERAND_REG_IMM_V2INT16:
1590
1734
case AMDGPU::OPERAND_REG_IMM_V2FP16: {
1591
1735
bool lost;
@@ -1614,6 +1758,8 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
1614
1758
case AMDGPU::OPERAND_REG_IMM_FP32:
1615
1759
case AMDGPU::OPERAND_REG_INLINE_C_INT32:
1616
1760
case AMDGPU::OPERAND_REG_INLINE_C_FP32:
1761
+ case AMDGPU::OPERAND_REG_INLINE_AC_INT32:
1762
+ case AMDGPU::OPERAND_REG_INLINE_AC_FP32:
1617
1763
case AMDGPU::OPERAND_REG_IMM_V2INT16:
1618
1764
case AMDGPU::OPERAND_REG_IMM_V2FP16:
1619
1765
if (isSafeTruncation (Val, 32 ) &&
@@ -1642,6 +1788,8 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
1642
1788
case AMDGPU::OPERAND_REG_IMM_FP16:
1643
1789
case AMDGPU::OPERAND_REG_INLINE_C_INT16:
1644
1790
case AMDGPU::OPERAND_REG_INLINE_C_FP16:
1791
+ case AMDGPU::OPERAND_REG_INLINE_AC_INT16:
1792
+ case AMDGPU::OPERAND_REG_INLINE_AC_FP16:
1645
1793
if (isSafeTruncation (Val, 16 ) &&
1646
1794
AMDGPU::isInlinableLiteral16 (static_cast <int16_t >(Val),
1647
1795
AsmParser->hasInv2PiInlineImm ())) {
@@ -1653,7 +1801,9 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
1653
1801
return ;
1654
1802
1655
1803
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: {
1657
1807
assert (isSafeTruncation (Val, 16 ));
1658
1808
assert (AMDGPU::isInlinableLiteral16 (static_cast <int16_t >(Val),
1659
1809
AsmParser->hasInv2PiInlineImm ()));
@@ -1741,6 +1891,15 @@ static int getRegClass(RegisterKind Is, unsigned RegWidth) {
1741
1891
case 8 : return AMDGPU::SGPR_256RegClassID;
1742
1892
case 16 : return AMDGPU::SGPR_512RegClassID;
1743
1893
}
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
+ }
1744
1903
}
1745
1904
return -1 ;
1746
1905
}
@@ -1837,6 +1996,7 @@ bool AMDGPUAsmParser::AddNextRegisterToList(unsigned &Reg, unsigned &RegWidth,
1837
1996
return false ;
1838
1997
case IS_VGPR:
1839
1998
case IS_SGPR:
1999
+ case IS_AGPR:
1840
2000
case IS_TTMP:
1841
2001
if (Reg1 != Reg + RegWidth) {
1842
2002
return false ;
@@ -1852,6 +2012,8 @@ static const StringRef Registers[] = {
1852
2012
{ " v" },
1853
2013
{ " s" },
1854
2014
{ " ttmp" },
2015
+ { " acc" },
2016
+ { " a" },
1855
2017
};
1856
2018
1857
2019
bool
@@ -1911,6 +2073,9 @@ bool AMDGPUAsmParser::ParseAMDGPURegister(RegisterKind &RegKind, unsigned &Reg,
1911
2073
} else if (RegName[0 ] == ' s' ) {
1912
2074
RegNumIndex = 1 ;
1913
2075
RegKind = IS_SGPR;
2076
+ } else if (RegName[0 ] == ' a' ) {
2077
+ RegNumIndex = RegName.startswith (" acc" ) ? 3 : 1 ;
2078
+ RegKind = IS_AGPR;
1914
2079
} else if (RegName.startswith (" ttmp" )) {
1915
2080
RegNumIndex = strlen (" ttmp" );
1916
2081
RegKind = IS_TTMP;
@@ -1992,6 +2157,7 @@ bool AMDGPUAsmParser::ParseAMDGPURegister(RegisterKind &RegKind, unsigned &Reg,
1992
2157
break ;
1993
2158
case IS_VGPR:
1994
2159
case IS_SGPR:
2160
+ case IS_AGPR:
1995
2161
case IS_TTMP:
1996
2162
{
1997
2163
unsigned Size = 1 ;
@@ -2517,6 +2683,8 @@ bool AMDGPUAsmParser::isInlineConstant(const MCInst &Inst,
2517
2683
const unsigned OperandType = Desc.OpInfo [OpIdx].OperandType ;
2518
2684
if (OperandType == AMDGPU::OPERAND_REG_INLINE_C_V2INT16 ||
2519
2685
OperandType == AMDGPU::OPERAND_REG_INLINE_C_V2FP16 ||
2686
+ OperandType == AMDGPU::OPERAND_REG_INLINE_AC_V2INT16 ||
2687
+ OperandType == AMDGPU::OPERAND_REG_INLINE_AC_V2FP16 ||
2520
2688
OperandType == AMDGPU::OPERAND_REG_IMM_V2INT16 ||
2521
2689
OperandType == AMDGPU::OPERAND_REG_IMM_V2FP16) {
2522
2690
return AMDGPU::isInlinableLiteralV216 (Val, hasInv2PiInlineImm ());
@@ -4327,7 +4495,7 @@ AMDGPUAsmParser::parseNamedBit(const char *Name, OperandVector &Operands,
4327
4495
if (Tok == Name) {
4328
4496
if (Tok == " r128" && isGFX9 ())
4329
4497
Error (S, " r128 modifier is not supported on this GPU" );
4330
- if (Tok == " a16" && !isGFX9 ())
4498
+ if (Tok == " a16" && !isGFX9 () && ! isGFX10 () )
4331
4499
Error (S, " a16 modifier is not supported on this GPU" );
4332
4500
Bit = 1 ;
4333
4501
Parser.Lex ();
@@ -5767,7 +5935,10 @@ static const OptionalOperand AMDGPUOptionalOperandTable[] = {
5767
5935
{" op_sel" , AMDGPUOperand::ImmTyOpSel, false , nullptr },
5768
5936
{" op_sel_hi" , AMDGPUOperand::ImmTyOpSelHi, false , nullptr },
5769
5937
{" 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 }
5771
5942
};
5772
5943
5773
5944
OperandMatchResultTy AMDGPUAsmParser::parseOptionalOperand (OperandVector &Operands) {
@@ -6109,6 +6280,22 @@ bool AMDGPUOperand::isDPPCtrl() const {
6109
6280
return false ;
6110
6281
}
6111
6282
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
+
6112
6299
bool AMDGPUOperand::isS16Imm () const {
6113
6300
return isImm () && (isInt<16 >(getImm ()) || isUInt<16 >(getImm ()));
6114
6301
}
@@ -6594,6 +6781,22 @@ void AMDGPUAsmParser::cvtSDWA(MCInst &Inst, const OperandVector &Operands,
6594
6781
}
6595
6782
}
6596
6783
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
+
6597
6800
// / Force static initialization.
6598
6801
extern " C" void LLVMInitializeAMDGPUAsmParser () {
6599
6802
RegisterMCAsmParser<AMDGPUAsmParser> A (getTheAMDGPUTarget ());
0 commit comments