mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-12-19 11:23:32 +00:00
[mips] Add new error message and improve testing for parsing the .module directive.
Summary: We used to silently ignore any empty .module's and we used to give an error saying that we found an "unexpected token at start of statement" when the value of the option wasn't an identifier (e.g. if it was a number). We now give an error saying that we "expected .module option identifier" in both of those cases. I also fixed the other tests in mips-abi-bad.s, which all seemed to be broken. Reviewers: dsanders Reviewed By: dsanders Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7095 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226905 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -3723,43 +3723,44 @@ bool MipsAsmParser::parseDirectiveModule() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Lexer.is(AsmToken::Identifier)) {
|
||||
StringRef Option = Parser.getTok().getString();
|
||||
Parser.Lex();
|
||||
|
||||
if (Option == "oddspreg") {
|
||||
getTargetStreamer().emitDirectiveModuleOddSPReg(true, isABI_O32());
|
||||
clearFeatureBits(Mips::FeatureNoOddSPReg, "nooddspreg");
|
||||
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||
reportParseError("unexpected token, expected end of statement");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if (Option == "nooddspreg") {
|
||||
if (!isABI_O32()) {
|
||||
Error(L, "'.module nooddspreg' requires the O32 ABI");
|
||||
return false;
|
||||
}
|
||||
|
||||
getTargetStreamer().emitDirectiveModuleOddSPReg(false, isABI_O32());
|
||||
setFeatureBits(Mips::FeatureNoOddSPReg, "nooddspreg");
|
||||
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||
reportParseError("unexpected token, expected end of statement");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if (Option == "fp") {
|
||||
return parseDirectiveModuleFP();
|
||||
}
|
||||
|
||||
return Error(L, "'" + Twine(Option) + "' is not a valid .module option.");
|
||||
StringRef Option;
|
||||
if (Parser.parseIdentifier(Option)) {
|
||||
reportParseError("expected .module option identifier");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (Option == "oddspreg") {
|
||||
getTargetStreamer().emitDirectiveModuleOddSPReg(true, isABI_O32());
|
||||
clearFeatureBits(Mips::FeatureNoOddSPReg, "nooddspreg");
|
||||
|
||||
// If this is not the end of the statement, report an error.
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||
reportParseError("unexpected token, expected end of statement");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false; // parseDirectiveModule has finished successfully.
|
||||
} else if (Option == "nooddspreg") {
|
||||
if (!isABI_O32()) {
|
||||
Error(L, "'.module nooddspreg' requires the O32 ABI");
|
||||
return false;
|
||||
}
|
||||
|
||||
getTargetStreamer().emitDirectiveModuleOddSPReg(false, isABI_O32());
|
||||
setFeatureBits(Mips::FeatureNoOddSPReg, "nooddspreg");
|
||||
|
||||
// If this is not the end of the statement, report an error.
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||
reportParseError("unexpected token, expected end of statement");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false; // parseDirectiveModule has finished successfully.
|
||||
} else if (Option == "fp") {
|
||||
return parseDirectiveModuleFP();
|
||||
} else {
|
||||
return Error(L, "'" + Twine(Option) + "' is not a valid .module option.");
|
||||
}
|
||||
}
|
||||
|
||||
/// parseDirectiveModuleFP
|
||||
|
||||
Reference in New Issue
Block a user