diff options
author | Alex Bradbury <asb@lowrisc.org> | 2018-05-23 11:20:28 +0000 |
---|---|---|
committer | Alex Bradbury <asb@lowrisc.org> | 2018-05-23 11:20:28 +0000 |
commit | 3fa69dd055a49e207ee03d37b6e79205e4ab981a (patch) | |
tree | f1bb6b712d8bacc7c01a3f74ce3df6a2314c9ed9 | |
parent | 0a59f18951d902e0f7c456412b581323214b56da (diff) | |
download | bcm5719-llvm-3fa69dd055a49e207ee03d37b6e79205e4ab981a.tar.gz bcm5719-llvm-3fa69dd055a49e207ee03d37b6e79205e4ab981a.zip |
[Sparc] Use addAliasForDirective to support data directives
The Sparc asm parser currently has custom parsing logic for .half, .word,
.nword and .xword. Rather than use this custom logic, we can just use
addAliasForDirective to enable the reuse of AsmParser::parseDirectiveValue.
https://reviews.llvm.org/D47003
llvm-svn: 333078
-rw-r--r-- | llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp index 05f78a48bad..9e23d2498bf 100644 --- a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp +++ b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp @@ -95,7 +95,6 @@ class SparcAsmParser : public MCTargetAsmParser { unsigned &RegKind); bool matchSparcAsmModifiers(const MCExpr *&EVal, SMLoc &EndLoc); - bool parseDirectiveWord(unsigned Size, SMLoc L); bool is64Bit() const { return getSTI().getTargetTriple().getArch() == Triple::sparcv9; @@ -109,6 +108,12 @@ public: const MCInstrInfo &MII, const MCTargetOptions &Options) : MCTargetAsmParser(Options, sti, MII), Parser(parser) { + Parser.addAliasForDirective(".half", ".2byte"); + Parser.addAliasForDirective(".word", ".4byte"); + Parser.addAliasForDirective(".nword", is64Bit() ? ".8byte" : ".4byte"); + if (is64Bit()) + Parser.addAliasForDirective(".xword", ".8byte"); + // Initialize the set of available features. setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits())); } @@ -682,21 +687,6 @@ ParseDirective(AsmToken DirectiveID) { 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(); @@ -713,28 +703,6 @@ ParseDirective(AsmToken DirectiveID) return true; } -bool SparcAsmParser:: parseDirectiveWord(unsigned Size, SMLoc L) { - if (getLexer().isNot(AsmToken::EndOfStatement)) { - while (true) { - 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; -} - OperandMatchResultTy SparcAsmParser::parseMEMOperand(OperandVector &Operands) { SMLoc S, E; |