[llvm-commits] [llvm] r74201 - /llvm/trunk/lib/MC/MCAsmStreamer.cpp
Daniel Dunbar
daniel at zuster.org
Thu Jun 25 14:03:18 PDT 2009
Author: ddunbar
Date: Thu Jun 25 16:03:18 2009
New Revision: 74201
URL: http://llvm.org/viewvc/llvm-project?rev=74201&view=rev
Log:
MC: Truncate values when printing, to keep 'as' happy.
Modified:
llvm/trunk/lib/MC/MCAsmStreamer.cpp
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=74201&r1=74200&r2=74201&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Thu Jun 25 16:03:18 2009
@@ -61,7 +61,7 @@
}
/// 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 @@
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 @@
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 @@
OS << ' ' << Pow2;
- OS << ", " << Value;
+ OS << ", " << truncateToSize(Value, ValueSize);
if (MaxBytesToEmit)
OS << ", " << MaxBytesToEmit;
OS << '\n';
More information about the llvm-commits
mailing list