diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-12-03 02:54:21 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-12-03 02:54:21 +0000 |
| commit | 4c70eeaf3302bd2f7a3e7800cbf8cf9ae7eba935 (patch) | |
| tree | 8baf6120c9770da81773ac30c641db5148b3203a /llvm/lib | |
| parent | 4e7eb12f6f728eb4193a57642205d3c9dbaaaf82 (diff) | |
| download | bcm5719-llvm-4c70eeaf3302bd2f7a3e7800cbf8cf9ae7eba935.tar.gz bcm5719-llvm-4c70eeaf3302bd2f7a3e7800cbf8cf9ae7eba935.zip | |
Make EmitIntValue more efficient and more like what we do for leb128. The
difference is much smaller (about 0.3s) but significant.
llvm-svn: 120787
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/MC/MCAsmStreamer.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 16 | ||||
| -rw-r--r-- | llvm/lib/MC/MCStreamer.cpp | 7 |
3 files changed, 20 insertions, 10 deletions
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index 5c9a347c3c0..7189a90406e 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -152,6 +152,8 @@ public: virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace, bool UseSet = false); + virtual void EmitIntValue(uint64_t Value, unsigned Size, + unsigned AddrSpace = 0); virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0); @@ -504,6 +506,11 @@ void MCAsmStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) { EmitEOL(); } +void MCAsmStreamer::EmitIntValue(uint64_t Value, unsigned Size, + unsigned AddrSpace) { + EmitValue(MCConstantExpr::Create(Value, getContext()), Size, AddrSpace); +} + void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size, unsigned AddrSpace, bool UseSet) { assert(CurSection && "Cannot emit contents before setting section!"); diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index f6753e3d1e1..1538a589966 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -83,16 +83,14 @@ void MCObjectStreamer::EmitValue(const MCExpr *Value, unsigned Size, // Avoid fixups when possible. int64_t AbsValue; - if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue)) { - // FIXME: Endianness assumption. - for (unsigned i = 0; i != Size; ++i) - DF->getContents().push_back(uint8_t(AbsValue >> (i * 8))); - } else { - DF->addFixup(MCFixup::Create(DF->getContents().size(), - AddValueSymbols(Value), - MCFixup::getKindForSize(Size, false))); - DF->getContents().resize(DF->getContents().size() + Size, 0); + if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue, &getAssembler())) { + EmitIntValue(AbsValue, Size, AddrSpace); + return; } + DF->addFixup(MCFixup::Create(DF->getContents().size(), + AddValueSymbols(Value), + MCFixup::getKindForSize(Size, false))); + DF->getContents().resize(DF->getContents().size() + Size, 0); } void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) { diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index 38ace6b2ee2..6df4ae44e40 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -46,7 +46,12 @@ void MCStreamer::EmitDwarfSetLineAddr(int64_t LineDelta, /// pass in a MCExpr for constant integers. void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size, unsigned AddrSpace) { - EmitValue(MCConstantExpr::Create(Value, getContext()), Size, AddrSpace); + assert(Size <= 8); + char buf[8]; + // FIXME: Endianness assumption. + for (unsigned i = 0; i != Size; ++i) + buf[i] = uint8_t(Value >> (i * 8)); + EmitBytes(StringRef(buf, Size), AddrSpace); } /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the |

