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
This commit is contained in:
Daniel Dunbar
2010-02-09 22:59:55 +00:00
parent 1f8075d7d2
commit 73c557458c
6 changed files with 180 additions and 7 deletions
+20 -1
View File
@@ -944,6 +944,24 @@ public:
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 @@ public:
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