<s> while ( true ) { unsigned Mode = <NUM_LIT> ; SMLoc S = 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> ) ;


<s> int64_t <ISA_LIT>AsmParser :: parseGPRIdxMacro ( ) { using namespace llvm :: <STR_LIT> ; if ( trySkipToken ( AsmToken :: RParen ) ) { return OFF ; } int64_t Imm = <NUM_LIT> ; while ( true ) { unsigned Mode = <NUM_LIT> ; SMLoc S = 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> ) ; return UNDEF ; } if ( Imm & Mode ) { Error ( S , <STR_LIT> ) ; return UNDEF ; } Imm |= Mode ;

if ( trySkipToken ( AsmToken :: RParen ) ) break ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseGPRIdxMode ( OperandVector & Operands ) { using namespace llvm :: <STR_LIT> ; int64_t Imm = <NUM_LIT> ; SMLoc S = getLoc ( ) ; if ( trySkipId ( <STR_LIT> , AsmToken :: LParen ) ) { Imm = parseGPRIdxMacro ( ) ; if ( Imm == UNDEF ) return MatchOperand_ParseFail ; } else { if ( getParser ( ) . parseAbsoluteExpression ( Imm ) ) return MatchOperand_ParseFail ; if ( Imm < <NUM_LIT> || ! isUInt < <NUM_LIT> > ( Imm ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; }


<s> int64_t ImmVal = <NUM_LIT> ; SMLoc Loc = getLoc ( ) ; if ( trySkipId ( <STR_LIT> , AsmToken :: LParen ) ) { OperandInfoTy HwReg ( ID_UNKNOWN_ ) ; OperandInfoTy Offset ( OFFSET_DEFAULT_ ) ; OperandInfoTy Width ( WIDTH_DEFAULT_ ) ; if ( parseHwregBody ( HwReg , Offset , Width ) && validateHwreg ( HwReg , Offset , Width ) ) {

ImmVal = encodeHwreg ( HwReg . Id , Offset . Id , Width . Id ) ;


<s> bool <ISA_LIT>AsmParser :: parseHwregBody ( OperandInfoTy & HwReg , OperandInfoTy & Offset , OperandInfoTy & Width ) { using namespace llvm :: <STR_LIT> ; HwReg . Loc = getLoc ( ) ;

if ( isToken ( AsmToken :: Identifier ) && ( HwReg . Id = getHwregId ( getTokenStr ( ) ) ) >= <NUM_LIT> ) {


<s> lex ( ) ; } else if ( ! parseExpr ( HwReg . Id , <STR_LIT> ) ) { return false ; } if ( trySkipToken ( AsmToken :: RParen ) ) return true ; if ( ! skipToken ( AsmToken :: Comma , <STR_LIT> ) ) return false ;


<s> if ( isToken ( AsmToken :: Identifier ) ) { Val = getTokenStr ( ) ; lex ( ) ; return true ; } else {

if ( ! ErrMsg . empty ( ) ) Error ( getLoc ( ) , ErrMsg ) ;


<s> lex ( ) ; return true ; } else { if ( ! ErrMsg . empty ( ) ) Error ( getLoc ( ) , ErrMsg ) ; return false ;


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


<s> OperandMatchResultTy Res = parseOperand ( Operands , Name , Mode ) ; if ( Res != MatchOperand_Success ) { checkUnsupportedInstruction ( Name , NameLoc ) ; if ( ! Parser . hasPendingError ( ) ) { StringRef Msg = ( Res == MatchOperand_ParseFail ) ? <STR_LIT> : <STR_LIT> ; Error ( getLoc ( ) , Msg ) ; } while ( ! trySkipToken ( AsmToken :: EndOfStatement ) ) { lex ( ) ; } return true ; }


<s> if ( AttrChan == - <NUM_LIT> ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } Str = Str . drop_back ( <NUM_LIT> ) . drop_front ( <NUM_LIT> ) ; uint8_t Attr ; if ( Str . getAsInteger ( <NUM_LIT> , Attr ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( Attr > <NUM_LIT> ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } SMLoc SChan = SMLoc :: getFromPointer ( Chan . data ( ) ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Attr , S , <ISA_LIT>Operand :: ImmTyInterpAttr ) ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , AttrChan , SChan , <ISA_LIT>Operand :: ImmTyAttrChan ) ) ;


<s> if ( Slot == - <NUM_LIT> ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Slot , S , <ISA_LIT>Operand :: ImmTyInterpSlot ) ) ;


<s> if ( ConvertResult && ! ConvertResult ( Value ) ) { Error ( S , <STR_LIT> + StringRef ( Prefix ) + <STR_LIT> ) ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Value , S , ImmTy ) ) ; return MatchOperand_Success ;


<s> if ( Name . endswith ( <STR_LIT> ) ) { setForcedEncodingSize ( <NUM_LIT> ) ; return Name . substr ( <NUM_LIT> , Name . size ( ) - <NUM_LIT> ) ; } else if ( Name . endswith ( <STR_LIT> ) ) { setForcedEncodingSize ( <NUM_LIT> ) ; return Name . substr ( <NUM_LIT> , Name . size ( ) - <NUM_LIT> ) ; } else if ( Name . endswith ( <STR_LIT> ) ) { setForcedDPP ( true ) ; return Name . substr ( <NUM_LIT> , Name . size ( ) - <NUM_LIT> ) ;


<s> setForcedEncodingSize ( <NUM_LIT> ) ; return Name . substr ( <NUM_LIT> , Name . size ( ) - <NUM_LIT> ) ; } else if ( Name . endswith ( <STR_LIT> ) ) { setForcedEncodingSize ( <NUM_LIT> ) ; return Name . substr ( <NUM_LIT> , Name . size ( ) - <NUM_LIT> ) ; } else if ( Name . endswith ( <STR_LIT> ) ) { setForcedDPP ( true ) ; return Name . substr ( <NUM_LIT> , Name . size ( ) - <NUM_LIT> ) ; } else if ( Name . endswith ( <STR_LIT> ) ) { setForcedSDWA ( true ) ; return Name . substr ( <NUM_LIT> , Name . size ( ) - <NUM_LIT> ) ; }


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseNamedBit ( StringRef Name , OperandVector & Operands , <ISA_LIT>Operand :: ImmTy ImmTy ) { int64_t Bit ; SMLoc S = getLoc ( ) ; if ( trySkipId ( Name ) ) { Bit = <NUM_LIT> ; } else if ( trySkipId ( <STR_LIT> , Name ) ) { Bit = <NUM_LIT> ;


<s> Bit = <NUM_LIT> ; } else if ( trySkipId ( <STR_LIT> , Name ) ) { Bit = <NUM_LIT> ; } else { return MatchOperand_NoMatch ; } if ( Name == <STR_LIT> && ! hasMIMG_R128 ( ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( Name == <STR_LIT> && ! isGFX9 ( ) && ! hasGFX10A16 ( ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( isGFX9 ( ) && ImmTy == <ISA_LIT>Operand :: ImmTyA16 ) ImmTy = <ISA_LIT>Operand :: ImmTyR128A16 ;

Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Bit , S , ImmTy ) ) ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseNumericFormat ( int64_t & Format ) { using namespace llvm :: <STR_LIT> ; SMLoc Loc = getLoc ( ) ; if ( ! parseExpr ( Format ) ) return MatchOperand_ParseFail ; if ( ! isValidFormatEncoding ( Format , getSTI ( ) ) ) { Error ( Loc , <STR_LIT> ) ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseNumericFormat ( int64_t & Format ) { using namespace llvm :: <STR_LIT> ; SMLoc Loc = getLoc ( ) ; if ( ! parseExpr ( Format ) ) return MatchOperand_ParseFail ;

if ( ! isValidFormatEncoding ( Format , getSTI ( ) ) ) {


return parseIntWithPrefix ( <STR_LIT> , Operands , <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> , ConvertOmodDiv ) ;


<s> if ( Mode == OperandMode_NSA && trySkipToken ( AsmToken :: LBrac ) ) { unsigned Prefix = Operands . size ( ) ; for ( ; ; ) { auto Loc = getLoc ( ) ; ResTy = parseReg ( Operands ) ; if ( ResTy == MatchOperand_NoMatch ) Error ( Loc , <STR_LIT> ) ; if ( ResTy != MatchOperand_Success ) return MatchOperand_ParseFail ; RBraceLoc = getLoc ( ) ; if ( trySkipToken ( AsmToken :: RBrac ) ) break ; if ( ! skipToken ( AsmToken :: Comma , <STR_LIT> ) ) { return MatchOperand_ParseFail ; }


<s> SMLoc RBraceLoc ; SMLoc LBraceLoc = getLoc ( ) ; if ( Mode == OperandMode_NSA && trySkipToken ( AsmToken :: LBrac ) ) { unsigned Prefix = Operands . size ( ) ; for ( ; ; ) { auto Loc = getLoc ( ) ; ResTy = parseReg ( Operands ) ; if ( ResTy == MatchOperand_NoMatch ) Error ( Loc , <STR_LIT> ) ; if ( ResTy != MatchOperand_Success ) return MatchOperand_ParseFail ; RBraceLoc = getLoc ( ) ; if ( trySkipToken ( AsmToken :: RBrac ) ) break ; if ( ! skipToken ( AsmToken :: Comma , <STR_LIT> ) ) {


<s> return MatchOperand_ParseFail ; } Val |= ( Op << I ) ; if ( trySkipToken ( AsmToken :: RBrac ) ) break ; if ( I + <NUM_LIT> == MaxSize ) { Error ( getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( ! skipToken ( AsmToken :: Comma , <STR_LIT> ) ) return MatchOperand_ParseFail ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Val , S , ImmTy ) ) ; return MatchOperand_Success ;


<s> for ( unsigned i = <NUM_LIT> ; i < MAX_OPR_LOOKAHEAD ; ++ i ) { if ( res != MatchOperand_Success || isToken ( AsmToken :: EndOfStatement ) ) break ; trySkipToken ( AsmToken :: Comma ) ; res = parseOptionalOpr ( Operands ) ; }


<s> res = parseOModOperand ( Operands ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTySdwaDstSel || Op . Type == <ISA_LIT>Operand :: ImmTySdwaSrc0Sel || Op . Type == <ISA_LIT>Operand :: ImmTySdwaSrc1Sel ) { res = parseSDWASel ( Operands , Op . Name , Op . Type ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTySdwaDstUnused ) { res = parseSDWADstUnused ( Operands ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTyOpSel || Op . Type == <ISA_LIT>Operand :: ImmTyOpSelHi || Op . Type == <ISA_LIT>Operand :: ImmTyNegLo || Op . Type == <ISA_LIT>Operand :: ImmTyNegHi ) { res = parseOperandArrayWithPrefix ( Op . Name , Operands , Op . Type , Op . ConvertResult ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTyDim ) { res = parseDim ( Operands ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTyCPol ) { res = parseCPol ( Operands ) ; } else { res = parseIntWithPrefix ( Op . Name , Operands , Op . Type , Op . ConvertResult ) ; } if ( res != MatchOperand_NoMatch ) { return res ; }


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


<s> if ( auto R = parseRegister ( ) ) { assert ( R -> isReg ( ) ) ; Operands . push_back ( std :: move ( R ) ) ; return MatchOperand_Success ; }


<s> assert ( R -> isReg ( ) ) ; Operands . push_back ( std :: move ( R ) ) ; return MatchOperand_Success ; }


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

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


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


<s> auto res = parseReg ( Operands ) ; if ( res != MatchOperand_NoMatch ) { return res ; } else if ( isModifier ( ) ) { return MatchOperand_NoMatch ; } else { return parseImm ( Operands , HasSP3AbsMod ) ;


<s> OperandMatchResultTy Res ; if ( AllowImm ) { Res = parseRegOrImm ( Operands , SP3Abs ) ; } else { Res = parseReg ( Operands ) ; } if ( Res != MatchOperand_Success ) { return ( SP3Neg || Neg || SP3Abs || Abs ) ? MatchOperand_ParseFail : Res ; } if ( SP3Abs && ! skipToken ( AsmToken :: Pipe , <STR_LIT> ) ) return MatchOperand_ParseFail ; if ( Abs && ! skipToken ( AsmToken :: RParen , <STR_LIT> ) ) return MatchOperand_ParseFail ; if ( Neg && ! skipToken ( AsmToken :: RParen , <STR_LIT> ) ) return MatchOperand_ParseFail ; <ISA_LIT>Operand :: Modifiers Mods ;


<s> if ( Neg && SP3Neg ) { Error ( Loc , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( Neg && ! skipToken ( AsmToken :: LParen , <STR_LIT> ) ) return MatchOperand_ParseFail ; Abs = trySkipId ( <STR_LIT> ) ; if ( Abs && ! skipToken ( AsmToken :: LParen , <STR_LIT> ) ) return MatchOperand_ParseFail ; Loc = getLoc ( ) ; SP3Abs = trySkipToken ( AsmToken :: Pipe ) ; if ( Abs && SP3Abs ) { Error ( Loc , <STR_LIT> ) ; return MatchOperand_ParseFail ; } OperandMatchResultTy Res ; if ( AllowImm ) { Res = parseRegOrImm ( Operands , SP3Abs ) ; } else { Res = parseReg ( Operands ) ; } if ( Res != MatchOperand_Success ) { return ( SP3Neg || Neg || SP3Abs || Abs ) ? MatchOperand_ParseFail : Res ; } if ( SP3Abs && ! skipToken ( AsmToken :: Pipe , <STR_LIT> ) ) return MatchOperand_ParseFail ; if ( Abs && ! skipToken ( AsmToken :: RParen , <STR_LIT> ) ) return MatchOperand_ParseFail ; if ( Neg && ! skipToken ( AsmToken :: RParen , <STR_LIT> ) ) return MatchOperand_ParseFail ; <ISA_LIT>Operand :: Modifiers Mods ; Mods . Abs = Abs || SP3Abs ;


<s> if ( Sext && ! skipToken ( AsmToken :: LParen , <STR_LIT> ) ) return MatchOperand_ParseFail ; OperandMatchResultTy Res ; if ( AllowImm ) { Res = parseRegOrImm ( Operands ) ; } else { Res = parseReg ( Operands ) ; } if ( Res != MatchOperand_Success ) { return Sext ? MatchOperand_ParseFail : Res ; } if ( Sext && ! skipToken ( AsmToken :: RParen , <STR_LIT> ) ) return MatchOperand_ParseFail ; <ISA_LIT>Operand :: Modifiers Mods ; Mods . Sext = Sext ; if ( Mods . hasIntModifiers ( ) ) { <ISA_LIT>Operand & Op = static_cast < <ISA_LIT>Operand & > ( * Operands . back ( ) ) ; if ( Op . isExpr ( ) ) { Error ( Op . getStartLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ;


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


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

if ( ! isUInt < <NUM_LIT> > ( RegLo ) ) {


<s> StringRef RegSuffix = RegName . substr ( RI -> Name . size ( ) ) ; if ( ! RegSuffix . empty ( ) ) { if ( ! getRegNum ( RegSuffix , RegNum ) ) { Error ( Loc , <STR_LIT> ) ; return <STR_LIT> ; } RegWidth = <NUM_LIT> ; } else {

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


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseRegWithFPInputMods ( OperandVector & Operands ) {

return parseRegOrImmWithFPInputMods ( Operands , false ) ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseRegWithIntInputMods ( OperandVector & Operands ) {

return parseRegOrImmWithIntInputMods ( Operands , false ) ;


<s> if ( res != MatchOperand_Success ) { return res ; } int64_t Int ; Int = StringSwitch < int64_t > ( Value ) . Case ( <STR_LIT> , DstUnused :: UNUSED_PAD ) . Case ( <STR_LIT> , DstUnused :: UNUSED_SEXT ) . Case ( <STR_LIT> , DstUnused :: UNUSED_PRESERVE ) . Default ( <NUM_LIT> ) ; if ( Int == <NUM_LIT> ) { Error ( StringLoc , <STR_LIT> ) ; return MatchOperand_ParseFail ; }

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


<s> SMLoc S = getLoc ( ) ; StringRef Value ; OperandMatchResultTy res ; SMLoc StringLoc ; res = parseStringWithPrefix ( Prefix , Value , StringLoc ) ; if ( res != MatchOperand_Success ) { return res ; } int64_t Int ; Int = StringSwitch < int64_t > ( Value ) . Case ( <STR_LIT> , SdwaSel :: BYTE_0 ) . Case ( <STR_LIT> , SdwaSel :: BYTE_1 ) . Case ( <STR_LIT> , SdwaSel :: BYTE_2 ) . Case ( <STR_LIT> , SdwaSel :: BYTE_3 ) . Case ( <STR_LIT> , SdwaSel :: WORD_0 ) . Case ( <STR_LIT> , SdwaSel :: WORD_1 ) . Case ( <STR_LIT> , SdwaSel :: DWORD ) . Default ( <NUM_LIT> ) ;


<s> Msg . Loc = getLoc ( ) ; if ( isToken ( AsmToken :: Identifier ) && ( Msg . Id = getMsgId ( getTokenStr ( ) ) ) >= <NUM_LIT> ) { Msg . IsSymbolic = true ; lex ( ) ; } else if ( ! parseExpr ( Msg . Id , <STR_LIT> ) ) { return false ; } if ( trySkipToken ( AsmToken :: Comma ) ) { Op . IsDefined = true ; Op . Loc = getLoc ( ) ;

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


<s> Op . Loc = getLoc ( ) ; if ( isToken ( AsmToken :: Identifier ) && ( Op . Id = getMsgOpId ( Msg . Id , getTokenStr ( ) ) ) >= <NUM_LIT> ) { lex ( ) ; } else if ( ! parseExpr ( Op . Id , <STR_LIT> ) ) { return false ; } if ( trySkipToken ( AsmToken :: Comma ) ) { Stream . IsDefined = true ; Stream . Loc = getLoc ( ) ; if ( ! parseExpr ( Stream . Id ) ) return false ; }


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

ImmVal = encodeMsg ( Msg . Id , Op . Id , Stream . Id ) ;


<s> if ( Opr . isExpr ( ) && ! Opr . isSymbolRefExpr ( ) ) { Error ( Loc , <STR_LIT> ) ; } else if ( Opr . isImm ( ) && ! Opr . isS16Imm ( ) ) { Error ( Loc , <STR_LIT> ) ; }


if ( isToken ( AsmToken :: Minus ) && ( isRegister ( NextToken [ <NUM_LIT> ] , NextToken [ <NUM_LIT> ] ) || NextToken [ <NUM_LIT> ] . is ( AsmToken :: Pipe ) || isId ( NextToken [ <NUM_LIT> ] , <STR_LIT> ) ) ) {


<s> if ( isToken ( AsmToken :: Minus ) && ( isRegister ( NextToken [ <NUM_LIT> ] , NextToken [ <NUM_LIT> ] ) || NextToken [ <NUM_LIT> ] . is ( AsmToken :: Pipe ) || isId ( NextToken [ <NUM_LIT> ] , <STR_LIT> ) ) ) { lex ( ) ;


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


<s> Val = getToken ( ) . getStringContents ( ) ; lex ( ) ; return true ; } else { Error ( getLoc ( ) , ErrMsg ) ; return false ;


<s> StringLoc = getLoc ( ) ; return parseId ( Value , <STR_LIT> ) ? MatchOperand_Success : MatchOperand_ParseFail ;


<s> Error ( StrLoc , <STR_LIT> ) ; return false ; } unsigned AndMask = <NUM_LIT> ; unsigned OrMask = <NUM_LIT> ; unsigned XorMask = <NUM_LIT> ; for ( size_t i = <NUM_LIT> ; i < Ctl . size ( ) ; ++ i ) { unsigned Mask = <NUM_LIT> << ( BITMASK_WIDTH - <NUM_LIT> - i ) ; switch ( Ctl [ i ] ) {


<s> } if ( Ctl . size ( ) != BITMASK_WIDTH ) { Error ( StrLoc , <STR_LIT> ) ; return false ; } unsigned AndMask = <NUM_LIT> ; unsigned OrMask = <NUM_LIT> ; unsigned XorMask = <NUM_LIT> ; for ( size_t i = <NUM_LIT> ; i < Ctl . size ( ) ; ++ i ) { unsigned Mask = <NUM_LIT> << ( BITMASK_WIDTH - <NUM_LIT> - i ) ; switch ( Ctl [ i ] ) { default : Error ( StrLoc , <STR_LIT> ) ; return false ; case '0' : break ; case '1' :


<s> int64_t GroupSize ; int64_t LaneIdx ; if ( ! parseSwizzleOperand ( GroupSize , <NUM_LIT> , <NUM_LIT> , <STR_LIT> , Loc ) ) { return false ; } if ( ! isPowerOf2_64 ( GroupSize ) ) { Error ( Loc , <STR_LIT> ) ; return false ;


<s> if ( parseSwizzleOperand ( LaneIdx , <NUM_LIT> , GroupSize - <NUM_LIT> , <STR_LIT> , Loc ) ) { Imm = encodeBitmaskPerm ( BITMASK_MAX - GroupSize + <NUM_LIT> , LaneIdx , <NUM_LIT> ) ; return true ;


<s> if ( trySkipId ( IdSymbolic [ ID_QUAD_PERM ] ) ) { Ok = parseSwizzleQuadPerm ( Imm ) ; } else if ( trySkipId ( IdSymbolic [ ID_BITMASK_PERM ] ) ) { Ok = parseSwizzleBitmaskPerm ( Imm ) ; } else if ( trySkipId ( IdSymbolic [ ID_BROADCAST ] ) ) { Ok = parseSwizzleBroadcast ( Imm ) ; } else if ( trySkipId ( IdSymbolic [ ID_SWAP ] ) ) { Ok = parseSwizzleSwap ( Imm ) ; } else if ( trySkipId ( IdSymbolic [ ID_REVERSE ] ) ) { Ok = parseSwizzleReverse ( Imm ) ; } else { Error ( ModeLoc , <STR_LIT> ) ; } return Ok && skipToken ( AsmToken :: RParen , <STR_LIT> ) ;


<s> bool <ISA_LIT>AsmParser :: parseSwizzleOffset ( int64_t & Imm ) { SMLoc OffsetLoc = getLoc ( ) ; if ( ! parseExpr ( Imm , <STR_LIT> ) ) { return false ; } if ( ! isUInt < <NUM_LIT> > ( Imm ) ) {


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


<s> Ok = parseSwizzleOffset ( Imm ) ; } } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Imm , S , <ISA_LIT>Operand :: ImmTySwizzle ) ) ;

return Ok ? MatchOperand_Success : MatchOperand_ParseFail ;


<s> if ( ! skipToken ( AsmToken :: Comma , <STR_LIT> ) ) { return false ; } Loc = getLoc ( ) ; if ( ! parseExpr ( Op ) ) { return false ; }


<s> } Loc = getLoc ( ) ; if ( ! parseExpr ( Op ) ) { return false ; } if ( Op < MinVal || Op > MaxVal ) { Error ( Loc , ErrMsg ) ; return false ;


<s> SMLoc Loc ; for ( unsigned i = <NUM_LIT> ; i < OpNum ; ++ i ) {

if ( ! parseSwizzleOperand ( Op [ i ] , MinVal , MaxVal , ErrMsg , Loc ) ) return false ;


<s> using namespace llvm :: <STR_LIT> ; int64_t Lane [ LANE_NUM ] ; if ( parseSwizzleOperands ( LANE_NUM , Lane , <NUM_LIT> , LANE_MAX , <STR_LIT> ) ) {


<s> using namespace llvm :: <STR_LIT> ; SMLoc Loc ; int64_t GroupSize ; if ( ! parseSwizzleOperand ( GroupSize , <NUM_LIT> , <NUM_LIT> , <STR_LIT> , Loc ) ) { return false ; } if ( ! isPowerOf2_64 ( GroupSize ) ) { Error ( Loc , <STR_LIT> ) ;


<s> } if ( ! isPowerOf2_64 ( GroupSize ) ) { Error ( Loc , <STR_LIT> ) ; return false ; }

Imm = encodeBitmaskPerm ( BITMASK_MAX , <NUM_LIT> , GroupSize ) ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseSymbolicOrNumericFormat ( int64_t & Format ) { using namespace llvm :: <STR_LIT> ; if ( ! trySkipId ( <STR_LIT> , AsmToken :: Colon ) ) return MatchOperand_NoMatch ; if ( trySkipToken ( AsmToken :: LBrac ) ) { StringRef FormatStr ; SMLoc Loc = getLoc ( ) ; if ( ! parseId ( FormatStr , <STR_LIT> ) ) return MatchOperand_ParseFail ; auto Res = parseSymbolicUnifiedFormat ( FormatStr , Loc , Format ) ; if ( Res == MatchOperand_NoMatch ) Res = parseSymbolicSplitFormat ( FormatStr , Loc , Format ) ; if ( Res != MatchOperand_Success ) return Res ; if ( ! skipToken ( AsmToken :: RBrac , <STR_LIT> ) ) return MatchOperand_ParseFail ;


<s> auto Res = parseSymbolicUnifiedFormat ( FormatStr , Loc , Format ) ; if ( Res == MatchOperand_NoMatch ) Res = parseSymbolicSplitFormat ( FormatStr , Loc , Format ) ; if ( Res != MatchOperand_Success ) return Res ; if ( ! skipToken ( AsmToken :: RBrac , <STR_LIT> ) ) return MatchOperand_ParseFail ;


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


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseSymbolicUnifiedFormat ( StringRef FormatStr , SMLoc Loc , int64_t & Format ) {


<s> } CollectStream << Parser . parseStringToEndOfStatement ( ) << getContext ( ) . getAsmInfo ( ) -> getSeparatorString ( ) ; Parser . eatToEndOfStatement ( ) ; } getLexer ( ) . setSkipSpace ( true ) ; if ( isToken ( AsmToken :: Eof ) && ! FoundEnd ) { return TokError ( Twine ( <STR_LIT> ) + Twine ( AssemblerDirectiveEnd ) + Twine ( <STR_LIT> ) ) ;


<s> int64_t Fmt = UFMT_UNDEF ; if ( ! tryParseFmt ( <STR_LIT> , UFMT_MAX , Fmt ) ) return MatchOperand_ParseFail ;

if ( Fmt == UFMT_UNDEF ) return MatchOperand_NoMatch ;


<s> int64_t Fmt = UFMT_UNDEF ; if ( ! tryParseFmt ( <STR_LIT> , UFMT_MAX , Fmt ) ) return MatchOperand_ParseFail ; if ( Fmt == UFMT_UNDEF ) return MatchOperand_NoMatch ; Format = Fmt ;


<s> auto Loc = getLoc ( ) ; if ( trySkipId ( <STR_LIT> ) ) { Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , <NUM_LIT> , Loc , <ISA_LIT>Operand :: ImmTyOff , false ) ) ; return MatchOperand_Success ; } if ( ! isRegister ( ) ) return MatchOperand_NoMatch ; std :: unique_ptr < <ISA_LIT>Operand > Reg = parseRegister ( ) ; if ( Reg ) { Operands . push_back ( std :: move ( Reg ) ) ; return MatchOperand_Success ; } return MatchOperand_ParseFail ;


<s> std :: unique_ptr < <ISA_LIT>Operand > Reg = parseRegister ( ) ; if ( Reg ) { Operands . push_back ( std :: move ( Reg ) ) ; return MatchOperand_Success ; }


<s> AsmToken <ISA_LIT>AsmParser :: peekToken ( ) {

return isToken ( AsmToken :: EndOfStatement ) ? getToken ( ) : getLexer ( ) . peekTok ( ) ;


<s> return isToken ( AsmToken :: EndOfStatement ) ? getToken ( ) : getLexer ( ) . peekTok ( ) ;


<s> for ( auto Idx = TokCount ; Idx < Tokens . size ( ) ; ++ Idx ) Tokens [ Idx ] = AsmToken ( AsmToken :: Error , <STR_LIT> ) ;


<s> void print ( raw_ostream & OS ) const override { switch ( Kind ) { case Register : OS << <STR_LIT> << getReg ( ) << <STR_LIT> << Reg . Mods << '>' ; break ; case Immediate : OS << '<' << getImm ( ) ; if ( getImmTy ( ) != ImmTyNone ) { OS << <STR_LIT> ; printImmTy ( OS , getImmTy ( ) ) ; }


<s> void setImmKindConst ( ) const { assert ( isImm ( ) ) ;


<s> assert ( isImm ( ) ) ; Imm . Kind = ImmKindTyConst ;


<s> void setImmKindNone ( ) const { assert ( isImm ( ) ) ; Imm . Kind = ImmKindTyNone ;


<s> if ( isRegKind ( ) ) Reg . Mods = Mods ; else Imm . Mods = Mods ;


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


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

if ( * R == RegNo ) return hasSGPR102_SGPR103 ( ) ;


<s> if ( Res == MatchOperand_NoMatch ) return true ; if ( Val < <NUM_LIT> || Val > MaxVal ) { Error ( Loc , Twine ( <STR_LIT> , StringRef ( Pref ) ) ) ; return false ;


<s> SMLoc Loc = getLoc ( ) ; auto Res = parseIntWithPrefix ( Pref , Val ) ; if ( Res == MatchOperand_ParseFail ) return false ; if ( Res == MatchOperand_NoMatch ) return true ; if ( Val < <NUM_LIT> || Val > MaxVal ) { Error ( Loc , Twine ( <STR_LIT> , StringRef ( Pref ) ) ) ; return false ; }


<s> bool Result = ParseRegister ( RegNo , StartLoc , EndLoc , true ) ;

bool PendingErrors = getParser ( ) . hasPendingError ( ) ;


<s> bool <ISA_LIT>AsmParser :: trySkipId ( const StringRef Id , const AsmToken :: TokenKind Kind ) {

if ( isId ( Id ) && peekToken ( ) . is ( Kind ) ) {


<s> if ( isToken ( Kind ) ) { lex ( ) ; return true ; }


<s> if ( ! SymbolName ) return true ; MCSymbol * Sym = getContext ( ) . getOrCreateSymbol ( * SymbolName ) ; int64_t NewMax = DwordRegIndex + RegWidth - <NUM_LIT> ; int64_t OldCount ; if ( ! Sym -> isVariable ( ) ) return ! Error ( getLoc ( ) , <STR_LIT> ) ; if ( ! Sym -> getVariableValue ( false ) -> evaluateAsAbsolute ( OldCount ) ) return ! Error ( getLoc ( ) , <STR_LIT> ) ; if ( OldCount <= NewMax ) Sym -> setVariableValue ( MCConstantExpr :: create ( NewMax + <NUM_LIT> , getContext ( ) ) ) ; return true ;


<s> if ( ! Sym -> isVariable ( ) ) return ! Error ( getLoc ( ) , <STR_LIT> ) ; if ( ! Sym -> getVariableValue ( false ) -> evaluateAsAbsolute ( OldCount ) ) return ! Error ( getLoc ( ) , <STR_LIT> ) ; if ( OldCount <= NewMax ) Sym -> setVariableValue ( MCConstantExpr :: create ( NewMax + <NUM_LIT> , getContext ( ) ) ) ; return true ;


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


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


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


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


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


<s> if ( ( TSFlags & ( <STR_LIT> | <STR_LIT> | <STR_LIT> | <STR_LIT> | <STR_LIT> ) ) == <NUM_LIT> ) return true ; uint16_t DataNameIdx = ( TSFlags & <STR_LIT> ) ? <STR_LIT> :: data0 : <STR_LIT> :: vdata ; const MCRegisterInfo * MRI = getMRI ( ) ; int DstAreg = IsAGPROperand ( Inst , <STR_LIT> :: vdst , MRI ) ; int DataAreg = IsAGPROperand ( Inst , DataNameIdx , MRI ) ; if ( ( TSFlags & <STR_LIT> ) && DataAreg >= <NUM_LIT> ) { int Data2Areg = IsAGPROperand ( Inst , <STR_LIT> :: data1 , MRI ) ; if ( Data2Areg >= <NUM_LIT> && Data2Areg != DataAreg ) return false ; } auto FB = getFeatureBits ( ) ; if ( FB [ <STR_LIT> ] ) { if ( DataAreg < <NUM_LIT> || DstAreg < <NUM_LIT> ) return true ; return DstAreg == DataAreg ; } return DstAreg < <NUM_LIT> && DataAreg < <NUM_LIT> ;


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


<s> unsigned LiteralSize ; if ( Desc . TSFlags & ( <STR_LIT> | <STR_LIT> | <STR_LIT> | <STR_LIT> | <STR_LIT> | <STR_LIT> ) ) { if ( <STR_LIT> ( Opcode , <STR_LIT> :: imm ) != - <NUM_LIT> ) { ++ NumLiterals ; LiteralSize = <NUM_LIT> ; } SmallDenseSet < unsigned > SGPRsUsed ; unsigned SGPRUsed = findImplicitSGPRReadInVOP ( Inst ) ; if ( SGPRUsed != <STR_LIT> ) { SGPRsUsed . insert ( SGPRUsed ) ; ++ ConstantBusUseCount ; } const int Src0Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src0 ) ; const int Src1Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src1 ) ; const int Src2Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src2 ) ; const int OpIndices [ ] = { Src0Idx , Src1Idx , Src2Idx } ; for ( int OpIdx : OpIndices ) { if ( OpIdx == - <NUM_LIT> ) break ; const MCOperand & MO = Inst . getOperand ( OpIdx ) ; if ( usesConstantBus ( Inst , OpIdx ) ) { if ( MO . isReg ( ) ) { LastSGPR = mc2PseudoReg ( MO . getReg ( ) ) ; if ( ! SGPRsUsed . count ( LastSGPR ) ) { SGPRsUsed . insert ( LastSGPR ) ; ++ ConstantBusUseCount ; } } else { if ( Desc . OpInfo [ OpIdx ] . OperandType == MCOI :: OPERAND_IMMEDIATE ) continue ; unsigned Size = <STR_LIT> ( Desc , OpIdx ) ; if ( Size < <NUM_LIT> ) Size = <NUM_LIT> ; if ( NumLiterals == <NUM_LIT> ) {


<s> bool <ISA_LIT>AsmParser :: validateDivScale ( const MCInst & Inst ) { switch ( Inst . getOpcode ( ) ) { default : return true ; case V_DIV_SCALE_F32_gfx6_gfx7 : case V_DIV_SCALE_F32_vi : case V_DIV_SCALE_F32_gfx10 : case V_DIV_SCALE_F64_gfx6_gfx7 : case V_DIV_SCALE_F64_vi : case V_DIV_SCALE_F64_gfx10 : break ; } for ( auto Name : { <STR_LIT> :: src0_modifiers , <STR_LIT> :: src2_modifiers , <STR_LIT> :: src2_modifiers } ) { if ( Inst . getOperand ( <STR_LIT> ( Inst . getOpcode ( ) , Name ) ) . getImm ( ) & <STR_LIT> ) { return false ; } } return true ;


<s> if ( DppCtrlIdx < <NUM_LIT> ) return true ; unsigned DppCtrl = Inst . getOperand ( DppCtrlIdx ) . getImm ( ) ; if ( ! <STR_LIT> ( DppCtrl ) ) { int Src0Idx = <STR_LIT> ( Opc , <STR_LIT> :: src0 ) ; if ( Src0Idx >= <NUM_LIT> && getMRI ( ) -> getSubReg ( Inst . getOperand ( Src0Idx ) . getReg ( ) , <STR_LIT> ) ) { SMLoc S = getImmLoc ( <ISA_LIT>Operand :: ImmTyDppCtrl , Operands ) ; Error ( S , <STR_LIT> ) ; return false ;


<s> const int Src0Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src0 ) ; const int Src1Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src1 ) ; const int Src2Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src2 ) ; 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 } ; for ( int SrcIdx : SrcIndices ) { if ( SrcIdx == - <NUM_LIT> ) break ; const MCOperand & Src = Inst . getOperand ( SrcIdx ) ; if ( Src . isReg ( ) ) { const unsigned SrcReg = mc2PseudoReg ( Src . getReg ( ) ) ; if ( isRegIntersect ( DstReg , SrcReg , TRI ) ) { Error ( getRegLoc ( SrcReg , Operands ) , <STR_LIT> ) ; return false ;


<s> int Data0Pos = <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: data0 ) ; assert ( Data0Pos != - <NUM_LIT> ) ; auto Reg = Inst . getOperand ( Data0Pos ) . getReg ( ) ; auto RegIdx = Reg - ( VGPR32 . contains ( Reg ) ? <STR_LIT> : <STR_LIT> ) ;


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


<s> const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) != <NUM_LIT> && ! hasIntClamp ( ) ) { int ClampIdx = <STR_LIT> ( Opc , <STR_LIT> :: clamp ) ; assert ( ClampIdx != - <NUM_LIT> ) ;

return Inst . getOperand ( ClampIdx ) . getImm ( ) == <NUM_LIT> ;


<s> bool <ISA_LIT>AsmParser :: validateIntClampSupported ( const MCInst & Inst ) { const unsigned Opc = Inst . getOpcode ( ) ;

const MCInstrDesc & Desc = MII . get ( Opc ) ;


<s> if ( ( Desc . TSFlags & Enc ) == <NUM_LIT> ) return None ; for ( auto SrcName : { OpName :: src0 , OpName :: src1 , OpName :: src2 } ) { auto SrcIdx = getNamedOperandIdx ( Opcode , SrcName ) ; if ( SrcIdx == - <NUM_LIT> ) break ; const auto & Src = Inst . getOperand ( SrcIdx ) ; if ( Src . isReg ( ) && Src . getReg ( ) == LDS_DIRECT ) { if ( isGFX90A ( ) ) return StringRef ( <STR_LIT> ) ; if ( IsRevOpcode ( Opcode ) || ( Desc . TSFlags & <STR_LIT> ) ) return StringRef ( <STR_LIT> ) ; if ( SrcName != OpName :: src0 ) return StringRef ( <STR_LIT> ) ;


<s> const unsigned Opc = Inst . getOpcode ( ) ; if ( Opc != <STR_LIT> ) return true ; const int Src0Idx = <STR_LIT> ( Opc , <STR_LIT> :: src0 ) ; assert ( Src0Idx != - <NUM_LIT> ) ;

const MCOperand & Src0 = Inst . getOperand ( Src0Idx ) ;


<s> unsigned Dim = Inst . getOperand ( DimIdx ) . getImm ( ) ; const <STR_LIT> * DimInfo = <STR_LIT> ( Dim ) ; bool IsNSA = SrsrcIdx - VAddr0Idx > <NUM_LIT> ; unsigned ActualAddrSize = IsNSA ? SrsrcIdx - VAddr0Idx : <STR_LIT> ( getMRI ( ) , Desc , VAddr0Idx ) / <NUM_LIT> ; bool IsA16 = ( A16Idx != - <NUM_LIT> && Inst . getOperand ( A16Idx ) . getImm ( ) ) ; unsigned ExpectedAddrSize = <STR_LIT> ( BaseOpcode , DimInfo , IsA16 , hasG16 ( ) ) ;


<s> if ( ! Desc . mayLoad ( ) || ! Desc . mayStore ( ) ) return true ; int DMaskIdx = <STR_LIT> ( Opc , <STR_LIT> :: dmask ) ;

unsigned DMask = Inst . getOperand ( DMaskIdx ) . getImm ( ) & <NUM_LIT> ;


<s> const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; if ( ! Desc . mayLoad ( ) || ! Desc . mayStore ( ) ) return true ; int DMaskIdx = <STR_LIT> ( Opc , <STR_LIT> :: dmask ) ; unsigned DMask = Inst . getOperand ( DMaskIdx ) . getImm ( ) & <NUM_LIT> ; return DMask == <NUM_LIT> || DMask == <NUM_LIT> || DMask == <NUM_LIT> ;


<s> const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; int D16Idx = <STR_LIT> ( Opc , <STR_LIT> :: d16 ) ; if ( D16Idx >= <NUM_LIT> && Inst . getOperand ( D16Idx ) . getImm ( ) ) { if ( isCI ( ) || is<ISA_LIT> ( ) ) return false ; } return true ;


<s> const unsigned Opc = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; int D16Idx = <STR_LIT> ( Opc , <STR_LIT> :: d16 ) ; if ( D16Idx >= <NUM_LIT> && Inst . getOperand ( D16Idx ) . getImm ( ) ) { if ( isCI ( ) || is<ISA_LIT> ( ) ) return false ; } return true ;


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

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


<s> int DimIdx = <STR_LIT> ( Opc , <STR_LIT> :: dim ) ; if ( DimIdx < <NUM_LIT> ) return true ; long Imm = Inst . getOperand ( DimIdx ) . getImm ( ) ; if ( Imm < <NUM_LIT> || Imm >= <NUM_LIT> ) return false ;


<s> const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ;

int DimIdx = <STR_LIT> ( Opc , <STR_LIT> :: dim ) ;


<s> bool <ISA_LIT>AsmParser :: validateMIMGGatherDMask ( const MCInst & Inst ) { const unsigned Opc = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; int DMaskIdx = <STR_LIT> ( Opc , <STR_LIT> :: dmask ) ; unsigned DMask = Inst . getOperand ( DMaskIdx ) . getImm ( ) & <NUM_LIT> ;

return DMask == <NUM_LIT> || DMask == <NUM_LIT> || DMask == <NUM_LIT> || DMask == <NUM_LIT> ;


<s> const unsigned Opc = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ;

int DMaskIdx = <STR_LIT> ( Opc , <STR_LIT> :: dmask ) ;


<s> const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; const <STR_LIT> * Info = <STR_LIT> ( Opc ) ; const <STR_LIT> * BaseOpcode = <STR_LIT> ( Info -> BaseOpcode ) ; if ( ! BaseOpcode -> MSAA ) return true ; int DimIdx = <STR_LIT> ( Opc , <STR_LIT> :: dim ) ; assert ( DimIdx != - <NUM_LIT> ) ;

unsigned Dim = Inst . getOperand ( DimIdx ) . getImm ( ) ;


<s> if ( Src0 . isReg ( ) ) { auto Reg = mc2PseudoReg ( Src0 . getReg ( ) ) ; const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; if ( ! isSGPR ( Reg , TRI ) ) return true ; ErrLoc = getRegLoc ( Reg , Operands ) ; } else {


<s> const int Src0Idx = <STR_LIT> ( Opc , <STR_LIT> :: src0 ) ; assert ( Src0Idx != - <NUM_LIT> ) ; SMLoc ErrLoc ; const MCOperand & Src0 = Inst . getOperand ( Src0Idx ) ; if ( Src0 . isReg ( ) ) { auto Reg = mc2PseudoReg ( Src0 . getReg ( ) ) ; const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; if ( ! isSGPR ( Reg , TRI ) ) return true ; ErrLoc = getRegLoc ( Reg , Operands ) ; } else { ErrLoc = getConstLoc ( Operands ) ; } Error ( ErrLoc , <STR_LIT> ) ;


<s> int OpSelIdx = <STR_LIT> ( Opc , <STR_LIT> :: op_sel ) ; unsigned OpSel = Inst . getOperand ( OpSelIdx ) . getImm ( ) ; if ( OpSel & ~ <NUM_LIT> ) return false ; } return true ;


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


<s> uint64_t TSFlags = MII . get ( Inst . getOpcode ( ) ) . TSFlags ; if ( ( TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; auto Opcode = Inst . getOpcode ( ) ; auto OpNum = <STR_LIT> ( Opcode , <STR_LIT> :: offset ) ; if ( OpNum == - <NUM_LIT> ) return true ; const auto & Op = Inst . getOperand ( OpNum ) ; if ( ! Op . isImm ( ) ) return true ; uint64_t Offset = Op . getImm ( ) ; bool IsBuffer = <STR_LIT> ( Opcode ) ; if ( <STR_LIT> ( getSTI ( ) , Offset ) || <STR_LIT> ( getSTI ( ) , Offset , IsBuffer ) ) return true ; Error ( getSMEMOffsetLoc ( Operands ) , ( isVI ( ) || IsBuffer ) ? <STR_LIT> :


<s> const int Src1Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src1 ) ; const int OpIndices [ ] = { Src0Idx , Src1Idx } ; 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 ( <STR_LIT> ( Desc , OpIdx ) ) { if ( MO . isImm ( ) && ! isInlineConstant ( Inst , OpIdx ) ) {

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


<s> const int Src1Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src1 ) ; const int OpIndices [ ] = { Src0Idx , Src1Idx } ; 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 ( <STR_LIT> ( Desc , OpIdx ) ) { 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 ; } } }

return NumLiterals + NumExprs <= <NUM_LIT> ;


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


<s> 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_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 ; case MCK_InterpSlot : return Operand . isInterpSlot ( ) ? Match_Success : Match_InvalidOperand ; case MCK_Attr :

return Operand . isInterpAttr ( ) ? Match_Success : Match_InvalidOperand ;


<s> auto FB = getFeatureBits ( ) ; return ( FB [ <STR_LIT> ] && Reg == <STR_LIT> ) || ( FB [ <STR_LIT> ] && Reg == <STR_LIT> ) ;


<s> const MCRegisterInfo * MRI = getMRI ( ) ; const MCRegisterClass & VGPR32 = MRI -> getRegClass ( <STR_LIT> ) ; const MCRegisterClass & AGPR32 = MRI -> getRegClass ( <STR_LIT> ) ; for ( unsigned I = <NUM_LIT> , E = Inst . getNumOperands ( ) ; I != E ; ++ I ) { const MCOperand & Op = Inst . getOperand ( I ) ; if ( ! Op . isReg ( ) ) continue ;

unsigned Sub = MRI -> getSubReg ( Op . getReg ( ) , <STR_LIT> ) ;


<s> } if ( MO . isImm ( ) && ! isInlineConstant ( Inst , OpIdx ) ) { uint32_t Value = static_cast < uint32_t > ( MO . getImm ( ) ) ; if ( NumLiterals == <NUM_LIT> || LiteralValue != Value ) { LiteralValue = Value ; ++ NumLiterals ; } } else if ( MO . isExpr ( ) ) { ++ NumExprs ; } } NumLiterals += NumExprs ; if ( ! NumLiterals ) return true ; if ( ImmIdx == - <NUM_LIT> && ! getFeatureBits ( ) [ <STR_LIT> ] ) { Error ( getLitLoc ( Operands ) , <STR_LIT> ) ; return false ; } if ( NumLiterals > <NUM_LIT> ) { Error ( getLitLoc ( Operands ) , <STR_LIT> ) ;


<s> const MCInstrDesc & Desc = MII . get ( Opcode ) ; const int ImmIdx = <STR_LIT> ( Opcode , <STR_LIT> :: imm ) ; if ( ! ( Desc . TSFlags & ( <STR_LIT> | <STR_LIT> ) ) && ImmIdx == - <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 OpIndices [ ] = { Src0Idx , Src1Idx , Src2Idx , ImmIdx } ; unsigned NumExprs = <NUM_LIT> ; unsigned NumLiterals = <NUM_LIT> ; uint32_t LiteralValue ; for ( int OpIdx : OpIndices ) { if ( OpIdx == - <NUM_LIT> ) continue ; const MCOperand & MO = Inst . getOperand ( OpIdx ) ; if ( ! MO . isImm ( ) && ! MO . isExpr ( ) ) continue ; if ( ! <STR_LIT> ( Desc , OpIdx ) ) continue ; if ( OpIdx == Src2Idx && ( Desc . TSFlags & <STR_LIT> ) && getFeatureBits ( ) [ <STR_LIT> ] ) { Error ( getConstLoc ( Operands ) , <STR_LIT> ) ; return false ; } if ( MO . isImm ( ) && ! isInlineConstant ( Inst , OpIdx ) ) { uint32_t Value = static_cast < uint32_t > ( MO . getImm ( ) ) ; if ( NumLiterals == <NUM_LIT> || LiteralValue != Value ) { LiteralValue = Value ; ++ NumLiterals ; } } else if ( MO . isExpr ( ) ) { ++ NumExprs ; } } NumLiterals += NumExprs ; if ( ! NumLiterals ) return true ; if ( ImmIdx == - <NUM_LIT> && ! getFeatureBits ( ) [ <STR_LIT> ] ) { Error ( getLitLoc ( Operands ) , <STR_LIT> ) ; return false ; }


<s> if ( AsmParser -> isVI ( ) ) return isVReg ( ) ; else if ( AsmParser -> isGFX9 ( ) ) return isRegKind ( ) ; else return false ;


<s> for ( auto Variant : getMatchedVariants ( ) ) { uint64_t EI ; auto R = MatchInstructionImpl ( Operands , Inst , EI , MatchingInlineAsm , Variant ) ; if ( ( R == Match_Success ) || ( R == Match_PreferE32 ) || ( R == Match_MissingFeature && Result != Match_PreferE32 ) || ( R == Match_InvalidOperand && Result != Match_MissingFeature && Result != Match_PreferE32 ) || ( R == Match_MnemonicFail && Result != Match_InvalidOperand && Result != Match_MissingFeature && Result != Match_PreferE32 ) ) { Result = R ; ErrorInfo = EI ; } if ( R == Match_Success ) break ; } switch ( Result ) { default : break ; case Match_Success : if ( ! validateInstruction ( Inst , IDLoc ) ) { return true ; } Inst . setLoc ( IDLoc ) ;

Out . EmitInstruction ( Inst , getSTI ( ) ) ;


<s> 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 ImmTyDFMT : OS << <STR_LIT> ; break ; case ImmTyNFMT : 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 ;


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


<s> bool <ISA_LIT>AsmParser :: validateInstruction ( const MCInst & Inst , const SMLoc & IDLoc ) { if ( ! validateConstantBusLimitations ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateEarlyClobberLimitations ( Inst ) ) {


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


<s> void <ISA_LIT>AsmParser :: cvtVOP3P ( MCInst & Inst , const OperandVector & Operands ) { cvtVOP3PImpl ( Inst , Operands , true ) ;


<s> cvtVOP3PImpl ( Inst , Operands , true ) ;


<s> unsigned OpSelHi = <NUM_LIT> ; unsigned NegLo = <NUM_LIT> ; unsigned NegHi = <NUM_LIT> ; if ( OpSelHiIdx != - <NUM_LIT> ) { OpSelHi = Inst . getOperand ( OpSelHiIdx ) . getImm ( ) ; } 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 ; uint32_t ModVal = <NUM_LIT> ; if ( ( OpSel & ( <NUM_LIT> << J ) ) != <NUM_LIT> ) ModVal |= <STR_LIT> ;

if ( ( OpSelHi & ( <NUM_LIT> << J ) ) != <NUM_LIT> ) ModVal |= <STR_LIT> ;


<s> void <ISA_LIT>AsmParser :: cvtVOP3P_NotPacked ( MCInst & Inst , const OperandVector & Operands ) { cvtVOP3PImpl ( Inst , Operands , false ) ;


<s> cvtVOP3PImpl ( Inst , Operands , false ) ;


<s> 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 ; 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 ImmTyHigh : OS << <STR_LIT> ; break ;


<s> void <ISA_LIT>AsmParser :: cvtD<ISA_LIT>mpl ( MCInst & Inst , const OperandVector & Operands , bool IsGdsHardcoded ) { OptionalImmIndexMap OptionalIdx ; for ( unsigned i = <NUM_LIT> , e = Operands . size ( ) ; i != e ; ++ i ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ i ] ) ; if ( Op . isReg ( ) ) { Op . addRegOperands ( Inst , <NUM_LIT> ) ; continue ; } if ( Op . isToken ( ) && Op . getToken ( ) == <STR_LIT> ) { IsGdsHardcoded = true ; continue ; } OptionalIdx [ Op . getImmTy ( ) ] = i ; } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyOffset ) ; if ( ! IsGdsHardcoded ) { addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyGDS ) ; }

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


<s> if ( Op . isImm ( ) && Op . getImmTy ( ) == <ISA_LIT>Operand :: ImmTyExpTgt ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; continue ; } if ( Op . isToken ( ) && Op . getToken ( ) == <STR_LIT> ) continue ; OptionalIdx [ Op . getImmTy ( ) ] = i ; } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyExpVM ) ;

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


<s> ++ SrcIdx ; continue ; } if ( Op . isOff ( ) ) { ++ SrcIdx ; Inst . addOperand ( MCOperand :: createReg ( <STR_LIT> ) ) ; continue ; } if ( Op . isImm ( ) && Op . getImmTy ( ) == <ISA_LIT>Operand :: ImmTyExpTgt ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; continue ; } if ( Op . isToken ( ) && Op . getToken ( ) == <STR_LIT> ) continue ;


<s> OptionalImmIndexMap OptionalIdx ; unsigned I = <NUM_LIT> ; const MCInstrDesc & Desc = MII . get ( Inst . getOpcode ( ) ) ; for ( unsigned J = <NUM_LIT> ; J < Desc . getNumDefs ( ) ; ++ J ) { ( ( <ISA_LIT>Operand & ) * Operands [ I ++ ] ) . addRegOperands ( Inst , <NUM_LIT> ) ; } for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( ( BasicInstType == <STR_LIT> || BasicInstType == <STR_LIT> ) && Op . isReg ( ) && Op . Reg . RegNo == <STR_LIT> ) { continue ; } else if ( isRegOrImmWithInputMods ( Desc , Inst . getNumOperands ( ) ) ) { Op . addRegWithInputModsOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isImm ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { llvm_unreachable ( <STR_LIT> ) ; } } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyClamp<ISA_LIT> , <NUM_LIT> ) ; if ( Inst . getOpcode ( ) != <STR_LIT> ) { switch ( BasicInstType ) { case <STR_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 ) ;


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

<ISA_LIT>AsmVariants :: DEFAULT , <ISA_LIT>AsmVariants :: VOP3 , <ISA_LIT>AsmVariants :: SDWA , <ISA_LIT>AsmVariants :: DPP } ;


<s> const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; const MCRegisterClass SGPRClass = TRI -> getRegClass ( <STR_LIT> ) ; const unsigned FirstSubReg = TRI -> getSubReg ( Reg , <NUM_LIT> ) ; return SGPRClass . contains ( FirstSubReg != <NUM_LIT> ? FirstSubReg : Reg ) || Reg == <STR_LIT> ;


<s> bool <ISA_LIT>AsmParser :: isSGPR ( unsigned Reg ) { const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; const MCRegisterClass SGPRClass = TRI -> getRegClass ( <STR_LIT> ) ; const unsigned FirstSubReg = TRI -> getSubReg ( Reg , <NUM_LIT> ) ; return SGPRClass . contains ( FirstSubReg != <NUM_LIT> ? FirstSubReg : Reg ) || Reg == <STR_LIT> ;


<s> int64_t CntVal ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: LParen ) ) return true ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return true ; if ( getParser ( ) . parseAbsoluteExpression ( CntVal ) ) return true ; if ( getLexer ( ) . isNot ( AsmToken :: RParen ) ) return true ; Parser . Lex ( ) ; if ( getLexer ( ) . is ( AsmToken :: Amp ) || getLexer ( ) . is ( AsmToken :: Comma ) ) Parser . Lex ( ) ; <STR_LIT> :: IsaVersion ISA = <STR_LIT> :: getIsaVersion ( getFeatureBits ( ) ) ; if ( CntName == <STR_LIT> ) IntVal = encodeVmcnt ( ISA , IntVal , CntVal ) ; else if ( CntName == <STR_LIT> ) IntVal = encodeExpcnt ( ISA , IntVal , CntVal ) ; else if ( CntName == <STR_LIT> ) IntVal = encodeLgkmcnt ( ISA , IntVal , CntVal ) ; else return true ; return false ;


<s> 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 ParseSectionDirectiveHSAText ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirective<ISA_LIT>HsaKernel ( ) ;

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


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


<s> 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 ; case ImmTyOpSelHi : OS << <STR_LIT> ; break ; case ImmTyNegLo : OS << <STR_LIT> ; break ; case ImmTyNegHi : OS << <STR_LIT> ; break ;


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


<s> if ( SGPRUsed != <STR_LIT> ) { ++ ConstantBusUseCount ; } const int Src0Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src0 ) ; const int Src1Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src1 ) ; const int Src2Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src2 ) ; const int OpIndices [ ] = { Src0Idx , Src1Idx , Src2Idx } ; for ( int OpIdx : OpIndices ) { if ( OpIdx == - <NUM_LIT> ) break ; const MCOperand & MO = Inst . getOperand ( OpIdx ) ; if ( usesConstantBus ( Inst , OpIdx ) ) { if ( MO . isReg ( ) ) { const unsigned Reg = mc2PseudoReg ( MO . getReg ( ) ) ; if ( Reg != SGPRUsed ) { ++ ConstantBusUseCount ; } SGPRUsed = Reg ; } else { ++ ConstantBusUseCount ; } }


<s> case ImmTyDFMT : OS << <STR_LIT> ; break ; case ImmTyNFMT : 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 ; case ImmTyOpSelHi : OS << <STR_LIT> ; break ;

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


<s> case ImmTyIdxen : OS << <STR_LIT> ; break ; case ImmTyAddr64 : OS << <STR_LIT> ; break ; case ImmTyOffset : OS << <STR_LIT> ; break ; case ImmTyInstOffset : 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 ImmTyD16 : OS << <STR_LIT> ; break ; case ImmTyDFMT : OS << <STR_LIT> ; break ; case ImmTyNFMT : 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 ;


<s> } if ( ! validateMIMGR128 ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGD16 ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGDataSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAtomicDMask ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGGatherDMask ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; }


<s> const unsigned Opc = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ;

return ! isCI ( ) && ! is<ISA_LIT> ( ) ;


<s> const unsigned Opc = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; if ( Desc . TSFlags & <STR_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> bool <ISA_LIT>AsmParser :: validateMIMGDataSize ( const MCInst & Inst ) { const unsigned Opc = Inst . getOpcode ( ) ; const MCInstrDesc & Desc = MII . get ( Opc ) ; if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; if ( Desc . TSFlags & <STR_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> ; unsigned DMask = Inst . getOperand ( DMaskIdx ) . getImm ( ) & <NUM_LIT> ; if ( DMask == <NUM_LIT> ) DMask = <NUM_LIT> ; unsigned DataSize = countPopulation ( DMask ) ; if ( ( Desc . TSFlags & <STR_LIT> ) != <NUM_LIT> && hasPackedD16 ( ) ) {

DataSize = ( DataSize + <NUM_LIT> ) / <NUM_LIT> ;


<s> if ( ( Desc . TSFlags & <STR_LIT> ) == <NUM_LIT> ) return true ; int Idx = <STR_LIT> ( Opc , <STR_LIT> :: r128 ) ; assert ( Idx != - <NUM_LIT> ) ; bool R128 = ( Inst . getOperand ( Idx ) . getImm ( ) != <NUM_LIT> ) ;


<s> unsigned <ISA_LIT>AsmParser :: validateTargetOperandClass ( MCParsedAsmOperand & Op , unsigned Kind ) { <ISA_LIT>Operand & Operand = ( <ISA_LIT>Operand & ) Op ; 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_d16 : return Operand . isD16 ( ) ? 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 ;


<s> case MCK_glc : return Operand . isGLC ( ) ? Match_Success : Match_InvalidOperand ; case MCK_d16 : return Operand . isD16 ( ) ? 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> return false ; } if ( ! validateEarlyClobberLimitations ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateIntClampSupported ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGD16 ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; }

if ( ! validateMIMGDataSize ( Inst ) ) {


<s> if ( ! validateMIMGD16 ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGDataSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAtomicDMask ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; }

if ( ! validateMIMGGatherDMask ( Inst ) ) {


<s> case ImmTyTFE : OS << <STR_LIT> ; break ; case ImmTyD16 : OS << <STR_LIT> ; break ; case ImmTyDFMT : OS << <STR_LIT> ; break ; case ImmTyNFMT : 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 ;


<s> bool <ISA_LIT>AsmParser :: validateInstruction ( const MCInst & Inst , const SMLoc & IDLoc ) { if ( ! validateConstantBusLimitations ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateEarlyClobberLimitations ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateIntClampSupported ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGR128 ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGD16 ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGDataSize ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } if ( ! validateMIMGAtomicDMask ( Inst ) ) { Error ( IDLoc , <STR_LIT> ) ; return false ; } return true ;


<s> MCSymbol * Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Major , Ctx ) ) ; } else { MCSymbol * Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Major , Ctx ) ) ; Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Minor , Ctx ) ) ; Sym = Ctx . getOrCreateSymbol ( Twine ( <STR_LIT> ) ) ; Sym -> setVariableValue ( MCConstantExpr :: create ( ISA . Stepping , Ctx ) ) ;


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

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


<s> IsaInfo :: IsaVersion Version = IsaInfo :: getIsaVersion ( Features ) ; unsigned NumVGPRs = NextFreeVGPR ; unsigned NumSGPRs = NextFreeSGPR ; unsigned MaxAddressableNumSGPRs = IsaInfo :: getAddressableNumSGPRs ( Features ) ; if ( Version . Major >= <NUM_LIT> && ! Features . test ( FeatureSGPRInitBug ) && NumSGPRs > MaxAddressableNumSGPRs ) return OutOfRangeError ( SGPRRange ) ; NumSGPRs += IsaInfo :: getNumExtraSGPRs ( Features , VCCUsed , FlatScrUsed , XNACKUsed ) ; if ( ( Version . Major <= <NUM_LIT> || Features . test ( FeatureSGPRInitBug ) ) && NumSGPRs > MaxAddressableNumSGPRs ) return OutOfRangeError ( SGPRRange ) ; if ( Features . test ( FeatureSGPRInitBug ) ) NumSGPRs = IsaInfo :: FIXED_NUM_SGPRS_FOR_INIT_BUG ; VGPRBlocks = IsaInfo :: getNumVGPRBlocks ( Features , NumVGPRs ) ;

SGPRBlocks = IsaInfo :: getNumSGPRBlocks ( Features , NumSGPRs ) ;


<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> ) ; } else if ( Op . isImmModifier ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else {


<s> bool <ISA_LIT>AsmParser :: ParseDirective ( AsmToken DirectiveID ) { StringRef IDVal = DirectiveID . getString ( ) ; if ( <STR_LIT> :: hasCodeObjectV3 ( & getSTI ( ) ) ) { if ( IDVal == <STR_LIT> ) return ParseDirectiveAMDGCNTarget ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirectiveAMDHSAKernel ( ) ; } else { if ( IDVal == <STR_LIT> ) return ParseDirectiveHSACodeObjectVersion ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirectiveHSACodeObjectISA ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirectiveAMDKernelCodeT ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirective<ISA_LIT>HsaKernel ( ) ;

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


<s> 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 ImmTyD16 : OS << <STR_LIT> ; break ; case ImmTyFORMAT : OS << <STR_LIT> ; break ; case ImmTyClamp<ISA_LIT> : OS << <STR_LIT> ; break ; case ImmTyOMod<ISA_LIT> : OS << <STR_LIT> ; break ; case 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 ;


<s> if ( <STR_LIT> :: getIsaVersion ( getFeatureBits ( ) ) . Major < <NUM_LIT> ) return true ; auto SymbolName = getGprCountSymbolName ( RegKind ) ; if ( ! SymbolName ) return true ; MCSymbol * Sym = getContext ( ) . getOrCreateSymbol ( * SymbolName ) ;

int64_t NewMax = DwordRegIndex + RegWidth - <NUM_LIT> ;


<s> int64_t NewMax = DwordRegIndex + RegWidth - <NUM_LIT> ; int64_t OldCount ; if ( ! Sym -> isVariable ( ) ) return ! Error ( getParser ( ) . getTok ( ) . getLoc ( ) , <STR_LIT> ) ; if ( ! Sym -> getVariableValue ( false ) -> evaluateAsAbsolute ( OldCount ) ) return ! Error ( getParser ( ) . getTok ( ) . getLoc ( ) , <STR_LIT> ) ;

if ( OldCount <= NewMax ) Sym -> setVariableValue ( MCConstantExpr :: create ( NewMax + <NUM_LIT> , getContext ( ) ) ) ;


<s> Val = - Val ; } } if ( <STR_LIT> ( AsmParser -> getMII ( ) -> get ( Inst . getOpcode ( ) ) , Inst . getNumOperands ( ) ) ) { addLiteralImmOperand ( Inst , Val ) ; } else {

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


<s> } llvm_unreachable ( <STR_LIT> ) ; case <NUM_LIT> : case <NUM_LIT> : { bool lost ; APFloat FPLiteral ( APFloat :: IEEEdouble ( ) , Literal ) ; FPLiteral . convert ( * getFltSemantics ( OpSize ) , APFloat :: rmNearestTiesToEven , & lost ) ; Inst . addOperand ( MCOperand :: createImm ( FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ) ) ; return ; } default : llvm_unreachable ( <STR_LIT> ) ; } return ; } switch ( OpSize ) { case <NUM_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 <NUM_LIT> : if ( <STR_LIT> ( Val , AsmParser -> hasInv2PiInlineImm ( ) ) ) { Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; return ; } Inst . addOperand ( MCOperand :: createImm ( Lo_32 ( Val ) ) ) ; return ; case <NUM_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 ; default : llvm_unreachable ( <STR_LIT> ) ;


<s> { <STR_LIT> Isa = <STR_LIT> ( getSTI ( ) . 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> <ISA_LIT>Operand ( enum KindTy Kind_ , const <ISA_LIT>AsmParser * AsmParser_ ) : MCParsedAsmOperand ( ) , Kind ( Kind_ ) , AsmParser ( AsmParser_ ) {


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


<s> continue ; } OptionalIdx [ Op . getImmTy ( ) ] = i ; } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyOffset ) ; if ( ! GDSOnly ) { addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyGDS ) ; } Inst . addOperand ( MCOperand :: createReg ( <STR_LIT> ) ) ;


<s> continue ; } if ( Op . isToken ( ) && Op . getToken ( ) == <STR_LIT> ) { GDSOnly = true ; continue ; } OptionalIdx [ Op . getImmTy ( ) ] = i ; } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyOffset ) ; if ( ! GDSOnly ) { addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyGDS ) ; } Inst . addOperand ( MCOperand :: createReg ( <STR_LIT> ) ) ;


<s> llvm_unreachable ( <STR_LIT> ) ; } } 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> ) { auto it = Inst . begin ( ) ; std :: advance ( it , <STR_LIT> ( Inst . getOpcode ( ) == <STR_LIT> ? <STR_LIT> : <STR_LIT> , <STR_LIT> :: src2_modifiers ) ) ;

it = Inst . insert ( it , MCOperand :: createImm ( <NUM_LIT> ) ) ;


<s> return getSTI ( ) . getFeatureBits ( ) [ <STR_LIT> ] ;


<s> if ( type . getScalarSizeInBits ( ) == <NUM_LIT> ) { return <STR_LIT> ( static_cast < int32_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> return <STR_LIT> ( static_cast < int32_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 ( ) ) ; }


<s> return false ; } if ( ! Imm . IsFPImm ) { unsigned Size = type . getSizeInBits ( ) ; if ( Size == <NUM_LIT> ) Size = <NUM_LIT> ; return isUIntN ( Size , Imm . Val ) || isIntN ( Size , Imm . Val ) ; } if ( type == <STR_LIT> ) { return true ; } if ( type == <STR_LIT> ) { return false ;


<s> return Error ( IDLoc , <STR_LIT> ) ; case Match_MnemonicFail : return Error ( IDLoc , <STR_LIT> ) ; case Match_InvalidOperand : { SMLoc ErrorLoc = IDLoc ; if ( ErrorInfo != ~ <NUM_LIT> ) { if ( ErrorInfo >= Operands . size ( ) ) { return Error ( IDLoc , <STR_LIT> ) ; } ErrorLoc = ( ( <ISA_LIT>Operand & ) * Operands [ ErrorInfo ] ) . getStartLoc ( ) ; if ( ErrorLoc == SMLoc ( ) ) ErrorLoc = IDLoc ; } return Error ( ErrorLoc , <STR_LIT> ) ; } case Match_PreferE32 : return Error ( IDLoc , <STR_LIT> <STR_LIT> ) ; } llvm_unreachable ( <STR_LIT> ) ;


<s> int64_t CntVal ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: LParen ) ) return true ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return true ; if ( getParser ( ) . parseAbsoluteExpression ( CntVal ) ) return true ;

if ( getLexer ( ) . isNot ( AsmToken :: RParen ) ) return true ;


<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> ) return ParseDirectiveRuntimeMetadata ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirectiveAMDKernelCodeT ( ) ; if ( IDVal == <STR_LIT> ) return ParseSectionDirectiveHSAText ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirective<ISA_LIT>HsaKernel ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirective<ISA_LIT>HsaModuleGlobal ( ) ; if ( IDVal == <STR_LIT> ) return ParseDirective<ISA_LIT>HsaProgramGlobal ( ) ; if ( IDVal == <STR_LIT> ) return ParseSectionDirectiveHSADataGlobalAgent ( ) ;


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


<s> } } MS << Parser . parseStringToEndOfStatement ( ) << getContext ( ) . getAsmInfo ( ) -> getSeparatorString ( ) ; Parser . eatToEndOfStatement ( ) ; } getLexer ( ) . setSkipSpace ( true ) ; if ( getLexer ( ) . is ( AsmToken :: Eof ) && ! FoundEnd ) return TokError ( <STR_LIT> ) ; MS . flush ( ) ; getTargetStreamer ( ) . EmitRuntimeMetadata ( Metadata ) ; return false ;


<s> case AsmToken :: Real : { int64_t IntVal ; if ( getParser ( ) . parseAbsoluteExpression ( IntVal ) ) return MatchOperand_ParseFail ; APFloat F ( BitsToDouble ( IntVal ) ) ; if ( Minus ) F . changeSign ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , F . bitcastToAPInt ( ) . getZExtValue ( ) , S , <ISA_LIT>Operand :: ImmTyNone , true ) ) ; return MatchOperand_Success ; } default : return Minus ? MatchOperand_ParseFail : MatchOperand_NoMatch ; }


<s> int64_t IntVal ; if ( getParser ( ) . parseAbsoluteExpression ( IntVal ) ) return MatchOperand_ParseFail ; APFloat F ( BitsToDouble ( IntVal ) ) ; if ( Minus ) F . changeSign ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , F . bitcastToAPInt ( ) . getZExtValue ( ) , S , <ISA_LIT>Operand :: ImmTyNone , true ) ) ; return MatchOperand_Success ;


<s> if ( ConvertResult && ! ConvertResult ( Value ) ) { return MatchOperand_ParseFail ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Value , S , ImmTy ) ) ; return MatchOperand_Success ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseNamedBit ( const char * Name , OperandVector & Operands , enum <ISA_LIT>Operand :: ImmTy ImmTy ) { int64_t Bit = <NUM_LIT> ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ;

if ( getLexer ( ) . isNot ( AsmToken :: EndOfStatement ) ) {


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


<s> OperandMatchResultTy res ; for ( const OptionalOperand & Op : <ISA_LIT>OptionalOperandTable ) { if ( Op . IsBit ) { res = parseNamedBit ( Op . Name , Operands , Op . Type ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> ) { res = parseOModOperand ( Operands ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTySdwaDstSel || Op . Type == <ISA_LIT>Operand :: ImmTySdwaSrc0Sel || Op . Type == <ISA_LIT>Operand :: ImmTySdwaSrc1Sel ) { res = parseSDWASel ( Operands , Op . Name , Op . Type ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTySdwaDstUnused ) { res = parseSDWADstUnused ( Operands ) ; } else { res = parseIntWithPrefix ( Op . Name , Operands , Op . Type , Op . ConvertResult ) ; } if ( res != MatchOperand_NoMatch ) { return res ;


<s> if ( res != MatchOperand_NoMatch ) { return res ;


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


<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 ; case ImmTyExpVM : OS << <STR_LIT> ; break ; case ImmTyHwreg : OS << <STR_LIT> ; break ; case ImmTySendMsg : OS << <STR_LIT> ; break ;


<s> ErrorInfo = EI ; } 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 ) ; return Error ( IDLoc , <STR_LIT> + Suggestion , ( ( <ISA_LIT>Operand & ) * Operands [ <NUM_LIT> ] ) . getLocRange ( ) ) ; } case Match_InvalidOperand : { SMLoc ErrorLoc = IDLoc ; if ( ErrorInfo != ~ <NUM_LIT> ) { if ( ErrorInfo >= Operands . size ( ) ) { return Error ( IDLoc , <STR_LIT> ) ; } ErrorLoc = ( ( <ISA_LIT>Operand & ) * Operands [ ErrorInfo ] ) . getStartLoc ( ) ; if ( ErrorLoc == SMLoc ( ) ) ErrorLoc = IDLoc ; } return Error ( ErrorLoc , <STR_LIT> ) ; } case Match_PreferE32 : return Error ( IDLoc , <STR_LIT> <STR_LIT> ) ;


<s> SmallVector < AsmToken , <NUM_LIT> > Tokens ; if ( Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth , Tokens ) ) { if ( RestoreOnFailure ) { while ( ! Tokens . empty ( ) ) { getLexer ( ) . UnLex ( Tokens . pop_back_val ( ) ) ;


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

} else KernelScope . usesRegister ( RegKind , RegNum , RegWidth ) ;


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


<s> unsigned NextReg , NextRegNum , NextRegWidth ; if ( ! Parse<ISA_LIT>Register ( NextRegKind , NextReg , NextRegNum , NextRegWidth , Tokens ) ) return <STR_LIT> ; 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 ) ;


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

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


<s> const_cast < <ISA_LIT>AsmParser * > ( AsmParser ) -> Warning ( Inst . getLoc ( ) , <STR_LIT> <STR_LIT> ) ; } Inst . addOperand ( MCOperand :: createImm ( Literal . lshr ( <NUM_LIT> ) . getZExtValue ( ) ) ) ; setImmKindLiteral ( ) ; return ; } llvm_unreachable ( <STR_LIT> ) ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : { bool lost ; APFloat FPLiteral ( APFloat :: IEEEdouble ( ) , Literal ) ; FPLiteral . convert ( * getOpFltSemantics ( OpTy ) , APFloat :: rmNearestTiesToEven , & lost ) ; uint64_t ImmVal = FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ; Inst . addOperand ( MCOperand :: createImm ( ImmVal ) ) ; setImmKindLiteral ( ) ; return ; } default : llvm_unreachable ( <STR_LIT> ) ; } return ; } switch ( OpTy ) { case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : if ( isSafeTruncation ( Val , <NUM_LIT> ) && <STR_LIT> ( static_cast < int32_t > ( Val ) , AsmParser -> hasInv2PiInlineImm ( ) ) ) { Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; setImmKindConst ( ) ; return ; } Inst . addOperand ( MCOperand :: createImm ( Val & <NUM_LIT> ) ) ; setImmKindLiteral ( ) ; return ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : if ( <STR_LIT> ( Val , AsmParser -> hasInv2PiInlineImm ( ) ) ) { Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; setImmKindConst ( ) ; return ; } Inst . addOperand ( MCOperand :: createImm ( Lo_32 ( Val ) ) ) ; setImmKindLiteral ( ) ; return ; case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


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


<s> ( ( <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> ) ; } else if ( Op . isImmModifier ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else if ( ! Op . isToken ( ) ) { llvm_unreachable ( <STR_LIT> ) ; } } bool IsGFX10Plus = isGFX10Plus ( ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDMask ) ; if ( IsGFX10Plus ) addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDim , - <NUM_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyUNorm ) ; if ( IsGFX10Plus ) addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDLC ) ;

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


<s> if ( Op . isImm ( ) && Op . getImmTy ( ) == <ISA_LIT>Operand :: ImmTyNone ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; continue ; } HasLdsModifier |= Op . isLDS ( ) ; if ( Op . isToken ( ) ) { continue ; } assert ( Op . isImm ( ) ) ; OptionalIdx [ Op . getImmTy ( ) ] = i ; } if ( IsLdsOpcode && ! HasLdsModifier ) { int NoLdsOpcode = <STR_LIT> ( Inst . getOpcode ( ) ) ; if ( NoLdsOpcode != - <NUM_LIT> ) { Inst . setOpcode ( NoLdsOpcode ) ; IsLdsOpcode = false ; } }

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


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


<s> <ISA_LIT>Operand :: Ptr <ISA_LIT>AsmParser :: defaultGLC_1 ( ) const { return <ISA_LIT>Operand :: CreateImm ( this , - <NUM_LIT> , SMLoc ( ) , <ISA_LIT>Operand :: ImmTyGLC ) ;


<s> bool <ISA_LIT>AsmParser :: isSupportedDPPCtrl ( StringRef Ctrl , const OperandVector & Operands ) { if ( Ctrl == <STR_LIT> || Ctrl == <STR_LIT> ) return isGFX10Plus ( ) ; if ( Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> ) return isVI ( ) || isGFX9 ( ) ;

return Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> ;


<s> return Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> || Ctrl == <STR_LIT> ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseDim ( OperandVector & Operands ) { if ( ! isGFX10Plus ( ) ) return MatchOperand_NoMatch ; SMLoc S = getLoc ( ) ; if ( ! trySkipId ( <STR_LIT> , AsmToken :: Colon ) ) return MatchOperand_NoMatch ; std :: string Token ; if ( isToken ( AsmToken :: Integer ) ) { SMLoc Loc = getToken ( ) . getEndLoc ( ) ; Token = std :: string ( getTokenStr ( ) ) ; lex ( ) ; if ( getLoc ( ) != Loc ) return MatchOperand_ParseFail ;


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

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


<s> raw_string_ostream ExpectedTargetOS ( ExpectedTarget ) ; IsaInfo :: streamIsaVersion ( & getSTI ( ) , ExpectedTargetOS ) ; if ( Target != ExpectedTargetOS . str ( ) ) return Error ( TargetRange . Start , <STR_LIT> , TargetRange ) ;

getTargetStreamer ( ) . EmitDirectiveAMDGCNTarget ( Target ) ;


<s> if ( ParseAsAbsoluteExpression ( Stepping ) ) return TokError ( <STR_LIT> ) ; if ( ! trySkipToken ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ; if ( ! parseString ( VendorName , <STR_LIT> ) ) return true ; if ( ! trySkipToken ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ;

if ( ! parseString ( ArchName , <STR_LIT> ) ) return true ;


<s> uint32_t Major ; uint32_t Minor ; uint32_t Stepping ; StringRef VendorName ; StringRef ArchName ; if ( isToken ( AsmToken :: EndOfStatement ) ) { <STR_LIT> ISA = <STR_LIT> ( getSTI ( ) . getCPU ( ) ) ; getTargetStreamer ( ) . EmitDirectiveHSACodeObjectISA ( ISA . Major , ISA . Minor , ISA . Stepping , <STR_LIT> , <STR_LIT> ) ; return false ; }

if ( ParseDirectiveMajorMinor ( Major , Minor ) ) return true ;


<s> if ( ParseToEndDirective ( AssemblerDirectiveBegin , AssemblerDirectiveEnd , HSAMetadataString ) ) return true ; if ( isHsaAbiVersion3 ( & getSTI ( ) ) ) { if ( ! getTargetStreamer ( ) . EmitHSAMetadataV3 ( HSAMetadataString ) ) return Error ( getLoc ( ) , <STR_LIT> ) ; } else { if ( ! getTargetStreamer ( ) . EmitHSAMetadataV2 ( HSAMetadataString ) ) return Error ( getLoc ( ) , <STR_LIT> ) ; } return false ;


<s> bool <ISA_LIT>AsmParser :: ParseDirectiveISAVersion ( ) { if ( getSTI ( ) . getTargetTriple ( ) . getArch ( ) != Triple :: amdgcn ) { return Error ( getLoc ( ) , <STR_LIT> <STR_LIT> ) ; } auto ISAVersionStringFromASM = getToken ( ) . getStringContents ( ) ; std :: string ISAVersionStringFromSTI ; raw_string_ostream ISAVersionStreamFromSTI ( ISAVersionStringFromSTI ) ; IsaInfo :: streamIsaVersion ( & getSTI ( ) , ISAVersionStreamFromSTI ) ;

if ( ISAVersionStringFromASM != ISAVersionStreamFromSTI . str ( ) ) {