MC: First cut at MCFixup, for getting fixup/relocation information out of an MCCodeEmitter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95708 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp
index 0cfb0cb..7ee2223 100644
--- a/lib/Target/X86/X86CodeEmitter.cpp
+++ b/lib/Target/X86/X86CodeEmitter.cpp
@@ -944,6 +944,24 @@
delete DummyF;
}
+ unsigned getNumFixupKinds() const {
+ return 5;
+ }
+
+ MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
+ static MCFixupKindInfo Infos[] = {
+ { "reloc_pcrel_word", 0, 4 * 8 },
+ { "reloc_picrel_word", 0, 4 * 8 },
+ { "reloc_absolute_word", 0, 4 * 8 },
+ { "reloc_absolute_word_sext", 0, 4 * 8 },
+ { "reloc_absolute_dword", 0, 8 * 8 }
+ };
+
+ assert(Kind >= FirstTargetFixupKind && Kind < MaxTargetFixupKind &&
+ "Invalid kind!");
+ return Infos[Kind - FirstTargetFixupKind];
+ }
+
bool AddRegToInstr(const MCInst &MI, MachineInstr *Instr,
unsigned Start) const {
if (Start + 1 > MI.getNumOperands())
@@ -997,7 +1015,8 @@
AddRegToInstr(MI, Instr, Start + 4));
}
- void EncodeInstruction(const MCInst &MI, raw_ostream &OS) const {
+ void EncodeInstruction(const MCInst &MI, raw_ostream &OS,
+ SmallVectorImpl<MCFixup> &Fixups) const {
// Don't look yet!
// Convert the MCInst to a MachineInstr so we can (ab)use the regular