diff options
author | Petr Hosek <phosek@chromium.org> | 2016-05-25 22:47:51 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2016-05-25 22:47:51 +0000 |
commit | e25837528b677fb8f9181c2bf8c8d06c2f43da24 (patch) | |
tree | e5888b230cbb4bc522579d3a7a181ededce9e124 /llvm/lib/MC/MCParser/AsmParser.cpp | |
parent | 6b93bf5783a1dd7b5535cff5eedbe2d965d90ac0 (diff) | |
download | bcm5719-llvm-e25837528b677fb8f9181c2bf8c8d06c2f43da24.tar.gz bcm5719-llvm-e25837528b677fb8f9181c2bf8c8d06c2f43da24.zip |
[MC] Support symbolic expressions in assembly directives
This matches the behavior of GNU assembler which supports symbolic
expressions in absolute expressions used in assembly directives.
Differential Revision: http://reviews.llvm.org/D20337
llvm-svn: 270786
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmParser.cpp')
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 7da00e89d78..f7de55002b1 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -2738,8 +2738,9 @@ bool AsmParser::parseDirectiveRealValue(const fltSemantics &Semantics) { bool AsmParser::parseDirectiveZero() { checkForValidSection(); - int64_t NumBytes; - if (parseAbsoluteExpression(NumBytes)) + SMLoc NumBytesLoc = Lexer.getLoc(); + const MCExpr *NumBytes; + if (parseExpression(NumBytes)) return true; int64_t Val = 0; @@ -2754,7 +2755,7 @@ bool AsmParser::parseDirectiveZero() { Lex(); - getStreamer().EmitFill(NumBytes, Val); + getStreamer().emitFill(*NumBytes, Val, NumBytesLoc); return false; } @@ -2764,17 +2765,11 @@ bool AsmParser::parseDirectiveZero() { bool AsmParser::parseDirectiveFill() { checkForValidSection(); - SMLoc RepeatLoc = getLexer().getLoc(); - int64_t NumValues; - if (parseAbsoluteExpression(NumValues)) + SMLoc NumValuesLoc = Lexer.getLoc(); + const MCExpr *NumValues; + if (parseExpression(NumValues)) return true; - if (NumValues < 0) { - Warning(RepeatLoc, - "'.fill' directive with negative repeat count has no effect"); - NumValues = 0; - } - int64_t FillSize = 1; int64_t FillExpr = 0; @@ -2806,7 +2801,7 @@ bool AsmParser::parseDirectiveFill() { if (FillSize < 0) { Warning(SizeLoc, "'.fill' directive with negative size has no effect"); - NumValues = 0; + NumValues = MCConstantExpr::create(0, getStreamer().getContext()); } if (FillSize > 8) { Warning(SizeLoc, "'.fill' directive with size greater than 8 has been truncated to 8"); @@ -2816,15 +2811,7 @@ bool AsmParser::parseDirectiveFill() { if (!isUInt<32>(FillExpr) && FillSize > 4) Warning(ExprLoc, "'.fill' directive pattern has been truncated to 32-bits"); - if (NumValues > 0) { - int64_t NonZeroFillSize = FillSize > 4 ? 4 : FillSize; - FillExpr &= ~0ULL >> (64 - NonZeroFillSize * 8); - for (uint64_t i = 0, e = NumValues; i != e; ++i) { - getStreamer().EmitIntValue(FillExpr, NonZeroFillSize); - if (NonZeroFillSize < FillSize) - getStreamer().EmitIntValue(0, FillSize - NonZeroFillSize); - } - } + getStreamer().emitFill(*NumValues, FillSize, FillExpr, NumValuesLoc); return false; } @@ -4058,8 +4045,9 @@ bool AsmParser::parseDirectiveBundleUnlock() { bool AsmParser::parseDirectiveSpace(StringRef IDVal) { checkForValidSection(); - int64_t NumBytes; - if (parseAbsoluteExpression(NumBytes)) + SMLoc NumBytesLoc = Lexer.getLoc(); + const MCExpr *NumBytes; + if (parseExpression(NumBytes)) return true; int64_t FillExpr = 0; @@ -4077,12 +4065,8 @@ bool AsmParser::parseDirectiveSpace(StringRef IDVal) { Lex(); - if (NumBytes <= 0) - return TokError("invalid number of bytes in '" + Twine(IDVal) + - "' directive"); - // FIXME: Sometimes the fill expr is 'nop' if it isn't supplied, instead of 0. - getStreamer().EmitFill(NumBytes, FillExpr); + getStreamer().emitFill(*NumBytes, FillExpr, NumBytesLoc); return false; } |