<s> switch ( MatchInstructionImpl ( Operands , Inst , ErrorInfo , MatchingInlineAsm ) ) { default : break ; case Match_Success : Inst . setLoc ( IDLoc ) ; Out . EmitInstruction ( Inst , getSTI ( ) ) ; return false ; case Match_MissingFeature : 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 ( ) ) { if ( isForcedVOP3 ( ) ) { <ISA_LIT>Operand & LastOp = ( ( <ISA_LIT>Operand & ) * Operands [ Operands . size ( ) - <NUM_LIT> ] ) ;

if ( LastOp . isRegKind ( ) || ( LastOp . isImm ( ) && LastOp . getImmTy ( ) != <ISA_LIT>Operand :: ImmTyNone ) ) {


<s> if ( ( ParsedOp . isImm ( ) && ParsedOp . getImmTy ( ) == OOp . Type ) || ( ParsedOp . isToken ( ) && ParsedOp . getToken ( ) == OOp . Name ) ) return true ; }


<s> static bool operandsHasOptionalOp ( const OperandVector & Operands , const OptionalOperand & OOp ) { for ( unsigned i = <NUM_LIT> ; i < Operands . size ( ) ; i ++ ) { const <ISA_LIT>Operand & ParsedOp = ( ( const <ISA_LIT>Operand & ) * Operands [ i ] ) ;

if ( ( ParsedOp . isImm ( ) && ParsedOp . getImmTy ( ) == OOp . Type ) || ( ParsedOp . isToken ( ) && ParsedOp . getToken ( ) == OOp . Name ) ) return true ;


<s> if ( Op . isImm ( ) && ( Op . getImmTy ( ) == <ISA_LIT>Operand :: ImmTyOMod || Op . getImmTy ( ) == <ISA_LIT>Operand :: ImmTyClamp ) ) return true ; } return false ;


<s> Parser . Lex ( ) ; if ( getLexer ( ) . is ( AsmToken :: Amp ) || getLexer ( ) . is ( AsmToken :: Comma ) ) Parser . Lex ( ) ; int CntShift ; int CntMask ; if ( CntName == <STR_LIT> ) { CntMask = <NUM_LIT> ; CntShift = <NUM_LIT> ; } else if ( CntName == <STR_LIT> ) { CntMask = <NUM_LIT> ;


<s> 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> StringRef KernelName = Parser . getTok ( ) . getString ( ) ;

getTargetStreamer ( ) . Emit<ISA_LIT>SymbolType ( KernelName , ELF :: STT_<ISA_LIT>_HSA_KERNEL ) ;


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

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


<s> StringRef GlobalName = Parser . getTok ( ) . getIdentifier ( ) ;

getTargetStreamer ( ) . Emit<ISA_LIT>HsaModuleScopeGlobal ( GlobalName ) ;


<s> bool <ISA_LIT>AsmParser :: ParseDirective<ISA_LIT>HsaProgramGlobal ( ) { if ( getLexer ( ) . isNot ( AsmToken :: Identifier ) ) return TokError ( <STR_LIT> ) ; StringRef GlobalName = Parser . getTok ( ) . getIdentifier ( ) ; getTargetStreamer ( ) . Emit<ISA_LIT>HsaProgramScopeGlobal ( GlobalName ) ; Lex ( ) ; return false ;


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


<s> bool <ISA_LIT>AsmParser :: ParseDirectiveHSACodeObjectISA ( ) { uint32_t Major ; uint32_t Minor ; uint32_t Stepping ; StringRef VendorName ; StringRef ArchName ; if ( getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { <STR_LIT> Isa = <STR_LIT> ( getSTI ( ) . getFeatureBits ( ) ) ; getTargetStreamer ( ) . EmitDirectiveHSACodeObjectISA ( Isa . Major , Isa . Minor , Isa . Stepping , <STR_LIT> , <STR_LIT> ) ; return false ; } if ( ParseDirectiveMajorMinor ( Major , Minor ) ) return true ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return TokError ( <STR_LIT> ) ; Stepping = getLexer ( ) . getTok ( ) . getIntVal ( ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: String ) ) return TokError ( <STR_LIT> ) ; VendorName = getLexer ( ) . getTok ( ) . getStringContents ( ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: String ) ) return TokError ( <STR_LIT> ) ;

ArchName = getLexer ( ) . getTok ( ) . getStringContents ( ) ;


<s> <STR_LIT> Isa = <STR_LIT> ( getSTI ( ) . getFeatureBits ( ) ) ; getTargetStreamer ( ) . EmitDirectiveHSACodeObjectISA ( Isa . Major , Isa . Minor , Isa . Stepping , <STR_LIT> , <STR_LIT> ) ; return false ; } if ( ParseDirectiveMajorMinor ( Major , Minor ) ) return true ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return TokError ( <STR_LIT> ) ; Stepping = getLexer ( ) . getTok ( ) . getIntVal ( ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: String ) ) return TokError ( <STR_LIT> ) ;

VendorName = getLexer ( ) . getTok ( ) . getStringContents ( ) ;


<s> uint32_t Major ; uint32_t Minor ; if ( ParseDirectiveMajorMinor ( Major , Minor ) ) return true ; getTargetStreamer ( ) . EmitDirectiveHSACodeObjectVersion ( Major , Minor ) ;


<s> uint32_t Minor ; if ( ParseDirectiveMajorMinor ( Major , Minor ) ) return true ; getTargetStreamer ( ) . EmitDirectiveHSACodeObjectVersion ( Major , Minor ) ;


<s> bool <ISA_LIT>AsmParser :: ParseDirectiveMajorMinor ( uint32_t & Major , uint32_t & Minor ) { if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return TokError ( <STR_LIT> ) ; Major = getLexer ( ) . getTok ( ) . getIntVal ( ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ;


<s> if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ; Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return TokError ( <STR_LIT> ) ; Minor = getLexer ( ) . getTok ( ) . getIntVal ( ) ; Lex ( ) ;


<s> return parseIntWithPrefix ( <STR_LIT> , Operands ) ;


<s> <ISA_LIT>AsmParser :: OperandMatchResultTy <ISA_LIT>AsmParser :: parseDMask ( OperandVector & Operands ) { return parseIntWithPrefix ( <STR_LIT> , Operands ) ;


<s> return parseOptionalOps ( DSOptionalOpsOff01 , Operands ) ;


<s> Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( <NUM_LIT> , S , <ISA_LIT>Operand :: ImmTyOffset ) ) ; Res = MatchOperand_Success ;


<s> SMLoc S = Parser . getTok ( ) . getLoc ( ) ; <ISA_LIT>AsmParser :: OperandMatchResultTy Res = parseIntWithPrefix ( <STR_LIT> , Operands , <ISA_LIT>Operand :: ImmTyOffset ) ; if ( Res == MatchOperand_NoMatch ) { Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( <NUM_LIT> , S , <ISA_LIT>Operand :: ImmTyOffset ) ) ;


<s> return parseOptionalOps ( DSOptionalOps , Operands ) ;


<s> return parseOptionalOps ( FlatAtomicOptionalOps , Operands ) ;


<s> <ISA_LIT>AsmParser :: OperandMatchResultTy <ISA_LIT>AsmParser :: parseFlatOptionalOps ( OperandVector & Operands ) { return parseOptionalOps ( FlatOptionalOps , Operands ) ;


<s> return parseNamedBit ( <STR_LIT> , Operands ) ;


<s> if ( Name . endswith ( <STR_LIT> ) ) setForcedEncodingSize ( <NUM_LIT> ) ; else if ( Name . endswith ( <STR_LIT> ) ) setForcedEncodingSize ( <NUM_LIT> ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateToken ( Name , NameLoc ) ) ; while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { <ISA_LIT>AsmParser :: OperandMatchResultTy Res = parseOperand ( Operands , Name ) ; if ( getLexer ( ) . is ( AsmToken :: Comma ) ) Parser . Lex ( ) ; switch ( Res ) { case MatchOperand_Success : break ; case MatchOperand_ParseFail : return Error ( getLexer ( ) . getLoc ( ) , <STR_LIT> ) ; case MatchOperand_NoMatch : return Error ( getLexer ( ) . getLoc ( ) , <STR_LIT> ) ; } }

<ISA_LIT>AsmParser :: OperandMatchResultTy Res ;


<s> <ISA_LIT>AsmParser :: OperandMatchResultTy <ISA_LIT>AsmParser :: parseIntWithPrefix ( const char * Prefix , OperandVector & Operands , enum <ISA_LIT>Operand :: ImmTy ImmTy ) { SMLoc S = Parser . getTok ( ) . getLoc ( ) ; int64_t Offset = <NUM_LIT> ; <ISA_LIT>AsmParser :: OperandMatchResultTy Res = parseIntWithPrefix ( Prefix , Offset ) ; if ( Res != MatchOperand_Success ) return Res ;

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


<s> int64_t Offset = <NUM_LIT> ; <ISA_LIT>AsmParser :: OperandMatchResultTy Res = parseIntWithPrefix ( Prefix , Offset ) ; if ( Res != MatchOperand_Success ) return Res ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( Offset , S , ImmTy ) ) ; return MatchOperand_Success ;


<s> return parseOptionalOps ( MubufOptionalOps , Operands ) ;


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


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

return parseIntWithPrefix ( <STR_LIT> , Operands ) ;


<s> case AsmToken :: Integer : { SMLoc S = Parser . getTok ( ) . getLoc ( ) ; int64_t IntVal ; if ( getParser ( ) . parseAbsoluteExpression ( IntVal ) ) return MatchOperand_ParseFail ; if ( ! isInt < <NUM_LIT> > ( IntVal ) && ! isUInt < <NUM_LIT> > ( IntVal ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( Negate ) IntVal *= - <NUM_LIT> ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( IntVal , S ) ) ; return MatchOperand_Success ; } case AsmToken :: Real : { SMLoc S = Parser . getTok ( ) . getLoc ( ) ; int64_t IntVal ; if ( getParser ( ) . parseAbsoluteExpression ( IntVal ) ) return MatchOperand_ParseFail ; APFloat F ( ( float ) BitsToDouble ( IntVal ) ) ; if ( Negate ) F . changeSign ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( F . bitcastToAPInt ( ) . getZExtValue ( ) , S ) ) ; return MatchOperand_Success ; } case AsmToken :: Identifier : { SMLoc S , E ; unsigned RegNo ; if ( ! ParseRegister ( RegNo , S , E ) ) { bool HasModifiers = operandsHaveModifiers ( Operands ) ; unsigned Modifiers = <NUM_LIT> ; if ( Negate ) Modifiers |= <NUM_LIT> ; if ( Abs ) {

if ( getLexer ( ) . getKind ( ) != AsmToken :: Pipe ) return MatchOperand_ParseFail ;


<s> Res = parseNamedBit ( Op . Name , Operands , Op . Type ) ; if ( Res == MatchOperand_NoMatch ) continue ; return Res ; } Res = parseIntWithPrefix ( Op . Name , Value , Op . Default ) ; if ( Res == MatchOperand_NoMatch ) continue ; if ( Res != MatchOperand_Success ) return Res ; if ( Op . ConvertResult && ! Op . ConvertResult ( Value ) ) { return MatchOperand_ParseFail ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( Value , S , Op . Type ) ) ; return MatchOperand_Success ; }


<s> getParser ( ) . getStreamer ( ) . SwitchSection ( <STR_LIT> ( getContext ( ) ) ) ; return false ;


<s> bool <ISA_LIT>AsmParser :: ParseSectionDirectiveHSADataGlobalAgent ( ) {

getParser ( ) . getStreamer ( ) . SwitchSection ( <STR_LIT> ( getContext ( ) ) ) ;


<s> getParser ( ) . getStreamer ( ) . SwitchSection ( <STR_LIT> ( getContext ( ) ) ) ;


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


<s> if ( getParser ( ) . parseAbsoluteExpression ( CntVal ) ) return MatchOperand_ParseFail ; break ; case AsmToken :: Identifier : do { if ( parseCnt ( CntVal ) ) return MatchOperand_ParseFail ; } while ( getLexer ( ) . isNot ( AsmToken :: EndOfStatement ) ) ; break ; }

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


<s> <ISA_LIT>AsmParser :: OperandMatchResultTy <ISA_LIT>AsmParser :: parseTFE ( OperandVector & Operands ) { return parseNamedBit ( <STR_LIT> , Operands ) ;


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

return parseNamedBit ( <STR_LIT> , Operands ) ;


<s> for ( unsigned i = <NUM_LIT> , e = Operands . size ( ) ; i != e ; ++ i ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ i ] ) ; if ( Op . isReg ( ) ) Op . setModifiers ( <NUM_LIT> ) ;


<s> bool IsVOP3 = isVOP3 ( Operands ) ; if ( HasModifiers || IsVOP3 || getLexer ( ) . isNot ( AsmToken :: EndOfStatement ) || getForcedEncodingSize ( ) == <NUM_LIT> ) { <ISA_LIT>AsmParser :: OperandMatchResultTy Res = parseOptionalOps ( VOP3OptionalOps , Operands ) ; if ( ! HasModifiers && Res == MatchOperand_Success ) { for ( unsigned i = <NUM_LIT> , e = Operands . size ( ) ; i != e ; ++ i ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ i ] ) ; if ( Op . isReg ( ) ) Op . setModifiers ( <NUM_LIT> ) ; }


<s> case Token : OS << '\'' << getToken ( ) << '\'' ; break ; case Expression : OS << <STR_LIT> << * Expr << '>' ; break ;


<s> case Token : OS << '\'' << getToken ( ) << '\'' ; break ; case Expression : OS << <STR_LIT> << * Expr << '>' ; break ; }


<s> void setForcedEncodingSize ( unsigned Size ) {


<s> void setModifiers ( unsigned Mods ) { assert ( isReg ( ) ) ;


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


<s> default : return true ; } } for ( MCRegAliasIterator R ( <STR_LIT> , & MRI , true ) ; R . isValid ( ) ; ++ R ) { if ( * R == RegNo ) return false ; }


<s> } Val = F . bitcastToAPInt ( ) . getZExtValue ( ) ; } else { Val = Negate ? - Val : Val ; } Inst . addOperand ( MCOperand :: createImm ( Val ) ) ; } else {

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


<s> if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } if ( Reg == <STR_LIT> && Reg1 == <STR_LIT> ) { Reg = <STR_LIT> ; RegWidth = <NUM_LIT> ; return true ; } return false ; case IS_VGPR : case IS_SGPR : case IS_TTMP : if ( Reg1 != Reg + RegWidth ) { return false ; } RegWidth ++ ; return true ; default : assert ( false ) ; return false ;


<s> if ( i != OptionalIdx . end ( ) ) { unsigned Idx = i -> second ; ( ( <ISA_LIT>Operand & ) * Operands [ Idx ] ) . addImmOperands ( Inst , <NUM_LIT> ) ; } else { Inst . addOperand ( MCOperand :: createImm ( Default ) ) ; }


<s> ( ( <ISA_LIT>Operand & ) * Operands [ Idx ] ) . addImmOperands ( Inst , <NUM_LIT> ) ; } else { Inst . addOperand ( MCOperand :: createImm ( Default ) ) ; }


<s> if ( getSTI ( ) . getFeatureBits ( ) . none ( ) ) { copySTI ( ) . ToggleFeature ( <STR_LIT> ) ; } setAvailableFeatures ( ComputeAvailableFeatures ( getSTI ( ) . getFeatureBits ( ) ) ) ; { <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> } setAvailableFeatures ( ComputeAvailableFeatures ( getSTI ( ) . getFeatureBits ( ) ) ) ; { <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> ) ) ;


<s> if ( ( getForcedEncodingSize ( ) == <NUM_LIT> && ( TSFlags & <STR_LIT> ) ) || ( getForcedEncodingSize ( ) == <NUM_LIT> && ! ( TSFlags & <STR_LIT> ) ) || ( isForcedDPP ( ) && ! ( TSFlags & <STR_LIT> ) ) || ( isForcedSDWA ( ) && ! ( TSFlags & <STR_LIT> ) ) ) return Match_InvalidOperand ; if ( ( TSFlags & <STR_LIT> ) && ( TSFlags & <STR_LIT> ) && getForcedEncodingSize ( ) != <NUM_LIT> ) return Match_PreferE32 ; return Match_Success ;


<s> } else if ( BoundCtrl == - <NUM_LIT> ) {


<s> if ( BoundCtrl == <NUM_LIT> ) { BoundCtrl = <NUM_LIT> ;


<s> auto Op = llvm :: make_unique < <ISA_LIT>Operand > ( Expression ) ; Op -> Expr = Expr ;


<s> Op -> Imm . IsFPImm = IsFPImm ; Op -> Imm . Type = Type ;

Op -> Imm . Mods = { false , false , false } ;


<s> Op -> Imm . Type = Type ; Op -> Imm . Mods = { false , false , false } ; Op -> StartLoc = Loc ; Op -> EndLoc = Loc ;


<s> static <ISA_LIT>Operand :: Ptr CreateReg ( unsigned RegNo , SMLoc S , SMLoc E , const MCRegisterInfo * TRI , const MCSubtargetInfo * STI , bool ForceVOP3 ) {

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


<s> Res -> Tok . Data = Str . data ( ) ;


<s> Op . addRegOrImmWithFPInputModsOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isDPPCtrl ( ) ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isImm ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { llvm_unreachable ( <STR_LIT> ) ; } } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppRowMask , <NUM_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppBankMask , <NUM_LIT> ) ;

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


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


<s> ( ( <ISA_LIT>Operand & ) * Operands [ I ++ ] ) . addRegOperands ( Inst , <NUM_LIT> ) ; }

for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) . addRegOrImmOperands ( Inst , <NUM_LIT> ) ;


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


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


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

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


<s> void cvtMubufAtomic ( MCInst & Inst , const OperandVector & Operands ) {

cvtMubufImpl ( Inst , Operands , true , false ) ;


<s> void cvtMubufAtomic ( MCInst & Inst , const OperandVector & Operands ) { cvtMubufImpl ( Inst , Operands , true , false ) ;


<s> } 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> ) { return ; } switch ( BasicInstType ) { case <STR_LIT> : { addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaDstSel , <NUM_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaDstUnused , <NUM_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySdwaSrc0Sel , <NUM_LIT> ) ; break ; } case <STR_LIT> : {


<s> 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> && Op . isReg ( ) && Op . Reg . RegNo == <STR_LIT> ) { continue ; } else if ( Op . isRegOrImmWithInputMods ( ) ) { Op . addRegOrImmWithInputModsOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isImm ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { llvm_unreachable ( <STR_LIT> ) ;


<s> void <ISA_LIT>AsmParser :: cvtSdwaVOPC ( MCInst & Inst , const OperandVector & Operands ) { cvtSDWA ( Inst , Operands , <STR_LIT> ) ;


<s> for ( unsigned E = Operands . size ( ) ; I != E ; ++ I ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isRegOrImmWithInputMods ( ) ) { Op . addRegOrImmWithFPInputModsOperands ( Inst , <NUM_LIT> ) ;


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

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


<s> if ( TSFlags & <STR_LIT> ) { cvtVOP3 ( Inst , Operands ) ; } else { cvtId ( Inst , Operands ) ; }


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


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


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


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

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


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


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


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


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


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

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


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


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

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


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


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

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


<s> int64_t Operand = <NUM_LIT> ; Operand |= Abs ? <STR_LIT> : <NUM_LIT> ;

Operand |= Neg ? <STR_LIT> : <NUM_LIT> ;


<s> int64_t getFPModifiersOperand ( ) const { int64_t Operand = <NUM_LIT> ;

Operand |= Abs ? <STR_LIT> : <NUM_LIT> ;


<s> int64_t getIntModifiersOperand ( ) const { int64_t Operand = <NUM_LIT> ; Operand |= Sext ? <STR_LIT> : <NUM_LIT> ;


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


<s> bool result = isImm ( ) && getImmTy ( ) == ImmTyDppCtrl && isUInt < <NUM_LIT> > ( getImm ( ) ) ; if ( result ) { int64_t Imm = getImm ( ) ;


<s> bool result = isImm ( ) && getImmTy ( ) == ImmTyDppCtrl && isUInt < <NUM_LIT> > ( getImm ( ) ) ; if ( result ) { int64_t Imm = getImm ( ) ; return ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) || ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) || ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) || ( ( Imm >= <NUM_LIT> ) && ( Imm <= <NUM_LIT> ) ) || ( Imm == <NUM_LIT> ) || ( Imm == <NUM_LIT> ) || ( Imm == <NUM_LIT> ) || ( Imm == <NUM_LIT> ) || ( Imm == <NUM_LIT> ) || ( Imm == <NUM_LIT> ) || ( Imm == <NUM_LIT> ) || ( Imm == <NUM_LIT> ) ;


<s> return false ; } const float F = BitsToFloat ( Imm . Val ) ; return ( Imm . Val <= <NUM_LIT> && Imm . Val >= - <NUM_LIT> ) || ( F == <NUM_LIT> || F == <NUM_LIT> || F == - <NUM_LIT> || F == <NUM_LIT> || F == - <NUM_LIT> || F == <NUM_LIT> || F == - <NUM_LIT> || F == <NUM_LIT> || F == - <NUM_LIT> ) ;


<s> } const float F = BitsToFloat ( Imm . Val ) ;

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


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


<s> bool isReg ( ) const override { return isRegKind ( ) && ! Reg . Mods . hasModifiers ( ) ;


return isRegKind ( ) && ! Reg . Mods . hasModifiers ( ) ;


<s> bool isRegClass ( unsigned RCID ) const {

return isReg ( ) && Reg . TRI -> getRegClass ( RCID ) . contains ( getReg ( ) ) ;


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


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


<s> return isImm ( ) || isSCSrc32 ( ) || isExpr ( ) ;


<s> bool isSSrc64 ( ) const { return isImm ( ) || isSCSrc64 ( ) ;


<s> if ( Kind != Expression || ! Expr ) return false ; return isa < MCSymbolRefExpr > ( Expr ) ;


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


<s> bool isVSrc64 ( ) const { return isImm ( ) || isVCSrc64 ( ) ;


<s> bool <ISA_LIT>AsmParser :: MatchAndEmitInstruction ( SMLoc IDLoc , unsigned & Opcode , OperandVector & Operands , MCStreamer & Out , uint64_t & ErrorInfo , bool MatchingInlineAsm ) { MCInst Inst ; switch ( MatchInstructionImpl ( Operands , Inst , ErrorInfo , MatchingInlineAsm ) ) { default : break ; case Match_Success : Inst . setLoc ( IDLoc ) ; Out . EmitInstruction ( Inst , getSTI ( ) ) ; return false ; case Match_MissingFeature : 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> ) ;


<s> OperandInfoTy ( int64_t Id_ ) : Id ( Id_ ) , IsSymbolic ( false ) {


<s> if ( getParser ( ) . parseAbsoluteExpression ( RegLo ) ) return false ; const bool isRBrace = getLexer ( ) . is ( AsmToken :: RBrac ) ; if ( ! isRBrace && getLexer ( ) . isNot ( AsmToken :: Colon ) ) return false ; Parser . Lex ( ) ; if ( isRBrace ) { RegHi = RegLo ; } else { if ( getParser ( ) . parseAbsoluteExpression ( RegHi ) ) return false ; if ( getLexer ( ) . isNot ( AsmToken :: RBrac ) ) return false ; Parser . Lex ( ) ; } RegNum = ( unsigned ) RegLo ; RegWidth = ( RegHi - RegLo ) + <NUM_LIT> ; } } } else if ( getLexer ( ) . is ( AsmToken :: LBrac ) ) { Parser . Lex ( ) ; if ( ! Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth ) ) return false ; if ( RegWidth != <NUM_LIT> ) return false ; RegisterKind RegKind1 ; unsigned Reg1 , RegNum1 , RegWidth1 ; do { if ( getLexer ( ) . is ( AsmToken :: Comma ) ) { Parser . Lex ( ) ; } else if ( getLexer ( ) . is ( AsmToken :: RBrac ) ) { Parser . Lex ( ) ; break ; } else if ( Parse<ISA_LIT>Register ( RegKind1 , Reg1 , RegNum1 , RegWidth1 ) ) { if ( RegWidth1 != <NUM_LIT> ) { return false ; } if ( RegKind1 != RegKind ) { return false ; } if ( ! AddNextRegisterToList ( Reg , RegWidth , RegKind1 , Reg1 , RegNum1 ) ) { return false ; } } else { return false ; } } while ( true ) ; } else { return false ; } switch ( RegKind ) { case IS_SPECIAL : RegNum = <NUM_LIT> ;


<s> RegKind = IS_SPECIAL ; } else { unsigned RegNumIndex = <NUM_LIT> ; if ( RegName [ <NUM_LIT> ] == 'v' ) { RegNumIndex = <NUM_LIT> ; RegKind = IS_VGPR ; } else if ( RegName [ <NUM_LIT> ] == 's' ) { RegNumIndex = <NUM_LIT> ; RegKind = IS_SGPR ; } else if ( RegName . startswith ( <STR_LIT> ) ) { RegNumIndex = strlen ( <STR_LIT> ) ; RegKind = IS_TTMP ; } else { return false ; } if ( RegName . size ( ) > RegNumIndex ) { if ( RegName . substr ( RegNumIndex ) . getAsInteger ( <NUM_LIT> , RegNum ) ) return false ; Parser . Lex ( ) ; RegWidth = <NUM_LIT> ; } else { Parser . Lex ( ) ; int64_t RegLo , RegHi ; if ( getLexer ( ) . isNot ( AsmToken :: LBrac ) ) return false ; Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( RegLo ) ) return false ; const bool isRBrace = getLexer ( ) . is ( AsmToken :: RBrac ) ; if ( ! isRBrace && getLexer ( ) . isNot ( AsmToken :: Colon ) ) return false ; Parser . Lex ( ) ; if ( isRBrace ) { RegHi = RegLo ; } else { if ( getParser ( ) . parseAbsoluteExpression ( RegHi ) ) return false ; if ( getLexer ( ) . isNot ( AsmToken :: RBrac ) ) return false ; Parser . Lex ( ) ; } RegNum = ( unsigned ) RegLo ; RegWidth = ( RegHi - RegLo ) + <NUM_LIT> ; } }

} else if ( getLexer ( ) . is ( AsmToken :: LBrac ) ) {


<s> bool <ISA_LIT>AsmParser :: ParseAMDKernelCodeTValue ( StringRef ID , amd_kernel_code_t & Header ) {


<s> Parser . Lex ( ) ; if ( getLexer ( ) . is ( AsmToken :: Amp ) || getLexer ( ) . is ( AsmToken :: Comma ) ) Parser . Lex ( ) ; int CntShift ; int CntMask ; if ( CntName == <STR_LIT> ) { CntMask = <NUM_LIT> ; CntShift = <NUM_LIT> ; } else if ( CntName == <STR_LIT> ) { CntMask = <NUM_LIT> ; CntShift = <NUM_LIT> ; } else if ( CntName == <STR_LIT> ) { CntMask = <NUM_LIT> ;


<s> 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 ( ) ; int CntShift ; int CntMask ; if ( CntName == <STR_LIT> ) {


<s> 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> if ( IDVal == <STR_LIT> ) return ParseDirectiveHSACodeObjectISA ( ) ; 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> int64_t Offset = OFFSET_DEFAULT_ ; int64_t Width = WIDTH_M1_DEFAULT_ + <NUM_LIT> ; if ( parseHwregConstruct ( HwReg , Offset , Width ) ) return MatchOperand_ParseFail ; if ( HwReg . Id < <NUM_LIT> || ! isUInt < ID_WIDTH_ > ( HwReg . Id ) ) { if ( HwReg . IsSymbolic ) Error ( S , <STR_LIT> ) ; else Error ( S , <STR_LIT> ) ; } if ( Offset < <NUM_LIT> || ! isUInt < OFFSET_WIDTH_ > ( Offset ) ) Error ( S , <STR_LIT> ) ; if ( ( Width - <NUM_LIT> ) < <NUM_LIT> || ! isUInt < WIDTH_M1_WIDTH_ > ( Width - <NUM_LIT> ) ) Error ( S , <STR_LIT> ) ; Imm16Val = ( HwReg . Id << ID_SHIFT_ ) | ( Offset << OFFSET_SHIFT_ ) | ( ( Width - <NUM_LIT> ) << WIDTH_M1_SHIFT_ ) ; } break ;


<s> } Parser . Lex ( ) ; } else { HwReg . IsSymbolic = false ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return true ; if ( getParser ( ) . parseAbsoluteExpression ( HwReg . Id ) ) return true ; } if ( getLexer ( ) . is ( AsmToken :: RParen ) ) { Parser . Lex ( ) ; return false ; } if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return true ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return true ; if ( getParser ( ) . parseAbsoluteExpression ( Offset ) ) return true ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return true ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return true ; if ( getParser ( ) . parseAbsoluteExpression ( Width ) ) return true ;

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


<s> Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: LParen ) ) return true ; Parser . Lex ( ) ; if ( getLexer ( ) . is ( AsmToken :: Identifier ) ) { HwReg . IsSymbolic = true ; HwReg . Id = ID_UNKNOWN_ ; const StringRef tok = Parser . getTok ( ) . getString ( ) ; for ( int i = ID_SYMBOLIC_FIRST_ ; i < ID_SYMBOLIC_LAST_ ; ++ i ) { if ( tok == IdSymbolic [ i ] ) { HwReg . Id = i ; break ; } } Parser . Lex ( ) ; } else { HwReg . IsSymbolic = false ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return true ;

if ( getParser ( ) . parseAbsoluteExpression ( HwReg . Id ) ) return true ;


<s> <ISA_LIT>AsmParser :: OperandMatchResultTy <ISA_LIT>AsmParser :: parseImm ( OperandVector & Operands ) { bool Minus = false ; if ( getLexer ( ) . getKind ( ) == AsmToken :: Minus ) { Minus = true ; Parser . Lex ( ) ; } SMLoc S = Parser . getTok ( ) . getLoc ( ) ; switch ( getLexer ( ) . getKind ( ) ) { case AsmToken :: Integer : { int64_t IntVal ; if ( getParser ( ) . parseAbsoluteExpression ( IntVal ) ) return MatchOperand_ParseFail ; if ( ! isInt < <NUM_LIT> > ( IntVal ) && ! isUInt < <NUM_LIT> > ( IntVal ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } if ( Minus ) IntVal *= - <NUM_LIT> ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( IntVal , S ) ) ; return MatchOperand_Success ; } case AsmToken :: Real : { int64_t IntVal ;


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


<s> bool <ISA_LIT>AsmParser :: ParseInstruction ( ParseInstructionInfo & Info , StringRef Name , SMLoc NameLoc , OperandVector & Operands ) { Name = parseMnemonicSuffix ( Name ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateToken ( Name , NameLoc ) ) ; while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { <ISA_LIT>AsmParser :: OperandMatchResultTy Res = parseOperand ( Operands , Name ) ; if ( getLexer ( ) . is ( AsmToken :: Comma ) ) Parser . Lex ( ) ; switch ( Res ) { case MatchOperand_Success : break ; case MatchOperand_ParseFail : Error ( getLexer ( ) . getLoc ( ) , <STR_LIT> ) ; while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { Parser . Lex ( ) ; } return true ; case MatchOperand_NoMatch : Error ( getLexer ( ) . getLoc ( ) , <STR_LIT> ) ; while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { Parser . Lex ( ) ; } return true ;


<s> <ISA_LIT>AsmParser :: OperandMatchResultTy <ISA_LIT>AsmParser :: parseIntWithPrefix ( const char * Prefix , OperandVector & Operands , enum <ISA_LIT>Operand :: ImmTy ImmTy , bool ( * ConvertResult ) ( int64_t & ) ) { SMLoc S = Parser . getTok ( ) . getLoc ( ) ; int64_t Value = <NUM_LIT> ; <ISA_LIT>AsmParser :: OperandMatchResultTy Res = parseIntWithPrefix ( Prefix , Value ) ; if ( Res != MatchOperand_Success ) return Res ; if ( ConvertResult && ! ConvertResult ( Value ) ) { return MatchOperand_ParseFail ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( Value , S , ImmTy ) ) ; return MatchOperand_Success ;


<s> } else if ( Name == <STR_LIT> ) { return parseIntWithPrefix ( <STR_LIT> , Operands , <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> , ConvertOmodDiv ) ; } else {


<s> <ISA_LIT>AsmParser :: OperandMatchResultTy <ISA_LIT>AsmParser :: parseOperand ( OperandVector & Operands , StringRef Mnemonic ) { OperandMatchResultTy ResTy = MatchOperandParserImpl ( Operands , Mnemonic ) ; if ( ResTy == MatchOperand_Success || ResTy == MatchOperand_ParseFail || getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) return ResTy ; ResTy = parseRegOrImm ( Operands ) ;

if ( ResTy == MatchOperand_Success ) return ResTy ;


<s> OperandMatchResultTy ResTy = MatchOperandParserImpl ( Operands , Mnemonic ) ; if ( ResTy == MatchOperand_Success || ResTy == MatchOperand_ParseFail || getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) return ResTy ; ResTy = parseRegOrImm ( Operands ) ; if ( ResTy == MatchOperand_Success ) return ResTy ; if ( getLexer ( ) . getKind ( ) == AsmToken :: Identifier ) { const auto & Tok = Parser . getTok ( ) ; SMLoc S = Tok . getLoc ( ) ; const MCExpr * Expr = nullptr ;

if ( ! Parser . parseExpression ( Expr ) ) {


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


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


<s> const auto & Tok = Parser . getTok ( ) ; SMLoc StartLoc = Tok . getLoc ( ) ; SMLoc EndLoc = Tok . getEndLoc ( ) ; const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; RegisterKind RegKind ; unsigned Reg , RegNum , RegWidth ; if ( ! Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth ) ) { return nullptr ; } return <ISA_LIT>Operand :: CreateReg ( Reg , StartLoc , EndLoc , TRI , & getSTI ( ) , false ) ;


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


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


<s> Sext = true ; if ( getLexer ( ) . isNot ( AsmToken :: LParen ) ) { Error ( Parser . getTok ( ) . getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } Parser . Lex ( ) ; } auto Res = parseRegOrImm ( Operands ) ; if ( Res != MatchOperand_Success ) { return Res ; } <ISA_LIT>Operand :: Modifiers Mods = { false , false , false } ; if ( Sext ) {

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


<s> if ( getLexer ( ) . isNot ( AsmToken :: RParen ) ) { Error ( Parser . getTok ( ) . getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } Parser . Lex ( ) ; Mods . Sext = true ; } if ( Mods . hasIntModifiers ( ) ) {

<ISA_LIT>Operand & Op = static_cast < <ISA_LIT>Operand & > ( * Operands . back ( ) ) ;


<s> <ISA_LIT>AsmParser :: OperandMatchResultTy <ISA_LIT>AsmParser :: parseSDWADstUnused ( OperandVector & Operands ) { SMLoc S = Parser . getTok ( ) . getLoc ( ) ; StringRef Value ; <ISA_LIT>AsmParser :: OperandMatchResultTy res ; res = parseStringWithPrefix ( <STR_LIT> , Value ) ; if ( res != MatchOperand_Success ) { return res ;


<s> Msg . IsSymbolic = false ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return true ; if ( getParser ( ) . parseAbsoluteExpression ( Msg . Id ) ) return true ; if ( getLexer ( ) . is ( AsmToken :: Integer ) ) if ( getParser ( ) . parseAbsoluteExpression ( Msg . Id ) ) Msg . Id = ID_UNKNOWN_ ; } if ( Msg . Id == ID_UNKNOWN_ ) return false ; if ( ! ( Msg . Id == ID_GS || Msg . Id == ID_GS_DONE || Msg . Id == ID_SYSMSG ) ) { if ( getLexer ( ) . isNot ( AsmToken :: RParen ) ) return true ; Parser . Lex ( ) ; return false ; } if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return true ; Parser . Lex ( ) ; assert ( Msg . Id == ID_GS || Msg . Id == ID_GS_DONE || Msg . Id == ID_SYSMSG ) ; Operation . Id = ID_UNKNOWN_ ; if ( getLexer ( ) . is ( AsmToken :: Identifier ) ) { Operation . IsSymbolic = true ; const char * const * S = ( Msg . Id == ID_SYSMSG ) ? OpSysSymbolic : OpGsSymbolic ; const int F = ( Msg . Id == ID_SYSMSG ) ? OP_SYS_FIRST_ : OP_GS_FIRST_ ; const int L = ( Msg . Id == ID_SYSMSG ) ? OP_SYS_LAST_ : OP_GS_LAST_ ; const StringRef Tok = Parser . getTok ( ) . getString ( ) ; for ( int i = F ; i < L ; ++ i ) { if ( Tok == S [ i ] ) { Operation . Id = i ; break ; } } Parser . Lex ( ) ; } else { Operation . IsSymbolic = false ; if ( getLexer ( ) . isNot ( AsmToken :: Integer ) ) return true ; if ( getParser ( ) . parseAbsoluteExpression ( Operation . Id ) ) return true ; } if ( ( Msg . Id == ID_GS || Msg . Id == ID_GS_DONE ) && Operation . Id != OP_GS_NOP ) { if ( getLexer ( ) . is ( AsmToken :: RParen ) ) { Parser . Lex ( ) ;


<s> do { if ( ! ( ( ID_INTERRUPT <= Msg . Id && Msg . Id <= ID_GS_DONE ) || Msg . Id == ID_SYSMSG ) ) { if ( Msg . IsSymbolic ) Error ( S , <STR_LIT> ) ; else Error ( S , <STR_LIT> ) ; break ; } Imm16Val = ( Msg . Id << ID_SHIFT_ ) ; if ( Msg . Id == ID_GS || Msg . Id == ID_GS_DONE ) { if ( ! ( OP_GS_FIRST_ <= Operation . Id && Operation . Id < OP_GS_LAST_ ) ) { if ( Operation . IsSymbolic ) Error ( S , <STR_LIT> ) ; else Error ( S , <STR_LIT> ) ; break ; } if ( Operation . Id == OP_GS_NOP && Msg . Id != ID_GS_DONE ) { Error ( S , <STR_LIT> ) ; break ; } Imm16Val |= ( Operation . Id << OP_SHIFT_ ) ; } if ( Msg . Id == ID_SYSMSG ) { if ( ! ( OP_SYS_FIRST_ <= Operation . Id && Operation . Id < OP_SYS_LAST_ ) ) {


<s> if ( Tok != Prefix ) { return MatchOperand_NoMatch ; } Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Colon ) ) { return MatchOperand_ParseFail ; } Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Identifier ) ) { return MatchOperand_ParseFail ;


<s> return MatchOperand_ParseFail ; } Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Identifier ) ) { return MatchOperand_ParseFail ; } Value = Parser . getTok ( ) . getString ( ) ;


<s> int64_t CntVal = <NUM_LIT> ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; switch ( getLexer ( ) . getKind ( ) ) { default : return MatchOperand_ParseFail ; case AsmToken :: Integer : if ( getParser ( ) . parseAbsoluteExpression ( CntVal ) ) return MatchOperand_ParseFail ; break ; case AsmToken :: Identifier : do { if ( parseCnt ( CntVal ) ) return MatchOperand_ParseFail ; } while ( getLexer ( ) . isNot ( AsmToken :: EndOfStatement ) ) ; break ; }

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


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


<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_glc : return Operand . isGLC ( ) ? Match_Success : Match_InvalidOperand ; case MCK_idxen : return Operand . isIdxen ( ) ? Match_Success : Match_InvalidOperand ; case MCK_offen : return Operand . isOffen ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SSrc32 : return Operand . isSSrc32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SoppBrTarget :

return Operand . isSoppBrTarget ( ) ? Match_Success : Match_InvalidOperand ;


<s> return Operand . isGLC ( ) ? Match_Success : Match_InvalidOperand ; case MCK_idxen : return Operand . isIdxen ( ) ? Match_Success : Match_InvalidOperand ; case MCK_offen : return Operand . isOffen ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SSrc32 : return Operand . isSSrc32 ( ) ? Match_Success : Match_InvalidOperand ; case MCK_SoppBrTarget : return Operand . isSoppBrTarget ( ) ? Match_Success : Match_InvalidOperand ;


<s> if ( <STR_LIT> ( AsmParser -> getMII ( ) -> get ( Inst . getOpcode ( ) ) , Inst . getNumOperands ( ) ) ) { addLiteralImmOperand ( Inst , Imm . Val , ApplyModifiers & isImmTy ( ImmTyNone ) && Imm . Mods . hasFPModifiers ( ) ) ; } else {

assert ( ! isImmTy ( ImmTyNone ) || ! hasModifiers ( ) ) ;


<s> } else { assert ( ! isImmTy ( ImmTyNone ) || ! hasModifiers ( ) ) ; Inst . addOperand ( MCOperand :: createImm ( Imm . Val ) ) ;


<s> if ( ! Imm . IsFPImm ) { Inst . addOperand ( MCOperand :: createImm ( Literal . getLoBits ( Bitwidth ) . getZExtValue ( ) ) ) ; return ; } bool Lost ; APFloat FPLiteral ( APFloat :: IEEEdouble ( ) , Literal ) ; FPLiteral . convert ( * getFltSemantics ( Bitwidth / <NUM_LIT> ) , APFloat :: rmNearestTiesToEven , & Lost ) ;

Inst . addOperand ( MCOperand :: createImm ( FPLiteral . bitcastToAPInt ( ) . getZExtValue ( ) ) ) ;


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


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


<s> 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> && <STR_LIT> :: hasCodeObjectV3 ( & getSTI ( ) ) ) { initializeGprCountSymbol ( IS_VGPR ) ; initializeGprCountSymbol ( IS_SGPR ) ; } else KernelScope . initialize ( getContext ( ) ) ;


<s> } if ( BoundCtrl == - <NUM_LIT> ) { BoundCtrl = <NUM_LIT> ; return true ; } return false ;


<s> Op -> Imm . Val = Val ; Op -> Imm . IsFPImm = IsFPImm ; Op -> Imm . Type = Type ; Op -> Imm . Mods = Modifiers ( ) ;


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


<s> assert ( ( unsigned ) TiedTo < Inst . getNumOperands ( ) ) ; Inst . addOperand ( Inst . getOperand ( TiedTo ) ) ; } <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ I ] ) ; if ( Op . isReg ( ) && validateVccOperand ( Op . getReg ( ) ) ) { continue ; } if ( IsDPP8 ) { if ( Op . isDPP8 ( ) ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; } else if ( isRegOrImmWithInputMods ( Desc , Inst . getNumOperands ( ) ) ) { Op . addRegWithFPInputModsOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isFI ( ) ) { Fi = Op . getImm ( ) ; } else if ( Op . isReg ( ) ) { Op . addRegOperands ( Inst , <NUM_LIT> ) ; } else { llvm_unreachable ( <STR_LIT> ) ; } } else { if ( isRegOrImmWithInputMods ( Desc , Inst . getNumOperands ( ) ) ) { Op . addRegWithFPInputModsOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isDPPCtrl ( ) ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; } else if ( Op . isImm ( ) ) { OptionalIdx [ Op . getImmTy ( ) ] = I ; } else { llvm_unreachable ( <STR_LIT> ) ; } } } if ( IsDPP8 ) { using namespace llvm :: <STR_LIT> ; Inst . addOperand ( MCOperand :: createImm ( Fi ? DPP8_FI_1 : DPP8_FI_0 ) ) ; } else { addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppRowMask , <NUM_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppBankMask , <NUM_LIT> ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppBoundCtrl ) ; if ( <STR_LIT> ( Inst . getOpcode ( ) , <STR_LIT> :: fi ) != - <NUM_LIT> ) { addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDppFi ) ; }


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


<s> } addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyOffset ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyFORMAT ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyGLC ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTySLC ) ; addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyTFE ) ;

if ( isGFX10 ( ) ) addOptionalImmOperand ( Inst , Operands , OptionalIdx , <ISA_LIT>Operand :: ImmTyDLC ) ;


<s> void <ISA_LIT>AsmParser :: cvtMubufImpl ( MCInst & Inst , const OperandVector & Operands , bool IsAtomic , bool IsAtomicReturn , bool IsLds ) { bool IsLdsOpcode = IsLds ; bool HasLdsModifier = false ; OptionalImmIndexMap OptionalIdx ; assert ( IsAtomicReturn ? IsAtomic : true ) ; unsigned FirstOperandIdx = <NUM_LIT> ; for ( unsigned i = FirstOperandIdx , e = Operands . size ( ) ; i != e ; ++ i ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ i ] ) ; if ( Op . isReg ( ) ) { Op . addRegOperands ( Inst , <NUM_LIT> ) ; if ( IsAtomicReturn && i == FirstOperandIdx ) Op . addRegOperands ( Inst , <NUM_LIT> ) ; continue ; } if ( Op . isImm ( ) && Op . getImmTy ( ) == <ISA_LIT>Operand :: ImmTyNone ) { Op . addImmOperands ( Inst , <NUM_LIT> ) ; continue ; } 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 ) ; if ( ! IsAtomic ) {

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


<s> void cvtMubufLds ( MCInst & Inst , const OperandVector & Operands ) {

cvtMubufImpl ( Inst , Operands , false , false , true ) ;


<s> void cvtMubufLds ( MCInst & Inst , const OperandVector & Operands ) { cvtMubufImpl ( Inst , Operands , false , false , true ) ;


<s> int OpSelHiIdx = <STR_LIT> ( Opc , <STR_LIT> :: op_sel_hi ) ; if ( OpSelHiIdx != - <NUM_LIT> ) { int DefaultVal = IsPacked ? - <NUM_LIT> : <NUM_LIT> ; addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyOpSelHi , DefaultVal ) ; } int NegLoIdx = <STR_LIT> ( Opc , <STR_LIT> :: neg_lo ) ; if ( NegLoIdx != - <NUM_LIT> ) { assert ( IsPacked ) ; addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyNegLo ) ; addOptionalImmOperand ( Inst , Operands , OptIdx , <ISA_LIT>Operand :: ImmTyNegHi ) ; } const int Ops [ ] = { <STR_LIT> :: src0 , <STR_LIT> :: src1 , <STR_LIT> :: src2 } ; const int ModOps [ ] = { <STR_LIT> :: src0_modifiers , <STR_LIT> :: src1_modifiers , <STR_LIT> :: src2_modifiers } ; int OpSelIdx = <STR_LIT> ( Opc , <STR_LIT> :: op_sel ) ; unsigned OpSel = Inst . getOperand ( OpSelIdx ) . getImm ( ) ; 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> ; if ( ( NegLo & ( <NUM_LIT> << J ) ) != <NUM_LIT> ) ModVal |= <STR_LIT> ; if ( ( NegHi & ( <NUM_LIT> << J ) ) != <NUM_LIT> ) ModVal |= <STR_LIT> ; int ModIdx = <STR_LIT> ( Opc , ModOps [ J ] ) ;

Inst . getOperand ( ModIdx ) . setImm ( Inst . getOperand ( ModIdx ) . getImm ( ) | ModVal ) ;


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

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


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


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


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

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


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


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

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


<s> case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : return <NUM_LIT> ; default : return <NUM_LIT> ; }


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


<s> for ( unsigned i = <NUM_LIT> , e = Operands . size ( ) ; i != e ; ++ i ) { <ISA_LIT>Operand & Op = ( ( <ISA_LIT>Operand & ) * Operands [ i ] ) ; if ( Op . isSMEMOffset ( ) ) return Op . getStartLoc ( ) ;


<s> return ( AsmParser -> getFeatureBits ( ) [ <STR_LIT> ] && isSCSrcB64 ( ) ) || ( AsmParser -> getFeatureBits ( ) [ <STR_LIT> ] && isSCSrcB32 ( ) ) ;


<s> } if ( type == <STR_LIT> ) { return false ; } MVT ExpectedType = ( type == <STR_LIT> ) ? <STR_LIT> : ( type == <STR_LIT> ) ? <STR_LIT> : type ;

APFloat FPLiteral ( APFloat :: IEEEdouble ( ) , APInt ( <NUM_LIT> , Imm . Val ) ) ;


<s> case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> : case <STR_LIT> :


<s> if ( AsmParser -> isVI ( ) ) return isVReg32 ( ) ; else if ( AsmParser -> isGFX9 ( ) || AsmParser -> isGFX10 ( ) ) return isRegClass ( <STR_LIT> ) || isInlinableImm ( type ) ; else return false ;


<s> bool <ISA_LIT>Operand :: isSDWAOperand ( MVT type ) const { if ( AsmParser -> isVI ( ) ) return isVReg32 ( ) ; else if ( AsmParser -> isGFX9 ( ) || AsmParser -> isGFX10 ( ) ) return isRegClass ( <STR_LIT> ) || isInlinableImm ( type ) ; else return false ;


<s> bool <ISA_LIT>AsmParser :: OutOfRangeError ( SMRange Range ) {

return getParser ( ) . Error ( Range . Start , <STR_LIT> , Range ) ;


<s> bool <ISA_LIT>AsmParser :: OutOfRangeError ( SMRange Range ) { return getParser ( ) . Error ( Range . Start , <STR_LIT> , Range ) ;


<s> if ( ! getFeatureBits ( ) [ <STR_LIT> ] ) return TokError ( <STR_LIT> ) ; } } if ( ID == <STR_LIT> ) { if ( Header . wavefront_size == <NUM_LIT> ) { if ( ! isGFX10 ( ) ) return TokError ( <STR_LIT> ) ; if ( ! getFeatureBits ( ) [ <STR_LIT> ] ) return TokError ( <STR_LIT> ) ; } else if ( Header . wavefront_size == <NUM_LIT> ) { if ( ! getFeatureBits ( ) [ <STR_LIT> ] ) return TokError ( <STR_LIT> ) ; } } if ( ID == <STR_LIT> ) { if ( G_00B848_WGP_MODE ( Header . compute_pgm_resource_registers ) && ! isGFX10 ( ) ) return TokError ( <STR_LIT> ) ; } if ( ID == <STR_LIT> ) { if ( G_00B848_MEM_ORDERED ( Header . compute_pgm_resource_registers ) && ! isGFX10 ( ) ) return TokError ( <STR_LIT> ) ; } if ( ID == <STR_LIT> ) { if ( G_00B848_FWD_PROGRESS ( Header . compute_pgm_resource_registers ) && ! isGFX10 ( ) ) return TokError ( <STR_LIT> ) ; } return false ;


<s> if ( getLexer ( ) . isNot ( AsmToken :: Integer ) && getLexer ( ) . isNot ( AsmToken :: Identifier ) ) { return true ; } if ( getParser ( ) . parseAbsoluteExpression ( Tmp ) ) { return true ; }

Ret = static_cast < uint32_t > ( Tmp ) ;


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


<s> if ( getLexer ( ) . getTok ( ) . getString ( ) != <STR_LIT> ) return MatchOperand_NoMatch ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Colon ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; std :: string Token ; if ( getLexer ( ) . is ( AsmToken :: Integer ) ) { SMLoc Loc = getLexer ( ) . getTok ( ) . getEndLoc ( ) ; Token = std :: string ( getLexer ( ) . getTok ( ) . getString ( ) ) ; Parser . Lex ( ) ; if ( getLexer ( ) . getTok ( ) . getLoc ( ) != Loc ) return MatchOperand_ParseFail ; } if ( getLexer ( ) . isNot ( AsmToken :: Identifier ) ) return MatchOperand_ParseFail ; Token += getLexer ( ) . getTok ( ) . getString ( ) ; StringRef DimId = Token ; if ( DimId . startswith ( <STR_LIT> ) ) DimId = DimId . substr ( <NUM_LIT> ) ; const <STR_LIT> * DimInfo = <STR_LIT> ( DimId ) ; if ( ! DimInfo ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , DimInfo -> Encoding , S , <ISA_LIT>Operand :: ImmTyDim ) ) ;


<s> SMRange TargetRange = SMRange ( TargetStart , getTok ( ) . getLoc ( ) ) ; std :: string ExpectedTarget ; raw_string_ostream ExpectedTargetOS ( ExpectedTarget ) ; IsaInfo :: streamIsaVersion ( & getSTI ( ) , ExpectedTargetOS ) ; if ( Target != ExpectedTargetOS . str ( ) ) return getParser ( ) . Error ( TargetRange . Start , <STR_LIT> , TargetRange ) ; getTargetStreamer ( ) . EmitDirectiveAMDGCNTarget ( Target ) ;


<s> Lex ( ) ; if ( ! <STR_LIT> :: hasCodeObjectV3 ( & getSTI ( ) ) ) KernelScope . initialize ( getContext ( ) ) ;


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

if ( parseToken ( AsmToken :: EndOfStatement , <STR_LIT> ) ) return true ;


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


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


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


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

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


<s> return Error ( getParser ( ) . getTok ( ) . getLoc ( ) , <STR_LIT> <STR_LIT> ) ; } auto ISAVersionStringFromASM = getLexer ( ) . getTok ( ) . getStringContents ( ) ; std :: string ISAVersionStringFromSTI ; raw_string_ostream ISAVersionStreamFromSTI ( ISAVersionStringFromSTI ) ;

IsaInfo :: streamIsaVersion ( & getSTI ( ) , ISAVersionStreamFromSTI ) ;


<s> bool <ISA_LIT>AsmParser :: ParseDirectiveMajorMinor ( uint32_t & Major , uint32_t & Minor ) { if ( ParseAsAbsoluteExpression ( Major ) ) return TokError ( <STR_LIT> ) ;

if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return TokError ( <STR_LIT> ) ;


<s> Lex ( ) ; if ( ParseAsAbsoluteExpression ( Minor ) ) return TokError ( <STR_LIT> ) ; return false ;


<s> if ( getSTI ( ) . getTargetTriple ( ) . getOS ( ) != Triple :: AMDPAL ) { return Error ( getParser ( ) . getTok ( ) . getLoc ( ) , ( Twine ( PALMD :: AssemblerDirective ) + Twine ( <STR_LIT> <STR_LIT> ) ) . str ( ) ) ; } auto PALMetadata = getTargetStreamer ( ) . getPALMetadata ( ) ; PALMetadata -> setLegacy ( ) ; for ( ; ; ) { uint32_t Key , Value ;

if ( ParseAsAbsoluteExpression ( Key ) ) {


<s> std :: string String ; if ( ParseToEndDirective ( <STR_LIT> :: AssemblerDirectiveBegin , <STR_LIT> :: AssemblerDirectiveEnd , String ) ) return true ;

auto PALMetadata = getTargetStreamer ( ) . getPALMetadata ( ) ;


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


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

for ( size_t i = <NUM_LIT> ; i < <NUM_LIT> ; ++ i ) DPP8 |= ( Sels [ i ] << ( i * <NUM_LIT> ) ) ;


<s> if ( ! isGFX10 ( ) && ( Prefix == <STR_LIT> || Prefix == <STR_LIT> ) ) return MatchOperand_NoMatch ; if ( ! isVI ( ) && ! isGFX9 ( ) && ( Prefix == <STR_LIT> || Prefix == <STR_LIT> || Prefix == <STR_LIT> || Prefix == <STR_LIT> || Prefix == <STR_LIT> ) ) return MatchOperand_NoMatch ; Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Colon ) ) return MatchOperand_ParseFail ; if ( Prefix == <STR_LIT> ) { Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: LBrac ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( Int ) || ! ( <NUM_LIT> <= Int && Int <= <NUM_LIT> ) ) return MatchOperand_ParseFail ; for ( int i = <NUM_LIT> ; i < <NUM_LIT> ; ++ i ) { if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; int64_t Temp ; if ( getParser ( ) . parseAbsoluteExpression ( Temp ) || ! ( <NUM_LIT> <= Temp && Temp <= <NUM_LIT> ) ) return MatchOperand_ParseFail ; const int shift = i * <NUM_LIT> + <NUM_LIT> ; Int += ( Temp << shift ) ; } if ( getLexer ( ) . isNot ( AsmToken :: RBrac ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; } else { Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( Int ) ) return MatchOperand_ParseFail ; if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= DppCtrl :: ROW_SHL0 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= DppCtrl :: ROW_SHR0 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= DppCtrl :: ROW_ROR0 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = DppCtrl :: WAVE_SHL1 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = DppCtrl :: WAVE_ROL1 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = DppCtrl :: WAVE_SHR1 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) {


<s> Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Colon ) ) return MatchOperand_ParseFail ; if ( Prefix == <STR_LIT> ) { Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: LBrac ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( Int ) || ! ( <NUM_LIT> <= Int && Int <= <NUM_LIT> ) ) return MatchOperand_ParseFail ; for ( int i = <NUM_LIT> ; i < <NUM_LIT> ; ++ i ) { if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; int64_t Temp ; if ( getParser ( ) . parseAbsoluteExpression ( Temp ) || ! ( <NUM_LIT> <= Temp && Temp <= <NUM_LIT> ) ) return MatchOperand_ParseFail ; const int shift = i * <NUM_LIT> + <NUM_LIT> ; Int += ( Temp << shift ) ; } if ( getLexer ( ) . isNot ( AsmToken :: RBrac ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; } else { Parser . Lex ( ) ; if ( getParser ( ) . parseAbsoluteExpression ( Int ) ) return MatchOperand_ParseFail ; if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= DppCtrl :: ROW_SHL0 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= DppCtrl :: ROW_SHR0 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> <= Int && Int <= <NUM_LIT> ) { Int |= DppCtrl :: ROW_ROR0 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = DppCtrl :: WAVE_SHL1 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = DppCtrl :: WAVE_ROL1 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = DppCtrl :: WAVE_SHR1 ; } else if ( Prefix == <STR_LIT> && <NUM_LIT> == Int ) { Int = DppCtrl :: WAVE_ROR1 ; } else if ( Prefix == <STR_LIT> ) { if ( Int == <NUM_LIT> ) { Int = DppCtrl :: BCAST15 ; } else if ( Int == <NUM_LIT> ) {


<s> return MatchOperand_ParseFail ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Imm , S , <ISA_LIT>Operand :: ImmTyEndpgm ) ) ;


<s> return ! getParser ( ) . parseAbsoluteExpression ( Imm ) ;


<s> StringRef Str = Parser . getTok ( ) . getString ( ) ; auto Res = parseExpTgtImpl ( Str , Val ) ; if ( Res != MatchOperand_Success ) return Res ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; Parser . Lex ( ) ;

Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Val , S , <ISA_LIT>Operand :: ImmTyExpTgt ) ) ;


<s> StringRef Str = Parser . getTok ( ) . getString ( ) ; auto Res = parseExpTgtImpl ( Str , Val ) ; if ( Res != MatchOperand_Success ) return Res ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; Parser . Lex ( ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Val , S , <ISA_LIT>Operand :: ImmTyExpTgt ) ) ; return MatchOperand_Success ;


<s> if ( Str == <STR_LIT> ) { Val = <NUM_LIT> ; return MatchOperand_Success ; } if ( Str . startswith ( <STR_LIT> ) ) { Str = Str . drop_front ( <NUM_LIT> ) ; if ( Str == <STR_LIT> ) { Val = <NUM_LIT> ; return MatchOperand_Success ; } if ( Str . getAsInteger ( <NUM_LIT> , Val ) ) return MatchOperand_ParseFail ; if ( Val > <NUM_LIT> ) { Error ( getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } return MatchOperand_Success ; } if ( Str . startswith ( <STR_LIT> ) ) { Str = Str . drop_front ( <NUM_LIT> ) ; if ( Str . getAsInteger ( <NUM_LIT> , Val ) ) return MatchOperand_ParseFail ; if ( Val > <NUM_LIT> || ( Val == <NUM_LIT> && ! isGFX10 ( ) ) ) { Error ( getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } Val += <NUM_LIT> ; return MatchOperand_Success ; } if ( isGFX10 ( ) && Str == <STR_LIT> ) { Val = <NUM_LIT> ; return MatchOperand_Success ; } if ( Str . startswith ( <STR_LIT> ) ) { Str = Str . drop_front ( <NUM_LIT> ) ; if ( Str . getAsInteger ( <NUM_LIT> , Val ) ) return MatchOperand_ParseFail ; if ( Val >= <NUM_LIT> ) { Error ( getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } Val += <NUM_LIT> ; return MatchOperand_Success ; } if ( Str . startswith ( <STR_LIT> ) ) { Str = Str . drop_front ( <NUM_LIT> ) ;


<s> if ( Str . startswith ( <STR_LIT> ) ) { Str = Str . drop_front ( <NUM_LIT> ) ; if ( Str == <STR_LIT> ) { Val = <NUM_LIT> ; return MatchOperand_Success ; } if ( Str . getAsInteger ( <NUM_LIT> , Val ) ) return MatchOperand_ParseFail ; if ( Val > <NUM_LIT> ) { Error ( getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } return MatchOperand_Success ; } if ( Str . startswith ( <STR_LIT> ) ) { Str = Str . drop_front ( <NUM_LIT> ) ; if ( Str . getAsInteger ( <NUM_LIT> , Val ) ) return MatchOperand_ParseFail ; if ( Val > <NUM_LIT> || ( Val == <NUM_LIT> && ! isGFX10 ( ) ) ) { Error ( getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } Val += <NUM_LIT> ;


<s> if ( Res == MatchOperand_ParseFail ) return Res ; bool FormatFound = ( Res == MatchOperand_Success ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Format , Loc , <ISA_LIT>Operand :: ImmTyFORMAT ) ) ; if ( FormatFound ) trySkipToken ( AsmToken :: Comma ) ; if ( isToken ( AsmToken :: EndOfStatement ) ) { return MatchOperand_Success ; } Res = parseRegOrImm ( Operands ) ; if ( Res != MatchOperand_Success ) return Res ; trySkipToken ( AsmToken :: Comma ) ; if ( ! FormatFound ) { Res = parseSymbolicOrNumericFormat ( Format ) ; if ( Res == MatchOperand_ParseFail ) return Res ; if ( Res == MatchOperand_Success ) { auto Size = Operands . size ( ) ; <ISA_LIT>Operand & Op = static_cast < <ISA_LIT>Operand & > ( * Operands [ Size - <NUM_LIT> ] ) ; assert ( Op . isImm ( ) && Op . getImmTy ( ) == <ISA_LIT>Operand :: ImmTyFORMAT ) ; Op . setImm ( Format ) ; } return MatchOperand_Success ; } if ( isId ( <STR_LIT> ) && peekToken ( ) . is ( AsmToken :: Colon ) ) { Error ( getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ;


<s> return MatchOperand_Success ; } Res = parseRegOrImm ( Operands ) ; if ( Res != MatchOperand_Success ) return Res ; trySkipToken ( AsmToken :: Comma ) ; if ( ! FormatFound ) { Res = parseSymbolicOrNumericFormat ( Format ) ; if ( Res == MatchOperand_ParseFail ) return Res ; if ( Res == MatchOperand_Success ) { auto Size = Operands . size ( ) ; <ISA_LIT>Operand & Op = static_cast < <ISA_LIT>Operand & > ( * Operands [ Size - <NUM_LIT> ] ) ; assert ( Op . isImm ( ) && Op . getImmTy ( ) == <ISA_LIT>Operand :: ImmTyFORMAT ) ; Op . setImm ( Format ) ; } return MatchOperand_Success ; } if ( isId ( <STR_LIT> ) && peekToken ( ) . is ( AsmToken :: Colon ) ) { Error ( getLoc ( ) , <STR_LIT> ) ; return MatchOperand_ParseFail ; } return MatchOperand_Success ;


<s> return UNDEF ; } if ( Imm & Mode ) { Error ( S , <STR_LIT> ) ; return UNDEF ; } Imm |= Mode ; if ( trySkipToken ( AsmToken :: RParen ) ) break ;

if ( ! skipToken ( AsmToken :: Comma , <STR_LIT> ) ) return UNDEF ;


<s> while ( true ) { unsigned Mode = <NUM_LIT> ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; for ( unsigned ModeId = ID_MIN ; ModeId <= ID_MAX ; ++ ModeId ) { if ( trySkipId ( IdSymbolic [ ModeId ] ) ) { Mode = <NUM_LIT> << ModeId ;


<s> } else { if ( getParser ( ) . parseAbsoluteExpression ( Imm ) ) return MatchOperand_ParseFail ; if ( Imm < <NUM_LIT> || ! isUInt < <NUM_LIT> > ( Imm ) ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ; } }

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


<s> if ( ImmVal < <NUM_LIT> || ! isUInt < <NUM_LIT> > ( ImmVal ) ) { Error ( Loc , <STR_LIT> ) ; return MatchOperand_ParseFail ; } } else { return MatchOperand_ParseFail ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , ImmVal , Loc , <ISA_LIT>Operand :: ImmTyHwreg ) ) ; return MatchOperand_Success ;


<s> } if ( trySkipToken ( AsmToken :: RParen ) ) return true ; return skipToken ( AsmToken :: Comma , <STR_LIT> ) && parseExpr ( Offset ) && skipToken ( AsmToken :: Comma , <STR_LIT> ) && parseExpr ( Width ) && skipToken ( AsmToken :: RParen , <STR_LIT> ) ;


<s> return false ; } if ( trySkipToken ( AsmToken :: RParen ) ) return true ;

return skipToken ( AsmToken :: Comma , <STR_LIT> ) && parseExpr ( Offset ) && skipToken ( AsmToken :: Comma , <STR_LIT> ) && parseExpr ( Width ) && skipToken ( AsmToken :: RParen , <STR_LIT> ) ;


<s> bool <ISA_LIT>AsmParser :: ParseInstruction ( ParseInstructionInfo & Info , StringRef Name , SMLoc NameLoc , OperandVector & Operands ) { Name = parseMnemonicSuffix ( Name ) ; Operands . push_back ( <ISA_LIT>Operand :: CreateToken ( this , Name , NameLoc ) ) ; bool IsMIMG = Name . startswith ( <STR_LIT> ) ; while ( ! getLexer ( ) . is ( AsmToken :: EndOfStatement ) ) { OperandMode Mode = OperandMode_Default ; if ( IsMIMG && isGFX10 ( ) && Operands . size ( ) == <NUM_LIT> ) Mode = OperandMode_NSA ; OperandMatchResultTy Res = parseOperand ( Operands , Name , Mode ) ; if ( getLexer ( ) . is ( AsmToken :: Comma ) ) Parser . Lex ( ) ; if ( Res != MatchOperand_Success ) { checkUnsupportedInstruction ( Name , NameLoc ) ;


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


<s> StringRef Chan = Str . take_back ( <NUM_LIT> ) ; int AttrChan = StringSwitch < int > ( Chan ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Default ( - <NUM_LIT> ) ; if ( AttrChan == - <NUM_LIT> ) return MatchOperand_ParseFail ; Str = Str . drop_back ( <NUM_LIT> ) . drop_front ( <NUM_LIT> ) ; uint8_t Attr ; if ( Str . getAsInteger ( <NUM_LIT> , Attr ) ) return MatchOperand_ParseFail ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; Parser . Lex ( ) ; if ( Attr > <NUM_LIT> ) { Error ( S , <STR_LIT> ) ; return MatchOperand_ParseFail ;


<s> int Slot = StringSwitch < int > ( Str ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Default ( - <NUM_LIT> ) ;

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


<s> if ( getLexer ( ) . getKind ( ) != AsmToken :: Identifier ) return MatchOperand_NoMatch ; StringRef Str = Parser . getTok ( ) . getString ( ) ; int Slot = StringSwitch < int > ( Str ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Case ( <STR_LIT> , <NUM_LIT> ) . Default ( - <NUM_LIT> ) ;


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


<s> if ( Tok == <STR_LIT> && ! hasMIMG_R128 ( ) ) Error ( S , <STR_LIT> ) ; if ( Tok == <STR_LIT> && ! isGFX9 ( ) && ! hasGFX10A16 ( ) ) Error ( S , <STR_LIT> ) ; Bit = <NUM_LIT> ; Parser . Lex ( ) ; } else if ( Tok . startswith ( <STR_LIT> ) && Tok . endswith ( Name ) ) { Bit = <NUM_LIT> ;


<s> StringRef Name = Parser . getTok ( ) . getString ( ) ; if ( Name == <STR_LIT> ) { return parseIntWithPrefix ( <STR_LIT> , Operands , <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> , ConvertOmodMul ) ; } if ( Name == <STR_LIT> ) { return parseIntWithPrefix ( <STR_LIT> , Operands , <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> , ConvertOmodDiv ) ;


<s> unsigned Prefix = Operands . size ( ) ; SMLoc LBraceLoc = getTok ( ) . getLoc ( ) ; Parser . Lex ( ) ; for ( ; ; ) { ResTy = parseReg ( Operands ) ; if ( ResTy != MatchOperand_Success ) return ResTy ; if ( getLexer ( ) . is ( AsmToken :: RBrac ) ) break ; if ( getLexer ( ) . isNot ( AsmToken :: Comma ) ) return MatchOperand_ParseFail ; Parser . Lex ( ) ; }

if ( Operands . size ( ) - Prefix > <NUM_LIT> ) {


<s> } else if ( Op . Type == <ISA_LIT>Operand :: ImmTyOMod<ISA_LIT> ) { res = parseOModOperand ( Operands ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTySdwaDstSel || Op . Type == <ISA_LIT>Operand :: ImmTySdwaSrc0Sel || Op . Type == <ISA_LIT>Operand :: ImmTySdwaSrc1Sel ) { res = parseSDWASel ( Operands , Op . Name , Op . Type ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTySdwaDstUnused ) { res = parseSDWADstUnused ( Operands ) ; } else if ( Op . Type == <ISA_LIT>Operand :: ImmTyOpSel || Op . Type == <ISA_LIT>Operand :: ImmTyOpSelHi || Op . Type == <ISA_LIT>Operand :: ImmTyNegLo || Op . Type == <ISA_LIT>Operand :: ImmTyNegHi ) {

res = parseOperandArrayWithPrefix ( Op . Name , Operands , Op . Type , Op . ConvertResult ) ;


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


<s> SMLoc EndLoc = Tok . getEndLoc ( ) ; RegisterKind RegKind ; unsigned Reg , RegNum , RegWidth ; if ( ! Parse<ISA_LIT>Register ( RegKind , Reg , RegNum , RegWidth ) ) { return nullptr ; } if ( <STR_LIT> :: hasCodeObjectV3 ( & getSTI ( ) ) ) { if ( ! updateGprCountSymbols ( RegKind , RegNum , RegWidth ) ) return nullptr ; } else KernelScope . usesRegister ( RegKind , RegNum , RegWidth ) ; return <ISA_LIT>Operand :: CreateReg ( this , Reg , StartLoc , EndLoc ) ;


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseSDWADstUnused ( OperandVector & Operands ) { using namespace llvm :: <STR_LIT> ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; StringRef Value ; OperandMatchResultTy res ; res = parseStringWithPrefix ( <STR_LIT> , Value ) ; 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> ) ;


<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> ) ; Parser . Lex ( ) ; if ( Int == <NUM_LIT> ) { return MatchOperand_ParseFail ; }

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


<s> using namespace llvm :: <STR_LIT> ; SMLoc S = Parser . getTok ( ) . getLoc ( ) ; StringRef Value ; OperandMatchResultTy res ; res = parseStringWithPrefix ( Prefix , Value ) ; 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> ) ; Parser . Lex ( ) ; if ( Int == <NUM_LIT> ) { return MatchOperand_ParseFail ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Int , S , Type ) ) ;


<s> } 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> ) ; Parser . Lex ( ) ; if ( Int == <NUM_LIT> ) { return MatchOperand_ParseFail ; } Operands . push_back ( <ISA_LIT>Operand :: CreateImm ( this , Int , S , Type ) ) ; return MatchOperand_Success ;


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

return skipToken ( AsmToken :: RParen , <STR_LIT> ) ;


<s> if ( parseSendMsgBody ( Msg , Op , Stream ) && validateSendMsg ( Msg , Op , Stream , Loc ) ) { ImmVal = encodeMsg ( Msg . Id , Op . Id , Stream . Id ) ; } else { return MatchOperand_ParseFail ; } } else if ( parseExpr ( ImmVal ) ) {

if ( ImmVal < <NUM_LIT> || ! isUInt < <NUM_LIT> > ( ImmVal ) ) {


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


<s> } StringRef Tok = Parser . getTok ( ) . getString ( ) ; if ( Tok != Prefix ) { return MatchOperand_NoMatch ; } Parser . Lex ( ) ; if ( getLexer ( ) . isNot ( AsmToken :: Colon ) ) { return MatchOperand_ParseFail ; } Parser . Lex ( ) ;

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


<s> 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' : OrMask |= Mask ; break ; case 'p' : AndMask |= Mask ; break ; case 'i' :


<s> Error ( S , <STR_LIT> ) ; return false ; } if ( parseSwizzleOperands ( <NUM_LIT> , & LaneIdx , <NUM_LIT> , GroupSize - <NUM_LIT> , <STR_LIT> ) ) { Imm = encodeBitmaskPerm ( BITMASK_MAX - GroupSize + <NUM_LIT> , LaneIdx , <NUM_LIT> ) ; return true ;


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


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


<s> SMLoc S = Parser . getTok ( ) . getLoc ( ) ; int64_t Imm = <NUM_LIT> ; if ( trySkipId ( <STR_LIT> ) ) { bool Ok = false ; if ( skipToken ( AsmToken :: Colon , <STR_LIT> ) ) { if ( trySkipId ( <STR_LIT> ) ) {


<s> OperandMatchResultTy <ISA_LIT>AsmParser :: parseSwizzleOp ( OperandVector & Operands ) { SMLoc S = Parser . getTok ( ) . getLoc ( ) ; int64_t Imm = <NUM_LIT> ; if ( trySkipId ( <STR_LIT> ) ) { bool Ok = false ; if ( skipToken ( AsmToken :: Colon , <STR_LIT> ) ) { if ( trySkipId ( <STR_LIT> ) ) { Ok = parseSwizzleMacro ( Imm ) ; } else {


<s> bool <ISA_LIT>AsmParser :: parseSwizzleOperands ( const unsigned OpNum , int64_t * Op , const unsigned MinVal , const unsigned MaxVal , const StringRef ErrMsg ) {

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


<s> int64_t GroupSize ; if ( ! parseSwizzleOperands ( <NUM_LIT> , & GroupSize , <NUM_LIT> , <NUM_LIT> , <STR_LIT> ) ) { return false ; } if ( ! isPowerOf2_64 ( GroupSize ) ) { Error ( S , <STR_LIT> ) ;


<s> int64_t GroupSize ; if ( ! parseSwizzleOperands ( <NUM_LIT> , & GroupSize , <NUM_LIT> , <NUM_LIT> , <STR_LIT> ) ) { return false ; } if ( ! isPowerOf2_64 ( GroupSize ) ) { Error ( S , <STR_LIT> ) ; return false ; } Imm = encodeBitmaskPerm ( BITMASK_MAX , <NUM_LIT> , GroupSize ) ; return true ;


<s> return MatchOperand_ParseFail ; } 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 ( isGFX10 ( ) ) { auto Ufmt = convertDfmtNfmt2Ufmt ( Dfmt , Nfmt ) ;


<s> SMLoc Loc = getLoc ( ) ; if ( ! parseId ( Str , <STR_LIT> ) || ! matchDfmtNfmt ( Dfmt , Nfmt , Str , Loc ) ) { return MatchOperand_ParseFail ; } if ( Dfmt == DFMT_UNDEF ) { Error ( Loc , <STR_LIT> ) ; return MatchOperand_ParseFail ; } else if ( Nfmt == NFMT_UNDEF ) { Error ( Loc , <STR_LIT> ) ;


<s> } if ( getLexer ( ) . is ( AsmToken :: Identifier ) ) { StringRef ID = getLexer ( ) . getTok ( ) . getIdentifier ( ) ; if ( ID == AssemblerDirectiveEnd ) { Lex ( ) ; FoundEnd = true ; break ; } } CollectStream << Parser . parseStringToEndOfStatement ( ) << getContext ( ) . getAsmInfo ( ) -> getSeparatorString ( ) ; Parser . eatToEndOfStatement ( ) ; }


<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 ImmTyDim : OS << <STR_LIT> ; break ; case ImmTyUNorm : OS << <STR_LIT> ; break ; case ImmTyDA : OS << <STR_LIT> ; break ; case ImmTyR128A16 : OS << <STR_LIT> ; break ; case ImmTyA16 : OS << <STR_LIT> ; break ; case ImmTyLWE : OS << <STR_LIT> ; break ; case ImmTyOff : OS << <STR_LIT> ; break ; case ImmTyExpTgt : OS << <STR_LIT> ; break ; case ImmTyExpCompr : OS << <STR_LIT> ; break ; case ImmTyExpVM : OS << <STR_LIT> ; break ; case ImmTyHwreg : OS << <STR_LIT> ; break ; case ImmTySendMsg : OS << <STR_LIT> ; break ; case ImmTyInterpSlot : OS << <STR_LIT> ; break ; case ImmTyInterpAttr : OS << <STR_LIT> ; break ; case ImmTyAttrChan : OS << <STR_LIT> ; break ; case ImmTyOpSel : OS << <STR_LIT> ; break ; case ImmTyOpSelHi : OS << <STR_LIT> ; break ; case ImmTyNegLo : OS << <STR_LIT> ; break ; case ImmTyNegHi : OS << <STR_LIT> ; break ; case ImmTySwizzle : OS << <STR_LIT> ; break ; case ImmTyGprIdxMode : OS << <STR_LIT> ; break ; case ImmTyHigh : OS << <STR_LIT> ; break ; case ImmTyBLGP : OS << <STR_LIT> ; break ; case ImmTyCBSZ : OS << <STR_LIT> ; break ; case ImmTyABID : OS << <STR_LIT> ; break ; case ImmTyEndpgm : OS << <STR_LIT> ; break ; }


<s> case ImmTySdwaDstSel : OS << <STR_LIT> ; break ; case ImmTySdwaSrc0Sel : OS << <STR_LIT> ; break ; case ImmTySdwaSrc1Sel : OS << <STR_LIT> ; break ; case ImmTySdwaDstUnused : OS << <STR_LIT> ; break ; case ImmTyDMask : OS << <STR_LIT> ; break ; case ImmTyDim : OS << <STR_LIT> ; break ; case ImmTyUNorm : OS << <STR_LIT> ; break ; case ImmTyDA : OS << <STR_LIT> ; break ; case ImmTyR128A16 : OS << <STR_LIT> ; break ; case ImmTyA16 : OS << <STR_LIT> ; break ; case ImmTyLWE : OS << <STR_LIT> ; break ; case ImmTyOff : OS << <STR_LIT> ; break ; case ImmTyExpTgt : OS << <STR_LIT> ; break ; case ImmTyExpCompr : OS << <STR_LIT> ; break ; case ImmTyExpVM : OS << <STR_LIT> ; break ; case ImmTyHwreg : OS << <STR_LIT> ; break ; case ImmTySendMsg : OS << <STR_LIT> ; break ;

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


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


<s> if ( <STR_LIT> ( getSTI ( ) . getCPU ( ) ) . Major < <NUM_LIT> ) return true ; auto SymbolName = getGprCountSymbolName ( RegKind ) ; if ( ! SymbolName ) return true ; MCSymbol * Sym = getContext ( ) . getOrCreateSymbol ( * SymbolName ) ; int64_t NewMax = DwordRegIndex + RegWidth - <NUM_LIT> ; int64_t OldCount ;

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


<s> const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; return isSGPR ( mc2PseudoReg ( Reg ) , TRI ) && Reg != SGPR_NULL ;


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


<s> } const MCRegisterInfo * TRI = getContext ( ) . getRegisterInfo ( ) ; const int Src0Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src0 ) ; const int Src1Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src1 ) ; const int Src2Idx = <STR_LIT> ( Opcode , <STR_LIT> :: src2 ) ; assert ( DstIdx != - <NUM_LIT> ) ; const MCOperand & Dst = Inst . getOperand ( DstIdx ) ; assert ( Dst . isReg ( ) ) ; const unsigned DstReg = mc2PseudoReg ( Dst . getReg ( ) ) ; const int SrcIndices [ ] = { Src0Idx , Src1Idx , Src2Idx } ; 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 ) ) {