aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-06-25 21:03:18 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-06-25 21:03:18 +0000
commit304f6a48b1232bdad8b2c0dff7c08d677826ef86 (patch)
tree2bdb6e74fcbc17a69f2d97bfab7d694a1fc68ab9 /lib/MC
parent1e249e3705bccd20d72d9131e9f904dc10595c02 (diff)
downloadexternal_llvm-304f6a48b1232bdad8b2c0dff7c08d677826ef86.zip
external_llvm-304f6a48b1232bdad8b2c0dff7c08d677826ef86.tar.gz
external_llvm-304f6a48b1232bdad8b2c0dff7c08d677826ef86.tar.bz2
MC: Truncate values when printing, to keep 'as' happy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74201 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r--lib/MC/MCAsmStreamer.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp
index f1f5a64..e38f2b3 100644
--- a/lib/MC/MCAsmStreamer.cpp
+++ b/lib/MC/MCAsmStreamer.cpp
@@ -61,7 +61,7 @@ namespace {
}
/// Allow printing values directly to a raw_ostream.
-inline raw_ostream &operator<<(raw_ostream &os, const MCValue &Value) {
+static inline raw_ostream &operator<<(raw_ostream &os, const MCValue &Value) {
if (Value.getSymA()) {
os << Value.getSymA()->getName();
if (Value.getSymB())
@@ -76,6 +76,16 @@ inline raw_ostream &operator<<(raw_ostream &os, const MCValue &Value) {
return os;
}
+static inline int64_t truncateToSize(int64_t Value, unsigned Bytes) {
+ assert(Bytes && "Invalid size!");
+ return Value & ((uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
+}
+
+static inline MCValue truncateToSize(const MCValue &Value, unsigned Bytes) {
+ return MCValue::get(Value.getSymA(), Value.getSymB(),
+ truncateToSize(Value.getCst(), Bytes));
+}
+
void MCAsmStreamer::SwitchSection(MCSection *Section) {
if (Section != CurSection) {
CurSection = Section;
@@ -148,7 +158,7 @@ void MCAsmStreamer::EmitValue(const MCValue &Value, unsigned Size) {
case 8: OS << ".quad"; break;
}
- OS << ' ' << Value << '\n';
+ OS << ' ' << truncateToSize(Value, Size) << '\n';
}
void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
@@ -169,7 +179,7 @@ void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
OS << ' ' << Pow2;
- OS << ", " << Value;
+ OS << ", " << truncateToSize(Value, ValueSize);
if (MaxBytesToEmit)
OS << ", " << MaxBytesToEmit;
OS << '\n';