aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-03-19 09:28:12 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-03-19 09:28:12 +0000
commit87190c473c216e481e0a70475577e496b3a3449e (patch)
tree921748977bad22a264ce9e3b6ddf7bad3b4e4dd6 /lib
parentb1e98945e4b107eb3f2ac1b54706c49864842dc4 (diff)
downloadexternal_llvm-87190c473c216e481e0a70475577e496b3a3449e.zip
external_llvm-87190c473c216e481e0a70475577e496b3a3449e.tar.gz
external_llvm-87190c473c216e481e0a70475577e496b3a3449e.tar.bz2
MCAssembler: Move ApplyFixup to the TargetAsmBackend, this is a target specific not object writer specific task.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98947 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/MCAssembler.cpp13
-rw-r--r--lib/Target/X86/X86AsmBackend.cpp26
2 files changed, 27 insertions, 12 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 500f23f..c4c3a8a 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -930,17 +930,6 @@ public:
OS << StringTable.str();
}
}
-
- void ApplyFixup(const MCAsmFixup &Fixup, MCDataFragment &DF,
- uint64_t FixedValue) {
- unsigned Size = 1 << getFixupKindLog2Size(Fixup.Kind);
-
- // FIXME: Endianness assumption.
- assert(Fixup.Offset + Size <= DF.getContents().size() &&
- "Invalid fixup offset!");
- for (unsigned i = 0; i != Size; ++i)
- DF.getContents()[Fixup.Offset + i] = uint8_t(FixedValue >> (i * 8));
- }
};
/* *** */
@@ -1475,7 +1464,7 @@ void MCAssembler::Finish() {
MOW.RecordRelocation(*this, *DF, Fixup, Target, FixedValue);
}
- MOW.ApplyFixup(Fixup, *DF, FixedValue);
+ getBackend().ApplyFixup(Fixup, *DF, FixedValue);
}
}
}
diff --git a/lib/Target/X86/X86AsmBackend.cpp b/lib/Target/X86/X86AsmBackend.cpp
index d7a9e1a..fec5638 100644
--- a/lib/Target/X86/X86AsmBackend.cpp
+++ b/lib/Target/X86/X86AsmBackend.cpp
@@ -9,6 +9,8 @@
#include "llvm/Target/TargetAsmBackend.h"
#include "X86.h"
+#include "X86FixupKinds.h"
+#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetAsmBackend.h"
@@ -16,10 +18,34 @@ using namespace llvm;
namespace {
+static unsigned getFixupKindLog2Size(unsigned Kind) {
+ switch (Kind) {
+ default: assert(0 && "invalid fixup kind!");
+ case X86::reloc_pcrel_1byte:
+ case FK_Data_1: return 0;
+ case FK_Data_2: return 1;
+ case X86::reloc_pcrel_4byte:
+ case X86::reloc_riprel_4byte:
+ case X86::reloc_riprel_4byte_movq_load:
+ case FK_Data_4: return 2;
+ case FK_Data_8: return 3;
+ }
+}
+
class X86AsmBackend : public TargetAsmBackend {
public:
X86AsmBackend(const Target &T)
: TargetAsmBackend(T) {}
+
+ void ApplyFixup(const MCAsmFixup &Fixup, MCDataFragment &DF,
+ uint64_t Value) const {
+ unsigned Size = 1 << getFixupKindLog2Size(Fixup.Kind);
+
+ assert(Fixup.Offset + Size <= DF.getContents().size() &&
+ "Invalid fixup offset!");
+ for (unsigned i = 0; i != Size; ++i)
+ DF.getContents()[Fixup.Offset + i] = uint8_t(Value >> (i * 8));
+ }
};
class DarwinX86AsmBackend : public X86AsmBackend {