Skip to content
Snippets Groups Projects
Commit 3ed6a6f6 authored by Anirudh Prasad's avatar Anirudh Prasad
Browse files

[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
parent c3d5f306
No related branches found
No related tags found
No related merge requests found
...@@ -830,7 +830,7 @@ SystemZAsmParser::parseRegister(OperandVector &Operands, RegisterKind Kind) { ...@@ -830,7 +830,7 @@ SystemZAsmParser::parseRegister(OperandVector &Operands, RegisterKind Kind) {
} }
// Handle register names of the form %<prefix><number> // Handle register names of the form %<prefix><number>
if (Parser.getTok().is(AsmToken::Percent)) { if (isParsingATT() && Parser.getTok().is(AsmToken::Percent)) {
if (parseRegister(Reg)) if (parseRegister(Reg))
return MatchOperand_ParseFail; return MatchOperand_ParseFail;
...@@ -912,6 +912,9 @@ SystemZAsmParser::parseAnyRegister(OperandVector &Operands) { ...@@ -912,6 +912,9 @@ SystemZAsmParser::parseAnyRegister(OperandVector &Operands) {
Operands.push_back(SystemZOperand::createImm(Register, StartLoc, EndLoc)); Operands.push_back(SystemZOperand::createImm(Register, StartLoc, EndLoc));
} }
else { else {
if (isParsingHLASM())
return MatchOperand_NoMatch;
Register Reg; Register Reg;
if (parseRegister(Reg)) if (parseRegister(Reg))
return MatchOperand_ParseFail; return MatchOperand_ParseFail;
...@@ -1019,7 +1022,7 @@ bool SystemZAsmParser::parseAddress(bool &HaveReg1, Register &Reg1, ...@@ -1019,7 +1022,7 @@ bool SystemZAsmParser::parseAddress(bool &HaveReg1, Register &Reg1,
if (getLexer().is(AsmToken::LParen)) { if (getLexer().is(AsmToken::LParen)) {
Parser.Lex(); Parser.Lex();
if (getLexer().is(AsmToken::Percent)) { if (isParsingATT() && getLexer().is(AsmToken::Percent)) {
// Parse the first register. // Parse the first register.
HaveReg1 = true; HaveReg1 = true;
if (parseRegister(Reg1)) if (parseRegister(Reg1))
...@@ -1062,7 +1065,7 @@ bool SystemZAsmParser::parseAddress(bool &HaveReg1, Register &Reg1, ...@@ -1062,7 +1065,7 @@ bool SystemZAsmParser::parseAddress(bool &HaveReg1, Register &Reg1,
if (parseIntegerRegister(Reg2, RegGR)) if (parseIntegerRegister(Reg2, RegGR))
return true; return true;
} else { } else {
if (parseRegister(Reg2)) if (isParsingATT() && parseRegister(Reg2))
return true; return true;
} }
} }
...@@ -1419,7 +1422,7 @@ bool SystemZAsmParser::parseOperand(OperandVector &Operands, ...@@ -1419,7 +1422,7 @@ bool SystemZAsmParser::parseOperand(OperandVector &Operands,
// a context-dependent parse routine, which gives the required register // a context-dependent parse routine, which gives the required register
// class. The code is here to mop up other cases, like those where // class. The code is here to mop up other cases, like those where
// the instruction isn't recognized. // the instruction isn't recognized.
if (Parser.getTok().is(AsmToken::Percent)) { if (isParsingATT() && Parser.getTok().is(AsmToken::Percent)) {
Register Reg; Register Reg;
if (parseRegister(Reg)) if (parseRegister(Reg))
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment