mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
[Sparc] Add support for parsing directives in SparcAsmParser.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202564 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -73,7 +73,9 @@ class SparcAsmParser : public MCTargetAsmParser {
|
||||
unsigned &RegKind);
|
||||
|
||||
bool matchSparcAsmModifiers(const MCExpr *&EVal, SMLoc &EndLoc);
|
||||
bool parseDirectiveWord(unsigned Size, SMLoc L);
|
||||
|
||||
bool is64Bit() const { return STI.getTargetTriple().startswith("sparcv9"); }
|
||||
public:
|
||||
SparcAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser,
|
||||
const MCInstrInfo &MII)
|
||||
@@ -482,8 +484,52 @@ ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
|
||||
bool SparcAsmParser::
|
||||
ParseDirective(AsmToken DirectiveID)
|
||||
{
|
||||
// Ignore all directives for now.
|
||||
Parser.eatToEndOfStatement();
|
||||
StringRef IDVal = DirectiveID.getString();
|
||||
|
||||
if (IDVal == ".byte")
|
||||
return parseDirectiveWord(1, DirectiveID.getLoc());
|
||||
|
||||
if (IDVal == ".half")
|
||||
return parseDirectiveWord(2, DirectiveID.getLoc());
|
||||
|
||||
if (IDVal == ".word")
|
||||
return parseDirectiveWord(4, DirectiveID.getLoc());
|
||||
|
||||
if (IDVal == ".nword")
|
||||
return parseDirectiveWord(is64Bit() ? 8 : 4, DirectiveID.getLoc());
|
||||
|
||||
if (is64Bit() && IDVal == ".xword")
|
||||
return parseDirectiveWord(8, DirectiveID.getLoc());
|
||||
|
||||
if (IDVal == ".register") {
|
||||
// For now, ignore .register directive.
|
||||
Parser.eatToEndOfStatement();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Let the MC layer to handle other directives.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SparcAsmParser:: parseDirectiveWord(unsigned Size, SMLoc L) {
|
||||
if (getLexer().isNot(AsmToken::EndOfStatement)) {
|
||||
for (;;) {
|
||||
const MCExpr *Value;
|
||||
if (getParser().parseExpression(Value))
|
||||
return true;
|
||||
|
||||
getParser().getStreamer().EmitValue(Value, Size);
|
||||
|
||||
if (getLexer().is(AsmToken::EndOfStatement))
|
||||
break;
|
||||
|
||||
// FIXME: Improve diagnostic.
|
||||
if (getLexer().isNot(AsmToken::Comma))
|
||||
return Error(L, "unexpected token in directive");
|
||||
Parser.Lex();
|
||||
}
|
||||
}
|
||||
Parser.Lex();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user