summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Bradbury <asb@lowrisc.org>2018-05-23 11:17:20 +0000
committerAlex Bradbury <asb@lowrisc.org>2018-05-23 11:17:20 +0000
commit0a59f18951d902e0f7c456412b581323214b56da (patch)
tree2ca39356cc47f186d108ca6b2b5fee97423f0c33
parent1c010d0fa4be73441bfd0adc07243f76739b1323 (diff)
downloadbcm5719-llvm-0a59f18951d902e0f7c456412b581323214b56da.tar.gz
bcm5719-llvm-0a59f18951d902e0f7c456412b581323214b56da.zip
[AArch64] Use addAliasForDirective to support data directives
The AArch64 asm parser currently has custom parsing logic for .hword, .word, and .xword. Rather than use this custom logic, we can just use addAliasForDirective to enable the reuse of AsmParser::parseDirectiveValue. Differential Revision: https://reviews.llvm.org/D47000 llvm-svn: 333077
-rw-r--r--llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp30
1 files changed, 7 insertions, 23 deletions
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index d26640737f0..83d984c9e4b 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -96,7 +96,6 @@ private:
bool parseDirectiveArch(SMLoc L);
bool parseDirectiveCPU(SMLoc L);
- bool parseDirectiveWord(unsigned Size, SMLoc L);
bool parseDirectiveInst(SMLoc L);
bool parseDirectiveTLSDescCall(SMLoc L);
@@ -166,6 +165,13 @@ public:
if (S.getTargetStreamer() == nullptr)
new AArch64TargetStreamer(S);
+ // Alias .hword/.word/xword to the target-independent .2byte/.4byte/.8byte
+ // directives as they have the same form and semantics:
+ /// ::= (.hword | .word | .xword ) [ expression (, expression)* ]
+ Parser.addAliasForDirective(".hword", ".2byte");
+ Parser.addAliasForDirective(".word", ".4byte");
+ Parser.addAliasForDirective(".xword", ".8byte");
+
// Initialize the set of available features.
setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
}
@@ -4369,12 +4375,6 @@ bool AArch64AsmParser::ParseDirective(AsmToken DirectiveID) {
parseDirectiveArch(Loc);
else if (IDVal == ".cpu")
parseDirectiveCPU(Loc);
- else if (IDVal == ".hword")
- parseDirectiveWord(2, Loc);
- else if (IDVal == ".word")
- parseDirectiveWord(4, Loc);
- else if (IDVal == ".xword")
- parseDirectiveWord(8, Loc);
else if (IDVal == ".tlsdesccall")
parseDirectiveTLSDescCall(Loc);
else if (IDVal == ".ltorg" || IDVal == ".pool")
@@ -4539,22 +4539,6 @@ bool AArch64AsmParser::parseDirectiveCPU(SMLoc L) {
return false;
}
-/// parseDirectiveWord
-/// ::= .word [ expression (, expression)* ]
-bool AArch64AsmParser::parseDirectiveWord(unsigned Size, SMLoc L) {
- auto parseOp = [&]() -> bool {
- const MCExpr *Value;
- if (getParser().parseExpression(Value))
- return true;
- getParser().getStreamer().EmitValue(Value, Size, L);
- return false;
- };
-
- if (parseMany(parseOp))
- return true;
- return false;
-}
-
/// parseDirectiveInst
/// ::= .inst opcode [, ...]
bool AArch64AsmParser::parseDirectiveInst(SMLoc Loc) {
OpenPOWER on IntegriCloud