summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCLinkerOptimizationHint.cpp
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2014-03-29 07:34:53 +0000
committerTim Northover <tnorthover@apple.com>2014-03-29 07:34:53 +0000
commit53d32518512bb30d0c43376bdd334ddfa0dbcd64 (patch)
treeb5df1bf6cf477afa53cf56c89c5fe8d51dbf5eff /llvm/lib/MC/MCLinkerOptimizationHint.cpp
parent5627670e8429c811032971211cfe3da89f0221b4 (diff)
downloadbcm5719-llvm-53d32518512bb30d0c43376bdd334ddfa0dbcd64.tar.gz
bcm5719-llvm-53d32518512bb30d0c43376bdd334ddfa0dbcd64.zip
MachO: Add linker-optimisation hint framework to MC.
Another part of the ARM64 backend (so tests will be following soon). This is currently used by the linker to relax adrp/ldr pairs into nops where possible, though could well be more broadly applicable. llvm-svn: 205084
Diffstat (limited to 'llvm/lib/MC/MCLinkerOptimizationHint.cpp')
-rw-r--r--llvm/lib/MC/MCLinkerOptimizationHint.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCLinkerOptimizationHint.cpp b/llvm/lib/MC/MCLinkerOptimizationHint.cpp
new file mode 100644
index 00000000000..628a6156fd8
--- /dev/null
+++ b/llvm/lib/MC/MCLinkerOptimizationHint.cpp
@@ -0,0 +1,30 @@
+//===-- llvm/MC/MCLinkerOptimizationHint.cpp ----- LOH handling -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/MC/MCLinkerOptimizationHint.h"
+#include "llvm/MC/MCAsmLayout.h"
+#include "llvm/Support/LEB128.h"
+#include "llvm/MC/MCStreamer.h"
+
+using namespace llvm;
+
+namespace llvm {
+template<>
+void MCLOHDirective::Emit_impl(raw_ostream &OutStream,
+ const MachObjectWriter &ObjWriter,
+ const MCAsmLayout &Layout) const {
+ const MCAssembler &Asm = Layout.getAssembler();
+ encodeULEB128(Kind, OutStream);
+ encodeULEB128(Args.size(), OutStream);
+ for (LOHArgs::const_iterator It = Args.begin(), EndIt = Args.end();
+ It != EndIt; ++It)
+ encodeULEB128(ObjWriter.getSymbolAddress(&Asm.getSymbolData(**It), Layout),
+ OutStream);
+}
+} // end namespace llvm
OpenPOWER on IntegriCloud