diff options
author | Reid Kleckner <rnk@google.com> | 2016-05-25 23:29:08 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-05-25 23:29:08 +0000 |
commit | 63d3d6df7d31a926a64dd15ce81d3e20002b4555 (patch) | |
tree | c45ab9c238f1f7c38b0aed28811afa1538646232 /llvm/lib/MC/MCParser | |
parent | 684ec17cd9d5828f549c6ea5d6cc6395f68cabdf (diff) | |
download | bcm5719-llvm-63d3d6df7d31a926a64dd15ce81d3e20002b4555.tar.gz bcm5719-llvm-63d3d6df7d31a926a64dd15ce81d3e20002b4555.zip |
Revert "[MC] Support symbolic expressions in assembly directives"
This reverts commit r270786, it causes the directive_fill.s to fail.
llvm-svn: 270795
Diffstat (limited to 'llvm/lib/MC/MCParser')
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index f7de55002b1..7da00e89d78 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -2738,9 +2738,8 @@ bool AsmParser::parseDirectiveRealValue(const fltSemantics &Semantics) { bool AsmParser::parseDirectiveZero() { checkForValidSection(); - SMLoc NumBytesLoc = Lexer.getLoc(); - const MCExpr *NumBytes; - if (parseExpression(NumBytes)) + int64_t NumBytes; + if (parseAbsoluteExpression(NumBytes)) return true; int64_t Val = 0; @@ -2755,7 +2754,7 @@ bool AsmParser::parseDirectiveZero() { Lex(); - getStreamer().emitFill(*NumBytes, Val, NumBytesLoc); + getStreamer().EmitFill(NumBytes, Val); return false; } @@ -2765,11 +2764,17 @@ bool AsmParser::parseDirectiveZero() { bool AsmParser::parseDirectiveFill() { checkForValidSection(); - SMLoc NumValuesLoc = Lexer.getLoc(); - const MCExpr *NumValues; - if (parseExpression(NumValues)) + SMLoc RepeatLoc = getLexer().getLoc(); + int64_t NumValues; + if (parseAbsoluteExpression(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; @@ -2801,7 +2806,7 @@ bool AsmParser::parseDirectiveFill() { if (FillSize < 0) { Warning(SizeLoc, "'.fill' directive with negative size has no effect"); - NumValues = MCConstantExpr::create(0, getStreamer().getContext()); + NumValues = 0; } if (FillSize > 8) { Warning(SizeLoc, "'.fill' directive with size greater than 8 has been truncated to 8"); @@ -2811,7 +2816,15 @@ bool AsmParser::parseDirectiveFill() { if (!isUInt<32>(FillExpr) && FillSize > 4) Warning(ExprLoc, "'.fill' directive pattern has been truncated to 32-bits"); - getStreamer().emitFill(*NumValues, FillSize, FillExpr, NumValuesLoc); + 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); + } + } return false; } @@ -4045,9 +4058,8 @@ bool AsmParser::parseDirectiveBundleUnlock() { bool AsmParser::parseDirectiveSpace(StringRef IDVal) { checkForValidSection(); - SMLoc NumBytesLoc = Lexer.getLoc(); - const MCExpr *NumBytes; - if (parseExpression(NumBytes)) + int64_t NumBytes; + if (parseAbsoluteExpression(NumBytes)) return true; int64_t FillExpr = 0; @@ -4065,8 +4077,12 @@ 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, NumBytesLoc); + getStreamer().EmitFill(NumBytes, FillExpr); return false; } |