@@ -1253,7 +1253,6 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
1253
1253
bool ForcedDPP = false ;
1254
1254
bool ForcedSDWA = false ;
1255
1255
KernelScopeInfo KernelScope;
1256
- unsigned CPolSeen;
1257
1256
1258
1257
// / @name Auto-generated Match Functions
1259
1258
// / {
@@ -1554,6 +1553,7 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
1554
1553
OperandMatchResultTy
1555
1554
parseNamedBit (StringRef Name, OperandVector &Operands,
1556
1555
AMDGPUOperand::ImmTy ImmTy = AMDGPUOperand::ImmTyNone);
1556
+ unsigned getCPolKind (StringRef Id, StringRef Mnemo, bool &Disabling) const ;
1557
1557
OperandMatchResultTy parseCPol (OperandVector &Operands);
1558
1558
OperandMatchResultTy parseStringWithPrefix (StringRef Prefix,
1559
1559
StringRef &Value,
@@ -1684,6 +1684,7 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
1684
1684
bool isId (const StringRef Id) const ;
1685
1685
bool isId (const AsmToken &Token, const StringRef Id) const ;
1686
1686
bool isToken (const AsmToken::TokenKind Kind) const ;
1687
+ StringRef getId () const ;
1687
1688
bool trySkipId (const StringRef Id);
1688
1689
bool trySkipId (const StringRef Pref, const StringRef Id);
1689
1690
bool trySkipId (const StringRef Id, const AsmToken::TokenKind Kind);
@@ -5868,7 +5869,6 @@ bool AMDGPUAsmParser::ParseInstruction(ParseInstructionInfo &Info,
5868
5869
OperandMode Mode = OperandMode_Default;
5869
5870
if (IsMIMG && isGFX10Plus () && Operands.size () == 2 )
5870
5871
Mode = OperandMode_NSA;
5871
- CPolSeen = 0 ;
5872
5872
OperandMatchResultTy Res = parseOperand (Operands, Name, Mode);
5873
5873
5874
5874
if (Res != MatchOperand_Success) {
@@ -6011,86 +6011,74 @@ AMDGPUAsmParser::parseNamedBit(StringRef Name, OperandVector &Operands,
6011
6011
return MatchOperand_Success;
6012
6012
}
6013
6013
6014
+ unsigned AMDGPUAsmParser::getCPolKind (StringRef Id, StringRef Mnemo,
6015
+ bool &Disabling) const {
6016
+ Disabling = Id.startswith (" no" );
6017
+
6018
+ if (isGFX940 () && !Mnemo.startswith (" s_" )) {
6019
+ return StringSwitch<unsigned >(Id)
6020
+ .Case (" nt" , AMDGPU::CPol::NT)
6021
+ .Case (" nont" , AMDGPU::CPol::NT)
6022
+ .Case (" sc0" , AMDGPU::CPol::SC0)
6023
+ .Case (" nosc0" , AMDGPU::CPol::SC0)
6024
+ .Case (" sc1" , AMDGPU::CPol::SC1)
6025
+ .Case (" nosc1" , AMDGPU::CPol::SC1)
6026
+ .Default (0 );
6027
+ }
6028
+
6029
+ return StringSwitch<unsigned >(Id)
6030
+ .Case (" dlc" , AMDGPU::CPol::DLC)
6031
+ .Case (" nodlc" , AMDGPU::CPol::DLC)
6032
+ .Case (" glc" , AMDGPU::CPol::GLC)
6033
+ .Case (" noglc" , AMDGPU::CPol::GLC)
6034
+ .Case (" scc" , AMDGPU::CPol::SCC)
6035
+ .Case (" noscc" , AMDGPU::CPol::SCC)
6036
+ .Case (" slc" , AMDGPU::CPol::SLC)
6037
+ .Case (" noslc" , AMDGPU::CPol::SLC)
6038
+ .Default (0 );
6039
+ }
6040
+
6014
6041
OperandMatchResultTy
6015
6042
AMDGPUAsmParser::parseCPol (OperandVector &Operands) {
6016
- OperandMatchResultTy Res = MatchOperand_NoMatch;
6017
-
6043
+ StringRef Mnemo = ((AMDGPUOperand &)*Operands[0 ]).getToken ();
6044
+ SMLoc OpLoc = getLoc ();
6045
+ unsigned Enabled = 0 , Seen = 0 ;
6018
6046
for (;;) {
6019
- unsigned CPolOn = 0 ;
6020
- unsigned CPolOff = 0 ;
6021
6047
SMLoc S = getLoc ();
6022
-
6023
- StringRef Mnemo = ((AMDGPUOperand &)*Operands[0 ]).getToken ();
6024
- if (isGFX940 () && !Mnemo.startswith (" s_" )) {
6025
- if (trySkipId (" sc0" ))
6026
- CPolOn = AMDGPU::CPol::SC0;
6027
- else if (trySkipId (" nosc0" ))
6028
- CPolOff = AMDGPU::CPol::SC0;
6029
- else if (trySkipId (" nt" ))
6030
- CPolOn = AMDGPU::CPol::NT;
6031
- else if (trySkipId (" nont" ))
6032
- CPolOff = AMDGPU::CPol::NT;
6033
- else if (trySkipId (" sc1" ))
6034
- CPolOn = AMDGPU::CPol::SC1;
6035
- else if (trySkipId (" nosc1" ))
6036
- CPolOff = AMDGPU::CPol::SC1;
6037
- else
6038
- break ;
6039
- } else if (trySkipId (" glc" ))
6040
- CPolOn = AMDGPU::CPol::GLC;
6041
- else if (trySkipId (" noglc" ))
6042
- CPolOff = AMDGPU::CPol::GLC;
6043
- else if (trySkipId (" slc" ))
6044
- CPolOn = AMDGPU::CPol::SLC;
6045
- else if (trySkipId (" noslc" ))
6046
- CPolOff = AMDGPU::CPol::SLC;
6047
- else if (trySkipId (" dlc" ))
6048
- CPolOn = AMDGPU::CPol::DLC;
6049
- else if (trySkipId (" nodlc" ))
6050
- CPolOff = AMDGPU::CPol::DLC;
6051
- else if (trySkipId (" scc" ))
6052
- CPolOn = AMDGPU::CPol::SCC;
6053
- else if (trySkipId (" noscc" ))
6054
- CPolOff = AMDGPU::CPol::SCC;
6055
- else
6048
+ bool Disabling;
6049
+ unsigned CPol = getCPolKind (getId (), Mnemo, Disabling);
6050
+ if (!CPol)
6056
6051
break ;
6057
6052
6058
- if (!isGFX10Plus () && ((CPolOn | CPolOff) & AMDGPU::CPol::DLC)) {
6053
+ lex ();
6054
+
6055
+ if (!isGFX10Plus () && CPol == AMDGPU::CPol::DLC) {
6059
6056
Error (S, " dlc modifier is not supported on this GPU" );
6060
6057
return MatchOperand_ParseFail;
6061
6058
}
6062
6059
6063
- if (!isGFX90A () && ((CPolOn | CPolOff) & AMDGPU::CPol::SCC) ) {
6060
+ if (!isGFX90A () && CPol == AMDGPU::CPol::SCC) {
6064
6061
Error (S, " scc modifier is not supported on this GPU" );
6065
6062
return MatchOperand_ParseFail;
6066
6063
}
6067
6064
6068
- if (CPolSeen & (CPolOn | CPolOff) ) {
6065
+ if (Seen & CPol ) {
6069
6066
Error (S, " duplicate cache policy modifier" );
6070
6067
return MatchOperand_ParseFail;
6071
6068
}
6072
6069
6073
- CPolSeen |= (CPolOn | CPolOff);
6074
- Res = MatchOperand_Success ;
6070
+ if (!Disabling)
6071
+ Enabled |= CPol ;
6075
6072
6076
- AMDGPUOperand *CPolOp = nullptr ;
6077
- for (unsigned I = 1 ; I != Operands.size (); ++I) {
6078
- AMDGPUOperand &Op = ((AMDGPUOperand &)*Operands[I]);
6079
- if (Op.isCPol ()) {
6080
- CPolOp = &Op;
6081
- break ;
6082
- }
6083
- }
6084
-
6085
- if (CPolOp) {
6086
- CPolOp->setImm ((CPolOp->getImm () | CPolOn) & ~CPolOff);
6087
- } else {
6088
- Operands.push_back (
6089
- AMDGPUOperand::CreateImm (this , CPolOn, S, AMDGPUOperand::ImmTyCPol));
6090
- }
6073
+ Seen |= CPol;
6091
6074
}
6092
6075
6093
- return Res;
6076
+ if (!Seen)
6077
+ return MatchOperand_NoMatch;
6078
+
6079
+ Operands.push_back (
6080
+ AMDGPUOperand::CreateImm (this , Enabled, OpLoc, AMDGPUOperand::ImmTyCPol));
6081
+ return MatchOperand_Success;
6094
6082
}
6095
6083
6096
6084
static void addOptionalImmOperand (
@@ -7120,6 +7108,10 @@ AMDGPUAsmParser::isToken(const AsmToken::TokenKind Kind) const {
7120
7108
return getTokenKind () == Kind;
7121
7109
}
7122
7110
7111
+ StringRef AMDGPUAsmParser::getId () const {
7112
+ return isToken (AsmToken::Identifier) ? getTokenStr () : StringRef ();
7113
+ }
7114
+
7123
7115
bool
7124
7116
AMDGPUAsmParser::trySkipId (const StringRef Id) {
7125
7117
if (isId (Id)) {
0 commit comments