summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCObjectStreamer.cpp
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2016-05-25 22:47:51 +0000
committerPetr Hosek <phosek@chromium.org>2016-05-25 22:47:51 +0000
commite25837528b677fb8f9181c2bf8c8d06c2f43da24 (patch)
treee5888b230cbb4bc522579d3a7a181ededce9e124 /llvm/lib/MC/MCObjectStreamer.cpp
parent6b93bf5783a1dd7b5535cff5eedbe2d965d90ac0 (diff)
downloadbcm5719-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/MCObjectStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCObjectStreamer.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index b90f0a80cfe..bf7d0f241c0 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -20,6 +20,7 @@
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
@@ -496,6 +497,43 @@ void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
insert(new MCFillFragment(FillValue, NumBytes));
}
+void MCObjectStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
+ SMLoc Loc) {
+ MCDataFragment *DF = getOrCreateDataFragment();
+ flushPendingLabels(DF, DF->getContents().size());
+
+ int64_t IntNumBytes;
+ if (!NumBytes.evaluateAsAbsolute(IntNumBytes, getAssembler())) {
+ getContext().reportError(Loc, "expected absolute expression");
+ return;
+ }
+
+ if (IntNumBytes <= 0) {
+ getContext().reportError(Loc, "invalid number of bytes");
+ return;
+ }
+
+ EmitFill(IntNumBytes, FillValue);
+}
+
+void MCObjectStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
+ int64_t Expr, SMLoc Loc) {
+ int64_t IntNumValues;
+ if (!NumValues.evaluateAsAbsolute(IntNumValues, getAssembler())) {
+ getContext().reportError(Loc, "expected absolute expression");
+ return;
+ }
+
+ if (IntNumValues < 0) {
+ getContext().getSourceManager()->PrintMessage(
+ Loc, SourceMgr::DK_Warning,
+ "'.fill' directive with negative repeat count has no effect");
+ return;
+ }
+
+ MCStreamer::emitFill(IntNumValues, Size, Expr);
+}
+
void MCObjectStreamer::FinishImpl() {
// If we are generating dwarf for assembly source files dump out the sections.
if (getContext().getGenDwarfForAssembly())
OpenPOWER on IntegriCloud