diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-06-25 21:03:18 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-06-25 21:03:18 +0000 |
| commit | 188e87fa2148939985eea5826ca8804cc41b44c8 (patch) | |
| tree | 4de9013a632d8498a0d10b37a8c04c4099487aa2 /llvm/lib | |
| parent | c7ea8df67e4cc2173270e4923dfcf4f1ed135032 (diff) | |
| download | bcm5719-llvm-188e87fa2148939985eea5826ca8804cc41b44c8.tar.gz bcm5719-llvm-188e87fa2148939985eea5826ca8804cc41b44c8.zip | |
MC: Truncate values when printing, to keep 'as' happy.
llvm-svn: 74201
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/MC/MCAsmStreamer.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index f1f5a648bbf..e38f2b3d8bc 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/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'; |

