aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Bradbury <asb@lowrisc.org>2018-07-02 13:37:15 +0000
committerAlex Bradbury <asb@lowrisc.org>2018-07-02 13:37:15 +0000
commit42485ec9ca06bb20c6780330f94a12b8d7cb29e8 (patch)
treeb99680ef59a7dad796c8a7de9ee6eb64757f352b
parent8fc5ec78d54df15de2908f16d55945da4b239613 (diff)
downloadllvm-42485ec9ca06bb20c6780330f94a12b8d7cb29e8.zip
llvm-42485ec9ca06bb20c6780330f94a12b8d7cb29e8.tar.gz
llvm-42485ec9ca06bb20c6780330f94a12b8d7cb29e8.tar.bz2
[X86] Use addAliasForDirective to support the .word directive
The X86 asm parser currently has custom parsing logic for .word. Rather than use this custom logic, we can just use addAliasForDirective to enable the reuse of AsmParser::parseDirectiveValue. See also similar changes to Sparc (rL333078), AArch64 (rL333077), and Hexagon (rL332607) backends. Differential Revision: https://reviews.llvm.org/D47004 llvm-svn: 336100
-rw-r--r--llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp28
1 files changed, 3 insertions, 25 deletions
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 86d8ae1..2bb4bad 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -846,7 +846,6 @@ private:
const InlineAsmIdentifierInfo &Info);
bool parseDirectiveEven(SMLoc L);
- bool ParseDirectiveWord(unsigned Size, SMLoc L);
bool ParseDirectiveCode(StringRef IDVal, SMLoc L);
/// CodeView FPO data directives.
@@ -945,6 +944,8 @@ public:
: MCTargetAsmParser(Options, sti, mii), InstInfo(nullptr),
Code16GCC(false) {
+ Parser.addAliasForDirective(".word", ".4byte");
+
// Initialize the set of available features.
setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
Instrumentation.reset(
@@ -3264,9 +3265,7 @@ bool X86AsmParser::OmitRegisterFromClobberLists(unsigned RegNo) {
bool X86AsmParser::ParseDirective(AsmToken DirectiveID) {
MCAsmParser &Parser = getParser();
StringRef IDVal = DirectiveID.getIdentifier();
- if (IDVal == ".word")
- return ParseDirectiveWord(2, DirectiveID.getLoc());
- else if (IDVal.startswith(".code"))
+ if (IDVal.startswith(".code"))
return ParseDirectiveCode(IDVal, DirectiveID.getLoc());
else if (IDVal.startswith(".att_syntax")) {
getParser().setParsingInlineAsm(false);
@@ -3327,27 +3326,6 @@ bool X86AsmParser::parseDirectiveEven(SMLoc L) {
getStreamer().EmitValueToAlignment(2, 0, 1, 0);
return false;
}
-/// ParseDirectiveWord
-/// ::= .word [ expression (, expression)* ]
-bool X86AsmParser::ParseDirectiveWord(unsigned Size, SMLoc L) {
- auto parseOp = [&]() -> bool {
- const MCExpr *Value;
- SMLoc ExprLoc = getLexer().getLoc();
- if (getParser().parseExpression(Value))
- return true;
- if (const auto *MCE = dyn_cast<MCConstantExpr>(Value)) {
- assert(Size <= 8 && "Invalid size");
- uint64_t IntValue = MCE->getValue();
- if (!isUIntN(8 * Size, IntValue) && !isIntN(8 * Size, IntValue))
- return Error(ExprLoc, "literal value out of range for directive");
- getStreamer().EmitIntValue(IntValue, Size);
- } else
- getStreamer().EmitValue(Value, Size, ExprLoc);
- return false;
- };
- parseMany(parseOp);
- return false;
-}
/// ParseDirectiveCode
/// ::= .code16 | .code32 | .code64