[llvm] 3ed6a6f - [SystemZ][z/OS] Enforce prefix-less registers in SystemZAsmParser for the HLASM dialect.
Anirudh Prasad via llvm-commits
llvm-commits at lists.llvm.org
Mon May 3 08:44:51 PDT 2021
Author: Anirudh Prasad
Date: 2021-05-03T11:44:44-04:00
New Revision: 3ed6a6f6cdea9777d0e0175e22cea04e2c0c6d43
URL: https://github.com/llvm/llvm-project/commit/3ed6a6f6cdea9777d0e0175e22cea04e2c0c6d43
DIFF: https://github.com/llvm/llvm-project/commit/3ed6a6f6cdea9777d0e0175e22cea04e2c0c6d43.diff
LOG: [SystemZ][z/OS] Enforce prefix-less registers in SystemZAsmParser for the HLASM dialect.
- Previously, https://reviews.llvm.org/D101308 removed prefixes from register while printing them out. This was especially needed for inline asm statements which used input/output operands.
- However, the backend SystemZAsmParser, accepts both prefixed registers and prefix-less registers as part of its implementation
- This patch aims to change that by ensuring that prefixed registers are only allowed for the ATT dialect.
Reviewed By: uweigand
Differential Revision: https://reviews.llvm.org/D101665
Added:
Modified:
llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp b/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
index ef6ba28718151..42980d6174972 100644
--- a/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
+++ b/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp
@@ -830,7 +830,7 @@ SystemZAsmParser::parseRegister(OperandVector &Operands, RegisterKind Kind) {
}
// Handle register names of the form %<prefix><number>
- if (Parser.getTok().is(AsmToken::Percent)) {
+ if (isParsingATT() && Parser.getTok().is(AsmToken::Percent)) {
if (parseRegister(Reg))
return MatchOperand_ParseFail;
@@ -912,6 +912,9 @@ SystemZAsmParser::parseAnyRegister(OperandVector &Operands) {
Operands.push_back(SystemZOperand::createImm(Register, StartLoc, EndLoc));
}
else {
+ if (isParsingHLASM())
+ return MatchOperand_NoMatch;
+
Register Reg;
if (parseRegister(Reg))
return MatchOperand_ParseFail;
@@ -1019,7 +1022,7 @@ bool SystemZAsmParser::parseAddress(bool &HaveReg1, Register &Reg1,
if (getLexer().is(AsmToken::LParen)) {
Parser.Lex();
- if (getLexer().is(AsmToken::Percent)) {
+ if (isParsingATT() && getLexer().is(AsmToken::Percent)) {
// Parse the first register.
HaveReg1 = true;
if (parseRegister(Reg1))
@@ -1062,7 +1065,7 @@ bool SystemZAsmParser::parseAddress(bool &HaveReg1, Register &Reg1,
if (parseIntegerRegister(Reg2, RegGR))
return true;
} else {
- if (parseRegister(Reg2))
+ if (isParsingATT() && parseRegister(Reg2))
return true;
}
}
@@ -1419,7 +1422,7 @@ bool SystemZAsmParser::parseOperand(OperandVector &Operands,
// a context-dependent parse routine, which gives the required register
// class. The code is here to mop up other cases, like those where
// the instruction isn't recognized.
- if (Parser.getTok().is(AsmToken::Percent)) {
+ if (isParsingATT() && Parser.getTok().is(AsmToken::Percent)) {
Register Reg;
if (parseRegister(Reg))
return true;
More information about the llvm-commits
mailing list