@@ -475,6 +475,8 @@ class AMDGPUOperand : public MCParsedAsmOperand {
475475
476476 bool isSSrcF64 () const { return isSCSrc_b64 () || isLiteralImm (MVT::f64 ); }
477477
478+ bool isSSrc_bf16 () const { return isSCSrcB16 () || isLiteralImm (MVT::bf16 ); }
479+
478480 bool isSSrc_f16 () const { return isSCSrcB16 () || isLiteralImm (MVT::f16 ); }
479481
480482 bool isSSrcV2F16 () const {
@@ -541,22 +543,40 @@ class AMDGPUOperand : public MCParsedAsmOperand {
541543 return isRegOrInlineNoMods (AMDGPU::VS_64RegClassID, MVT::f64 );
542544 }
543545
546+ bool isVCSrcTBF16 () const {
547+ return isRegOrInlineNoMods (AMDGPU::VS_16RegClassID, MVT::bf16 );
548+ }
549+
544550 bool isVCSrcTF16 () const {
545551 return isRegOrInlineNoMods (AMDGPU::VS_16RegClassID, MVT::f16 );
546552 }
547553
554+ bool isVCSrcTBF16_Lo128 () const {
555+ return isRegOrInlineNoMods (AMDGPU::VS_16_Lo128RegClassID, MVT::bf16 );
556+ }
557+
548558 bool isVCSrcTF16_Lo128 () const {
549559 return isRegOrInlineNoMods (AMDGPU::VS_16_Lo128RegClassID, MVT::f16 );
550560 }
551561
562+ bool isVCSrcFake16BF16_Lo128 () const {
563+ return isRegOrInlineNoMods (AMDGPU::VS_32_Lo128RegClassID, MVT::bf16 );
564+ }
565+
552566 bool isVCSrcFake16F16_Lo128 () const {
553567 return isRegOrInlineNoMods (AMDGPU::VS_32_Lo128RegClassID, MVT::f16 );
554568 }
555569
570+ bool isVCSrc_bf16 () const {
571+ return isRegOrInlineNoMods (AMDGPU::VS_32RegClassID, MVT::bf16 );
572+ }
573+
556574 bool isVCSrc_f16 () const {
557575 return isRegOrInlineNoMods (AMDGPU::VS_32RegClassID, MVT::f16 );
558576 }
559577
578+ bool isVCSrc_v2bf16 () const { return isVCSrc_bf16 (); }
579+
560580 bool isVCSrc_v2f16 () const { return isVCSrc_f16 (); }
561581
562582 bool isVSrc_b32 () const {
@@ -597,18 +617,34 @@ class AMDGPUOperand : public MCParsedAsmOperand {
597617
598618 bool isVSrc_f64 () const { return isVCSrcF64 () || isLiteralImm (MVT::f64 ); }
599619
620+ bool isVSrcT_bf16 () const { return isVCSrcTBF16 () || isLiteralImm (MVT::bf16 ); }
621+
600622 bool isVSrcT_f16 () const { return isVCSrcTF16 () || isLiteralImm (MVT::f16 ); }
601623
624+ bool isVSrcT_bf16_Lo128 () const {
625+ return isVCSrcTBF16_Lo128 () || isLiteralImm (MVT::bf16 );
626+ }
627+
602628 bool isVSrcT_f16_Lo128 () const {
603629 return isVCSrcTF16_Lo128 () || isLiteralImm (MVT::f16 );
604630 }
605631
632+ bool isVSrcFake16_bf16_Lo128 () const {
633+ return isVCSrcFake16BF16_Lo128 () || isLiteralImm (MVT::bf16 );
634+ }
635+
606636 bool isVSrcFake16_f16_Lo128 () const {
607637 return isVCSrcFake16F16_Lo128 () || isLiteralImm (MVT::f16 );
608638 }
609639
640+ bool isVSrc_bf16 () const { return isVCSrc_bf16 () || isLiteralImm (MVT::bf16 ); }
641+
610642 bool isVSrc_f16 () const { return isVCSrc_f16 () || isLiteralImm (MVT::f16 ); }
611643
644+ bool isVSrc_v2bf16 () const {
645+ return isVSrc_bf16 () || isLiteralImm (MVT::v2bf16);
646+ }
647+
612648 bool isVSrc_v2f16 () const { return isVSrc_f16 () || isLiteralImm (MVT::v2f16); }
613649
614650 bool isVISrcB32 () const {
@@ -635,6 +671,10 @@ class AMDGPUOperand : public MCParsedAsmOperand {
635671 return isVISrcF16 () || isVISrcB32 ();
636672 }
637673
674+ bool isVISrc_64_bf16 () const {
675+ return isRegOrInlineNoMods (AMDGPU::VReg_64RegClassID, MVT::bf16 );
676+ }
677+
638678 bool isVISrc_64_f16 () const {
639679 return isRegOrInlineNoMods (AMDGPU::VReg_64RegClassID, MVT::f16 );
640680 }
@@ -803,6 +843,10 @@ class AMDGPUOperand : public MCParsedAsmOperand {
803843 return isAISrc_128F16 () || isAISrc_128_b32 ();
804844 }
805845
846+ bool isVISrc_128_bf16 () const {
847+ return isRegOrInlineNoMods (AMDGPU::VReg_128RegClassID, MVT::bf16 );
848+ }
849+
806850 bool isVISrc_128_f16 () const {
807851 return isRegOrInlineNoMods (AMDGPU::VReg_128RegClassID, MVT::f16 );
808852 }
@@ -1890,6 +1934,14 @@ static const fltSemantics *getOpFltSemantics(uint8_t OperandType) {
18901934 case AMDGPU::OPERAND_REG_IMM_V2FP16:
18911935 case AMDGPU::OPERAND_KIMM16:
18921936 return &APFloat::IEEEhalf ();
1937+ case AMDGPU::OPERAND_REG_IMM_BF16:
1938+ case AMDGPU::OPERAND_REG_IMM_BF16_DEFERRED:
1939+ case AMDGPU::OPERAND_REG_INLINE_C_BF16:
1940+ case AMDGPU::OPERAND_REG_INLINE_C_V2BF16:
1941+ case AMDGPU::OPERAND_REG_INLINE_AC_BF16:
1942+ case AMDGPU::OPERAND_REG_INLINE_AC_V2BF16:
1943+ case AMDGPU::OPERAND_REG_IMM_V2BF16:
1944+ return &APFloat::BFloat ();
18931945 default :
18941946 llvm_unreachable (" unsupported fp type" );
18951947 }
@@ -2186,17 +2238,24 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
21862238 case AMDGPU::OPERAND_REG_INLINE_AC_INT32:
21872239 case AMDGPU::OPERAND_REG_INLINE_AC_FP32:
21882240 case AMDGPU::OPERAND_REG_IMM_INT16:
2241+ case AMDGPU::OPERAND_REG_IMM_BF16:
21892242 case AMDGPU::OPERAND_REG_IMM_FP16:
2243+ case AMDGPU::OPERAND_REG_IMM_BF16_DEFERRED:
21902244 case AMDGPU::OPERAND_REG_IMM_FP16_DEFERRED:
21912245 case AMDGPU::OPERAND_REG_INLINE_C_INT16:
2246+ case AMDGPU::OPERAND_REG_INLINE_C_BF16:
21922247 case AMDGPU::OPERAND_REG_INLINE_C_FP16:
21932248 case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
2249+ case AMDGPU::OPERAND_REG_INLINE_C_V2BF16:
21942250 case AMDGPU::OPERAND_REG_INLINE_C_V2FP16:
21952251 case AMDGPU::OPERAND_REG_INLINE_AC_INT16:
2252+ case AMDGPU::OPERAND_REG_INLINE_AC_BF16:
21962253 case AMDGPU::OPERAND_REG_INLINE_AC_FP16:
21972254 case AMDGPU::OPERAND_REG_INLINE_AC_V2INT16:
2255+ case AMDGPU::OPERAND_REG_INLINE_AC_V2BF16:
21982256 case AMDGPU::OPERAND_REG_INLINE_AC_V2FP16:
21992257 case AMDGPU::OPERAND_REG_IMM_V2INT16:
2258+ case AMDGPU::OPERAND_REG_IMM_V2BF16:
22002259 case AMDGPU::OPERAND_REG_IMM_V2FP16:
22012260 case AMDGPU::OPERAND_REG_INLINE_C_V2FP32:
22022261 case AMDGPU::OPERAND_REG_IMM_V2FP32:
@@ -2240,6 +2299,7 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
22402299 case AMDGPU::OPERAND_REG_INLINE_AC_INT32:
22412300 case AMDGPU::OPERAND_REG_INLINE_AC_FP32:
22422301 case AMDGPU::OPERAND_REG_IMM_V2INT16:
2302+ case AMDGPU::OPERAND_REG_IMM_V2BF16:
22432303 case AMDGPU::OPERAND_REG_IMM_V2FP16:
22442304 case AMDGPU::OPERAND_REG_IMM_V2FP32:
22452305 case AMDGPU::OPERAND_REG_INLINE_C_V2FP32:
@@ -2295,6 +2355,22 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
22952355 setImmKindLiteral ();
22962356 return ;
22972357
2358+ case AMDGPU::OPERAND_REG_IMM_BF16:
2359+ case AMDGPU::OPERAND_REG_IMM_BF16_DEFERRED:
2360+ case AMDGPU::OPERAND_REG_INLINE_C_BF16:
2361+ case AMDGPU::OPERAND_REG_INLINE_AC_BF16:
2362+ if (isSafeTruncation (Val, 16 ) &&
2363+ AMDGPU::isInlinableLiteralBF16 (static_cast <int16_t >(Val),
2364+ AsmParser->hasInv2PiInlineImm ())) {
2365+ Inst.addOperand (MCOperand::createImm (Val));
2366+ setImmKindConst ();
2367+ return ;
2368+ }
2369+
2370+ Inst.addOperand (MCOperand::createImm (Val & 0xffff ));
2371+ setImmKindLiteral ();
2372+ return ;
2373+
22982374 case AMDGPU::OPERAND_REG_INLINE_C_V2INT16:
22992375 case AMDGPU::OPERAND_REG_INLINE_C_V2FP16:
23002376 case AMDGPU::OPERAND_REG_INLINE_AC_V2INT16:
@@ -2306,6 +2382,17 @@ void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val, bool ApplyMo
23062382 Inst.addOperand (MCOperand::createImm (Val));
23072383 return ;
23082384 }
2385+
2386+ case AMDGPU::OPERAND_REG_INLINE_C_V2BF16:
2387+ case AMDGPU::OPERAND_REG_INLINE_AC_V2BF16: {
2388+ assert (isSafeTruncation (Val, 16 ));
2389+ assert (AMDGPU::isInlinableLiteralBF16 (static_cast <int16_t >(Val),
2390+ AsmParser->hasInv2PiInlineImm ()));
2391+
2392+ Inst.addOperand (MCOperand::createImm (Val));
2393+ return ;
2394+ }
2395+
23092396 case AMDGPU::OPERAND_KIMM32:
23102397 Inst.addOperand (MCOperand::createImm (Literal.getLoBits (32 ).getZExtValue ()));
23112398 setImmKindMandatoryLiteral ();
@@ -3429,6 +3516,11 @@ bool AMDGPUAsmParser::isInlineConstant(const MCInst &Inst,
34293516 OperandType == AMDGPU::OPERAND_REG_IMM_V2FP16)
34303517 return AMDGPU::isInlinableLiteralV2F16 (Val);
34313518
3519+ if (OperandType == AMDGPU::OPERAND_REG_INLINE_C_V2BF16 ||
3520+ OperandType == AMDGPU::OPERAND_REG_INLINE_AC_V2BF16 ||
3521+ OperandType == AMDGPU::OPERAND_REG_IMM_V2BF16)
3522+ return AMDGPU::isInlinableLiteralV2BF16 (Val);
3523+
34323524 return AMDGPU::isInlinableLiteral16 (Val, hasInv2PiInlineImm ());
34333525 }
34343526 default :
0 commit comments