diff options
Diffstat (limited to 'contrib/llvm/lib/MC/MCLinkerOptimizationHint.cpp')
-rw-r--r-- | contrib/llvm/lib/MC/MCLinkerOptimizationHint.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/contrib/llvm/lib/MC/MCLinkerOptimizationHint.cpp b/contrib/llvm/lib/MC/MCLinkerOptimizationHint.cpp index 5f6a579..f71fc78 100644 --- a/contrib/llvm/lib/MC/MCLinkerOptimizationHint.cpp +++ b/contrib/llvm/lib/MC/MCLinkerOptimizationHint.cpp @@ -10,6 +10,7 @@ #include "llvm/MC/MCLinkerOptimizationHint.h" #include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCAssembler.h" +#include "llvm/MC/MCMachObjectWriter.h" #include "llvm/Support/LEB128.h" using namespace llvm; @@ -27,7 +28,31 @@ void MCLOHDirective::emit_impl(raw_ostream &OutStream, const MCAsmLayout &Layout) const { encodeULEB128(Kind, OutStream); encodeULEB128(Args.size(), OutStream); - for (LOHArgs::const_iterator It = Args.begin(), EndIt = Args.end(); - It != EndIt; ++It) - encodeULEB128(ObjWriter.getSymbolAddress(**It, Layout), OutStream); + for (const MCSymbol *Arg : Args) + encodeULEB128(ObjWriter.getSymbolAddress(*Arg, Layout), OutStream); +} + +void MCLOHDirective::emit(MachObjectWriter &ObjWriter, + const MCAsmLayout &Layout) const { + raw_ostream &OutStream = ObjWriter.getStream(); + emit_impl(OutStream, ObjWriter, Layout); +} + +uint64_t MCLOHDirective::getEmitSize(const MachObjectWriter &ObjWriter, + const MCAsmLayout &Layout) const { + class raw_counting_ostream : public raw_ostream { + uint64_t Count; + + void write_impl(const char *, size_t size) override { Count += size; } + + uint64_t current_pos() const override { return Count; } + + public: + raw_counting_ostream() : Count(0) {} + ~raw_counting_ostream() override { flush(); } + }; + + raw_counting_ostream OutStream; + emit_impl(OutStream, ObjWriter, Layout); + return OutStream.tell(); } |