<s> } ; DppCtrlCheck Check = StringSwitch < DppCtrlCheck > ( Ctrl ) . Case ( <STR_LIT> , { DppCtrl :: WAVE_SHL1 , <NUM_LIT> , <NUM_LIT> } ) . Case ( <STR_LIT> , { DppCtrl :: WAVE_ROL1 , <NUM_LIT> , <NUM_LIT> } ) . Case ( <STR_LIT> , { DppCtrl :: WAVE_SHR1 , <NUM_LIT> , <NUM_LIT> } ) . Case ( <STR_LIT> , { DppCtrl :: WAVE_ROR1 , <NUM_LIT> , <NUM_LIT> } ) . Case ( <STR_LIT> , { DppCtrl :: ROW_SHL0 , <NUM_LIT> , <NUM_LIT> } ) . Case ( <STR_LIT> , { DppCtrl :: ROW_SHR0 , <NUM_LIT> , <NUM_LIT> } ) . Case ( <STR_LIT> , { DppCtrl :: ROW_ROR0 , <NUM_LIT> , <NUM_LIT> } ) . Case ( <STR_LIT> , { DppCtrl :: ROW_SHARE_FIRST , <NUM_LIT> , <NUM_LIT> } ) . Case ( <STR_LIT> , { DppCtrl :: ROW_XMASK_FIRST , <NUM_LIT> , <NUM_LIT> } ) . Default ( { - <NUM_LIT> , <NUM_LIT> , <NUM_LIT> } ) ; bool Valid ; if ( Check . Ctrl == - <NUM_LIT> ) { Valid = ( Ctrl == <STR_LIT> && ( Val == <NUM_LIT> || Val == <NUM_LIT> ) ) ; Val = ( Val == <NUM_LIT> ) ? DppCtrl :: BCAST15 : DppCtrl :: BCAST31 ;


<s> Name = parseMnemonicSuffix ( Name ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateToken ( this , Name , NameLoc ) ) ; bool IsMIMG = Name . startswith ( <STR_LIT> ) ; while ( ! trySkipToken ( AsmToken :: EndOfStatement ) ) { OperandMode Mode = OperandMode_Default ; if ( IsMIMG && isGFX10Plus ( ) && Operands . size ( ) == <NUM_LIT> ) Mode = OperandMode_NSA ; OperandMatchResultTy Res = parseOperand ( Operands , Name , Mode ) ; trySkipToken ( AsmToken :: Comma ) ; if ( Res != MatchOperand_Success ) { checkUnsupportedInstruction ( Name , NameLoc ) ; if ( ! Parser . hasPendingError ( ) ) { StringRef Msg = ( Res == MatchOperand_ParseFail ) ? <STR_LIT> : <STR_LIT> ; Error ( getLoc ( ) , Msg ) ; } while ( ! trySkipToken ( AsmToken :: EndOfStatement ) ) { lex ( ) ; } return true ; } }


<s> Operands . push_back ( <ISA_LIT>Operand :: CreateToken ( this , Name , NameLoc ) ) ; bool IsMIMG = Name . startswith ( <STR_LIT> ) ; while ( ! trySkipToken ( AsmToken :: EndOfStatement ) ) { OperandMode Mode = OperandMode_Default ; if ( IsMIMG && isGFX10Plus ( ) && Operands . size ( ) == <NUM_LIT> ) Mode = OperandMode_NSA ; OperandMatchResultTy Res = parseOperand ( Operands , Name , Mode ) ; trySkipToken ( AsmToken :: Comma ) ; if ( Res != MatchOperand_Success ) { checkUnsupportedInstruction ( Name , NameLoc ) ; if ( ! Parser . hasPendingError ( ) ) { StringRef Msg = ( Res == MatchOperand_ParseFail ) ? <STR_LIT> :


<s> switch ( getTokenKind ( ) ) { case AsmToken :: Identifier : { StringRef Tok = getTokenStr ( ) ; if ( Tok == Name ) { if ( Tok == <STR_LIT> && ! hasMIMG_R128 ( ) ) Error ( S , <STR_LIT> ) ; if ( Tok == <STR_LIT> && ! isGFX9 ( ) && ! hasGFX10A16 ( ) ) Error ( S , <STR_LIT> ) ; Bit = <NUM_LIT> ; Parser . Lex ( ) ; } else if ( Tok . startswith ( <STR_LIT> ) && Tok . endswith ( Name ) ) { Bit = <NUM_LIT> ; Parser . Lex ( ) ; } else {


<s> unsigned Reg , RegNum , RegWidth ; if ( ! Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth ) ) { return nullptr ; } if ( isHsaAbiVersion3 ( & getSTI ( ) ) ) { if ( ! updateGprCountSymbols ( RegKind , RegNum , RegWidth ) ) return nullptr ; } else KernelScope . usesRegister ( RegKind , RegNum , RegWidth ) ;

return <ISA_LIT>Operand :: CreateReg ( this , Reg , StartLoc , EndLoc ) ;


<s> if ( ! updateGprCountSymbols ( RegKind , RegNum , RegWidth ) ) return nullptr ; } else KernelScope . usesRegister ( RegKind , RegNum , RegWidth ) ;


<s> case <STR_LIT> : case <STR_LIT> : return isGFX9Plus ( ) ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return ! isGFX9Plus ( ) ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return ( isVI ( ) || isGFX9 ( ) ) && hasXNACK ( ) ; case <STR_LIT> : return isGFX10Plus ( ) ; default : break ; } if ( isCI ( ) ) return true ; if ( is<ISA_LIT> ( ) || isGFX10Plus ( ) ) { switch ( RegNo ) {


<s> int GLCPos = <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: glc1 ) ; if ( GLCPos != - <NUM_LIT> ) { if ( Inst . getOperand ( GLCPos ) . getImm ( ) == - <NUM_LIT> ) { Error ( IDLoc , <STR_LIT> ) ; return false ; }


<s> bool <ISA_LIT>AsmParser :: validateCoherencyBits ( const MCInst & Inst , const OperandVector & Operands , const SMLoc & IDLoc ) { int GLCPos = <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: glc1 ) ; if ( GLCPos != - <NUM_LIT> ) { if ( Inst . getOperand ( GLCPos ) . getImm ( ) == - <NUM_LIT> ) { Error ( IDLoc , <STR_LIT> ) ;


<s> auto OpNum = <STR_LIT> ( Opcode , <STR_LIT> :: offset ) ; assert ( OpNum != - <NUM_LIT> ) ; const auto & Op = Inst . getOperand ( OpNum ) ; if ( ! hasFlatOffsets ( ) && Op . getImm ( ) != <NUM_LIT> ) { Error ( getFlatOffsetLoc ( Operands ) , <STR_LIT> ) ; return false ; } if ( TSFlags & ( <STR_LIT> | <STR_LIT> ) ) { unsigned OffsetSize = <STR_LIT> ( getSTI ( ) , true ) ; if ( ! isIntN ( OffsetSize , Op . getImm ( ) ) ) { Error ( getFlatOffsetLoc ( Operands ) , Twine ( <STR_LIT> ) + Twine ( OffsetSize ) + <STR_LIT> ) ; return false ; } } else { unsigned OffsetSize = <STR_LIT> ( getSTI ( ) , false ) ; if ( ! isUIntN ( OffsetSize , Op . getImm ( ) ) ) { Error ( getFlatOffsetLoc ( Operands ) , Twine ( <STR_LIT> ) + Twine ( OffsetSize ) + <STR_LIT> ) ; return false ; } }


<s> if ( ! hasFlatOffsets ( ) && Op . getImm ( ) != <NUM_LIT> ) { Error ( getFlatOffsetLoc ( Operands ) , <STR_LIT> ) ; return false ; } if ( TSFlags & ( <STR_LIT> | <STR_LIT> ) ) { unsigned OffsetSize = <STR_LIT> ( getSTI ( ) , true ) ; if ( ! isIntN ( OffsetSize , Op . getImm ( ) ) ) { Error ( getFlatOffsetLoc ( Operands ) , Twine ( <STR_LIT> ) + Twine ( OffsetSize ) + <STR_LIT> ) ; return false ; } } else { unsigned OffsetSize = <STR_LIT> ( getSTI ( ) , false ) ; if ( ! isUIntN ( OffsetSize , Op . getImm ( ) ) ) { Error ( getFlatOffsetLoc ( Operands ) , Twine ( <STR_LIT> ) + Twine ( OffsetSize ) + <STR_LIT> ) ; return false ; } }


<s> return false ; } if ( ! validateMIMGGatherDMask ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyDMask , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMovrels ( Inst , Operands ) ) { return false ; } if ( ! validateFlatOffset ( Inst , Operands ) ) { return false ; } if ( ! validateSMEMOffset ( Inst , Operands ) ) { return false ; } if ( ! validateMAIAccWrite ( Inst , Operands ) ) { return false ; } if ( ! validateDivScale ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateCoherencyBits ( Inst , Operands , IDLoc ) ) { return false ; } return true ;


<s> Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyD16 , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMIMGDim ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGDataSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAddrSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAtomicDMask ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyDMask , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMIMGGatherDMask ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyDMask , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMovrels ( Inst , Operands ) ) {


<s> const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> || ! isGFX10Plus ( ) ) return true ; const <STR_LIT> * Info = <STR_LIT> ( Opc ) ; const <STR_LIT> * BaseOpcode = <STR_LIT> ( Info -> BaseOpcode ) ; int VAddr0Idx = <STR_LIT> ( Opc , <STR_LIT> :: vaddr0 ) ; int SrsrcIdx = <STR_LIT> ( Opc , <STR_LIT> :: srsrc ) ; int DimIdx = <STR_LIT> ( Opc , <STR_LIT> :: dim ) ; assert ( VAddr0Idx != - <NUM_LIT> ) ; assert ( SrsrcIdx != - <NUM_LIT> ) ; assert ( SrsrcIdx > VAddr0Idx ) ; if ( DimIdx == - <NUM_LIT> ) return true ; unsigned Dim = Inst . getOperand ( DimIdx ) . getImm ( ) ; const <STR_LIT> * DimInfo = <STR_LIT> ( Dim ) ; bool IsNSA = SrsrcIdx - VAddr0Idx > <NUM_LIT> ; unsigned VAddrSize = IsNSA ? SrsrcIdx - VAddr0Idx : <STR_LIT> ( getMRI ( ) , Desc , VAddr0Idx ) / <NUM_LIT> ;

unsigned AddrSize = BaseOpcode -> NumExtraArgs + ( BaseOpcode -> Gradients ? DimInfo -> NumGradients : <NUM_LIT> ) + ( BaseOpcode -> Coordinates ? DimInfo -> NumCoords : <NUM_LIT> ) + ( BaseOpcode -> LodOrClampOrMip ? <NUM_LIT> : <NUM_LIT> ) ;


<s> if ( ! isValidMsgId ( Msg . Id , getSTI ( ) , Strict ) ) { Error ( Msg . Loc , <STR_LIT> ) ; return false ; } if ( Strict && ( msgRequiresOp ( Msg . Id ) != Op . IsDefined ) ) { if ( Op . IsDefined ) { Error ( Op . Loc , <STR_LIT> ) ; } else { Error ( Msg . Loc , <STR_LIT> ) ; } return false ; } if ( ! isValidMsgOp ( Msg . Id , Op . Id , Strict ) ) { Error ( Op . Loc , <STR_LIT> ) ; return false ; } if ( Strict && ! msgSupportsStream ( Msg . Id , Op . Id ) && Stream . IsDefined ) { Error ( Stream . Loc , <STR_LIT> ) ; return false ; }

if ( ! isValidMsgStream ( Msg . Id , Op . Id , Stream . Id , Strict ) ) {


<s> bool <ISA_LIT>AsmParser :: validateVOP3Literal ( const MCInst & Inst , const OperandVector & Operands ) { unsigned Opcode = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opcode ) ; if ( ! ( Desc . TSFlags & ( <STR_LIT> | <STR_LIT> ) ) ) return true ; const int Src0Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src0 ) ; const int Src1Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src1 ) ; const int Src2Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src2 ) ; const int OpIndices [ ] = { Src0Idx , Src1Idx , Src2Idx } ; unsigned NumExprs = <NUM_LIT> ; unsigned NumLiterals = <NUM_LIT> ; uint32_t LiteralValue ; for ( int OpIdx : OpIndices ) { if ( OpIdx == - <NUM_LIT> ) break ; const MCOperand & MO = Inst . getOperand ( OpIdx ) ; if ( ! MO . isImm ( ) && ! MO . isExpr ( ) ) continue ; if ( ! <STR_LIT> ( Desc , OpIdx ) ) continue ; if ( OpIdx == Src2Idx && ( Desc . TSFlags & <STR_LIT> ) && getFeatureBits ( ) [ <STR_LIT> ] ) { Error ( getConstLoc ( Operands ) , <STR_LIT> ) ; return false ; } if ( MO . isImm ( ) && ! isInlineConstant ( Inst , OpIdx ) ) { uint32_t Value = static_cast < uint32_t > ( MO . getImm ( ) ) ; if ( NumLiterals == <NUM_LIT> || LiteralValue != Value ) { LiteralValue = Value ; ++ NumLiterals ; } } else if ( MO . isExpr ( ) ) { ++ NumExprs ; } } NumLiterals += NumExprs ; if ( ! NumLiterals ) return true ; if ( ! getFeatureBits ( ) [ <STR_LIT> ] ) { Error ( getLitLoc ( Operands ) , <STR_LIT> ) ; return false ;


<s> case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : if ( isSafeTruncation ( Val , <NUM_LIT> ) && <STR_LIT> ( static_cast < int32_t > ( Val ) , AsmParser -> hasInv2PiInlineImm ( ) ) ) { Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; setImmKindConst ( ) ; return ; } Inst . addOperand ( MCOperand :: createImm ( Val & <NUM_LIT> ) ) ; setImmKindLiteral ( ) ; return ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : if ( <STR_LIT> ( Val , AsmParser -> hasInv2PiInlineImm ( ) ) ) { Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; setImmKindConst ( ) ; return ; } Inst . addOperand ( MCOperand :: createImm ( Lo_32 ( Val ) ) ) ; setImmKindLiteral ( ) ; return ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : if ( isSafeTruncation ( Val , <NUM_LIT> ) && <STR_LIT> ( static_cast < int16_t > ( Val ) , AsmParser -> hasInv2PiInlineImm ( ) ) ) { Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; setImmKindConst ( ) ; return ; } Inst . addOperand ( MCOperand :: createImm ( Val & <NUM_LIT> ) ) ; setImmKindLiteral ( ) ; return ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : { assert ( isSafeTruncation ( Val , <NUM_LIT> ) ) ; assert ( <STR_LIT> ( static_cast < int16_t > ( Val ) , AsmParser -> hasInv2PiInlineImm ( ) ) ) ; Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; return ;


<s> unsigned Sub = MRI -> getSubReg ( Op . getReg ( ) , <STR_LIT> ) ; auto Reg = Sub ? Sub : Op . getReg ( ) ;

const MCRegisterClass & AGRP32 = MRI -> getRegClass ( <STR_LIT> ) ;


<s> bool <ISA_LIT>AsmParser :: validateGWS ( const MCInst & Inst , const OperandVector & Operands ) { if ( ! getFeatureBits ( ) [ <STR_LIT> ] ) return true ; int Opc = Inst . getOpcode ( ) ; if ( Opc != <STR_LIT> && Opc != <STR_LIT> && Opc != <STR_LIT> ) return true ;

const MCRegisterInfo * MRI = getMRI ( ) ;


<s> int Opc = Inst . getOpcode ( ) ; if ( Opc != <STR_LIT> && Opc != <STR_LIT> && Opc != <STR_LIT> ) return true ; const MCRegisterInfo * MRI = getMRI ( ) ; const MCRegisterClass & VGRP32 = MRI -> getRegClass ( <STR_LIT> ) ; int Data0Pos = <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: data0 ) ; assert ( Data0Pos != - <NUM_LIT> ) ;

auto Reg = Inst . getOperand ( Data0Pos ) . getReg ( ) ;


<s> const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> || ! isGFX10Plus ( ) ) return true ; const <STR_LIT> * Info = <STR_LIT> ( Opc ) ; const <STR_LIT> * BaseOpcode = <STR_LIT> ( Info -> BaseOpcode ) ; int VAddr0Idx = <STR_LIT> ( Opc , <STR_LIT> :: vaddr0 ) ; int SrsrcIdx = <STR_LIT> ( Opc , <STR_LIT> :: srsrc ) ; int DimIdx = <STR_LIT> ( Opc , <STR_LIT> :: dim ) ; int A16Idx = <STR_LIT> ( Opc , <STR_LIT> :: a16 ) ; assert ( VAddr0Idx != - <NUM_LIT> ) ; assert ( SrsrcIdx != - <NUM_LIT> ) ; assert ( SrsrcIdx > VAddr0Idx ) ; if ( DimIdx == - <NUM_LIT> ) return true ; unsigned Dim = Inst . getOperand ( DimIdx ) . getImm ( ) ; const <STR_LIT> * DimInfo = <STR_LIT> ( Dim ) ; bool IsNSA = SrsrcIdx - VAddr0Idx > <NUM_LIT> ; unsigned VAddrSize = IsNSA ? SrsrcIdx - VAddr0Idx : <STR_LIT> ( getMRI ( ) , Desc , VAddr0Idx ) / <NUM_LIT> ;

bool IsA16 = ( A16Idx != - <NUM_LIT> && Inst . getOperand ( A16Idx ) . getImm ( ) ) ;


<s> const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> || ! isGFX10Plus ( ) ) return true ; const <STR_LIT> * Info = <STR_LIT> ( Opc ) ; const <STR_LIT> * BaseOpcode = <STR_LIT> ( Info -> BaseOpcode ) ; int VAddr0Idx = <STR_LIT> ( Opc , <STR_LIT> :: vaddr0 ) ; int SrsrcIdx = <STR_LIT> ( Opc , <STR_LIT> :: srsrc ) ; int DimIdx = <STR_LIT> ( Opc , <STR_LIT> :: dim ) ; int A16Idx = <STR_LIT> ( Opc , <STR_LIT> :: a16 ) ; assert ( VAddr0Idx != - <NUM_LIT> ) ; assert ( SrsrcIdx != - <NUM_LIT> ) ; assert ( SrsrcIdx > VAddr0Idx ) ; if ( DimIdx == - <NUM_LIT> ) return true ; unsigned Dim = Inst . getOperand ( DimIdx ) . getImm ( ) ; const <STR_LIT> * DimInfo = <STR_LIT> ( Dim ) ; bool IsNSA = SrsrcIdx - VAddr0Idx > <NUM_LIT> ; unsigned VAddrSize = IsNSA ? SrsrcIdx - VAddr0Idx : <STR_LIT> ( getMRI ( ) , Desc , VAddr0Idx ) / <NUM_LIT> ; bool IsA16 = ( A16Idx != - <NUM_LIT> && Inst . getOperand ( A16Idx ) . getImm ( ) ) ; unsigned AddrSize = <STR_LIT> ( BaseOpcode , DimInfo , IsA16 , hasG16 ( ) ) ; if ( ! IsNSA ) {

if ( AddrSize > <NUM_LIT> ) AddrSize = <NUM_LIT> ;


<s> const MCRegisterInfo * MRI = getMRI ( ) ; const MCRegisterClass & VGRP32 = MRI -> getRegClass ( <STR_LIT> ) ; const MCRegisterClass & AGRP32 = MRI -> getRegClass ( <STR_LIT> ) ; for ( unsigned I = <NUM_LIT> , E = Inst . getNumOperands ( ) ; I != E ; ++ I ) { const MCOperand & Op = Inst . getOperand ( I ) ; if ( ! Op . isReg ( ) ) continue ; unsigned Sub = MRI -> getSubReg ( Op . getReg ( ) , <STR_LIT> ) ; if ( ! Sub ) continue ; if ( VGRP32 . contains ( Sub ) && ( ( Sub - <STR_LIT> ) & <NUM_LIT> ) ) return false ;

if ( AGRP32 . contains ( Sub ) && ( ( Sub - <STR_LIT> ) & <NUM_LIT> ) ) return false ;


<s> auto FB = getFeatureBits ( ) ; if ( ! FB [ <STR_LIT> ] ) return true ; const MCRegisterInfo * MRI = getMRI ( ) ; const MCRegisterClass & VGRP32 = MRI -> getRegClass ( <STR_LIT> ) ; const MCRegisterClass & AGRP32 = MRI -> getRegClass ( <STR_LIT> ) ; for ( unsigned I = <NUM_LIT> , E = Inst . getNumOperands ( ) ; I != E ; ++ I ) { const MCOperand & Op = Inst . getOperand ( I ) ; if ( ! Op . isReg ( ) ) continue ; unsigned Sub = MRI -> getSubReg ( Op . getReg ( ) , <STR_LIT> ) ;


<s> auto OpNum = Inst . getNumOperands ( ) ; assert ( <STR_LIT> ( InstDesc , OpNum ) ) ; if ( ApplyModifiers ) { assert ( <STR_LIT> ( InstDesc , OpNum ) ) ; const unsigned Size = Imm . IsFPImm ? sizeof ( double ) : getOperandSize ( InstDesc , OpNum ) ; Val = applyInputFPModifiers ( Val , Size ) ; } APInt Literal ( <NUM_LIT> , Val ) ; uint8_t OpTy = InstDesc . OpInfo [ OpNum ] . OperandType ; if ( Imm . IsFPImm ) { switch ( OpTy ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : if ( <STR_LIT> ( Literal . getZExtValue ( ) , AsmParser -> hasInv2PiInlineImm ( ) ) ) { Inst . addOperand ( MCOperand :: createImm ( Literal . getZExtValue ( ) ) ) ; return ; } if ( <STR_LIT> ( InstDesc , OpNum ) ) { if ( Literal . getLoBits ( <NUM_LIT> ) != <NUM_LIT> ) { const_cast < <ISA_LIT>AsmParser * > ( AsmParser ) -> Warning ( Inst . getLoc ( ) , <STR_LIT> <STR_LIT> ) ; } Inst . addOperand ( MCOperand :: createImm ( Literal . lshr ( <NUM_LIT> ) . getZExtValue ( ) ) ) ; return ; } llvm_unreachable ( <STR_LIT> ) ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : { bool lost ; APFloat FPLiteral ( APFloat :: IEEEdouble ( ) , Literal ) ; FPLiteral . convert ( * getOpFltSemantics ( OpTy ) , APFloat :: rmNearestTiesToEven , & lost ) ; uint64_t ImmVal = FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ; Inst . addOperand ( MCOperand :: createImm ( ImmVal ) ) ; return ; } default : llvm_unreachable ( <STR_LIT> ) ; } return ; } switch ( OpTy ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : if ( isSafeTruncation ( Val , <NUM_LIT> ) && <STR_LIT> ( static_cast < int32_t > ( Val ) , AsmParser -> hasInv2PiInlineImm ( ) ) ) { Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; return ; } Inst . addOperand ( MCOperand :: createImm ( Val & <NUM_LIT> ) ) ; return ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : if ( <STR_LIT> ( Val , AsmParser -> hasInv2PiInlineImm ( ) ) ) { Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; return ; } Inst . addOperand ( MCOperand :: createImm ( Lo_32 ( Val ) ) ) ; return ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :

if ( isSafeTruncation ( Val , <NUM_LIT> ) && <STR_LIT> ( static_cast < int16_t > ( Val ) , AsmParser -> hasInv2PiInlineImm ( ) ) ) {


<s> } } if ( TSFlags & <STR_LIT> ) { auto Opcode = Inst . getOpcode ( ) ; auto OpNum = <STR_LIT> ( Opcode , <STR_LIT> :: offset ) ; const auto & Op = Inst . getOperand ( OpNum ) ; if ( ! hasFlatOffsets ( ) && Op . getImm ( ) != <NUM_LIT> ) return Match_InvalidOperand ; if ( isGFX10 ( ) ) { if ( TSFlags & <STR_LIT> ) { if ( ! isInt < <NUM_LIT> > ( Op . getImm ( ) ) ) return Match_InvalidOperand ; } else { if ( ! isUInt < <NUM_LIT> > ( Op . getImm ( ) ) ) return Match_InvalidOperand ; }


<s> case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return & APFloat :: IEEEdouble ( ) ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> case <STR_LIT> : return & APFloat :: IEEEsingle ( ) ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return & APFloat :: IEEEdouble ( ) ; case <STR_LIT> : case <STR_LIT> :


<s> } const MCOperand & MO = Inst . getOperand ( OpIdx ) ; int64_t Val = MO . getImm ( ) ; auto OpSize = <STR_LIT> ( Desc , OpIdx ) ; switch ( OpSize ) { case <NUM_LIT> : return <STR_LIT> ( Val , hasInv2PiInlineImm ( ) ) ; case <NUM_LIT> :


<s> std :: string Suggestion = <ISA_LIT>MnemonicSpellCheck ( ( ( <ISA_LIT>Operand & ) * Operands [ <NUM_LIT> ] ) . getToken ( ) , FBS ) ; return Error ( IDLoc , <STR_LIT> + Suggestion , ( ( <ISA_LIT>Operand & ) * Operands [ <NUM_LIT> ] ) . getLocRange ( ) ) ; } case Match_InvalidOperand : { SMLoc ErrorLoc = IDLoc ; if ( ErrorInfo != ~ <NUM_LIT> ) { if ( ErrorInfo >= Operands . size ( ) ) { return Error ( IDLoc , <STR_LIT> ) ; } ErrorLoc = ( ( <ISA_LIT>Operand & ) * Operands [ ErrorInfo ] ) . getStartLoc ( ) ; if ( ErrorLoc == SMLoc ( ) ) ErrorLoc = IDLoc ; } return Error ( ErrorLoc , <STR_LIT> ) ;


<s> if ( ( R == Match_Success ) || ( R == Match_PreferE32 ) || ( R == Match_MissingFeature && Result != Match_PreferE32 ) || ( R == Match_InvalidOperand && Result != Match_MissingFeature && Result != Match_PreferE32 ) || ( R == Match_MnemonicFail && Result != Match_InvalidOperand && Result != Match_MissingFeature && Result != Match_PreferE32 ) ) { Result = R ; ErrorInfo = EI ; } if ( R == Match_Success ) break ; } switch ( Result ) { default : break ; case Match_Success : if ( ! validateInstruction ( Inst , IDLoc ) ) { return true ; } Inst . setLoc ( IDLoc ) ; Out . EmitInstruction ( Inst , getSTI ( ) ) ; return false ; case Match_MissingFeature : return Error ( IDLoc , <STR_LIT> ) ; case Match_MnemonicFail : { FeatureBitset FBS = ComputeAvailableFeatures ( getSTI ( ) . getFeatureBits ( ) ) ; std :: string Suggestion = <ISA_LIT>MnemonicSpellCheck ( ( ( <ISA_LIT>Operand & ) * Operands [ <NUM_LIT> ] ) . getToken ( ) , FBS ) ; return Error ( IDLoc , <STR_LIT> + Suggestion , ( ( <ISA_LIT>Operand & ) * Operands [ <NUM_LIT> ] ) . getLocRange ( ) ) ; }


<s> using namespace llvm :: <STR_LIT> ; int64_t ImmVal = <NUM_LIT> ; SMLoc Loc = getLoc ( ) ; if ( trySkipId ( <STR_LIT> , AsmToken :: LParen ) ) { OperandInfoTy HwReg ( ID_UNKNOWN_ ) ; int64_t Offset = OFFSET_DEFAULT_ ; int64_t Width = WIDTH_DEFAULT_ ; if ( parseHwregBody ( HwReg , Offset , Width ) ) { validateHwreg ( HwReg , Offset , Width , Loc ) ; ImmVal = encodeHwreg ( HwReg . Id , Offset , Width ) ; } } else if ( parseExpr ( ImmVal ) ) { if ( ImmVal < <NUM_LIT> || ! isUInt < <NUM_LIT> > ( ImmVal ) ) Error ( Loc , <STR_LIT> ) ;


<s> switch ( getLexer ( ) . getKind ( ) ) { case AsmToken :: Identifier : { StringRef Tok = Parser . getTok ( ) . getString ( ) ; if ( Tok == Name ) { if ( Tok == <STR_LIT> && isGFX9 ( ) ) Error ( S , <STR_LIT> ) ; if ( Tok == <STR_LIT> && ! isGFX9 ( ) ) Error ( S , <STR_LIT> ) ; Bit = <NUM_LIT> ; Parser . Lex ( ) ; } else if ( Tok . startswith ( <STR_LIT> ) && Tok . endswith ( Name ) ) { Bit = <NUM_LIT> ; Parser . Lex ( ) ; } else { return MatchOperand_NoMatch ; } break ; } default : return MatchOperand_NoMatch ; } }

if ( ! isGFX10 ( ) && ImmTy == <ISA_LIT>Operand :: ImmTyDLC ) return MatchOperand_ParseFail ;


<s> else Error ( S , <STR_LIT> ) ; break ; } if ( Operation . Id == OP_GS_NOP && Msg . Id != ID_GS_DONE ) { Error ( S , <STR_LIT> ) ; break ; } Imm16Val |= ( Operation . Id << OP_SHIFT_ ) ; } if ( Msg . Id == ID_SYSMSG ) { if ( ! ( OP_SYS_FIRST_ <= Operation . Id && Operation . Id < OP_SYS_LAST_ ) ) { if ( Operation . IsSymbolic ) Error ( S , <STR_LIT> ) ; else Error ( S , <STR_LIT> ) ; break ; } Imm16Val |= ( Operation . Id << OP_SHIFT_ ) ; } if ( ( Msg . Id == ID_GS || Msg . Id == ID_GS_DONE ) && Operation . Id != OP_GS_NOP ) { if ( ! ( STREAM_ID_FIRST_ <= StreamId && StreamId < STREAM_ID_LAST_ ) ) { Error ( S , <STR_LIT> ) ; break ; } Imm16Val |= ( StreamId << STREAM_ID_SHIFT_ ) ; } } while ( false ) ;


<s> case ImmTyUNorm : OS << <STR_LIT> ; break ; case ImmTyDA : OS << <STR_LIT> ; break ; case ImmTyR128A16 : OS << <STR_LIT> ; break ; case ImmTyLWE : OS << <STR_LIT> ; break ; case ImmTyOff : OS << <STR_LIT> ; break ; case ImmTyExpTgt : OS << <STR_LIT> ; break ; case ImmTyExpCompr : OS << <STR_LIT> ; break ; case ImmTyExpVM : OS << <STR_LIT> ; break ; case ImmTyHwreg : OS << <STR_LIT> ; break ; case ImmTySendMsg : OS << <STR_LIT> ; break ; case ImmTyInterpSlot : OS << <STR_LIT> ; break ; case ImmTyInterpAttr : OS << <STR_LIT> ; break ; case ImmTyAttrChan : OS << <STR_LIT> ; break ; case ImmTyOpSel : OS << <STR_LIT> ; break ; case ImmTyOpSelHi : OS << <STR_LIT> ; break ; case ImmTyNegLo : OS << <STR_LIT> ; break ; case ImmTyNegHi : OS << <STR_LIT> ; break ; case ImmTySwizzle : OS << <STR_LIT> ; break ; case ImmTyGprIdxMode : OS << <STR_LIT> ; break ; case ImmTyHigh : OS << <STR_LIT> ; break ; case ImmTyEndpgm : OS << <STR_LIT> ;


<s> Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateSOPLiteral ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateVOP3Literal ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateConstantBusLimitations ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateEarlyClobberLimitations ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateIntClampSupported ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateOpSel ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGD16 ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGDim ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGDataSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAddrSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAtomicDMask ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGGatherDMask ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; }


<s> Error ( Loc , Twine ( DepCtrName , <STR_LIT> ) ) ; return ; case OPR_ID_DUPLICATE : Error ( Loc , Twine ( <STR_LIT> , DepCtrName ) ) ; return ;


<s> bool <ISA_LIT>Operand :: isDepCtr ( ) const {


<s> if ( ! skipToken ( AsmToken :: Identifier , <STR_LIT> ) || ! skipToken ( AsmToken :: LParen , <STR_LIT> ) ) return false ; int64_t ExprVal ; if ( ! parseExpr ( ExprVal ) ) return false ; unsigned PrevOprMask = UsedOprMask ; int CntVal = encodeDepCtr ( DepCtrName , ExprVal , UsedOprMask , getSTI ( ) ) ;


<s> return false ; } if ( ! skipToken ( AsmToken :: RParen , <STR_LIT> ) ) return false ; if ( trySkipToken ( AsmToken :: Amp ) || trySkipToken ( AsmToken :: Comma ) ) { if ( isToken ( AsmToken :: EndOfStatement ) ) { Error ( getLoc ( ) , <STR_LIT> ) ; return false ; }


<s> MCContext & Ctx = getContext ( ) ; MCSymbol * Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Major , Ctx ) ) ; Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Minor , Ctx ) ) ; Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ;

Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Stepping , Ctx ) ) ;


<s> MCContext & Ctx = getContext ( ) ; MCSymbol * Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Major , Ctx ) ) ; Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ;

Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Minor , Ctx ) ) ;


<s> getTargetStreamer ( ) . EmitDirectiveHSACodeObjectISA ( ISA . Major , ISA . Minor , ISA . Stepping , <STR_LIT> , <STR_LIT> ) ; return false ; } if ( ParseDirectiveMajorMinor ( Major , Minor ) ) return true ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ; Lex ( ) ; if ( ParseAsAbsoluteExpression ( Stepping ) ) return TokError ( <STR_LIT> ) ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: String ) ) return TokError ( <STR_LIT> ) ; VendorName = getLexer ( ) . getTok ( ) . getStringContents ( ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: String ) ) return TokError ( <STR_LIT> ) ; ArchName = getLexer ( ) . getTok ( ) . getStringContents ( ) ; Lex ( ) ; getTargetStreamer ( ) . EmitDirectiveHSACodeObjectISA ( Major , Minor , Stepping , VendorName , ArchName ) ; return false ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseSWaitCntOps ( OperandVector & Operands ) { <STR_LIT> :: IsaVersion ISA = <STR_LIT> :: getIsaVersion ( getSTI ( ) . getFeatureBits ( ) ) ; int64_t Waitcnt = getWaitcntBitMask ( ISA ) ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; switch ( getLexer ( ) . getKind ( ) ) { default : return MatchOperand_ParseFail ; case AsmToken :: Integer : if ( getParser ( ) . parseAbsoluteExpression ( Waitcnt ) ) return MatchOperand_ParseFail ; break ; case AsmToken :: Identifier : do { if ( parseCnt ( Waitcnt ) ) return MatchOperand_ParseFail ; } while ( getLexer ( ) . isNot ( AsmToken :: EndOfStatement ) ) ;


<s> SMLoc S = Parser . getTok ( ) . getLoc ( ) ; switch ( getLexer ( ) . getKind ( ) ) { default : return MatchOperand_ParseFail ; case AsmToken :: Integer : if ( getParser ( ) . parseAbsoluteExpression ( Waitcnt ) ) return MatchOperand_ParseFail ; break ; case AsmToken :: Identifier : do { if ( parseCnt ( Waitcnt ) ) return MatchOperand_ParseFail ; } while ( getLexer ( ) . isNot ( AsmToken :: EndOfStatement ) ) ; break ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Waitcnt , S ) ) ;


<s> unsigned <ISA_LIT>AsmParser :: getConstantBusLimit ( unsigned Opcode ) const { if ( ! isGFX10Plus ( ) ) return <NUM_LIT> ; switch ( Opcode ) { case <STR_LIT> :


<s> if ( getLexer ( ) . isNot ( AsmToken :: Identifier ) ) return MatchOperand_NoMatch ; if ( getLexer ( ) . getTok ( ) . getString ( ) != <STR_LIT> ) return MatchOperand_NoMatch ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Colon ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; std :: string Token ; if ( getLexer ( ) . is ( AsmToken :: Integer ) ) { SMLoc Loc = getLexer ( ) . getTok ( ) . getEndLoc ( ) ; Token = std :: string ( getLexer ( ) . getTok ( ) . getString ( ) ) ; Parser . Lex ( ) ;

if ( getLexer ( ) . getTok ( ) . getLoc ( ) != Loc ) return MatchOperand_ParseFail ;


<s> std :: string Token ; if ( getLexer ( ) . is ( AsmToken :: Integer ) ) { SMLoc Loc = getLexer ( ) . getTok ( ) . getEndLoc ( ) ; Token = std :: string ( getLexer ( ) . getTok ( ) . getString ( ) ) ; Parser . Lex ( ) ; if ( getLexer ( ) . getTok ( ) . getLoc ( ) != Loc ) return MatchOperand_ParseFail ; } if ( getLexer ( ) . isNot ( AsmToken :: Identifier ) ) return MatchOperand_ParseFail ; Token += getLexer ( ) . getTok ( ) . getString ( ) ; StringRef DimId = Token ;

if ( DimId . startswith ( <STR_LIT> ) ) DimId = DimId . substr ( <NUM_LIT> ) ;


<s> std :: string HSAMetadataString ; if ( ParseToEndDirective ( AssemblerDirectiveBegin , AssemblerDirectiveEnd , HSAMetadataString ) ) return true ; if ( isHsaAbiVersion3 ( & getSTI ( ) ) ) { if ( ! getTargetStreamer ( ) . EmitHSAMetadataV3 ( HSAMetadataString ) ) return Error ( getParser ( ) . getTok ( ) . getLoc ( ) , <STR_LIT> ) ; } else {

if ( ! getTargetStreamer ( ) . EmitHSAMetadataV2 ( HSAMetadataString ) ) return Error ( getParser ( ) . getTok ( ) . getLoc ( ) , <STR_LIT> ) ;


<s> bool <ISA_LIT>AsmParser :: ParseDirectiveHSAMetadata ( ) { const char * AssemblerDirectiveBegin ; const char * AssemblerDirectiveEnd ; std :: tie ( AssemblerDirectiveBegin , AssemblerDirectiveEnd ) = isHsaAbiVersion3 ( & getSTI ( ) ) ? std :: make_tuple ( HSAMD :: V3 :: AssemblerDirectiveBegin , HSAMD :: V3 :: AssemblerDirectiveEnd ) : std :: make_tuple ( HSAMD :: AssemblerDirectiveBegin , HSAMD :: AssemblerDirectiveEnd ) ; if ( getSTI ( ) . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) { return Error ( getParser ( ) . getTok ( ) . getLoc ( ) , ( Twine ( AssemblerDirectiveBegin ) + Twine ( <STR_LIT> <STR_LIT> ) ) . str ( ) ) ; } std :: string HSAMetadataString ; if ( ParseToEndDirective ( AssemblerDirectiveBegin , AssemblerDirectiveEnd , HSAMetadataString ) ) return true ; if ( isHsaAbiVersion3 ( & getSTI ( ) ) ) { if ( ! getTargetStreamer ( ) . EmitHSAMetadataV3 ( HSAMetadataString ) ) return Error ( getParser ( ) . getTok ( ) . getLoc ( ) , <STR_LIT> ) ; } else { if ( ! getTargetStreamer ( ) . EmitHSAMetadataV2 ( HSAMetadataString ) ) return Error ( getParser ( ) . getTok ( ) . getLoc ( ) , <STR_LIT> ) ;


<s> Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: LBrac ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( Sels [ <NUM_LIT> ] ) ) return MatchOperand_ParseFail ; if ( <NUM_LIT> > Sels [ <NUM_LIT> ] || <NUM_LIT> < Sels [ <NUM_LIT> ] ) return MatchOperand_ParseFail ; for ( size_t i = <NUM_LIT> ; i < <NUM_LIT> ; ++ i ) { if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ;

if ( getParser ( ) . parseAbsoluteExpression ( Sels [ i ] ) ) return MatchOperand_ParseFail ;


<s> auto Res = parseExpTgtImpl ( getTokenStr ( ) , Val ) ; if ( Res != MatchOperand_Success ) { Error ( S , <STR_LIT> ) ; return Res ; } Parser . Lex ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Val , S , <ISA_LIT>Operand :: ImmTyExpTgt ) ) ; return MatchOperand_Success ;


<s> uint8_t Val ; auto Res = parseExpTgtImpl ( getTokenStr ( ) , Val ) ; if ( Res != MatchOperand_Success ) { Error ( S , <STR_LIT> ) ; return Res ; }


<s> if ( isGFX10Plus ( ) && Str == <STR_LIT> ) { Val = Exp :: ET_PRIM ; return MatchOperand_Success ; } if ( Str . startswith ( <STR_LIT> ) ) { Str = Str . drop_front ( <NUM_LIT> ) ; if ( Str . getAsInteger ( <NUM_LIT> , Val ) ) return MatchOperand_ParseFail ; if ( Val >= <NUM_LIT> ) return MatchOperand_ParseFail ; Val += Exp :: ET_PARAM0 ; return MatchOperand_Success ; } return MatchOperand_ParseFail ;


<s> StringRef Msg = ( Res == MatchOperand_ParseFail ) ? <STR_LIT> : <STR_LIT> ; Error ( getLexer ( ) . getLoc ( ) , Msg ) ; } while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { Parser . Lex ( ) ; } Parser . Lex ( ) ; return true ; } } Parser . Lex ( ) ;


<s> std :: unique_ptr < <ISA_LIT>Operand > <ISA_LIT>AsmParser :: parseRegister ( bool RestoreOnFailure ) { const auto & Tok = Parser . getTok ( ) ; SMLoc StartLoc = Tok . getLoc ( ) ; SMLoc EndLoc = Tok . getEndLoc ( ) ; RegisterKind RegKind ; unsigned Reg , RegNum , RegWidth ; if ( ! Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth ) ) { return nullptr ; } if ( isHsaAbiVersion3 ( & getSTI ( ) ) ) { if ( ! updateGprCountSymbols ( RegKind , RegNum , RegWidth ) ) return nullptr ; } else KernelScope . usesRegister ( RegKind , RegNum , RegWidth ) ;

return <ISA_LIT>Operand :: CreateReg ( this , Reg , StartLoc , EndLoc ) ;


<s> } if ( ! isUInt < <NUM_LIT> > ( Imm ) ) { Error ( OffsetLoc , <STR_LIT> ) ; return false ; }


<s> bool <ISA_LIT>AsmParser :: parseSwizzleOperand ( int64_t & Op , const unsigned MinVal , const unsigned MaxVal , const StringRef ErrMsg , SMLoc & Loc ) { if ( ! skipToken ( AsmToken :: Comma , <STR_LIT> ) ) { return false ; }

Loc = Parser . getTok ( ) . getLoc ( ) ;


<s> Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } Error ( Loc , <STR_LIT> ) ; return false ; case IS_VGPR : case IS_SGPR : case IS_AGPR : case IS_TTMP : if ( Reg1 != Reg + RegWidth / <NUM_LIT> ) { Error ( Loc , <STR_LIT> ) ; return false ;


<s> } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } Error ( Loc , <STR_LIT> ) ; return false ; case IS_VGPR : case IS_SGPR : case IS_AGPR : case IS_TTMP : if ( Reg1 != Reg + RegWidth / <NUM_LIT> ) { Error ( Loc , <STR_LIT> ) ; return false ; } RegWidth += <NUM_LIT> ;


<s> MCSymbol * Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Major , Ctx ) ) ; Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Minor , Ctx ) ) ; Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Stepping , Ctx ) ) ; } if ( ISA . Major >= <NUM_LIT> && isHsaAbiVersion3AndAbove ( & getSTI ( ) ) ) { initializeGprCountSymbol ( IS_VGPR ) ; initializeGprCountSymbol ( IS_SGPR ) ; } else KernelScope . initialize ( getContext ( ) ) ; }


<s> if ( getFeatureBits ( ) . none ( ) ) { copySTI ( ) . ToggleFeature ( <STR_LIT> ) ; } setAvailableFeatures ( ComputeAvailableFeatures ( getFeatureBits ( ) ) ) ; { <STR_LIT> ISA = <STR_LIT> ( getSTI ( ) . getCPU ( ) ) ; MCContext & Ctx = getContext ( ) ; if ( ISA . Major >= <NUM_LIT> && isHsaAbiVersion3AndAbove ( & getSTI ( ) ) ) { MCSymbol * Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Major , Ctx ) ) ; Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Minor , Ctx ) ) ; Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Stepping , Ctx ) ) ; } else { MCSymbol * Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Major , Ctx ) ) ; Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Minor , Ctx ) ) ;


<s> <ISA_LIT>Operand ( KindTy Kind_ , const <ISA_LIT>AsmParser * AsmParser_ ) : Kind ( Kind_ ) , AsmParser ( AsmParser_ ) {


<s> <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ i ] ) ; if ( Op . isBLGP ( ) ) return Op . getStartLoc ( ) ; } return SMLoc ( ) ;


<s> } } else if ( Is == IS_SGPR ) { switch ( RegWidth ) { default : return - <NUM_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; } } else if ( Is == IS_AGPR ) { switch ( RegWidth ) { default : return - <NUM_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> :


<s> case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; } } else if ( Is == IS_SGPR ) { switch ( RegWidth ) { default : return - <NUM_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; } } else if ( Is == IS_AGPR ) { switch ( RegWidth ) { default : return - <NUM_LIT> ; case <NUM_LIT> : return <STR_LIT> ;


<s> const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; const MCRegisterClass RC = TRI -> getRegClass ( RCID ) ; if ( RegIdx >= RC . getNumRegs ( ) ) { Error ( Loc , <STR_LIT> ) ; return <STR_LIT> ; }


<s> usesSgprAt ( SgprIndexUnusedMin = - <NUM_LIT> ) ; usesVgprAt ( VgprIndexUnusedMin = - <NUM_LIT> ) ; if ( hasMAIInsts ( * MSTI ) ) {

usesAgprAt ( AgprIndexUnusedMin = - <NUM_LIT> ) ;


<s> bool isRegOrInline ( unsigned RCID , MVT type ) const {

return isRegClass ( RCID ) || isInlinableImm ( type ) ;


<s> bool isRegOrInlineNoMods ( unsigned RCID , MVT type ) const {

return isRegOrInline ( RCID , type ) && ! hasModifiers ( ) ;


<s> void <ISA_LIT>AsmParser :: onBeginOfFile ( ) { if ( ! getParser ( ) . getStreamer ( ) . getTargetStreamer ( ) || getSTI ( ) . getTargetTriple ( ) . getArch ( ) == Triple :: r600 ) return ; if ( ! getTargetStreamer ( ) . getTargetID ( ) ) getTargetStreamer ( ) . initializeTargetID ( getSTI ( ) , getSTI ( ) . getFeatureString ( ) ) ;

if ( isHsaAbiVersion3AndAbove ( & getSTI ( ) ) ) getTargetStreamer ( ) . EmitDirectiveAMDGCNTarget ( ) ;


<s> else if ( trySkipId ( <STR_LIT> ) ) CPolOn = <STR_LIT> :: DLC ; else if ( trySkipId ( <STR_LIT> ) ) CPolOff = <STR_LIT> :: DLC ; else if ( trySkipId ( <STR_LIT> ) ) CPolOn = <STR_LIT> :: SCC ; else if ( trySkipId ( <STR_LIT> ) ) CPolOff = <STR_LIT> :: SCC ; else return MatchOperand_NoMatch ; if ( ! isGFX10Plus ( ) && ( ( CPolOn | CPolOff ) & <STR_LIT> :: DLC ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( ! isGFX90A ( ) && ( ( CPolOn | CPolOff ) & <STR_LIT> :: SCC ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( CPolSeen & ( CPolOn | CPolOff ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } CPolSeen |= ( CPolOn | CPolOff ) ; for ( unsigned I = <NUM_LIT> ; I != Operands . size ( ) ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isCPol ( ) ) { Op . setImm ( ( Op . getImm ( ) | CPolOn ) & ~ CPolOff ) ; return MatchOperand_Success ; } } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , CPolOn , S , <ISA_LIT>Operand :: ImmTyCPol ) ) ; return MatchOperand_Success ;


<s> else if ( trySkipId ( <STR_LIT> ) ) CPolOn = <STR_LIT> :: SLC ; else if ( trySkipId ( <STR_LIT> ) ) CPolOff = <STR_LIT> :: SLC ; else if ( trySkipId ( <STR_LIT> ) ) CPolOn = <STR_LIT> :: DLC ; else if ( trySkipId ( <STR_LIT> ) ) CPolOff = <STR_LIT> :: DLC ; else if ( trySkipId ( <STR_LIT> ) ) CPolOn = <STR_LIT> :: SCC ; else if ( trySkipId ( <STR_LIT> ) ) CPolOff = <STR_LIT> :: SCC ; else return MatchOperand_NoMatch ; if ( ! isGFX10Plus ( ) && ( ( CPolOn | CPolOff ) & <STR_LIT> :: DLC ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( ! isGFX90A ( ) && ( ( CPolOn | CPolOff ) & <STR_LIT> :: SCC ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( CPolSeen & ( CPolOn | CPolOff ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } CPolSeen |= ( CPolOn | CPolOff ) ; for ( unsigned I = <NUM_LIT> ; I != Operands . size ( ) ; ++ I ) {

<ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ;


<s> const char * AssemblerDirectiveEnd ; std :: tie ( AssemblerDirectiveBegin , AssemblerDirectiveEnd ) = isHsaAbiVersion3AndAbove ( & getSTI ( ) ) ? std :: make_tuple ( HSAMD :: V3 :: AssemblerDirectiveBegin , HSAMD :: V3 :: AssemblerDirectiveEnd ) : std :: make_tuple ( HSAMD :: AssemblerDirectiveBegin , HSAMD :: AssemblerDirectiveEnd ) ; if ( getSTI ( ) . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) { return Error ( getLoc ( ) , ( Twine ( AssemblerDirectiveBegin ) + Twine ( <STR_LIT> <STR_LIT> ) ) . str ( ) ) ; } std :: string HSAMetadataString ; if ( ParseToEndDirective ( AssemblerDirectiveBegin , AssemblerDirectiveEnd , HSAMetadataString ) ) return true ; if ( isHsaAbiVersion3AndAbove ( & getSTI ( ) ) ) {

if ( ! getTargetStreamer ( ) . EmitHSAMetadataV3 ( HSAMetadataString ) ) return Error ( getLoc ( ) , <STR_LIT> ) ;


<s> if ( getSTI ( ) . getTargetTriple ( ) . getOS ( ) != Triple :: AMDHSA ) { return Error ( getLoc ( ) , ( Twine ( AssemblerDirectiveBegin ) + Twine ( <STR_LIT> <STR_LIT> ) ) . str ( ) ) ; } std :: string HSAMetadataString ;

if ( ParseToEndDirective ( AssemblerDirectiveBegin , AssemblerDirectiveEnd , HSAMetadataString ) ) return true ;


<s> OperandInfoTy Width ( WIDTH_DEFAULT_ ) ; if ( parseHwregBody ( HwReg , Offset , Width ) && validateHwreg ( HwReg , Offset , Width ) ) { ImmVal = encodeHwreg ( HwReg . Id , Offset . Id , Width . Id ) ; } else { return MatchOperand_ParseFail ; } } else if ( parseExpr ( ImmVal , <STR_LIT> ) ) { if ( ImmVal < <NUM_LIT> || ! isUInt < <NUM_LIT> > ( ImmVal ) ) {


<s> if ( isToken ( AsmToken :: Identifier ) && ( HwReg . Id = getHwregId ( getTokenStr ( ) , getSTI ( ) ) ) != OPR_ID_UNKNOWN ) { HwReg . IsSymbolic = true ; lex ( ) ; } else if ( ! parseExpr ( HwReg . Id , <STR_LIT> ) ) {


<s> bool <ISA_LIT>AsmParser :: parseHwregBody ( OperandInfoTy & HwReg , OperandInfoTy & Offset , OperandInfoTy & Width ) { using namespace llvm :: <STR_LIT> ; HwReg . Loc = getLoc ( ) ; if ( isToken ( AsmToken :: Identifier ) && ( HwReg . Id = getHwregId ( getTokenStr ( ) , getSTI ( ) ) ) != OPR_ID_UNKNOWN ) { HwReg . IsSymbolic = true ; lex ( ) ;

} else if ( ! parseExpr ( HwReg . Id , <STR_LIT> ) ) {


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseOptionalOpr ( OperandVector & Operands ) { OperandMatchResultTy res ; for ( const OptionalOperand & Op : <ISA_LIT>OptionalOperandTable ) { if ( Op . IsBit ) { res = parseNamedBit ( Op . Name , Operands , Op . Type ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> ) { res = parseOModOperand ( Operands ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTySdwaDstSel || Op . Type == <ISA_LIT>Operand :: ImmTySdwaSrc0Sel || Op . Type == <ISA_LIT>Operand :: ImmTySdwaSrc1Sel ) { res = parseSDWASel ( Operands , Op . Name , Op . Type ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTySdwaDstUnused ) { res = parseSDWADstUnused ( Operands ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTyOpSel || Op . Type == <ISA_LIT>Operand :: ImmTyOpSelHi || Op . Type == <ISA_LIT>Operand :: ImmTyNegLo || Op . Type == <ISA_LIT>Operand :: ImmTyNegHi ) { res = parseOperandArrayWithPrefix ( Op . Name , Operands , Op . Type , Op . ConvertResult ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTyDim ) { res = parseDim ( Operands ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTyCPol ) { res = parseCPol ( Operands ) ; } else { res = parseIntWithPrefix ( Op . Name , Operands , Op . Type , Op . ConvertResult ) ;

if ( Op . Type == <ISA_LIT>Operand :: ImmTyBLGP && res == MatchOperand_NoMatch ) {


<s> if ( ! Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth ) ) { return nullptr ; } if ( isHsaAbiVersion3AndAbove ( & getSTI ( ) ) ) { if ( ! updateGprCountSymbols ( RegKind , RegNum , RegWidth ) ) return nullptr ; } else KernelScope . usesRegister ( RegKind , RegNum , RegWidth ) ;


<s> auto Loc = getLoc ( ) ; if ( ! Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth ) ) return <STR_LIT> ; if ( RegWidth != <NUM_LIT> ) { Error ( Loc , <STR_LIT> ) ; return <STR_LIT> ; } for ( ; trySkipToken ( AsmToken :: Comma ) ; ) { RegisterKind NextRegKind ; unsigned NextReg , NextRegNum , NextRegWidth ; Loc = getLoc ( ) ; if ( ! Parse<ISA_LIT>Register ( NextRegKind , NextReg , NextRegNum , NextRegWidth , Tokens ) ) { return <STR_LIT> ; } if ( NextRegWidth != <NUM_LIT> ) { Error ( Loc , <STR_LIT> ) ; return <STR_LIT> ; }


<s> if ( ! skipToken ( AsmToken :: LBrac , <STR_LIT> ) ) return false ; SMLoc FirstIdxLoc = getLoc ( ) ; SMLoc SecondIdxLoc ; if ( ! parseExpr ( RegLo ) ) return false ; if ( trySkipToken ( AsmToken :: Colon ) ) { SecondIdxLoc = getLoc ( ) ; if ( ! parseExpr ( RegHi ) ) return false ; } else { RegHi = RegLo ; } if ( ! skipToken ( AsmToken :: RBrac , <STR_LIT> ) ) return false ; if ( ! isUInt < <NUM_LIT> > ( RegLo ) ) {


<s> Error ( Loc , <STR_LIT> ) ; return <STR_LIT> ; } Tokens . push_back ( getToken ( ) ) ; lex ( ) ; RegKind = RI -> Kind ; StringRef RegSuffix = RegName . substr ( RI -> Name . size ( ) ) ; if ( ! RegSuffix . empty ( ) ) { if ( ! getRegNum ( RegSuffix , RegNum ) ) { Error ( Loc , <STR_LIT> ) ; return <STR_LIT> ; } RegWidth = <NUM_LIT> ; } else { if ( ! ParseRegRange ( RegNum , RegWidth ) ) return <STR_LIT> ; } return getRegularReg ( RegKind , RegNum , RegWidth , Loc ) ;


<s> } else if ( ! parseExpr ( Msg . Id , <STR_LIT> ) ) { return false ; } if ( trySkipToken ( AsmToken :: Comma ) ) { Op . IsDefined = true ; Op . Loc = getLoc ( ) ;

if ( isToken ( AsmToken :: Identifier ) && ( Op . Id = getMsgOpId ( Msg . Id , getTokenStr ( ) ) ) >= <NUM_LIT> ) {


<s> OperandInfoTy Op ( OP_NONE_ ) ; OperandInfoTy Stream ( STREAM_ID_NONE_ ) ; if ( parseSendMsgBody ( Msg , Op , Stream ) && validateSendMsg ( Msg , Op , Stream ) ) { ImmVal = encodeMsg ( Msg . Id , Op . Id , Stream . Id ) ; } else { return MatchOperand_ParseFail ; } } else if ( parseExpr ( ImmVal , <STR_LIT> ) ) { if ( ImmVal < <NUM_LIT> || ! isUInt < <NUM_LIT> > ( ImmVal ) ) { Error ( Loc , <STR_LIT> ) ; return MatchOperand_ParseFail ;


<s> int64_t ImmVal = <NUM_LIT> ; SMLoc Loc = getLoc ( ) ; if ( trySkipId ( <STR_LIT> , AsmToken :: LParen ) ) { OperandInfoTy Msg ( OPR_ID_UNKNOWN ) ; OperandInfoTy Op ( OP_NONE_ ) ; OperandInfoTy Stream ( STREAM_ID_NONE_ ) ; if ( parseSendMsgBody ( Msg , Op , Stream ) && validateSendMsg ( Msg , Op , Stream ) ) { ImmVal = encodeMsg ( Msg . Id , Op . Id , Stream . Id ) ; } else { return MatchOperand_ParseFail ; } } else if ( parseExpr ( ImmVal , <STR_LIT> ) ) { if ( ImmVal < <NUM_LIT> || ! isUInt < <NUM_LIT> > ( ImmVal ) ) { Error ( Loc , <STR_LIT> ) ; return MatchOperand_ParseFail ;


<s> if ( Reg ) { RegNum = <NUM_LIT> ; RegWidth = <NUM_LIT> ; RegKind = IS_SPECIAL ; Tokens . push_back ( getToken ( ) ) ;


<s> case <STR_LIT> : return isGFX9Plus ( ) ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return ! isGFX9Plus ( ) ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return ( isVI ( ) || isGFX9 ( ) ) && getTargetStreamer ( ) . getTargetID ( ) -> isXnackSupported ( ) ; case <STR_LIT> : return isGFX10Plus ( ) ; default : break ; } if ( isCI ( ) ) return true ; if ( is<ISA_LIT> ( ) || isGFX10Plus ( ) ) { switch ( RegNo ) { case <STR_LIT> :


<s> bool <ISA_LIT>AsmParser :: updateGprCountSymbols ( RegisterKind RegKind , unsigned DwordRegIndex , unsigned RegWidth ) { if ( <STR_LIT> ( getSTI ( ) . getCPU ( ) ) . Major < <NUM_LIT> ) return true ; auto SymbolName = getGprCountSymbolName ( RegKind ) ; if ( ! SymbolName ) return true ; MCSymbol * Sym = getContext ( ) . getOrCreateSymbol ( * SymbolName ) ;

int64_t NewMax = DwordRegIndex + divideCeil ( RegWidth , <NUM_LIT> ) - <NUM_LIT> ;


<s> MCSymbol * Sym = getContext ( ) . getOrCreateSymbol ( * SymbolName ) ; int64_t NewMax = DwordRegIndex + divideCeil ( RegWidth , <NUM_LIT> ) - <NUM_LIT> ; int64_t OldCount ;

if ( ! Sym -> isVariable ( ) ) return ! Error ( getLoc ( ) , <STR_LIT> ) ;


<s> MCSymbol * const Sym = Ctx -> getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( AgprIndexUnusedMin , * Ctx ) ) ;

MCSymbol * const vSym = Ctx -> getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ;


<s> case IS_AGPR : usesAgprAt ( DwordRegIndex + divideCeil ( RegWidth , <NUM_LIT> ) - <NUM_LIT> ) ; break ; case IS_VGPR : usesVgprAt ( DwordRegIndex + divideCeil ( RegWidth , <NUM_LIT> ) - <NUM_LIT> ) ; break ; default : break ; }


<s> break ; case IS_VGPR : usesVgprAt ( DwordRegIndex + divideCeil ( RegWidth , <NUM_LIT> ) - <NUM_LIT> ) ; break ; default : break ;


<s> MCSymbol * const Sym = Ctx -> getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( SgprIndexUnusedMin , * Ctx ) ) ;


<s> bool <ISA_LIT>AsmParser :: validateBLGP ( const MCInst & Inst , const OperandVector & Operands ) { unsigned Opc = Inst . getOpcode ( ) ; int BlgpIdx = <STR_LIT> ( Opc , <STR_LIT> :: blgp ) ; if ( BlgpIdx == - <NUM_LIT> ) return true ; SMLoc BLGPLoc = getBLGPLoc ( Operands ) ; if ( ! BLGPLoc . isValid ( ) ) return true ; bool IsNeg = StringRef ( BLGPLoc . getPointer ( ) ) . startswith ( <STR_LIT> ) ; auto FB = getFeatureBits ( ) ; bool UsesNeg = false ; if ( FB [ <STR_LIT> ] ) { switch ( Opc ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : UsesNeg = true ;


<s> unsigned CPol = Inst . getOperand ( CPolPos ) . getImm ( ) ; uint64_t TSFlags = MII . get ( Inst . getOpcode ( ) ) . TSFlags ; if ( ( TSFlags & ( <STR_LIT> ) ) && ( CPol & ~ ( <STR_LIT> :: GLC | <STR_LIT> :: DLC ) ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( isGFX90A ( ) && ! isGFX940 ( ) && ( CPol & CPol :: SCC ) ) { SMLoc S = getImmLoc ( <ISA_LIT>Operand :: ImmTyCPol , Operands ) ; StringRef CStr ( S . getPointer ( ) ) ; S = SMLoc :: getFromPointer ( & CStr . data ( ) [ CStr . find ( <STR_LIT> ) ] ) ; Error ( S , <STR_LIT> ) ; return false ; } if ( ! ( TSFlags & ( <STR_LIT> | <STR_LIT> ) ) ) return true ; if ( TSFlags & <STR_LIT> ) { if ( ! ( TSFlags & <STR_LIT> ) && ! ( CPol & CPol :: GLC ) ) { Error ( IDLoc , isGFX940 ( ) ? <STR_LIT> : <STR_LIT> ) ; return false ; } } else { if ( CPol & CPol :: GLC ) { SMLoc S = getImmLoc ( <ISA_LIT>Operand :: ImmTyCPol , Operands ) ; StringRef CStr ( S . getPointer ( ) ) ; S = SMLoc :: getFromPointer ( & CStr . data ( ) [ CStr . find ( <STR_LIT> ) ] ) ;

Error ( S , isGFX940 ( ) ? <STR_LIT> : <STR_LIT> ) ;


<s> const unsigned Opcode = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opcode ) ; const int DstIdx = <STR_LIT> ( Opcode , <STR_LIT> :: vdst ) ; if ( DstIdx == - <NUM_LIT> || Desc . getOperandConstraint ( DstIdx , MCOI :: EARLY_CLOBBER ) == - <NUM_LIT> ) { return true ; } const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; const int Src0Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src0 ) ; const int Src1Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src1 ) ; const int Src2Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src2 ) ; assert ( DstIdx != - <NUM_LIT> ) ; const MCOperand & Dst = Inst . getOperand ( DstIdx ) ; assert ( Dst . isReg ( ) ) ; const int SrcIndices [ ] = { Src0Idx , Src1Idx , Src2Idx } ; for ( int SrcIdx : SrcIndices ) { if ( SrcIdx == - <NUM_LIT> ) break ; const MCOperand & Src = Inst . getOperand ( SrcIdx ) ; if ( Src . isReg ( ) ) { if ( TRI -> regsOverlap ( Dst . getReg ( ) , Src . getReg ( ) ) ) { const unsigned SrcReg = mc2PseudoReg ( Src . getReg ( ) ) ; Error ( getRegLoc ( SrcReg , Operands ) , <STR_LIT> ) ;


<s> Error ( HwReg . Loc , <STR_LIT> ) ; return false ; } } if ( ! isValidHwregOffset ( Offset . Id ) ) { Error ( Offset . Loc , <STR_LIT> ) ; return false ; } if ( ! isValidHwregWidth ( Width . Id ) ) { Error ( Width . Loc , <STR_LIT> ) ; return false ; }


<s> } } else { if ( ! isValidHwreg ( HwReg . Id ) ) { Error ( HwReg . Loc , <STR_LIT> ) ; return false ; } } if ( ! isValidHwregOffset ( Offset . Id ) ) { Error ( Offset . Loc , <STR_LIT> ) ; return false ; } if ( ! isValidHwregWidth ( Width . Id ) ) { Error ( Width . Loc , <STR_LIT> ) ; return false ;


<s> } if ( ! validateSOPLiteral ( Inst ) ) { Error ( getLitLoc ( Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateVOPLiteral ( Inst , Operands ) ) { return false ; } if ( ! validateConstantBusLimitations ( Inst , Operands ) ) { return false ; } if ( ! validateEarlyClobberLimitations ( Inst , Operands ) ) { return false ; } if ( ! validateIntClampSupported ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateOpSel ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyOpSel , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateDPP ( Inst , Operands ) ) { return false ; } if ( ! validateMIMGD16 ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyD16 , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMIMGDim ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGMSAA ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyDim , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMIMGDataSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAddrSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAtomicDMask ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyDMask , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMIMGGatherDMask ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyDMask , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMovrels ( Inst , Operands ) ) { return false ; } if ( ! validateFlatOffset ( Inst , Operands ) ) { return false ; } if ( ! validateSMEMOffset ( Inst , Operands ) ) { return false ; } if ( ! validateMAIAccWrite ( Inst , Operands ) ) { return false ; } if ( ! validateMFMA ( Inst , Operands ) ) { return false ; } if ( ! validateCoherencyBits ( Inst , Operands , IDLoc ) ) { return false ; } if ( ! validateAGPRLdSt ( Inst ) ) { Error ( IDLoc , getFeatureBits ( ) [ <STR_LIT> ] ? <STR_LIT> : <STR_LIT> ) ; return false ; }


<s> assert ( Src0Idx != - <NUM_LIT> ) ; const MCOperand & Src0 = Inst . getOperand ( Src0Idx ) ; if ( ! Src0 . isReg ( ) ) return true ; auto Reg = mc2PseudoReg ( Src0 . getReg ( ) ) ; const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; if ( ! isGFX90A ( ) && isSGPR ( Reg , TRI ) ) { Error ( getRegLoc ( Reg , Operands ) , <STR_LIT> ) ; return false ;


<s> bool <ISA_LIT>AsmParser :: validateMFMA ( const MCInst & Inst , const OperandVector & Operands ) { const unsigned Opc = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; const int Src2Idx = <STR_LIT> ( Opc , <STR_LIT> :: src2 ) ; if ( Src2Idx == - <NUM_LIT> ) return true ; const MCOperand & Src2 = Inst . getOperand ( Src2Idx ) ; if ( ! Src2 . isReg ( ) ) return true ; MCRegister Src2Reg = Src2 . getReg ( ) ; MCRegister DstReg = Inst . getOperand ( <NUM_LIT> ) . getReg ( ) ; if ( Src2Reg == DstReg ) return true ; const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; if ( TRI -> getRegClass ( Desc . OpInfo [ <NUM_LIT> ] . RegClass ) . getSizeInBits ( ) <= <NUM_LIT> ) return true ;

if ( TRI -> regsOverlap ( Src2Reg , DstReg ) ) {


<s> bool <ISA_LIT>AsmParser :: validateOpSel ( const MCInst & Inst ) { const unsigned Opc = Inst . getOpcode ( ) ; if ( Opc == <STR_LIT> || Opc == <STR_LIT> ) { int OpSelIdx = <STR_LIT> ( Opc , <STR_LIT> :: op_sel ) ; unsigned OpSel = Inst . getOperand ( OpSelIdx ) . getImm ( ) ; if ( OpSel & ~ <NUM_LIT> ) return false ; } if ( isGFX940 ( ) && ( MII . get ( Opc ) . TSFlags & <STR_LIT> ) ) { int OpSelIdx = <STR_LIT> ( Opc , <STR_LIT> :: op_sel ) ; if ( OpSelIdx != - <NUM_LIT> ) { if ( Inst . getOperand ( OpSelIdx ) . getImm ( ) != <NUM_LIT> ) return false ; }

int OpSelHiIdx = <STR_LIT> ( Opc , <STR_LIT> :: op_sel_hi ) ;


<s> if ( Msg . Id == OPR_ID_UNSUPPORTED ) { Error ( Msg . Loc , <STR_LIT> ) ; return false ; } } else { if ( ! isValidMsgId ( Msg . Id ) ) { Error ( Msg . Loc , <STR_LIT> ) ; return false ; } } if ( Strict && ( msgRequiresOp ( Msg . Id ) != Op . IsDefined ) ) { if ( Op . IsDefined ) { Error ( Op . Loc , <STR_LIT> ) ; } else { Error ( Msg . Loc , <STR_LIT> ) ; } return false ; } if ( ! isValidMsgOp ( Msg . Id , Op . Id , getSTI ( ) , Strict ) ) { Error ( Op . Loc , <STR_LIT> ) ; return false ; } if ( Strict && ! msgSupportsStream ( Msg . Id , Op . Id ) && Stream . IsDefined ) {


<s> if ( Msg . Id == OPR_ID_UNSUPPORTED ) { Error ( Msg . Loc , <STR_LIT> ) ; return false ; } } else { if ( ! isValidMsgId ( Msg . Id ) ) { Error ( Msg . Loc , <STR_LIT> ) ; return false ; } } if ( Strict && ( msgRequiresOp ( Msg . Id ) != Op . IsDefined ) ) { if ( Op . IsDefined ) { Error ( Op . Loc , <STR_LIT> ) ; } else { Error ( Msg . Loc , <STR_LIT> ) ; } return false ; } if ( ! isValidMsgOp ( Msg . Id , Op . Id , getSTI ( ) , Strict ) ) { Error ( Op . Loc , <STR_LIT> ) ; return false ; } if ( Strict && ! msgSupportsStream ( Msg . Id , Op . Id ) && Stream . IsDefined ) { Error ( Stream . Loc , <STR_LIT> ) ; return false ;


<s> if ( Op . isOff ( ) ) { assert ( SrcIdx < <NUM_LIT> ) ; OperandIdx [ SrcIdx ] = Inst . size ( ) ; Inst . addOperand ( MCOperand :: createReg ( <STR_LIT> ) ) ; ++ SrcIdx ; continue ; } if ( Op . isImm ( ) && Op . getImmTy ( ) == <ISA_LIT>Operand :: ImmTyExpTgt ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; continue ; } if ( Op . isToken ( ) && ( Op . getToken ( ) == <STR_LIT> || Op . getToken ( ) == <STR_LIT> ) ) continue ; OptionalIdx [ Op . getImmTy ( ) ] = i ; } assert ( SrcIdx == <NUM_LIT> ) ; bool Compr = false ; if ( OptionalIdx . find ( <ISA_LIT>Operand :: ImmTyExpCompr ) != OptionalIdx . end ( ) ) { Compr = true ; Inst . getOperand ( OperandIdx [ <NUM_LIT> ] ) = Inst . getOperand ( OperandIdx [ <NUM_LIT> ] ) ; Inst . getOperand ( OperandIdx [ <NUM_LIT> ] ) . setReg ( <STR_LIT> ) ;


<s> if ( OptionalIdx . find ( <ISA_LIT>Operand :: ImmTyExpCompr ) != OptionalIdx . end ( ) ) { Compr = true ; Inst . getOperand ( OperandIdx [ <NUM_LIT> ] ) = Inst . getOperand ( OperandIdx [ <NUM_LIT> ] ) ; Inst . getOperand ( OperandIdx [ <NUM_LIT> ] ) . setReg ( <STR_LIT> ) ; Inst . getOperand ( OperandIdx [ <NUM_LIT> ] ) . setReg ( <STR_LIT> ) ; } for ( auto i = <NUM_LIT> ; i < SrcIdx ; ++ i ) { if ( Inst . getOperand ( OperandIdx [ i ] ) . getReg ( ) != <STR_LIT> ) { EnMask |= Compr ? ( <NUM_LIT> << i * <NUM_LIT> ) : ( <NUM_LIT> << i ) ; } } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyExpVM ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyExpCompr ) ;

Inst . addOperand ( MCOperand :: createImm ( EnMask ) ) ;


<s> for ( unsigned i = FirstOperandIdx , e = Operands . size ( ) ; i != e ; ++ i ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ i ] ) ; if ( Op . isReg ( ) ) { Op . addRegOperands ( Inst , <NUM_LIT> ) ; if ( IsAtomicReturn && i == FirstOperandIdx ) Op . addRegOperands ( Inst , <NUM_LIT> ) ; continue ; } if ( Op . isImm ( ) && Op . getImmTy ( ) == <ISA_LIT>Operand :: ImmTyNone ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; continue ; } if ( Op . isToken ( ) ) { continue ; } assert ( Op . isImm ( ) ) ;


<s> unsigned Opc = Inst . getOpcode ( ) ; unsigned I = <NUM_LIT> ; const MCInstrDesc & Desc = MII . get ( Inst . getOpcode ( ) ) ; for ( unsigned J = <NUM_LIT> ; J < Desc . getNumDefs ( ) ; ++ J ) { ( ( <ISA_LIT>Operand & ) * Operands [ I ++ ] ) . addRegOperands ( Inst , <NUM_LIT> ) ; } for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( isRegOrImmWithInputMods ( Desc , Inst . getNumOperands ( ) ) ) { Op . addRegOrImmWithFPInputModsOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isImmModifier ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { llvm_unreachable ( <STR_LIT> ) ; } } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> ) ; int OpSelIdx = <STR_LIT> ( Opc , <STR_LIT> :: op_sel ) ; if ( OpSelIdx != - <NUM_LIT> ) addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyOpSel ) ;

addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyWaitEXP ) ;


<s> <ISA_LIT>Operand :: Ptr <ISA_LIT>AsmParser :: defaultWaitEXP ( ) const { return <ISA_LIT>Operand :: CreateImm ( this , <NUM_LIT> , SMLoc ( ) , <ISA_LIT>Operand :: ImmTyWaitEXP ) ;


<s> return <ISA_LIT>Operand :: CreateImm ( this , <NUM_LIT> , SMLoc ( ) , <ISA_LIT>Operand :: ImmTyWaitEXP ) ;


<s> bool isGFX11 ( ) const { return <STR_LIT> ( getSTI ( ) ) ;


<s> bool <ISA_LIT>Operand :: isSDelayAlu ( ) const {


<s> bool <ISA_LIT>Operand :: isSMEMOffset ( ) const {

return isImmTy ( ImmTyNone ) || isImmTy ( ImmTyOffset ) ;


<s> return isImmTy ( ImmTyNone ) || isImmTy ( ImmTyOffset ) ;


<s> bool <ISA_LIT>Operand :: isWaitEXP ( ) const {

return isImmTy ( ImmTyWaitEXP ) && isUInt < <NUM_LIT> > ( getImm ( ) ) ;


<s> return isImmTy ( ImmTyWaitEXP ) && isUInt < <NUM_LIT> > ( getImm ( ) ) ;


<s> return isImmTy ( ImmTyWaitVDST ) && isUInt < <NUM_LIT> > ( getImm ( ) ) ;


<s> bool <ISA_LIT>Operand :: isWaitVDST ( ) const { return isImmTy ( ImmTyWaitVDST ) && isUInt < <NUM_LIT> > ( getImm ( ) ) ;


<s> if ( ! skipToken ( AsmToken :: Identifier , <STR_LIT> ) || ! skipToken ( AsmToken :: LParen , <STR_LIT> ) ) return false ; SMLoc ValueLoc = getLoc ( ) ; StringRef ValueName = getTokenStr ( ) ; if ( ! skipToken ( AsmToken :: Identifier , <STR_LIT> ) || ! skipToken ( AsmToken :: RParen , <STR_LIT> ) ) return false ; unsigned Shift ; if ( FieldName == <STR_LIT> ) { Shift = <NUM_LIT> ; } else if ( FieldName == <STR_LIT> ) { Shift = <NUM_LIT> ; } else if ( FieldName == <STR_LIT> ) { Shift = <NUM_LIT> ; } else { Error ( FieldLoc , <STR_LIT> + FieldName ) ; return false ; } int Value ; if ( Shift == <NUM_LIT> ) { Value = StringSwitch < int > ( ValueName ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Default ( - <NUM_LIT> ) ; } else { Value = StringSwitch < int > ( ValueName ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Default ( - <NUM_LIT> ) ; } if ( Value < <NUM_LIT> ) { Error ( ValueLoc , <STR_LIT> + ValueName ) ; return false ; } Delay |= Value << Shift ;


<s> } else if ( FieldName == <STR_LIT> ) { Shift = <NUM_LIT> ; } else { Error ( FieldLoc , <STR_LIT> + FieldName ) ; return false ; } int Value ; if ( Shift == <NUM_LIT> ) { Value = StringSwitch < int > ( ValueName ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Default ( - <NUM_LIT> ) ; } else { Value = StringSwitch < int > ( ValueName ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Default ( - <NUM_LIT> ) ;


<s> bool IsMIMG = Name . startswith ( <STR_LIT> ) ; while ( ! trySkipToken ( AsmToken :: EndOfStatement ) ) { OperandMode Mode = OperandMode_Default ; if ( IsMIMG && isGFX10Plus ( ) && Operands . size ( ) == <NUM_LIT> ) Mode = OperandMode_NSA ; CPolSeen = <NUM_LIT> ; OperandMatchResultTy Res = parseOperand ( Operands , Name , Mode ) ; if ( Res != MatchOperand_Success ) { checkUnsupportedInstruction ( Name , NameLoc ) ; if ( ! Parser . hasPendingError ( ) ) { StringRef Msg = ( Res == MatchOperand_ParseFail ) ? <STR_LIT> : <STR_LIT> ;


<s> int64_t Delay = <NUM_LIT> ; SMLoc S = getLoc ( ) ;

if ( isToken ( AsmToken :: Identifier ) && peekToken ( ) . is ( AsmToken :: LParen ) ) {


<s> } } Dfmt = ( Dfmt == DFMT_UNDEF ) ? DFMT_DEFAULT : Dfmt ; Nfmt = ( Nfmt == NFMT_UNDEF ) ? NFMT_DEFAULT : Nfmt ; if ( isGFX10Plus ( ) ) { auto Ufmt = convertDfmtNfmt2Ufmt ( Dfmt , Nfmt , getSTI ( ) ) ; if ( Ufmt == UFMT_UNDEF ) { Error ( FormatLoc , <STR_LIT> ) ; return MatchOperand_ParseFail ; } Format = Ufmt ;


<s> } else if ( Nfmt == NFMT_UNDEF ) { Error ( Loc , <STR_LIT> ) ; return MatchOperand_ParseFail ; } } Dfmt = ( Dfmt == DFMT_UNDEF ) ? DFMT_DEFAULT : Dfmt ; Nfmt = ( Nfmt == NFMT_UNDEF ) ? NFMT_DEFAULT : Nfmt ; if ( isGFX10Plus ( ) ) { auto Ufmt = convertDfmtNfmt2Ufmt ( Dfmt , Nfmt , getSTI ( ) ) ; if ( Ufmt == UFMT_UNDEF ) { Error ( FormatLoc , <STR_LIT> ) ; return MatchOperand_ParseFail ;


<s> using namespace llvm :: <STR_LIT> ; auto Id = getUnifiedFormat ( FormatStr , getSTI ( ) ) ; if ( Id == UFMT_UNDEF ) return MatchOperand_NoMatch ;


<s> using namespace llvm :: <STR_LIT> ; auto Id = getUnifiedFormat ( FormatStr , getSTI ( ) ) ; if ( Id == UFMT_UNDEF ) return MatchOperand_NoMatch ; if ( ! isGFX10Plus ( ) ) { Error ( Loc , <STR_LIT> ) ; return MatchOperand_ParseFail ; } Format = Id ; return MatchOperand_Success ;


<s> case ImmTySWZ : OS << <STR_LIT> ; break ; case ImmTyTFE : OS << <STR_LIT> ; break ; case ImmTyD16 : OS << <STR_LIT> ; break ; case ImmTyFORMAT : OS << <STR_LIT> ; break ; case ImmTyClamp<ISA_LIT> : OS << <STR_LIT> ; break ; case ImmTyOMod<ISA_LIT> : OS << <STR_LIT> ; break ; case ImmTyDPP8 : OS << <STR_LIT> ; break ; case ImmTyDppCtrl : OS << <STR_LIT> ; break ; case ImmTyDppRowMask : OS << <STR_LIT> ; break ; case ImmTyDppBankMask : OS << <STR_LIT> ; break ; case ImmTyDppBoundCtrl : OS << <STR_LIT> ; break ; case ImmTyDppFi : OS << <STR_LIT> ; break ; case ImmTySdwaDstSel : OS << <STR_LIT> ; break ; case ImmTySdwaSrc0Sel : OS << <STR_LIT> ; break ; case ImmTySdwaSrc1Sel : OS << <STR_LIT> ; break ; case ImmTySdwaDstUnused : OS << <STR_LIT> ; break ; case ImmTyDMask : OS << <STR_LIT> ; break ; case ImmTyDim : OS << <STR_LIT> ; break ; case ImmTyUNorm : OS << <STR_LIT> ; break ; case ImmTyDA : OS << <STR_LIT> ; break ; case ImmTyR128A16 : OS << <STR_LIT> ; break ; case ImmTyA16 : OS << <STR_LIT> ; break ; case ImmTyLWE : OS << <STR_LIT> ; break ; case ImmTyOff : OS << <STR_LIT> ; break ; case ImmTyExpTgt : OS << <STR_LIT> ; break ; case ImmTyExpCompr : OS << <STR_LIT> ; break ; case ImmTyExpVM : OS << <STR_LIT> ; break ; case ImmTyHwreg : OS << <STR_LIT> ; break ;

case ImmTySendMsg : OS << <STR_LIT> ; break ;


<s> } if ( CPol & ~ ( <STR_LIT> :: GLC | <STR_LIT> :: DLC ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } } if ( isGFX90A ( ) && ! isGFX940 ( ) && ( CPol & CPol :: SCC ) ) { SMLoc S = getImmLoc ( <ISA_LIT>Operand :: ImmTyCPol , Operands ) ; StringRef CStr ( S . getPointer ( ) ) ; S = SMLoc :: getFromPointer ( & CStr . data ( ) [ CStr . find ( <STR_LIT> ) ] ) ; Error ( S , <STR_LIT> ) ; return false ; } if ( ! ( TSFlags & ( <STR_LIT> | <STR_LIT> ) ) ) return true ; if ( TSFlags & <STR_LIT> ) { if ( ! ( TSFlags & <STR_LIT> ) && ! ( CPol & CPol :: GLC ) ) { Error ( IDLoc , isGFX940 ( ) ? <STR_LIT> : <STR_LIT> ) ; return false ; } } else { if ( CPol & CPol :: GLC ) { SMLoc S = getImmLoc ( <ISA_LIT>Operand :: ImmTyCPol , Operands ) ; StringRef CStr ( S . getPointer ( ) ) ; S = SMLoc :: getFromPointer ( & CStr . data ( ) [ CStr . find ( isGFX940 ( ) ? <STR_LIT> : <STR_LIT> ) ] ) ; Error ( S , isGFX940 ( ) ? <STR_LIT> : <STR_LIT> ) ; return false ;


<s> if ( isGFX940 ( ) ) return true ; uint64_t TSFlags = MII . get ( Inst . getOpcode ( ) ) . TSFlags ;

if ( ( TSFlags & ( <STR_LIT> | <STR_LIT> ) ) != ( <STR_LIT> | <STR_LIT> ) ) return true ;


<s> if ( auto ErrMsg = validateMIMGDataSize ( Inst ) ) { Error ( IDLoc , * ErrMsg ) ; return false ; } if ( ! validateMIMGAddrSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAtomicDMask ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyDMask , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMIMGGatherDMask ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyDMask , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMovrels ( Inst , Operands ) ) { return false ; } if ( ! validateFlatOffset ( Inst , Operands ) ) { return false ; } if ( ! validateSMEMOffset ( Inst , Operands ) ) { return false ; } if ( ! validateMAIAccWrite ( Inst , Operands ) ) { return false ; } if ( ! validateMFMA ( Inst , Operands ) ) { return false ; } if ( ! validateCoherencyBits ( Inst , Operands , IDLoc ) ) {


<s> } if ( ! validateOpSel ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyOpSel , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateDPP ( Inst , Operands ) ) { return false ; } if ( ! validateMIMGD16 ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyD16 , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMIMGDim ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGMSAA ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyDim , Operands ) , <STR_LIT> ) ; return false ; } if ( auto ErrMsg = validateMIMGDataSize ( Inst ) ) { Error ( IDLoc , * ErrMsg ) ; return false ; } if ( ! validateMIMGAddrSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAtomicDMask ( Inst ) ) { Error ( getImmLoc ( <ISA_LIT>Operand :: ImmTyDMask , Operands ) , <STR_LIT> ) ; return false ; } if ( ! validateMIMGGatherDMask ( Inst ) ) {


<s> using namespace <ISA_LIT>InstrFlags ; const unsigned Opcode = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opcode ) ; const auto Enc = VOP1 | VOP2 | VOP3 | VOPC | VOP3P | <STR_LIT> ; if ( ( Desc . TSFlags & Enc ) == <NUM_LIT> ) return None ; for ( auto SrcName : { OpName :: src0 , OpName :: src1 , OpName :: src2 } ) { auto SrcIdx = getNamedOperandIdx ( Opcode , SrcName ) ;


<s> const unsigned Opc = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return None ; int VDataIdx = <STR_LIT> ( Opc , <STR_LIT> :: vdata ) ; int DMaskIdx = <STR_LIT> ( Opc , <STR_LIT> :: dmask ) ; int TFEIdx = <STR_LIT> ( Opc , <STR_LIT> :: tfe ) ; assert ( VDataIdx != - <NUM_LIT> ) ; if ( DMaskIdx == - <NUM_LIT> || TFEIdx == - <NUM_LIT> ) return None ; unsigned VDataSize = <STR_LIT> ( getMRI ( ) , Desc , VDataIdx ) ;

unsigned TFESize = ( TFEIdx != - <NUM_LIT> && Inst . getOperand ( TFEIdx ) . getImm ( ) ) ? <NUM_LIT> : <NUM_LIT> ;


<s> if ( ! isValidMsgId ( Msg . Id , getSTI ( ) ) ) { Error ( Msg . Loc , <STR_LIT> ) ; return false ; } } if ( Strict && ( msgRequiresOp ( Msg . Id , getSTI ( ) ) != Op . IsDefined ) ) { if ( Op . IsDefined ) { Error ( Op . Loc , <STR_LIT> ) ; } else { Error ( Msg . Loc , <STR_LIT> ) ; } return false ; } if ( ! isValidMsgOp ( Msg . Id , Op . Id , getSTI ( ) , Strict ) ) { Error ( Op . Loc , <STR_LIT> ) ; return false ; } if ( Strict && ! msgSupportsStream ( Msg . Id , Op . Id , getSTI ( ) ) && Stream . IsDefined ) { Error ( Stream . Loc , <STR_LIT> ) ; return false ; }

if ( ! isValidMsgStream ( Msg . Id , Op . Id , Stream . Id , getSTI ( ) , Strict ) ) {


<s> using namespace llvm :: <STR_LIT> ; int64_t Format = getDefaultFormatEncoding ( getSTI ( ) ) ; OperandMatchResultTy Res ; SMLoc Loc = getLoc ( ) ; Res = isGFX10 ( ) ? parseUfmt ( Format ) : parseDfmtNfmt ( Format ) ; if ( Res == MatchOperand_ParseFail ) return Res ; bool FormatFound = ( Res == MatchOperand_Success ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Format , Loc , <ISA_LIT>Operand :: ImmTyFORMAT ) ) ; if ( FormatFound ) trySkipToken ( AsmToken :: Comma ) ;

if ( isToken ( AsmToken :: EndOfStatement ) ) {


<s> auto Res = parseSymbolicUnifiedFormat ( FormatStr , Loc , Format ) ; if ( Res == MatchOperand_NoMatch ) Res = parseSymbolicSplitFormat ( FormatStr , Loc , Format ) ;

if ( Res != MatchOperand_Success ) return Res ;


<s> int64_t Dfmt = DFMT_UNDEF ; int64_t Nfmt = NFMT_UNDEF ; if ( ! matchDfmtNfmt ( Dfmt , Nfmt , FormatStr , FormatLoc ) ) return MatchOperand_ParseFail ; if ( trySkipToken ( AsmToken :: Comma ) ) { StringRef Str ; SMLoc Loc = getLoc ( ) ; if ( ! parseId ( Str , <STR_LIT> ) || ! matchDfmtNfmt ( Dfmt , Nfmt , Str , Loc ) ) { return MatchOperand_ParseFail ; } if ( Dfmt == DFMT_UNDEF ) { Error ( Loc , <STR_LIT> ) ; } else if ( Nfmt == NFMT_UNDEF ) { Error ( Loc , <STR_LIT> ) ; } } Dfmt = ( Dfmt == DFMT_UNDEF ) ? DFMT_DEFAULT : Dfmt ; Nfmt = ( Nfmt == NFMT_UNDEF ) ? NFMT_DEFAULT : Nfmt ; if ( isGFX10 ( ) ) { auto Ufmt = convertDfmtNfmt2Ufmt ( Dfmt , Nfmt ) ;

if ( Ufmt == UFMT_UNDEF ) Error ( FormatLoc , <STR_LIT> ) ;


<s> if ( getLexer ( ) . is ( AsmToken :: Comma ) ) Parser . Lex ( ) ; if ( Res != MatchOperand_Success ) { if ( ! Parser . hasPendingError ( ) ) { StringRef Msg = ( Res == MatchOperand_ParseFail ) ? <STR_LIT> : <STR_LIT> ; Error ( getLexer ( ) . getLoc ( ) , Msg ) ;


<s> if ( Desc . TSFlags & ( <STR_LIT> | <STR_LIT> | <STR_LIT> | <STR_LIT> | <STR_LIT> | <STR_LIT> ) ) { if ( <STR_LIT> ( Opcode , <STR_LIT> :: imm ) != - <NUM_LIT> ) { ++ ConstantBusUseCount ; } SmallDenseSet < unsigned > SGPRsUsed ; unsigned SGPRUsed = findImplicitSGPRReadInVOP ( Inst ) ; if ( SGPRUsed != <STR_LIT> ) { SGPRsUsed . insert ( SGPRUsed ) ; ++ ConstantBusUseCount ; } const int Src0Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src0 ) ; const int Src1Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src1 ) ; const int Src2Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src2 ) ; const int OpIndices [ ] = { Src0Idx , Src1Idx , Src2Idx } ; for ( int OpIdx : OpIndices ) { if ( OpIdx == - <NUM_LIT> ) break ; const MCOperand & MO = Inst . getOperand ( OpIdx ) ; if ( usesConstantBus ( Inst , OpIdx ) ) {


<s> if ( MO . isReg ( ) ) { const unsigned Reg = mc2PseudoReg ( MO . getReg ( ) ) ; if ( ! SGPRsUsed . count ( Reg ) ) { SGPRsUsed . insert ( Reg ) ; ++ ConstantBusUseCount ; } } else { if ( Desc . OpInfo [ OpIdx ] . OperandType == MCOI :: OPERAND_IMMEDIATE ) continue ; unsigned Size = <STR_LIT> ( Desc , OpIdx ) ; if ( Size < <NUM_LIT> ) Size = <NUM_LIT> ; if ( NumLiterals == <NUM_LIT> ) { NumLiterals = <NUM_LIT> ; LiteralSize = Size ; } else if ( LiteralSize != Size ) { NumLiterals = <NUM_LIT> ; } }


<s> } const int Ops [ ] = { <STR_LIT> :: src0 , <STR_LIT> :: src1 , <STR_LIT> :: src2 } ; const int ModOps [ ] = { <STR_LIT> :: src0_modifiers , <STR_LIT> :: src1_modifiers , <STR_LIT> :: src2_modifiers } ; int OpSelIdx = <STR_LIT> ( Opc , <STR_LIT> :: op_sel ) ; int OpSelHiIdx = <STR_LIT> ( Opc , <STR_LIT> :: op_sel_hi ) ; unsigned OpSel = Inst . getOperand ( OpSelIdx ) . getImm ( ) ; unsigned OpSelHi = Inst . getOperand ( OpSelHiIdx ) . getImm ( ) ; unsigned NegLo = <NUM_LIT> ; unsigned NegHi = <NUM_LIT> ; if ( NegLoIdx != - <NUM_LIT> ) { int NegHiIdx = <STR_LIT> ( Opc , <STR_LIT> :: neg_hi ) ; NegLo = Inst . getOperand ( NegLoIdx ) . getImm ( ) ; NegHi = Inst . getOperand ( NegHiIdx ) . getImm ( ) ; }

for ( int J = <NUM_LIT> ; J < <NUM_LIT> ; ++ J ) {


<s> bool Abs = Imm . Modifiers & <NUM_LIT> ; if ( Imm . IsFPImm ) { APFloat F ( BitsToFloat ( Val ) ) ; if ( Abs ) { F . clearSign ( ) ; } if ( Negate ) { F . changeSign ( ) ; } Val = F . bitcastToAPInt ( ) . getZExtValue ( ) ;


<s> void addRegOrImmOperands ( MCInst & Inst , unsigned N ) const { if ( isRegKind ( ) ) addRegOperands ( Inst , N ) ;


<s> if ( isRegKind ( ) ) addRegOperands ( Inst , N ) ; else addImmOperands ( Inst , N ) ;


<s> addRegOperands ( Inst , N ) ; } else { Inst . addOperand ( MCOperand :: createImm ( Imm . Modifiers ) ) ; addImmOperands ( Inst , N , false ) ;


<s> static <ISA_LIT>Operand :: Ptr CreateImm ( int64_t Val , SMLoc Loc , enum ImmTy Type = ImmTyNone , bool IsFPImm = false ) { auto Op = llvm :: make_unique < <ISA_LIT>Operand > ( Immediate ) ; Op -> Imm . Val = Val ;


<s> auto Op = llvm :: make_unique < <ISA_LIT>Operand > ( Register ) ; Op -> Reg . RegNo = RegNo ; Op -> Reg . TRI = TRI ; Op -> Reg . STI = STI ; Op -> Reg . Modifiers = <NUM_LIT> ; Op -> Reg . IsForcedVOP3 = ForceVOP3 ; Op -> StartLoc = S ;


<s> const MCInstrDesc & Desc = MII . get ( Inst . getOpcode ( ) ) ; for ( unsigned J = <NUM_LIT> ; J < Desc . getNumDefs ( ) ; ++ J ) { ( ( <ISA_LIT>Operand & ) * Operands [ I ++ ] ) . addRegOperands ( Inst , <NUM_LIT> ) ; } for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isRegOrImmWithInputMods ( ) ) { Op . addRegOrImmWithInputModsOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isDPPCtrl ( ) ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isImm ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { llvm_unreachable ( <STR_LIT> ) ; } } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppRowMask , <NUM_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppBankMask , <NUM_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppBoundCtrl ) ;


<s> } else if ( Op . isImm ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { assert ( false ) ; } } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> ) ;


<s> <ISA_LIT>Operand :: Ptr <ISA_LIT>AsmParser :: defaultClamp<ISA_LIT> ( ) const { return <ISA_LIT>Operand :: CreateImm ( <NUM_LIT> , SMLoc ( ) , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> ) ;


<s> <ISA_LIT>Operand :: Ptr <ISA_LIT>AsmParser :: defaultHwreg ( ) const {

return <ISA_LIT>Operand :: CreateImm ( <NUM_LIT> , SMLoc ( ) , <ISA_LIT>Operand :: ImmTyHwreg ) ;


<s> return <ISA_LIT>Operand :: CreateImm ( <NUM_LIT> , SMLoc ( ) , <ISA_LIT>Operand :: ImmTyHwreg ) ;


<s> <ISA_LIT>Operand :: Ptr <ISA_LIT>AsmParser :: defaultMubufOffset ( ) const {

return <ISA_LIT>Operand :: CreateImm ( <NUM_LIT> , SMLoc ( ) , <ISA_LIT>Operand :: ImmTyOffset ) ;


<s> return <ISA_LIT>Operand :: CreateImm ( <NUM_LIT> , SMLoc ( ) , <ISA_LIT>Operand :: ImmTySdwaDstUnused ) ;


<s> <ISA_LIT>Operand :: Ptr <ISA_LIT>AsmParser :: defaultSDWASel ( ) const { return <ISA_LIT>Operand :: CreateImm ( <NUM_LIT> , SMLoc ( ) , <ISA_LIT>Operand :: ImmTySdwaSel ) ;


<s> assert ( isRegKind ( ) || isImm ( ) ) ; return isRegKind ( ) ? Reg . Modifiers != <NUM_LIT> : Imm . Modifiers != <NUM_LIT> ;


<s> return Kind == Immediate && Imm . Type != ImmTyNone ;


<s> return ( Imm . Val <= <NUM_LIT> && Imm . Val >= - <NUM_LIT> ) || ( F == <NUM_LIT> || F == <NUM_LIT> || F == - <NUM_LIT> || F == <NUM_LIT> || F == - <NUM_LIT> || F == <NUM_LIT> || F == - <NUM_LIT> || F == <NUM_LIT> || F == - <NUM_LIT> ) ;


<s> return Kind == Register && Reg . Modifiers == <NUM_LIT> ;


<s> bool isRegOrImmWithInputMods ( ) const {

return Kind == Register || isInlinableImm ( ) ;


<s> bool isRegOrImmWithInputMods ( ) const { return Kind == Register || isInlinableImm ( ) ;


<s> bool isSDWASel ( ) const { return isImmTy ( ImmTySdwaSel ) ;


<s> else if ( RegName [ <NUM_LIT> ] == 's' ) { RegNumIndex = <NUM_LIT> ; RegKind = IS_SGPR ; } else if ( RegName . startswith ( <STR_LIT> ) ) { RegNumIndex = strlen ( <STR_LIT> ) ; RegKind = IS_TTMP ; } else { return false ; } if ( RegName . size ( ) > RegNumIndex ) { if ( RegName . substr ( RegNumIndex ) . getAsInteger ( <NUM_LIT> , RegNum ) ) { return false ; } Parser . Lex ( ) ; RegWidth = <NUM_LIT> ; } else { Parser . Lex ( ) ; int64_t RegLo , RegHi ; if ( getLexer ( ) . isNot ( AsmToken :: LBrac ) ) { return false ; } Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( RegLo ) ) { return false ; } const bool isRBrace = getLexer ( ) . is ( AsmToken :: RBrac ) ; if ( ! isRBrace && getLexer ( ) . isNot ( AsmToken :: Colon ) ) { return false ; } Parser . Lex ( ) ; if ( isRBrace ) { RegHi = RegLo ; } else { if ( getParser ( ) . parseAbsoluteExpression ( RegHi ) ) { return false ; } if ( getLexer ( ) . isNot ( AsmToken :: RBrac ) ) { return false ; } Parser . Lex ( ) ; } RegNum = ( unsigned ) RegLo ; RegWidth = ( RegHi - RegLo ) + <NUM_LIT> ; } } } else if ( getLexer ( ) . is ( AsmToken :: LBrac ) ) { Parser . Lex ( ) ; if ( ! Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth ) ) { return false ; } if ( RegWidth != <NUM_LIT> ) { return false ; } RegisterKind RegKind1 ; unsigned Reg1 , RegNum1 , RegWidth1 ; do { if ( getLexer ( ) . is ( AsmToken :: Comma ) ) { Parser . Lex ( ) ; } else if ( getLexer ( ) . is ( AsmToken :: RBrac ) ) { Parser . Lex ( ) ; break ; } else if ( Parse<ISA_LIT>Register ( RegKind1 , Reg1 , RegNum1 , RegWidth1 ) ) { if ( RegWidth1 != <NUM_LIT> ) { return false ; } if ( RegKind1 != RegKind ) { return false ; } if ( ! AddNextRegisterToList ( Reg , RegWidth , RegKind1 , Reg1 , RegNum1 ) ) { return false ; } } else { return false ; } } while ( true ) ; } else { return false ; } switch ( RegKind ) { case IS_SPECIAL : RegNum = <NUM_LIT> ; RegWidth = <NUM_LIT> ; break ; case IS_VGPR : case IS_SGPR :


<s> raw_svector_ostream Err ( ErrStr ) ; if ( ! parseAmdKernelCodeField ( ID , getLexer ( ) , Header , Err ) ) { return TokError ( Err . str ( ) ) ; }


<s> } if ( Prefix == <STR_LIT> ) { Int = <NUM_LIT> ; } else if ( Prefix == <STR_LIT> ) { Int = <NUM_LIT> ; } else { if ( Prefix != <STR_LIT> && Prefix != <STR_LIT> && Prefix != <STR_LIT> && Prefix != <STR_LIT> && Prefix != <STR_LIT> && Prefix != <STR_LIT> && Prefix != <STR_LIT> && Prefix != <STR_LIT> && Prefix != <STR_LIT> ) { return MatchOperand_NoMatch ; } Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Colon ) ) return MatchOperand_ParseFail ; if ( Prefix == <STR_LIT> ) { Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: LBrac ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return MatchOperand_ParseFail ; Int = getLexer ( ) . getTok ( ) . getIntVal ( ) ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return MatchOperand_ParseFail ; Int += ( getLexer ( ) . getTok ( ) . getIntVal ( ) << <NUM_LIT> ) ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return MatchOperand_ParseFail ; Int += ( getLexer ( ) . getTok ( ) . getIntVal ( ) << <NUM_LIT> ) ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return MatchOperand_ParseFail ; Int += ( getLexer ( ) . getTok ( ) . getIntVal ( ) << <NUM_LIT> ) ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: RBrac ) ) return MatchOperand_ParseFail ;


<s> else if ( Name . endswith ( <STR_LIT> ) ) setForcedEncodingSize ( <NUM_LIT> ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateToken ( Name , NameLoc ) ) ; if ( Name . endswith ( <STR_LIT> ) ) { Name = Name . substr ( <NUM_LIT> , Name . size ( ) - <NUM_LIT> ) ; } if ( Name . endswith ( <STR_LIT> ) ) { Name = Name . substr ( <NUM_LIT> , Name . size ( ) - <NUM_LIT> ) ; } while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) {

<ISA_LIT>AsmParser :: OperandMatchResultTy Res = parseOperand ( Operands , Name ) ;


<s> <ISA_LIT>AsmParser :: OperandMatchResultTy <ISA_LIT>AsmParser :: parseOperand ( OperandVector & Operands , StringRef Mnemonic ) { OperandMatchResultTy ResTy = MatchOperandParserImpl ( Operands , Mnemonic ) ; if ( ResTy == MatchOperand_Success || ResTy == MatchOperand_ParseFail || getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) return ResTy ; ResTy = parseRegOrImm ( Operands ) ; if ( ResTy == MatchOperand_Success ) return ResTy ; if ( getLexer ( ) . getKind ( ) == AsmToken :: Identifier ) { const auto & Tok = Parser . getTok ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateToken ( Tok . getString ( ) , Tok . getLoc ( ) ) ) ; Parser . Lex ( ) ;


<s> res = parseSDWASel ( Operands ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTySdwaDstUnused ) { res = parseSDWADstUnused ( Operands ) ; } else { res = parseIntWithPrefix ( Op . Name , Operands , Op . Type , Op . ConvertResult ) ; } if ( res != MatchOperand_NoMatch ) { return res ; }


<s> return MatchOperand_ParseFail ; } else if ( res == MatchOperand_NoMatch ) { res = parseStringWithPrefix ( <STR_LIT> , Value ) ; if ( res == MatchOperand_ParseFail ) { return MatchOperand_ParseFail ; } else if ( res == MatchOperand_NoMatch ) { res = parseStringWithPrefix ( <STR_LIT> , Value ) ; if ( res != MatchOperand_Success ) { return res ; } } } int64_t Int ; Int = StringSwitch < int64_t > ( Value ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Default ( <NUM_LIT> ) ; Parser . Lex ( ) ;


<s> return MatchOperand_ParseFail ; } else if ( res == MatchOperand_NoMatch ) { res = parseStringWithPrefix ( <STR_LIT> , Value ) ; if ( res != MatchOperand_Success ) { return res ; } } } int64_t Int ; Int = StringSwitch < int64_t > ( Value ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Default ( <NUM_LIT> ) ; Parser . Lex ( ) ; if ( Int == <NUM_LIT> ) { return MatchOperand_ParseFail ; }

Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( Int , S , <ISA_LIT>Operand :: ImmTySdwaSel ) ) ;


<s> <ISA_LIT>AsmParser :: OperandMatchResultTy <ISA_LIT>AsmParser :: parseStringWithPrefix ( const char * Prefix , StringRef & Value ) { if ( getLexer ( ) . isNot ( AsmToken :: Identifier ) ) { return MatchOperand_NoMatch ; } StringRef Tok = Parser . getTok ( ) . getString ( ) ; if ( Tok != Prefix ) { return MatchOperand_NoMatch ; }


<s> if ( getImmTy ( ) != ImmTyNone ) { OS << <STR_LIT> ; printImmTy ( OS , getImmTy ( ) ) ; } OS << <STR_LIT> << Imm . Modifiers << '>' ; break ; case Token : OS << '\'' << getToken ( ) << '\'' ; break ; case Expression : OS << <STR_LIT> << * Expr << '>' ; break ; }


<s> case ImmTyOffset : OS << <STR_LIT> ; break ; case ImmTyOffset0 : OS << <STR_LIT> ; break ; case ImmTyOffset1 : OS << <STR_LIT> ; break ; case ImmTyGLC : OS << <STR_LIT> ; break ; case ImmTySLC : OS << <STR_LIT> ; break ; case ImmTyTFE : OS << <STR_LIT> ; break ; case ImmTyClamp<ISA_LIT> : OS << <STR_LIT> ; break ; case ImmTyOMod<ISA_LIT> : OS << <STR_LIT> ; break ; case ImmTyDppCtrl : OS << <STR_LIT> ; break ; case ImmTyDppRowMask : OS << <STR_LIT> ; break ; case ImmTyDppBankMask : OS << <STR_LIT> ; break ; case ImmTyDppBoundCtrl : OS << <STR_LIT> ; break ; case ImmTySdwaSel : OS << <STR_LIT> ; break ; case ImmTySdwaDstUnused : OS << <STR_LIT> ; break ; case ImmTyDMask : OS << <STR_LIT> ; break ; case ImmTyUNorm : OS << <STR_LIT> ; break ; case ImmTyDA : OS << <STR_LIT> ; break ; case ImmTyR128 : OS << <STR_LIT> ; break ; case ImmTyLWE : OS << <STR_LIT> ; break ; case ImmTyHwreg : OS << <STR_LIT> ; break ; case ImmTySendMsg : OS << <STR_LIT> ; break ; }


<s> case ImmTyGLC : OS << <STR_LIT> ; break ; case ImmTySLC : OS << <STR_LIT> ; break ; case ImmTyTFE : OS << <STR_LIT> ; break ; case ImmTyClamp<ISA_LIT> : OS << <STR_LIT> ; break ; case ImmTyOMod<ISA_LIT> : OS << <STR_LIT> ; break ; case ImmTyDppCtrl : OS << <STR_LIT> ; break ; case ImmTyDppRowMask : OS << <STR_LIT> ; break ; case ImmTyDppBankMask : OS << <STR_LIT> ; break ; case ImmTyDppBoundCtrl : OS << <STR_LIT> ; break ; case ImmTySdwaSel : OS << <STR_LIT> ; break ; case ImmTySdwaDstUnused : OS << <STR_LIT> ; break ; case ImmTyDMask : OS << <STR_LIT> ; break ; case ImmTyUNorm : OS << <STR_LIT> ; break ; case ImmTyDA : OS << <STR_LIT> ; break ; case ImmTyR128 : OS << <STR_LIT> ; break ; case ImmTyLWE : OS << <STR_LIT> ; break ; case ImmTyHwreg : OS << <STR_LIT> ; break ; case ImmTySendMsg : OS << <STR_LIT> ; break ;


<s> assert ( isReg ( ) || ( isImm ( ) && Imm . Modifiers == <NUM_LIT> ) ) ; if ( isReg ( ) ) Reg . Modifiers = Mods ;


<s> case MCK_glc : return Operand . isGLC ( ) ? Match_Success : Match_InvalidOperand ; case MCK_idxen : return Operand . isIdxen ( ) ? Match_Success : Match_InvalidOperand ; case MCK_offen : return Operand . isOffen ( ) ? Match_Success : Match_InvalidOperand ; default : return Match_InvalidOperand ; }


<s> const int Src0Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src0 ) ; const int Src1Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src1 ) ; const int Src2Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src2 ) ; const int OpIndices [ ] = { Src0Idx , Src1Idx , Src2Idx } ; unsigned NumLiterals = <NUM_LIT> ; uint32_t LiteralValue ; for ( int OpIdx : OpIndices ) { if ( OpIdx == - <NUM_LIT> ) break ; const MCOperand & MO = Inst . getOperand ( OpIdx ) ; if ( ! MO . isImm ( ) || ! <STR_LIT> ( Desc , OpIdx ) ) continue ; if ( OpIdx == Src2Idx && ( Desc . TSFlags & <STR_LIT> ) && getFeatureBits ( ) [ <STR_LIT> ] ) return false ;

if ( ! isInlineConstant ( Inst , OpIdx ) ) {


<s> bool isVI ( ) const { return getSTI ( ) . getFeatureBits ( ) [ <STR_LIT> ] ;


<s> if ( IDVal == <STR_LIT> ) return ParseDirectiveHSACodeObjectVersion ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirectiveHSACodeObjectISA ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirectiveAMDKernelCodeT ( ) ; if ( IDVal == <STR_LIT> || IDVal == <STR_LIT> ) return ParseSectionDirectiveHSAText ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirective<ISA_LIT>HsaKernel ( ) ;


<s> if ( IDVal == <STR_LIT> || IDVal == <STR_LIT> ) return ParseSectionDirectiveHSAText ( ) ;

if ( IDVal == <STR_LIT> ) return ParseDirective<ISA_LIT>HsaKernel ( ) ;


<s> if ( getLexer ( ) . isNot ( AsmToken :: LBrac ) ) return true ; Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( RegLo ) ) return true ; if ( getLexer ( ) . isNot ( AsmToken :: Colon ) ) return true ; Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( RegHi ) ) return true ; if ( getLexer ( ) . isNot ( AsmToken :: RBrac ) ) return true ; Parser . Lex ( ) ; RegWidth = ( RegHi - RegLo ) + <NUM_LIT> ; if ( IsVgpr ) { RegIndexInClass = RegLo ; } else { unsigned Size = std :: min ( RegWidth , <NUM_LIT> ) ; if ( RegLo % Size != <NUM_LIT> ) return true ; RegIndexInClass = RegLo / Size ; } } const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; int RCID = getRegClass ( IsVgpr , RegWidth ) ; if ( RCID == - <NUM_LIT> ) return true ;

const MCRegisterClass RC = TRI -> getRegClass ( RCID ) ;


<s> R . isValid ( ) ; ++ R ) { if ( * R == RegNo ) return false ; }


<s> unsigned NumSGPRs = NextFreeSGPR ; if ( Version . Major >= <NUM_LIT> ) NumSGPRs = <NUM_LIT> ; else { unsigned MaxAddressableNumSGPRs = IsaInfo :: getAddressableNumSGPRs ( & getSTI ( ) ) ; if ( Version . Major >= <NUM_LIT> && ! Features . test ( FeatureSGPRInitBug ) && NumSGPRs > MaxAddressableNumSGPRs ) return OutOfRangeError ( SGPRRange ) ;

NumSGPRs += IsaInfo :: getNumExtraSGPRs ( & getSTI ( ) , VCCUsed , FlatScrUsed , XNACKUsed ) ;


<s> unsigned NumSGPRs = NextFreeSGPR ; if ( Version . Major >= <NUM_LIT> ) NumSGPRs = <NUM_LIT> ; else { unsigned MaxAddressableNumSGPRs = IsaInfo :: getAddressableNumSGPRs ( & getSTI ( ) ) ; if ( Version . Major >= <NUM_LIT> && ! Features . test ( FeatureSGPRInitBug ) && NumSGPRs > MaxAddressableNumSGPRs ) return OutOfRangeError ( SGPRRange ) ; NumSGPRs += IsaInfo :: getNumExtraSGPRs ( & getSTI ( ) , VCCUsed , FlatScrUsed , XNACKUsed ) ; if ( ( Version . Major <= <NUM_LIT> || Features . test ( FeatureSGPRInitBug ) ) && NumSGPRs > MaxAddressableNumSGPRs ) return OutOfRangeError ( SGPRRange ) ; if ( Features . test ( FeatureSGPRInitBug ) ) NumSGPRs = IsaInfo :: FIXED_NUM_SGPRS_FOR_INIT_BUG ;


<s> } <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isReg ( ) && Op . getReg ( ) == <STR_LIT> ) { continue ; } if ( isRegOrImmWithInputMods ( Desc , Inst . getNumOperands ( ) ) ) { Op . addRegWithFPInputModsOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isDPPCtrl ( ) ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isImm ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { llvm_unreachable ( <STR_LIT> ) ; } }

addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppRowMask , <NUM_LIT> ) ;


<s> unsigned I = <NUM_LIT> ; const MCInstrDesc & Desc = MII . get ( Inst . getOpcode ( ) ) ; for ( unsigned J = <NUM_LIT> ; J < Desc . getNumDefs ( ) ; ++ J ) { ( ( <ISA_LIT>Operand & ) * Operands [ I ++ ] ) . addRegOperands ( Inst , <NUM_LIT> ) ; } for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { auto TiedTo = Desc . getOperandConstraint ( Inst . getNumOperands ( ) , MCOI :: TIED_TO ) ; if ( TiedTo != - <NUM_LIT> ) { assert ( ( unsigned ) TiedTo < Inst . getNumOperands ( ) ) ; Inst . addOperand ( Inst . getOperand ( TiedTo ) ) ; } <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isReg ( ) && Op . getReg ( ) == <STR_LIT> ) { continue ; } if ( isRegOrImmWithInputMods ( Desc , Inst . getNumOperands ( ) ) ) { Op . addRegWithFPInputModsOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isDPPCtrl ( ) ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isImm ( ) ) {


<s> static unsigned getSpecialRegForName ( StringRef RegName ) { return StringSwitch < unsigned > ( RegName ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Case ( <STR_LIT> , <STR_LIT> ) . Default ( <NUM_LIT> ) ;


<s> static bool isInlineValue ( unsigned Reg ) { switch ( Reg ) {


<s> Parser . eatToEndOfStatement ( ) ; return false ; } SmallString < <NUM_LIT> > ErrStr ; raw_svector_ostream Err ( ErrStr ) ; if ( ! parseAmdKernelCodeField ( ID , getParser ( ) , Header , Err ) ) { return TokError ( Err . str ( ) ) ; } Lex ( ) ; if ( ID == <STR_LIT> ) { if ( G_00B848_WGP_MODE ( Header . compute_pgm_resource_registers ) && ! isGFX10 ( ) ) return TokError ( <STR_LIT> ) ; } if ( ID == <STR_LIT> ) { if ( G_00B848_MEM_ORDERED ( Header . compute_pgm_resource_registers ) && ! isGFX10 ( ) ) return TokError ( <STR_LIT> ) ; } if ( ID == <STR_LIT> ) { if ( G_00B848_FWD_PROGRESS ( Header . compute_pgm_resource_registers ) && ! isGFX10 ( ) ) return TokError ( <STR_LIT> ) ; }


<s> raw_svector_ostream Err ( ErrStr ) ; if ( ! parseAmdKernelCodeField ( ID , getParser ( ) , Header , Err ) ) { return TokError ( Err . str ( ) ) ; } Lex ( ) ; if ( ID == <STR_LIT> ) { if ( G_00B848_WGP_MODE ( Header . compute_pgm_resource_registers ) && ! isGFX10 ( ) ) return TokError ( <STR_LIT> ) ;


<s> if ( <STR_LIT> :: hasCodeObjectV3 ( & getSTI ( ) ) ) { if ( IDVal == <STR_LIT> ) return ParseDirectiveAMDGCNTarget ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirectiveAMDHSAKernel ( ) ; if ( IDVal == <STR_LIT> :: V3 :: AssemblerDirectiveBegin ) return ParseDirectiveHSAMetadata ( ) ; } else { if ( IDVal == <STR_LIT> ) return ParseDirectiveHSACodeObjectVersion ( ) ;

if ( IDVal == <STR_LIT> ) return ParseDirectiveHSACodeObjectISA ( ) ;


<s> for ( int i = ID_SYMBOLIC_FIRST_ ; i < Last ; ++ i ) { if ( tok == IdSymbolic [ i ] ) { HwReg . Id = i ; break ; } } Parser . Lex ( ) ; } else { HwReg . IsSymbolic = false ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return true ; if ( getParser ( ) . parseAbsoluteExpression ( HwReg . Id ) ) return true ; } if ( getLexer ( ) . is ( AsmToken :: RParen ) ) { Parser . Lex ( ) ; return false ; } if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return true ; Parser . Lex ( ) ;