<s> 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 unsigned DstReg = mc2PseudoReg ( Dst . getReg ( ) ) ; const int SrcIndices [ ] = { Src0Idx , Src1Idx , Src2Idx } ;


<s> Error ( getFlatOffsetLoc ( Operands ) , <STR_LIT> ) ; return false ; } unsigned OffsetSize = isGFX9 ( ) ? <NUM_LIT> : <NUM_LIT> ; if ( TSFlags & <STR_LIT> ) { if ( ! isIntN ( OffsetSize , Op . getImm ( ) ) ) { Error ( getFlatOffsetLoc ( Operands ) , isGFX9 ( ) ? <STR_LIT> : <STR_LIT> ) ; return false ;


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


<s> bool <ISA_LIT>AsmParser :: validateLdsDirect ( const MCInst & Inst ) { using namespace <ISA_LIT>InstrFlags ; const unsigned Opcode = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opcode ) ; if ( ( Desc . TSFlags & ( VOP1 | VOP2 | VOP3 | VOPC | VOP3P | <STR_LIT> ) ) == <NUM_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 SrcIndices [ ] = { Src1Idx , Src2Idx } ; for ( int SrcIdx : SrcIndices ) { if ( SrcIdx == - <NUM_LIT> ) break ; const MCOperand & Src = Inst . getOperand ( SrcIdx ) ; if ( Src . isReg ( ) && Src . getReg ( ) == LDS_DIRECT ) { return false ;


<s> if ( ( Desc . TSFlags & ( VOP1 | VOP2 | VOP3 | VOPC | VOP3P | <STR_LIT> ) ) == <NUM_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 SrcIndices [ ] = { Src1Idx , Src2Idx } ; for ( int SrcIdx : SrcIndices ) { if ( SrcIdx == - <NUM_LIT> ) break ;

const MCOperand & Src = Inst . getOperand ( SrcIdx ) ;


<s> auto Reg = Src0 . getReg ( ) ; const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; if ( isSGPR ( mc2PseudoReg ( Reg ) , TRI ) ) { Error ( getLoc ( ) , <STR_LIT> ) ; return false ; } return true ;


<s> 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> ) ; if ( ! IsNSA ) { if ( AddrSize > <NUM_LIT> ) AddrSize = <NUM_LIT> ; else if ( AddrSize > <NUM_LIT> ) AddrSize = <NUM_LIT> ; } return VAddrSize == AddrSize ;


<s> unsigned VDataSize = <STR_LIT> ( getMRI ( ) , Desc , VDataIdx ) ; unsigned TFESize = Inst . getOperand ( TFEIdx ) . getImm ( ) ? <NUM_LIT> : <NUM_LIT> ; unsigned DMask = Inst . getOperand ( DMaskIdx ) . getImm ( ) & <NUM_LIT> ; if ( DMask == <NUM_LIT> ) DMask = <NUM_LIT> ; unsigned DataSize = ( Desc . TSFlags & <STR_LIT> ) ? <NUM_LIT> : countPopulation ( DMask ) ; if ( hasPackedD16 ( ) ) { int D16Idx = <STR_LIT> ( Opc , <STR_LIT> :: d16 ) ; if ( D16Idx >= <NUM_LIT> && Inst . getOperand ( D16Idx ) . getImm ( ) ) DataSize = ( DataSize + <NUM_LIT> ) / <NUM_LIT> ; } return ( VDataSize / <NUM_LIT> ) == DataSize + TFESize ;


<s> bool <ISA_LIT>AsmParser :: validateMovrels ( const MCInst & Inst ) { const unsigned Opc = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> || ! IsMovrelsSDWAOpcode ( Opc ) ) return true ;

const int Src0Idx = <STR_LIT> ( Opc , <STR_LIT> :: src0 ) ;


<s> const MCOperand & Src0 = Inst . getOperand ( Src0Idx ) ; if ( ! Src0 . isReg ( ) ) return false ; auto Reg = Src0 . getReg ( ) ; const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; return ! isSGPR ( mc2PseudoReg ( Reg ) , TRI ) ;


<s> Error ( S , <STR_LIT> ) ; return false ; } else if ( Strict && ( msgRequiresOp ( Msg . Id ) != Op . IsDefined ) ) { Error ( S , Op . IsDefined ? <STR_LIT> : <STR_LIT> ) ; return false ; } else if ( ! isValidMsgOp ( Msg . Id , Op . Id , Strict ) ) { Error ( S , <STR_LIT> ) ;


<s> return Operand . isIdxen ( ) ? Match_Success : Match_InvalidOperand ; case MCK_offen : return Operand . isOffen ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SSrcB32 : return Operand . isSSrcB32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SSrcF32 : return Operand . isSSrcF32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SoppBrTarget : return Operand . isSoppBrTarget ( ) ? Match_Success : Match_InvalidOperand ; case MCK_VReg32OrOff : return Operand . isVReg32OrOff ( ) ? Match_Success : Match_InvalidOperand ; case MCK_InterpSlot : return Operand . isInterpSlot ( ) ? Match_Success : Match_InvalidOperand ; case MCK_Attr : return Operand . isInterpAttr ( ) ? Match_Success : Match_InvalidOperand ; case MCK_AttrChan : return Operand . isAttrChan ( ) ? Match_Success : Match_InvalidOperand ; case MCK_ImmSMEMOffset : return Operand . isSMEMOffset ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SReg_64 : case MCK_SReg_64_XEXEC :

return Operand . isNull ( ) ? Match_Success : Match_InvalidOperand ;


<s> 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> ] ) 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 ; return ! NumLiterals || ( NumLiterals == <NUM_LIT> && getFeatureBits ( ) [ <STR_LIT> ] ) ;


<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 ; } 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 ; } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } return false ; case IS_VGPR : case IS_SGPR : case IS_AGPR : case IS_TTMP : if ( Reg1 != Reg + RegWidth ) { return false ; }


<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 ; } return false ; case IS_VGPR : case IS_SGPR : case IS_AGPR : case IS_TTMP : if ( Reg1 != Reg + RegWidth ) { return false ;


<s> for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isReg ( ) ) { Op . addRegOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isImmModifier ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else if ( ! Op . isToken ( ) ) { llvm_unreachable ( <STR_LIT> ) ; } } bool IsGFX10 = isGFX10 ( ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDMask ) ; if ( IsGFX10 ) addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDim , - <NUM_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyUNorm ) ; if ( IsGFX10 ) addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDLC ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyGLC ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySLC ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyR128A16 ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyTFE ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyLWE ) ; if ( ! IsGFX10 ) addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDA ) ;

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


<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> ) ; } if ( <STR_LIT> ( Opc , <STR_LIT> :: src0_modifiers ) != - <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 if ( Op . isRegOrImm ( ) ) { Op . addRegOrImmOperands ( Inst , <NUM_LIT> ) ; } else { llvm_unreachable ( <STR_LIT> ) ; } } } else { for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isMod ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { Op . addRegOrImmOperands ( Inst , <NUM_LIT> ) ; } } }

if ( <STR_LIT> ( Opc , <STR_LIT> :: clamp ) != - <NUM_LIT> ) {


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

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


<s> void <ISA_LIT>AsmParser :: errorExpTgt ( ) {

Error ( Parser . getTok ( ) . getLoc ( ) , <STR_LIT> ) ;


<s> static const unsigned Variants [ ] = { <ISA_LIT>AsmVariants :: VOP3 } ; return makeArrayRef ( Variants ) ; } if ( isForcedSDWA ( ) ) { static const unsigned Variants [ ] = { <ISA_LIT>AsmVariants :: SDWA , <ISA_LIT>AsmVariants :: SDWA9 } ; return makeArrayRef ( Variants ) ; } if ( isForcedDPP ( ) ) { static const unsigned Variants [ ] = { <ISA_LIT>AsmVariants :: DPP } ;


<s> case <NUM_LIT> : return <STR_LIT> ; case <NUM_LIT> : return <STR_LIT> ; } } else if ( Is == IS_TTMP ) { 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> ; } } 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> ;


<s> unsigned AlignSize = <NUM_LIT> ; if ( RegKind == IS_SGPR || RegKind == IS_TTMP ) { AlignSize = std :: min ( RegWidth , <NUM_LIT> ) ; } if ( RegNum % AlignSize != <NUM_LIT> ) return <STR_LIT> ; unsigned RegIdx = RegNum / AlignSize ; int RCID = getRegClass ( RegKind , RegWidth ) ; if ( RCID == - <NUM_LIT> ) return <STR_LIT> ; const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ;

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


<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> ) . 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 ( <STR_LIT> ) ;


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


<s> if ( isInlineValue ( ) ) { return true ; } if ( ! isImmTy ( ImmTyNone ) ) { return false ; } APInt Literal ( <NUM_LIT> , Imm . Val ) ; if ( Imm . IsFPImm ) { if ( type == <STR_LIT> || type == <STR_LIT> ) { return <STR_LIT> ( Imm . Val , AsmParser -> hasInv2PiInlineImm ( ) ) ; } APFloat FPLiteral ( APFloat :: IEEEdouble ( ) , APInt ( <NUM_LIT> , Imm . Val ) ) ; if ( ! canLosslesslyConvertToFPType ( FPLiteral , type ) ) return false ; if ( type . getScalarSizeInBits ( ) == <NUM_LIT> ) { return <STR_LIT> ( static_cast < int16_t > ( FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ; } return <STR_LIT> ( static_cast < int32_t > ( FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ; } if ( type == <STR_LIT> || type == <STR_LIT> ) { return <STR_LIT> ( Imm . Val , AsmParser -> hasInv2PiInlineImm ( ) ) ; } if ( ! isSafeTruncation ( Imm . Val , type . getScalarSizeInBits ( ) ) ) { return false ; } if ( type . getScalarSizeInBits ( ) == <NUM_LIT> ) {

return <STR_LIT> ( static_cast < int16_t > ( Literal . getLoBits ( <NUM_LIT> ) . getSExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ;


<s> if ( type . getScalarSizeInBits ( ) == <NUM_LIT> ) { return <STR_LIT> ( static_cast < int16_t > ( FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ; } return <STR_LIT> ( static_cast < int32_t > ( FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ; } if ( type == <STR_LIT> || type == <STR_LIT> ) { return <STR_LIT> ( Imm . Val , AsmParser -> hasInv2PiInlineImm ( ) ) ; } if ( ! isSafeTruncation ( Imm . Val , type . getScalarSizeInBits ( ) ) ) { return false ; } if ( type . getScalarSizeInBits ( ) == <NUM_LIT> ) { return <STR_LIT> ( static_cast < int16_t > ( Literal . getLoBits ( <NUM_LIT> ) . getSExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ; }

return <STR_LIT> ( static_cast < int32_t > ( Literal . getLoBits ( <NUM_LIT> ) . getZExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ;


<s> case <NUM_LIT> : { const unsigned OperandType = Desc . OpInfo [ OpIdx ] . OperandType ; if ( OperandType == <STR_LIT> || OperandType == <STR_LIT> || OperandType == <STR_LIT> || OperandType == <STR_LIT> || OperandType == <STR_LIT> || OperandType == <STR_LIT> ) { return <STR_LIT> ( Val , hasInv2PiInlineImm ( ) ) ; } else { return <STR_LIT> ( Val , hasInv2PiInlineImm ( ) ) ;


<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> : 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> : 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> : 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> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> return isImm ( ) && isUInt < <NUM_LIT> > ( getImm ( ) ) ;


<s> return isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) ;


<s> return isVCSrcF16 ( ) || isLiteralImm ( <STR_LIT> ) ;


<s> if ( R == Match_Success ) break ; } switch ( Result ) { default : break ; case Match_Success : if ( ! validateInstruction ( Inst , IDLoc , Operands ) ) { 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 ) ;


<s> Reg = <STR_LIT> ; if ( isToken ( AsmToken :: Identifier ) ) { Reg = ParseSpecialReg ( RegKind , RegNum , RegWidth ) ; if ( Reg == <STR_LIT> ) Reg = ParseRegularReg ( RegKind , RegNum , RegWidth ) ; } else {

Reg = ParseRegList ( RegKind , RegNum , RegWidth ) ;


<s> if ( Reg == <STR_LIT> ) Reg = ParseRegularReg ( RegKind , RegNum , RegWidth ) ; } else { Reg = ParseRegList ( RegKind , RegNum , RegWidth ) ; } const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; return Reg != <STR_LIT> && subtargetHasRegister ( * TRI , Reg ) ;


<s> if ( Res != MatchOperand_NoMatch ) { if ( Res != MatchOperand_Success ) return Res ; if ( Nfmt >= <NUM_LIT> ) { Error ( Parser . getTok ( ) . getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } GotNfmt = true ; Parser . Lex ( ) ; continue ; } } break ; } if ( ! GotDfmt && ! GotNfmt ) return MatchOperand_NoMatch ; auto Format = Dfmt | Nfmt << <NUM_LIT> ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Format , S , <ISA_LIT>Operand :: ImmTyFORMAT ) ) ;


<s> SMLoc S = Parser . getTok ( ) . getLoc ( ) ; int64_t Dfmt = <NUM_LIT> , Nfmt = <NUM_LIT> ; bool GotDfmt = false , GotNfmt = false ; while ( ! GotDfmt || ! GotNfmt ) { if ( ! GotDfmt ) { auto Res = parseIntWithPrefix ( <STR_LIT> , Dfmt ) ; if ( Res != MatchOperand_NoMatch ) { if ( Res != MatchOperand_Success ) return Res ; if ( Dfmt >= <NUM_LIT> ) { Error ( Parser . getTok ( ) . getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } GotDfmt = true ; Parser . Lex ( ) ; continue ; } } if ( ! GotNfmt ) { auto Res = parseIntWithPrefix ( <STR_LIT> , Nfmt ) ; if ( Res != MatchOperand_NoMatch ) { if ( Res != MatchOperand_Success ) return Res ; if ( Nfmt >= <NUM_LIT> ) { Error ( Parser . getTok ( ) . getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } GotNfmt = true ; Parser . Lex ( ) ; continue ; } } break ; } if ( ! GotDfmt && ! GotNfmt ) return MatchOperand_NoMatch ; auto Format = Dfmt | Nfmt << <NUM_LIT> ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Format , S , <ISA_LIT>Operand :: ImmTyFORMAT ) ) ; return MatchOperand_Success ;


<s> Token += getLexer ( ) . getTok ( ) . getString ( ) ; StringRef DimId = Token ; if ( DimId . startswith ( <STR_LIT> ) ) DimId = DimId . substr ( <NUM_LIT> ) ; const <STR_LIT> * DimInfo = <STR_LIT> ( DimId ) ; if ( ! DimInfo ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , DimInfo -> Encoding , S , <ISA_LIT>Operand :: ImmTyDim ) ) ;


<s> Parser . Lex ( ) ; std :: string Token ; if ( getLexer ( ) . is ( AsmToken :: Integer ) ) { SMLoc Loc = getLexer ( ) . getTok ( ) . getEndLoc ( ) ; Token = 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> ) ; const <STR_LIT> * DimInfo = <STR_LIT> ( DimId ) ; if ( ! DimInfo ) return MatchOperand_ParseFail ;


<s> if ( getParser ( ) . parseIdentifier ( Name ) ) return TokError ( <STR_LIT> ) ; MCSymbol * Symbol = getContext ( ) . getOrCreateSymbol ( Name ) ; if ( parseToken ( AsmToken :: Comma , <STR_LIT> ) ) return true ; unsigned LocalMemorySize = <STR_LIT> :: getLocalMemorySize ( & getSTI ( ) ) ; int64_t Size ; SMLoc SizeLoc = getLexer ( ) . getLoc ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( Size ) ) return true ; if ( Size < <NUM_LIT> ) return Error ( SizeLoc , <STR_LIT> ) ; if ( Size > LocalMemorySize ) return Error ( SizeLoc , <STR_LIT> ) ; int64_t Align = <NUM_LIT> ; if ( getLexer ( ) . is ( AsmToken :: Comma ) ) { Lex ( ) ; SMLoc AlignLoc = getLexer ( ) . getLoc ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( Align ) ) return true ; if ( Align < <NUM_LIT> || ! isPowerOf2_64 ( Align ) ) return Error ( AlignLoc , <STR_LIT> ) ; if ( Align >= <NUM_LIT> << <NUM_LIT> ) return Error ( AlignLoc , <STR_LIT> ) ; } if ( parseToken ( AsmToken :: EndOfStatement , <STR_LIT> ) ) return true ;


<s> Str = Str . drop_front ( <NUM_LIT> ) ; if ( Str == <STR_LIT> ) { Val = <NUM_LIT> ; return MatchOperand_Success ; } if ( Str . getAsInteger ( <NUM_LIT> , Val ) ) return MatchOperand_ParseFail ; if ( Val > <NUM_LIT> ) errorExpTgt ( ) ; 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> || ( Val == <NUM_LIT> && ! isGFX10 ( ) ) ) errorExpTgt ( ) ; Val += <NUM_LIT> ; return MatchOperand_Success ; } if ( isGFX10 ( ) && Str == <STR_LIT> ) { Val = <NUM_LIT> ; 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> ) errorExpTgt ( ) ; Val += <NUM_LIT> ; return MatchOperand_Success ; } if ( Str . startswith ( <STR_LIT> ) ) {


<s> if ( Str == <STR_LIT> ) { Val = <NUM_LIT> ; return MatchOperand_Success ; } if ( Str . startswith ( <STR_LIT> ) ) { Str = Str . drop_front ( <NUM_LIT> ) ; if ( Str == <STR_LIT> ) { Val = <NUM_LIT> ; return MatchOperand_Success ; } if ( Str . getAsInteger ( <NUM_LIT> , Val ) ) return MatchOperand_ParseFail ; if ( Val > <NUM_LIT> ) errorExpTgt ( ) ; 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> || ( Val == <NUM_LIT> && ! isGFX10 ( ) ) ) errorExpTgt ( ) ; Val += <NUM_LIT> ; return MatchOperand_Success ; } if ( isGFX10 ( ) && Str == <STR_LIT> ) { Val = <NUM_LIT> ; 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> ) errorExpTgt ( ) ; Val += <NUM_LIT> ; return MatchOperand_Success ; } if ( Str . startswith ( <STR_LIT> ) ) { Str = Str . drop_front ( <NUM_LIT> ) ; if ( Str . getAsInteger ( <NUM_LIT> , Val ) ) return MatchOperand_ParseFail ;


<s> return OFF ; } int64_t Imm = <NUM_LIT> ; while ( true ) { unsigned Mode = <NUM_LIT> ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; for ( unsigned ModeId = ID_MIN ; ModeId <= ID_MAX ; ++ ModeId ) { if ( trySkipId ( IdSymbolic [ ModeId ] ) ) { Mode = <NUM_LIT> << ModeId ; break ; } } if ( Mode == <NUM_LIT> ) { Error ( S , ( Imm == <NUM_LIT> ) ? <STR_LIT> : <STR_LIT> ) ; break ; } if ( Imm & Mode ) { Error ( S , <STR_LIT> ) ; break ; } Imm |= Mode ; if ( trySkipToken ( AsmToken :: RParen ) ) break ; if ( ! skipToken ( AsmToken :: Comma , <STR_LIT> ) ) break ; }


<s> SMLoc S = Parser . getTok ( ) . getLoc ( ) ; if ( getLexer ( ) . getKind ( ) == AsmToken :: Identifier && Parser . getTok ( ) . getString ( ) == <STR_LIT> && getLexer ( ) . peekTok ( ) . is ( AsmToken :: LParen ) ) { Parser . Lex ( ) ; Parser . Lex ( ) ; Imm = parseGPRIdxMacro ( ) ; } else { if ( getParser ( ) . parseAbsoluteExpression ( Imm ) ) return MatchOperand_NoMatch ; if ( Imm < <NUM_LIT> || ! isUInt < <NUM_LIT> > ( Imm ) ) { Error ( S , <STR_LIT> ) ;


<s> 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> ) ; }

Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , ImmVal , Loc , <ISA_LIT>Operand :: ImmTyHwreg ) ) ;


<s> bool Negate = false ; if ( ! IsReal && Tok . is ( AsmToken :: Minus ) && NextTok . is ( AsmToken :: Real ) ) { lex ( ) ; IsReal = true ; Negate = true ; } if ( IsReal ) { StringRef Num = getTokenStr ( ) ; lex ( ) ; APFloat RealVal ( APFloat :: IEEEdouble ( ) ) ; auto roundMode = APFloat :: rmNearestTiesToEven ; if ( errorToBool ( RealVal . convertFromString ( Num , roundMode ) . takeError ( ) ) ) { return MatchOperand_ParseFail ; } if ( Negate ) RealVal . changeSign ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , RealVal . bitcastToAPInt ( ) . getZExtValue ( ) , S , <ISA_LIT>Operand :: ImmTyNone , true ) ) ; return MatchOperand_Success ; } else { int64_t IntVal ; const MCExpr * Expr ; SMLoc S = getLoc ( ) ; if ( HasSP3AbsModifier ) { SMLoc EndLoc ; if ( getParser ( ) . parsePrimaryExpr ( Expr , EndLoc ) ) return MatchOperand_ParseFail ; } else { if ( Parser . parseExpression ( Expr ) ) return MatchOperand_ParseFail ; } if ( Expr -> evaluateAsAbsolute ( IntVal ) ) { Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , IntVal , S ) ) ;


<s> auto roundMode = APFloat :: rmNearestTiesToEven ; if ( errorToBool ( RealVal . convertFromString ( Num , roundMode ) . takeError ( ) ) ) { return MatchOperand_ParseFail ; } if ( Negate ) RealVal . changeSign ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , RealVal . bitcastToAPInt ( ) . getZExtValue ( ) , S , <ISA_LIT>Operand :: ImmTyNone , true ) ) ; return MatchOperand_Success ; } else { int64_t IntVal ; const MCExpr * Expr ; SMLoc S = getLoc ( ) ; if ( HasSP3AbsModifier ) { SMLoc EndLoc ; if ( getParser ( ) . parsePrimaryExpr ( Expr , EndLoc ) ) return MatchOperand_ParseFail ; } else {

if ( Parser . parseExpression ( Expr ) ) return MatchOperand_ParseFail ;


<s> while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { OperandMode Mode = OperandMode_Default ; if ( IsMIMG && isGFX10 ( ) && Operands . size ( ) == <NUM_LIT> ) Mode = OperandMode_NSA ; OperandMatchResultTy Res = parseOperand ( Operands , Name , Mode ) ; if ( getLexer ( ) . is ( AsmToken :: Comma ) ) Parser . Lex ( ) ; switch ( Res ) { case MatchOperand_Success : break ; case MatchOperand_ParseFail : Error ( getLexer ( ) . getLoc ( ) , <STR_LIT> ) ; while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { Parser . Lex ( ) ; } return true ; case MatchOperand_NoMatch : Error ( getLexer ( ) . getLoc ( ) , <STR_LIT> ) ; while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { Parser . Lex ( ) ; } return true ; } }


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseInterpAttr ( OperandVector & Operands ) { if ( getLexer ( ) . getKind ( ) != AsmToken :: Identifier ) return MatchOperand_NoMatch ; StringRef Str = Parser . getTok ( ) . getString ( ) ; if ( ! Str . startswith ( <STR_LIT> ) ) return MatchOperand_NoMatch ; StringRef Chan = Str . take_back ( <NUM_LIT> ) ; int AttrChan = StringSwitch < int > ( Chan ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Default ( - <NUM_LIT> ) ; if ( AttrChan == - <NUM_LIT> ) return MatchOperand_ParseFail ; Str = Str . drop_back ( <NUM_LIT> ) . drop_front ( <NUM_LIT> ) ; uint8_t Attr ; if ( Str . getAsInteger ( <NUM_LIT> , Attr ) ) return MatchOperand_ParseFail ;

SMLoc S = Parser . getTok ( ) . getLoc ( ) ;


<s> if ( Tok == <STR_LIT> && ! isGFX9 ( ) && ! isGFX10 ( ) ) 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> if ( getLexer ( ) . isNot ( AsmToken :: EndOfStatement ) ) { 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 ( ) && ! isGFX10 ( ) ) 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 ;


<s> 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 :: ImmTyFORMAT && ! isGFX10 ( ) ) {


<s> 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 ) ) { Error ( StartLoc , <STR_LIT> ) ; return nullptr ; } if ( <STR_LIT> :: hasCodeObjectV3 ( & getSTI ( ) ) ) {

if ( ! updateGprCountSymbols ( RegKind , RegNum , RegWidth ) ) return nullptr ;


<s> if ( ! Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth ) ) { Error ( StartLoc , <STR_LIT> ) ; return nullptr ; } if ( <STR_LIT> :: hasCodeObjectV3 ( & 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 ( NextRegWidth != <NUM_LIT> ) return <STR_LIT> ; if ( NextRegKind != RegKind ) return <STR_LIT> ; if ( ! AddNextRegisterToList ( Reg , RegWidth , RegKind , NextReg ) ) return <STR_LIT> ; } if ( ! trySkipToken ( AsmToken :: RBrac ) ) return <STR_LIT> ; if ( isRegularReg ( RegKind ) ) Reg = getRegularReg ( RegKind , RegNum , RegWidth ) ; return Reg ;


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

if ( NextRegWidth != <NUM_LIT> ) return <STR_LIT> ;


<s> if ( ! parseExpr ( RegLo ) ) return false ; if ( trySkipToken ( AsmToken :: Colon ) ) { if ( ! parseExpr ( RegHi ) ) return false ; } else { RegHi = RegLo ; } if ( ! trySkipToken ( AsmToken :: RBrac ) ) return false ; if ( ! isUInt < <NUM_LIT> > ( RegLo ) || ! isUInt < <NUM_LIT> > ( RegHi ) || RegLo > RegHi ) return false ; Num = static_cast < unsigned > ( RegLo ) ;


<s> assert ( isToken ( AsmToken :: Identifier ) ) ; StringRef RegName = getTokenStr ( ) ; const RegInfo * RI = getRegularRegInfo ( RegName ) ; if ( ! RI ) return <STR_LIT> ; lex ( ) ; RegKind = RI -> Kind ; StringRef RegSuffix = RegName . substr ( RI -> Name . size ( ) ) ; if ( ! RegSuffix . empty ( ) ) { if ( ! getRegNum ( RegSuffix , RegNum ) ) return <STR_LIT> ; RegWidth = <NUM_LIT> ; } else {

if ( ! ParseRegRange ( RegNum , RegWidth ) ) return <STR_LIT> ;


<s> StringRef RegName = getTokenStr ( ) ; const RegInfo * RI = getRegularRegInfo ( RegName ) ; if ( ! RI ) return <STR_LIT> ; lex ( ) ; RegKind = RI -> Kind ; StringRef RegSuffix = RegName . substr ( RI -> Name . size ( ) ) ; if ( ! RegSuffix . empty ( ) ) { if ( ! getRegNum ( RegSuffix , RegNum ) ) return <STR_LIT> ; RegWidth = <NUM_LIT> ; } else { if ( ! ParseRegRange ( RegNum , RegWidth ) ) return <STR_LIT> ; }

return getRegularReg ( RegKind , RegNum , RegWidth ) ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseSendMsgOp ( OperandVector & Operands ) { using namespace llvm :: <STR_LIT> ; int64_t ImmVal = <NUM_LIT> ; SMLoc Loc = getLoc ( ) ; if ( trySkipId ( <STR_LIT> , AsmToken :: LParen ) ) { OperandInfoTy Msg ( ID_UNKNOWN_ ) ; OperandInfoTy Op ( OP_NONE_ ) ; OperandInfoTy Stream ( STREAM_ID_NONE_ ) ; if ( parseSendMsgBody ( Msg , Op , Stream ) && validateSendMsg ( Msg , Op , Stream , Loc ) ) { ImmVal = encodeMsg ( Msg . Id , Op . Id , Stream . Id ) ; } } else if ( parseExpr ( ImmVal ) ) { if ( ImmVal < <NUM_LIT> || ! isUInt < <NUM_LIT> > ( ImmVal ) ) Error ( Loc , <STR_LIT> ) ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , ImmVal , Loc , <ISA_LIT>Operand :: ImmTySendMsg ) ) ; return MatchOperand_Success ;


<s> unsigned <ISA_LIT>AsmParser :: ParseSpecialReg ( RegisterKind & RegKind , unsigned & RegNum , unsigned & RegWidth ) { assert ( isToken ( AsmToken :: Identifier ) ) ; unsigned Reg = getSpecialRegForName ( getTokenStr ( ) ) ; if ( Reg ) {


<s> if ( isToken ( AsmToken :: Identifier ) && peekToken ( ) . is ( AsmToken :: LParen ) ) { while ( parseCnt ( Waitcnt ) && ! isToken ( AsmToken :: EndOfStatement ) ) ; } else {


<s> AsmToken <ISA_LIT>AsmParser :: peekToken ( ) { return getLexer ( ) . peekTok ( ) ;


<s> 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 ImmTyBLGP : OS << <STR_LIT> ; break ; case ImmTyCBSZ : OS << <STR_LIT> ; break ; case ImmTyABID : OS << <STR_LIT> ; break ;

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


<s> for ( MCRegAliasIterator R ( <STR_LIT> , & MRI , true ) ; R . isValid ( ) ; ++ R ) { if ( * R == RegNo ) return isGFX9 ( ) || isGFX10 ( ) ; } for ( MCRegAliasIterator R ( <STR_LIT> , & MRI , true ) ; R . isValid ( ) ; ++ R ) { if ( * R == RegNo ) return hasSGPR104_SGPR105 ( ) ; } switch ( RegNo ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return ! isCI ( ) && ! is<ISA_LIT> ( ) && ! isVI ( ) ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return ! isGFX9 ( ) && ! isGFX10 ( ) ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return ! isCI ( ) && ! is<ISA_LIT> ( ) && ! isGFX10 ( ) && hasXNACK ( ) ; case <STR_LIT> : return isGFX10 ( ) ; default : break ; } if ( isCI ( ) ) return true ; if ( is<ISA_LIT> ( ) || isGFX10 ( ) ) { switch ( RegNo ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return false ; default : return true ; } }


<s> 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> ) ; if ( ! IsNSA ) { if ( AddrSize > <NUM_LIT> ) AddrSize = <NUM_LIT> ; else if ( AddrSize > <NUM_LIT> ) AddrSize = <NUM_LIT> ;


<s> 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 ( DimIdx != - <NUM_LIT> ) ; assert ( SrsrcIdx > VAddr0Idx ) ; 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> ) ; if ( ! IsNSA ) { if ( AddrSize > <NUM_LIT> ) AddrSize = <NUM_LIT> ;

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


<s> if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; 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> ) ; assert ( DMaskIdx != - <NUM_LIT> ) ; assert ( TFEIdx != - <NUM_LIT> ) ; unsigned VDataSize = <STR_LIT> ( getMRI ( ) , Desc , VDataIdx ) ;

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


<s> case MCK_gds : return Operand . isGDS ( ) ? Match_Success : Match_InvalidOperand ; case MCK_lds : return Operand . isLDS ( ) ? Match_Success : Match_InvalidOperand ; 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 ; case MCK_SSrcB32 : return Operand . isSSrcB32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SSrcF32 : return Operand . isSSrcF32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SoppBrTarget : return Operand . isSoppBrTarget ( ) ? Match_Success : Match_InvalidOperand ; case MCK_VReg32OrOff : return Operand . isVReg32OrOff ( ) ? Match_Success : Match_InvalidOperand ;


<s> 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> : { bool lost ; APFloat FPLiteral ( APFloat :: IEEEdouble ( ) , Literal ) ; FPLiteral . convert ( * getOpFltSemantics ( OpTy ) , APFloat :: rmNearestTiesToEven , & lost ) ; uint64_t ImmVal = FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ; if ( OpTy == <STR_LIT> || OpTy == <STR_LIT> ) { ImmVal |= ( ImmVal << <NUM_LIT> ) ; } 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> : { if ( isInt < <NUM_LIT> > ( Val ) && <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 ( isInt < <NUM_LIT> > ( Val ) && <STR_LIT> ( static_cast < int16_t > ( Val ) , AsmParser -> hasInv2PiInlineImm ( ) ) ) { Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; return ; } Inst . addOperand ( MCOperand :: createImm ( Val & <NUM_LIT> ) ) ; return ; } case <STR_LIT> :


<s> bool <ISA_LIT>AsmParser :: AddNextRegisterToList ( unsigned & Reg , unsigned & RegWidth , RegisterKind RegKind , unsigned Reg1 , unsigned RegNum ) { switch ( RegKind ) { case IS_SPECIAL : if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; }


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


<s> if ( ( getForcedEncodingSize ( ) == <NUM_LIT> && ( TSFlags & <STR_LIT> ) ) || ( getForcedEncodingSize ( ) == <NUM_LIT> && ! ( TSFlags & <STR_LIT> ) ) || ( isForcedDPP ( ) && ! ( TSFlags & <STR_LIT> ) ) || ( isForcedSDWA ( ) && ! ( TSFlags & <STR_LIT> ) ) ) return Match_InvalidOperand ; if ( ( TSFlags & <STR_LIT> ) && ( TSFlags & <STR_LIT> ) && getForcedEncodingSize ( ) != <NUM_LIT> ) return Match_PreferE32 ; if ( Inst . getOpcode ( ) == <STR_LIT> || Inst . getOpcode ( ) == <STR_LIT> ) { auto OpNum = <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: dst_sel ) ; const auto & Op = Inst . getOperand ( OpNum ) ; if ( ! Op . isImm ( ) || Op . getImm ( ) != <STR_LIT> :: SdwaSel :: DWORD ) { return Match_InvalidOperand ; } } if ( ( TSFlags & <STR_LIT> ) && ! hasFlatOffsets ( ) ) { auto OpNum = <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: offset ) ; const auto & Op = Inst . getOperand ( OpNum ) ; if ( Op . getImm ( ) != <NUM_LIT> ) return Match_InvalidOperand ; } return Match_Success ;


<s> uint64_t TSFlags = MII . get ( Inst . getOpcode ( ) ) . TSFlags ; if ( ( getForcedEncodingSize ( ) == <NUM_LIT> && ( TSFlags & <STR_LIT> ) ) || ( getForcedEncodingSize ( ) == <NUM_LIT> && ! ( TSFlags & <STR_LIT> ) ) || ( isForcedDPP ( ) && ! ( TSFlags & <STR_LIT> ) ) || ( isForcedSDWA ( ) && ! ( TSFlags & <STR_LIT> ) ) ) return Match_InvalidOperand ; if ( ( TSFlags & <STR_LIT> ) && ( TSFlags & <STR_LIT> ) && getForcedEncodingSize ( ) != <NUM_LIT> ) return Match_PreferE32 ; if ( Inst . getOpcode ( ) == <STR_LIT> || Inst . getOpcode ( ) == <STR_LIT> ) {

auto OpNum = <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: dst_sel ) ;


<s> static <ISA_LIT>Operand :: Ptr CreateExpr ( const <ISA_LIT>AsmParser * AsmParser , const class MCExpr * Expr , SMLoc S ) { auto Op = llvm :: make_unique < <ISA_LIT>Operand > ( Expression , AsmParser ) ; Op -> Expr = Expr ; Op -> StartLoc = S ; Op -> EndLoc = S ;


<s> Op -> Reg . RegNo = RegNo ; Op -> Reg . Mods = Modifiers ( ) ; Op -> Reg . IsForcedVOP3 = ForceVOP3 ; Op -> StartLoc = S ; Op -> EndLoc = E ; return Op ;


<s> Res -> Tok . Length = Str . size ( ) ; Res -> StartLoc = Loc ; Res -> EndLoc = Loc ; return Res ;


<s> } 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> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppBankMask , <NUM_LIT> ) ;

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


<s> if ( Op . isReg ( ) ) { Op . addRegOperands ( Inst , <NUM_LIT> ) ; continue ; } if ( Op . isToken ( ) && Op . getToken ( ) == <STR_LIT> ) { IsGdsHardcoded = true ; continue ; } OptionalIdx [ Op . getImmTy ( ) ] = i ; } <ISA_LIT>Operand :: ImmTy OffsetType = ( Inst . getOpcode ( ) == <STR_LIT> || Inst . getOpcode ( ) == <STR_LIT> ) ? <ISA_LIT>Operand :: ImmTySwizzle : <ISA_LIT>Operand :: ImmTyOffset ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , OffsetType ) ; if ( ! IsGdsHardcoded ) { addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyGDS ) ; }

Inst . addOperand ( MCOperand :: createReg ( <STR_LIT> ) ) ;


<s> } } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDMask ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyUNorm ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyGLC ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDA ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyR128 ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyTFE ) ;

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


<s> } ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) . addRegOperands ( Inst , <NUM_LIT> ) ; OptionalImmIndexMap OptionalIdx ; for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isRegOrImm ( ) ) { Op . addRegOrImmOperands ( Inst , <NUM_LIT> ) ; continue ; } else if ( Op . isImmModifier ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { llvm_unreachable ( <STR_LIT> ) ; } } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDMask ) ;

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


<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> ) ; } ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) . addRegOperands ( Inst , <NUM_LIT> ) ; OptionalImmIndexMap OptionalIdx ; for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isRegOrImm ( ) ) { Op . addRegOrImmOperands ( Inst , <NUM_LIT> ) ; continue ; } else if ( Op . isImmModifier ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { llvm_unreachable ( <STR_LIT> ) ; } } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDMask ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyUNorm ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyGLC ) ;

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


<s> cvtSDWA ( Inst , Operands , <STR_LIT> , true ) ;


<s> addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> ) ;

if ( Inst . getOpcode ( ) == <STR_LIT> || Inst . getOpcode ( ) == <STR_LIT> || Inst . getOpcode ( ) == <STR_LIT> ) {


<s> void <ISA_LIT>AsmParser :: cvtVOP3 ( MCInst & Inst , const OperandVector & Operands ) { OptionalImmIndexMap OptionalIdx ; cvtVOP3Impl ( Inst , Operands , OptionalIdx ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> ) ;

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


<s> 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 if ( Op . isRegOrImm ( ) ) { Op . addRegOrImmOperands ( Inst , <NUM_LIT> ) ;


<s> } 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 ( ) ) {


<s> } for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isMod ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ;


<s> addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyOpSel ) ; addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyOpSelHi , - <NUM_LIT> ) ; int NegLoIdx = <STR_LIT> ( Opc , <STR_LIT> :: neg_lo ) ; if ( NegLoIdx != - <NUM_LIT> ) { addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyNegLo ) ; addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyNegHi ) ; } 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> ;


<s> cvtVOP3Impl ( Inst , Operands , OptIdx ) ; int Opc = Inst . getOpcode ( ) ; if ( <STR_LIT> ( Opc , <STR_LIT> :: clamp ) != - <NUM_LIT> ) { addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> ) ; } addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyOpSel ) ; addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyOpSelHi , - <NUM_LIT> ) ; int NegLoIdx = <STR_LIT> ( Opc , <STR_LIT> :: neg_lo ) ; if ( NegLoIdx != - <NUM_LIT> ) { addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyNegLo ) ; addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyNegHi ) ; } 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 ) { int OpIdx = <STR_LIT> ( Opc , Ops [ J ] ) ; if ( OpIdx == - <NUM_LIT> ) break ;


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


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

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


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


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


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

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


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


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


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


<s> const unsigned Num = Desc . getNumImplicitUses ( ) ; for ( unsigned i = <NUM_LIT> ; i < Num ; ++ i ) { unsigned Reg = Desc . ImplicitUses [ i ] ; switch ( Reg ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return Reg ; default : break ; } }


<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> bool <ISA_LIT>Operand :: isGPRIdxMode ( ) const { return isImm ( ) && isUInt < <NUM_LIT> > ( getImm ( ) ) ;


<s> if ( ! isImmTy ( ImmTyNone ) ) { return false ; } APInt Literal ( <NUM_LIT> , Imm . Val ) ; if ( Imm . IsFPImm ) { if ( type == <STR_LIT> || type == <STR_LIT> ) { return <STR_LIT> ( Imm . Val , AsmParser -> hasInv2PiInlineImm ( ) ) ; } APFloat FPLiteral ( APFloat :: IEEEdouble ( ) , APInt ( <NUM_LIT> , Imm . Val ) ) ; if ( ! canLosslesslyConvertToFPType ( FPLiteral , type ) ) return false ; if ( type . getScalarSizeInBits ( ) == <NUM_LIT> ) { return <STR_LIT> ( static_cast < int16_t > ( FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ; } return <STR_LIT> ( static_cast < int32_t > ( FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ; } if ( type == <STR_LIT> || type == <STR_LIT> ) { return <STR_LIT> ( Imm . Val , AsmParser -> hasInv2PiInlineImm ( ) ) ; } if ( type . getScalarSizeInBits ( ) == <NUM_LIT> ) { return <STR_LIT> ( static_cast < int16_t > ( Literal . getLoBits ( <NUM_LIT> ) . getSExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ; }

return <STR_LIT> ( static_cast < int32_t > ( Literal . getLoBits ( <NUM_LIT> ) . getZExtValue ( ) ) , AsmParser -> hasInv2PiInlineImm ( ) ) ;


<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> : return <STR_LIT> ( Val , hasInv2PiInlineImm ( ) ) ; case <NUM_LIT> : { const unsigned OperandType = Desc . OpInfo [ OpIdx ] . OperandType ; if ( OperandType == <STR_LIT> || OperandType == <STR_LIT> ) { return <STR_LIT> ( Val , hasInv2PiInlineImm ( ) ) ; } else { return <STR_LIT> ( Val , hasInv2PiInlineImm ( ) ) ; } } default : llvm_unreachable ( <STR_LIT> ) ; }


<s> if ( ! <STR_LIT> ( Desc , OpIdx ) ) { return false ; } 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> : return <STR_LIT> ( Val , hasInv2PiInlineImm ( ) ) ; case <NUM_LIT> : { const unsigned OperandType = Desc . OpInfo [ OpIdx ] . OperandType ; if ( OperandType == <STR_LIT> || OperandType == <STR_LIT> ) { return <STR_LIT> ( Val , hasInv2PiInlineImm ( ) ) ; } else { return <STR_LIT> ( Val , hasInv2PiInlineImm ( ) ) ; } } default : llvm_unreachable ( <STR_LIT> ) ;


<s> return isImmTy ( ImmTyOffset ) && isInt < <NUM_LIT> > ( getImm ( ) ) ;


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


<s> bool isRegOrImmWithFP16InputMods ( ) const { return isRegOrImmWithInputMods ( <STR_LIT> ) ;


<s> bool isRegOrImmWithFP32InputMods ( ) const { return isRegOrImmWithInputMods ( <STR_LIT> ) ;


<s> bool isRegOrImmWithFP64InputMods ( ) const {

return isRegOrImmWithInputMods ( <STR_LIT> ) ;


<s> bool isRegOrImmWithFP64InputMods ( ) const { return isRegOrImmWithInputMods ( <STR_LIT> ) ;


<s> return isRegKind ( ) || isInlinableImm ( type ) ;


<s> return isRegOrImmWithInputMods ( <STR_LIT> ) ;


<s> bool isRegOrImmWithInt32InputMods ( ) const { return isRegOrImmWithInputMods ( <STR_LIT> ) ;


<s> return isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) ;


<s> bool isVReg ( ) const { return isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) || isRegClass ( <STR_LIT> ) ;


<s> bool isVReg32OrOff ( ) const { return isOff ( ) || isRegClass ( <STR_LIT> ) ;


<s> bool isVSrcF32 ( ) const { return isVCSrcF32 ( ) || isLiteralImm ( <STR_LIT> ) ;


<s> bool isVSrcV2F16 ( ) const { llvm_unreachable ( <STR_LIT> ) ;


<s> void LLVMInitialize<ISA_LIT>AsmParser ( ) {

RegisterMCAsmParser < <ISA_LIT>AsmParser > A ( getThe<ISA_LIT>Target ( ) ) ;


<s> if ( AbsMod && getLexer ( ) . peekTok ( ) . is ( AsmToken :: Pipe ) && ( getLexer ( ) . getKind ( ) == AsmToken :: Integer || getLexer ( ) . getKind ( ) == AsmToken :: Real ) ) { SMLoc EndLoc ; const MCExpr * Expr ; if ( getParser ( ) . parsePrimaryExpr ( Expr , EndLoc ) ) { return true ;


<s> if ( getLexer ( ) . isNot ( AsmToken :: LParen ) ) return true ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return true ; SMLoc ValLoc = Parser . getTok ( ) . getLoc ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( CntVal ) ) return true ; <STR_LIT> :: IsaVersion ISA = <STR_LIT> :: getIsaVersion ( getFeatureBits ( ) ) ; bool Failed = true ; bool Sat = CntName . endswith ( <STR_LIT> ) ; if ( CntName == <STR_LIT> || CntName == <STR_LIT> ) { Failed = encodeCnt ( ISA , IntVal , CntVal , Sat , encodeVmcnt , decodeVmcnt ) ; } else if ( CntName == <STR_LIT> || CntName == <STR_LIT> ) {

Failed = encodeCnt ( ISA , IntVal , CntVal , Sat , encodeExpcnt , decodeExpcnt ) ;


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


<s> bool <ISA_LIT>AsmParser :: ParseDirective ( AsmToken DirectiveID ) { StringRef IDVal = DirectiveID . getString ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirectiveHSACodeObjectVersion ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirectiveHSACodeObjectISA ( ) ; if ( IDVal == <STR_LIT> :: MetadataAssemblerDirectiveBegin ) return ParseDirectiveCodeObjectMetadata ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirectiveAMDKernelCodeT ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirective<ISA_LIT>HsaKernel ( ) ; return true ;


<s> bool <ISA_LIT>AsmParser :: ParseDirective<ISA_LIT>HsaKernel ( ) { if ( getLexer ( ) . isNot ( AsmToken :: Identifier ) ) return TokError ( <STR_LIT> ) ;

StringRef KernelName = Parser . getTok ( ) . getString ( ) ;


<s> amd_kernel_code_t Header ; <STR_LIT> ( Header , getFeatureBits ( ) ) ; while ( true ) { while ( getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Identifier ) ) return TokError ( <STR_LIT> ) ; StringRef ID = getLexer ( ) . getTok ( ) . getIdentifier ( ) ;


<s> YamlStream << getLexer ( ) . getTok ( ) . getString ( ) ; Lex ( ) ; } if ( getLexer ( ) . is ( AsmToken :: Identifier ) ) { StringRef ID = getLexer ( ) . getTok ( ) . getIdentifier ( ) ; if ( ID == <STR_LIT> :: MetadataAssemblerDirectiveEnd ) { Lex ( ) ; FoundEnd = true ; break ; } }

YamlStream << Parser . parseStringToEndOfStatement ( ) << getContext ( ) . getAsmInfo ( ) -> getSeparatorString ( ) ;


<s> <STR_LIT> :: IsaVersion ISA = <STR_LIT> :: getIsaVersion ( getFeatureBits ( ) ) ; 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 ( ) ;


<s> } 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> ) ;


<s> } else { Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( Int ) ) return MatchOperand_ParseFail ; if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = <NUM_LIT> ; } else if ( Prefix == <STR_LIT> ) { if ( Int == <NUM_LIT> ) { Int = <NUM_LIT> ; } else if ( Int == <NUM_LIT> ) { Int = <NUM_LIT> ; } else { return MatchOperand_ParseFail ; } } else { return MatchOperand_ParseFail ; } } } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Int , S , <ISA_LIT>Operand :: ImmTyDppCtrl ) ) ; return MatchOperand_Success ;


<s> Parser . Lex ( ) ; int64_t Temp ; if ( getParser ( ) . parseAbsoluteExpression ( Temp ) || ! ( <NUM_LIT> <= Temp && Temp <= <NUM_LIT> ) ) return MatchOperand_ParseFail ; const int shift = i * <NUM_LIT> + <NUM_LIT> ; Int += ( Temp << shift ) ; } if ( getLexer ( ) . isNot ( AsmToken :: RBrac ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; } else { Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( Int ) ) return MatchOperand_ParseFail ; if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = <NUM_LIT> ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = <NUM_LIT> ;


<s> if ( Val > <NUM_LIT> ) errorExpTgt ( ) ; 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> ) errorExpTgt ( ) ; Val += <NUM_LIT> ; 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> ) errorExpTgt ( ) ; Val += <NUM_LIT> ; return MatchOperand_Success ;


<s> if ( HwReg . Id < <NUM_LIT> || ! isUInt < ID_WIDTH_ > ( HwReg . Id ) ) { if ( HwReg . IsSymbolic ) Error ( S , <STR_LIT> ) ; else Error ( S , <STR_LIT> ) ; } if ( Offset < <NUM_LIT> || ! isUInt < OFFSET_WIDTH_ > ( Offset ) ) Error ( S , <STR_LIT> ) ;

if ( ( Width - <NUM_LIT> ) < <NUM_LIT> || ! isUInt < WIDTH_M1_WIDTH_ > ( Width - <NUM_LIT> ) ) Error ( S , <STR_LIT> ) ;


<s> int64_t Width = WIDTH_M1_DEFAULT_ + <NUM_LIT> ; if ( parseHwregConstruct ( HwReg , Offset , Width ) ) return MatchOperand_ParseFail ; if ( HwReg . Id < <NUM_LIT> || ! isUInt < ID_WIDTH_ > ( HwReg . Id ) ) { if ( HwReg . IsSymbolic ) Error ( S , <STR_LIT> ) ; else Error ( S , <STR_LIT> ) ; } if ( Offset < <NUM_LIT> || ! isUInt < OFFSET_WIDTH_ > ( Offset ) ) Error ( S , <STR_LIT> ) ; if ( ( Width - <NUM_LIT> ) < <NUM_LIT> || ! isUInt < WIDTH_M1_WIDTH_ > ( Width - <NUM_LIT> ) ) Error ( S , <STR_LIT> ) ; Imm16Val = ( HwReg . Id << ID_SHIFT_ ) | ( Offset << OFFSET_SHIFT_ ) | ( ( Width - <NUM_LIT> ) << WIDTH_M1_SHIFT_ ) ; } break ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Imm16Val , S , <ISA_LIT>Operand :: ImmTyHwreg ) ) ; return MatchOperand_Success ;


<s> bool Minus = false ; if ( getLexer ( ) . getKind ( ) == AsmToken :: Minus ) { Minus = true ; Parser . Lex ( ) ; } SMLoc S = Parser . getTok ( ) . getLoc ( ) ; switch ( getLexer ( ) . getKind ( ) ) { case AsmToken :: Integer : {


<s> bool <ISA_LIT>AsmParser :: ParseInstruction ( ParseInstructionInfo & Info , StringRef Name , SMLoc NameLoc , OperandVector & Operands ) { Name = parseMnemonicSuffix ( Name ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateToken ( this , Name , NameLoc ) ) ; while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { OperandMatchResultTy Res = parseOperand ( Operands , Name ) ; if ( getLexer ( ) . is ( AsmToken :: Comma ) ) Parser . Lex ( ) ; switch ( Res ) {


<s> if ( getLexer ( ) . is ( AsmToken :: Comma ) ) Parser . Lex ( ) ; switch ( Res ) { case MatchOperand_Success : break ; case MatchOperand_ParseFail : Error ( getLexer ( ) . getLoc ( ) , <STR_LIT> ) ; while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { Parser . Lex ( ) ; } return true ; case MatchOperand_NoMatch : Error ( getLexer ( ) . getLoc ( ) , <STR_LIT> ) ; while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { Parser . Lex ( ) ; } return true ; }


<s> OperandMatchResultTy Res = parseIntWithPrefix ( Prefix , Value ) ; if ( Res != MatchOperand_Success ) return Res ; if ( ConvertResult && ! ConvertResult ( Value ) ) {


<s> int64_t Bit = <NUM_LIT> ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: EndOfStatement ) ) { switch ( getLexer ( ) . getKind ( ) ) { case AsmToken :: Identifier : { StringRef Tok = Parser . getTok ( ) . getString ( ) ; if ( Tok == Name ) { Bit = <NUM_LIT> ; Parser . Lex ( ) ; } else if ( Tok . startswith ( <STR_LIT> ) && Tok . endswith ( Name ) ) { Bit = <NUM_LIT> ; Parser . Lex ( ) ; } else { return MatchOperand_NoMatch ; } break ;


<s> ResTy = parseRegOrImm ( Operands ) ; if ( ResTy == MatchOperand_Success ) return ResTy ; if ( getLexer ( ) . getKind ( ) == AsmToken :: Identifier ) { const auto & Tok = Parser . getTok ( ) ; SMLoc S = Tok . getLoc ( ) ; const MCExpr * Expr = nullptr ; if ( ! Parser . parseExpression ( Expr ) ) { Operands . push_back ( <ISA_LIT>Operand :: CreateExpr ( this , Expr , S ) ) ; return MatchOperand_Success ; } Operands . push_back ( <ISA_LIT>Operand :: CreateToken ( this , Tok . getString ( ) , Tok . getLoc ( ) ) ) ; Parser . Lex ( ) ; return MatchOperand_Success ;


<s> if ( ! Name . equals ( Prefix ) ) return MatchOperand_NoMatch ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Colon ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: LBrac ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; unsigned Val = <NUM_LIT> ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; for ( int I = <NUM_LIT> ; I < <NUM_LIT> ; ++ I ) { if ( I != <NUM_LIT> ) { if ( getLexer ( ) . is ( AsmToken :: RBrac ) ) break ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; } if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return MatchOperand_ParseFail ; int64_t Op ; if ( getParser ( ) . parseAbsoluteExpression ( Op ) ) return MatchOperand_ParseFail ;

if ( Op != <NUM_LIT> && Op != <NUM_LIT> ) return MatchOperand_ParseFail ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseReg ( OperandVector & Operands ) { if ( auto R = parseRegister ( ) ) { assert ( R -> isReg ( ) ) ; R -> Reg . IsForcedVOP3 = isForcedVOP3 ( ) ;

Operands . push_back ( std :: move ( R ) ) ;


<s> assert ( R -> isReg ( ) ) ; R -> Reg . IsForcedVOP3 = isForcedVOP3 ( ) ; Operands . push_back ( std :: move ( R ) ) ; return MatchOperand_Success ; } return MatchOperand_NoMatch ;


<s> if ( ! Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth , & DwordRegIndex ) ) { return nullptr ; } KernelScope . usesRegister ( RegKind , DwordRegIndex , RegWidth ) ; return <ISA_LIT>Operand :: CreateReg ( this , Reg , StartLoc , EndLoc , false ) ;


<s> auto res = parseImm ( Operands , AbsMod ) ; if ( res != MatchOperand_NoMatch ) { return res ;


<s> break ; case AsmToken :: Identifier : { OperandInfoTy Msg ( ID_UNKNOWN_ ) ; OperandInfoTy Operation ( OP_UNKNOWN_ ) ; int64_t StreamId = STREAM_ID_DEFAULT_ ; if ( parseSendMsgConstruct ( Msg , Operation , StreamId ) ) return MatchOperand_ParseFail ; do { if ( ! ( ( ID_INTERRUPT <= Msg . Id && Msg . Id <= ID_GS_DONE ) || Msg . Id == ID_SYSMSG ) ) { if ( Msg . IsSymbolic ) Error ( S , <STR_LIT> ) ; else Error ( S , <STR_LIT> ) ; break ; } Imm16Val = ( Msg . Id << ID_SHIFT_ ) ; if ( Msg . Id == ID_GS || Msg . Id == ID_GS_DONE ) { if ( ! ( OP_GS_FIRST_ <= Operation . Id && Operation . Id < OP_GS_LAST_ ) ) { if ( Operation . IsSymbolic ) Error ( S , <STR_LIT> ) ; 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_ ) ; }


<s> } case AsmToken :: Identifier : Operands . push_back ( <ISA_LIT>Operand :: CreateExpr ( this , MCSymbolRefExpr :: create ( getContext ( ) . getOrCreateSymbol ( Parser . getTok ( ) . getString ( ) ) , getContext ( ) ) , S ) ) ; Parser . Lex ( ) ; return MatchOperand_Success ; }


<s> return MatchOperand_Success ; } case AsmToken :: Identifier : Operands . push_back ( <ISA_LIT>Operand :: CreateExpr ( this , MCSymbolRefExpr :: create ( getContext ( ) . getOrCreateSymbol ( Parser . getTok ( ) . getString ( ) ) , getContext ( ) ) , S ) ) ; Parser . Lex ( ) ; return MatchOperand_Success ;


<s> Val = Parser . getTok ( ) . getStringContents ( ) ; Parser . Lex ( ) ; return true ; } else {


<s> if ( trySkipId ( <STR_LIT> ) ) { Ok = parseSwizzleMacro ( Imm ) ; } else { Ok = parseSwizzleOffset ( Imm ) ; } }

Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Imm , S , <ISA_LIT>Operand :: ImmTySwizzle ) ) ;


<s> if ( parseSwizzleOperands ( LANE_NUM , Lane , <NUM_LIT> , LANE_MAX , <STR_LIT> ) ) { Imm = QUAD_PERM_ENC ; for ( auto i = <NUM_LIT> ; i < LANE_NUM ; ++ i ) { Imm |= Lane [ i ] << ( LANE_SHIFT * i ) ; }


<s> } const AsmToken & Tok = Parser . getTok ( ) ; if ( Tok . getString ( ) == <STR_LIT> ) { Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , <NUM_LIT> , Tok . getLoc ( ) , <ISA_LIT>Operand :: ImmTyOff , false ) ) ; Parser . Lex ( ) ; return MatchOperand_Success ; }


<s> 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 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 ImmTyUNorm : OS << <STR_LIT> ; break ; case ImmTyDA : OS << <STR_LIT> ; break ; case ImmTyR128 : 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 ;


<s> switch ( Type ) { case ImmTyNone : OS << <STR_LIT> ; break ; case ImmTyGDS : OS << <STR_LIT> ; break ; case ImmTyOffen : OS << <STR_LIT> ; break ; case ImmTyIdxen : OS << <STR_LIT> ; break ; case ImmTyAddr64 : OS << <STR_LIT> ; break ; 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 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 ImmTyUNorm : OS << <STR_LIT> ; break ; case ImmTyDA : OS << <STR_LIT> ; break ; case ImmTyR128 : 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 ;


<s> if ( ! trySkipToken ( Kind ) ) { Error ( Parser . getTok ( ) . getLoc ( ) , ErrMsg ) ; return false ; } return true ;


<s> if ( getLexer ( ) . getKind ( ) == AsmToken :: Identifier && Parser . getTok ( ) . getString ( ) == Id ) { Parser . Lex ( ) ; return true ; }


<s> if ( getLexer ( ) . getKind ( ) == Kind ) {


<s> bool <ISA_LIT>AsmParser :: usesConstantBus ( const MCInst & Inst , unsigned OpIdx ) { const MCOperand & MO = Inst . getOperand ( OpIdx ) ; if ( MO . isImm ( ) ) { return ! isInlineConstant ( Inst , OpIdx ) ; }

return ! MO . isReg ( ) || isSGPR ( mc2PseudoReg ( MO . getReg ( ) ) , getContext ( ) . getRegisterInfo ( ) ) ;


<s> if ( MO . isImm ( ) ) { return ! isInlineConstant ( Inst , OpIdx ) ; } return ! MO . isReg ( ) || isSGPR ( mc2PseudoReg ( MO . getReg ( ) ) , getContext ( ) . getRegisterInfo ( ) ) ;


<s> void usesRegister ( RegisterKind RegKind , unsigned DwordRegIndex , unsigned RegWidth ) { switch ( RegKind ) { case IS_SGPR : usesSgprAt ( DwordRegIndex + RegWidth - <NUM_LIT> ) ; break ;

case IS_VGPR : usesVgprAt ( DwordRegIndex + RegWidth - <NUM_LIT> ) ; break ;


<s> switch ( RegKind ) { case IS_SGPR : usesSgprAt ( DwordRegIndex + RegWidth - <NUM_LIT> ) ; break ;


<s> case MCK_offen : return Operand . isOffen ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SSrcB32 : return Operand . isSSrcB32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SSrcF32 : return Operand . isSSrcF32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SoppBrTarget : return Operand . isSoppBrTarget ( ) ? Match_Success : Match_InvalidOperand ; case MCK_VReg32OrOff : return Operand . isVReg32OrOff ( ) ? Match_Success : Match_InvalidOperand ; case MCK_InterpSlot : return Operand . isInterpSlot ( ) ? Match_Success : Match_InvalidOperand ; case MCK_Attr : return Operand . isInterpAttr ( ) ? Match_Success : Match_InvalidOperand ;


<s> case MCK_SSrcF32 : return Operand . isSSrcF32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SoppBrTarget : return Operand . isSoppBrTarget ( ) ? Match_Success : Match_InvalidOperand ; case MCK_VReg32OrOff : return Operand . isVReg32OrOff ( ) ? Match_Success : Match_InvalidOperand ; case MCK_InterpSlot : return Operand . isInterpSlot ( ) ? Match_Success : Match_InvalidOperand ; case MCK_Attr : return Operand . isInterpAttr ( ) ? Match_Success : Match_InvalidOperand ; case MCK_AttrChan : return Operand . isAttrChan ( ) ? Match_Success : Match_InvalidOperand ; default : return Match_InvalidOperand ; }


<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 ; } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } return false ; case IS_VGPR : case IS_SGPR : case IS_AGPR : case IS_TTMP : if ( Reg1 != Reg + RegWidth ) {


<s> 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 ; } return false ; case IS_VGPR : case IS_SGPR : case IS_AGPR : case IS_TTMP : if ( Reg1 != Reg + RegWidth ) { return false ;


<s> static <ISA_LIT>Operand :: Ptr CreateReg ( const <ISA_LIT>AsmParser * AsmParser , unsigned RegNo , SMLoc S , SMLoc E ) {

auto Op = llvm :: make_unique < <ISA_LIT>Operand > ( Register , AsmParser ) ;


<s> if ( isRegOrImmWithInputMods ( Desc , Inst . getNumOperands ( ) ) ) { Op . addRegOrImmWithInputModsOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isImm ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { llvm_unreachable ( <STR_LIT> ) ; } skippedVcc = false ; } if ( Inst . getOpcode ( ) != <STR_LIT> && Inst . getOpcode ( ) != <STR_LIT> && Inst . getOpcode ( ) != <STR_LIT> ) { switch ( BasicInstType ) { case <STR_LIT> : addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> , <NUM_LIT> ) ; if ( <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: omod ) != - <NUM_LIT> ) { addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> , <NUM_LIT> ) ; } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaDstSel , SdwaSel :: DWORD ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaDstUnused , DstUnused :: UNUSED_PRESERVE ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaSrc0Sel , SdwaSel :: DWORD ) ; break ; case <STR_LIT> : addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> , <NUM_LIT> ) ; if ( <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: omod ) != - <NUM_LIT> ) { addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> , <NUM_LIT> ) ; } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaDstSel , SdwaSel :: DWORD ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaDstUnused , DstUnused :: UNUSED_PRESERVE ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaSrc0Sel , SdwaSel :: DWORD ) ;

addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaSrc1Sel , SdwaSel :: DWORD ) ;


<s> case <STR_LIT> : addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> , <NUM_LIT> ) ; if ( <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: omod ) != - <NUM_LIT> ) { addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> , <NUM_LIT> ) ; } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaDstSel , SdwaSel :: DWORD ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaDstUnused , DstUnused :: UNUSED_PRESERVE ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaSrc0Sel , SdwaSel :: DWORD ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaSrc1Sel , SdwaSel :: DWORD ) ; break ; case <STR_LIT> : if ( <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: clamp ) != - <NUM_LIT> ) addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> , <NUM_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaSrc0Sel , SdwaSel :: DWORD ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaSrc1Sel , SdwaSel :: DWORD ) ; break ; default : llvm_unreachable ( <STR_LIT> ) ; } } if ( Inst . getOpcode ( ) == <STR_LIT> || Inst . getOpcode ( ) == <STR_LIT> ) { auto it = Inst . begin ( ) ;

std :: advance ( it , <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: src2 ) ) ;


<s> unsigned <ISA_LIT>AsmParser :: findImplicitSGPRReadInVOP ( const MCInst & Inst ) const { const MCInstrDesc & Desc = MII . get ( Inst . getOpcode ( ) ) ;

const unsigned Num = Desc . getNumImplicitUses ( ) ;


<s> unsigned <ISA_LIT>AsmParser :: findImplicitSGPRReadInVOP ( const MCInst & Inst ) const { const MCInstrDesc & Desc = MII . get ( Inst . getOpcode ( ) ) ; const unsigned Num = Desc . getNumImplicitUses ( ) ; for ( unsigned i = <NUM_LIT> ; i < Num ; ++ i ) { unsigned Reg = Desc . ImplicitUses [ i ] ; switch ( Reg ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> } else if ( Is == IS_TTMP ) { 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> ; } } 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> ; } } else if ( Is == IS_AGPR ) { switch ( RegWidth ) {


<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_TTMP ) { 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> ; } } 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> ; } } else if ( Is == IS_AGPR ) { switch ( RegWidth ) { default : return - <NUM_LIT> ;


<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> ) . 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> 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> ) . 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> bool <ISA_LIT>Operand :: isBoolReg ( ) const { return AsmParser -> getFeatureBits ( ) [ <STR_LIT> ] ? isSCSrcB64 ( ) : isSCSrcB32 ( ) ;


<s> switch ( Reg ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return true ; case <STR_LIT> : case <STR_LIT> :


<s> unsigned RegNum ; if ( ! RegName . substr ( Reg . size ( ) ) . getAsInteger ( <NUM_LIT> , RegNum ) ) return true ; } else { if ( NextToken . is ( AsmToken :: LBrac ) ) return true ; }


<s> } 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 , nullptr ) ) 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 , nullptr ) ) { 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> OperandMatchResultTy <ISA_LIT>AsmParser :: parseImm ( OperandVector & Operands , bool HasSP3AbsModifier ) { assert ( ! isRegister ( ) ) ; assert ( ! isModifier ( ) ) ; const auto & Tok = getToken ( ) ; const auto & NextTok = peekToken ( ) ; bool IsReal = Tok . is ( AsmToken :: Real ) ; SMLoc S = getLoc ( ) ; bool Negate = false ; if ( ! IsReal && Tok . is ( AsmToken :: Minus ) && NextTok . is ( AsmToken :: Real ) ) { lex ( ) ; IsReal = true ; Negate = true ; } if ( IsReal ) { StringRef Num = getTokenStr ( ) ; lex ( ) ; APFloat RealVal ( APFloat :: IEEEdouble ( ) ) ; auto roundMode = APFloat :: rmNearestTiesToEven ; if ( RealVal . convertFromString ( Num , roundMode ) == APFloat :: opInvalidOp ) { return MatchOperand_ParseFail ; } if ( Negate ) RealVal . changeSign ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , RealVal . bitcastToAPInt ( ) . getZExtValue ( ) , S , <ISA_LIT>Operand :: ImmTyNone , true ) ) ; return MatchOperand_Success ; } else { int64_t IntVal ; const MCExpr * Expr ; SMLoc S = getLoc ( ) ; if ( HasSP3AbsModifier ) { SMLoc EndLoc ; if ( getParser ( ) . parsePrimaryExpr ( Expr , EndLoc ) ) return MatchOperand_ParseFail ; } else { if ( Parser . parseExpression ( Expr ) ) return MatchOperand_ParseFail ; } if ( Expr -> evaluateAsAbsolute ( IntVal ) ) { Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , IntVal , S ) ) ; } else { Operands . push_back ( <ISA_LIT>Operand :: CreateExpr ( this , Expr , S ) ) ; } return MatchOperand_Success ;


<s> 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 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 ;


<s> 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 ; } if ( ! validateFlatOffset ( Inst , Operands ) ) { return false ; }


<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 ;


<s> if ( OpIdx == - <NUM_LIT> ) break ; const MCOperand & MO = Inst . getOperand ( OpIdx ) ; if ( MO . isImm ( ) && <STR_LIT> ( Desc , OpIdx ) && ! isInlineConstant ( Inst , OpIdx ) ) { uint32_t Value = static_cast < uint32_t > ( MO . getImm ( ) ) ; if ( NumLiterals == <NUM_LIT> || LiteralValue != Value ) { LiteralValue = Value ; ++ NumLiterals ;


<s> switch ( Kind ) { case MCK_addr64 : return Operand . isAddr64 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_gds : return Operand . isGDS ( ) ? Match_Success : Match_InvalidOperand ; case MCK_lds : return Operand . isLDS ( ) ? Match_Success : Match_InvalidOperand ; 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 ; case MCK_SSrcB32 : return Operand . isSSrcB32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SSrcF32 : return Operand . isSSrcF32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SoppBrTarget : return Operand . isSoppBrTarget ( ) ? Match_Success : Match_InvalidOperand ; case MCK_VReg32OrOff : return Operand . isVReg32OrOff ( ) ? Match_Success : Match_InvalidOperand ;


<s> for ( int OpIdx : OpIndices ) { if ( OpIdx == - <NUM_LIT> ) break ; const MCOperand & MO = Inst . getOperand ( OpIdx ) ; if ( ! MO . isImm ( ) || ! <STR_LIT> ( Desc , OpIdx ) ) continue ; if ( ! isInlineConstant ( Inst , OpIdx ) ) {

uint32_t Value = static_cast < uint32_t > ( MO . getImm ( ) ) ;


<s> 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> : { bool lost ; APFloat FPLiteral ( APFloat :: IEEEdouble ( ) , Literal ) ; FPLiteral . convert ( * getOpFltSemantics ( OpTy ) , APFloat :: rmNearestTiesToEven , & lost ) ; uint64_t ImmVal = FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ; if ( OpTy == <STR_LIT> || OpTy == <STR_LIT> ) { ImmVal |= ( ImmVal << <NUM_LIT> ) ; } Inst . addOperand ( MCOperand :: createImm ( ImmVal ) ) ; return ; } default : llvm_unreachable ( <STR_LIT> ) ; } return ; } switch ( OpTy ) {


<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> : { bool lost ; APFloat FPLiteral ( APFloat :: IEEEdouble ( ) , Literal ) ; FPLiteral . convert ( * getOpFltSemantics ( OpTy ) , APFloat :: rmNearestTiesToEven , & lost ) ; uint64_t ImmVal = FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ; if ( OpTy == <STR_LIT> || OpTy == <STR_LIT> ) { ImmVal |= ( ImmVal << <NUM_LIT> ) ; } 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> : if ( isInt < <NUM_LIT> > ( Val ) && <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 ;


<s> 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 ; } return false ; case IS_VGPR : case IS_SGPR : case IS_TTMP : if ( Reg1 != Reg + RegWidth ) { return false ; } RegWidth ++ ; return true ; default :


<s> setAvailableFeatures ( ComputeAvailableFeatures ( getFeatureBits ( ) ) ) ; { <STR_LIT> :: IsaVersion ISA = <STR_LIT> :: getIsaVersion ( getFeatureBits ( ) ) ; 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> addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDMask ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyUNorm ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyGLC ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySLC ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyR128 ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyTFE ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyLWE ) ;

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


<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> ) ; } if ( IsAtomic ) { assert ( Desc . getNumDefs ( ) == <NUM_LIT> ) ; ( ( <ISA_LIT>Operand & ) * Operands [ I - <NUM_LIT> ] ) . addRegOperands ( Inst , <NUM_LIT> ) ; } OptionalImmIndexMap OptionalIdx ; for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isReg ( ) ) { Op . addRegOperands ( Inst , <NUM_LIT> ) ;