diff options
| author | Alex Bradbury <asb@lowrisc.org> | 2018-04-25 17:25:29 +0000 |
|---|---|---|
| committer | Alex Bradbury <asb@lowrisc.org> | 2018-04-25 17:25:29 +0000 |
| commit | cd8688a4c26540c4d03e5f1ac6566e7cd29bddc5 (patch) | |
| tree | 8d1e9f360c21ca17894111dd1574ddb3ac42f622 /llvm/lib/Target/RISCV | |
| parent | 39d61944df1a2f975b51a05249bd0082ffbf7f49 (diff) | |
| download | bcm5719-llvm-cd8688a4c26540c4d03e5f1ac6566e7cd29bddc5.tar.gz bcm5719-llvm-cd8688a4c26540c4d03e5f1ac6566e7cd29bddc5.zip | |
[RISCV] Allow call pseudoinstruction to be used to call a function name that coincides with a register name
Previously `call zero`, `call f0` etc would fail. This leads to compilation
failures if building programs that define functions with those names and using
-save-temps.
llvm-svn: 330846
Diffstat (limited to 'llvm/lib/Target/RISCV')
| -rw-r--r-- | llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 02f075a8532..b5e46b63756 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -65,7 +65,7 @@ class RISCVAsmParser : public MCTargetAsmParser { OperandMatchResultTy parseMemOpBaseReg(OperandVector &Operands); OperandMatchResultTy parseOperandWithModifier(OperandVector &Operands); - bool parseOperand(OperandVector &Operands); + bool parseOperand(OperandVector &Operands, bool ForceImmediate); public: enum RISCVMatchResultTy { @@ -881,12 +881,15 @@ RISCVAsmParser::parseMemOpBaseReg(OperandVector &Operands) { return MatchOperand_Success; } -/// Looks at a token type and creates the relevant operand -/// from this information, adding to Operands. -/// If operand was parsed, returns false, else true. -bool RISCVAsmParser::parseOperand(OperandVector &Operands) { - // Attempt to parse token as register - if (parseRegister(Operands, true) == MatchOperand_Success) +/// Looks at a token type and creates the relevant operand from this +/// information, adding to Operands. If operand was parsed, returns false, else +/// true. If ForceImmediate is true, no attempt will be made to parse the +/// operand as a register, which is needed for pseudoinstructions such as +/// call. +bool RISCVAsmParser::parseOperand(OperandVector &Operands, + bool ForceImmediate) { + // Attempt to parse token as register, unless ForceImmediate. + if (!ForceImmediate && parseRegister(Operands, true) == MatchOperand_Success) return false; // Attempt to parse token as an immediate @@ -913,7 +916,7 @@ bool RISCVAsmParser::ParseInstruction(ParseInstructionInfo &Info, return false; // Parse first operand - if (parseOperand(Operands)) + if (parseOperand(Operands, Name == "call")) return true; // Parse until end of statement, consuming commas between operands @@ -922,7 +925,7 @@ bool RISCVAsmParser::ParseInstruction(ParseInstructionInfo &Info, getLexer().Lex(); // Parse next operand - if (parseOperand(Operands)) + if (parseOperand(Operands, false)) return true; } |

