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/X86MCCodeEmitter.cpp b/lib/Target/X86/X86MCCodeEmitter.cpp
index 7e9130b..679abb3 100644
--- a/lib/Target/X86/X86MCCodeEmitter.cpp
+++ b/lib/Target/X86/X86MCCodeEmitter.cpp
@@ -33,6 +33,24 @@
}
~X86MCCodeEmitter() {}
+
+ 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];
+ }
static unsigned GetX86RegNum(const MCOperand &MO) {
return X86RegisterInfo::getX86RegNum(MO.getReg());
@@ -75,7 +93,8 @@
unsigned RegOpcodeField, intptr_t PCAdj,
raw_ostream &OS) const;
- void EncodeInstruction(const MCInst &MI, raw_ostream &OS) const;
+ void EncodeInstruction(const MCInst &MI, raw_ostream &OS,
+ SmallVectorImpl<MCFixup> &Fixups) const;
};
@@ -379,7 +398,8 @@
}
void X86MCCodeEmitter::
-EncodeInstruction(const MCInst &MI, raw_ostream &OS) const {
+EncodeInstruction(const MCInst &MI, raw_ostream &OS,
+ SmallVectorImpl<MCFixup> &Fixups) const {
unsigned Opcode = MI.getOpcode();
const TargetInstrDesc &Desc = TII.get(Opcode);
unsigned TSFlags = Desc.TSFlags;