70 enum KindTy { Token, Immediate, Register, Expression } Kind;
72 SMLoc StartLoc, EndLoc;
73 const AMDGPUAsmParser *AsmParser;
76 AMDGPUOperand(KindTy Kind_,
const AMDGPUAsmParser *AsmParser_)
77 : Kind(Kind_), AsmParser(AsmParser_) {}
79 using Ptr = std::unique_ptr<AMDGPUOperand>;
87 bool hasFPModifiers()
const {
return Abs || Neg; }
88 bool hasIntModifiers()
const {
return Sext; }
89 bool hasModifiers()
const {
return hasFPModifiers() || hasIntModifiers(); }
90 bool isForcedLit()
const {
return Lit == LitModifier::Lit; }
91 bool isForcedLit64()
const {
return Lit == LitModifier::Lit64; }
93 int64_t getFPModifiersOperand()
const {
100 int64_t getIntModifiersOperand()
const {
106 int64_t getModifiersOperand()
const {
107 assert(!(hasFPModifiers() && hasIntModifiers()) &&
108 "fp and int modifiers should not be used simultaneously");
109 if (hasFPModifiers())
110 return getFPModifiersOperand();
111 if (hasIntModifiers())
112 return getIntModifiersOperand();
116 friend raw_ostream &
operator<<(raw_ostream &OS,
117 AMDGPUOperand::Modifiers Mods);
192 ImmTyMatrixAScaleFmt,
193 ImmTyMatrixBScaleFmt,
226 mutable int MCOpIdx = -1;
229 bool isToken()
const override {
return Kind == Token; }
231 bool isSymbolRefExpr()
const {
235 bool hasSymbolSpecifier()
const {
236 return isSymbolRefExpr() &&
241 bool isImm()
const override {
return Kind == Immediate; }
243 bool isInlinableImm(MVT type)
const;
244 bool isLiteralImm(MVT type)
const;
246 bool isRegKind()
const {
return Kind == Register; }
248 bool isReg()
const override {
return isRegKind() && !hasModifiers(); }
250 bool isRegOrInline(
unsigned RCID, MVT type)
const {
251 return isRegClass(RCID) || isInlinableImm(type);
254 bool isRegOrInlineTarget(
unsigned TargetRCIdx, MVT type)
const {
255 return isRegClassTarget(TargetRCIdx) || isInlinableImm(type);
259 return isRegOrInline(RCID, type) || isLiteralImm(type);
262 bool isRegOrImmWithInputModsTarget(
unsigned TargetRCIdx, MVT type)
const {
263 return isRegOrInlineTarget(TargetRCIdx, type) || isLiteralImm(type);
266 template <
bool IsFake16>
bool isRegOrImmWithIntT16InputMods()
const {
268 IsFake16 ? AMDGPU::VS_32RegClassID : AMDGPU::VS_16RegClassID, MVT::i16);
271 bool isRegOrImmWithInt32InputMods()
const {
275 template <
bool IsFake16>
bool isRegOrInlineImmWithIntT16InputMods()
const {
276 return isRegOrInline(
277 IsFake16 ? AMDGPU::VS_32RegClassID : AMDGPU::VS_16RegClassID, MVT::i16);
280 bool isRegOrInlineImmWithInt32InputMods()
const {
281 return isRegOrInline(AMDGPU::VS_32RegClassID, MVT::i32);
284 bool isRegOrImmWithInt64InputMods()
const {
285 return isRegOrImmWithInputModsTarget(AMDGPU::VS_64_AlignTarget, MVT::i64);
288 bool isRegOrImmWithFP16InputMods()
const {
292 template <
bool IsFake16>
bool isRegOrImmWithFPT16InputMods()
const {
294 IsFake16 ? AMDGPU::VS_32RegClassID : AMDGPU::VS_16RegClassID, MVT::f16);
297 bool isRegOrImmWithFPT16_LO16InputMods()
const {
301 bool isRegOrImmWithFP32InputMods()
const {
305 bool isRegOrImmWithFP64InputMods()
const {
306 return isRegOrImmWithInputModsTarget(AMDGPU::VS_64_AlignTarget, MVT::f64);
309 template <
bool IsFake16>
bool isRegOrInlineImmWithFP16InputMods()
const {
310 return isRegOrInline(
311 IsFake16 ? AMDGPU::VS_32RegClassID : AMDGPU::VS_16RegClassID, MVT::f16);
314 bool isRegOrInlineImmWithFP32InputMods()
const {
315 return isRegOrInline(AMDGPU::VS_32RegClassID, MVT::f32);
318 bool isRegOrInlineImmWithFP64InputMods()
const {
319 return isRegOrInlineTarget(AMDGPU::VS_64_AlignTarget, MVT::f64);
322 bool isVRegWithInputMods(
unsigned RCID)
const {
return isRegClass(RCID); }
324 bool isVRegWithFP32InputMods()
const {
325 return isVRegWithInputMods(AMDGPU::VGPR_32RegClassID);
328 bool isVRegWithFP64InputMods()
const {
329 return isRegClassTarget(AMDGPU::VReg_64_AlignTarget);
332 bool isPackedFP16InputMods()
const {
336 bool isPackedVGPRFP32InputMods()
const {
340 bool isVReg32()
const {
return isRegClass(AMDGPU::VGPR_32RegClassID); }
342 bool isVReg32OrOff()
const {
return isOff() || isVReg32(); }
344 bool isRsrcReg32()
const {
return isRegClass(AMDGPU::RsrcReg32RegClassID); }
346 bool isNull()
const {
return isRegKind() &&
getReg() == AMDGPU::SGPR_NULL; }
348 bool isAV_LdSt_32_Align2_RegOp()
const {
349 return isRegClass(AMDGPU::VGPR_32RegClassID) ||
350 isRegClass(AMDGPU::AGPR_32RegClassID);
353 bool isVRegWithInputMods()
const;
354 template <
bool IsFake16>
bool isT16_Lo128VRegWithInputMods()
const;
355 template <
bool IsFake16>
bool isT16VRegWithInputMods()
const;
356 bool isT16_LO16VRegWithInputMods()
const;
358 bool isSDWAOperand(MVT type)
const;
359 bool isSDWAFP16Operand()
const;
360 bool isSDWAFP32Operand()
const;
361 bool isSDWAInt16Operand()
const;
362 bool isSDWAInt32Operand()
const;
364 bool isImmTy(ImmTy ImmT)
const {
return isImm() &&
Imm.Type == ImmT; }
366 template <ImmTy Ty>
bool isImmTy()
const {
return isImmTy(Ty); }
368 bool isImmLiteral()
const {
return isImmTy(ImmTyNone); }
370 bool isImmModifier()
const {
return isImm() &&
Imm.Type != ImmTyNone; }
372 bool isOModSI()
const {
return isImmTy(ImmTyOModSI); }
373 bool isDim()
const {
return isImmTy(ImmTyDim); }
374 bool isR128A16()
const {
return isImmTy(ImmTyR128A16); }
375 bool isOff()
const {
return isImmTy(ImmTyOff); }
376 bool isExpTgt()
const {
return isImmTy(ImmTyExpTgt); }
377 bool isOffen()
const {
return isImmTy(ImmTyOffen); }
378 bool isIdxen()
const {
return isImmTy(ImmTyIdxen); }
379 bool isAddr64()
const {
return isImmTy(ImmTyAddr64); }
380 bool isSMEMOffsetMod()
const {
return isImmTy(ImmTySMEMOffsetMod); }
381 bool isFlatOffset()
const {
382 return isImmTy(ImmTyOffset) || isImmTy(ImmTyInstOffset);
384 bool isGDS()
const {
return isImmTy(ImmTyGDS); }
385 bool isLDS()
const {
return isImmTy(ImmTyLDS); }
386 bool isCPol()
const {
return isImmTy(ImmTyCPol); }
387 bool isIndexKey8bit()
const {
return isImmTy(ImmTyIndexKey8bit); }
388 bool isIndexKey16bit()
const {
return isImmTy(ImmTyIndexKey16bit); }
389 bool isIndexKey32bit()
const {
return isImmTy(ImmTyIndexKey32bit); }
390 bool isMatrixAFMT()
const {
return isImmTy(ImmTyMatrixAFMT); }
391 bool isMatrixBFMT()
const {
return isImmTy(ImmTyMatrixBFMT); }
392 bool isMatrixAScale()
const {
return isImmTy(ImmTyMatrixAScale); }
393 bool isMatrixBScale()
const {
return isImmTy(ImmTyMatrixBScale); }
394 bool isMatrixAScaleFmt()
const {
return isImmTy(ImmTyMatrixAScaleFmt); }
395 bool isMatrixBScaleFmt()
const {
return isImmTy(ImmTyMatrixBScaleFmt); }
396 bool isTFE()
const {
return isImmTy(ImmTyTFE); }
397 bool isFormat()
const {
return isImmTy(ImmTyFormat) &&
isUInt<7>(
getImm()); }
398 bool isFormatOp()
const {
401 bool isDppFI()
const {
return isImmTy(ImmTyDppFI); }
402 bool isSDWADstSel()
const {
return isImmTy(ImmTySDWADstSel); }
403 bool isSDWASrc0Sel()
const {
return isImmTy(ImmTySDWASrc0Sel); }
404 bool isSDWASrc1Sel()
const {
return isImmTy(ImmTySDWASrc1Sel); }
405 bool isSDWADstUnused()
const {
return isImmTy(ImmTySDWADstUnused); }
406 bool isInterpSlot()
const {
return isImmTy(ImmTyInterpSlot); }
407 bool isInterpAttr()
const {
return isImmTy(ImmTyInterpAttr); }
408 bool isInterpAttrChan()
const {
return isImmTy(ImmTyInterpAttrChan); }
409 bool isOpSel()
const {
return isImmTy(ImmTyOpSel); }
410 bool isOpSelHi()
const {
return isImmTy(ImmTyOpSelHi); }
411 bool isNegLo()
const {
return isImmTy(ImmTyNegLo); }
412 bool isNegHi()
const {
return isImmTy(ImmTyNegHi); }
413 bool isDone()
const {
return isImmTy(ImmTyDone); }
414 bool isRowEn()
const {
return isImmTy(ImmTyRowEn); }
416 bool isRegOrImm()
const {
return isReg() || isImm(); }
418 bool isRegClass(
unsigned RCID)
const;
421 bool isRegClassTarget(
unsigned TargetRCIdx)
const;
425 bool isRegOrInlineNoMods(
unsigned RCID, MVT type)
const {
426 return isRegOrInline(RCID, type) && !hasModifiers();
429 bool isRegOrInlineNoModsTarget(
unsigned TargetRCIdx, MVT type)
const {
430 return isRegOrInlineTarget(TargetRCIdx, type) && !hasModifiers();
433 bool isSCSrcB16()
const {
434 return isRegOrInlineNoMods(AMDGPU::SReg_32RegClassID, MVT::i16);
437 bool isSCSrc_b32()
const {
438 return isRegOrInlineNoMods(AMDGPU::SReg_32RegClassID, MVT::i32);
441 bool isSCSrc_b64()
const {
442 return isRegOrInlineNoMods(AMDGPU::SReg_64RegClassID, MVT::i64);
445 bool isBoolReg()
const;
447 bool isSSrc_b32()
const {
448 return isSCSrc_b32() || isLiteralImm(MVT::i32) || isExpr();
451 bool isSSrc_b16()
const {
return isSCSrcB16() || isLiteralImm(MVT::i16); }
453 bool isSSrc_b64()
const {
456 return isSCSrc_b64() || isLiteralImm(MVT::i64) ||
457 (((
const MCTargetAsmParser *)AsmParser)
458 ->getAvailableFeatures()[AMDGPU::Feature64BitLiterals] &&
462 bool isSSrc_f32()
const {
463 return isSCSrc_b32() || isLiteralImm(MVT::f32) || isExpr();
466 bool isSSrc_bf16()
const {
return isSCSrcB16() || isLiteralImm(MVT::bf16); }
468 bool isSSrc_f16()
const {
return isSCSrcB16() || isLiteralImm(MVT::f16); }
470 bool isSSrc_NoInline_f16()
const {
return isSSrc_f16(); }
472 bool isSSrcOrLds_b32()
const {
473 return isRegOrInlineNoMods(AMDGPU::SRegOrLds_32RegClassID, MVT::i32) ||
474 isLiteralImm(MVT::i32) || isExpr();
477 bool isVCSrc_b32()
const {
478 return isRegOrInlineNoMods(AMDGPU::VS_32RegClassID, MVT::i32);
481 bool isVCSrc_b32_Lo256()
const {
482 return isRegOrInlineNoMods(AMDGPU::VS_32_Lo256RegClassID, MVT::i32);
485 bool isVCSrc_b64_Lo256()
const {
486 return isRegOrInlineNoMods(AMDGPU::VS_64_Lo256RegClassID, MVT::i64);
489 bool isVCSrc_b64()
const {
490 return isRegOrInlineNoModsTarget(AMDGPU::VS_64_AlignTarget, MVT::i64);
493 bool isVCSrcT_b16()
const {
494 return isRegOrInlineNoMods(AMDGPU::VS_16RegClassID, MVT::i16);
497 bool isVCSrcTB16_Lo128()
const {
498 return isRegOrInlineNoMods(AMDGPU::VS_16_Lo128RegClassID, MVT::i16);
501 bool isVCSrcFake16B16_Lo128()
const {
502 return isRegOrInlineNoMods(AMDGPU::VS_32_Lo128RegClassID, MVT::i16);
505 bool isVCSrc_b16()
const {
506 return isRegOrInlineNoMods(AMDGPU::VS_32RegClassID, MVT::i16);
509 bool isVCSrc_v2b16()
const {
return isVCSrc_b16(); }
511 bool isVCSrc_f32()
const {
512 return isRegOrInlineNoMods(AMDGPU::VS_32RegClassID, MVT::f32);
515 bool isVCSrc_f64()
const {
516 return isRegOrInlineNoModsTarget(AMDGPU::VS_64_AlignTarget, MVT::f64);
519 bool isVCSrcTBF16()
const {
520 return isRegOrInlineNoMods(AMDGPU::VS_16RegClassID, MVT::bf16);
523 bool isVCSrcT_f16()
const {
524 return isRegOrInlineNoMods(AMDGPU::VS_16RegClassID, MVT::f16);
527 bool isVCSrcT_bf16()
const {
528 return isRegOrInlineNoMods(AMDGPU::VS_16RegClassID, MVT::f16);
531 bool isVCSrcTF16_LO16()
const {
532 return isRegOrInlineNoMods(AMDGPU::VS_16_LO16RegClassID, MVT::f16);
535 bool isVCSrcTBF16_Lo128()
const {
536 return isRegOrInlineNoMods(AMDGPU::VS_16_Lo128RegClassID, MVT::bf16);
539 bool isVCSrcTF16_Lo128()
const {
540 return isRegOrInlineNoMods(AMDGPU::VS_16_Lo128RegClassID, MVT::f16);
543 bool isVCSrcFake16BF16_Lo128()
const {
544 return isRegOrInlineNoMods(AMDGPU::VS_32_Lo128RegClassID, MVT::bf16);
547 bool isVCSrcFake16F16_Lo128()
const {
548 return isRegOrInlineNoMods(AMDGPU::VS_32_Lo128RegClassID, MVT::f16);
551 bool isVCSrc_bf16()
const {
552 return isRegOrInlineNoMods(AMDGPU::VS_32RegClassID, MVT::bf16);
555 bool isVCSrc_f16()
const {
556 return isRegOrInlineNoMods(AMDGPU::VS_32RegClassID, MVT::f16);
559 bool isVCSrc_v2bf16()
const {
return isVCSrc_bf16(); }
561 bool isVCSrc_v2f16()
const {
return isVCSrc_f16(); }
563 bool isVSrc_b32()
const {
564 return isVCSrc_f32() || isLiteralImm(MVT::i32) || isExpr();
567 bool isVSrc_b64()
const {
return isVCSrc_f64() || isLiteralImm(MVT::i64); }
569 bool isVSrc_v2b64()
const {
570 return isRegOrInlineNoModsTarget(AMDGPU::VS_128_AlignTarget, MVT::i64) ||
571 isLiteralImm(MVT::i64);
574 bool isVSrc_v2f64()
const {
575 return isRegOrInlineNoModsTarget(AMDGPU::VS_128_AlignTarget, MVT::f64) ||
576 isLiteralImm(MVT::f64);
579 bool isVSrcT_b16()
const {
return isVCSrcT_b16() || isLiteralImm(MVT::i16); }
581 bool isVSrcT_b16_Lo128()
const {
582 return isVCSrcTB16_Lo128() || isLiteralImm(MVT::i16);
585 bool isVSrcFake16_b16_Lo128()
const {
586 return isVCSrcFake16B16_Lo128() || isLiteralImm(MVT::i16);
589 bool isVSrc_b16()
const {
return isVCSrc_b16() || isLiteralImm(MVT::i16); }
591 bool isVSrc_v2b16()
const {
return isVSrc_b16() || isLiteralImm(MVT::v2i16); }
593 bool isVSrc_v2f32()
const {
return isVSrc_f64() || isLiteralImm(MVT::v2f32); }
595 bool isVCSrc_v2b32()
const {
return isVCSrc_b64(); }
597 bool isVSrc_v2b32()
const {
return isVSrc_b64() || isLiteralImm(MVT::v2i32); }
599 bool isVSrc_f32()
const {
600 return isVCSrc_f32() || isLiteralImm(MVT::f32) || isExpr();
603 bool isVSrc_f64()
const {
604 return isRegOrInlineNoModsTarget(AMDGPU::VS_64_AlignTarget, MVT::f64) ||
605 isLiteralImm(MVT::f64);
608 bool isVSrcT_bf16()
const {
609 return isVCSrcTBF16() || isLiteralImm(MVT::bf16);
612 bool isVSrcT_f16()
const {
return isVCSrcT_f16() || isLiteralImm(MVT::f16); }
614 bool isVSrcT_f16_LO16()
const {
615 return isVCSrcTF16_LO16() || isLiteralImm(MVT::f16);
618 bool isVSrcT_bf16_Lo128()
const {
619 return isVCSrcTBF16_Lo128() || isLiteralImm(MVT::bf16);
622 bool isVSrcT_f16_Lo128()
const {
623 return isVCSrcTF16_Lo128() || isLiteralImm(MVT::f16);
626 bool isVSrcFake16_bf16_Lo128()
const {
627 return isVCSrcFake16BF16_Lo128() || isLiteralImm(MVT::bf16);
630 bool isVSrcFake16_f16_Lo128()
const {
631 return isVCSrcFake16F16_Lo128() || isLiteralImm(MVT::f16);
634 bool isVSrc_bf16()
const {
return isVCSrc_bf16() || isLiteralImm(MVT::bf16); }
636 bool isVSrc_f16()
const {
return isVCSrc_f16() || isLiteralImm(MVT::f16); }
638 bool isVSrc_v2bf16()
const {
639 return isVSrc_bf16() || isLiteralImm(MVT::v2bf16);
642 bool isVSrc_v2f16()
const {
return isVSrc_f16() || isLiteralImm(MVT::v2f16); }
644 bool isVSrc_v2f16_splat()
const {
return isVSrc_v2f16(); }
646 bool isVSrc_NoInline_v2f16()
const {
return isVSrc_v2f16(); }
648 bool isVISrc_64_bf16()
const {
649 return isRegOrInlineNoModsTarget(AMDGPU::VReg_64_AlignTarget, MVT::bf16);
652 bool isVISrc_64_f16()
const {
653 return isRegOrInlineNoModsTarget(AMDGPU::VReg_64_AlignTarget, MVT::f16);
656 bool isVISrc_64_b32()
const {
657 return isRegOrInlineNoModsTarget(AMDGPU::VReg_64_AlignTarget, MVT::i32);
660 bool isVISrc_64_f64()
const {
661 return isRegOrInlineNoModsTarget(AMDGPU::VReg_64_AlignTarget, MVT::f64);
664 bool isVISrc_256_b32()
const {
665 return isRegOrInlineNoModsTarget(AMDGPU::VReg_256_AlignTarget, MVT::i32);
668 bool isVISrc_256_f32()
const {
669 return isRegOrInlineNoModsTarget(AMDGPU::VReg_256_AlignTarget, MVT::f32);
672 bool isVISrc_256_f64()
const {
673 return isRegOrInlineNoModsTarget(AMDGPU::VReg_256_AlignTarget, MVT::f64);
676 bool isVISrc_512_f64()
const {
677 return isRegOrInlineNoModsTarget(AMDGPU::VReg_512_AlignTarget, MVT::f64);
680 bool isVISrc_128_b32()
const {
681 return isRegOrInlineNoModsTarget(AMDGPU::VReg_128_AlignTarget, MVT::i32);
684 bool isVISrc_128_f32()
const {
685 return isRegOrInlineNoModsTarget(AMDGPU::VReg_128_AlignTarget, MVT::f32);
688 bool isVISrc_512_b32()
const {
689 return isRegOrInlineNoModsTarget(AMDGPU::VReg_512_AlignTarget, MVT::i32);
692 bool isVISrc_512_f32()
const {
693 return isRegOrInlineNoModsTarget(AMDGPU::VReg_512_AlignTarget, MVT::f32);
696 bool isVISrc_1024_b32()
const {
697 return isRegOrInlineNoModsTarget(AMDGPU::VReg_1024_AlignTarget, MVT::i32);
700 bool isVISrc_1024_f32()
const {
701 return isRegOrInlineNoModsTarget(AMDGPU::VReg_1024_AlignTarget, MVT::f32);
704 bool isAISrc_64_f64()
const {
705 return isRegOrInlineNoModsTarget(AMDGPU::AReg_64_AlignTarget, MVT::f64);
708 bool isAISrc_128_b32()
const {
709 return isRegOrInlineNoModsTarget(AMDGPU::AReg_128_AlignTarget, MVT::i32);
712 bool isAISrc_128_f32()
const {
713 return isRegOrInlineNoModsTarget(AMDGPU::AReg_128_AlignTarget, MVT::f32);
716 bool isVISrc_128_bf16()
const {
717 return isRegOrInlineNoModsTarget(AMDGPU::VReg_128_AlignTarget, MVT::bf16);
720 bool isVISrc_128_f16()
const {
721 return isRegOrInlineNoModsTarget(AMDGPU::VReg_128_AlignTarget, MVT::f16);
724 bool isAISrc_256_f64()
const {
725 return isRegOrInlineNoModsTarget(AMDGPU::AReg_256_AlignTarget, MVT::f64);
728 bool isAISrc_512_b32()
const {
729 return isRegOrInlineNoModsTarget(AMDGPU::AReg_512_AlignTarget, MVT::i32);
732 bool isAISrc_512_f32()
const {
733 return isRegOrInlineNoModsTarget(AMDGPU::AReg_512_AlignTarget, MVT::f32);
736 bool isAISrc_1024_b32()
const {
737 return isRegOrInlineNoModsTarget(AMDGPU::AReg_1024_AlignTarget, MVT::i32);
740 bool isAISrc_1024_f32()
const {
741 return isRegOrInlineNoModsTarget(AMDGPU::AReg_1024_AlignTarget, MVT::f32);
744 bool isKImmFP32()
const {
return isLiteralImm(MVT::f32); }
746 bool isKImmFP16()
const {
return isLiteralImm(MVT::f16); }
748 bool isKImmFP64()
const {
return isLiteralImm(MVT::f64); }
750 bool isMem()
const override {
return false; }
752 bool isExpr()
const {
return Kind == Expression; }
754 bool isSOPPBrTarget()
const {
return isExpr() || isImm(); }
756 bool isSMEMOffsetPCRel()
const {
return isExpr() || isImm(); }
758 bool isSWaitCnt()
const;
759 bool isDepCtr()
const;
760 bool isSDelayALU()
const;
761 bool isHwreg()
const;
762 bool isSendMsg()
const;
763 bool isWaitEvent()
const;
764 bool isSplitBarrier()
const;
765 bool isSwizzle()
const;
766 bool isSMRDOffset8()
const;
767 bool isSMEMOffset()
const;
768 bool isSMRDLiteralOffset()
const;
770 bool isDPPCtrl()
const;
772 bool isGPRIdxMode()
const;
773 bool isS16Imm()
const;
774 bool isU16Imm()
const;
775 bool isEndpgm()
const;
777 auto getPredicate(std::function<
bool(
const AMDGPUOperand &
Op)>
P)
const {
778 return [
this,
P]() {
return P(*
this); };
783 return StringRef(Tok.Data, Tok.Length);
791 ImmTy getImmTy()
const {
796 MCRegister
getReg()
const override {
801 SMLoc getStartLoc()
const override {
return StartLoc; }
803 SMLoc getEndLoc()
const override {
return EndLoc; }
805 int getMCOpIdx()
const {
return MCOpIdx; }
807 Modifiers getModifiers()
const {
808 assert(isRegKind() || isImmTy(ImmTyNone));
809 return isRegKind() ?
Reg.Mods :
Imm.Mods;
812 void setModifiers(Modifiers Mods) {
813 assert(isRegKind() || isImmTy(ImmTyNone));
820 bool hasModifiers()
const {
return getModifiers().hasModifiers(); }
822 bool hasFPModifiers()
const {
return getModifiers().hasFPModifiers(); }
824 bool hasIntModifiers()
const {
return getModifiers().hasIntModifiers(); }
826 bool isForcedLit()
const {
827 return isImmLiteral() && getModifiers().isForcedLit();
830 bool isForcedLit64()
const {
831 return isImmLiteral() && getModifiers().isForcedLit64();
836 void addImmOperands(MCInst &Inst,
unsigned N,
837 bool ApplyModifiers =
true)
const;
839 void addLiteralImmOperand(MCInst &Inst, int64_t Val,
840 bool ApplyModifiers)
const;
842 void addRegOperands(MCInst &Inst,
unsigned N)
const;
844 void addRegOrImmOperands(MCInst &Inst,
unsigned N)
const {
846 addRegOperands(Inst,
N);
848 addImmOperands(Inst,
N);
851 void addRegOrImmWithInputModsOperands(MCInst &Inst,
unsigned N)
const {
852 Modifiers Mods = getModifiers();
855 addRegOperands(Inst,
N);
857 addImmOperands(Inst,
N,
false);
861 void addRegOrImmWithFPInputModsOperands(MCInst &Inst,
unsigned N)
const {
862 assert(!hasIntModifiers());
863 addRegOrImmWithInputModsOperands(Inst,
N);
866 void addRegWithInputModsOperands(MCInst &Inst,
unsigned N)
const {
867 Modifiers Mods = getModifiers();
870 addRegOperands(Inst,
N);
873 void addRegWithFPInputModsOperands(MCInst &Inst,
unsigned N)
const {
874 assert(!hasIntModifiers());
875 addRegWithInputModsOperands(Inst,
N);
878 static void printImmTy(raw_ostream &OS, ImmTy
Type) {
881 case ImmTyNone: OS <<
"None";
break;
882 case ImmTyGDS: OS <<
"GDS";
break;
883 case ImmTyLDS: OS <<
"LDS";
break;
884 case ImmTyOffen: OS <<
"Offen";
break;
885 case ImmTyIdxen: OS <<
"Idxen";
break;
886 case ImmTyAddr64: OS <<
"Addr64";
break;
887 case ImmTyOffset: OS <<
"Offset";
break;
888 case ImmTyInstOffset: OS <<
"InstOffset";
break;
889 case ImmTyOffset0: OS <<
"Offset0";
break;
890 case ImmTyOffset1: OS <<
"Offset1";
break;
891 case ImmTySMEMOffsetMod: OS <<
"SMEMOffsetMod";
break;
892 case ImmTyCPol: OS <<
"CPol";
break;
893 case ImmTyIndexKey8bit: OS <<
"index_key";
break;
894 case ImmTyIndexKey16bit: OS <<
"index_key";
break;
895 case ImmTyIndexKey32bit: OS <<
"index_key";
break;
896 case ImmTyTFE: OS <<
"TFE";
break;
897 case ImmTyIsAsync: OS <<
"IsAsync";
break;
898 case ImmTyD16: OS <<
"D16";
break;
899 case ImmTyFormat: OS <<
"Format";
break;
900 case ImmTyFormatOp: OS <<
"FormatOp";
break;
901 case ImmTyClamp: OS <<
"Clamp";
break;
902 case ImmTyOModSI: OS <<
"OModSI";
break;
903 case ImmTyDPP8: OS <<
"DPP8";
break;
904 case ImmTyDppCtrl: OS <<
"DppCtrl";
break;
905 case ImmTyDppRowMask: OS <<
"DppRowMask";
break;
906 case ImmTyDppBankMask: OS <<
"DppBankMask";
break;
907 case ImmTyDppBoundCtrl: OS <<
"DppBoundCtrl";
break;
908 case ImmTyDppFI: OS <<
"DppFI";
break;
909 case ImmTySDWADstSel: OS <<
"SDWADstSel";
break;
910 case ImmTySDWASrc0Sel: OS <<
"SDWASrc0Sel";
break;
911 case ImmTySDWASrc1Sel: OS <<
"SDWASrc1Sel";
break;
912 case ImmTySDWADstUnused: OS <<
"SDWADstUnused";
break;
913 case ImmTyDMask: OS <<
"DMask";
break;
914 case ImmTyDim: OS <<
"Dim";
break;
915 case ImmTyUNorm: OS <<
"UNorm";
break;
916 case ImmTyDA: OS <<
"DA";
break;
917 case ImmTyR128A16: OS <<
"R128A16";
break;
918 case ImmTyA16: OS <<
"A16";
break;
919 case ImmTyLWE: OS <<
"LWE";
break;
920 case ImmTyOff: OS <<
"Off";
break;
921 case ImmTyExpTgt: OS <<
"ExpTgt";
break;
922 case ImmTyExpCompr: OS <<
"ExpCompr";
break;
923 case ImmTyExpVM: OS <<
"ExpVM";
break;
924 case ImmTyDone: OS <<
"Done";
break;
925 case ImmTyRowEn: OS <<
"RowEn";
break;
926 case ImmTyHwreg: OS <<
"Hwreg";
break;
927 case ImmTySendMsg: OS <<
"SendMsg";
break;
928 case ImmTyWaitEvent: OS <<
"WaitEvent";
break;
929 case ImmTyInterpSlot: OS <<
"InterpSlot";
break;
930 case ImmTyInterpAttr: OS <<
"InterpAttr";
break;
931 case ImmTyInterpAttrChan: OS <<
"InterpAttrChan";
break;
932 case ImmTyOpSel: OS <<
"OpSel";
break;
933 case ImmTyOpSelHi: OS <<
"OpSelHi";
break;
934 case ImmTyNegLo: OS <<
"NegLo";
break;
935 case ImmTyNegHi: OS <<
"NegHi";
break;
936 case ImmTySwizzle: OS <<
"Swizzle";
break;
937 case ImmTyGprIdxMode: OS <<
"GprIdxMode";
break;
938 case ImmTyHigh: OS <<
"High";
break;
939 case ImmTyBLGP: OS <<
"BLGP";
break;
940 case ImmTyCBSZ: OS <<
"CBSZ";
break;
941 case ImmTyABID: OS <<
"ABID";
break;
942 case ImmTyEndpgm: OS <<
"Endpgm";
break;
943 case ImmTyWaitVDST: OS <<
"WaitVDST";
break;
944 case ImmTyWaitEXP: OS <<
"WaitEXP";
break;
945 case ImmTyWaitVAVDst: OS <<
"WaitVAVDst";
break;
946 case ImmTyWaitVMVSrc: OS <<
"WaitVMVSrc";
break;
947 case ImmTyBitOp3: OS <<
"BitOp3";
break;
948 case ImmTyMatrixAFMT: OS <<
"ImmTyMatrixAFMT";
break;
949 case ImmTyMatrixBFMT: OS <<
"ImmTyMatrixBFMT";
break;
950 case ImmTyMatrixAScale: OS <<
"ImmTyMatrixAScale";
break;
951 case ImmTyMatrixBScale: OS <<
"ImmTyMatrixBScale";
break;
952 case ImmTyMatrixAScaleFmt: OS <<
"ImmTyMatrixAScaleFmt";
break;
953 case ImmTyMatrixBScaleFmt: OS <<
"ImmTyMatrixBScaleFmt";
break;
954 case ImmTyMatrixAReuse: OS <<
"ImmTyMatrixAReuse";
break;
955 case ImmTyMatrixBReuse: OS <<
"ImmTyMatrixBReuse";
break;
956 case ImmTyScaleSel: OS <<
"ScaleSel" ;
break;
957 case ImmTyByteSel: OS <<
"ByteSel" ;
break;
962 void print(raw_ostream &OS,
const MCAsmInfo &MAI)
const override {
966 <<
" mods: " <<
Reg.Mods <<
'>';
970 if (getImmTy() != ImmTyNone) {
972 printImmTy(OS, getImmTy());
974 OS <<
" mods: " <<
Imm.Mods <<
'>';
987 static AMDGPUOperand::Ptr CreateImm(
const AMDGPUAsmParser *AsmParser,
988 int64_t Val, SMLoc Loc,
989 ImmTy
Type = ImmTyNone,
990 bool IsFPImm =
false) {
991 auto Op = std::make_unique<AMDGPUOperand>(Immediate, AsmParser);
993 Op->Imm.IsFPImm = IsFPImm;
995 Op->Imm.Mods = Modifiers();
1001 static AMDGPUOperand::Ptr CreateToken(
const AMDGPUAsmParser *AsmParser,
1002 StringRef Str, SMLoc Loc,
1003 bool HasExplicitEncodingSize =
true) {
1004 auto Res = std::make_unique<AMDGPUOperand>(Token, AsmParser);
1005 Res->Tok.Data = Str.data();
1006 Res->Tok.Length = Str.size();
1007 Res->StartLoc = Loc;
1012 static AMDGPUOperand::Ptr CreateReg(
const AMDGPUAsmParser *AsmParser,
1013 MCRegister
Reg, SMLoc S, SMLoc
E) {
1014 auto Op = std::make_unique<AMDGPUOperand>(Register, AsmParser);
1015 Op->Reg.RegNo =
Reg;
1016 Op->Reg.Mods = Modifiers();
1022 static AMDGPUOperand::Ptr CreateExpr(
const AMDGPUAsmParser *AsmParser,
1023 const class MCExpr *Expr, SMLoc S) {
1024 auto Op = std::make_unique<AMDGPUOperand>(Expression, AsmParser);
1033 OS <<
"abs:" << Mods.Abs <<
" neg: " << Mods.Neg <<
" sext:" << Mods.Sext;
1042#define GET_REGISTER_MATCHER
1043#include "AMDGPUGenAsmMatcher.inc"
1044#undef GET_REGISTER_MATCHER
1045#undef GET_SUBTARGET_FEATURE_NAME
1050class KernelScopeInfo {
1051 int SgprIndexUnusedMin = -1;
1052 int VgprIndexUnusedMin = -1;
1053 int AgprIndexUnusedMin = -1;
1057 void usesSgprAt(
int i) {
1058 if (i >= SgprIndexUnusedMin) {
1059 SgprIndexUnusedMin = ++i;
1062 Ctx->getOrCreateSymbol(
Twine(
".kernel.sgpr_count"));
1068 void usesVgprAt(
int i) {
1069 if (i >= VgprIndexUnusedMin) {
1070 VgprIndexUnusedMin = ++i;
1073 Ctx->getOrCreateSymbol(
Twine(
".kernel.vgpr_count"));
1076 VgprIndexUnusedMin);
1082 void usesAgprAt(
int i) {
1087 if (i >= AgprIndexUnusedMin) {
1088 AgprIndexUnusedMin = ++i;
1091 Ctx->getOrCreateSymbol(
Twine(
".kernel.agpr_count"));
1096 Ctx->getOrCreateSymbol(
Twine(
".kernel.vgpr_count"));
1099 VgprIndexUnusedMin);
1106 KernelScopeInfo() =
default;
1110 MSTI = Ctx->getSubtargetInfo();
1112 usesSgprAt(SgprIndexUnusedMin = -1);
1113 usesVgprAt(VgprIndexUnusedMin = -1);
1115 usesAgprAt(AgprIndexUnusedMin = -1);
1119 void usesRegister(RegisterKind RegKind,
unsigned DwordRegIndex,
1120 unsigned RegWidth) {
1123 usesSgprAt(DwordRegIndex +
divideCeil(RegWidth, 32) - 1);
1126 usesAgprAt(DwordRegIndex +
divideCeil(RegWidth, 32) - 1);
1129 usesVgprAt(DwordRegIndex +
divideCeil(RegWidth, 32) - 1);
1138 MCAsmParser &Parser;
1140 unsigned ForcedEncodingSize = 0;
1141 bool ForcedDPP =
false;
1142 bool ForcedSDWA =
false;
1143 KernelScopeInfo KernelScope;
1144 const unsigned HwMode;
1146 const AMDGPU::IsaVersion ISA;
1151#define GET_ASSEMBLER_HEADER
1152#include "AMDGPUGenAsmMatcher.inc"
1157 unsigned getRegOperandSize(
const MCInstrDesc &
Desc,
unsigned OpNo)
const {
1159 int16_t RCID = MII.getOpRegClassID(
Desc.operands()[OpNo], HwMode);
1163 std::optional<AMDGPU::InfoSectionData> InfoData;
1172 SmallVector<unsigned> OpcodeStream;
1174 OpcodeStreamSymbols;
1175 SmallPtrSet<const MCSymbol *, 8> AMDHSAKernelSymbols;
1178 void checkKernelPrologues();
1181 void createConstantSymbol(StringRef Id, int64_t Val);
1183 bool ParseAsAbsoluteExpression(uint32_t &Ret);
1184 bool OutOfRangeError(SMRange
Range);
1200 bool calculateGPRBlocks(
const FeatureBitset &Features,
const MCExpr *VCCUsed,
1201 const MCExpr *FlatScrUsed,
bool XNACKUsed,
1202 std::optional<bool> EnableWavefrontSize32,
1203 const MCExpr *NextFreeVGPR, SMRange VGPRRange,
1204 const MCExpr *NextFreeSGPR, SMRange SGPRRange,
1205 const MCExpr *&VGPRBlocks,
const MCExpr *&SGPRBlocks);
1206 bool ParseDirectiveAMDGCNTarget();
1207 bool ParseDirectiveAMDHSACodeObjectVersion();
1208 bool ParseDirectiveAMDHSAKernel();
1209 bool ParseAMDKernelCodeTValue(StringRef ID, AMDGPUMCKernelCodeT &Header);
1210 bool ParseDirectiveAMDKernelCodeT();
1212 bool subtargetHasRegister(
const MCRegisterInfo &
MRI, MCRegister
Reg);
1213 bool ParseDirectiveAMDGPUHsaKernel();
1215 bool ParseDirectiveISAVersion();
1216 bool ParseDirectiveHSAMetadata();
1217 bool ParseDirectivePALMetadataBegin();
1218 bool ParseDirectivePALMetadata();
1219 bool ParseDirectiveAMDGPULDS();
1220 bool ParseDirectiveAMDGPUInfo();
1224 bool ParseToEndDirective(
const char *AssemblerDirectiveBegin,
1225 const char *AssemblerDirectiveEnd,
1226 std::string &CollectString);
1228 bool AddNextRegisterToList(MCRegister &
Reg,
unsigned &RegWidth,
1229 RegisterKind RegKind, MCRegister Reg1,
1230 RegisterKind RegKind1, SMLoc Loc);
1231 bool ParseAMDGPURegister(RegisterKind &RegKind, MCRegister &
Reg,
1232 unsigned &RegNum,
unsigned &RegWidth,
1233 bool RestoreOnFailure =
false);
1234 bool ParseAMDGPURegister(RegisterKind &RegKind, MCRegister &
Reg,
1235 unsigned &RegNum,
unsigned &RegWidth,
1236 SmallVectorImpl<AsmToken> &Tokens);
1237 MCRegister ParseRegularReg(RegisterKind &RegKind,
unsigned &RegNum,
1239 SmallVectorImpl<AsmToken> &Tokens);
1240 MCRegister ParseSpecialReg(RegisterKind &RegKind,
unsigned &RegNum,
1242 SmallVectorImpl<AsmToken> &Tokens);
1243 MCRegister ParseRegList(RegisterKind &RegKind,
unsigned &RegNum,
1245 SmallVectorImpl<AsmToken> &Tokens);
1246 bool ParseRegRange(
unsigned &Num,
unsigned &Width,
unsigned &SubReg);
1247 MCRegister getRegularReg(RegisterKind RegKind,
unsigned RegNum,
1248 unsigned SubReg,
unsigned RegWidth, SMLoc Loc);
1251 bool isRegister(
const AsmToken &Token,
const AsmToken &NextToken)
const;
1252 std::optional<StringRef> getGprCountSymbolName(RegisterKind RegKind);
1253 void initializeGprCountSymbol(RegisterKind RegKind);
1254 bool updateGprCountSymbols(RegisterKind RegKind,
unsigned DwordRegIndex,
1260 OperandMode_Default,
1264 using OptionalImmIndexMap = std::map<AMDGPUOperand::ImmTy, unsigned>;
1266 AMDGPUAsmParser(
const MCSubtargetInfo &STI, MCAsmParser &_Parser,
1267 const MCInstrInfo &MII)
1268 : MCTargetAsmParser(STI, MII), Parser(_Parser),
1269 HwMode(STI.getHwMode(MCSubtargetInfo::HwMode_RegInfo)),
1274 setAvailableFeatures(ComputeAvailableFeatures(getFeatureBits()));
1276 if (ISA.Major >= 6 &&
isHsaAbi(getSTI())) {
1277 createConstantSymbol(
".amdgcn.gfx_generation_number", ISA.Major);
1278 createConstantSymbol(
".amdgcn.gfx_generation_minor", ISA.Minor);
1279 createConstantSymbol(
".amdgcn.gfx_generation_stepping", ISA.Stepping);
1281 createConstantSymbol(
".option.machine_version_major", ISA.Major);
1282 createConstantSymbol(
".option.machine_version_minor", ISA.Minor);
1283 createConstantSymbol(
".option.machine_version_stepping", ISA.Stepping);
1285 if (ISA.Major >= 6 &&
isHsaAbi(getSTI())) {
1286 initializeGprCountSymbol(IS_VGPR);
1287 initializeGprCountSymbol(IS_SGPR);
1292 createConstantSymbol(Symbol, Code);
1294 createConstantSymbol(
"UC_VERSION_W64_BIT", 0x2000);
1295 createConstantSymbol(
"UC_VERSION_W32_BIT", 0x4000);
1296 createConstantSymbol(
"UC_VERSION_MDP_BIT", 0x8000);
1336 bool hasBVHRayTracingInsts()
const {
1337 return getFeatureBits()[AMDGPU::FeatureBVHRayTracingInsts];
1340 bool isWave32()
const {
return getAvailableFeatures()[Feature_isWave32Bit]; }
1342 bool isWave64()
const {
return getAvailableFeatures()[Feature_isWave64Bit]; }
1344 bool hasInv2PiInlineImm()
const {
1345 return getFeatureBits()[AMDGPU::FeatureInv2PiInlineImm];
1348 bool has64BitLiterals()
const {
1349 return getFeatureBits()[AMDGPU::Feature64BitLiterals];
1352 bool hasFlatOffsets()
const {
1353 return getFeatureBits()[AMDGPU::FeatureFlatInstOffsets];
1356 bool hasTrue16Insts()
const {
1357 return getFeatureBits()[AMDGPU::FeatureTrue16BitInsts];
1361 return getFeatureBits()[AMDGPU::FeatureArchitectedFlatScratch];
1364 bool hasSGPR102_SGPR103()
const {
return !
isVI() && !
isGFX9(); }
1366 bool hasSGPR104_SGPR105()
const {
return isGFX10Plus(); }
1368 bool hasIntClamp()
const {
return getFeatureBits()[AMDGPU::FeatureIntClamp]; }
1370 bool hasPartialNSAEncoding()
const {
1371 return getFeatureBits()[AMDGPU::FeaturePartialNSAEncoding];
1374 bool hasGloballyAddressableScratch()
const {
1375 return getFeatureBits()[AMDGPU::FeatureGloballyAddressableScratch];
1378 bool hasScaleOffset()
const {
1379 return getFeatureBits()[AMDGPU::FeatureScaleOffset];
1382 bool hasCacheFillSize()
const {
1383 return getFeatureBits()[AMDGPU::FeatureCacheFillSize];
1396 AMDGPUTargetStreamer &getTargetStreamer() {
1397 MCTargetStreamer &TS = *getParser().getStreamer().getTargetStreamer();
1398 return static_cast<AMDGPUTargetStreamer &
>(TS);
1404 return const_cast<AMDGPUAsmParser *
>(
this)->MCTargetAsmParser::getContext();
1407 const MCRegisterInfo *getMRI()
const {
1411 const MCInstrInfo *getMII()
const {
return &MII; }
1415 int16_t getTargetRegClass(
unsigned TargetRCIdx)
const {
1421 const FeatureBitset &getFeatureBits()
const {
1422 return getSTI().getFeatureBits();
1425 void setForcedEncodingSize(
unsigned Size) { ForcedEncodingSize =
Size; }
1426 void setForcedDPP(
bool ForceDPP_) { ForcedDPP = ForceDPP_; }
1427 void setForcedSDWA(
bool ForceSDWA_) { ForcedSDWA = ForceSDWA_; }
1429 unsigned getForcedEncodingSize()
const {
return ForcedEncodingSize; }
1430 bool isForcedVOP3()
const {
return ForcedEncodingSize == 64; }
1431 bool isForcedDPP()
const {
return ForcedDPP; }
1432 bool isForcedSDWA()
const {
return ForcedSDWA; }
1433 ArrayRef<unsigned> getMatchedVariants()
const;
1434 StringRef getMatchedVariantName()
const;
1436 std::unique_ptr<AMDGPUOperand> parseRegister(
bool RestoreOnFailure =
false);
1437 bool ParseRegister(MCRegister &RegNo, SMLoc &StartLoc, SMLoc &EndLoc,
1438 bool RestoreOnFailure);
1439 bool parseRegister(MCRegister &
Reg, SMLoc &StartLoc, SMLoc &EndLoc)
override;
1440 ParseStatus tryParseRegister(MCRegister &
Reg, SMLoc &StartLoc,
1441 SMLoc &EndLoc)
override;
1442 unsigned checkTargetMatchPredicate(MCInst &Inst)
override;
1443 unsigned validateTargetOperandClass(MCParsedAsmOperand &
Op,
1444 unsigned Kind)
override;
1445 bool matchAndEmitInstruction(SMLoc IDLoc,
unsigned &Opcode,
1448 bool MatchingInlineAsm)
override;
1449 bool ParseDirective(AsmToken DirectiveID)
override;
1450 void doBeforeLabelEmit(MCSymbol *Symbol, SMLoc IDLoc)
override;
1451 void onEndOfFile()
override;
1453 OperandMode
Mode = OperandMode_Default);
1454 StringRef parseMnemonicSuffix(StringRef Name);
1455 bool parseInstruction(ParseInstructionInfo &Info, StringRef Name,
1461 ParseStatus parseIntWithPrefix(
const char *Prefix, int64_t &
Int);
1465 AMDGPUOperand::ImmTy ImmTy = AMDGPUOperand::ImmTyNone,
1466 std::function<
bool(int64_t &)> ConvertResult =
nullptr);
1468 ParseStatus parseOperandArrayWithPrefix(
1470 AMDGPUOperand::ImmTy ImmTy = AMDGPUOperand::ImmTyNone,
1471 bool (*ConvertResult)(int64_t &) =
nullptr);
1475 AMDGPUOperand::ImmTy ImmTy = AMDGPUOperand::ImmTyNone,
1476 bool IgnoreNegative =
false);
1477 unsigned getCPolKind(StringRef Id, StringRef Mnemo,
bool &Disabling)
const;
1482 ParseStatus parseStringWithPrefix(StringRef Prefix, StringRef &
Value,
1486 ArrayRef<const char *> Ids,
1490 ArrayRef<const char *> Ids,
1491 AMDGPUOperand::ImmTy
Type);
1494 bool isOperandModifier(
const AsmToken &Token,
1495 const AsmToken &NextToken)
const;
1496 bool isRegOrOperandModifier(
const AsmToken &Token,
1497 const AsmToken &NextToken)
const;
1498 bool isNamedOperandModifier(
const AsmToken &Token,
1499 const AsmToken &NextToken)
const;
1500 bool isOpcodeModifierWithVal(
const AsmToken &Token,
1501 const AsmToken &NextToken)
const;
1502 bool parseSP3NegModifier();
1509 bool AllowImm =
true);
1511 bool AllowImm =
true);
1517 AMDGPUOperand::ImmTy ImmTy);
1522 AMDGPUOperand::ImmTy
Type);
1526 AMDGPUOperand::ImmTy
Type);
1530 AMDGPUOperand::ImmTy
Type);
1534 ParseStatus parseDfmtNfmt(int64_t &
Format);
1535 ParseStatus parseUfmt(int64_t &
Format);
1536 ParseStatus parseSymbolicSplitFormat(StringRef FormatStr, SMLoc Loc,
1538 ParseStatus parseSymbolicUnifiedFormat(StringRef FormatStr, SMLoc Loc,
1542 ParseStatus parseSymbolicOrNumericFormat(int64_t &
Format);
1543 ParseStatus parseNumericFormat(int64_t &
Format);
1547 ParseStatus tryParseFmt(
const char *Pref, int64_t MaxVal, int64_t &Fmt);
1548 bool matchDfmtNfmt(int64_t &Dfmt, int64_t &Nfmt, StringRef FormatStr,
1553 bool parseCnt(int64_t &IntVal);
1556 bool parseDepCtr(int64_t &IntVal,
unsigned &Mask);
1557 void depCtrError(SMLoc Loc,
int ErrorId, StringRef DepCtrName);
1560 bool parseDelay(int64_t &Delay);
1566 struct OperandInfoTy {
1569 bool IsSymbolic =
false;
1570 bool IsDefined =
false;
1572 constexpr OperandInfoTy(int64_t Val) : Val(Val) {}
1575 struct StructuredOpField : OperandInfoTy {
1579 bool IsDefined =
false;
1581 constexpr StructuredOpField(StringLiteral Id, StringLiteral Desc,
1582 unsigned Width, int64_t
Default)
1583 : OperandInfoTy(
Default), Id(Id), Desc(Desc), Width(Width) {}
1584 virtual ~StructuredOpField() =
default;
1586 bool Error(AMDGPUAsmParser &Parser,
const Twine &Err)
const {
1587 Parser.Error(Loc,
"invalid " + Desc +
": " + Err);
1591 virtual bool validate(AMDGPUAsmParser &Parser)
const {
1593 return Error(Parser,
"not supported on this GPU");
1595 return Error(Parser,
"only " + Twine(Width) +
"-bit values are legal");
1603 bool parseSendMsgBody(OperandInfoTy &
Msg, OperandInfoTy &
Op,
1604 OperandInfoTy &Stream);
1605 bool validateSendMsg(
const OperandInfoTy &
Msg,
const OperandInfoTy &
Op,
1606 const OperandInfoTy &Stream);
1608 ParseStatus parseHwregFunc(OperandInfoTy &HwReg, OperandInfoTy &
Offset,
1609 OperandInfoTy &Width);
1614 static SMLoc getLaterLoc(SMLoc a, SMLoc b);
1621 SMLoc getOperandLoc(std::function<
bool(
const AMDGPUOperand &)>
Test,
1623 SMLoc getImmLoc(AMDGPUOperand::ImmTy
Type,
1627 bool validateInstruction(
const MCInst &Inst, SMLoc IDLoc,
1633 bool validateBF16InlineConst(
const MCInst &Inst,
1636 bool validateConstantBusLimitations(
const MCInst &Inst,
1638 std::optional<unsigned> checkVOPDRegBankConstraints(
const MCInst &Inst,
1641 bool tryVOPD(
const MCInst &Inst);
1642 bool tryVOPD3(
const MCInst &Inst);
1643 bool tryAnotherVOPDEncoding(
const MCInst &Inst);
1645 bool validateIntClampSupported(
const MCInst &Inst);
1646 bool validateMIMGAtomicDMask(
const MCInst &Inst);
1647 bool validateMIMGGatherDMask(
const MCInst &Inst);
1649 bool validateMIMGDataSize(
const MCInst &Inst, SMLoc IDLoc);
1650 bool validateMIMGAddrSize(
const MCInst &Inst, SMLoc IDLoc);
1651 bool validateMIMGD16(
const MCInst &Inst);
1653 bool validateTensorR128(
const MCInst &Inst);
1654 bool validateMIMGMSAA(
const MCInst &Inst);
1655 bool validateOpSel(
const MCInst &Inst);
1656 bool validateTrue16OpSel(
const MCInst &Inst);
1657 bool validateNeg(
const MCInst &Inst, AMDGPU::OpName OpName);
1659 bool validateVccOperand(MCRegister
Reg)
const;
1664 bool validateAGPRLdSt(
const MCInst &Inst)
const;
1665 bool validateVGPRAlign(
const MCInst &Inst)
const;
1669 bool validateDivScale(
const MCInst &Inst);
1674 const unsigned CPol);
1680 bool validateClusterBarrierIsFirst(
const MCInst &Inst,
1683 unsigned getConstantBusLimit(
unsigned Opcode)
const;
1684 bool usesConstantBus(
const MCInst &Inst,
unsigned OpIdx);
1685 bool isInlineConstant(
const MCInst &Inst,
unsigned OpIdx)
const;
1686 MCRegister findImplicitSGPRReadInVOP(
const MCInst &Inst)
const;
1688 bool isSupportedMnemo(StringRef Mnemo,
const FeatureBitset &FBS);
1689 bool isSupportedMnemo(StringRef Mnemo,
const FeatureBitset &FBS,
1690 ArrayRef<unsigned> Variants);
1691 bool checkUnsupportedInstruction(StringRef Name, SMLoc IDLoc);
1693 bool isId(
const StringRef Id)
const;
1694 bool isId(
const AsmToken &Token,
const StringRef Id)
const;
1696 StringRef getId()
const;
1697 bool trySkipId(
const StringRef Id);
1698 bool trySkipId(
const StringRef Pref,
const StringRef Id);
1702 bool parseString(StringRef &Val,
1703 const StringRef ErrMsg =
"expected a string");
1704 bool parseId(StringRef &Val,
const StringRef ErrMsg =
"");
1710 StringRef getTokenStr()
const;
1711 AsmToken peekToken(
bool ShouldSkipSpace =
true);
1713 SMLoc getLoc()
const;
1717 void onBeginOfFile()
override;
1722 void emitTargetDirective();
1723 bool parsePrimaryExpr(
const MCExpr *&Res, SMLoc &EndLoc)
override;
1736 bool parseSwizzleOperand(int64_t &
Op,
const unsigned MinVal,
1737 const unsigned MaxVal,
const Twine &ErrMsg,
1739 bool parseSwizzleOperands(
const unsigned OpNum, int64_t *
Op,
1740 const unsigned MinVal,
const unsigned MaxVal,
1741 const StringRef ErrMsg);
1743 bool parseSwizzleOffset(int64_t &
Imm);
1744 bool parseSwizzleMacro(int64_t &
Imm);
1745 bool parseSwizzleQuadPerm(int64_t &
Imm);
1746 bool parseSwizzleBitmaskPerm(int64_t &
Imm);
1747 bool parseSwizzleBroadcast(int64_t &
Imm);
1748 bool parseSwizzleSwap(int64_t &
Imm);
1749 bool parseSwizzleReverse(int64_t &
Imm);
1750 bool parseSwizzleFFT(int64_t &
Imm);
1751 bool parseSwizzleRotate(int64_t &
Imm);
1754 int64_t parseGPRIdxMacro();
1757 cvtMubufImpl(Inst,
Operands,
false);
1760 cvtMubufImpl(Inst,
Operands,
true);
1766 OptionalImmIndexMap &OptionalIdx);
1775 OptionalImmIndexMap &OptionalIdx);
1777 OptionalImmIndexMap &OptionalIdx);
1781 void cvtOpSelHelper(MCInst &Inst,
unsigned OpSel);
1783 bool parseDimId(
unsigned &Encoding);
1785 bool convertDppBoundCtrl(int64_t &BoundCtrl);
1789 int64_t parseDPPCtrlSel(StringRef Ctrl);
1790 int64_t parseDPPCtrlPerm();
1796 bool IsDPP8 =
false);
1802 AMDGPUOperand::ImmTy
Type);
1810 enum class SDWAInstType :
unsigned {
VOP1 = 0,
VOP2 = 1,
VOPC = 2 };
1813 SDWAInstType BasicInstType,
bool SkipDstVcc =
false,
1814 bool SkipSrcVcc =
false);
1924bool AMDGPUOperand::isInlinableImm(
MVT type)
const {
1934 if (!isImmTy(ImmTyNone)) {
1939 if (getModifiers().
Lit != LitModifier::None)
1949 if (type == MVT::f64 || type == MVT::i64) {
1951 AsmParser->hasInv2PiInlineImm());
1954 APFloat FPLiteral(APFloat::IEEEdouble(), APInt(64,
Imm.Val));
1973 APFloat::rmNearestTiesToEven, &Lost);
1980 uint32_t ImmVal = FPLiteral.bitcastToAPInt().getZExtValue();
1982 AsmParser->hasInv2PiInlineImm());
1987 static_cast<int32_t
>(FPLiteral.bitcastToAPInt().getZExtValue()),
1988 AsmParser->hasInv2PiInlineImm());
1992 if (type == MVT::f64 || type == MVT::i64) {
1994 AsmParser->hasInv2PiInlineImm());
2003 static_cast<int16_t
>(
Literal.getLoBits(16).getSExtValue()), type,
2004 AsmParser->hasInv2PiInlineImm());
2008 static_cast<int32_t
>(
Literal.getLoBits(32).getZExtValue()),
2009 AsmParser->hasInv2PiInlineImm());
2012bool AMDGPUOperand::isLiteralImm(MVT type)
const {
2014 if (!isImmTy(ImmTyNone)) {
2019 (type == MVT::i64 || type == MVT::f64) && AsmParser->has64BitLiterals();
2024 if (type == MVT::f64 && hasFPModifiers()) {
2044 if (type == MVT::f64) {
2049 if (type == MVT::i64) {
2062 MVT ExpectedType = (type == MVT::v2f16) ? MVT::f16
2063 : (type == MVT::v2i16) ? MVT::f32
2064 : (type == MVT::v2f32) ? MVT::f32
2067 APFloat FPLiteral(APFloat::IEEEdouble(), APInt(64,
Imm.Val));
2071bool AMDGPUOperand::isRegClassTarget(
unsigned TargetRCIdx)
const {
2074 int16_t RCID = AsmParser->getTargetRegClass(TargetRCIdx);
2075 return RCID >= 0 && isRegClass(RCID);
2078bool AMDGPUOperand::isRegClass(
unsigned RCID)
const {
2079 return isRegKind() &&
2080 AsmParser->getMRI()->getRegClass(RCID).contains(
getReg());
2083bool AMDGPUOperand::isVRegWithInputMods()
const {
2084 return isRegClass(AMDGPU::VGPR_32RegClassID) ||
2086 (AsmParser->getFeatureBits()[AMDGPU::FeatureDPALU_DPP] &&
2087 isRegClassTarget(AMDGPU::VReg_64_AlignTarget));
2090template <
bool IsFake16>
2091bool AMDGPUOperand::isT16_Lo128VRegWithInputMods()
const {
2092 return isRegClass(IsFake16 ? AMDGPU::VGPR_32_Lo128RegClassID
2093 : AMDGPU::VGPR_16_Lo128RegClassID);
2096template <
bool IsFake16>
bool AMDGPUOperand::isT16VRegWithInputMods()
const {
2097 return isRegClass(IsFake16 ? AMDGPU::VGPR_32RegClassID
2098 : AMDGPU::VGPR_16RegClassID);
2101bool AMDGPUOperand::isT16_LO16VRegWithInputMods()
const {
2102 return isRegClass(AMDGPU::VGPR_16_LO16RegClassID);
2105bool AMDGPUOperand::isSDWAOperand(MVT type)
const {
2106 if (AsmParser->isVI())
2108 if (AsmParser->isGFX9Plus())
2109 return isRegClass(AMDGPU::VS_32RegClassID) || isInlinableImm(type);
2113bool AMDGPUOperand::isSDWAFP16Operand()
const {
2114 return isSDWAOperand(MVT::f16);
2117bool AMDGPUOperand::isSDWAFP32Operand()
const {
2118 return isSDWAOperand(MVT::f32);
2121bool AMDGPUOperand::isSDWAInt16Operand()
const {
2122 return isSDWAOperand(MVT::i16);
2125bool AMDGPUOperand::isSDWAInt32Operand()
const {
2126 return isSDWAOperand(MVT::i32);
2129bool AMDGPUOperand::isBoolReg()
const {
2130 return isReg() && ((AsmParser->isWave64() && isSCSrc_b64()) ||
2131 (AsmParser->isWave32() && isSCSrc_b32()));
2135 unsigned Size)
const {
2136 assert(isImmTy(ImmTyNone) &&
Imm.Mods.hasFPModifiers());
2151void AMDGPUOperand::addImmOperands(MCInst &Inst,
unsigned N,
2152 bool ApplyModifiers)
const {
2162 addLiteralImmOperand(Inst,
Imm.Val,
2163 ApplyModifiers & isImmTy(ImmTyNone) &&
2164 Imm.Mods.hasFPModifiers());
2166 assert(!isImmTy(ImmTyNone) || !hasModifiers());
2171void AMDGPUOperand::addLiteralImmOperand(MCInst &Inst, int64_t Val,
2172 bool ApplyModifiers)
const {
2173 const auto &InstDesc = AsmParser->getMII()->get(Inst.
getOpcode());
2178 if (ApplyModifiers) {
2180 const unsigned Size =
2182 Val = applyInputFPModifiers(Val,
Size);
2186 uint8_t OpTy = InstDesc.operands()[OpNum].OperandType;
2188 bool CanUse64BitLiterals =
2191 MCContext &Ctx = AsmParser->getContext();
2202 if (
Lit == LitModifier::None &&
2204 AsmParser->hasInv2PiInlineImm())) {
2212 bool HasMandatoryLiteral =
2215 if (
Literal.getLoBits(32) != 0 &&
2216 (InstDesc.getSize() != 4 || !AsmParser->has64BitLiterals()) &&
2217 !HasMandatoryLiteral) {
2218 const_cast<AMDGPUAsmParser *
>(AsmParser)->
Warning(
2220 "Can't encode literal as exact 64-bit floating-point operand. "
2221 "Low 32-bits will be set to zero");
2222 Val &= 0xffffffff00000000u;
2228 if (CanUse64BitLiterals &&
Lit == LitModifier::None &&
2234 Lit = LitModifier::Lit64;
2235 }
else if (
Lit == LitModifier::Lit) {
2249 if (CanUse64BitLiterals &&
Lit == LitModifier::None &&
2251 Lit = LitModifier::Lit64;
2258 if (
Lit == LitModifier::None && AsmParser->hasInv2PiInlineImm() &&
2259 Literal == 0x3fc45f306725feed) {
2299 Val = FPLiteral.bitcastToAPInt().getZExtValue();
2306 if (
Lit != LitModifier::None) {
2337 if (
Lit == LitModifier::None &&
2347 if (!AsmParser->has64BitLiterals() ||
Lit == LitModifier::Lit)
2355 if (
Lit == LitModifier::None &&
2363 if (!AsmParser->has64BitLiterals()) {
2364 Val =
static_cast<uint64_t>(Val) << 32;
2371 if (
Lit == LitModifier::Lit ||
2373 Val =
static_cast<uint64_t>(Val) << 32;
2377 if (
Lit == LitModifier::Lit)
2404 if (
Lit != LitModifier::None) {
2412void AMDGPUOperand::addRegOperands(MCInst &Inst,
unsigned N)
const {
2418bool AMDGPUOperand::isInlineValue()
const {
2426void AMDGPUAsmParser::createConstantSymbol(StringRef Id, int64_t Val) {
2437 if (Is == IS_VGPR) {
2442 return AMDGPU::VGPR_32RegClassID;
2444 return AMDGPU::VReg_64RegClassID;
2446 return AMDGPU::VReg_96RegClassID;
2448 return AMDGPU::VReg_128RegClassID;
2450 return AMDGPU::VReg_160RegClassID;
2452 return AMDGPU::VReg_192RegClassID;
2454 return AMDGPU::VReg_224RegClassID;
2456 return AMDGPU::VReg_256RegClassID;
2458 return AMDGPU::VReg_288RegClassID;
2460 return AMDGPU::VReg_320RegClassID;
2462 return AMDGPU::VReg_352RegClassID;
2464 return AMDGPU::VReg_384RegClassID;
2466 return AMDGPU::VReg_512RegClassID;
2468 return AMDGPU::VReg_1024RegClassID;
2470 }
else if (Is == IS_TTMP) {
2475 return AMDGPU::TTMP_32RegClassID;
2477 return AMDGPU::TTMP_64RegClassID;
2479 return AMDGPU::TTMP_128RegClassID;
2481 return AMDGPU::TTMP_256RegClassID;
2483 return AMDGPU::TTMP_512RegClassID;
2485 }
else if (Is == IS_SGPR) {
2490 return AMDGPU::SGPR_32RegClassID;
2492 return AMDGPU::SGPR_64RegClassID;
2494 return AMDGPU::SGPR_96RegClassID;
2496 return AMDGPU::SGPR_128RegClassID;
2498 return AMDGPU::SGPR_160RegClassID;
2500 return AMDGPU::SGPR_192RegClassID;
2502 return AMDGPU::SGPR_224RegClassID;
2504 return AMDGPU::SGPR_256RegClassID;
2506 return AMDGPU::SGPR_288RegClassID;
2508 return AMDGPU::SGPR_320RegClassID;
2510 return AMDGPU::SGPR_352RegClassID;
2512 return AMDGPU::SGPR_384RegClassID;
2514 return AMDGPU::SGPR_512RegClassID;
2516 }
else if (Is == IS_AGPR) {
2521 return AMDGPU::AGPR_32RegClassID;
2523 return AMDGPU::AReg_64RegClassID;
2525 return AMDGPU::AReg_96RegClassID;
2527 return AMDGPU::AReg_128RegClassID;
2529 return AMDGPU::AReg_160RegClassID;
2531 return AMDGPU::AReg_192RegClassID;
2533 return AMDGPU::AReg_224RegClassID;
2535 return AMDGPU::AReg_256RegClassID;
2537 return AMDGPU::AReg_288RegClassID;
2539 return AMDGPU::AReg_320RegClassID;
2541 return AMDGPU::AReg_352RegClassID;
2543 return AMDGPU::AReg_384RegClassID;
2545 return AMDGPU::AReg_512RegClassID;
2547 return AMDGPU::AReg_1024RegClassID;
2555 .
Case(
"exec", AMDGPU::EXEC)
2556 .
Case(
"vcc", AMDGPU::VCC)
2557 .
Case(
"flat_scratch", AMDGPU::FLAT_SCR)
2558 .
Case(
"xnack_mask", AMDGPU::XNACK_MASK)
2559 .
Case(
"shared_base", AMDGPU::SRC_SHARED_BASE)
2560 .
Case(
"src_shared_base", AMDGPU::SRC_SHARED_BASE)
2561 .
Case(
"shared_limit", AMDGPU::SRC_SHARED_LIMIT)
2562 .
Case(
"src_shared_limit", AMDGPU::SRC_SHARED_LIMIT)
2563 .
Case(
"private_base", AMDGPU::SRC_PRIVATE_BASE)
2564 .
Case(
"src_private_base", AMDGPU::SRC_PRIVATE_BASE)
2565 .
Case(
"private_limit", AMDGPU::SRC_PRIVATE_LIMIT)
2566 .
Case(
"src_private_limit", AMDGPU::SRC_PRIVATE_LIMIT)
2567 .
Case(
"src_flat_scratch_base_lo", AMDGPU::SRC_FLAT_SCRATCH_BASE_LO)
2568 .
Case(
"src_flat_scratch_base_hi", AMDGPU::SRC_FLAT_SCRATCH_BASE_HI)
2569 .
Case(
"pops_exiting_wave_id", AMDGPU::SRC_POPS_EXITING_WAVE_ID)
2570 .
Case(
"src_pops_exiting_wave_id", AMDGPU::SRC_POPS_EXITING_WAVE_ID)
2571 .
Case(
"lds_direct", AMDGPU::LDS_DIRECT)
2572 .
Case(
"src_lds_direct", AMDGPU::LDS_DIRECT)
2573 .
Case(
"m0", AMDGPU::M0)
2574 .
Case(
"vccz", AMDGPU::SRC_VCCZ)
2575 .
Case(
"src_vccz", AMDGPU::SRC_VCCZ)
2576 .
Case(
"execz", AMDGPU::SRC_EXECZ)
2577 .
Case(
"src_execz", AMDGPU::SRC_EXECZ)
2578 .
Case(
"scc", AMDGPU::SRC_SCC)
2579 .
Case(
"src_scc", AMDGPU::SRC_SCC)
2580 .
Case(
"tba", AMDGPU::TBA)
2581 .
Case(
"tma", AMDGPU::TMA)
2582 .
Case(
"flat_scratch_lo", AMDGPU::FLAT_SCR_LO)
2583 .
Case(
"flat_scratch_hi", AMDGPU::FLAT_SCR_HI)
2584 .
Case(
"xnack_mask_lo", AMDGPU::XNACK_MASK_LO)
2585 .
Case(
"xnack_mask_hi", AMDGPU::XNACK_MASK_HI)
2586 .
Case(
"vcc_lo", AMDGPU::VCC_LO)
2587 .
Case(
"vcc_hi", AMDGPU::VCC_HI)
2588 .
Case(
"exec_lo", AMDGPU::EXEC_LO)
2589 .
Case(
"exec_hi", AMDGPU::EXEC_HI)
2590 .
Case(
"tma_lo", AMDGPU::TMA_LO)
2591 .
Case(
"tma_hi", AMDGPU::TMA_HI)
2592 .
Case(
"tba_lo", AMDGPU::TBA_LO)
2593 .
Case(
"tba_hi", AMDGPU::TBA_HI)
2594 .
Case(
"pc", AMDGPU::PC_REG)
2595 .
Case(
"null", AMDGPU::SGPR_NULL)
2599bool AMDGPUAsmParser::ParseRegister(MCRegister &RegNo, SMLoc &StartLoc,
2600 SMLoc &EndLoc,
bool RestoreOnFailure) {
2601 auto R = parseRegister();
2605 RegNo =
R->getReg();
2606 StartLoc =
R->getStartLoc();
2607 EndLoc =
R->getEndLoc();
2611bool AMDGPUAsmParser::parseRegister(MCRegister &
Reg, SMLoc &StartLoc,
2613 return ParseRegister(
Reg, StartLoc, EndLoc,
false);
2616ParseStatus AMDGPUAsmParser::tryParseRegister(MCRegister &
Reg, SMLoc &StartLoc,
2618 bool Result = ParseRegister(
Reg, StartLoc, EndLoc,
true);
2619 bool PendingErrors = getParser().hasPendingError();
2620 getParser().clearPendingErrors();
2628bool AMDGPUAsmParser::AddNextRegisterToList(MCRegister &
Reg,
unsigned &RegWidth,
2629 RegisterKind RegKind,
2631 RegisterKind RegKind1, SMLoc Loc) {
2633 if (RegKind == IS_SGPR) {
2634 unsigned RegIdx = (
Reg - AMDGPU::SGPR0) + RegWidth / 32;
2635 if ((RegIdx == 106 && Reg1 == AMDGPU::VCC_LO) ||
2636 (RegIdx == 107 && Reg1 == AMDGPU::VCC_HI)) {
2642 if (RegKind != RegKind1) {
2643 Error(Loc,
"registers in a list must be of the same kind");
2649 if (
Reg == AMDGPU::EXEC_LO && Reg1 == AMDGPU::EXEC_HI) {
2654 if (
Reg == AMDGPU::FLAT_SCR_LO && Reg1 == AMDGPU::FLAT_SCR_HI) {
2655 Reg = AMDGPU::FLAT_SCR;
2659 if (
Reg == AMDGPU::XNACK_MASK_LO && Reg1 == AMDGPU::XNACK_MASK_HI) {
2660 Reg = AMDGPU::XNACK_MASK;
2664 if (
Reg == AMDGPU::VCC_LO && Reg1 == AMDGPU::VCC_HI) {
2669 if (
Reg == AMDGPU::TBA_LO && Reg1 == AMDGPU::TBA_HI) {
2674 if (
Reg == AMDGPU::TMA_LO && Reg1 == AMDGPU::TMA_HI) {
2679 Error(Loc,
"register does not fit in the list");
2685 if (Reg1 !=
Reg + RegWidth / 32) {
2686 Error(Loc,
"registers in a list must have consecutive indices");
2702 {{
"v"}, IS_VGPR}, {{
"s"}, IS_SGPR}, {{
"ttmp"}, IS_TTMP},
2703 {{
"acc"}, IS_AGPR}, {{
"a"}, IS_AGPR},
2707 return Kind == IS_VGPR || Kind == IS_SGPR || Kind == IS_TTMP ||
2713 if (Str.starts_with(
Reg.Name))
2719 return !Str.getAsInteger(10, Num);
2722bool AMDGPUAsmParser::isRegister(
const AsmToken &Token,
2723 const AsmToken &NextToken)
const {
2738 StringRef RegSuffix = Str.substr(
RegName.size());
2739 if (!RegSuffix.
empty()) {
2756bool AMDGPUAsmParser::isRegister() {
2757 return isRegister(
getToken(), peekToken());
2760MCRegister AMDGPUAsmParser::getRegularReg(RegisterKind RegKind,
unsigned RegNum,
2761 unsigned SubReg,
unsigned RegWidth,
2765 unsigned AlignSize = 1;
2766 if (RegKind == IS_SGPR || RegKind == IS_TTMP) {
2772 if (RegNum % AlignSize != 0) {
2773 Error(Loc,
"invalid register alignment");
2774 return MCRegister();
2777 unsigned RegIdx = RegNum / AlignSize;
2780 Error(Loc,
"invalid or unsupported register size");
2781 return MCRegister();
2785 const MCRegisterClass &RC =
TRI->getRegClass(RCID);
2786 if (RegIdx >= RC.
getNumRegs() || (RegKind == IS_VGPR && RegIdx > 255)) {
2787 Error(Loc,
"register index is out of range");
2788 return AMDGPU::NoRegister;
2791 if (RegKind == IS_VGPR && !
isGFX1250Plus() && RegIdx + RegWidth / 32 > 256) {
2792 Error(Loc,
"register index is out of range");
2793 return MCRegister();
2802 Error(Loc,
"invalid subregister");
2808bool AMDGPUAsmParser::ParseRegRange(
unsigned &Num,
unsigned &RegWidth,
2810 int64_t RegLo, RegHi;
2814 SMLoc FirstIdxLoc = getLoc();
2821 SecondIdxLoc = getLoc();
2832 Error(FirstIdxLoc,
"invalid register index");
2837 Error(SecondIdxLoc,
"invalid register index");
2841 if (RegLo > RegHi) {
2842 Error(FirstIdxLoc,
"first register index should not exceed second index");
2846 if (RegHi == RegLo) {
2847 StringRef RegSuffix = getTokenStr();
2848 if (RegSuffix ==
".l") {
2849 SubReg = AMDGPU::lo16;
2851 }
else if (RegSuffix ==
".h") {
2852 SubReg = AMDGPU::hi16;
2857 Num =
static_cast<unsigned>(RegLo);
2858 RegWidth = 32 * ((RegHi - RegLo) + 1);
2863MCRegister AMDGPUAsmParser::ParseSpecialReg(RegisterKind &RegKind,
2866 SmallVectorImpl<AsmToken> &Tokens) {
2872 RegKind = IS_SPECIAL;
2879MCRegister AMDGPUAsmParser::ParseRegularReg(RegisterKind &RegKind,
2882 SmallVectorImpl<AsmToken> &Tokens) {
2884 StringRef
RegName = getTokenStr();
2885 auto Loc = getLoc();
2889 Error(Loc,
"invalid register name");
2890 return MCRegister();
2898 unsigned SubReg = NoSubRegister;
2899 bool IsRange =
false;
2900 if (!RegSuffix.
empty()) {
2902 SubReg = AMDGPU::lo16;
2904 SubReg = AMDGPU::hi16;
2908 Error(Loc,
"invalid register index");
2909 return MCRegister();
2915 if (!ParseRegRange(RegNum, RegWidth, SubReg))
2916 return MCRegister();
2920 MCRegister
Reg = getRegularReg(RegKind, RegNum, SubReg, RegWidth, Loc);
2921 const MCRegisterInfo &
TRI = *
getContext().getRegisterInfo();
2922 if (RegKind == IS_SGPR && IsRange
2923 ? (
TRI.isSubRegister(
Reg, VCC_LO) ||
TRI.isSubRegister(
Reg, VCC_HI))
2924 : (
Reg == VCC_LO ||
Reg == VCC_HI)) {
2925 Error(Loc,
"register index is out of range");
2926 return MCRegister();
2932MCRegister AMDGPUAsmParser::ParseRegList(RegisterKind &RegKind,
2933 unsigned &RegNum,
unsigned &RegWidth,
2934 SmallVectorImpl<AsmToken> &Tokens) {
2936 auto ListLoc = getLoc();
2939 "expected a register or a list of registers")) {
2940 return MCRegister();
2945 auto Loc = getLoc();
2946 if (!ParseAMDGPURegister(RegKind,
Reg, RegNum, RegWidth))
2947 return MCRegister();
2948 if (RegWidth != 32) {
2949 Error(Loc,
"expected a single 32-bit register");
2950 return MCRegister();
2954 RegisterKind NextRegKind;
2956 unsigned NextRegNum, NextRegWidth;
2959 if (!ParseAMDGPURegister(NextRegKind, NextReg, NextRegNum, NextRegWidth,
2961 return MCRegister();
2963 if (NextRegWidth != 32) {
2964 Error(Loc,
"expected a single 32-bit register");
2965 return MCRegister();
2967 if (!AddNextRegisterToList(
Reg, RegWidth, RegKind, NextReg, NextRegKind,
2969 return MCRegister();
2973 "expected a comma or a closing square bracket")) {
2974 return MCRegister();
2978 Reg = getRegularReg(RegKind, RegNum, NoSubRegister, RegWidth, ListLoc);
2983bool AMDGPUAsmParser::ParseAMDGPURegister(RegisterKind &RegKind,
2984 MCRegister &
Reg,
unsigned &RegNum,
2986 SmallVectorImpl<AsmToken> &Tokens) {
2987 auto Loc = getLoc();
2991 Reg = ParseSpecialReg(RegKind, RegNum, RegWidth, Tokens);
2993 Reg = ParseRegularReg(RegKind, RegNum, RegWidth, Tokens);
2995 Reg = ParseRegList(RegKind, RegNum, RegWidth, Tokens);
3000 assert(Parser.hasPendingError());
3004 if (!subtargetHasRegister(*
TRI,
Reg)) {
3005 if (
Reg == AMDGPU::SGPR_NULL) {
3006 Error(Loc,
"'null' operand is not supported on this GPU");
3009 " register not available on this GPU");
3017bool AMDGPUAsmParser::ParseAMDGPURegister(RegisterKind &RegKind,
3018 MCRegister &
Reg,
unsigned &RegNum,
3020 bool RestoreOnFailure ) {
3024 if (ParseAMDGPURegister(RegKind,
Reg, RegNum, RegWidth, Tokens)) {
3025 if (RestoreOnFailure) {
3026 while (!Tokens.
empty()) {
3035std::optional<StringRef>
3036AMDGPUAsmParser::getGprCountSymbolName(RegisterKind RegKind) {
3039 return StringRef(
".amdgcn.next_free_vgpr");
3041 return StringRef(
".amdgcn.next_free_sgpr");
3043 return std::nullopt;
3047void AMDGPUAsmParser::initializeGprCountSymbol(RegisterKind RegKind) {
3048 auto SymbolName = getGprCountSymbolName(RegKind);
3049 assert(SymbolName &&
"initializing invalid register kind");
3055bool AMDGPUAsmParser::updateGprCountSymbols(RegisterKind RegKind,
3056 unsigned DwordRegIndex,
3057 unsigned RegWidth) {
3062 auto SymbolName = getGprCountSymbolName(RegKind);
3067 int64_t NewMax = DwordRegIndex +
divideCeil(RegWidth, 32) - 1;
3071 return !
Error(getLoc(),
3072 ".amdgcn.next_free_{v,s}gpr symbols must be variable");
3076 ".amdgcn.next_free_{v,s}gpr symbols must be absolute expressions");
3078 if (OldCount <= NewMax)
3084std::unique_ptr<AMDGPUOperand>
3085AMDGPUAsmParser::parseRegister(
bool RestoreOnFailure) {
3087 SMLoc StartLoc = Tok.getLoc();
3088 SMLoc EndLoc = Tok.getEndLoc();
3089 RegisterKind RegKind;
3091 unsigned RegNum, RegWidth;
3093 if (!ParseAMDGPURegister(RegKind,
Reg, RegNum, RegWidth)) {
3097 if (!updateGprCountSymbols(RegKind, RegNum, RegWidth))
3100 KernelScope.usesRegister(RegKind, RegNum, RegWidth);
3101 return AMDGPUOperand::CreateReg(
this,
Reg, StartLoc, EndLoc);
3108 if (isRegister() || isModifier())
3111 if (
Lit == LitModifier::None) {
3112 if (trySkipId(
"lit"))
3113 Lit = LitModifier::Lit;
3114 else if (trySkipId(
"lit64"))
3115 Lit = LitModifier::Lit64;
3117 if (
Lit != LitModifier::None) {
3120 ParseStatus S = parseImm(
Operands, HasSP3AbsModifier,
Lit);
3129 const auto &NextTok = peekToken();
3132 bool Negate =
false;
3140 AMDGPUOperand::Modifiers Mods;
3148 StringRef Num = getTokenStr();
3151 APFloat RealVal(APFloat::IEEEdouble());
3152 auto roundMode = APFloat::rmNearestTiesToEven;
3153 if (
errorToBool(RealVal.convertFromString(Num, roundMode).takeError()))
3156 RealVal.changeSign();
3159 AMDGPUOperand::CreateImm(
this, RealVal.bitcastToAPInt().getZExtValue(),
3160 S, AMDGPUOperand::ImmTyNone,
true));
3161 AMDGPUOperand &
Op =
static_cast<AMDGPUOperand &
>(*
Operands.back());
3162 Op.setModifiers(Mods);
3171 if (HasSP3AbsModifier) {
3180 if (getParser().parsePrimaryExpr(Expr, EndLoc,
nullptr))
3183 if (Parser.parseExpression(Expr))
3187 if (Expr->evaluateAsAbsolute(IntVal)) {
3189 return Error(S,
"literal value out of range");
3190 Operands.push_back(AMDGPUOperand::CreateImm(
this, IntVal, S));
3191 AMDGPUOperand &
Op =
static_cast<AMDGPUOperand &
>(*
Operands.back());
3192 Op.setModifiers(Mods);
3194 if (
Lit != LitModifier::None)
3196 Operands.push_back(AMDGPUOperand::CreateExpr(
this, Expr, S));
3209 if (
auto R = parseRegister()) {
3219 ParseStatus Res = parseReg(
Operands);
3227bool AMDGPUAsmParser::isNamedOperandModifier(
const AsmToken &Token,
3228 const AsmToken &NextToken)
const {
3231 return str ==
"abs" || str ==
"neg" || str ==
"sext";
3236bool AMDGPUAsmParser::isOpcodeModifierWithVal(
const AsmToken &Token,
3237 const AsmToken &NextToken)
const {
3241bool AMDGPUAsmParser::isOperandModifier(
const AsmToken &Token,
3242 const AsmToken &NextToken)
const {
3243 return isNamedOperandModifier(Token, NextToken) || Token.
is(
AsmToken::Pipe);
3246bool AMDGPUAsmParser::isRegOrOperandModifier(
const AsmToken &Token,
3247 const AsmToken &NextToken)
const {
3248 return isRegister(Token, NextToken) || isOperandModifier(Token, NextToken);
3265bool AMDGPUAsmParser::isModifier() {
3268 AsmToken NextToken[2];
3269 peekTokens(NextToken);
3273 bool IsOpcodeModifier = isOpcodeModifierWithVal(Tok, NextToken[0]) &&
3276 return isOperandModifier(Tok, NextToken[0]) ||
3278 isRegOrOperandModifier(NextToken[0], NextToken[1])) ||
3304bool AMDGPUAsmParser::parseSP3NegModifier() {
3306 AsmToken NextToken[2];
3307 peekTokens(NextToken);
3310 (isRegister(NextToken[0], NextToken[1]) ||
3328 return Error(getLoc(),
"invalid syntax, expected 'neg' modifier");
3330 SP3Neg = parseSP3NegModifier();
3333 Neg = trySkipId(
"neg");
3335 return Error(Loc,
"expected register or immediate");
3339 Abs = trySkipId(
"abs");
3344 if (trySkipId(
"lit")) {
3345 Lit = LitModifier::Lit;
3348 }
else if (trySkipId(
"lit64")) {
3349 Lit = LitModifier::Lit64;
3352 if (!has64BitLiterals())
3353 return Error(Loc,
"lit64 is not supported on this GPU");
3359 return Error(Loc,
"expected register or immediate");
3368 return (SP3Neg || Neg || SP3Abs || Abs ||
Lit != LitModifier::None)
3372 if (
Lit != LitModifier::None && !
Operands.back()->isImm())
3373 Error(Loc,
"expected immediate with lit modifier");
3375 if (SP3Abs && !skipToken(
AsmToken::Pipe,
"expected vertical bar"))
3381 if (
Lit != LitModifier::None &&
3385 AMDGPUOperand::Modifiers Mods;
3386 Mods.Abs = Abs || SP3Abs;
3387 Mods.Neg = Neg || SP3Neg;
3390 if (Mods.hasFPModifiers() ||
Lit != LitModifier::None) {
3391 AMDGPUOperand &
Op =
static_cast<AMDGPUOperand &
>(*
Operands.back());
3393 return Error(
Op.getStartLoc(),
"expected an absolute expression");
3394 Op.setModifiers(Mods);
3402 bool Sext = trySkipId(
"sext");
3403 if (Sext && !skipToken(
AsmToken::LParen,
"expected left paren after sext"))
3418 AMDGPUOperand::Modifiers Mods;
3421 if (Mods.hasIntModifiers()) {
3422 AMDGPUOperand &
Op =
static_cast<AMDGPUOperand &
>(*
Operands.back());
3424 return Error(
Op.getStartLoc(),
"expected an absolute expression");
3425 Op.setModifiers(Mods);
3432 return parseRegOrImmWithFPInputMods(
Operands,
false);
3436 return parseRegOrImmWithIntInputMods(
Operands,
false);
3443 if (!trySkipId(
"rsrcidx"))
3449 SMLoc RegLoc = getLoc();
3450 std::unique_ptr<AMDGPUOperand>
Reg = parseRegister();
3458 if (!
Reg->isRsrcReg32())
3459 return Error(RegLoc,
"rsrcidx operand must be a 32-bit SGPR or VGPR");
3469 auto Loc = getLoc();
3470 if (trySkipId(
"off")) {
3472 AMDGPUOperand::CreateImm(
this, 0, Loc, AMDGPUOperand::ImmTyOff,
false));
3479 std::unique_ptr<AMDGPUOperand>
Reg = parseRegister();
3488unsigned AMDGPUAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
3493 return Match_InvalidOperand;
3495 if (Inst.
getOpcode() == AMDGPU::V_MAC_F32_sdwa_vi ||
3496 Inst.
getOpcode() == AMDGPU::V_MAC_F16_sdwa_vi) {
3499 AMDGPU::getNamedOperandIdx(Inst.
getOpcode(), AMDGPU::OpName::dst_sel);
3501 if (!
Op.isImm() ||
Op.getImm() != AMDGPU::SDWA::SdwaSel::DWORD) {
3502 return Match_InvalidOperand;
3510 if (tryAnotherVOPDEncoding(Inst))
3511 return Match_InvalidOperand;
3513 return Match_Success;
3517 static const unsigned Variants[] = {
3526ArrayRef<unsigned> AMDGPUAsmParser::getMatchedVariants()
const {
3527 if (isForcedDPP() && isForcedVOP3()) {
3531 if (getForcedEncodingSize() == 32) {
3536 if (isForcedVOP3()) {
3541 if (isForcedSDWA()) {
3547 if (isForcedDPP()) {
3555StringRef AMDGPUAsmParser::getMatchedVariantName()
const {
3556 if (isForcedDPP() && isForcedVOP3())
3559 if (getForcedEncodingSize() == 32)
3575AMDGPUAsmParser::findImplicitSGPRReadInVOP(
const MCInst &Inst)
const {
3579 case AMDGPU::FLAT_SCR:
3581 case AMDGPU::VCC_LO:
3582 case AMDGPU::VCC_HI:
3589 return MCRegister();
3596bool AMDGPUAsmParser::isInlineConstant(
const MCInst &Inst,
3597 unsigned OpIdx)
const {
3605 const MCOperand &MO = Inst.
getOperand(OpIdx);
3655unsigned AMDGPUAsmParser::getConstantBusLimit(
unsigned Opcode)
const {
3661 case AMDGPU::V_LSHLREV_B64_e64:
3662 case AMDGPU::V_LSHLREV_B64_gfx10:
3663 case AMDGPU::V_LSHLREV_B64_e64_gfx11:
3664 case AMDGPU::V_LSHLREV_B64_e32_gfx12:
3665 case AMDGPU::V_LSHLREV_B64_e64_gfx12:
3666 case AMDGPU::V_LSHRREV_B64_e64:
3667 case AMDGPU::V_LSHRREV_B64_gfx10:
3668 case AMDGPU::V_LSHRREV_B64_e64_gfx11:
3669 case AMDGPU::V_LSHRREV_B64_e64_gfx12:
3670 case AMDGPU::V_ASHRREV_I64_e64:
3671 case AMDGPU::V_ASHRREV_I64_gfx10:
3672 case AMDGPU::V_ASHRREV_I64_e64_gfx11:
3673 case AMDGPU::V_ASHRREV_I64_e64_gfx12:
3674 case AMDGPU::V_LSHL_B64_e64:
3675 case AMDGPU::V_LSHR_B64_e64:
3676 case AMDGPU::V_ASHR_I64_e64:
3689 bool AddMandatoryLiterals =
false) {
3692 AddMandatoryLiterals ? getNamedOperandIdx(Opcode, OpName::imm) : -1;
3696 AddMandatoryLiterals ? getNamedOperandIdx(Opcode, OpName::immX) : -1;
3698 return {getNamedOperandIdx(Opcode, OpName::src0X),
3699 getNamedOperandIdx(Opcode, OpName::vsrc1X),
3700 getNamedOperandIdx(Opcode, OpName::vsrc2X),
3701 getNamedOperandIdx(Opcode, OpName::src0Y),
3702 getNamedOperandIdx(Opcode, OpName::vsrc1Y),
3703 getNamedOperandIdx(Opcode, OpName::vsrc2Y),
3708 return {getNamedOperandIdx(Opcode, OpName::src0),
3709 getNamedOperandIdx(Opcode, OpName::src1),
3710 getNamedOperandIdx(Opcode, OpName::src2), ImmIdx};
3713bool AMDGPUAsmParser::usesConstantBus(
const MCInst &Inst,
unsigned OpIdx) {
3714 const MCOperand &MO = Inst.
getOperand(OpIdx);
3716 return !isInlineConstant(Inst, OpIdx);
3723 return isSGPR(PReg,
TRI) && PReg != SGPR_NULL;
3734 const unsigned Opcode = Inst.
getOpcode();
3735 if (Opcode != V_WRITELANE_B32_gfx6_gfx7 && Opcode != V_WRITELANE_B32_vi)
3738 if (!LaneSelOp.
isReg())
3741 return LaneSelReg ==
M0 || LaneSelReg == M0_gfxpre11;
3744bool AMDGPUAsmParser::validateConstantBusLimitations(
3746 const unsigned Opcode = Inst.
getOpcode();
3747 const MCInstrDesc &
Desc = MII.
get(Opcode);
3748 MCRegister LastSGPR;
3749 unsigned ConstantBusUseCount = 0;
3750 unsigned NumLiterals = 0;
3751 unsigned LiteralSize;
3767 SmallDenseSet<MCRegister> SGPRsUsed;
3768 MCRegister SGPRUsed = findImplicitSGPRReadInVOP(Inst);
3770 SGPRsUsed.
insert(SGPRUsed);
3771 ++ConstantBusUseCount;
3776 unsigned ConstantBusLimit = getConstantBusLimit(Opcode);
3778 for (
int OpIdx : OpIndices) {
3782 const MCOperand &MO = Inst.
getOperand(OpIdx);
3783 if (usesConstantBus(Inst, OpIdx)) {
3792 if (SGPRsUsed.
insert(LastSGPR).second) {
3793 ++ConstantBusUseCount;
3813 if (NumLiterals == 0) {
3816 }
else if (LiteralSize !=
Size) {
3822 if (ConstantBusUseCount + NumLiterals > ConstantBusLimit) {
3824 "invalid operand (violates constant bus restrictions)");
3831std::optional<unsigned>
3832AMDGPUAsmParser::checkVOPDRegBankConstraints(
const MCInst &Inst,
bool AsVOPD3) {
3834 const unsigned Opcode = Inst.
getOpcode();
3840 auto getVRegIdx = [&](unsigned,
unsigned OperandIdx) {
3841 const MCOperand &Opr = Inst.
getOperand(OperandIdx);
3850 Opcode == AMDGPU::V_DUAL_MOV_B32_e32_X_MOV_B32_e32_gfx1170 ||
3851 Opcode == AMDGPU::V_DUAL_MOV_B32_e32_X_MOV_B32_e32_gfx12 ||
3852 Opcode == AMDGPU::V_DUAL_MOV_B32_e32_X_MOV_B32_e32_gfx1250 ||
3853 Opcode == AMDGPU::V_DUAL_MOV_B32_e32_X_MOV_B32_e32_gfx13 ||
3854 Opcode == AMDGPU::V_DUAL_MOV_B32_e32_X_MOV_B32_e32_e96_gfx1250 ||
3855 Opcode == AMDGPU::V_DUAL_MOV_B32_e32_X_MOV_B32_e32_e96_gfx13;
3859 for (
auto OpName : {OpName::src0X, OpName::src0Y}) {
3860 int I = getNamedOperandIdx(Opcode, OpName);
3864 int64_t
Imm =
Op.getImm();
3870 for (
auto OpName : {OpName::vsrc1X, OpName::vsrc1Y, OpName::vsrc2X,
3871 OpName::vsrc2Y, OpName::imm}) {
3872 int I = getNamedOperandIdx(Opcode, OpName);
3882 auto InvalidCompOprIdx = InstInfo.getInvalidCompOperandIndex(
3883 getVRegIdx, *
TRI, SkipSrc, AllowSameVGPR, AsVOPD3);
3885 return InvalidCompOprIdx;
3888bool AMDGPUAsmParser::validateVOPD(
const MCInst &Inst,
3895 for (
const std::unique_ptr<MCParsedAsmOperand> &Operand :
Operands) {
3896 AMDGPUOperand &
Op = (AMDGPUOperand &)*Operand;
3897 if ((
Op.isRegKind() ||
Op.isImmTy(AMDGPUOperand::ImmTyNone)) &&
3899 Error(
Op.getStartLoc(),
"ABS not allowed in VOPD3 instructions");
3903 auto InvalidCompOprIdx = checkVOPDRegBankConstraints(Inst, AsVOPD3);
3904 if (!InvalidCompOprIdx.has_value())
3907 auto CompOprIdx = *InvalidCompOprIdx;
3910 std::max(InstInfo[
VOPD::X].getIndexInParsedOperands(CompOprIdx),
3911 InstInfo[
VOPD::Y].getIndexInParsedOperands(CompOprIdx));
3914 auto Loc = ((AMDGPUOperand &)*
Operands[ParsedIdx]).getStartLoc();
3915 if (CompOprIdx == VOPD::Component::DST) {
3917 Error(Loc,
"dst registers must be distinct");
3919 Error(Loc,
"one dst register must be even and the other odd");
3921 auto CompSrcIdx = CompOprIdx - VOPD::Component::DST_NUM;
3922 Error(Loc, Twine(
"src") + Twine(CompSrcIdx) +
3923 " operands must use different VGPR banks");
3931bool AMDGPUAsmParser::tryVOPD3(
const MCInst &Inst) {
3933 auto InvalidCompOprIdx = checkVOPDRegBankConstraints(Inst,
false);
3934 if (!InvalidCompOprIdx.has_value())
3938 InvalidCompOprIdx = checkVOPDRegBankConstraints(Inst,
true);
3939 if (InvalidCompOprIdx.has_value()) {
3944 if (*InvalidCompOprIdx == VOPD::Component::DST)
3957bool AMDGPUAsmParser::tryVOPD(
const MCInst &Inst) {
3958 const unsigned Opcode = Inst.
getOpcode();
3973 for (
auto OpName : {OpName::src0X_modifiers, OpName::src0Y_modifiers,
3974 OpName::vsrc1X_modifiers, OpName::vsrc1Y_modifiers,
3975 OpName::vsrc2X_modifiers, OpName::vsrc2Y_modifiers}) {
3976 int I = getNamedOperandIdx(Opcode, OpName);
3983 return !tryVOPD3(Inst);
3988bool AMDGPUAsmParser::tryAnotherVOPDEncoding(
const MCInst &Inst) {
3993 return tryVOPD(Inst);
3994 return tryVOPD3(Inst);
3997bool AMDGPUAsmParser::validateIntClampSupported(
const MCInst &Inst) {
4002 int ClampIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::clamp);
4010bool AMDGPUAsmParser::validateMIMGDataSize(
const MCInst &Inst, SMLoc IDLoc) {
4018 int VDataIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::vdata);
4019 int DMaskIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::dmask);
4020 int TFEIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::tfe);
4025 if ((DMaskIdx == -1 || TFEIdx == -1) &&
4026 hasBVHRayTracingInsts())
4029 unsigned VDataSize = getRegOperandSize(
Desc, VDataIdx);
4030 unsigned TFESize = (TFEIdx != -1 && Inst.
getOperand(TFEIdx).
getImm()) ? 1 : 0;
4035 bool IsPackedD16 =
false;
4038 int D16Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::d16);
4039 IsPackedD16 = D16Idx >= 0;
4041 DataSize = (DataSize + 1) / 2;
4044 if ((VDataSize / 4) == DataSize + TFESize)
4049 Modifiers = IsPackedD16 ?
"dmask and d16" :
"dmask";
4051 Modifiers = IsPackedD16 ?
"dmask, d16 and tfe" :
"dmask and tfe";
4053 Error(IDLoc, Twine(
"image data size does not match ") + Modifiers);
4057bool AMDGPUAsmParser::validateMIMGAddrSize(
const MCInst &Inst, SMLoc IDLoc) {
4066 const AMDGPU::MIMGBaseOpcodeInfo *BaseOpcode =
4068 int VAddr0Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::vaddr0);
4069 AMDGPU::OpName RSrcOpName =
4071 int SrsrcIdx = AMDGPU::getNamedOperandIdx(
Opc, RSrcOpName);
4072 int DimIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::dim);
4073 int A16Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::a16);
4077 assert(SrsrcIdx > VAddr0Idx);
4080 if (BaseOpcode->
BVH) {
4081 if (IsA16 == BaseOpcode->
A16)
4083 Error(IDLoc,
"image address size does not match a16");
4089 bool IsNSA = SrsrcIdx - VAddr0Idx > 1;
4090 unsigned ActualAddrSize =
4091 IsNSA ? SrsrcIdx - VAddr0Idx : getRegOperandSize(
Desc, VAddr0Idx) / 4;
4093 unsigned ExpectedAddrSize =
4097 if (hasPartialNSAEncoding() &&
4099 int VAddrLastIdx = SrsrcIdx - 1;
4100 unsigned VAddrLastSize = getRegOperandSize(
Desc, VAddrLastIdx) / 4;
4102 ActualAddrSize = VAddrLastIdx - VAddr0Idx + VAddrLastSize;
4105 if (ExpectedAddrSize > 12)
4106 ExpectedAddrSize = 16;
4111 if (ActualAddrSize == 8 && (ExpectedAddrSize >= 5 && ExpectedAddrSize <= 7))
4115 if (ActualAddrSize == ExpectedAddrSize)
4118 Error(IDLoc,
"image address size does not match dim and a16");
4122bool AMDGPUAsmParser::validateMIMGAtomicDMask(
const MCInst &Inst) {
4129 if (!
Desc.mayLoad() || !
Desc.mayStore())
4132 int DMaskIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::dmask);
4139 return DMask == 0x1 || DMask == 0x3 || DMask == 0xf;
4142bool AMDGPUAsmParser::validateMIMGGatherDMask(
const MCInst &Inst) {
4149 int DMaskIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::dmask);
4157 return DMask == 0x1 || DMask == 0x2 || DMask == 0x4 || DMask == 0x8;
4160bool AMDGPUAsmParser::validateMIMGDim(
const MCInst &Inst,
4174 for (
unsigned i = 1, e =
Operands.size(); i != e; ++i) {
4175 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[i]);
4182bool AMDGPUAsmParser::validateMIMGMSAA(
const MCInst &Inst) {
4189 const AMDGPU::MIMGBaseOpcodeInfo *BaseOpcode =
4192 if (!BaseOpcode->
MSAA)
4195 int DimIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::dim);
4201 return DimInfo->
MSAA;
4206 case AMDGPU::V_MOVRELS_B32_sdwa_gfx10:
4207 case AMDGPU::V_MOVRELSD_B32_sdwa_gfx10:
4208 case AMDGPU::V_MOVRELSD_2_B32_sdwa_gfx10:
4218bool AMDGPUAsmParser::validateMovrels(
const MCInst &Inst,
4226 const int Src0Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src0);
4237 Error(getOperandLoc(
Operands, Src0Idx),
"source operand must be a VGPR");
4241bool AMDGPUAsmParser::validateMAIAccWrite(
const MCInst &Inst,
4246 if (
Opc != AMDGPU::V_ACCVGPR_WRITE_B32_vi)
4249 const int Src0Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src0);
4260 "source operand must be either a VGPR or an inline constant");
4267bool AMDGPUAsmParser::validateMAISrc2(
const MCInst &Inst,
4272 !getFeatureBits()[FeatureMFMAInlineLiteralBug])
4275 const int Src2Idx = getNamedOperandIdx(Opcode, OpName::src2);
4279 if (Inst.
getOperand(Src2Idx).
isImm() && isInlineConstant(Inst, Src2Idx)) {
4281 "inline constants are not allowed for this operand");
4288bool AMDGPUAsmParser::validateMFMA(
const MCInst &Inst,
4296 int BlgpIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::blgp);
4297 if (BlgpIdx != -1) {
4298 if (
const MFMA_F8F6F4_Info *Info = AMDGPU::isMFMA_F8F6F4(
Opc)) {
4299 int CbszIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::cbsz);
4309 int Src0Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src0);
4311 "wrong register tuple size for cbsz value " + Twine(CBSZ));
4316 int Src1Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src1);
4318 "wrong register tuple size for blgp value " + Twine(BLGP));
4326 const int Src2Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src2);
4336 if (Src2Reg == DstReg)
4341 .getSizeInBits() <= 128)
4344 if (
TRI->regsOverlap(Src2Reg, DstReg)) {
4346 "source 2 operand must not partially overlap with dst");
4353bool AMDGPUAsmParser::validateDivScale(
const MCInst &Inst) {
4357 case V_DIV_SCALE_F32_gfx6_gfx7:
4358 case V_DIV_SCALE_F32_vi:
4359 case V_DIV_SCALE_F32_gfx10:
4360 case V_DIV_SCALE_F64_gfx6_gfx7:
4361 case V_DIV_SCALE_F64_vi:
4362 case V_DIV_SCALE_F64_gfx10:
4369 {AMDGPU::OpName::src0_modifiers, AMDGPU::OpName::src2_modifiers,
4370 AMDGPU::OpName::src2_modifiers}) {
4381bool AMDGPUAsmParser::validateMIMGD16(
const MCInst &Inst) {
4388 int D16Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::d16);
4397bool AMDGPUAsmParser::validateTensorR128(
const MCInst &Inst) {
4403 int R128Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::r128);
4410 case AMDGPU::V_SUBREV_F32_e32:
4411 case AMDGPU::V_SUBREV_F32_e64:
4412 case AMDGPU::V_SUBREV_F32_e32_gfx10:
4413 case AMDGPU::V_SUBREV_F32_e32_gfx6_gfx7:
4414 case AMDGPU::V_SUBREV_F32_e32_vi:
4415 case AMDGPU::V_SUBREV_F32_e64_gfx10:
4416 case AMDGPU::V_SUBREV_F32_e64_gfx6_gfx7:
4417 case AMDGPU::V_SUBREV_F32_e64_vi:
4419 case AMDGPU::V_SUBREV_CO_U32_e32:
4420 case AMDGPU::V_SUBREV_CO_U32_e64:
4421 case AMDGPU::V_SUBREV_I32_e32_gfx6_gfx7:
4422 case AMDGPU::V_SUBREV_I32_e64_gfx6_gfx7:
4424 case AMDGPU::V_SUBBREV_U32_e32:
4425 case AMDGPU::V_SUBBREV_U32_e64:
4426 case AMDGPU::V_SUBBREV_U32_e32_gfx6_gfx7:
4427 case AMDGPU::V_SUBBREV_U32_e32_vi:
4428 case AMDGPU::V_SUBBREV_U32_e64_gfx6_gfx7:
4429 case AMDGPU::V_SUBBREV_U32_e64_vi:
4431 case AMDGPU::V_SUBREV_U32_e32:
4432 case AMDGPU::V_SUBREV_U32_e64:
4433 case AMDGPU::V_SUBREV_U32_e32_gfx9:
4434 case AMDGPU::V_SUBREV_U32_e32_vi:
4435 case AMDGPU::V_SUBREV_U32_e64_gfx9:
4436 case AMDGPU::V_SUBREV_U32_e64_vi:
4438 case AMDGPU::V_SUBREV_F16_e32:
4439 case AMDGPU::V_SUBREV_F16_e64:
4440 case AMDGPU::V_SUBREV_F16_e32_gfx10:
4441 case AMDGPU::V_SUBREV_F16_e32_vi:
4442 case AMDGPU::V_SUBREV_F16_e64_gfx10:
4443 case AMDGPU::V_SUBREV_F16_e64_vi:
4445 case AMDGPU::V_SUBREV_U16_e32:
4446 case AMDGPU::V_SUBREV_U16_e64:
4447 case AMDGPU::V_SUBREV_U16_e32_vi:
4448 case AMDGPU::V_SUBREV_U16_e64_vi:
4450 case AMDGPU::V_SUBREV_CO_U32_e32_gfx9:
4451 case AMDGPU::V_SUBREV_CO_U32_e64_gfx10:
4452 case AMDGPU::V_SUBREV_CO_U32_e64_gfx9:
4454 case AMDGPU::V_SUBBREV_CO_U32_e32_gfx9:
4455 case AMDGPU::V_SUBBREV_CO_U32_e64_gfx9:
4457 case AMDGPU::V_SUBREV_NC_U32_e32_gfx10:
4458 case AMDGPU::V_SUBREV_NC_U32_e64_gfx10:
4460 case AMDGPU::V_SUBREV_CO_CI_U32_e32_gfx10:
4461 case AMDGPU::V_SUBREV_CO_CI_U32_e64_gfx10:
4463 case AMDGPU::V_LSHRREV_B32_e32:
4464 case AMDGPU::V_LSHRREV_B32_e64:
4465 case AMDGPU::V_LSHRREV_B32_e32_gfx6_gfx7:
4466 case AMDGPU::V_LSHRREV_B32_e64_gfx6_gfx7:
4467 case AMDGPU::V_LSHRREV_B32_e32_vi:
4468 case AMDGPU::V_LSHRREV_B32_e64_vi:
4469 case AMDGPU::V_LSHRREV_B32_e32_gfx10:
4470 case AMDGPU::V_LSHRREV_B32_e64_gfx10:
4472 case AMDGPU::V_ASHRREV_I32_e32:
4473 case AMDGPU::V_ASHRREV_I32_e64:
4474 case AMDGPU::V_ASHRREV_I32_e32_gfx10:
4475 case AMDGPU::V_ASHRREV_I32_e32_gfx6_gfx7:
4476 case AMDGPU::V_ASHRREV_I32_e32_vi:
4477 case AMDGPU::V_ASHRREV_I32_e64_gfx10:
4478 case AMDGPU::V_ASHRREV_I32_e64_gfx6_gfx7:
4479 case AMDGPU::V_ASHRREV_I32_e64_vi:
4481 case AMDGPU::V_LSHLREV_B32_e32:
4482 case AMDGPU::V_LSHLREV_B32_e64:
4483 case AMDGPU::V_LSHLREV_B32_e32_gfx10:
4484 case AMDGPU::V_LSHLREV_B32_e32_gfx6_gfx7:
4485 case AMDGPU::V_LSHLREV_B32_e32_vi:
4486 case AMDGPU::V_LSHLREV_B32_e64_gfx10:
4487 case AMDGPU::V_LSHLREV_B32_e64_gfx6_gfx7:
4488 case AMDGPU::V_LSHLREV_B32_e64_vi:
4490 case AMDGPU::V_LSHLREV_B16_e32:
4491 case AMDGPU::V_LSHLREV_B16_e64:
4492 case AMDGPU::V_LSHLREV_B16_e32_vi:
4493 case AMDGPU::V_LSHLREV_B16_e64_vi:
4494 case AMDGPU::V_LSHLREV_B16_gfx10:
4496 case AMDGPU::V_LSHRREV_B16_e32:
4497 case AMDGPU::V_LSHRREV_B16_e64:
4498 case AMDGPU::V_LSHRREV_B16_e32_vi:
4499 case AMDGPU::V_LSHRREV_B16_e64_vi:
4500 case AMDGPU::V_LSHRREV_B16_gfx10:
4502 case AMDGPU::V_ASHRREV_I16_e32:
4503 case AMDGPU::V_ASHRREV_I16_e64:
4504 case AMDGPU::V_ASHRREV_I16_e32_vi:
4505 case AMDGPU::V_ASHRREV_I16_e64_vi:
4506 case AMDGPU::V_ASHRREV_I16_gfx10:
4508 case AMDGPU::V_LSHLREV_B64_e64:
4509 case AMDGPU::V_LSHLREV_B64_gfx10:
4510 case AMDGPU::V_LSHLREV_B64_vi:
4512 case AMDGPU::V_LSHRREV_B64_e64:
4513 case AMDGPU::V_LSHRREV_B64_gfx10:
4514 case AMDGPU::V_LSHRREV_B64_vi:
4516 case AMDGPU::V_ASHRREV_I64_e64:
4517 case AMDGPU::V_ASHRREV_I64_gfx10:
4518 case AMDGPU::V_ASHRREV_I64_vi:
4520 case AMDGPU::V_PK_LSHLREV_B16:
4521 case AMDGPU::V_PK_LSHLREV_B16_gfx10:
4522 case AMDGPU::V_PK_LSHLREV_B16_vi:
4524 case AMDGPU::V_PK_LSHRREV_B16:
4525 case AMDGPU::V_PK_LSHRREV_B16_gfx10:
4526 case AMDGPU::V_PK_LSHRREV_B16_vi:
4527 case AMDGPU::V_PK_ASHRREV_I16:
4528 case AMDGPU::V_PK_ASHRREV_I16_gfx10:
4529 case AMDGPU::V_PK_ASHRREV_I16_vi:
4536bool AMDGPUAsmParser::validateLdsDirect(
const MCInst &Inst,
4538 const unsigned Opcode = Inst.
getOpcode();
4547 for (
auto SrcName : {OpName::src0, OpName::src1, OpName::src2}) {
4548 auto SrcIdx = getNamedOperandIdx(Opcode, SrcName);
4552 if (Src.isReg() && Src.getReg() == LDS_DIRECT) {
4556 "lds_direct is not supported on this GPU");
4562 "lds_direct cannot be used with this instruction");
4566 if (SrcName != OpName::src0) {
4568 "lds_direct may be used as src0 only");
4578 for (
unsigned i = 1, e =
Operands.size(); i != e; ++i) {
4579 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[i]);
4580 if (
Op.isFlatOffset())
4581 return Op.getStartLoc();
4586bool AMDGPUAsmParser::validateOffset(
const MCInst &Inst,
4589 auto OpNum = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::offset);
4594 return validateFlatOffset(Inst,
Operands);
4597 return validateSMEMOffset(Inst,
Operands);
4602 const unsigned OffsetSize = 24;
4603 if (!
isUIntN(OffsetSize - 1,
Op.getImm())) {
4605 Twine(
"expected a ") + Twine(OffsetSize - 1) +
4606 "-bit unsigned offset for buffer ops");
4610 const unsigned OffsetSize = 16;
4611 if (!
isUIntN(OffsetSize,
Op.getImm())) {
4613 Twine(
"expected a ") + Twine(OffsetSize) +
"-bit unsigned offset");
4620bool AMDGPUAsmParser::validateFlatOffset(
const MCInst &Inst,
4626 auto OpNum = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::offset);
4630 if (!hasFlatOffsets() &&
Op.getImm() != 0) {
4632 "flat offset modifier is not supported on this GPU");
4639 bool AllowNegative =
4641 if (!
isIntN(OffsetSize,
Op.getImm()) || (!AllowNegative &&
Op.getImm() < 0)) {
4643 Twine(
"expected a ") +
4644 (AllowNegative ? Twine(OffsetSize) +
"-bit signed offset"
4645 : Twine(OffsetSize - 1) +
"-bit unsigned offset"));
4654 for (
unsigned i = 2, e =
Operands.size(); i != e; ++i) {
4655 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[i]);
4656 if (
Op.isSMEMOffset() ||
Op.isSMEMOffsetMod())
4657 return Op.getStartLoc();
4662bool AMDGPUAsmParser::validateSMEMOffset(
const MCInst &Inst,
4671 auto OpNum = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::offset);
4687 ?
"expected a 23-bit unsigned offset for buffer ops"
4688 :
isGFX12Plus() ?
"expected a 24-bit signed offset"
4689 : (
isVI() || IsBuffer) ?
"expected a 20-bit unsigned offset"
4690 :
"expected a 21-bit signed offset");
4696bool AMDGPUAsmParser::validateSMEMSData(
const MCInst &Inst,
4702 AMDGPU::getNamedOperandIdx(Inst.
getOpcode(), AMDGPU::OpName::sdata);
4707 Error(getOperandLoc(
Operands, OpNum),
"expected a 5-bit unsigned immediate");
4716bool AMDGPUAsmParser::validateBF16InlineConst(
const MCInst &Inst,
4718 if (!getFeatureBits()[AMDGPU::FeatureBF16InlineConstFromUpperFP32])
4733 const int Src0Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src0);
4737 const MCOperandInfo &Src0Info =
Desc.operands()[Src0Idx];
4742 if (!
Src0.isImm() ||
4744 hasInv2PiInlineImm()))
4749 AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src0_modifiers);
4750 if (ModsIdx != -1 &&
4756 "bf16 inline constant is read from the high half of the fp32 inline "
4757 "constant on this GPU; use the e64 encoding with op_sel:[1,0]");
4761bool AMDGPUAsmParser::validateSOPLiteral(
const MCInst &Inst,
4764 const MCInstrDesc &
Desc = MII.
get(Opcode);
4768 const int Src0Idx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::src0);
4769 const int Src1Idx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::src1);
4771 const int OpIndices[] = {Src0Idx, Src1Idx};
4773 unsigned NumExprs = 0;
4774 unsigned NumLiterals = 0;
4777 for (
int OpIdx : OpIndices) {
4781 const MCOperand &MO = Inst.
getOperand(OpIdx);
4785 std::optional<int64_t>
Imm;
4788 }
else if (MO.
isExpr()) {
4797 if (!
Imm.has_value()) {
4799 }
else if (!isInlineConstant(Inst, OpIdx)) {
4803 if (NumLiterals == 0 || LiteralValue !=
Value) {
4811 if (NumLiterals + NumExprs <= 1)
4815 "only one unique literal operand is allowed");
4819bool AMDGPUAsmParser::validateOpSel(
const MCInst &Inst) {
4822 int OpSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel);
4830 int OpSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel);
4831 if (OpSelIdx != -1) {
4835 int OpSelHiIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel_hi);
4836 if (OpSelHiIdx != -1) {
4845 int OpSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel);
4852 if (getFeatureBits()[AMDGPU::FeatureGFX950Insts] &&
4853 (
Opc == AMDGPU::V_PK_ADD_F32_vi ||
Opc == AMDGPU::V_PK_MUL_F32_vi ||
4854 Opc == AMDGPU::V_PK_FMA_F32_vi)) {
4855 int OpSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel);
4859 if (
Opc == AMDGPU::V_PK_FMA_F32_vi &&
4860 (((OpSel >> 1) & 1) || ((OpSel >> 2) & 1)))
4863 else if ((OpSel & 3) == 2)
4871 int Src0Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src0);
4872 int Src1Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src1);
4873 int OpSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel);
4874 int OpSelHiIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel_hi);
4883 auto VerifyOneSGPR = [
OpSel, OpSelHi](
unsigned Index) ->
bool {
4885 return ((OpSel & Mask) == 0) && ((OpSelHi &
Mask) == 0);
4895 int Src2Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src2);
4896 if (Src2Idx != -1) {
4907bool AMDGPUAsmParser::validateTrue16OpSel(
const MCInst &Inst) {
4908 if (!hasTrue16Insts())
4910 const MCRegisterInfo *
MRI = getMRI();
4912 int OpSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel);
4918 if (OpSelOpValue == 0)
4920 unsigned OpCount = 0;
4921 for (AMDGPU::OpName OpName : {AMDGPU::OpName::src0, AMDGPU::OpName::src1,
4922 AMDGPU::OpName::src2, AMDGPU::OpName::vdst}) {
4923 int OpIdx = AMDGPU::getNamedOperandIdx(Inst.
getOpcode(), OpName);
4930 bool OpSelOpIsHi = ((OpSelOpValue & (1 << OpCount)) != 0);
4931 if (OpSelOpIsHi != VGPRSuffixIsHi)
4940bool AMDGPUAsmParser::validateNeg(
const MCInst &Inst, AMDGPU::OpName OpName) {
4941 assert(OpName == AMDGPU::OpName::neg_lo || OpName == AMDGPU::OpName::neg_hi);
4953 int NegIdx = AMDGPU::getNamedOperandIdx(
Opc, OpName);
4964 const AMDGPU::OpName SrcMods[3] = {AMDGPU::OpName::src0_modifiers,
4965 AMDGPU::OpName::src1_modifiers,
4966 AMDGPU::OpName::src2_modifiers};
4968 for (
unsigned i = 0; i < 3; ++i) {
4978bool AMDGPUAsmParser::validateDPP(
const MCInst &Inst,
4981 int DppCtrlIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::dpp_ctrl);
4982 if (DppCtrlIdx >= 0) {
4986 getSTI().
hasFeature(AMDGPU::FeatureDPALU_DPP) &&
4990 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyDppCtrl,
Operands);
4991 Error(S,
isGFX12() ?
"DP ALU dpp only supports row_share"
4992 :
"DP ALU dpp only supports row_newbcast");
4997 int Dpp8Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::dpp8);
4998 bool IsDPP = DppCtrlIdx >= 0 || Dpp8Idx >= 0;
5001 int Src1Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src1);
5007 "invalid operand for instruction");
5012 "src1 immediate operand invalid for instruction");
5022bool AMDGPUAsmParser::validateVccOperand(MCRegister
Reg)
const {
5023 return (
Reg == AMDGPU::VCC && isWave64()) ||
5024 (
Reg == AMDGPU::VCC_LO && isWave32());
5028bool AMDGPUAsmParser::validateVOPLiteral(
const MCInst &Inst,
5031 const MCInstrDesc &
Desc = MII.
get(Opcode);
5032 bool HasMandatoryLiteral = getNamedOperandIdx(Opcode, OpName::imm) != -1;
5039 std::optional<unsigned> LiteralOpIdx;
5042 for (
int OpIdx : OpIndices) {
5046 const MCOperand &MO = Inst.
getOperand(OpIdx);
5052 std::optional<int64_t>
Imm;
5058 bool IsAnotherLiteral =
false;
5059 bool IsForcedLit = findMCOperand(
Operands, OpIdx).isForcedLit();
5060 bool IsForcedLit64 = findMCOperand(
Operands, OpIdx).isForcedLit64();
5061 if (!
Imm.has_value()) {
5063 IsAnotherLiteral =
true;
5064 }
else if (IsForcedLit || IsForcedLit64 || !isInlineConstant(Inst, OpIdx)) {
5069 HasMandatoryLiteral);
5081 (IsForcedLit64 && !HasMandatoryLiteral)) &&
5082 (!has64BitLiterals() ||
Desc.getSize() != 4)) {
5084 "invalid operand for instruction");
5089 if (!IsForcedFP64 && (IsForcedLit64 || !IsValid32Op) &&
5090 OpIdx != getNamedOperandIdx(Opcode, OpName::src0)) {
5092 "invalid operand for instruction");
5097 if (IsValid32Op && !IsForcedFP64 && !IsForcedLit64) {
5098 Value =
static_cast<uint32_t
>(
5106 if (IsAnotherLiteral && !HasMandatoryLiteral &&
5107 !getFeatureBits()[FeatureVOP3Literal]) {
5109 "literal operands are not supported");
5113 if (LiteralOpIdx && IsAnotherLiteral) {
5115 getOperandLoc(
Operands, *LiteralOpIdx)),
5116 "only one unique literal operand is allowed");
5120 if (IsAnotherLiteral)
5121 LiteralOpIdx = OpIdx;
5130 int OpIdx = AMDGPU::getNamedOperandIdx(Inst.
getOpcode(), Name);
5144bool AMDGPUAsmParser::validateAGPRLdSt(
const MCInst &Inst)
const {
5150 ? AMDGPU::OpName::data0
5151 : AMDGPU::OpName::vdata;
5153 const MCRegisterInfo *
MRI = getMRI();
5159 if (Data2Areg >= 0 && Data2Areg != DataAreg)
5163 auto FB = getFeatureBits();
5164 if (FB[AMDGPU::FeatureGFX90AInsts]) {
5165 if (DataAreg < 0 || DstAreg < 0)
5167 return DstAreg == DataAreg;
5170 return DstAreg < 1 && DataAreg < 1;
5173bool AMDGPUAsmParser::validateVGPRAlign(
const MCInst &Inst)
const {
5174 auto FB = getFeatureBits();
5175 if (!FB[AMDGPU::FeatureRequiresAlignedVGPRs])
5179 const MCRegisterInfo *
MRI = getMRI();
5182 if (FB[AMDGPU::FeatureGFX90AInsts] &&
Opc == AMDGPU::DS_READ_B96_TR_B6_vi)
5185 if (FB[AMDGPU::FeatureGFX1250Insts]) {
5189 case AMDGPU::DS_LOAD_TR6_B96:
5190 case AMDGPU::DS_LOAD_TR6_B96_gfx12:
5194 case AMDGPU::GLOBAL_LOAD_TR6_B96:
5195 case AMDGPU::GLOBAL_LOAD_TR6_B96_gfx1250: {
5199 int VAddrIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::vaddr);
5200 if (VAddrIdx != -1) {
5202 MCRegister
Sub =
MRI->getSubReg(
Op.getReg(), AMDGPU::sub0);
5203 if ((
Sub - AMDGPU::VGPR0) & 1)
5208 case AMDGPU::GLOBAL_LOAD_TR6_B96_SADDR:
5209 case AMDGPU::GLOBAL_LOAD_TR6_B96_SADDR_gfx1250:
5214 const MCRegisterClass &VGPR32 =
MRI->
getRegClass(AMDGPU::VGPR_32RegClassID);
5215 const MCRegisterClass &AGPR32 =
MRI->
getRegClass(AMDGPU::AGPR_32RegClassID);
5221 MCRegister
Sub =
MRI->getSubReg(
Op.getReg(), AMDGPU::sub0);
5235 for (
unsigned i = 1, e =
Operands.size(); i != e; ++i) {
5236 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[i]);
5238 return Op.getStartLoc();
5243bool AMDGPUAsmParser::validateBLGP(
const MCInst &Inst,
5246 int BlgpIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::blgp);
5249 SMLoc BLGPLoc = getBLGPLoc(
Operands);
5252 bool IsNeg = StringRef(BLGPLoc.
getPointer()).starts_with(
"neg:");
5253 auto FB = getFeatureBits();
5254 bool UsesNeg =
false;
5255 if (FB[AMDGPU::FeatureGFX940Insts]) {
5257 case AMDGPU::V_MFMA_F64_16X16X4F64_gfx940_acd:
5258 case AMDGPU::V_MFMA_F64_16X16X4F64_gfx940_vcd:
5259 case AMDGPU::V_MFMA_F64_4X4X4F64_gfx940_acd:
5260 case AMDGPU::V_MFMA_F64_4X4X4F64_gfx940_vcd:
5265 if (IsNeg == UsesNeg)
5268 Error(BLGPLoc, UsesNeg ?
"invalid modifier: blgp is not supported"
5269 :
"invalid modifier: neg is not supported");
5274bool AMDGPUAsmParser::validateWaitCnt(
const MCInst &Inst,
5280 if (
Opc != AMDGPU::S_WAITCNT_EXPCNT_gfx11 &&
5281 Opc != AMDGPU::S_WAITCNT_LGKMCNT_gfx11 &&
5282 Opc != AMDGPU::S_WAITCNT_VMCNT_gfx11 &&
5283 Opc != AMDGPU::S_WAITCNT_VSCNT_gfx11)
5286 int Src0Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::sdst);
5289 if (
Reg == AMDGPU::SGPR_NULL)
5292 Error(getOperandLoc(
Operands, Src0Idx),
"src0 must be null");
5296bool AMDGPUAsmParser::validateDS(
const MCInst &Inst,
5301 return validateGWS(Inst,
Operands);
5306 AMDGPU::getNamedOperandIdx(Inst.
getOpcode(), AMDGPU::OpName::gds);
5311 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyGDS,
Operands);
5312 Error(S,
"gds modifier is not supported on this GPU");
5320bool AMDGPUAsmParser::validateGWS(
const MCInst &Inst,
5322 if (!getFeatureBits()[AMDGPU::FeatureGFX90AInsts])
5326 if (
Opc != AMDGPU::DS_GWS_INIT_vi &&
Opc != AMDGPU::DS_GWS_BARRIER_vi &&
5327 Opc != AMDGPU::DS_GWS_SEMA_BR_vi)
5330 const MCRegisterInfo *
MRI = getMRI();
5331 const MCRegisterClass &VGPR32 =
MRI->
getRegClass(AMDGPU::VGPR_32RegClassID);
5333 AMDGPU::getNamedOperandIdx(Inst.
getOpcode(), AMDGPU::OpName::data0);
5336 auto RegIdx =
Reg - (VGPR32.
contains(
Reg) ? AMDGPU::VGPR0 : AMDGPU::AGPR0);
5338 Error(getOperandLoc(
Operands, Data0Pos),
"vgpr must be even aligned");
5345bool AMDGPUAsmParser::validateCoherencyBits(
const MCInst &Inst,
5349 AMDGPU::getNamedOperandIdx(Inst.
getOpcode(), AMDGPU::OpName::cpol);
5356 if (!hasCacheFillSize()) {
5357 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol,
Operands);
5360 Error(S,
"Cache fill size is not supported on this GPU");
5361 }
else if (!validateCFSBits(Inst,
Operands)) {
5366 if (!hasScaleOffset() && (CPol &
CPol::SCAL)) {
5367 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol,
Operands);
5370 Error(S,
"scale_offset is not supported on this GPU");
5374 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol,
Operands);
5377 Error(S,
"nv is not supported on this GPU");
5381 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol,
Operands);
5384 Error(S,
"scale_offset is not supported for this instruction");
5388 return validateTHAndScopeBits(Inst,
Operands, CPol);
5392 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol,
Operands);
5393 Error(S,
"cache policy is not supported for SMRD instructions");
5397 Error(IDLoc,
"invalid cache policy for SMEM instruction");
5404 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol,
Operands);
5408 "scc modifier is not supported for this instruction on this GPU");
5419 :
"instruction must use glc");
5424 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol,
Operands);
5427 &CStr.data()[CStr.find(
isGFX940() ?
"sc0" :
"glc")]);
5429 :
"instruction must not use glc");
5437bool AMDGPUAsmParser::validateTHAndScopeBits(
const MCInst &Inst,
5439 const unsigned CPol) {
5444 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol,
Operands);
5451 return PrintError(
"th:TH_ATOMIC_RETURN requires a destination operand");
5456 return PrintError(
"instruction must use th:TH_ATOMIC_RETURN");
5464 return PrintError(
"invalid th value for SMEM instruction");
5471 return PrintError(
"scope and th combination is not valid");
5477 return PrintError(
"invalid th value for atomic instructions");
5480 return PrintError(
"invalid th value for store instructions");
5483 return PrintError(
"invalid th value for load instructions");
5489bool AMDGPUAsmParser::validateCFSBits(
const MCInst &Inst,
5491 const unsigned Opcode = Inst.
getOpcode();
5492 const MCInstrDesc &
Desc = MII.
get(Opcode);
5495 SMLoc S = getImmLoc(AMDGPUOperand::ImmTyCPol,
Operands);
5503 return PrintError(
"Cache fill size is only supported for VC operations");
5506bool AMDGPUAsmParser::validateTFE(
const MCInst &Inst,
5510 SMLoc Loc = getImmLoc(AMDGPUOperand::ImmTyTFE,
Operands);
5512 Error(Loc,
"TFE modifier has no meaning for store instructions");
5520bool AMDGPUAsmParser::validateWMMA(
const MCInst &Inst,
5526 int AFmtIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::matrix_a_fmt);
5530 int BFmtIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::matrix_b_fmt);
5533 auto validateFmt = [&](
unsigned Fmt, AMDGPU::OpName SrcOp) ->
bool {
5534 int SrcIdx = AMDGPU::getNamedOperandIdx(
Opc, SrcOp);
5543 "wrong register tuple size for " +
5548 if (!validateFmt(AFmt, AMDGPU::OpName::src0) ||
5549 !validateFmt(BFmt, AMDGPU::OpName::src1))
5553 AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::matrix_a_scale_fmt);
5554 if (AScaleIdx == -1)
5558 AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::matrix_b_scale_fmt);
5562 "invalid matrix and scale format combination");
5569bool AMDGPUAsmParser::validateMonitorSleep(
const MCInst &Inst,
5572 if (
Opc != AMDGPU::S_MONITOR_SLEEP_gfx12 ||
5573 !getSTI().
hasFeature(AMDGPU::FeatureNoSleepForever))
5576 int ImmIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::simm16);
5579 "sleep forever is unsupported on the target");
5586bool AMDGPUAsmParser::validateClusterBarrierIsFirst(
5589 if (
Opc != AMDGPU::S_BARRIER_SIGNAL_ISFIRST_IMM_gfx12 &&
5590 Opc != AMDGPU::S_BARRIER_SIGNAL_ISFIRST_IMM_gfx13)
5593 int Src0Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src0);
5600 "s_barrier_signal_isfirst does not support user_cluster_barrier_id (-3)");
5604bool AMDGPUAsmParser::validateScaleSel(
const MCInst &Inst,
5607 int ScaleSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::scale_sel);
5608 if (ScaleSelIdx == -1)
5612 case AMDGPU::V_CVT_SCALE_PK16_F16_FP6_e64_gfx1250:
5613 case AMDGPU::V_CVT_SCALE_PK16_BF16_FP6_e64_gfx1250:
5614 case AMDGPU::V_CVT_SCALE_PK16_F16_BF6_e64_gfx1250:
5615 case AMDGPU::V_CVT_SCALE_PK16_BF16_BF6_e64_gfx1250:
5616 case AMDGPU::V_CVT_SCALE_PK16_F32_FP6_e64_gfx1250:
5617 case AMDGPU::V_CVT_SCALE_PK16_F32_BF6_e64_gfx1250:
5618 case AMDGPU::V_CVT_SCALE_PK8_F16_FP4_e64_gfx1250:
5619 case AMDGPU::V_CVT_SCALE_PK8_BF16_FP4_e64_gfx1250:
5620 case AMDGPU::V_CVT_SCALE_PK8_F32_FP4_e64_gfx1250:
5623 case AMDGPU::V_CVT_SCALE_PK8_F16_FP8_e64_gfx1250:
5624 case AMDGPU::V_CVT_SCALE_PK8_BF16_FP8_e64_gfx1250:
5625 case AMDGPU::V_CVT_SCALE_PK8_F16_BF8_e64_gfx1250:
5626 case AMDGPU::V_CVT_SCALE_PK8_BF16_BF8_e64_gfx1250:
5627 case AMDGPU::V_CVT_SCALE_PK8_F32_FP8_e64_gfx1250:
5628 case AMDGPU::V_CVT_SCALE_PK8_F32_BF8_e64_gfx1250:
5635 if (getSTI().
hasFeature(AMDGPU::FeatureBlock16ConversionScaleInsts))
5639 if (ScaleSel < MaxSel)
5643 "scale_sel maximum supported value is " + Twine(MaxSel - 1));
5647bool AMDGPUAsmParser::validateInstruction(
const MCInst &Inst, SMLoc IDLoc,
5649 if (!validateLdsDirect(Inst,
Operands))
5651 if (!validateTrue16OpSel(Inst)) {
5653 "op_sel operand conflicts with 16-bit operand suffix");
5656 if (!validateSOPLiteral(Inst,
Operands))
5658 if (!validateVOPLiteral(Inst,
Operands)) {
5661 if (!validateConstantBusLimitations(Inst,
Operands)) {
5664 if (!validateVOPD(Inst,
Operands)) {
5667 if (!validateIntClampSupported(Inst)) {
5669 "integer clamping is not supported on this GPU");
5672 if (!validateOpSel(Inst)) {
5674 "invalid op_sel operand");
5677 if (!validateNeg(Inst, AMDGPU::OpName::neg_lo)) {
5679 "invalid neg_lo operand");
5682 if (!validateNeg(Inst, AMDGPU::OpName::neg_hi)) {
5684 "invalid neg_hi operand");
5687 if (!validateDPP(Inst,
Operands)) {
5691 if (!validateMIMGD16(Inst)) {
5693 "d16 modifier is not supported on this GPU");
5696 if (!validateMIMGDim(Inst,
Operands)) {
5697 Error(IDLoc,
"missing dim operand");
5700 if (!validateTensorR128(Inst)) {
5702 "instruction must set modifier r128=0");
5705 if (!validateMIMGMSAA(Inst)) {
5707 "invalid dim; must be MSAA type");
5710 if (!validateMIMGDataSize(Inst, IDLoc)) {
5713 if (!validateMIMGAddrSize(Inst, IDLoc))
5715 if (!validateMIMGAtomicDMask(Inst)) {
5717 "invalid atomic image dmask");
5720 if (!validateMIMGGatherDMask(Inst)) {
5722 "invalid image_gather dmask: only one bit must be set");
5725 if (!validateMovrels(Inst,
Operands)) {
5728 if (!validateOffset(Inst,
Operands)) {
5731 if (!validateSMEMSData(Inst,
Operands))
5733 if (!validateBF16InlineConst(Inst,
Operands)) {
5736 if (!validateMAIAccWrite(Inst,
Operands)) {
5739 if (!validateMAISrc2(Inst,
Operands)) {
5742 if (!validateMFMA(Inst,
Operands)) {
5745 if (!validateCoherencyBits(Inst,
Operands, IDLoc)) {
5749 if (!validateAGPRLdSt(Inst)) {
5752 getFeatureBits()[AMDGPU::FeatureGFX90AInsts]
5753 ?
"invalid register class: data and dst should be all VGPR or AGPR"
5754 :
"invalid register class: agpr loads and stores not supported on "
5758 if (!validateVGPRAlign(Inst)) {
5759 Error(IDLoc,
"invalid register class: vgpr tuples must be 64 bit aligned");
5766 if (!validateBLGP(Inst,
Operands)) {
5770 if (!validateDivScale(Inst)) {
5771 Error(IDLoc,
"ABS not allowed in VOP3B instructions");
5774 if (!validateWaitCnt(Inst,
Operands)) {
5777 if (!validateTFE(Inst,
Operands)) {
5780 if (!validateWMMA(Inst,
Operands)) {
5783 if (!validateMonitorSleep(Inst,
Operands)) {
5786 if (!validateClusterBarrierIsFirst(Inst,
Operands)) {
5789 if (!validateScaleSel(Inst,
Operands)) {
5798 unsigned VariantID = 0);
5802 unsigned VariantID);
5804bool AMDGPUAsmParser::isSupportedMnemo(
StringRef Mnemo,
5809bool AMDGPUAsmParser::isSupportedMnemo(StringRef Mnemo,
5810 const FeatureBitset &FBS,
5811 ArrayRef<unsigned> Variants) {
5812 for (
auto Variant : Variants) {
5820bool AMDGPUAsmParser::checkUnsupportedInstruction(StringRef Mnemo,
5822 FeatureBitset FBS = ComputeAvailableFeatures(getFeatureBits());
5825 if (isSupportedMnemo(Mnemo, FBS, getMatchedVariants()))
5830 getParser().clearPendingErrors();
5834 StringRef VariantName = getMatchedVariantName();
5835 if (!VariantName.
empty() && isSupportedMnemo(Mnemo, FBS)) {
5836 return Error(IDLoc, Twine(VariantName,
5837 " variant of this instruction is not supported"));
5841 if (
isGFX10Plus() && getFeatureBits()[AMDGPU::FeatureWavefrontSize64] &&
5842 !getFeatureBits()[AMDGPU::FeatureWavefrontSize32]) {
5844 FeatureBitset FeaturesWS32 = getFeatureBits();
5845 FeaturesWS32.
flip(AMDGPU::FeatureWavefrontSize64)
5846 .
flip(AMDGPU::FeatureWavefrontSize32);
5847 FeatureBitset AvailableFeaturesWS32 =
5848 ComputeAvailableFeatures(FeaturesWS32);
5850 if (isSupportedMnemo(Mnemo, AvailableFeaturesWS32, getMatchedVariants()))
5851 return Error(IDLoc,
"instruction requires wavesize=32");
5855 if (isSupportedMnemo(Mnemo, FeatureBitset().set())) {
5856 return Error(IDLoc,
"instruction not supported on this GPU (" +
5857 getSTI().
getCPU() +
")" +
": " + Mnemo);
5862 return Error(IDLoc,
"invalid instruction" + Suggestion);
5868 const auto &
Op = ((AMDGPUOperand &)*
Operands[InvalidOprIdx]);
5869 if (
Op.isToken() && InvalidOprIdx > 1) {
5870 const auto &PrevOp = ((AMDGPUOperand &)*
Operands[InvalidOprIdx - 1]);
5871 return PrevOp.isToken() && PrevOp.getToken() ==
"::";
5876bool AMDGPUAsmParser::matchAndEmitInstruction(SMLoc IDLoc,
unsigned &Opcode,
5880 bool MatchingInlineAsm) {
5883 unsigned Result = Match_Success;
5888 auto atLeastAsSpecific = [](
unsigned New,
unsigned Cur) {
5889 auto rank = [](
unsigned M) {
5890 return M == Match_MnemonicFail ? 1
5891 :
M == Match_InvalidOperand ? 2
5892 :
M == Match_MissingFeature ? 3
5895 return rank(New) >= rank(Cur);
5898 for (
auto Variant : getMatchedVariants()) {
5901 MatchInstructionImpl(
Operands, Inst, EI, MatchingInlineAsm, Variant);
5902 if (R == Match_Success || atLeastAsSpecific(R, Result)) {
5906 if (R == Match_Success)
5910 if (Result == Match_Success) {
5911 if (!validateInstruction(Inst, IDLoc,
Operands)) {
5914 emitTargetDirective();
5915 Out.emitInstruction(Inst, getSTI());
5922 if (checkUnsupportedInstruction(Mnemo, IDLoc)) {
5929 case Match_MissingFeature:
5933 return Error(IDLoc,
"operands are not valid for this GPU or mode");
5935 case Match_InvalidOperand: {
5936 SMLoc ErrorLoc = IDLoc;
5937 if (ErrorInfo != ~0ULL) {
5938 if (ErrorInfo >=
Operands.size()) {
5939 return Error(IDLoc,
"too few operands for instruction");
5941 AMDGPUOperand &ErrorOp = (AMDGPUOperand &)*
Operands[ErrorInfo];
5942 ErrorLoc = ErrorOp.getStartLoc();
5943 if (ErrorLoc == SMLoc())
5947 return Error(ErrorLoc,
"invalid VOPDY instruction");
5949 return Error(ErrorLoc,
"invalid operand for instruction");
5952 case Match_MnemonicFail:
5958bool AMDGPUAsmParser::ParseAsAbsoluteExpression(uint32_t &Ret) {
5963 if (getParser().parseAbsoluteExpression(Tmp)) {
5966 Ret =
static_cast<uint32_t
>(Tmp);
5970bool AMDGPUAsmParser::ParseDirectiveAMDGCNTarget() {
5971 if (!getSTI().getTargetTriple().isAMDGCN())
5972 return TokError(
"directive only supported for amdgcn architecture");
5974 std::string TargetIDDirective;
5975 SMLoc TargetStart = getTok().getLoc();
5976 if (getParser().parseEscapedString(TargetIDDirective))
5979 std::optional<AMDGPU::TargetID> MaybeParsed =
5982 return getParser().Error(TargetStart,
5983 "malformed target id '" + TargetIDDirective +
"'");
5986 const Triple &
TT = getSTI().getTargetTriple();
5992 return getParser().Error(
5993 TargetStart,
"target id '" + TargetIDDirective +
5994 "' specifies a processor that is not valid for "
5996 TT.getArchName() +
"'");
5999 const std::optional<AMDGPU::TargetID> &CurrentTargetID =
6000 getTargetStreamer().getTargetID();
6003 const Triple &STITriple = getSTI().getTargetTriple();
6004 if (!DirectiveTriple.isCompatibleWith(STITriple)) {
6005 return getParser().Error(
6006 TargetStart,
".amdgcn_target " + Twine(ParsedTargetID.
toString()) +
6007 " is incompatible with " +
6008 Twine(CurrentTargetID->toString()));
6012 StringRef DirectiveProcessor =
6015 if (DirectiveISA != ISA) {
6016 return getParser().Error(TargetStart,
6017 ".amdgcn_target directive processor " +
6018 Twine(DirectiveProcessor) +
6019 " does not match the specified processor " +
6020 Twine(getSTI().
getCPU()));
6026 CurrentTargetID->getXnackSetting())) {
6028 ".amdgcn_target directive has conflicting xnack settings");
6032 CurrentTargetID->getSramEccSetting())) {
6034 ".amdgcn_target directive has conflicting sramecc settings");
6040 getTargetStreamer().getTargetID()->setXnackSetting(
6042 getTargetStreamer().getTargetID()->setSramEccSetting(
6048bool AMDGPUAsmParser::OutOfRangeError(SMRange
Range) {
6052bool AMDGPUAsmParser::calculateGPRBlocks(
6053 const FeatureBitset &Features,
const MCExpr *VCCUsed,
6054 const MCExpr *FlatScrUsed,
bool XNACKUsed,
6055 std::optional<bool> EnableWavefrontSize32,
const MCExpr *NextFreeVGPR,
6056 SMRange VGPRRange,
const MCExpr *NextFreeSGPR, SMRange SGPRRange,
6057 const MCExpr *&VGPRBlocks,
const MCExpr *&SGPRBlocks) {
6062 const MCExpr *
NumSGPRs = NextFreeSGPR;
6063 int64_t EvaluatedSGPRs;
6065 if (
ISA.Major >= 10)
6070 if (
NumSGPRs->evaluateAsAbsolute(EvaluatedSGPRs) &&
ISA.Major >= 8 &&
6071 !Features.
test(FeatureSGPRInitBug) &&
6072 static_cast<uint64_t>(EvaluatedSGPRs) > MaxAddressableNumSGPRs)
6073 return OutOfRangeError(SGPRRange);
6075 const MCExpr *ExtraSGPRs =
6079 if (
NumSGPRs->evaluateAsAbsolute(EvaluatedSGPRs) &&
6080 (
ISA.Major <= 7 || Features.
test(FeatureSGPRInitBug)) &&
6081 static_cast<uint64_t>(EvaluatedSGPRs) > MaxAddressableNumSGPRs)
6082 return OutOfRangeError(SGPRRange);
6084 if (Features.
test(FeatureSGPRInitBug))
6091 auto GetNumGPRBlocks = [&Ctx](
const MCExpr *NumGPR,
6092 unsigned Granule) ->
const MCExpr * {
6096 const MCExpr *AlignToGPR =
6098 const MCExpr *DivGPR =
6104 VGPRBlocks = GetNumGPRBlocks(
6113bool AMDGPUAsmParser::ParseDirectiveAMDHSAKernel() {
6114 if (!getSTI().getTargetTriple().isAMDGCN())
6115 return TokError(
"directive only supported for amdgcn architecture");
6118 return TokError(
"directive only supported for amdhsa OS");
6120 StringRef KernelName;
6121 if (getParser().parseIdentifier(KernelName))
6128 AMDGPU::MCKernelDescriptor KD =
6138 const MCExpr *NextFreeVGPR = ZeroExpr;
6140 const MCExpr *NamedBarCnt = ZeroExpr;
6145 const MCExpr *NextFreeSGPR = ZeroExpr;
6148 unsigned ImpliedUserSGPRCount = 0;
6152 std::optional<unsigned> ExplicitUserSGPRCount;
6153 const MCExpr *ReserveVCC = OneExpr;
6154 const MCExpr *ReserveFlatScr = OneExpr;
6155 std::optional<bool> EnableWavefrontSize32;
6162 SMRange IDRange = getTok().getLocRange();
6163 if (!parseId(ID,
"expected .amdhsa_ directive or .end_amdhsa_kernel"))
6166 if (ID ==
".end_amdhsa_kernel")
6169 if (!Seen.
insert(ID).second)
6170 return TokError(
".amdhsa_ directives cannot be repeated");
6172 SMLoc ValStart = getLoc();
6173 const MCExpr *ExprVal;
6174 if (getParser().parseExpression(ExprVal))
6176 SMLoc ValEnd = getLoc();
6177 SMRange ValRange = SMRange(ValStart, ValEnd);
6181 bool EvaluatableExpr;
6182 if ((EvaluatableExpr = ExprVal->evaluateAsAbsolute(IVal))) {
6184 return OutOfRangeError(ValRange);
6188#define PARSE_BITS_ENTRY(FIELD, ENTRY, VALUE, RANGE) \
6189 if (!isUInt<ENTRY##_WIDTH>(Val)) \
6190 return OutOfRangeError(RANGE); \
6191 AMDGPU::MCKernelDescriptor::bits_set(FIELD, VALUE, ENTRY##_SHIFT, ENTRY, \
6196#define EXPR_RESOLVE_OR_ERROR(RESOLVED) \
6198 return Error(IDRange.Start, "directive should have resolvable expression", \
6201 if (ID ==
".amdhsa_group_segment_fixed_size") {
6204 return OutOfRangeError(ValRange);
6206 }
else if (ID ==
".amdhsa_private_segment_fixed_size") {
6209 return OutOfRangeError(ValRange);
6211 }
else if (ID ==
".amdhsa_kernarg_size") {
6213 return OutOfRangeError(ValRange);
6215 }
else if (ID ==
".amdhsa_user_sgpr_count") {
6217 ExplicitUserSGPRCount = Val;
6218 }
else if (ID ==
".amdhsa_user_sgpr_private_segment_buffer") {
6222 "directive is not supported with architected flat scratch",
6225 KERNEL_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_BUFFER,
6228 ImpliedUserSGPRCount += 4;
6229 }
else if (ID ==
".amdhsa_user_sgpr_kernarg_preload_length") {
6232 return Error(IDRange.
Start,
"directive requires gfx90a+", IDRange);
6235 return OutOfRangeError(ValRange);
6239 ImpliedUserSGPRCount += Val;
6240 PreloadLength = Val;
6242 }
else if (ID ==
".amdhsa_user_sgpr_kernarg_preload_offset") {
6245 return Error(IDRange.
Start,
"directive requires gfx90a+", IDRange);
6248 return OutOfRangeError(ValRange);
6252 PreloadOffset = Val;
6253 }
else if (ID ==
".amdhsa_user_sgpr_dispatch_ptr") {
6256 KERNEL_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_PTR, ExprVal,
6259 ImpliedUserSGPRCount += 2;
6260 }
else if (ID ==
".amdhsa_user_sgpr_queue_ptr") {
6263 KERNEL_CODE_PROPERTY_ENABLE_SGPR_QUEUE_PTR, ExprVal,
6266 ImpliedUserSGPRCount += 2;
6267 }
else if (ID ==
".amdhsa_user_sgpr_kernarg_segment_ptr") {
6270 KERNEL_CODE_PROPERTY_ENABLE_SGPR_KERNARG_SEGMENT_PTR,
6273 ImpliedUserSGPRCount += 2;
6274 }
else if (ID ==
".amdhsa_user_sgpr_dispatch_id") {
6277 KERNEL_CODE_PROPERTY_ENABLE_SGPR_DISPATCH_ID, ExprVal,
6280 ImpliedUserSGPRCount += 2;
6281 }
else if (ID ==
".amdhsa_user_sgpr_flat_scratch_init") {
6284 "directive is not supported with architected flat scratch",
6288 KERNEL_CODE_PROPERTY_ENABLE_SGPR_FLAT_SCRATCH_INIT,
6291 ImpliedUserSGPRCount += 2;
6292 }
else if (ID ==
".amdhsa_user_sgpr_private_segment_size") {
6295 KERNEL_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_SIZE,
6298 ImpliedUserSGPRCount += 1;
6299 }
else if (ID ==
".amdhsa_wavefront_size32") {
6302 return Error(IDRange.
Start,
"directive requires gfx10+", IDRange);
6303 EnableWavefrontSize32 = Val;
6305 KERNEL_CODE_PROPERTY_ENABLE_WAVEFRONT_SIZE32, ExprVal,
6307 }
else if (ID ==
".amdhsa_uses_dynamic_stack") {
6309 KERNEL_CODE_PROPERTY_USES_DYNAMIC_STACK, ExprVal,
6311 }
else if (ID ==
".amdhsa_system_sgpr_private_segment_wavefront_offset") {
6314 "directive is not supported with architected flat scratch",
6317 COMPUTE_PGM_RSRC2_ENABLE_PRIVATE_SEGMENT, ExprVal,
6319 }
else if (ID ==
".amdhsa_enable_private_segment") {
6323 "directive is not supported without architected flat scratch",
6326 COMPUTE_PGM_RSRC2_ENABLE_PRIVATE_SEGMENT, ExprVal,
6328 }
else if (ID ==
".amdhsa_system_sgpr_workgroup_id_x") {
6330 COMPUTE_PGM_RSRC2_ENABLE_SGPR_WORKGROUP_ID_X, ExprVal,
6332 }
else if (ID ==
".amdhsa_system_sgpr_workgroup_id_y") {
6334 COMPUTE_PGM_RSRC2_ENABLE_SGPR_WORKGROUP_ID_Y, ExprVal,
6336 }
else if (ID ==
".amdhsa_system_sgpr_workgroup_id_z") {
6338 COMPUTE_PGM_RSRC2_ENABLE_SGPR_WORKGROUP_ID_Z, ExprVal,
6340 }
else if (ID ==
".amdhsa_system_sgpr_workgroup_info") {
6342 COMPUTE_PGM_RSRC2_ENABLE_SGPR_WORKGROUP_INFO, ExprVal,
6344 }
else if (ID ==
".amdhsa_system_vgpr_workitem_id") {
6346 COMPUTE_PGM_RSRC2_ENABLE_VGPR_WORKITEM_ID, ExprVal,
6348 }
else if (ID ==
".amdhsa_next_free_vgpr") {
6349 VGPRRange = ValRange;
6350 NextFreeVGPR = ExprVal;
6351 }
else if (ID ==
".amdhsa_next_free_sgpr") {
6352 SGPRRange = ValRange;
6353 NextFreeSGPR = ExprVal;
6354 }
else if (ID ==
".amdhsa_accum_offset") {
6356 return Error(IDRange.
Start,
"directive requires gfx90a+", IDRange);
6357 AccumOffset = ExprVal;
6358 }
else if (ID ==
".amdhsa_named_barrier_count") {
6360 return Error(IDRange.
Start,
"directive requires gfx1250+", IDRange);
6361 NamedBarCnt = ExprVal;
6362 }
else if (ID ==
".amdhsa_reserve_vcc") {
6364 return OutOfRangeError(ValRange);
6365 ReserveVCC = ExprVal;
6366 }
else if (ID ==
".amdhsa_reserve_flat_scratch") {
6368 return Error(IDRange.
Start,
"directive requires gfx7+", IDRange);
6371 "directive is not supported with architected flat scratch",
6374 return OutOfRangeError(ValRange);
6375 ReserveFlatScr = ExprVal;
6376 }
else if (ID ==
".amdhsa_reserve_xnack_mask") {
6378 return Error(IDRange.
Start,
"directive requires gfx8+", IDRange);
6380 return OutOfRangeError(ValRange);
6381 bool XnackOn = getTargetStreamer().getTargetID()->isXnackOnOrAny();
6382 if (Val != XnackOn) {
6383 return getParser().Error(
6385 ".amdhsa_reserve_xnack_mask does not match target id", IDRange);
6387 }
else if (ID ==
".amdhsa_float_round_mode_32") {
6389 COMPUTE_PGM_RSRC1_FLOAT_ROUND_MODE_32, ExprVal,
6391 }
else if (ID ==
".amdhsa_float_round_mode_16_64") {
6393 COMPUTE_PGM_RSRC1_FLOAT_ROUND_MODE_16_64, ExprVal,
6395 }
else if (ID ==
".amdhsa_float_denorm_mode_32") {
6397 COMPUTE_PGM_RSRC1_FLOAT_DENORM_MODE_32, ExprVal,
6399 }
else if (ID ==
".amdhsa_float_denorm_mode_16_64") {
6401 COMPUTE_PGM_RSRC1_FLOAT_DENORM_MODE_16_64, ExprVal,
6403 }
else if (ID ==
".amdhsa_dx10_clamp") {
6404 if (!getSTI().
hasFeature(AMDGPU::FeatureDX10ClampAndIEEEMode))
6405 return Error(IDRange.
Start,
"directive unsupported on gfx1170+",
6408 COMPUTE_PGM_RSRC1_GFX6_GFX11_ENABLE_DX10_CLAMP, ExprVal,
6410 }
else if (ID ==
".amdhsa_ieee_mode") {
6411 if (!getSTI().
hasFeature(AMDGPU::FeatureDX10ClampAndIEEEMode))
6412 return Error(IDRange.
Start,
"directive unsupported on gfx1170+",
6415 COMPUTE_PGM_RSRC1_GFX6_GFX11_ENABLE_IEEE_MODE, ExprVal,
6417 }
else if (ID ==
".amdhsa_fp16_overflow") {
6419 return Error(IDRange.
Start,
"directive requires gfx9+", IDRange);
6421 COMPUTE_PGM_RSRC1_GFX9_PLUS_FP16_OVFL, ExprVal,
6423 }
else if (ID ==
".amdhsa_tg_split") {
6425 return Error(IDRange.
Start,
"directive requires gfx90a+", IDRange);
6428 }
else if (ID ==
".amdhsa_workgroup_processor_mode") {
6431 "directive unsupported on " + getSTI().
getCPU(), IDRange);
6433 COMPUTE_PGM_RSRC1_GFX10_PLUS_WGP_MODE, ExprVal,
6435 }
else if (ID ==
".amdhsa_memory_ordered") {
6437 return Error(IDRange.
Start,
"directive requires gfx10+", IDRange);
6439 COMPUTE_PGM_RSRC1_GFX10_PLUS_MEM_ORDERED, ExprVal,
6441 }
else if (ID ==
".amdhsa_forward_progress") {
6443 return Error(IDRange.
Start,
"directive requires gfx10+", IDRange);
6445 COMPUTE_PGM_RSRC1_GFX10_PLUS_FWD_PROGRESS, ExprVal,
6447 }
else if (ID ==
".amdhsa_shared_vgpr_count") {
6449 if (
ISA.Major < 10 ||
ISA.Major >= 12)
6450 return Error(IDRange.
Start,
"directive requires gfx10 or gfx11",
6452 SharedVGPRCount = Val;
6454 COMPUTE_PGM_RSRC3_GFX10_GFX11_SHARED_VGPR_COUNT, ExprVal,
6456 }
else if (ID ==
".amdhsa_inst_pref_size") {
6458 return Error(IDRange.
Start,
"directive requires gfx11+", IDRange);
6459 if (
ISA.Major == 11) {
6461 COMPUTE_PGM_RSRC3_GFX11_INST_PREF_SIZE, ExprVal,
6465 COMPUTE_PGM_RSRC3_GFX12_PLUS_INST_PREF_SIZE, ExprVal,
6468 }
else if (ID ==
".amdhsa_exception_fp_ieee_invalid_op") {
6471 COMPUTE_PGM_RSRC2_ENABLE_EXCEPTION_IEEE_754_FP_INVALID_OPERATION,
6473 }
else if (ID ==
".amdhsa_exception_fp_denorm_src") {
6475 COMPUTE_PGM_RSRC2_ENABLE_EXCEPTION_FP_DENORMAL_SOURCE,
6477 }
else if (ID ==
".amdhsa_exception_fp_ieee_div_zero") {
6480 COMPUTE_PGM_RSRC2_ENABLE_EXCEPTION_IEEE_754_FP_DIVISION_BY_ZERO,
6482 }
else if (ID ==
".amdhsa_exception_fp_ieee_overflow") {
6484 COMPUTE_PGM_RSRC2_ENABLE_EXCEPTION_IEEE_754_FP_OVERFLOW,
6486 }
else if (ID ==
".amdhsa_exception_fp_ieee_underflow") {
6488 COMPUTE_PGM_RSRC2_ENABLE_EXCEPTION_IEEE_754_FP_UNDERFLOW,
6490 }
else if (ID ==
".amdhsa_exception_fp_ieee_inexact") {
6492 COMPUTE_PGM_RSRC2_ENABLE_EXCEPTION_IEEE_754_FP_INEXACT,
6494 }
else if (ID ==
".amdhsa_exception_int_div_zero") {
6496 COMPUTE_PGM_RSRC2_ENABLE_EXCEPTION_INT_DIVIDE_BY_ZERO,
6498 }
else if (ID ==
".amdhsa_round_robin_scheduling") {
6500 return Error(IDRange.
Start,
"directive requires gfx12+", IDRange);
6502 COMPUTE_PGM_RSRC1_GFX12_PLUS_ENABLE_WG_RR_EN, ExprVal,
6505 return Error(IDRange.
Start,
"unknown .amdhsa_kernel directive", IDRange);
6508#undef PARSE_BITS_ENTRY
6511 if (!Seen.
contains(
".amdhsa_next_free_vgpr"))
6512 return TokError(
".amdhsa_next_free_vgpr directive is required");
6514 if (!Seen.
contains(
".amdhsa_next_free_sgpr"))
6515 return TokError(
".amdhsa_next_free_sgpr directive is required");
6517 unsigned UserSGPRCount = ExplicitUserSGPRCount.value_or(ImpliedUserSGPRCount);
6519 return TokError(
"too many user SGPRs enabled, found " +
6520 Twine(UserSGPRCount) +
", but only " +
6526 if (PreloadLength) {
6532 const MCExpr *VGPRBlocks;
6533 const MCExpr *SGPRBlocks;
6534 if (calculateGPRBlocks(getFeatureBits(), ReserveVCC, ReserveFlatScr,
6535 getTargetStreamer().getTargetID()->isXnackOnOrAny(),
6536 EnableWavefrontSize32, NextFreeVGPR, VGPRRange,
6537 NextFreeSGPR, SGPRRange, VGPRBlocks, SGPRBlocks))
6540 int64_t EvaluatedVGPRBlocks;
6541 bool VGPRBlocksEvaluatable =
6542 VGPRBlocks->evaluateAsAbsolute(EvaluatedVGPRBlocks);
6543 if (VGPRBlocksEvaluatable &&
6545 static_cast<uint64_t>(EvaluatedVGPRBlocks))) {
6546 return OutOfRangeError(VGPRRange);
6550 COMPUTE_PGM_RSRC1_GRANULATED_WORKITEM_VGPR_COUNT_SHIFT,
6551 COMPUTE_PGM_RSRC1_GRANULATED_WORKITEM_VGPR_COUNT,
getContext());
6553 int64_t EvaluatedSGPRBlocks;
6554 if (SGPRBlocks->evaluateAsAbsolute(EvaluatedSGPRBlocks) &&
6556 static_cast<uint64_t>(EvaluatedSGPRBlocks)))
6557 return OutOfRangeError(SGPRRange);
6560 COMPUTE_PGM_RSRC1_GRANULATED_WAVEFRONT_SGPR_COUNT_SHIFT,
6561 COMPUTE_PGM_RSRC1_GRANULATED_WAVEFRONT_SGPR_COUNT,
getContext());
6563 if (ExplicitUserSGPRCount && ImpliedUserSGPRCount > *ExplicitUserSGPRCount)
6564 return TokError(
"amdgpu_user_sgpr_count smaller than implied by "
6565 "enabled user SGPRs");
6571 COMPUTE_PGM_RSRC2_GFX125_USER_SGPR_COUNT_SHIFT,
6572 COMPUTE_PGM_RSRC2_GFX125_USER_SGPR_COUNT,
getContext());
6577 COMPUTE_PGM_RSRC2_GFX6_GFX120_USER_SGPR_COUNT_SHIFT,
6578 COMPUTE_PGM_RSRC2_GFX6_GFX120_USER_SGPR_COUNT,
getContext());
6583 return TokError(
"Kernarg size should be resolvable");
6585 if (PreloadLength && kernarg_size &&
6586 (PreloadLength * 4 + PreloadOffset * 4 > kernarg_size))
6587 return TokError(
"Kernarg preload length + offset is larger than the "
6588 "kernarg segment size");
6591 if (!Seen.
contains(
".amdhsa_accum_offset"))
6592 return TokError(
".amdhsa_accum_offset directive is required");
6593 int64_t EvaluatedAccum;
6594 bool AccumEvaluatable = AccumOffset->evaluateAsAbsolute(EvaluatedAccum);
6595 uint64_t UEvaluatedAccum = EvaluatedAccum;
6596 if (AccumEvaluatable &&
6597 (UEvaluatedAccum < 4 || UEvaluatedAccum > 256 || (UEvaluatedAccum & 3)))
6598 return TokError(
"accum_offset should be in range [4..256] in "
6601 int64_t EvaluatedNumVGPR;
6602 if (NextFreeVGPR->evaluateAsAbsolute(EvaluatedNumVGPR) &&
6606 return TokError(
"accum_offset exceeds total VGPR allocation");
6612 COMPUTE_PGM_RSRC3_GFX90A_ACCUM_OFFSET_SHIFT,
6613 COMPUTE_PGM_RSRC3_GFX90A_ACCUM_OFFSET,
6619 COMPUTE_PGM_RSRC3_GFX125_NAMED_BAR_CNT_SHIFT,
6620 COMPUTE_PGM_RSRC3_GFX125_NAMED_BAR_CNT,
6623 if (
ISA.Major >= 10 &&
ISA.Major < 12) {
6625 if (SharedVGPRCount && EnableWavefrontSize32 && *EnableWavefrontSize32) {
6626 return TokError(
"shared_vgpr_count directive not valid on "
6627 "wavefront size 32");
6630 if (VGPRBlocksEvaluatable &&
6631 (SharedVGPRCount * 2 +
static_cast<uint64_t>(EvaluatedVGPRBlocks) >
6633 return TokError(
"shared_vgpr_count*2 + "
6634 "compute_pgm_rsrc1.GRANULATED_WORKITEM_VGPR_COUNT cannot "
6639 emitTargetDirective();
6640 getTargetStreamer().EmitAmdhsaKernelDescriptor(getSTI(), KernelName, KD,
6641 NextFreeVGPR, NextFreeSGPR,
6642 ReserveVCC, ReserveFlatScr);
6646bool AMDGPUAsmParser::ParseDirectiveAMDHSACodeObjectVersion() {
6648 if (ParseAsAbsoluteExpression(
Version))
6651 getTargetStreamer().EmitDirectiveAMDHSACodeObjectVersion(
Version);
6652 emitTargetDirective();
6656bool AMDGPUAsmParser::ParseAMDKernelCodeTValue(StringRef ID,
6657 AMDGPUMCKernelCodeT &
C) {
6660 if (ID ==
"max_scratch_backing_memory_byte_size") {
6661 Parser.eatToEndOfStatement();
6665 SmallString<40> ErrStr;
6666 raw_svector_ostream Err(ErrStr);
6667 if (!
C.ParseKernelCodeT(ID, getParser(), Err)) {
6668 return TokError(Err.
str());
6672 if (ID ==
"enable_wavefront_size32") {
6675 return TokError(
"enable_wavefront_size32=1 is only allowed on GFX10+");
6677 return TokError(
"enable_wavefront_size32=1 requires +WavefrontSize32");
6680 return TokError(
"enable_wavefront_size32=0 requires +WavefrontSize64");
6684 if (ID ==
"wavefront_size") {
6685 if (
C.wavefront_size == 5) {
6687 return TokError(
"wavefront_size=5 is only allowed on GFX10+");
6689 return TokError(
"wavefront_size=5 requires +WavefrontSize32");
6690 }
else if (
C.wavefront_size == 6) {
6692 return TokError(
"wavefront_size=6 requires +WavefrontSize64");
6699bool AMDGPUAsmParser::ParseDirectiveAMDKernelCodeT() {
6700 AMDGPUMCKernelCodeT KernelCode;
6710 if (!parseId(ID,
"expected value identifier or .end_amd_kernel_code_t"))
6713 if (ID ==
".end_amd_kernel_code_t")
6716 if (ParseAMDKernelCodeTValue(ID, KernelCode))
6721 getTargetStreamer().EmitAMDKernelCodeT(KernelCode);
6726bool AMDGPUAsmParser::ParseDirectiveAMDGPUHsaKernel() {
6727 StringRef KernelName;
6728 if (!parseId(KernelName,
"expected symbol name"))
6731 getTargetStreamer().EmitAMDGPUSymbolType(KernelName,
6738bool AMDGPUAsmParser::ParseDirectiveISAVersion() {
6739 if (!getSTI().getTargetTriple().isAMDGCN()) {
6740 return Error(getLoc(),
6741 ".amd_amdgpu_isa directive is not available on non-amdgcn "
6745 StringRef TargetIDDirective = getLexer().getTok().getStringContents();
6747 std::optional<AMDGPU::TargetID> MaybeParsed =
6750 return Error(getParser().getTok().getLoc(),
6751 "malformed target id '" + TargetIDDirective +
"'");
6754 const Triple &
TT = getSTI().getTargetTriple();
6760 return Error(getParser().getTok().getLoc(),
6761 "target id '" + TargetIDDirective +
6762 "' specifies a processor that is not valid for subarch '" +
6763 TT.getArchName() +
"'");
6766 const std::optional<AMDGPU::TargetID> &CurrentTargetID =
6767 getTargetStreamer().getTargetID();
6770 const Triple &STITriple = getSTI().getTargetTriple();
6771 if (!DirectiveTriple.isCompatibleWith(STITriple)) {
6772 return Error(getParser().getTok().getLoc(),
6773 ".amd_amdgpu_isa " + Twine(ParsedTargetID.
toString()) +
6774 " is incompatible with " +
6775 Twine(CurrentTargetID->toString()));
6779 StringRef DirectiveProcessor =
6782 if (DirectiveISA != ISA) {
6783 return Error(getParser().getTok().getLoc(),
6784 ".amd_amdgpu_isa directive processor " +
6785 Twine(DirectiveProcessor) +
6786 " does not match the specified processor " +
6787 Twine(getSTI().
getCPU()));
6790 getTargetStreamer().EmitISAVersion();
6796bool AMDGPUAsmParser::ParseDirectiveHSAMetadata() {
6799 std::string HSAMetadataString;
6804 if (!getTargetStreamer().EmitHSAMetadataV3(HSAMetadataString))
6805 return Error(getLoc(),
"invalid HSA metadata");
6812bool AMDGPUAsmParser::ParseToEndDirective(
const char *AssemblerDirectiveBegin,
6813 const char *AssemblerDirectiveEnd,
6814 std::string &CollectString) {
6816 raw_string_ostream CollectStream(CollectString);
6818 getLexer().setSkipSpace(
false);
6820 bool FoundEnd =
false;
6823 CollectStream << getTokenStr();
6827 if (trySkipId(AssemblerDirectiveEnd)) {
6832 CollectStream << Parser.parseStringToEndOfStatement()
6833 <<
getContext().getAsmInfo().getSeparatorString();
6835 Parser.eatToEndOfStatement();
6838 getLexer().setSkipSpace(
true);
6841 return TokError(Twine(
"expected directive ") +
6842 Twine(AssemblerDirectiveEnd) + Twine(
" not found"));
6849bool AMDGPUAsmParser::ParseDirectivePALMetadataBegin() {
6855 auto *PALMetadata = getTargetStreamer().getPALMetadata();
6856 if (!PALMetadata->setFromString(
String))
6857 return Error(getLoc(),
"invalid PAL metadata");
6862bool AMDGPUAsmParser::ParseDirectivePALMetadata() {
6865 Twine(
" directive is "
6866 "not available on non-amdpal OSes"))
6870 auto *PALMetadata = getTargetStreamer().getPALMetadata();
6871 PALMetadata->setLegacy();
6874 if (ParseAsAbsoluteExpression(
Key)) {
6875 return TokError(Twine(
"invalid value in ") +
6879 return TokError(Twine(
"expected an even number of values in ") +
6882 if (ParseAsAbsoluteExpression(
Value)) {
6883 return TokError(Twine(
"invalid value in ") +
6886 PALMetadata->setRegister(
Key,
Value);
6895bool AMDGPUAsmParser::ParseDirectiveAMDGPULDS() {
6896 if (getParser().checkForValidSection())
6900 SMLoc NameLoc = getLoc();
6901 if (getParser().parseIdentifier(Name))
6902 return TokError(
"expected identifier in directive");
6905 if (getParser().parseComma())
6911 SMLoc SizeLoc = getLoc();
6912 if (getParser().parseAbsoluteExpression(
Size))
6915 return Error(SizeLoc,
"size must be non-negative");
6916 if (
Size > LocalMemorySize)
6917 return Error(SizeLoc,
"size is too large");
6921 SMLoc AlignLoc = getLoc();
6922 if (getParser().parseAbsoluteExpression(Alignment))
6925 return Error(AlignLoc,
"alignment must be a power of two");
6930 if (Alignment >= 1u << 31)
6931 return Error(AlignLoc,
"alignment is too large");
6937 Symbol->redefineIfPossible();
6938 if (!
Symbol->isUndefined())
6939 return Error(NameLoc,
"invalid symbol redefinition");
6941 getTargetStreamer().emitAMDGPULDS(Symbol,
Size,
Align(Alignment));
6945bool AMDGPUAsmParser::ParseDirectiveAMDGPUInfo() {
6946 if (getParser().checkForValidSection())
6950 if (getParser().parseIdentifier(FuncName))
6951 return TokError(
"expected symbol name after .amdgpu_info");
6954 AMDGPU::InfoSectionData ParsedInfoData;
6955 AMDGPU::FuncInfo FI;
6957 bool HasScalarAttrs =
false;
6964 SMLoc IDLoc = getLoc();
6965 if (!parseId(ID,
"expected directive or .end_amdgpu_info"))
6968 if (ID ==
".end_amdgpu_info")
6976 return Error(IDLoc,
"unknown .amdgpu_info directive '" + ID +
"'");
6978 if (Dir ==
"flags") {
6980 if (getParser().parseAbsoluteExpression(Val))
6983 FI.
UsesVCC = !!(
Flags & AMDGPU::FuncInfoFlags::FUNC_USES_VCC);
6985 !!(
Flags & AMDGPU::FuncInfoFlags::FUNC_USES_FLAT_SCRATCH);
6987 HasScalarAttrs =
true;
6988 }
else if (Dir ==
"num_sgpr") {
6990 if (getParser().parseAbsoluteExpression(Val))
6992 FI.
NumSGPR =
static_cast<uint32_t
>(Val);
6993 HasScalarAttrs =
true;
6994 }
else if (Dir ==
"num_vgpr") {
6996 if (getParser().parseAbsoluteExpression(Val))
6999 HasScalarAttrs =
true;
7000 }
else if (Dir ==
"num_agpr") {
7002 if (getParser().parseAbsoluteExpression(Val))
7005 HasScalarAttrs =
true;
7006 }
else if (Dir ==
"private_segment_size") {
7008 if (getParser().parseAbsoluteExpression(Val))
7011 HasScalarAttrs =
true;
7012 }
else if (Dir ==
"use") {
7014 if (getParser().parseIdentifier(ResName))
7015 return TokError(
"expected resource symbol for .amdgpu_use");
7016 ParsedInfoData.
Uses.push_back(
7017 {FuncSym,
getContext().getOrCreateSymbol(ResName)});
7018 }
else if (Dir ==
"call") {
7020 if (getParser().parseIdentifier(DstName))
7021 return TokError(
"expected callee symbol for .amdgpu_call");
7022 ParsedInfoData.
Calls.push_back(
7023 {FuncSym,
getContext().getOrCreateSymbol(DstName)});
7024 }
else if (Dir ==
"indirect_call") {
7026 if (getParser().parseEscapedString(TypeId))
7027 return TokError(
"expected type ID string for .amdgpu_indirect_call");
7028 ParsedInfoData.
IndirectCalls.push_back({FuncSym, std::move(TypeId)});
7029 }
else if (Dir ==
"typeid") {
7031 if (getParser().parseEscapedString(TypeId))
7032 return TokError(
"expected type ID string for .amdgpu_typeid");
7033 ParsedInfoData.
TypeIds.push_back({FuncSym, std::move(TypeId)});
7035 return Error(IDLoc,
"unknown .amdgpu_info directive '" + ID +
"'");
7040 ParsedInfoData.
Funcs.push_back(std::move(FI));
7042 AMDGPU::InfoSectionData &
Data = InfoData ? *InfoData : InfoData.emplace();
7043 for (AMDGPU::FuncInfo &Func : ParsedInfoData.
Funcs)
7044 Data.Funcs.push_back(std::move(Func));
7045 for (std::pair<MCSymbol *, MCSymbol *> &Use : ParsedInfoData.
Uses)
7046 Data.Uses.push_back(Use);
7047 for (std::pair<MCSymbol *, MCSymbol *> &
Call : ParsedInfoData.
Calls)
7049 for (std::pair<MCSymbol *, std::string> &
IndirectCall :
7052 for (std::pair<MCSymbol *, std::string> &TypeId : ParsedInfoData.
TypeIds)
7053 Data.TypeIds.push_back(std::move(TypeId));
7058void AMDGPUAsmParser::doBeforeLabelEmit(MCSymbol *Symbol, SMLoc IDLoc) {
7065void AMDGPUAsmParser::checkKernelPrologues() {
7066 if (getFeatureBits()[AMDGPU::FeatureRequiresInitialUnclausedVmem]) {
7067 static const unsigned Required[] = {S_MOV_B64_gfx12, V_NOP_e32_gfx12,
7068 GLOBAL_PREFETCH_B8_SADDR_gfx1250};
7069 for (
auto [Sym, Loc,
Offset] : OpcodeStreamSymbols) {
7070 if (!AMDHSAKernelSymbols.
contains(Sym))
7072 ArrayRef<unsigned> Prologue =
ArrayRef(OpcodeStream).drop_front(
Offset);
7073 if (!Prologue.
empty() && Prologue.
front() == S_SETREG_IMM32_B32_gfx12)
7077 "' does not begin with the required prologue "
7078 "sequence: s_mov_b64 followed by v_nop and "
7079 "global_prefetch_b8");
7083 OpcodeStream.
clear();
7084 OpcodeStreamSymbols.clear();
7085 AMDHSAKernelSymbols.
clear();
7088void AMDGPUAsmParser::onEndOfFile() {
7089 emitTargetDirective();
7090 checkKernelPrologues();
7092 getTargetStreamer().emitAMDGPUInfo(*InfoData);
7095bool AMDGPUAsmParser::ParseDirective(AsmToken DirectiveID) {
7096 StringRef IDVal = DirectiveID.
getString();
7099 if (IDVal ==
".amdhsa_kernel")
7100 return ParseDirectiveAMDHSAKernel();
7102 if (IDVal ==
".amdhsa_code_object_version")
7103 return ParseDirectiveAMDHSACodeObjectVersion();
7107 return ParseDirectiveHSAMetadata();
7109 if (IDVal ==
".amd_kernel_code_t")
7110 return ParseDirectiveAMDKernelCodeT();
7112 if (IDVal ==
".amdgpu_hsa_kernel")
7113 return ParseDirectiveAMDGPUHsaKernel();
7115 if (IDVal ==
".amd_amdgpu_isa")
7116 return ParseDirectiveISAVersion();
7120 Twine(
" directive is "
7121 "not available on non-amdhsa OSes"))
7126 if (IDVal ==
".amdgcn_target")
7127 return ParseDirectiveAMDGCNTarget();
7129 if (IDVal ==
".amdgpu_lds")
7130 return ParseDirectiveAMDGPULDS();
7132 if (IDVal ==
".amdgpu_info")
7133 return ParseDirectiveAMDGPUInfo();
7136 return ParseDirectivePALMetadataBegin();
7139 return ParseDirectivePALMetadata();
7144bool AMDGPUAsmParser::subtargetHasRegister(
const MCRegisterInfo &
MRI,
7146 if (
MRI.regsOverlap(TTMP12_TTMP13_TTMP14_TTMP15,
Reg))
7150 if (
MRI.regsOverlap(SGPR104_SGPR105,
Reg))
7151 return hasSGPR104_SGPR105();
7154 case SRC_SHARED_BASE_LO:
7155 case SRC_SHARED_BASE:
7156 case SRC_SHARED_LIMIT_LO:
7157 case SRC_SHARED_LIMIT:
7159 case SRC_PRIVATE_BASE_LO:
7160 case SRC_PRIVATE_BASE:
7161 case SRC_PRIVATE_LIMIT_LO:
7162 case SRC_PRIVATE_LIMIT:
7164 case SRC_FLAT_SCRATCH_BASE_LO:
7165 case SRC_FLAT_SCRATCH_BASE_HI:
7166 return hasGloballyAddressableScratch();
7167 case SRC_POPS_EXITING_WAVE_ID:
7180 getTargetStreamer().getTargetID()->isXnackSupported();
7209 if (
MRI.regsOverlap(SGPR102_SGPR103,
Reg))
7210 return hasSGPR102_SGPR103();
7218 ParseStatus Res = parseVOPD(
Operands);
7223 Res = MatchOperandParserImpl(
Operands, Mnemonic);
7235 SMLoc LBraceLoc = getLoc();
7240 auto Loc = getLoc();
7243 Error(Loc,
"expected a register");
7247 RBraceLoc = getLoc();
7252 "expected a comma or a closing square bracket"))
7256 if (
Operands.size() - Prefix > 1) {
7258 AMDGPUOperand::CreateToken(
this,
"[", LBraceLoc));
7259 Operands.push_back(AMDGPUOperand::CreateToken(
this,
"]", RBraceLoc));
7268StringRef AMDGPUAsmParser::parseMnemonicSuffix(StringRef Name) {
7270 setForcedEncodingSize(0);
7271 setForcedDPP(
false);
7272 setForcedSDWA(
false);
7274 if (
Name.consume_back(
"_e64_dpp")) {
7276 setForcedEncodingSize(64);
7279 if (
Name.consume_back(
"_e64")) {
7280 setForcedEncodingSize(64);
7283 if (
Name.consume_back(
"_e32")) {
7284 setForcedEncodingSize(32);
7287 if (
Name.consume_back(
"_dpp")) {
7291 if (
Name.consume_back(
"_sdwa")) {
7292 setForcedSDWA(
true);
7300 unsigned VariantID);
7306 Name = parseMnemonicSuffix(Name);
7312 Operands.push_back(AMDGPUOperand::CreateToken(
this, Name, NameLoc));
7314 bool IsMIMG = Name.starts_with(
"image_");
7317 OperandMode
Mode = OperandMode_Default;
7319 Mode = OperandMode_NSA;
7323 checkUnsupportedInstruction(Name, NameLoc);
7324 if (!Parser.hasPendingError()) {
7327 :
"not a valid operand.";
7347ParseStatus AMDGPUAsmParser::parseTokenOp(StringRef Name,
7350 if (!trySkipId(Name))
7353 Operands.push_back(AMDGPUOperand::CreateToken(
this, Name, S));
7357ParseStatus AMDGPUAsmParser::parseIntWithPrefix(
const char *Prefix,
7366ParseStatus AMDGPUAsmParser::parseIntWithPrefix(
7368 std::function<
bool(int64_t &)> ConvertResult) {
7372 ParseStatus Res = parseIntWithPrefix(Prefix,
Value);
7376 if (ConvertResult && !ConvertResult(
Value)) {
7377 Error(S,
"invalid " + StringRef(Prefix) +
" value.");
7380 Operands.push_back(AMDGPUOperand::CreateImm(
this,
Value, S, ImmTy));
7384ParseStatus AMDGPUAsmParser::parseOperandArrayWithPrefix(
7386 bool (*ConvertResult)(int64_t &)) {
7395 const unsigned MaxSize = 4;
7399 for (
int I = 0;; ++
I) {
7401 SMLoc Loc = getLoc();
7405 if (
Op != 0 &&
Op != 1)
7406 return Error(Loc,
"invalid " + StringRef(Prefix) +
" value.");
7413 if (
I + 1 == MaxSize)
7414 return Error(getLoc(),
"expected a closing square bracket");
7420 Operands.push_back(AMDGPUOperand::CreateImm(
this, Val, S, ImmTy));
7424ParseStatus AMDGPUAsmParser::parseNamedBit(StringRef Name,
7426 AMDGPUOperand::ImmTy ImmTy,
7427 bool IgnoreNegative) {
7431 if (trySkipId(Name)) {
7433 }
else if (trySkipId(
"no", Name)) {
7442 return Error(S,
"r128 modifier is not supported on this GPU");
7443 if (Name ==
"a16" && !
hasA16())
7444 return Error(S,
"a16 modifier is not supported on this GPU");
7446 if (Bit == 0 && Name ==
"gds") {
7449 return Error(S,
"nogds is not allowed");
7452 if (
isGFX9() && ImmTy == AMDGPUOperand::ImmTyA16)
7453 ImmTy = AMDGPUOperand::ImmTyR128A16;
7455 Operands.push_back(AMDGPUOperand::CreateImm(
this, Bit, S, ImmTy));
7459unsigned AMDGPUAsmParser::getCPolKind(StringRef Id, StringRef Mnemo,
7460 bool &Disabling)
const {
7461 Disabling =
Id.consume_front(
"no");
7464 return StringSwitch<unsigned>(Id)
7471 return StringSwitch<unsigned>(Id)
7481 SMLoc StringLoc = getLoc();
7483 int64_t CPolVal = 0;
7504 ResScope = parseScope(
Operands, Scope);
7517 if (trySkipId(
"nv")) {
7521 }
else if (trySkipId(
"no",
"nv")) {
7528 if (trySkipId(
"scale_offset")) {
7532 }
else if (trySkipId(
"no",
"scale_offset")) {
7556 Operands.push_back(AMDGPUOperand::CreateImm(
this, CPolVal, StringLoc,
7557 AMDGPUOperand::ImmTyCPol));
7562 SMLoc OpLoc = getLoc();
7563 unsigned Enabled = 0, Seen = 0;
7567 unsigned CPol = getCPolKind(getId(), Mnemo, Disabling);
7574 return Error(S,
"dlc modifier is not supported on this GPU");
7577 return Error(S,
"scc modifier is not supported on this GPU");
7580 return Error(S,
"duplicate cache policy modifier");
7592 AMDGPUOperand::CreateImm(
this,
Enabled, OpLoc, AMDGPUOperand::ImmTyCPol));
7601 ParseStatus Res = parseStringOrIntWithPrefix(
7602 Operands,
"scope", {
"SCOPE_CU",
"SCOPE_SE",
"SCOPE_DEV",
"SCOPE_SYS"},
7616 ParseStatus Res = parseStringWithPrefix(
"th",
Value, StringLoc);
7620 if (
Value ==
"TH_DEFAULT")
7622 else if (
Value ==
"TH_STORE_LU" ||
Value ==
"TH_LOAD_WB" ||
7623 Value ==
"TH_LOAD_NT_WB") {
7624 return Error(StringLoc,
"invalid th value");
7625 }
else if (
Value.consume_front(
"TH_ATOMIC_")) {
7627 }
else if (
Value.consume_front(
"TH_LOAD_")) {
7629 }
else if (
Value.consume_front(
"TH_STORE_")) {
7632 return Error(StringLoc,
"invalid th value");
7635 if (
Value ==
"BYPASS")
7640 TH |= StringSwitch<int64_t>(
Value)
7650 .Default(0xffffffff);
7652 TH |= StringSwitch<int64_t>(
Value)
7663 .Default(0xffffffff);
7666 if (TH == 0xffffffff)
7667 return Error(StringLoc,
"invalid th value");
7676 ParseStatus Res = parseStringOrIntWithPrefix(
7677 Operands,
"cfs", {
"CFS_256B",
"CFS_128B",
"CFS_64B",
"CFS_32B"},
CFS);
7687 AMDGPUAsmParser::OptionalImmIndexMap &OptionalIdx,
7688 AMDGPUOperand::ImmTy ImmT, int64_t
Default = 0,
7689 std::optional<unsigned> InsertAt = std::nullopt) {
7690 auto i = OptionalIdx.find(ImmT);
7691 if (i != OptionalIdx.end()) {
7692 unsigned Idx = i->second;
7693 const AMDGPUOperand &
Op =
7694 static_cast<const AMDGPUOperand &
>(*
Operands[
Idx]);
7698 Op.addImmOperands(Inst, 1);
7700 if (InsertAt.has_value())
7707ParseStatus AMDGPUAsmParser::parseStringWithPrefix(StringRef Prefix,
7713 StringLoc = getLoc();
7718ParseStatus AMDGPUAsmParser::parseStringOrIntWithPrefix(
7724 SMLoc StringLoc = getLoc();
7728 Value = getTokenStr();
7732 if (
Value == Ids[IntVal])
7737 if (IntVal < 0 || IntVal >= (int64_t)Ids.
size())
7738 return Error(StringLoc,
"invalid " + Twine(Name) +
" value");
7743ParseStatus AMDGPUAsmParser::parseStringOrIntWithPrefix(
7745 AMDGPUOperand::ImmTy
Type) {
7749 ParseStatus Res = parseStringOrIntWithPrefix(
Operands, Name, Ids, IntVal);
7751 Operands.push_back(AMDGPUOperand::CreateImm(
this, IntVal, S,
Type));
7760ParseStatus AMDGPUAsmParser::tryParseFmt(
const char *Pref, int64_t MaxVal,
7763 SMLoc Loc = getLoc();
7765 ParseStatus Res = parseIntWithPrefix(Pref, Val);
7769 if (Val < 0 || Val > MaxVal)
7770 return Error(Loc, Twine(
"out of range ", StringRef(Pref)));
7777 AMDGPUOperand::ImmTy ImmTy) {
7778 const char *Pref =
"index_key";
7780 SMLoc Loc = getLoc();
7781 auto Res = parseIntWithPrefix(Pref, ImmVal);
7785 if ((ImmTy == AMDGPUOperand::ImmTyIndexKey16bit ||
7786 ImmTy == AMDGPUOperand::ImmTyIndexKey32bit) &&
7787 (ImmVal < 0 || ImmVal > 1))
7788 return Error(Loc, Twine(
"out of range ", StringRef(Pref)));
7790 if (ImmTy == AMDGPUOperand::ImmTyIndexKey8bit && (ImmVal < 0 || ImmVal > 3))
7791 return Error(Loc, Twine(
"out of range ", StringRef(Pref)));
7793 Operands.push_back(AMDGPUOperand::CreateImm(
this, ImmVal, Loc, ImmTy));
7798 return tryParseIndexKey(
Operands, AMDGPUOperand::ImmTyIndexKey8bit);
7802 return tryParseIndexKey(
Operands, AMDGPUOperand::ImmTyIndexKey16bit);
7806 return tryParseIndexKey(
Operands, AMDGPUOperand::ImmTyIndexKey32bit);
7811 AMDGPUOperand::ImmTy
Type) {
7817 return tryParseMatrixFMT(
Operands,
"matrix_a_fmt",
7818 AMDGPUOperand::ImmTyMatrixAFMT);
7822 return tryParseMatrixFMT(
Operands,
"matrix_b_fmt",
7823 AMDGPUOperand::ImmTyMatrixBFMT);
7828 AMDGPUOperand::ImmTy
Type) {
7834 return tryParseMatrixScale(
Operands,
"matrix_a_scale",
7835 AMDGPUOperand::ImmTyMatrixAScale);
7839 return tryParseMatrixScale(
Operands,
"matrix_b_scale",
7840 AMDGPUOperand::ImmTyMatrixBScale);
7845 AMDGPUOperand::ImmTy
Type) {
7851 return tryParseMatrixScaleFmt(
Operands,
"matrix_a_scale_fmt",
7852 AMDGPUOperand::ImmTyMatrixAScaleFmt);
7856 return tryParseMatrixScaleFmt(
Operands,
"matrix_b_scale_fmt",
7857 AMDGPUOperand::ImmTyMatrixBScaleFmt);
7862ParseStatus AMDGPUAsmParser::parseDfmtNfmt(int64_t &
Format) {
7863 using namespace llvm::AMDGPU::MTBUFFormat;
7868 auto TryAfterComma = [&](
const char *Pref, int64_t MaxVal,
7869 int64_t &Fmt) -> ParseStatus {
7871 return Error(getLoc(),
"expected a comma");
7872 AsmToken NextTokens[2];
7873 peekTokens(NextTokens);
7878 return tryParseFmt(Pref, MaxVal, Fmt);
7883 ParseStatus Res = tryParseFmt(
"dfmt", DFMT_MAX, Dfmt);
7885 Res = TryAfterComma(
"nfmt", NFMT_MAX, Nfmt);
7887 Res = tryParseFmt(
"nfmt", NFMT_MAX, Nfmt);
7889 Res = TryAfterComma(
"dfmt", DFMT_MAX, Dfmt);
7898ParseStatus AMDGPUAsmParser::parseUfmt(int64_t &
Format) {
7902bool AMDGPUAsmParser::matchDfmtNfmt(int64_t &Dfmt, int64_t &Nfmt,
7903 StringRef FormatStr, SMLoc Loc) {
7904 using namespace llvm::AMDGPU::MTBUFFormat;
7908 if (
Format != DFMT_UNDEF) {
7914 if (
Format != NFMT_UNDEF) {
7919 Error(Loc,
"unsupported format");
7923ParseStatus AMDGPUAsmParser::parseSymbolicSplitFormat(StringRef FormatStr,
7926 using namespace llvm::AMDGPU::MTBUFFormat;
7930 if (!matchDfmtNfmt(Dfmt, Nfmt, FormatStr, FormatLoc))
7935 SMLoc Loc = getLoc();
7936 if (!parseId(Str,
"expected a format string") ||
7937 !matchDfmtNfmt(Dfmt, Nfmt, Str, Loc))
7939 if (Dfmt == DFMT_UNDEF)
7940 return Error(Loc,
"duplicate numeric format");
7941 if (Nfmt == NFMT_UNDEF)
7942 return Error(Loc,
"duplicate data format");
7945 Dfmt = (Dfmt ==
DFMT_UNDEF) ? DFMT_DEFAULT : Dfmt;
7946 Nfmt = (Nfmt ==
NFMT_UNDEF) ? NFMT_DEFAULT : Nfmt;
7950 if (Ufmt == UFMT_UNDEF)
7951 return Error(FormatLoc,
"unsupported format");
7960ParseStatus AMDGPUAsmParser::parseSymbolicUnifiedFormat(StringRef FormatStr,
7963 using namespace llvm::AMDGPU::MTBUFFormat;
7966 if (Id == UFMT_UNDEF)
7970 return Error(Loc,
"unified format is not supported on this GPU");
7976ParseStatus AMDGPUAsmParser::parseNumericFormat(int64_t &
Format) {
7977 using namespace llvm::AMDGPU::MTBUFFormat;
7978 SMLoc Loc = getLoc();
7983 return Error(Loc,
"out of range format");
7988ParseStatus AMDGPUAsmParser::parseSymbolicOrNumericFormat(int64_t &
Format) {
7989 using namespace llvm::AMDGPU::MTBUFFormat;
7995 StringRef FormatStr;
7996 SMLoc Loc = getLoc();
7997 if (!parseId(FormatStr,
"expected a format string"))
8000 auto Res = parseSymbolicUnifiedFormat(FormatStr, Loc,
Format);
8002 Res = parseSymbolicSplitFormat(FormatStr, Loc,
Format);
8012 return parseNumericFormat(
Format);
8016 SMLoc Loc = getLoc();
8018 ParseStatus Res = parseSymbolicOrNumericFormat(
Format);
8023 AMDGPUOperand::CreateImm(
this,
Format, Loc, AMDGPUOperand::ImmTyFormat));
8028 SMLoc Loc = getLoc();
8035 AMDGPUOperand::ImmTyFormatOp));
8041 parseIntWithPrefix(
"offset",
Operands, AMDGPUOperand::ImmTyOffset);
8043 Res = parseIntWithPrefix(
"inst_offset",
Operands,
8044 AMDGPUOperand::ImmTyInstOffset);
8051 parseNamedBit(
"r128",
Operands, AMDGPUOperand::ImmTyR128A16);
8053 Res = parseNamedBit(
"a16",
Operands, AMDGPUOperand::ImmTyA16);
8059 parseIntWithPrefix(
"blgp",
Operands, AMDGPUOperand::ImmTyBLGP);
8062 parseOperandArrayWithPrefix(
"neg",
Operands, AMDGPUOperand::ImmTyBLGP);
8072 OptionalImmIndexMap OptionalIdx;
8074 unsigned OperandIdx[4];
8075 unsigned EnMask = 0;
8078 for (
unsigned i = 1, e =
Operands.size(); i != e; ++i) {
8079 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[i]);
8084 OperandIdx[SrcIdx] = Inst.
size();
8085 Op.addRegOperands(Inst, 1);
8092 OperandIdx[SrcIdx] = Inst.
size();
8098 if (
Op.isImm() &&
Op.getImmTy() == AMDGPUOperand::ImmTyExpTgt) {
8099 Op.addImmOperands(Inst, 1);
8103 if (
Op.isToken() && (
Op.getToken() ==
"done" ||
Op.getToken() ==
"row_en"))
8107 OptionalIdx[
Op.getImmTy()] = i;
8113 if (OptionalIdx.find(AMDGPUOperand::ImmTyExpCompr) != OptionalIdx.end()) {
8120 for (
auto i = 0; i < SrcIdx; ++i) {
8122 EnMask |= Compr ? (0x3 << i * 2) : (0x1 << i);
8128 AMDGPUOperand::ImmTyExpCompr);
8138 int64_t CntVal,
bool Saturate,
8144 IntVal =
encode(ISA, IntVal, CntVal);
8145 if (CntVal !=
decode(ISA, IntVal)) {
8147 IntVal =
encode(ISA, IntVal, -1);
8155bool AMDGPUAsmParser::parseCnt(int64_t &IntVal) {
8157 SMLoc CntLoc = getLoc();
8158 StringRef CntName = getTokenStr();
8165 SMLoc ValLoc = getLoc();
8172 if (CntName ==
"vmcnt" || CntName ==
"vmcnt_sat") {
8174 }
else if (CntName ==
"expcnt" || CntName ==
"expcnt_sat") {
8176 }
else if (CntName ==
"lgkmcnt" || CntName ==
"lgkmcnt_sat") {
8179 Error(CntLoc,
"invalid counter name " + CntName);
8184 Error(ValLoc,
"too large value for " + CntName);
8193 Error(getLoc(),
"expected a counter name");
8207 if (!parseCnt(Waitcnt))
8215 Operands.push_back(AMDGPUOperand::CreateImm(
this, Waitcnt, S));
8219bool AMDGPUAsmParser::parseDelay(int64_t &Delay) {
8220 SMLoc FieldLoc = getLoc();
8221 StringRef FieldName = getTokenStr();
8226 SMLoc ValueLoc = getLoc();
8233 if (FieldName ==
"instid0") {
8235 }
else if (FieldName ==
"instskip") {
8237 }
else if (FieldName ==
"instid1") {
8240 Error(FieldLoc,
"invalid field name " + FieldName);
8259 .Case(
"VALU_DEP_1", 1)
8260 .Case(
"VALU_DEP_2", 2)
8261 .Case(
"VALU_DEP_3", 3)
8262 .Case(
"VALU_DEP_4", 4)
8263 .Case(
"TRANS32_DEP_1", 5)
8264 .Case(
"TRANS32_DEP_2", 6)
8265 .Case(
"TRANS32_DEP_3", 7)
8266 .Case(
"FMA_ACCUM_CYCLE_1", 8)
8267 .Case(
"SALU_CYCLE_1", 9)
8268 .Case(
"SALU_CYCLE_2", 10)
8269 .Case(
"SALU_CYCLE_3", 11)
8277 Delay |=
Value << Shift;
8287 if (!parseDelay(Delay))
8295 Operands.push_back(AMDGPUOperand::CreateImm(
this, Delay, S));
8299bool AMDGPUOperand::isSWaitCnt()
const {
return isImm(); }
8301bool AMDGPUOperand::isSDelayALU()
const {
return isImm(); }
8307void AMDGPUAsmParser::depCtrError(SMLoc Loc,
int ErrorId,
8308 StringRef DepCtrName) {
8311 Error(Loc, Twine(
"invalid counter name ", DepCtrName));
8314 Error(Loc, Twine(DepCtrName,
" is not supported on this GPU"));
8317 Error(Loc, Twine(
"duplicate counter name ", DepCtrName));
8320 Error(Loc, Twine(
"invalid value for ", DepCtrName));
8327bool AMDGPUAsmParser::parseDepCtr(int64_t &DepCtr,
unsigned &UsedOprMask) {
8329 using namespace llvm::AMDGPU::DepCtr;
8331 SMLoc DepCtrLoc = getLoc();
8332 StringRef DepCtrName = getTokenStr();
8342 unsigned PrevOprMask = UsedOprMask;
8343 int CntVal =
encodeDepCtr(DepCtrName, ExprVal, UsedOprMask, getSTI());
8346 depCtrError(DepCtrLoc, CntVal, DepCtrName);
8355 Error(getLoc(),
"expected a counter name");
8360 int64_t CntValMask = PrevOprMask ^ UsedOprMask;
8361 DepCtr = (DepCtr & ~CntValMask) | CntVal;
8366 using namespace llvm::AMDGPU::DepCtr;
8369 SMLoc Loc = getLoc();
8372 unsigned UsedOprMask = 0;
8374 if (!parseDepCtr(DepCtr, UsedOprMask))
8382 Operands.push_back(AMDGPUOperand::CreateImm(
this, DepCtr, Loc));
8386bool AMDGPUOperand::isDepCtr()
const {
return isS16Imm(); }
8392ParseStatus AMDGPUAsmParser::parseHwregFunc(OperandInfoTy &HwReg,
8394 OperandInfoTy &Width) {
8395 using namespace llvm::AMDGPU::Hwreg;
8401 HwReg.Loc = getLoc();
8404 HwReg.IsSymbolic =
true;
8406 }
else if (!
parseExpr(HwReg.Val,
"a register name")) {
8414 if (!skipToken(
AsmToken::Comma,
"expected a comma or a closing parenthesis"))
8424 Width.Loc = getLoc();
8433 using namespace llvm::AMDGPU::Hwreg;
8436 SMLoc Loc = getLoc();
8438 StructuredOpField HwReg(
"id",
"hardware register", HwregId::Width,
8440 StructuredOpField
Offset(
"offset",
"bit offset", HwregOffset::Width,
8441 HwregOffset::Default);
8442 struct : StructuredOpField {
8443 using StructuredOpField::StructuredOpField;
8444 bool validate(AMDGPUAsmParser &Parser)
const override {
8446 return Error(Parser,
"only values from 1 to 32 are legal");
8449 } Width(
"size",
"bitfield width", HwregSize::Width, HwregSize::Default);
8450 ParseStatus Res = parseStructuredOpFields({&HwReg, &
Offset, &Width});
8453 Res = parseHwregFunc(HwReg,
Offset, Width);
8456 if (!validateStructuredOpFields({&HwReg, &
Offset, &Width}))
8458 ImmVal = HwregEncoding::encode(HwReg.Val,
Offset.Val, Width.Val);
8462 parseExpr(ImmVal,
"a hwreg macro, structured immediate"))
8469 return Error(Loc,
"invalid immediate: only 16-bit values are legal");
8471 AMDGPUOperand::CreateImm(
this, ImmVal, Loc, AMDGPUOperand::ImmTyHwreg));
8475bool AMDGPUOperand::isHwreg()
const {
return isImmTy(ImmTyHwreg); }
8481bool AMDGPUAsmParser::parseSendMsgBody(OperandInfoTy &
Msg, OperandInfoTy &
Op,
8482 OperandInfoTy &Stream) {
8483 using namespace llvm::AMDGPU::SendMsg;
8488 Msg.IsSymbolic =
true;
8495 Op.IsDefined =
true;
8501 }
else if (!
parseExpr(
Op.Val,
"an operation name")) {
8506 Stream.IsDefined =
true;
8507 Stream.Loc = getLoc();
8516bool AMDGPUAsmParser::validateSendMsg(
const OperandInfoTy &
Msg,
8517 const OperandInfoTy &
Op,
8518 const OperandInfoTy &Stream) {
8519 using namespace llvm::AMDGPU::SendMsg;
8528 Error(
Msg.Loc,
"specified message id is not supported on this GPU");
8533 Error(
Msg.Loc,
"invalid message id");
8539 Error(
Op.Loc,
"message does not support operations");
8541 Error(
Msg.Loc,
"missing message operation");
8547 Error(
Op.Loc,
"specified operation id is not supported on this GPU");
8549 Error(
Op.Loc,
"invalid operation id");
8554 Error(Stream.Loc,
"message operation does not support streams");
8558 Error(Stream.Loc,
"invalid message stream id");
8565 using namespace llvm::AMDGPU::SendMsg;
8568 SMLoc Loc = getLoc();
8572 OperandInfoTy
Op(OP_NONE_);
8573 OperandInfoTy Stream(STREAM_ID_NONE_);
8574 if (parseSendMsgBody(
Msg,
Op, Stream) && validateSendMsg(
Msg,
Op, Stream)) {
8579 }
else if (
parseExpr(ImmVal,
"a sendmsg macro")) {
8581 return Error(Loc,
"invalid immediate: only 16-bit values are legal");
8587 AMDGPUOperand::CreateImm(
this, ImmVal, Loc, AMDGPUOperand::ImmTySendMsg));
8591bool AMDGPUOperand::isSendMsg()
const {
return isImmTy(ImmTySendMsg); }
8594 using namespace llvm::AMDGPU::WaitEvent;
8596 SMLoc Loc = getLoc();
8599 StructuredOpField DontWaitExportReady(
"dont_wait_export_ready",
"bit value",
8601 StructuredOpField ExportReady(
"export_ready",
"bit value", 1, 0);
8603 StructuredOpField *TargetBitfield =
8604 isGFX11() ? &DontWaitExportReady : &ExportReady;
8606 ParseStatus Res = parseStructuredOpFields({TargetBitfield});
8610 if (!validateStructuredOpFields({TargetBitfield}))
8612 ImmVal = TargetBitfield->Val;
8619 return Error(Loc,
"invalid immediate: only 16-bit values are legal");
8621 Operands.push_back(AMDGPUOperand::CreateImm(
this, ImmVal, Loc,
8622 AMDGPUOperand::ImmTyWaitEvent));
8626bool AMDGPUOperand::isWaitEvent()
const {
return isImmTy(ImmTyWaitEvent); }
8639 int Slot = StringSwitch<int>(Str)
8646 return Error(S,
"invalid interpolation slot");
8649 AMDGPUOperand::CreateImm(
this, Slot, S, AMDGPUOperand::ImmTyInterpSlot));
8660 if (!Str.starts_with(
"attr"))
8661 return Error(S,
"invalid interpolation attribute");
8663 StringRef Chan = Str.take_back(2);
8664 int AttrChan = StringSwitch<int>(Chan)
8671 return Error(S,
"invalid or missing interpolation attribute channel");
8673 Str = Str.drop_back(2).drop_front(4);
8676 if (Str.getAsInteger(10, Attr))
8677 return Error(S,
"invalid or missing interpolation attribute number");
8680 return Error(S,
"out of bounds interpolation attribute number");
8685 AMDGPUOperand::CreateImm(
this, Attr, S, AMDGPUOperand::ImmTyInterpAttr));
8686 Operands.push_back(AMDGPUOperand::CreateImm(
8687 this, AttrChan, SChan, AMDGPUOperand::ImmTyInterpAttrChan));
8696 using namespace llvm::AMDGPU::Exp;
8706 return Error(S, (Id == ET_INVALID)
8707 ?
"invalid exp target"
8708 :
"exp target is not supported on this GPU");
8711 AMDGPUOperand::CreateImm(
this, Id, S, AMDGPUOperand::ImmTyExpTgt));
8719bool AMDGPUAsmParser::isId(
const AsmToken &Token,
const StringRef Id)
const {
8723bool AMDGPUAsmParser::isId(
const StringRef Id)
const {
8728 return getTokenKind() ==
Kind;
8731StringRef AMDGPUAsmParser::getId()
const {
8735bool AMDGPUAsmParser::trySkipId(
const StringRef Id) {
8743bool AMDGPUAsmParser::trySkipId(
const StringRef Pref,
const StringRef Id) {
8745 StringRef Tok = getTokenStr();
8754bool AMDGPUAsmParser::trySkipId(
const StringRef Id,
8756 if (isId(Id) && peekToken().is(Kind)) {
8765 if (isToken(Kind)) {
8773 const StringRef ErrMsg) {
8774 if (!trySkipToken(Kind)) {
8775 Error(getLoc(), ErrMsg);
8781bool AMDGPUAsmParser::parseExpr(int64_t &
Imm, StringRef Expected) {
8785 if (Parser.parseExpression(Expr))
8788 if (Expr->evaluateAsAbsolute(
Imm))
8791 if (Expected.empty()) {
8792 Error(S,
"expected absolute expression");
8795 Twine(
"expected ", Expected) + Twine(
" or an absolute expression"));
8804 if (Parser.parseExpression(Expr))
8808 if (Expr->evaluateAsAbsolute(IntVal)) {
8809 Operands.push_back(AMDGPUOperand::CreateImm(
this, IntVal, S));
8811 Operands.push_back(AMDGPUOperand::CreateExpr(
this, Expr, S));
8816bool AMDGPUAsmParser::parseString(StringRef &Val,
const StringRef ErrMsg) {
8818 Val =
getToken().getStringContents();
8822 Error(getLoc(), ErrMsg);
8826bool AMDGPUAsmParser::parseId(StringRef &Val,
const StringRef ErrMsg) {
8828 Val = getTokenStr();
8832 if (!ErrMsg.
empty())
8833 Error(getLoc(), ErrMsg);
8837AsmToken AMDGPUAsmParser::getToken()
const {
return Parser.getTok(); }
8839AsmToken AMDGPUAsmParser::peekToken(
bool ShouldSkipSpace) {
8842 : getLexer().peekTok(ShouldSkipSpace);
8846 auto TokCount = getLexer().peekTokens(Tokens);
8853 return getLexer().getKind();
8856SMLoc AMDGPUAsmParser::getLoc()
const {
return getToken().getLoc(); }
8858StringRef AMDGPUAsmParser::getTokenStr()
const {
8862void AMDGPUAsmParser::lex() { Parser.Lex(); }
8864const AMDGPUOperand &
8866 int MCOpIdx)
const {
8868 const AMDGPUOperand &TargetOp =
static_cast<AMDGPUOperand &
>(*Op);
8869 if (TargetOp.getMCOpIdx() == MCOpIdx)
8876 return ((AMDGPUOperand &)*
Operands[0]).getStartLoc();
8880SMLoc AMDGPUAsmParser::getLaterLoc(SMLoc a, SMLoc b) {
8885 int MCOpIdx)
const {
8886 return findMCOperand(
Operands, MCOpIdx).getStartLoc();
8889SMLoc AMDGPUAsmParser::getOperandLoc(
8890 std::function<
bool(
const AMDGPUOperand &)>
Test,
8892 for (
unsigned i =
Operands.size() - 1; i > 0; --i) {
8893 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[i]);
8895 return Op.getStartLoc();
8900SMLoc AMDGPUAsmParser::getImmLoc(AMDGPUOperand::ImmTy
Type,
8902 auto Test = [=](
const AMDGPUOperand &
Op) {
return Op.isImmTy(
Type); };
8917 StringRef
Id = getTokenStr();
8918 SMLoc IdLoc = getLoc();
8924 find_if(Fields, [Id](StructuredOpField *
F) {
return F->Id ==
Id; });
8925 if (
I == Fields.
end())
8926 return Error(IdLoc,
"unknown field");
8927 if ((*I)->IsDefined)
8928 return Error(IdLoc,
"duplicate field");
8931 (*I)->Loc = getLoc();
8934 (*I)->IsDefined =
true;
8941bool AMDGPUAsmParser::validateStructuredOpFields(
8943 return all_of(Fields, [
this](
const StructuredOpField *
F) {
8944 return F->validate(*
this);
8954 const unsigned XorMask) {
8961bool AMDGPUAsmParser::parseSwizzleOperand(int64_t &
Op,
const unsigned MinVal,
8962 const unsigned MaxVal,
8963 const Twine &ErrMsg, SMLoc &Loc) {
8979bool AMDGPUAsmParser::parseSwizzleOperands(
const unsigned OpNum, int64_t *
Op,
8980 const unsigned MinVal,
8981 const unsigned MaxVal,
8982 const StringRef ErrMsg) {
8984 for (
unsigned i = 0; i < OpNum; ++i) {
8985 if (!parseSwizzleOperand(
Op[i], MinVal, MaxVal, ErrMsg, Loc))
8992bool AMDGPUAsmParser::parseSwizzleQuadPerm(int64_t &
Imm) {
8993 using namespace llvm::AMDGPU::Swizzle;
8996 if (parseSwizzleOperands(LANE_NUM, Lane, 0, LANE_MAX,
8997 "expected a 2-bit lane id")) {
9007bool AMDGPUAsmParser::parseSwizzleBroadcast(int64_t &
Imm) {
9008 using namespace llvm::AMDGPU::Swizzle;
9014 if (!parseSwizzleOperand(GroupSize, 2, 32,
9015 "group size must be in the interval [2,32]", Loc)) {
9019 Error(Loc,
"group size must be a power of two");
9022 if (parseSwizzleOperand(LaneIdx, 0, GroupSize - 1,
9023 "lane id must be in the interval [0,group size - 1]",
9031bool AMDGPUAsmParser::parseSwizzleReverse(int64_t &
Imm) {
9032 using namespace llvm::AMDGPU::Swizzle;
9037 if (!parseSwizzleOperand(GroupSize, 2, 32,
9038 "group size must be in the interval [2,32]", Loc)) {
9042 Error(Loc,
"group size must be a power of two");
9050bool AMDGPUAsmParser::parseSwizzleSwap(int64_t &
Imm) {
9051 using namespace llvm::AMDGPU::Swizzle;
9056 if (!parseSwizzleOperand(GroupSize, 1, 16,
9057 "group size must be in the interval [1,16]", Loc)) {
9061 Error(Loc,
"group size must be a power of two");
9069bool AMDGPUAsmParser::parseSwizzleBitmaskPerm(int64_t &
Imm) {
9070 using namespace llvm::AMDGPU::Swizzle;
9077 SMLoc StrLoc = getLoc();
9078 if (!parseString(Ctl)) {
9081 if (Ctl.
size() != BITMASK_WIDTH) {
9082 Error(StrLoc,
"expected a 5-character mask");
9086 unsigned AndMask = 0;
9087 unsigned OrMask = 0;
9088 unsigned XorMask = 0;
9090 for (
size_t i = 0; i < Ctl.
size(); ++i) {
9094 Error(StrLoc,
"invalid mask");
9115bool AMDGPUAsmParser::parseSwizzleFFT(int64_t &
Imm) {
9116 using namespace llvm::AMDGPU::Swizzle;
9119 Error(getLoc(),
"FFT mode swizzle not supported on this GPU");
9125 if (!parseSwizzleOperand(Swizzle, 0, FFT_SWIZZLE_MAX,
9126 "FFT swizzle must be in the interval [0," +
9127 Twine(FFT_SWIZZLE_MAX) + Twine(
']'),
9135bool AMDGPUAsmParser::parseSwizzleRotate(int64_t &
Imm) {
9136 using namespace llvm::AMDGPU::Swizzle;
9139 Error(getLoc(),
"Rotate mode swizzle not supported on this GPU");
9146 if (!parseSwizzleOperand(
Direction, 0, 1,
9147 "direction must be 0 (left) or 1 (right)", Loc))
9151 if (!parseSwizzleOperand(
9152 RotateSize, 0, ROTATE_MAX_SIZE,
9153 "number of threads to rotate must be in the interval [0," +
9154 Twine(ROTATE_MAX_SIZE) + Twine(
']'),
9159 (RotateSize << ROTATE_SIZE_SHIFT);
9163bool AMDGPUAsmParser::parseSwizzleOffset(int64_t &
Imm) {
9165 SMLoc OffsetLoc = getLoc();
9171 Error(OffsetLoc,
"expected a 16-bit offset");
9177bool AMDGPUAsmParser::parseSwizzleMacro(int64_t &
Imm) {
9178 using namespace llvm::AMDGPU::Swizzle;
9182 SMLoc ModeLoc = getLoc();
9185 if (trySkipId(IdSymbolic[ID_QUAD_PERM])) {
9186 Ok = parseSwizzleQuadPerm(
Imm);
9187 }
else if (trySkipId(IdSymbolic[ID_BITMASK_PERM])) {
9188 Ok = parseSwizzleBitmaskPerm(
Imm);
9189 }
else if (trySkipId(IdSymbolic[ID_BROADCAST])) {
9190 Ok = parseSwizzleBroadcast(
Imm);
9191 }
else if (trySkipId(IdSymbolic[ID_SWAP])) {
9192 Ok = parseSwizzleSwap(
Imm);
9193 }
else if (trySkipId(IdSymbolic[ID_REVERSE])) {
9194 Ok = parseSwizzleReverse(
Imm);
9195 }
else if (trySkipId(IdSymbolic[ID_FFT])) {
9196 Ok = parseSwizzleFFT(
Imm);
9197 }
else if (trySkipId(IdSymbolic[ID_ROTATE])) {
9198 Ok = parseSwizzleRotate(
Imm);
9200 Error(ModeLoc,
"expected a swizzle mode");
9203 return Ok && skipToken(
AsmToken::RParen,
"expected a closing parentheses");
9213 if (trySkipId(
"offset")) {
9217 if (trySkipId(
"swizzle")) {
9218 Ok = parseSwizzleMacro(
Imm);
9220 Ok = parseSwizzleOffset(
Imm);
9225 AMDGPUOperand::CreateImm(
this,
Imm, S, AMDGPUOperand::ImmTySwizzle));
9232bool AMDGPUOperand::isSwizzle()
const {
return isImmTy(ImmTySwizzle); }
9238int64_t AMDGPUAsmParser::parseGPRIdxMacro() {
9240 using namespace llvm::AMDGPU::VGPRIndexMode;
9252 for (
unsigned ModeId = ID_MIN; ModeId <=
ID_MAX; ++ModeId) {
9253 if (trySkipId(IdSymbolic[ModeId])) {
9261 ?
"expected a VGPR index mode or a closing parenthesis"
9262 :
"expected a VGPR index mode");
9267 Error(S,
"duplicate VGPR index mode");
9275 "expected a comma or a closing parenthesis"))
9284 using namespace llvm::AMDGPU::VGPRIndexMode;
9290 Imm = parseGPRIdxMacro();
9294 if (getParser().parseAbsoluteExpression(
Imm))
9297 return Error(S,
"invalid immediate: only 4-bit values are legal");
9301 AMDGPUOperand::CreateImm(
this,
Imm, S, AMDGPUOperand::ImmTyGprIdxMode));
9305bool AMDGPUOperand::isGPRIdxMode()
const {
return isImmTy(ImmTyGprIdxMode); }
9316 if (isRegister() || isModifier())
9323 assert(Opr.isImm() || Opr.isExpr());
9324 SMLoc Loc = Opr.getStartLoc();
9328 if (Opr.isExpr() && !Opr.isSymbolRefExpr()) {
9329 Error(Loc,
"expected an absolute expression or a label");
9330 }
else if (Opr.isImm() && !Opr.isS16Imm()) {
9331 Error(Loc,
"expected a 16-bit signed jump offset");
9338 if (isRegister() || isModifier())
9343 assert(Opr.isImm() || Opr.isExpr());
9346 if (Opr.isExpr() && (!Opr.isSymbolRefExpr() || Opr.hasSymbolSpecifier()))
9347 Error(Opr.getStartLoc(),
9348 "expected an absolute expression or an unqualified label");
9366 OptionalImmIndexMap OptionalIdx;
9367 unsigned FirstOperandIdx = 1;
9368 bool IsAtomicReturn =
false;
9374 for (
unsigned i = FirstOperandIdx, e =
Operands.size(); i != e; ++i) {
9375 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[i]);
9379 Op.addRegOperands(Inst, 1);
9383 if (IsAtomicReturn && i == FirstOperandIdx)
9384 Op.addRegOperands(Inst, 1);
9389 if (
Op.isImm() &&
Op.getImmTy() == AMDGPUOperand::ImmTyNone) {
9390 Op.addImmOperands(Inst, 1);
9402 OptionalIdx[
Op.getImmTy()] = i;
9406 AMDGPUOperand::ImmTyOffset);
9422bool AMDGPUOperand::isSMRDOffset8()
const {
9426bool AMDGPUOperand::isSMEMOffset()
const {
9428 return isImmLiteral();
9431bool AMDGPUOperand::isSMRDLiteralOffset()
const {
9466bool AMDGPUAsmParser::convertDppBoundCtrl(int64_t &BoundCtrl) {
9467 if (BoundCtrl == 0 || BoundCtrl == 1) {
9475void AMDGPUAsmParser::onBeginOfFile() {
9476 if (!getParser().getStreamer().getTargetStreamer())
9479 if (!getTargetStreamer().getTargetID())
9480 getTargetStreamer().initializeTargetID(getSTI(),
9484void AMDGPUAsmParser::emitTargetDirective() {
9485 if (!getParser().getStreamer().getTargetStreamer() ||
9490 getTargetStreamer().emitDirectiveAMDGCNTargetOnce();
9499bool AMDGPUAsmParser::parsePrimaryExpr(
const MCExpr *&Res, SMLoc &EndLoc) {
9503 StringRef TokenId = getTokenStr();
9504 AGVK VK = StringSwitch<AGVK>(TokenId)
9505 .Case(
"max", AGVK::AGVK_Max)
9506 .Case(
"min", AGVK::AGVK_Min)
9507 .Case(
"or", AGVK::AGVK_Or)
9508 .Case(
"extrasgprs", AGVK::AGVK_ExtraSGPRs)
9509 .Case(
"totalnumvgprs", AGVK::AGVK_TotalNumVGPRs)
9510 .Case(
"alignto", AGVK::AGVK_AlignTo)
9511 .Case(
"occupancy", AGVK::AGVK_Occupancy)
9512 .Case(
"instprefsize", AGVK::AGVK_InstPrefSize)
9513 .Default(AGVK::AGVK_None);
9522 if (Exprs.
empty()) {
9524 "empty " + Twine(TokenId) +
" expression");
9527 if (CommaCount + 1 != Exprs.
size()) {
9529 "mismatch of commas in " + Twine(TokenId) +
" expression");
9533 Expected && Exprs.
size() != Expected) {
9534 Error(
getToken().getLoc(), Twine(TokenId) +
" expression expects " +
9535 Twine(Expected) +
" operands");
9542 if (getParser().parseExpression(Expr, EndLoc))
9546 if (LastTokenWasComma)
9550 "unexpected token in " + Twine(TokenId) +
" expression");
9556 return getParser().parsePrimaryExpr(Res, EndLoc,
nullptr);
9560 StringRef
Name = getTokenStr();
9561 if (Name ==
"mul") {
9562 return parseIntWithPrefix(
"mul",
Operands, AMDGPUOperand::ImmTyOModSI,
9566 if (Name ==
"div") {
9567 return parseIntWithPrefix(
"div",
Operands, AMDGPUOperand::ImmTyOModSI,
9578 int OpSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel);
9583 const AMDGPU::OpName
Ops[] = {AMDGPU::OpName::src0, AMDGPU::OpName::src1,
9584 AMDGPU::OpName::src2};
9592 int DstIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::vdst);
9597 int ModIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src0_modifiers);
9599 if (
DstOp.isReg() &&
9600 MRI.getRegClass(AMDGPU::VGPR_16RegClassID).contains(
DstOp.
getReg())) {
9604 if ((OpSel & (1 << SrcNum)) != 0)
9610void AMDGPUAsmParser::cvtVOP3OpSel(MCInst &Inst,
9617 OptionalImmIndexMap &OptionalIdx) {
9618 cvtVOP3P(Inst,
Operands, OptionalIdx);
9627 &&
Desc.NumOperands > (OpNum + 1)
9629 &&
Desc.operands()[OpNum + 1].RegClass != -1
9631 &&
Desc.getOperandConstraint(OpNum + 1,
9635void AMDGPUAsmParser::cvtOpSelHelper(MCInst &Inst,
unsigned OpSel) {
9637 constexpr AMDGPU::OpName
Ops[] = {AMDGPU::OpName::src0, AMDGPU::OpName::src1,
9638 AMDGPU::OpName::src2};
9639 constexpr AMDGPU::OpName ModOps[] = {AMDGPU::OpName::src0_modifiers,
9640 AMDGPU::OpName::src1_modifiers,
9641 AMDGPU::OpName::src2_modifiers};
9642 for (
int J = 0; J < 3; ++J) {
9643 int OpIdx = AMDGPU::getNamedOperandIdx(
Opc,
Ops[J]);
9649 int ModIdx = AMDGPU::getNamedOperandIdx(
Opc, ModOps[J]);
9652 if ((OpSel & (1 << J)) != 0)
9655 if (ModOps[J] == AMDGPU::OpName::src0_modifiers && (OpSel & (1 << 3)) != 0)
9662void AMDGPUAsmParser::cvtVOP3Interp(MCInst &Inst,
9664 OptionalImmIndexMap OptionalIdx;
9669 for (
unsigned J = 0; J <
Desc.getNumDefs(); ++J) {
9670 ((AMDGPUOperand &)*
Operands[
I++]).addRegOperands(Inst, 1);
9674 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[
I]);
9676 Op.addRegOrImmWithFPInputModsOperands(Inst, 2);
9677 }
else if (
Op.isInterpSlot() ||
Op.isInterpAttr() ||
9678 Op.isInterpAttrChan()) {
9680 }
else if (
Op.isImmModifier()) {
9681 OptionalIdx[
Op.getImmTy()] =
I;
9689 AMDGPUOperand::ImmTyHigh);
9693 AMDGPUOperand::ImmTyClamp);
9697 AMDGPUOperand::ImmTyOModSI);
9702 AMDGPUOperand::ImmTyOpSel);
9703 int OpSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel);
9706 cvtOpSelHelper(Inst, OpSel);
9711 OptionalImmIndexMap OptionalIdx;
9716 for (
unsigned J = 0; J <
Desc.getNumDefs(); ++J) {
9717 ((AMDGPUOperand &)*
Operands[
I++]).addRegOperands(Inst, 1);
9721 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[
I]);
9723 Op.addRegOrImmWithFPInputModsOperands(Inst, 2);
9724 }
else if (
Op.isImmModifier()) {
9725 OptionalIdx[
Op.getImmTy()] =
I;
9733 int OpSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel);
9736 AMDGPUOperand::ImmTyOpSel);
9739 AMDGPUOperand::ImmTyWaitEXP);
9745 cvtOpSelHelper(Inst, OpSel);
9748void AMDGPUAsmParser::cvtScaledMFMA(MCInst &Inst,
9750 OptionalImmIndexMap OptionalIdx;
9753 int CbszOpIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::cbsz);
9757 for (
unsigned J = 0; J <
Desc.getNumDefs(); ++J)
9758 static_cast<AMDGPUOperand &
>(*
Operands[
I++]).addRegOperands(Inst, 1);
9761 AMDGPUOperand &
Op =
static_cast<AMDGPUOperand &
>(*
Operands[
I]);
9766 if (NumOperands == CbszOpIdx) {
9771 Op.addRegOrImmWithFPInputModsOperands(Inst, 2);
9772 }
else if (
Op.isImmModifier()) {
9773 OptionalIdx[
Op.getImmTy()] =
I;
9775 Op.addRegOrImmOperands(Inst, 1);
9780 auto CbszIdx = OptionalIdx.find(AMDGPUOperand::ImmTyCBSZ);
9781 if (CbszIdx != OptionalIdx.end()) {
9782 int CbszVal = ((AMDGPUOperand &)*
Operands[CbszIdx->second]).
getImm();
9786 int BlgpOpIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::blgp);
9787 auto BlgpIdx = OptionalIdx.find(AMDGPUOperand::ImmTyBLGP);
9788 if (BlgpIdx != OptionalIdx.end()) {
9789 int BlgpVal = ((AMDGPUOperand &)*
Operands[BlgpIdx->second]).
getImm();
9800 auto OpselIdx = OptionalIdx.find(AMDGPUOperand::ImmTyOpSel);
9801 if (OpselIdx != OptionalIdx.end()) {
9802 OpSel =
static_cast<const AMDGPUOperand &
>(*
Operands[OpselIdx->second])
9806 unsigned OpSelHi = 0;
9807 auto OpselHiIdx = OptionalIdx.find(AMDGPUOperand::ImmTyOpSelHi);
9808 if (OpselHiIdx != OptionalIdx.end()) {
9809 OpSelHi =
static_cast<const AMDGPUOperand &
>(*
Operands[OpselHiIdx->second])
9812 const AMDGPU::OpName ModOps[] = {AMDGPU::OpName::src0_modifiers,
9813 AMDGPU::OpName::src1_modifiers};
9815 for (
unsigned J = 0; J < 2; ++J) {
9816 unsigned ModVal = 0;
9817 if (OpSel & (1 << J))
9819 if (OpSelHi & (1 << J))
9822 const int ModIdx = AMDGPU::getNamedOperandIdx(
Opc, ModOps[J]);
9828 OptionalImmIndexMap &OptionalIdx) {
9833 for (
unsigned J = 0; J <
Desc.getNumDefs(); ++J) {
9834 ((AMDGPUOperand &)*
Operands[
I++]).addRegOperands(Inst, 1);
9838 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[
I]);
9840 Op.addRegOrImmWithFPInputModsOperands(Inst, 2);
9841 }
else if (
Op.isImmModifier()) {
9842 OptionalIdx[
Op.getImmTy()] =
I;
9844 Op.addRegOrImmOperands(Inst, 1);
9850 AMDGPUOperand::ImmTyScaleSel);
9854 AMDGPUOperand::ImmTyClamp);
9860 AMDGPUOperand::ImmTyByteSel);
9865 AMDGPUOperand::ImmTyOModSI);
9872 auto *it = Inst.
begin();
9874 it, AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src2_modifiers));
9883 OptionalImmIndexMap OptionalIdx;
9884 cvtVOP3(Inst,
Operands, OptionalIdx);
9888 OptionalImmIndexMap &OptIdx) {
9893 if (
Opc == AMDGPU::V_CVT_SCALEF32_PK_FP4_F16_vi ||
9894 Opc == AMDGPU::V_CVT_SCALEF32_PK_FP4_BF16_vi ||
9895 Opc == AMDGPU::V_CVT_SR_BF8_F32_vi ||
9896 Opc == AMDGPU::V_CVT_SR_FP8_F32_vi ||
9897 Opc == AMDGPU::V_CVT_SR_BF8_F32_gfx12_e64_gfx11 ||
9898 Opc == AMDGPU::V_CVT_SR_FP8_F32_gfx12_e64_gfx11 ||
9899 Opc == AMDGPU::V_CVT_SR_BF8_F32_gfx12_e64_gfx12 ||
9900 Opc == AMDGPU::V_CVT_SR_FP8_F32_gfx12_e64_gfx12 ||
9901 Opc == AMDGPU::V_CVT_SR_BF8_F32_gfx12_e64_gfx13 ||
9902 Opc == AMDGPU::V_CVT_SR_FP8_F32_gfx12_e64_gfx13) {
9911 int VdstInIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::vdst_in);
9912 if (VdstInIdx != -1 && VdstInIdx ==
static_cast<int>(Inst.
getNumOperands()))
9915 int BitOp3Idx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::bitop3);
9916 if (BitOp3Idx != -1) {
9923 int OpSelIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel);
9924 if (OpSelIdx != -1) {
9928 int OpSelHiIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::op_sel_hi);
9929 if (OpSelHiIdx != -1) {
9930 int DefaultVal =
IsPacked ? -1 : 0;
9936 AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::matrix_a_fmt);
9937 if (MatrixAFMTIdx != -1) {
9939 AMDGPUOperand::ImmTyMatrixAFMT, 0);
9943 AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::matrix_b_fmt);
9944 if (MatrixBFMTIdx != -1) {
9946 AMDGPUOperand::ImmTyMatrixBFMT, 0);
9949 int MatrixAScaleIdx =
9950 AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::matrix_a_scale);
9951 if (MatrixAScaleIdx != -1) {
9953 AMDGPUOperand::ImmTyMatrixAScale, 0);
9956 int MatrixBScaleIdx =
9957 AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::matrix_b_scale);
9958 if (MatrixBScaleIdx != -1) {
9960 AMDGPUOperand::ImmTyMatrixBScale, 0);
9963 int MatrixAScaleFmtIdx =
9964 AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::matrix_a_scale_fmt);
9965 if (MatrixAScaleFmtIdx != -1) {
9967 AMDGPUOperand::ImmTyMatrixAScaleFmt, 0);
9970 int MatrixBScaleFmtIdx =
9971 AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::matrix_b_scale_fmt);
9972 if (MatrixBScaleFmtIdx != -1) {
9974 AMDGPUOperand::ImmTyMatrixBScaleFmt, 0);
9979 AMDGPUOperand::ImmTyMatrixAReuse, 0);
9983 AMDGPUOperand::ImmTyMatrixBReuse, 0);
9985 int NegLoIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::neg_lo);
9989 int NegHiIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::neg_hi);
9993 const AMDGPU::OpName
Ops[] = {AMDGPU::OpName::src0, AMDGPU::OpName::src1,
9994 AMDGPU::OpName::src2};
9995 const AMDGPU::OpName ModOps[] = {AMDGPU::OpName::src0_modifiers,
9996 AMDGPU::OpName::src1_modifiers,
9997 AMDGPU::OpName::src2_modifiers};
10000 unsigned OpSelHi = 0;
10001 unsigned NegLo = 0;
10002 unsigned NegHi = 0;
10004 if (OpSelIdx != -1)
10007 if (OpSelHiIdx != -1)
10010 if (NegLoIdx != -1)
10013 if (NegHiIdx != -1)
10016 for (
int J = 0; J < 3; ++J) {
10017 int OpIdx = AMDGPU::getNamedOperandIdx(
Opc,
Ops[J]);
10021 int ModIdx = AMDGPU::getNamedOperandIdx(
Opc, ModOps[J]);
10031 uint32_t ModVal = 0;
10033 const MCOperand &SrcOp = Inst.
getOperand(OpIdx);
10034 if (SrcOp.
isReg() && getMRI()
10038 if (VGPRSuffixIsHi)
10041 if ((OpSel & (1 << J)) != 0)
10045 if ((OpSelHi & (1 << J)) != 0)
10048 if ((NegLo & (1 << J)) != 0)
10051 if ((NegHi & (1 << J)) != 0)
10059 OptionalImmIndexMap OptIdx;
10065 unsigned i,
unsigned Opc,
10066 AMDGPU::OpName
OpName) {
10067 if (AMDGPU::getNamedOperandIdx(
Opc,
OpName) != -1)
10068 ((AMDGPUOperand &)*
Operands[i]).addRegOrImmWithFPInputModsOperands(Inst, 2);
10070 ((AMDGPUOperand &)*
Operands[i]).addRegOperands(Inst, 1);
10076 ((AMDGPUOperand &)*
Operands[1]).addRegOperands(Inst, 1);
10079 ((AMDGPUOperand &)*
Operands[1]).addRegOperands(Inst, 1);
10080 ((AMDGPUOperand &)*
Operands[4]).addRegOperands(Inst, 1);
10082 OptionalImmIndexMap OptIdx;
10083 for (
unsigned i = 5; i <
Operands.size(); ++i) {
10084 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[i]);
10085 OptIdx[
Op.getImmTy()] = i;
10090 AMDGPUOperand::ImmTyIndexKey8bit);
10094 AMDGPUOperand::ImmTyIndexKey16bit);
10098 AMDGPUOperand::ImmTyIndexKey32bit);
10115 SMLoc S = getLoc();
10118 Operands.push_back(AMDGPUOperand::CreateToken(
this,
"::", S));
10119 SMLoc OpYLoc = getLoc();
10122 Operands.push_back(AMDGPUOperand::CreateToken(
this, OpYName, OpYLoc));
10125 return Error(OpYLoc,
"expected a VOPDY instruction after ::");
10134 auto addOp = [&](uint16_t ParsedOprIdx) {
10135 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[ParsedOprIdx]);
10137 Op.addRegOrImmWithFPInputModsOperands(Inst, 2);
10141 Op.addRegOperands(Inst, 1);
10144 if (
Op.isImm() ||
Op.isExpr()) {
10145 Op.addImmOperands(Inst, 1);
10157 addOp(InstInfo[CompIdx].getIndexOfDstInParsedOperands());
10161 const auto &CInfo = InstInfo[CompIdx];
10162 auto CompSrcOperandsNum = InstInfo[CompIdx].getCompParsedSrcOperandsNum();
10163 for (
unsigned CompSrcIdx = 0; CompSrcIdx < CompSrcOperandsNum; ++CompSrcIdx)
10164 addOp(CInfo.getIndexOfSrcInParsedOperands(CompSrcIdx));
10165 if (CInfo.hasSrc2Acc())
10166 addOp(CInfo.getIndexOfDstInParsedOperands());
10170 AMDGPU::getNamedOperandIdx(Inst.
getOpcode(), AMDGPU::OpName::bitop3);
10171 if (BitOp3Idx != -1) {
10172 OptionalImmIndexMap OptIdx;
10173 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands.back());
10175 OptIdx[
Op.getImmTy()] =
Operands.size() - 1;
10185bool AMDGPUOperand::isDPP8()
const {
return isImmTy(ImmTyDPP8); }
10187bool AMDGPUOperand::isDPPCtrl()
const {
10188 using namespace AMDGPU::DPP;
10190 bool result = isImm() && getImmTy() == ImmTyDppCtrl &&
isUInt<9>(
getImm());
10193 return (
Imm >= DppCtrl::QUAD_PERM_FIRST &&
10194 Imm <= DppCtrl::QUAD_PERM_LAST) ||
10195 (
Imm >= DppCtrl::ROW_SHL_FIRST &&
Imm <= DppCtrl::ROW_SHL_LAST) ||
10196 (
Imm >= DppCtrl::ROW_SHR_FIRST &&
Imm <= DppCtrl::ROW_SHR_LAST) ||
10197 (
Imm >= DppCtrl::ROW_ROR_FIRST &&
Imm <= DppCtrl::ROW_ROR_LAST) ||
10198 (
Imm == DppCtrl::WAVE_SHL1) || (
Imm == DppCtrl::WAVE_ROL1) ||
10199 (
Imm == DppCtrl::WAVE_SHR1) || (
Imm == DppCtrl::WAVE_ROR1) ||
10200 (
Imm == DppCtrl::ROW_MIRROR) || (
Imm == DppCtrl::ROW_HALF_MIRROR) ||
10201 (
Imm == DppCtrl::BCAST15) || (
Imm == DppCtrl::BCAST31) ||
10202 (
Imm >= DppCtrl::ROW_SHARE_FIRST &&
10203 Imm <= DppCtrl::ROW_SHARE_LAST) ||
10204 (
Imm >= DppCtrl::ROW_XMASK_FIRST &&
Imm <= DppCtrl::ROW_XMASK_LAST);
10213bool AMDGPUOperand::isBLGP()
const {
10217bool AMDGPUOperand::isS16Imm()
const {
10221bool AMDGPUOperand::isU16Imm()
const {
10229bool AMDGPUAsmParser::parseDimId(
unsigned &Encoding) {
10234 SMLoc Loc =
getToken().getEndLoc();
10235 Token = std::string(getTokenStr());
10237 if (getLoc() != Loc)
10242 if (!parseId(Suffix))
10246 StringRef DimId = Token;
10261 SMLoc S = getLoc();
10267 SMLoc Loc = getLoc();
10268 if (!parseDimId(Encoding))
10269 return Error(Loc,
"invalid dim value");
10272 AMDGPUOperand::CreateImm(
this, Encoding, S, AMDGPUOperand::ImmTyDim));
10281 SMLoc S = getLoc();
10290 if (!skipToken(
AsmToken::LBrac,
"expected an opening square bracket"))
10293 for (
size_t i = 0; i < 8; ++i) {
10297 SMLoc Loc = getLoc();
10298 if (getParser().parseAbsoluteExpression(Sels[i]))
10300 if (0 > Sels[i] || 7 < Sels[i])
10301 return Error(Loc,
"expected a 3-bit value");
10304 if (!skipToken(
AsmToken::RBrac,
"expected a closing square bracket"))
10308 for (
size_t i = 0; i < 8; ++i)
10309 DPP8 |= (Sels[i] << (i * 3));
10312 AMDGPUOperand::CreateImm(
this, DPP8, S, AMDGPUOperand::ImmTyDPP8));
10316bool AMDGPUAsmParser::isSupportedDPPCtrl(StringRef Ctrl,
10318 if (Ctrl ==
"row_newbcast")
10321 if (Ctrl ==
"row_share" || Ctrl ==
"row_xmask")
10324 if (Ctrl ==
"wave_shl" || Ctrl ==
"wave_shr" || Ctrl ==
"wave_rol" ||
10325 Ctrl ==
"wave_ror" || Ctrl ==
"row_bcast")
10328 return Ctrl ==
"row_mirror" ||
Ctrl ==
"row_half_mirror" ||
10329 Ctrl ==
"quad_perm" ||
Ctrl ==
"row_shl" ||
Ctrl ==
"row_shr" ||
10333int64_t AMDGPUAsmParser::parseDPPCtrlPerm() {
10336 if (!skipToken(
AsmToken::LBrac,
"expected an opening square bracket"))
10340 for (
int i = 0; i < 4; ++i) {
10345 SMLoc Loc = getLoc();
10346 if (getParser().parseAbsoluteExpression(Temp))
10348 if (Temp < 0 || Temp > 3) {
10349 Error(Loc,
"expected a 2-bit value");
10353 Val += (Temp << i * 2);
10356 if (!skipToken(
AsmToken::RBrac,
"expected a closing square bracket"))
10362int64_t AMDGPUAsmParser::parseDPPCtrlSel(StringRef Ctrl) {
10363 using namespace AMDGPU::DPP;
10368 SMLoc Loc = getLoc();
10370 if (getParser().parseAbsoluteExpression(Val))
10373 struct DppCtrlCheck {
10379 DppCtrlCheck
Check =
10380 StringSwitch<DppCtrlCheck>(Ctrl)
10381 .Case(
"wave_shl", {DppCtrl::WAVE_SHL1, 1, 1})
10382 .Case(
"wave_rol", {DppCtrl::WAVE_ROL1, 1, 1})
10383 .Case(
"wave_shr", {DppCtrl::WAVE_SHR1, 1, 1})
10384 .Case(
"wave_ror", {DppCtrl::WAVE_ROR1, 1, 1})
10385 .Case(
"row_shl", {DppCtrl::ROW_SHL0, 1, 15})
10386 .Case(
"row_shr", {DppCtrl::ROW_SHR0, 1, 15})
10387 .Case(
"row_ror", {DppCtrl::ROW_ROR0, 1, 15})
10388 .Case(
"row_share", {DppCtrl::ROW_SHARE_FIRST, 0, 15})
10389 .Case(
"row_xmask", {DppCtrl::ROW_XMASK_FIRST, 0, 15})
10390 .Case(
"row_newbcast", {DppCtrl::ROW_NEWBCAST_FIRST, 0, 15})
10394 if (
Check.Ctrl == -1) {
10395 Valid = (
Ctrl ==
"row_bcast" && (Val == 15 || Val == 31));
10403 Error(Loc, Twine(
"invalid ", Ctrl) + Twine(
" value"));
10411 using namespace AMDGPU::DPP;
10414 !isSupportedDPPCtrl(getTokenStr(),
Operands))
10417 SMLoc S = getLoc();
10423 if (Ctrl ==
"row_mirror") {
10424 Val = DppCtrl::ROW_MIRROR;
10425 }
else if (Ctrl ==
"row_half_mirror") {
10426 Val = DppCtrl::ROW_HALF_MIRROR;
10429 if (Ctrl ==
"quad_perm") {
10430 Val = parseDPPCtrlPerm();
10432 Val = parseDPPCtrlSel(Ctrl);
10441 AMDGPUOperand::CreateImm(
this, Val, S, AMDGPUOperand::ImmTyDppCtrl));
10447 OptionalImmIndexMap OptionalIdx;
10454 int OldIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::old);
10456 AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::src2_modifiers);
10457 bool IsMAC = OldIdx != -1 && Src2ModIdx != -1 &&
10461 for (
unsigned J = 0; J <
Desc.getNumDefs(); ++J) {
10462 ((AMDGPUOperand &)*
Operands[
I++]).addRegOperands(Inst, 1);
10466 int VdstInIdx = AMDGPU::getNamedOperandIdx(
Opc, AMDGPU::OpName::vdst_in);
10467 bool IsVOP3CvtSrDpp =
Opc == AMDGPU::V_CVT_SR_BF8_F32_gfx12_e64_dpp8_gfx12 ||
10468 Opc == AMDGPU::V_CVT_SR_BF8_F32_gfx12_e64_dpp8_gfx13 ||
10469 Opc == AMDGPU::V_CVT_SR_FP8_F32_gfx12_e64_dpp8_gfx12 ||
10470 Opc == AMDGPU::V_CVT_SR_FP8_F32_gfx12_e64_dpp8_gfx13 ||
10471 Opc == AMDGPU::V_CVT_SR_BF8_F32_gfx12_e64_dpp_gfx12 ||
10472 Opc == AMDGPU::V_CVT_SR_BF8_F32_gfx12_e64_dpp_gfx13 ||
10473 Opc == AMDGPU::V_CVT_SR_FP8_F32_gfx12_e64_dpp_gfx12 ||
10474 Opc == AMDGPU::V_CVT_SR_FP8_F32_gfx12_e64_dpp_gfx13;
10480 if (OldIdx == NumOperands) {
10482 constexpr int DST_IDX = 0;
10484 }
else if (Src2ModIdx == NumOperands) {
10494 if (IsVOP3CvtSrDpp) {
10503 if (TiedTo != -1) {
10508 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[
I]);
10510 if (IsDPP8 &&
Op.isDppFI()) {
10513 Op.addRegOrImmWithFPInputModsOperands(Inst, 2);
10514 }
else if (
Op.isReg()) {
10515 Op.addRegOperands(Inst, 1);
10516 }
else if (
Op.isImm() &&
10518 Op.addImmOperands(Inst, 1);
10519 }
else if (
Op.isImm()) {
10520 OptionalIdx[
Op.getImmTy()] =
I;
10528 AMDGPUOperand::ImmTyClamp);
10534 AMDGPUOperand::ImmTyByteSel);
10539 AMDGPUOperand::ImmTyOModSI);
10542 cvtVOP3P(Inst,
Operands, OptionalIdx);
10544 cvtVOP3OpSel(Inst,
Operands, OptionalIdx);
10547 AMDGPUOperand::ImmTyOpSel);
10552 AMDGPUOperand::ImmTyDPP8);
10553 using namespace llvm::AMDGPU::DPP;
10557 AMDGPUOperand::ImmTyDppCtrl, 0xe4);
10559 AMDGPUOperand::ImmTyDppRowMask, 0xf);
10561 AMDGPUOperand::ImmTyDppBankMask, 0xf);
10563 AMDGPUOperand::ImmTyDppBoundCtrl);
10567 AMDGPUOperand::ImmTyDppFI);
10573 OptionalImmIndexMap OptionalIdx;
10577 for (
unsigned J = 0; J <
Desc.getNumDefs(); ++J) {
10578 ((AMDGPUOperand &)*
Operands[
I++]).addRegOperands(Inst, 1);
10585 if (TiedTo != -1) {
10590 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[
I]);
10592 if (
Op.isReg() && validateVccOperand(
Op.getReg())) {
10600 Op.addImmOperands(Inst, 1);
10602 Op.addRegWithFPInputModsOperands(Inst, 2);
10603 }
else if (
Op.isDppFI()) {
10605 }
else if (
Op.isReg()) {
10606 Op.addRegOperands(Inst, 1);
10612 Op.addRegWithFPInputModsOperands(Inst, 2);
10613 }
else if (
Op.isReg()) {
10614 Op.addRegOperands(Inst, 1);
10615 }
else if (
Op.isDPPCtrl()) {
10616 Op.addImmOperands(Inst, 1);
10617 }
else if (
Op.isImm()) {
10619 OptionalIdx[
Op.getImmTy()] =
I;
10627 using namespace llvm::AMDGPU::DPP;
10631 AMDGPUOperand::ImmTyDppRowMask, 0xf);
10633 AMDGPUOperand::ImmTyDppBankMask, 0xf);
10635 AMDGPUOperand::ImmTyDppBoundCtrl);
10638 AMDGPUOperand::ImmTyDppFI);
10649 AMDGPUOperand::ImmTy
Type) {
10650 return parseStringOrIntWithPrefix(
10652 {
"BYTE_0",
"BYTE_1",
"BYTE_2",
"BYTE_3",
"WORD_0",
"WORD_1",
"DWORD"},
10657 return parseStringOrIntWithPrefix(
10658 Operands,
"dst_unused", {
"UNUSED_PAD",
"UNUSED_SEXT",
"UNUSED_PRESERVE"},
10659 AMDGPUOperand::ImmTySDWADstUnused);
10663 cvtSDWA(Inst,
Operands, SDWAInstType::VOP1);
10667 cvtSDWA(Inst,
Operands, SDWAInstType::VOP2);
10670void AMDGPUAsmParser::cvtSdwaVOP2b(MCInst &Inst,
10672 cvtSDWA(Inst,
Operands, SDWAInstType::VOP2,
true,
true);
10675void AMDGPUAsmParser::cvtSdwaVOP2e(MCInst &Inst,
10677 cvtSDWA(Inst,
Operands, SDWAInstType::VOP2,
false,
true);
10685 SDWAInstType BasicInstType,
bool SkipDstVcc,
10687 using namespace llvm::AMDGPU::SDWA;
10689 OptionalImmIndexMap OptionalIdx;
10690 bool SkipVcc = SkipDstVcc || SkipSrcVcc;
10691 bool SkippedVcc =
false;
10695 for (
unsigned J = 0; J <
Desc.getNumDefs(); ++J) {
10696 ((AMDGPUOperand &)*
Operands[
I++]).addRegOperands(Inst, 1);
10700 AMDGPUOperand &
Op = ((AMDGPUOperand &)*
Operands[
I]);
10701 if (SkipVcc && !SkippedVcc &&
Op.isReg() &&
10702 (
Op.getReg() == AMDGPU::VCC ||
Op.getReg() == AMDGPU::VCC_LO)) {
10708 if (BasicInstType == SDWAInstType::VOP2 &&
10714 if (BasicInstType == SDWAInstType::VOPC && Inst.
getNumOperands() == 0) {
10720 Op.addRegOrImmWithInputModsOperands(Inst, 2);
10721 }
else if (
Op.isImm()) {
10723 OptionalIdx[
Op.getImmTy()] =
I;
10727 SkippedVcc =
false;
10731 if (
Opc != AMDGPU::V_NOP_sdwa_gfx10 &&
Opc != AMDGPU::V_NOP_sdwa_gfx9 &&
10732 Opc != AMDGPU::V_NOP_sdwa_vi) {
10734 switch (BasicInstType) {
10735 case SDWAInstType::VOP1:
10738 AMDGPUOperand::ImmTyClamp, 0);
10742 AMDGPUOperand::ImmTyOModSI, 0);
10746 AMDGPUOperand::ImmTySDWADstSel, SdwaSel::DWORD);
10750 AMDGPUOperand::ImmTySDWADstUnused,
10751 DstUnused::UNUSED_PRESERVE);
10754 AMDGPUOperand::ImmTySDWASrc0Sel, SdwaSel::DWORD);
10757 case SDWAInstType::VOP2:
10759 AMDGPUOperand::ImmTyClamp, 0);
10763 AMDGPUOperand::ImmTyOModSI, 0);
10766 AMDGPUOperand::ImmTySDWADstSel, SdwaSel::DWORD);
10768 AMDGPUOperand::ImmTySDWADstUnused,
10769 DstUnused::UNUSED_PRESERVE);
10771 AMDGPUOperand::ImmTySDWASrc0Sel, SdwaSel::DWORD);
10773 AMDGPUOperand::ImmTySDWASrc1Sel, SdwaSel::DWORD);
10776 case SDWAInstType::VOPC:
10779 AMDGPUOperand::ImmTyClamp, 0);
10781 AMDGPUOperand::ImmTySDWASrc0Sel, SdwaSel::DWORD);
10783 AMDGPUOperand::ImmTySDWASrc1Sel, SdwaSel::DWORD);
10790 if (Inst.
getOpcode() == AMDGPU::V_MAC_F32_sdwa_vi ||
10791 Inst.
getOpcode() == AMDGPU::V_MAC_F16_sdwa_vi) {
10792 auto *it = Inst.
begin();
10794 it, AMDGPU::getNamedOperandIdx(Inst.
getOpcode(), AMDGPU::OpName::src2));
10807#define GET_MATCHER_IMPLEMENTATION
10808#define GET_MNEMONIC_SPELL_CHECKER
10809#define GET_MNEMONIC_CHECKER
10810#include "AMDGPUGenAsmMatcher.inc"
10816 return parseTokenOp(
"addr64",
Operands);
10818 return parseNamedBit(
"done",
Operands, AMDGPUOperand::ImmTyDone,
true);
10820 return parseTokenOp(
"idxen",
Operands);
10822 return parseNamedBit(
"lds",
Operands, AMDGPUOperand::ImmTyLDS,
10825 return parseTokenOp(
"offen",
Operands);
10827 return parseTokenOp(
"off",
Operands);
10828 case MCK_row_95_en:
10829 return parseNamedBit(
"row_en",
Operands, AMDGPUOperand::ImmTyRowEn,
true);
10831 return parseNamedBit(
"gds",
Operands, AMDGPUOperand::ImmTyGDS);
10833 return parseNamedBit(
"tfe",
Operands, AMDGPUOperand::ImmTyTFE);
10835 return tryCustomParseOperand(
Operands, MCK);
10840unsigned AMDGPUAsmParser::validateTargetOperandClass(MCParsedAsmOperand &
Op,
10846 AMDGPUOperand &Operand = (AMDGPUOperand &)
Op;
10849 return Operand.isAddr64() ? Match_Success : Match_InvalidOperand;
10851 return Operand.isGDS() ? Match_Success : Match_InvalidOperand;
10853 return Operand.isLDS() ? Match_Success : Match_InvalidOperand;
10855 return Operand.isIdxen() ? Match_Success : Match_InvalidOperand;
10857 return Operand.isOffen() ? Match_Success : Match_InvalidOperand;
10859 return Operand.isTFE() ? Match_Success : Match_InvalidOperand;
10861 return Operand.isDone() ? Match_Success : Match_InvalidOperand;
10862 case MCK_row_95_en:
10863 return Operand.isRowEn() ? Match_Success : Match_InvalidOperand;
10871 return Operand.isSSrc_b32() ? Match_Success : Match_InvalidOperand;
10873 return Operand.isSSrc_f32() ? Match_Success : Match_InvalidOperand;
10874 case MCK_SOPPBrTarget:
10875 return Operand.isSOPPBrTarget() ? Match_Success : Match_InvalidOperand;
10876 case MCK_VReg32OrOff:
10877 return Operand.isVReg32OrOff() ? Match_Success : Match_InvalidOperand;
10878 case MCK_InterpSlot:
10879 return Operand.isInterpSlot() ? Match_Success : Match_InvalidOperand;
10880 case MCK_InterpAttr:
10881 return Operand.isInterpAttr() ? Match_Success : Match_InvalidOperand;
10882 case MCK_InterpAttrChan:
10883 return Operand.isInterpAttrChan() ? Match_Success : Match_InvalidOperand;
10885 case MCK_SReg_64_XEXEC:
10895 return Operand.isNull() ? Match_Success : Match_InvalidOperand;
10897 return Match_InvalidOperand;
10906 SMLoc S = getLoc();
10915 return Error(S,
"expected a 16-bit value");
10918 AMDGPUOperand::CreateImm(
this,
Imm, S, AMDGPUOperand::ImmTyEndpgm));
10922bool AMDGPUOperand::isEndpgm()
const {
return isImmTy(ImmTyEndpgm); }
10928bool AMDGPUOperand::isSplitBarrier()
const {
static const TargetRegisterClass * getRegClass(const MachineInstr &MI, Register Reg)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
SmallVector< int16_t, MAX_SRC_OPERANDS_NUM > OperandIndices
static bool checkWriteLane(const MCInst &Inst)
static bool getRegNum(StringRef Str, unsigned &Num)
static void addSrcModifiersAndSrc(MCInst &Inst, const OperandVector &Operands, unsigned i, unsigned Opc, AMDGPU::OpName OpName)
static constexpr RegInfo RegularRegisters[]
static const RegInfo * getRegularRegInfo(StringRef Str)
static ArrayRef< unsigned > getAllVariants()
static OperandIndices getSrcOperandIndices(unsigned Opcode, bool AddMandatoryLiterals=false)
static int IsAGPROperand(const MCInst &Inst, AMDGPU::OpName Name, const MCRegisterInfo *MRI)
static bool IsMovrelsSDWAOpcode(const unsigned Opcode)
static const fltSemantics * getFltSemantics(unsigned Size)
static bool isRegularReg(RegisterKind Kind)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUAsmParser()
Force static initialization.
static bool ConvertOmodMul(int64_t &Mul)
#define PARSE_BITS_ENTRY(FIELD, ENTRY, VALUE, RANGE)
static bool isInlineableLiteralOp16(int64_t Val, MVT VT, bool HasInv2Pi)
static bool canLosslesslyConvertToFPType(APFloat &FPLiteral, MVT VT)
static bool AMDGPUCheckMnemonic(StringRef Mnemonic, const FeatureBitset &AvailableFeatures, unsigned VariantID)
static void applyMnemonicAliases(StringRef &Mnemonic, const FeatureBitset &Features, unsigned VariantID)
constexpr unsigned MAX_SRC_OPERANDS_NUM
#define EXPR_RESOLVE_OR_ERROR(RESOLVED)
static bool ConvertOmodDiv(int64_t &Div)
static bool IsRevOpcode(const unsigned Opcode)
static bool encodeCnt(const AMDGPU::IsaVersion ISA, int64_t &IntVal, int64_t CntVal, bool Saturate, unsigned(*encode)(const IsaVersion &Version, unsigned, unsigned), unsigned(*decode)(const IsaVersion &Version, unsigned))
static MCRegister getSpecialRegForName(StringRef RegName)
static void addOptionalImmOperand(MCInst &Inst, const OperandVector &Operands, AMDGPUAsmParser::OptionalImmIndexMap &OptionalIdx, AMDGPUOperand::ImmTy ImmT, int64_t Default=0, std::optional< unsigned > InsertAt=std::nullopt)
static void cvtVOP3DstOpSelOnly(MCInst &Inst, const MCRegisterInfo &MRI)
static bool isRegOrImmWithInputMods(const MCInstrDesc &Desc, unsigned OpNum)
static const fltSemantics * getOpFltSemantics(uint8_t OperandType)
static bool isInvalidVOPDY(const OperandVector &Operands, uint64_t InvalidOprIdx)
static std::string AMDGPUMnemonicSpellCheck(StringRef S, const FeatureBitset &FBS, unsigned VariantID=0)
static LLVM_READNONE unsigned encodeBitmaskPerm(const unsigned AndMask, const unsigned OrMask, const unsigned XorMask)
static bool isSafeTruncation(int64_t Val, unsigned Size)
AMDHSA kernel descriptor MCExpr struct for use in MC layer.
Provides AMDGPU specific target descriptions.
Enums shared between the AMDGPU backend (LLVM) and the ELF linker (LLD) for the .amdgpu....
AMDHSA kernel descriptor definitions.
static bool parseExpr(MCAsmParser &MCParser, const MCExpr *&Value, raw_ostream &Err)
MC layer struct for AMDGPUMCKernelCodeT, provides MCExpr functionality where required.
@ AMD_CODE_PROPERTY_ENABLE_WAVEFRONT_SIZE32
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
static llvm::Expected< InlineInfo > decode(GsymDataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr)
Decode an InlineInfo in Data at the specified offset.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
Loop::LoopBounds::Direction Direction
static bool hasFeature(StringRef Feature, const FeatureBitset &FeatureBits, ArrayRef< SubtargetFeatureKV > ProcFeatures)
Register const TargetRegisterInfo * TRI
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
static bool isReg(const MCInst &MI, unsigned OpNo)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
MachineRegisterInfo & MRI
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
Interface definition for SIInstrInfo.
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file implements the SmallBitVector class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, const llvm::StringTable &StandardNames, VectorLibrary VecLib)
Initialize the set of available library functions based on the specified target triple.
static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName)
static const char * getRegisterName(MCRegister Reg)
static const AMDGPUMCExpr * createMax(ArrayRef< const MCExpr * > Args, MCContext &Ctx)
static unsigned getNumExpectedArgs(VariantKind Kind)
static const AMDGPUMCExpr * createLit(LitModifier Lit, int64_t Value, MCContext &Ctx)
static const AMDGPUMCExpr * create(VariantKind Kind, ArrayRef< const MCExpr * > Args, MCContext &Ctx)
static const AMDGPUMCExpr * createExtraSGPRs(const MCExpr *VCCUsed, const MCExpr *FlatScrUsed, bool XNACKUsed, MCContext &Ctx)
Allow delayed MCExpr resolve of ExtraSGPRs (in case VCCUsed or FlatScrUsed are unresolvable but neede...
static const AMDGPUMCExpr * createAlignTo(const MCExpr *Value, const MCExpr *Align, MCContext &Ctx)
static std::optional< TargetID > parseTargetIDString(StringRef TargetIDDirective)
Parse and validate a TargetID from a full "<triple>-<processor>:<features>" directive string.
TargetIDSetting getXnackSetting() const
GPUKind getGPUKind() const
StringRef getTargetTripleString() const
std::string toString() const
TargetIDSetting getSramEccSetting() const
static constexpr roundingMode rmNearestTiesToEven
static constexpr const fltSemantics & IEEEhalf()
static constexpr const fltSemantics & IEEEsingle()
static constexpr const fltSemantics & BFloat()
static constexpr const fltSemantics & IEEEdouble()
opStatus
IEEE-754R 7: Default exception handling.
LLVM_ABI opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
const T & front() const
Get the first element.
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
StringRef getString() const
Get the string for the current token, this includes all characters (for example, the quotes on string...
bool is(TokenKind K) const
Container class for subtarget features.
constexpr bool test(unsigned I) const
constexpr FeatureBitset & flip(unsigned I)
void printExpr(raw_ostream &, const MCExpr &) const
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
static const MCBinaryExpr * createDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Instances of this class represent a single low-level machine instruction.
unsigned getNumOperands() const
unsigned getOpcode() const
iterator insert(iterator I, const MCOperand &Op)
void addOperand(const MCOperand Op)
const MCOperand & getOperand(unsigned i) const
Describe properties that are true of each instruction in the target description file.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
const int16_t * getRegClassByHwModeTable(unsigned ModeId) const
int16_t getOpRegClassID(const MCOperandInfo &OpInfo, unsigned HwModeId) const
Return the ID of the register class to use for OpInfo, for the active HwMode HwModeId.
Instances of this class represent operands of the MCInst class.
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
void setReg(MCRegister Reg)
Set the register number.
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
MCRegisterClass - Base class of TargetRegisterClass.
MCRegister getRegister(unsigned i) const
getRegister - Return the specified register in the class.
unsigned getNumRegs() const
getNumRegs - Return the number of registers in this class.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isValid() const
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
StringRef getName() const
getName - Get the symbol name.
bool isVariable() const
isVariable - Check if this is a variable symbol.
LLVM_ABI void setVariableValue(const MCExpr *Value)
void setRedefinable(bool Value)
Mark this symbol as redefinable.
const MCExpr * getVariableValue() const
Get the expression of the variable symbol.
MCTargetAsmParser - Generic interface to target specific assembly parsers.
uint64_t getScalarSizeInBits() const
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
Ternary parse status returned by various parse* methods.
constexpr bool isFailure() const
static constexpr StatusTy Failure
constexpr bool isSuccess() const
static constexpr StatusTy Success
static constexpr StatusTy NoMatch
constexpr bool isNoMatch() const
constexpr unsigned id() const
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
constexpr const char * getPointer() const
constexpr bool isValid() const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Represent a constant reference to a string, i.e.
bool consume_back(StringRef Suffix)
Returns true if this StringRef has the given suffix and removes that suffix.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
constexpr size_t size() const
Get the string size.
constexpr const char * data() const
Get a pointer to the start of the string (which may not be null terminated).
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
bool consume_front(char Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
bool contains(StringRef key) const
Check if the set contains the given key.
std::pair< typename Base::iterator, bool > insert(StringRef key)
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_ABI std::string str() const
Return the twine contents as a std::string.
std::pair< iterator, bool > insert(const ValueT &V)
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask, const MCSubtargetInfo &STI)
int getDefaultDepCtrEncoding(const MCSubtargetInfo &STI)
bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI)
unsigned getTgtId(const StringRef Name)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char NumSGPRs[]
Key for Kernel::CodeProps::Metadata::mNumSGPRs.
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
constexpr char AssemblerDirectiveBegin[]
HSA metadata beginning assembler directive.
constexpr char AssemblerDirectiveEnd[]
HSA metadata ending assembler directive.
constexpr char AssemblerDirectiveBegin[]
Old HSA metadata beginning assembler directive for V2.
int64_t getHwregId(StringRef Name, const MCSubtargetInfo &STI)
@ FIXED_NUM_SGPRS_FOR_INIT_BUG
unsigned getVGPREncodingGranule(const MCSubtargetInfo &STI, std::optional< bool > EnableWavefrontSize32)
unsigned getSGPREncodingGranule(const MCSubtargetInfo &STI)
bool targetIDSettingsConflict(TargetIDSetting Lhs, TargetIDSetting Rhs)
Returns true if Lhs and Rhs are incompatible (both specific but different).
unsigned getLocalMemorySize(const MCSubtargetInfo &STI)
constexpr char AssemblerDirective[]
PAL metadata (old linear format) assembler directive.
constexpr char AssemblerDirectiveBegin[]
PAL metadata (new MsgPack format) beginning assembler directive.
constexpr char AssemblerDirectiveEnd[]
PAL metadata (new MsgPack format) ending assembler directive.
int64_t getMsgOpId(int64_t MsgId, StringRef Name, const MCSubtargetInfo &STI)
Map from a symbolic name for a sendmsg operation to the operation portion of the immediate encoding.
int64_t getMsgId(StringRef Name, const MCSubtargetInfo &STI)
Map from a symbolic name for a msg_id to the message portion of the immediate encoding.
uint64_t encodeMsg(uint64_t MsgId, uint64_t OpId, uint64_t StreamId)
bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI)
bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI)
bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId, const MCSubtargetInfo &STI, bool Strict)
bool msgRequiresOp(int64_t MsgId, const MCSubtargetInfo &STI)
bool isValidMsgOp(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI, bool Strict)
ArrayRef< GFXVersion > getGFXVersions()
constexpr unsigned COMPONENTS[]
constexpr const char *const ModMatrixFmt[]
constexpr const char *const ModMatrixScaleFmt[]
constexpr const char *const ModMatrixScale[]
bool isInlineValue(MCRegister Reg)
bool isPKFMACF16InlineConstant(uint32_t Literal, bool IsGFX11Plus)
LLVM_READONLY const MIMGInfo * getMIMGInfo(unsigned Opc)
bool isInlinableLiteralFP16(int16_t Literal, bool HasInv2Pi)
bool isSGPR(MCRegister Reg, const MCRegisterInfo *TRI)
Is Reg - scalar register.
MCRegister getMCReg(MCRegister Reg, const MCSubtargetInfo &STI)
If Reg is a pseudo reg, return the correct hardware register given STI otherwise return Reg.
FuncInfoFlags
Per-function flags packed into INFO_FLAGS entries.
uint8_t wmmaScaleF8F6F4FormatToNumRegs(unsigned Fmt)
const int OPR_ID_UNSUPPORTED
bool isInlinableLiteralV2I16(uint32_t Literal)
bool isHi16Reg(MCRegister Reg, const MCRegisterInfo &MRI)
unsigned getTemporalHintType(const MCInstrDesc TID)
static AMDGPUMCExpr::Specifier getSpecifier(const MCSymbolRefExpr *SRE)
LLVM_READONLY bool isLitExpr(const MCExpr *Expr)
bool isInlinableLiteralV2BF16(uint32_t Literal)
LLVM_ABI bool isCPUValidForSubArch(Triple::SubArchType SubArch, GPUKind AK)
Return true if the GPU AK is usable with the triple subarch SubArch.
unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI)
unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST)
For pre-GFX12 FLAT instructions the offset must be positive; MSB is ignored and forced to zero.
bool hasA16(const MCSubtargetInfo &STI)
bool isLegalSMRDEncodedSignedOffset(const MCSubtargetInfo &ST, int64_t EncodedOffset, bool IsBuffer)
bool isGFX12Plus(const MCSubtargetInfo &STI)
unsigned getNSAMaxSize(const MCSubtargetInfo &STI, bool HasSampler)
bool hasPackedD16(const MCSubtargetInfo &STI)
bool isGFX940(const MCSubtargetInfo &STI)
bool isInlinableLiteralV2F16(uint32_t Literal)
bool isHsaAbi(const MCSubtargetInfo &STI)
bool isGFX11(const MCSubtargetInfo &STI)
const int OPR_VAL_INVALID
bool getSMEMIsBuffer(unsigned Opc)
bool isPackedSingleSGPRFP32Inst(unsigned Opc)
The opcode is a packed fp32 instruction which only reads low 32 bits of a scalar operand and propagat...
LLVM_ABI unsigned getAddressableNumSGPRs(GPUKind AK)
uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal)
LLVM_ABI IsaVersion getIsaVersion(StringRef GPU)
unsigned getRegBitWidth(unsigned RCID)
Get the size in bits of a register from the register class RC.
bool isValid32BitLiteral(uint64_t Val, bool IsFP64)
LLVM_ABI unsigned getTotalNumVGPRs(GPUKind AK, bool IsWave32)
CanBeVOPD getCanBeVOPD(unsigned Opc, unsigned EncodingFamily, bool VOPD3)
LLVM_READNONE bool isLegalDPALU_DPPControl(const MCSubtargetInfo &ST, unsigned DC)
bool isSI(const MCSubtargetInfo &STI)
bool hasPrivateApertureRegs(const MCSubtargetInfo &STI)
unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt)
unsigned getWaitcntBitMask(const IsaVersion &Version)
bool isGFX9(const MCSubtargetInfo &STI)
unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST)
LLVM_READONLY bool hasNamedOperand(uint32_t Opcode, OpName NamedIdx)
bool isKImmOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this a KImm operand?
GPUKind
GPU kinds supported by the AMDGPU target.
bool isGFX90A(const MCSubtargetInfo &STI)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfoByEncoding(uint8_t DimEnc)
bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi)
bool isGFX12(const MCSubtargetInfo &STI)
unsigned encodeExpcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Expcnt)
bool hasMAIInsts(const MCSubtargetInfo &STI)
constexpr bool isSISrcOperand(const MCOperandInfo &OpInfo)
Is this an AMDGPU specific source operand?
bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi, bool *IsBF16)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfoByAsmSuffix(StringRef AsmSuffix)
bool hasMIMG_R128(const MCSubtargetInfo &STI)
LLVM_ABI GPUKind parseArchAMDGCN(StringRef CPU)
bool hasG16(const MCSubtargetInfo &STI)
unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode, const MIMGDimInfo *Dim, bool IsA16, bool IsG16Supported)
bool hasArchitectedFlatScratch(const MCSubtargetInfo &STI)
LLVM_READONLY int64_t getLitValue(const MCExpr *Expr)
bool isGFX11Plus(const MCSubtargetInfo &STI)
bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this floating-point operand?
bool isGFX10Plus(const MCSubtargetInfo &STI)
AMDGPU::TargetID TargetID
int64_t encode32BitLiteral(int64_t Imm, OperandType Type, bool IsLit)
bool isValidWMMAScaleFmtCombination(unsigned AFmt, unsigned AScale, unsigned BFmt, unsigned BScale)
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
@ OPERAND_REG_INLINE_C_FP64
@ OPERAND_REG_IMM_NOINLINE_FP16
@ OPERAND_REG_INLINE_C_BF16
@ OPERAND_REG_INLINE_C_V2BF16
@ OPERAND_REG_IMM_V2INT64
@ OPERAND_REG_IMM_V2INT16
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
@ OPERAND_REG_IMM_V2FP16_SPLAT
@ OPERAND_REG_INLINE_C_INT64
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
@ OPERAND_REG_IMM_NOINLINE_V2FP16
@ OPERAND_REG_INLINE_C_V2FP16
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
@ OPERAND_REG_INLINE_AC_FP32
@ OPERAND_REG_IMM_V2INT32
@ OPERAND_REG_INLINE_C_FP32
@ OPERAND_REG_INLINE_C_INT32
@ OPERAND_REG_INLINE_C_V2INT16
@ OPERAND_REG_INLINE_AC_FP64
@ OPERAND_REG_INLINE_C_FP16
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
constexpr bool isBF16SrcOperand(const MCOperandInfo &OpInfo)
Is this a scalar (i.e. not packed) bf16 source operand?
bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII, const MCSubtargetInfo &ST)
LLVM_ABI StringRef getArchNameAMDGCN(GPUKind AK)
bool hasGDS(const MCSubtargetInfo &STI)
bool isLegalSMRDEncodedUnsignedOffset(const MCSubtargetInfo &ST, int64_t EncodedOffset)
bool isGFX9Plus(const MCSubtargetInfo &STI)
bool hasDPPSrc1SGPR(const MCSubtargetInfo &STI)
const int OPR_ID_DUPLICATE
bool isVOPD(unsigned Opc)
VOPD::InstInfo getVOPDInstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
unsigned encodeVmcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Vmcnt)
unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt)
const MIMGBaseOpcodeInfo * getMIMGBaseOpcode(unsigned Opc)
bool isVI(const MCSubtargetInfo &STI)
bool supportsScaleOffset(const MCInstrInfo &MII, unsigned Opcode)
MCRegister mc2PseudoReg(MCRegister Reg)
Convert hardware register Reg to a pseudo register.
unsigned hasKernargPreload(const MCSubtargetInfo &STI)
bool supportsWGP(const MCSubtargetInfo &STI)
LLVM_READNONE unsigned getOperandSize(const MCOperandInfo &OpInfo)
bool isCI(const MCSubtargetInfo &STI)
unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Lgkmcnt)
LLVM_READONLY const MIMGBaseOpcodeInfo * getMIMGBaseOpcodeInfo(unsigned BaseOpcode)
bool isGFX1250Plus(const MCSubtargetInfo &STI)
bool hasPopsExitingWaveID(const MCSubtargetInfo &STI)
unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt)
bool isInlinableLiteralI16(int32_t Literal, bool HasInv2Pi)
bool hasVOPD(const MCSubtargetInfo &STI)
bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi)
Is this literal inlinable.
bool isPermlane16(unsigned Opc)
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ UNDEF
UNDEF - An undefined node.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
void validate(const Triple &TT, const FeatureBitset &FeatureBits)
constexpr bool isAtomicRet(const T &...O)
constexpr bool isVOPC(const T &...O)
constexpr bool isVOP3(const T &...O)
constexpr bool isVOP1(const T &...O)
constexpr bool usesTENSOR_CNT(const T &...O)
constexpr bool isMAI(const T &...O)
constexpr bool isVOP2(const T &...O)
constexpr bool isSWMMAC(const T &...O)
constexpr bool isSOP2(const T &...O)
constexpr bool isFLAT(const T &...O)
constexpr bool isVOP3P(const T &...O)
constexpr bool isBuffer(const T &...O)
constexpr bool hasIntClamp(const T &...O)
constexpr bool isAtomicNoRet(const T &...O)
constexpr bool isSMRD(const T &...O)
constexpr bool isVOP3Like(const T &...O)
constexpr bool isMIMG(const T &...O)
constexpr bool isVMEM(const T &...O)
constexpr bool isImage(const T &...O)
constexpr bool isWMMA(const T &...O)
constexpr bool isVOPD3(const T &...O)
constexpr bool isGWS(const T &...O)
constexpr bool isMUBUF(const T &...O)
constexpr bool isSDWA(const T &...O)
constexpr bool isSOPC(const T &...O)
constexpr bool isDOT(const T &...O)
constexpr bool isVSAMPLE(const T &...O)
constexpr bool isDS(const T &...O)
constexpr bool isAtomic(const T &...O)
constexpr bool isGather4(const T &...O)
constexpr bool isPacked(const T &...O)
constexpr bool isDPP(const T &...O)
constexpr bool isSegmentSpecificFLAT(const T &...O)
@ Valid
The data is already valid.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
EnumSet< Modifier > Modifiers
unsigned getOpcode(const VPValue *V)
Return the instruction opcode for the recipe defining V or 0 for unsupported recipes and VPValues not...
This is an optimization pass for GlobalISel generic memory operations.
bool errorToBool(Error Err)
Helper for converting an Error to a bool.
StringMapEntry< Value * > ValueName
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
static bool isMem(const MachineInstr &MI, unsigned Op)
LLVM_ABI std::pair< StringRef, StringRef > getToken(StringRef Source, StringRef Delimiters=" \t\n\v\f\r")
getToken - This function extracts one token from source, ignoring any leading characters that appear ...
static StringRef getCPU(StringRef CPU)
Processes a CPU name.
testing::Matcher< const detail::ErrorHolder & > Failed()
LLVM_ABI void PrintError(const Twine &Msg)
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
T bit_ceil(T Value)
Returns the smallest integral power of two no smaller than Value if Value is nonzero.
Target & getTheR600Target()
The target for R600 GPUs.
constexpr int popcount(T Value) noexcept
Count the number of set bits in a value.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
SmallVectorImpl< std::unique_ptr< MCParsedAsmOperand > > OperandVector
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
constexpr uint32_t Lo_32(uint64_t Value)
Return the low 32 bits of a 64 bit value.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
Target & getTheGCNTarget()
The target for GCN GPUs.
@ Sub
Subtraction of integers.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
unsigned M0(unsigned Val)
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Target & getTheGCNLegacyTarget()
The target for GCN GPUs, registered under the legacy "amdgcn" architecture name for use with -march.
@ Enabled
Convert any .debug_str_offsets tables to DWARF64 if needed.
void initDefault(const MCSubtargetInfo &STI, MCContext &Ctx, bool InitMCExpr=true)
void validate(const MCSubtargetInfo *STI, MCContext &Ctx)
uint32_t PrivateSegmentSize
SmallVector< std::pair< MCSymbol *, std::string >, 4 > IndirectCalls
SmallVector< std::pair< MCSymbol *, MCSymbol * >, 8 > Calls
SmallVector< FuncInfo, 8 > Funcs
SmallVector< std::pair< MCSymbol *, std::string >, 4 > TypeIds
SmallVector< std::pair< MCSymbol *, MCSymbol * >, 4 > Uses
Instruction set architecture version.
const MCExpr * compute_pgm_rsrc2
const MCExpr * kernarg_size
const MCExpr * kernarg_preload
const MCExpr * compute_pgm_rsrc3
const MCExpr * private_segment_fixed_size
const MCExpr * compute_pgm_rsrc1
static void bits_set(const MCExpr *&Dst, const MCExpr *Value, uint32_t Shift, uint32_t Mask, MCContext &Ctx)
const MCExpr * group_segment_fixed_size
static MCKernelDescriptor getDefaultAmdhsaKernelDescriptor(const MCSubtargetInfo *STI, MCContext &Ctx)
const MCExpr * kernel_code_properties
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...
uint32_t group_segment_fixed_size
uint32_t private_segment_fixed_size