mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-12-19 11:23:32 +00:00
correct target directive handling error handling
The target specific parser should return `false' if the target AsmParser handles the directive, and `true' if the generic parser should handle the directive. Many of the target specific directive handlers would `return Error' which does not follow these semantics. This change simply changes the target specific routines to conform to the semantis of the ParseDirective correctly. Conformance to the semantics improves diagnostics emitted for the invalid directives. X86 is taken as a sample to ensure that multiple diagnostics are not presented for a single error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199068 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -8072,7 +8072,7 @@ bool ARMAsmParser::parseDirectiveWord(unsigned Size, SMLoc L) {
|
||||
for (;;) {
|
||||
const MCExpr *Value;
|
||||
if (getParser().parseExpression(Value))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
getParser().getStreamer().EmitValue(Value, Size);
|
||||
|
||||
@@ -8080,8 +8080,10 @@ bool ARMAsmParser::parseDirectiveWord(unsigned Size, SMLoc L) {
|
||||
break;
|
||||
|
||||
// FIXME: Improve diagnostic.
|
||||
if (getLexer().isNot(AsmToken::Comma))
|
||||
return Error(L, "unexpected token in directive");
|
||||
if (getLexer().isNot(AsmToken::Comma)) {
|
||||
Error(L, "unexpected token in directive");
|
||||
return false;
|
||||
}
|
||||
Parser.Lex();
|
||||
}
|
||||
}
|
||||
@@ -8093,12 +8095,16 @@ bool ARMAsmParser::parseDirectiveWord(unsigned Size, SMLoc L) {
|
||||
/// parseDirectiveThumb
|
||||
/// ::= .thumb
|
||||
bool ARMAsmParser::parseDirectiveThumb(SMLoc L) {
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||
return Error(L, "unexpected token in directive");
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||
Error(L, "unexpected token in directive");
|
||||
return false;
|
||||
}
|
||||
Parser.Lex();
|
||||
|
||||
if (!hasThumb())
|
||||
return Error(L, "target does not support Thumb mode");
|
||||
if (!hasThumb()) {
|
||||
Error(L, "target does not support Thumb mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isThumb())
|
||||
SwitchMode();
|
||||
@@ -8109,12 +8115,16 @@ bool ARMAsmParser::parseDirectiveThumb(SMLoc L) {
|
||||
/// parseDirectiveARM
|
||||
/// ::= .arm
|
||||
bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||
return Error(L, "unexpected token in directive");
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||
Error(L, "unexpected token in directive");
|
||||
return false;
|
||||
}
|
||||
Parser.Lex();
|
||||
|
||||
if (!hasARM())
|
||||
return Error(L, "target does not support ARM mode");
|
||||
if (!hasARM()) {
|
||||
Error(L, "target does not support ARM mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isThumb())
|
||||
SwitchMode();
|
||||
@@ -8140,8 +8150,11 @@ bool ARMAsmParser::parseDirectiveThumbFunc(SMLoc L) {
|
||||
if (isMachO) {
|
||||
const AsmToken &Tok = Parser.getTok();
|
||||
if (Tok.isNot(AsmToken::EndOfStatement)) {
|
||||
if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String))
|
||||
return Error(L, "unexpected token in .thumb_func directive");
|
||||
if (Tok.isNot(AsmToken::Identifier) && Tok.isNot(AsmToken::String)) {
|
||||
Error(L, "unexpected token in .thumb_func directive");
|
||||
return false;
|
||||
}
|
||||
|
||||
MCSymbol *Func =
|
||||
getParser().getContext().GetOrCreateSymbol(Tok.getIdentifier());
|
||||
getParser().getStreamer().EmitThumbFunc(Func);
|
||||
@@ -8150,11 +8163,12 @@ bool ARMAsmParser::parseDirectiveThumbFunc(SMLoc L) {
|
||||
}
|
||||
}
|
||||
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement))
|
||||
return Error(L, "unexpected token in directive");
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||
Error(L, "unexpected token in directive");
|
||||
return false;
|
||||
}
|
||||
|
||||
NextSymbolIsThumb = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8162,15 +8176,21 @@ bool ARMAsmParser::parseDirectiveThumbFunc(SMLoc L) {
|
||||
/// ::= .syntax unified | divided
|
||||
bool ARMAsmParser::parseDirectiveSyntax(SMLoc L) {
|
||||
const AsmToken &Tok = Parser.getTok();
|
||||
if (Tok.isNot(AsmToken::Identifier))
|
||||
return Error(L, "unexpected token in .syntax directive");
|
||||
if (Tok.isNot(AsmToken::Identifier)) {
|
||||
Error(L, "unexpected token in .syntax directive");
|
||||
return false;
|
||||
}
|
||||
|
||||
StringRef Mode = Tok.getString();
|
||||
if (Mode == "unified" || Mode == "UNIFIED")
|
||||
if (Mode == "unified" || Mode == "UNIFIED") {
|
||||
Parser.Lex();
|
||||
else if (Mode == "divided" || Mode == "DIVIDED")
|
||||
return Error(L, "'.syntax divided' arm asssembly not supported");
|
||||
else
|
||||
return Error(L, "unrecognized syntax mode in .syntax directive");
|
||||
} else if (Mode == "divided" || Mode == "DIVIDED") {
|
||||
Error(L, "'.syntax divided' arm asssembly not supported");
|
||||
return false;
|
||||
} else {
|
||||
Error(L, "unrecognized syntax mode in .syntax directive");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||
Error(Parser.getTok().getLoc(), "unexpected token in directive");
|
||||
@@ -8676,7 +8696,7 @@ bool ARMAsmParser::parseDirectiveRegSave(SMLoc L, bool IsVector) {
|
||||
|
||||
// Parse the register list
|
||||
if (parseRegisterList(CO.Operands))
|
||||
return true;
|
||||
return false;
|
||||
ARMOperand *Op = (ARMOperand*)CO.Operands[0];
|
||||
if (!IsVector && !Op->isRegList()) {
|
||||
Error(L, ".save expects GPR registers");
|
||||
|
||||
Reference in New Issue
Block a user