forked from OSchip/llvm-project
[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
This commit is contained in:
parent
0a59f18951
commit
3fa69dd055
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue